Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-04-01 15:52:37 +0300
committerStefan Niedermann <info@niedermann.it>2021-04-01 15:52:37 +0300
commitc3debd3da5394375c156ac9ebf73547154b8feba (patch)
treea20c316024848ac364c0177894a5b08f7cc41634 /app/src/main
parent5944fbacf4d261a127f862862eeda5ef660a7e02 (diff)
Remove branding toggle
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java8
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java8
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java2
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedPreferenceCategory.java12
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java6
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java9
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java29
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java5
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_19_20.java19
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java14
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/preferences.xml7
12 files changed, 47 insertions, 73 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java
index a9d88c32..c372c772 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java
@@ -37,11 +37,9 @@ public abstract class BrandedActivity extends AppCompatActivity implements Brand
getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
colorAccent = typedValue.data;
- if (BrandingUtil.isBrandingEnabled(this)) {
- @ColorInt final int mainColor = BrandingUtil.readBrandMainColor(this);
- @ColorInt final int textColor = BrandingUtil.readBrandTextColor(this);
- applyBrand(mainColor, textColor);
- }
+ @ColorInt final int mainColor = BrandingUtil.readBrandMainColor(this);
+ @ColorInt final int textColor = BrandingUtil.readBrandTextColor(this);
+ applyBrand(mainColor, textColor);
}
@Override
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java
index 63eb2a69..57d24adf 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java
@@ -14,11 +14,9 @@ public abstract class BrandedDialogFragment extends DialogFragment implements Br
@Nullable Context context = getContext();
if (context != null) {
- if (BrandingUtil.isBrandingEnabled(context)) {
- @ColorInt final int mainColor = BrandingUtil.readBrandMainColor(context);
- @ColorInt final int textColor = BrandingUtil.readBrandTextColor(context);
- applyBrand(mainColor, textColor);
- }
+ @ColorInt final int mainColor = BrandingUtil.readBrandMainColor(context);
+ @ColorInt final int textColor = BrandingUtil.readBrandTextColor(context);
+ applyBrand(mainColor, textColor);
}
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java
index 5752bff8..b134919c 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java
@@ -32,7 +32,7 @@ public abstract class BrandedFragment extends Fragment implements Branded {
colorPrimary = typedValue.data;
@Nullable Context context = getContext();
- if (context != null && BrandingUtil.isBrandingEnabled(context)) {
+ if (context != null) {
@ColorInt final int mainColor = BrandingUtil.readBrandMainColor(context);
@ColorInt final int textColor = BrandingUtil.readBrandTextColor(context);
applyBrand(mainColor, textColor);
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedPreferenceCategory.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedPreferenceCategory.java
index d2bcd274..7d75a412 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedPreferenceCategory.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedPreferenceCategory.java
@@ -34,13 +34,11 @@ public class BrandedPreferenceCategory extends PreferenceCategory {
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- if (BrandingUtil.isBrandingEnabled(getContext())) {
- final View v = holder.itemView.findViewById(android.R.id.title);
- @Nullable final Context context = getContext();
- if (context != null && v instanceof TextView) {
- @ColorInt final int mainColor = getSecondaryForegroundColorDependingOnTheme(context, BrandingUtil.readBrandMainColor(context));
- ((TextView) v).setTextColor(mainColor);
- }
+ final View v = holder.itemView.findViewById(android.R.id.title);
+ @Nullable final Context context = getContext();
+ if (context != null && v instanceof TextView) {
+ @ColorInt final int mainColor = getSecondaryForegroundColorDependingOnTheme(context, BrandingUtil.readBrandMainColor(context));
+ ((TextView) v).setTextColor(mainColor);
}
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java
index aabd3f04..1bb39297 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java
@@ -15,10 +15,8 @@ public class BrandedSnackbar {
@NonNull
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, @Snackbar.Duration int duration) {
final Snackbar snackbar = Snackbar.make(view, text, duration);
- if (BrandingUtil.isBrandingEnabled(view.getContext())) {
- int color = BrandingUtil.readBrandMainColor(view.getContext());
- snackbar.setActionTextColor(ColorUtil.INSTANCE.isColorDark(color) ? Color.WHITE : color);
- }
+ final int color = BrandingUtil.readBrandMainColor(view.getContext());
+ snackbar.setActionTextColor(ColorUtil.INSTANCE.isColorDark(color) ? Color.WHITE : color);
return snackbar;
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
index a3dd233c..de1f53d1 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java
@@ -61,13 +61,8 @@ public class BrandedSwitchPreference extends SwitchPreference implements Branded
@Override
public void applyBrand(@ColorInt int mainColor, @ColorInt int textColor) {
- if (BrandingUtil.isBrandingEnabled(getContext())) {
- this.mainColor = mainColor;
- this.textColor = textColor;
- } else {
- this.mainColor = getContext().getResources().getColor(R.color.defaultBrand);
- this.textColor = Color.WHITE;
- }
+ this.mainColor = mainColor;
+ this.textColor = textColor;
// onBindViewHolder is called after applyBrand, therefore we have to store the given values and apply them later.
applyBrand();
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
index c92cdf1f..d98eb8b0 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
@@ -33,43 +33,30 @@ public class BrandingUtil {
}
- public static boolean isBrandingEnabled(@NonNull Context context) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- return prefs.getBoolean(context.getString(R.string.pref_key_branding), true);
- }
-
@ColorInt
public static int readBrandMainColor(@NonNull Context context) {
- if (BrandingUtil.isBrandingEnabled(context)) {
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
- Log.v(TAG, "--- Read: shared_preference_theme_main");
- return sharedPreferences.getInt(pref_key_branding_main, context.getApplicationContext().getResources().getColor(R.color.defaultBrand));
- } else {
- return ContextCompat.getColor(context, R.color.defaultBrand);
- }
+ final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
+ Log.v(TAG, "--- Read: shared_preference_theme_main");
+ return sharedPreferences.getInt(pref_key_branding_main, context.getApplicationContext().getResources().getColor(R.color.defaultBrand));
}
@ColorInt
public static int readBrandTextColor(@NonNull Context context) {
- if (isBrandingEnabled(context)) {
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
- Log.v(TAG, "--- Read: shared_preference_theme_text");
- return sharedPreferences.getInt(pref_key_branding_text, Color.WHITE);
- } else {
- return Color.WHITE;
- }
+ final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
+ Log.v(TAG, "--- Read: shared_preference_theme_text");
+ return sharedPreferences.getInt(pref_key_branding_text, Color.WHITE);
}
public static void saveBrandColors(@NonNull Context context, @ColorInt int mainColor, @ColorInt int textColor) {
final int previousMainColor = readBrandMainColor(context);
final int previousTextColor = readBrandTextColor(context);
- SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
+ final SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
Log.v(TAG, "--- Write: shared_preference_theme_main" + " | " + mainColor);
Log.v(TAG, "--- Write: shared_preference_theme_text" + " | " + textColor);
editor.putInt(pref_key_branding_main, mainColor);
editor.putInt(pref_key_branding_text, textColor);
editor.apply();
- if (isBrandingEnabled(context) && context instanceof BrandedActivity) {
+ if (context instanceof BrandedActivity) {
if (mainColor != previousMainColor || textColor != previousTextColor) {
final BrandedActivity activity = (BrandedActivity) context;
activity.runOnUiThread(() -> ActivityCompat.recreate(activity));
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
index 46d36e1c..d84236cb 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java
@@ -16,6 +16,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_15_16;
import it.niedermann.owncloud.notes.persistence.migration.Migration_16_17;
import it.niedermann.owncloud.notes.persistence.migration.Migration_17_18;
import it.niedermann.owncloud.notes.persistence.migration.Migration_18_19;
+import it.niedermann.owncloud.notes.persistence.migration.Migration_19_20;
import it.niedermann.owncloud.notes.persistence.migration.Migration_4_5;
import it.niedermann.owncloud.notes.persistence.migration.Migration_5_6;
import it.niedermann.owncloud.notes.persistence.migration.Migration_6_7;
@@ -26,7 +27,7 @@ import it.niedermann.owncloud.notes.shared.util.DatabaseIndexUtil;
abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
- private static final int database_version = 19;
+ private static final int database_version = 20;
@NonNull
protected final Context context;
@@ -194,6 +195,8 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
new Migration_17_18(db);
case 18:
new Migration_18_19(context);
+ case 19:
+ new Migration_19_20(context);
}
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_19_20.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_19_20.java
new file mode 100644
index 00000000..20ebebfa
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_19_20.java
@@ -0,0 +1,19 @@
+package it.niedermann.owncloud.notes.persistence.migration;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import androidx.annotation.NonNull;
+import androidx.preference.PreferenceManager;
+
+public class Migration_19_20 {
+
+ /**
+ * Removes <code>branding</code> from {@link SharedPreferences} because we do no longer allow to disable it.
+ *
+ * @param context {@link Context}
+ */
+ public Migration_19_20(@NonNull Context context) {
+ PreferenceManager.getDefaultSharedPreferences(context).edit().remove("branding").apply();
+ }
+}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java
index fade8a74..d6fcf9f8 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/preferences/PreferencesFragment.java
@@ -44,20 +44,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
fontPref = findPreference(getString(R.string.pref_key_font));
- brandingPref = findPreference(getString(R.string.pref_key_branding));
- if (brandingPref != null) {
- brandingPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
- updateNoteListWidgets(requireContext());
- final Boolean branding = (Boolean) newValue;
- Log.v(TAG, "branding: " + branding);
- requireActivity().setResult(Activity.RESULT_OK);
- ActivityCompat.recreate(requireActivity());
- return true;
- });
- } else {
- Log.e(TAG, "Could not find preference with key: \"" + getString(R.string.pref_key_branding) + "\"");
- }
-
gridViewPref = findPreference(getString(R.string.pref_key_gridview));
if (gridViewPref != null) {
gridViewPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e607c780..9835feee 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -99,7 +99,6 @@
<string name="pref_key_note_mode" translatable="false">noteMode</string>
<string name="pref_key_theme" translatable="false">darkTheme</string>
<string name="pref_key_font" translatable="false">font</string>
- <string name="pref_key_branding" translatable="false">branding</string>
<string name="pref_key_gridview" translatable="false">gridview</string>
<string name="pref_key_font_size" translatable="false">fontSize</string>
<string name="pref_key_wifi_only" translatable="false">wifiOnly</string>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index f199636b..87773768 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -39,13 +39,6 @@
android:title="@string/settings_theme_title" />
<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
- android:defaultValue="true"
- android:icon="@drawable/ic_color_lens_grey600_24dp"
- android:key="@string/pref_key_branding"
- android:layout="@layout/item_pref"
- android:title="@string/settings_branding" />
-
- <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
android:icon="@drawable/ic_baseline_dashboard_24"
android:key="@string/pref_key_gridview"
android:layout="@layout/item_pref"