diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 848cc08bc..4af7841e0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -116,7 +116,7 @@
= 23) {
getWindow().setStatusBarColor(Color.TRANSPARENT);
- getWindow().getDecorView().setSystemUiVisibility(Utils.isDarkModeEnabled(this) ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ getWindow().getDecorView().setSystemUiVisibility(darkMode ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// icons are always white back then
- getWindow().setStatusBarColor(Utils.isDarkModeEnabled(this) ? Color.TRANSPARENT : Color.argb(127, 0, 0, 0));
+ getWindow().setStatusBarColor(darkMode ? Color.TRANSPARENT : Color.argb(127, 0, 0, 0));
}
// XXX android 9 and below has a nasty rendering bug if the theme was patched earlier
Utils.postPatchColors(this);
diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
index 14c6aaf1c..95f239495 100644
--- a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
+++ b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
@@ -690,9 +690,22 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
);
// Fix theming
+
int colorPrimary = MaterialColors.getColor(this, R.attr.colorPrimary, ContextCompat.getColor(this, R.color.md_theme_light_primary));
- mCropperOptions.setToolbarColor(colorPrimary);
- mCropperOptions.setStatusBarColor(colorPrimary);
+ int colorOnPrimary = MaterialColors.getColor(this, R.attr.colorOnPrimary, ContextCompat.getColor(this, R.color.md_theme_light_onPrimary));
+ int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface, ContextCompat.getColor(this, R.color.md_theme_light_surface));
+ int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
+ int colorBackground = MaterialColors.getColor(this, android.R.attr.colorBackground, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
+ mCropperOptions.setToolbarColor(colorSurface);
+ mCropperOptions.setStatusBarColor(colorSurface);
+ mCropperOptions.setToolbarWidgetColor(colorOnSurface);
+ mCropperOptions.setRootViewBackgroundColor(colorBackground);
+ // set tool tip to be the darker of primary color
+ if (Utils.isDarkModeEnabled(this)) {
+ mCropperOptions.setActiveControlsWidgetColor(colorOnPrimary);
+ } else {
+ mCropperOptions.setActiveControlsWidgetColor(colorPrimary);
+ }
}
@Override
@@ -906,7 +919,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
protected void setColorFromIcon() {
Object icon = thumbnail.getTag();
if (icon != null && (icon instanceof Bitmap)) {
- updateTempState(LoyaltyCardField.headerColor, new Palette.Builder((Bitmap) icon).generate().getDominantColor(tempLoyaltyCard.headerColor != null ? tempLoyaltyCard.headerColor : R.attr.colorPrimary));
+ updateTempState(LoyaltyCardField.headerColor, new Palette.Builder((Bitmap) icon).generate().getDominantColor(tempLoyaltyCard.headerColor != null ? tempLoyaltyCard.headerColor : R.attr.colorPrimary));
} else {
Log.d("setColorFromIcon", "attempting header color change from icon but icon does not exist");
}
@@ -1391,13 +1404,13 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
}
}
}
- mCropperLauncher.launch(
- UCrop.of(
- sourceUri,
- destUri
- ).withOptions(mCropperOptions)
- .getIntent(this)
- );
+ Intent ucropIntent = UCrop.of(
+ sourceUri,
+ destUri
+ ).withOptions(mCropperOptions)
+ .getIntent(this);
+ ucropIntent.setClass(this, UCropWrapper.class);
+ mCropperLauncher.launch(ucropIntent);
}
private void generateBarcode() {
diff --git a/app/src/main/java/protect/card_locker/UCropWrapper.java b/app/src/main/java/protect/card_locker/UCropWrapper.java
new file mode 100644
index 000000000..99b7df367
--- /dev/null
+++ b/app/src/main/java/protect/card_locker/UCropWrapper.java
@@ -0,0 +1,63 @@
+package protect.card_locker;
+
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatImageView;
+import androidx.core.content.ContextCompat;
+import androidx.core.graphics.ColorUtils;
+
+import com.google.android.material.color.MaterialColors;
+import com.yalantis.ucrop.UCropActivity;
+
+public class UCropWrapper extends UCropActivity {
+ @Override
+ protected void onPostCreate(@Nullable Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ boolean darkMode = Utils.isDarkModeEnabled(this);
+ // setup status bar to look like the rest of the app
+ if (Build.VERSION.SDK_INT >= 23) {
+ getWindow().getDecorView().setSystemUiVisibility(darkMode ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ } else {
+ // icons are always white back then
+ if (!darkMode) {
+ getWindow().setStatusBarColor(ColorUtils.compositeColors(Color.argb(127, 0, 0, 0), getWindow().getStatusBarColor()));
+ }
+ }
+
+ // find and check views that we wish to color modify
+ // for when we update ucrop or switch to another cropper
+ View check = findViewById(com.yalantis.ucrop.R.id.wrapper_controls);
+ if (check instanceof FrameLayout) {
+ FrameLayout controls = (FrameLayout) check;
+ check = findViewById(com.yalantis.ucrop.R.id.wrapper_states);
+ if (check instanceof LinearLayout) {
+ LinearLayout states = (LinearLayout) check;
+ for (int i = 0; i < controls.getChildCount(); i++) {
+ check = controls.getChildAt(i);
+ if (check instanceof AppCompatImageView) {
+ AppCompatImageView controlsBackgroundImage = (AppCompatImageView) check;
+ // everything gathered and are as expected, now perform color patching
+ Utils.patchColors(this);
+ int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface, ContextCompat.getColor(this, R.color.md_theme_light_surface));
+ int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
+
+ Drawable controlsBackgroundImageDrawable = controlsBackgroundImage.getBackground();
+ controlsBackgroundImageDrawable.mutate();
+ controlsBackgroundImageDrawable.setTint(darkMode ? colorOnSurface : colorSurface);
+ controlsBackgroundImage.setBackgroundDrawable(controlsBackgroundImageDrawable);
+
+ states.setBackgroundColor(darkMode ? colorSurface : colorOnSurface);
+ break;
+ }
+ }
+ }
+ }
+ }
+}