From 83ea6ffbf70275e6560ab5e6eaeb270a084f946c Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 22 Aug 2021 16:16:27 +0200 Subject: [PATCH] Cleanups --- .gitignore | 1 + .../protect/card_locker/AboutActivity.java | 5 -- .../card_locker/BarcodeSelectorActivity.java | 5 -- .../card_locker/CatimaAppCompatActivity.java | 55 +++++++++++-------- .../card_locker/ImportExportActivity.java | 5 -- .../card_locker/LoyaltyCardEditActivity.java | 5 -- .../card_locker/LoyaltyCardViewActivity.java | 5 -- .../protect/card_locker/MainActivity.java | 5 -- .../card_locker/ManageGroupsActivity.java | 5 -- .../protect/card_locker/ScanActivity.java | 5 -- .../preferences/SettingsActivity.java | 5 -- build.gradle | 2 +- 12 files changed, 33 insertions(+), 70 deletions(-) diff --git a/.gitignore b/.gitignore index 7472a42d6..34b75ecae 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ captures/ **/release **/debug +app/*.log diff --git a/app/src/main/java/protect/card_locker/AboutActivity.java b/app/src/main/java/protect/card_locker/AboutActivity.java index 69ab5b1f0..0ab4f86cb 100644 --- a/app/src/main/java/protect/card_locker/AboutActivity.java +++ b/app/src/main/java/protect/card_locker/AboutActivity.java @@ -21,11 +21,6 @@ public class AboutActivity extends CatimaAppCompatActivity { private static final String TAG = "Catima"; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java index e70357ed9..3d2c9c668 100644 --- a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java +++ b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java @@ -63,11 +63,6 @@ public class BarcodeSelectorActivity extends CatimaAppCompatActivity private Map> barcodeViewMap; private LinkedList barcodeGeneratorTasks = new LinkedList<>(); - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java b/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java index 569cc1630..791f1dc31 100644 --- a/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java +++ b/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java @@ -1,5 +1,6 @@ package protect.card_locker; +import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.util.TypedValue; @@ -11,34 +12,40 @@ public class CatimaAppCompatActivity extends AppCompatActivity { SharedPreferences pref; - @Override + @Override + protected void attachBaseContext(Context base) { + // Apply chosen language + super.attachBaseContext(Utils.updateBaseContextLocale(base)); + } + + @Override public Resources.Theme getTheme() { Resources.Theme theme = super.getTheme(); - pref = PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()); - String themeName = pref.getString("pref_theme_color", getString(R.string.settings_key_catima_theme)); - if(themeName.equals(getString(R.string.settings_key_brown_theme))){ - theme.applyStyle(R.style.AppTheme_brown, true); - }else if(themeName.equals(getString(R.string.settings_key_pink_theme))){ - theme.applyStyle(R.style.AppTheme_pink, true); - }else if(themeName.equals(getString(R.string.settings_key_magenta_theme))){ - theme.applyStyle(R.style.AppTheme_magenta, true); - }else if(themeName.equals(getString(R.string.settings_key_violet_theme))){ - theme.applyStyle(R.style.AppTheme_violet, true); - }else if(themeName.equals(getString(R.string.settings_key_blue_theme))){ - theme.applyStyle(R.style.AppTheme_blue, true); - }else if(themeName.equals(getString(R.string.settings_key_sky_blue_theme))){ - theme.applyStyle(R.style.AppTheme_sky_blue, true); - }else if(themeName.equals(getString(R.string.settings_key_green_theme))){ - theme.applyStyle(R.style.AppTheme_green, true); - }else if(themeName.equals(getString(R.string.settings_key_grey_theme))){ - theme.applyStyle(R.style.AppTheme_grey, true); - }else { - theme.applyStyle(R.style.AppTheme_NoActionBar, true); - } - // you could also use a switch if you have many themes that could apply + pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + String themeName = pref.getString("pref_theme_color", getString(R.string.settings_key_catima_theme)); + if (themeName.equals(getString(R.string.settings_key_brown_theme))){ + theme.applyStyle(R.style.AppTheme_brown, true); + } else if(themeName.equals(getString(R.string.settings_key_pink_theme))){ + theme.applyStyle(R.style.AppTheme_pink, true); + } else if(themeName.equals(getString(R.string.settings_key_magenta_theme))){ + theme.applyStyle(R.style.AppTheme_magenta, true); + } else if(themeName.equals(getString(R.string.settings_key_violet_theme))){ + theme.applyStyle(R.style.AppTheme_violet, true); + } else if(themeName.equals(getString(R.string.settings_key_blue_theme))){ + theme.applyStyle(R.style.AppTheme_blue, true); + } else if(themeName.equals(getString(R.string.settings_key_sky_blue_theme))){ + theme.applyStyle(R.style.AppTheme_sky_blue, true); + } else if(themeName.equals(getString(R.string.settings_key_green_theme))){ + theme.applyStyle(R.style.AppTheme_green, true); + } else if(themeName.equals(getString(R.string.settings_key_grey_theme))){ + theme.applyStyle(R.style.AppTheme_grey, true); + } else { + theme.applyStyle(R.style.AppTheme_NoActionBar, true); + } + return theme; } + public int getThemeColor(){ TypedValue typedValue = new TypedValue(); Resources.Theme theme = getTheme(); diff --git a/app/src/main/java/protect/card_locker/ImportExportActivity.java b/app/src/main/java/protect/card_locker/ImportExportActivity.java index 73b6d7149..01edb063a 100644 --- a/app/src/main/java/protect/card_locker/ImportExportActivity.java +++ b/app/src/main/java/protect/card_locker/ImportExportActivity.java @@ -49,11 +49,6 @@ public class ImportExportActivity extends CatimaAppCompatActivity private String importAlertMessage; private DataFormat importDataFormat; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java index ba5699e4f..b0ace1710 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java @@ -140,11 +140,6 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity LoyaltyCard tempLoyaltyCard; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - private static LoyaltyCard updateTempState(LoyaltyCard loyaltyCard, LoyaltyCardField fieldName, Object value) { return new LoyaltyCard( (int) (fieldName == LoyaltyCardField.id ? value : loyaltyCard.id), diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 11a484104..774e32780 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -105,11 +105,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity IMAGE_BACK } - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - private void extractIntentFields(Intent intent) { final Bundle b = intent.getExtras(); diff --git a/app/src/main/java/protect/card_locker/MainActivity.java b/app/src/main/java/protect/card_locker/MainActivity.java index 14b3367f6..eecf007da 100644 --- a/app/src/main/java/protect/card_locker/MainActivity.java +++ b/app/src/main/java/protect/card_locker/MainActivity.java @@ -50,11 +50,6 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard private View mHelpText; private View mNoMatchingCardsText; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - private ActionMode.Callback mCurrentActionModeCallback = new ActionMode.Callback() { @Override diff --git a/app/src/main/java/protect/card_locker/ManageGroupsActivity.java b/app/src/main/java/protect/card_locker/ManageGroupsActivity.java index 93199ff3d..6f8943141 100644 --- a/app/src/main/java/protect/card_locker/ManageGroupsActivity.java +++ b/app/src/main/java/protect/card_locker/ManageGroupsActivity.java @@ -30,11 +30,6 @@ public class ManageGroupsActivity extends CatimaAppCompatActivity implements Gro private RecyclerView mGroupList; GroupCursorAdapter mAdapter; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/protect/card_locker/ScanActivity.java b/app/src/main/java/protect/card_locker/ScanActivity.java index 625bd9091..e2dd9107c 100644 --- a/app/src/main/java/protect/card_locker/ScanActivity.java +++ b/app/src/main/java/protect/card_locker/ScanActivity.java @@ -39,11 +39,6 @@ public class ScanActivity extends CatimaAppCompatActivity { private String addGroup; private boolean torch = false; - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - private void extractIntentFields(Intent intent) { final Bundle b = intent.getExtras(); cardId = b != null ? b.getString(LoyaltyCardEditActivity.BUNDLE_CARDID) : null; diff --git a/app/src/main/java/protect/card_locker/preferences/SettingsActivity.java b/app/src/main/java/protect/card_locker/preferences/SettingsActivity.java index 9a7d8b2d9..7fbaf0418 100644 --- a/app/src/main/java/protect/card_locker/preferences/SettingsActivity.java +++ b/app/src/main/java/protect/card_locker/preferences/SettingsActivity.java @@ -27,11 +27,6 @@ import protect.card_locker.Utils; public class SettingsActivity extends CatimaAppCompatActivity { - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(Utils.updateBaseContextLocale(base)); - } - @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/build.gradle b/build.gradle index 80f0a7843..39dfcc99d 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.0.0' + classpath 'com.android.tools.build:gradle:7.0.1' classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.0' // NOTE: Do not place your application dependencies here; they belong