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:
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/branding')
-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
7 files changed, 24 insertions, 50 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));