Skip to content

Commit 05a4fad

Browse files
feat(theming): Get rid of textColor property
Signed-off-by: Stefan Niedermann <info@niedermann.it>
1 parent c9f50bf commit 05a4fad

38 files changed

Lines changed: 159 additions & 216 deletions

app/src/main/java/it/niedermann/owncloud/notes/FormattingHelpActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ private String buildFormattingHelp() {
223223
}
224224

225225
@Override
226-
public void applyBrand(int mainColor, int textColor) {
227-
final var util = BrandingUtil.of(mainColor, this);
226+
public void applyBrand(int color) {
227+
final var util = BrandingUtil.of(color, this);
228228
util.notes.applyBrandToPrimaryToolbar(binding.appBar, binding.toolbar, colorAccent);
229229
}
230230
}

app/src/main/java/it/niedermann/owncloud/notes/about/AboutActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ protected void onCreate(Bundle savedInstanceState) {
5050
}
5151

5252
@Override
53-
public void applyBrand(int mainColor, int textColor) {
54-
final var util = BrandingUtil.of(mainColor, this);
53+
public void applyBrand(int color) {
54+
final var util = BrandingUtil.of(color, this);
5555
util.material.themeTabLayout(binding.tabs);
5656
util.notes.applyBrandToPrimaryToolbar(binding.appBar, binding.toolbar, colorAccent);
5757
}

app/src/main/java/it/niedermann/owncloud/notes/about/AboutFragmentLicenseTab.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
3434
}
3535

3636
@Override
37-
public void applyBrand(int mainColor, int textColor) {
38-
final var util = BrandingUtil.of(mainColor, requireContext());
37+
public void applyBrand(int color) {
38+
final var util = BrandingUtil.of(color, requireContext());
3939
util.material.colorMaterialButtonPrimaryFilled(binding.aboutAppLicenseButton);
4040
}
4141
}

app/src/main/java/it/niedermann/owncloud/notes/accountpicker/AccountPickerDialogFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static DialogFragment newInstance(@NonNull ArrayList<Account> targetAccou
109109
}
110110

111111
@Override
112-
public void applyBrand(int mainColor, int textColor) {
112+
public void applyBrand(int color) {
113113
// Nothing to do...
114114
}
115115
}

app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public static DialogFragment newInstance(long currentAccountId) {
116116
}
117117

118118
@Override
119-
public void applyBrand(int mainColor, int textColor) {
120-
final var util = BrandingUtil.of(mainColor, requireContext());
121-
util.notes.colorLayerDrawable((LayerDrawable) binding.check.getDrawable(), R.id.area, mainColor);
119+
public void applyBrand(int color) {
120+
final var util = BrandingUtil.of(color, requireContext());
121+
util.notes.colorLayerDrawable((LayerDrawable) binding.check.getDrawable(), R.id.area, color);
122122
}
123123
}

app/src/main/java/it/niedermann/owncloud/notes/branding/Branded.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
public interface Branded {
77
@UiThread
8-
void applyBrand(@ColorInt int mainColor, @ColorInt int textColor);
8+
void applyBrand(@ColorInt int color);
99
}

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package it.niedermann.owncloud.notes.branding;
22

3-
import static it.niedermann.owncloud.notes.branding.BrandingUtil.readBrandColors;
3+
import static it.niedermann.owncloud.notes.branding.BrandingUtil.readBrandMainColorLiveData;
44

55
import android.util.TypedValue;
66
import android.view.Menu;
@@ -23,7 +23,7 @@ protected void onStart() {
2323
getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
2424
colorAccent = typedValue.data;
2525

26-
readBrandColors(this).observe(this, (pair) -> applyBrand(pair.first, pair.second));
26+
readBrandMainColorLiveData(this).observe(this, this::applyBrand);
2727
}
2828

2929
@Override

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedDialogFragment.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public void onStart() {
1313
super.onStart();
1414

1515
@Nullable final var context = requireContext();
16-
@ColorInt final int mainColor = BrandingUtil.readBrandMainColor(context);
17-
@ColorInt final int textColor = BrandingUtil.readBrandTextColor(context);
18-
applyBrand(mainColor, textColor);
16+
@ColorInt final int color = BrandingUtil.readBrandMainColor(context);
17+
applyBrand(color);
1918
}
2019
}

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedFragment.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public void onStart() {
2828
context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
2929
colorPrimary = typedValue.data;
3030

31-
@ColorInt final int mainColor = BrandingUtil.readBrandMainColor(context);
32-
@ColorInt final int textColor = BrandingUtil.readBrandTextColor(context);
33-
applyBrand(mainColor, textColor);
31+
@ColorInt final int color = BrandingUtil.readBrandMainColor(context);
32+
applyBrand(color);
3433
}
3534

3635
@Override

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public class BrandedSwitchPreference extends SwitchPreference implements Branded
1717
@ColorInt
1818
private Integer mainColor = null;
1919

20-
@ColorInt
21-
private Integer textColor = null;
22-
2320
@SuppressLint("UseSwitchCompatOrMaterialCode")
2421
@Nullable
2522
private Switch switchView;
@@ -46,16 +43,15 @@ public void onBindViewHolder(PreferenceViewHolder holder) {
4643

4744
if (holder.itemView instanceof ViewGroup) {
4845
switchView = findSwitchWidget(holder.itemView);
49-
if (mainColor != null && textColor != null) {
46+
if (mainColor != null) {
5047
applyBrand();
5148
}
5249
}
5350
}
5451

5552
@Override
56-
public void applyBrand(@ColorInt int mainColor, @ColorInt int textColor) {
57-
this.mainColor = mainColor;
58-
this.textColor = textColor;
53+
public void applyBrand(@ColorInt int color) {
54+
this.mainColor = color;
5955
// onBindViewHolder is called after applyBrand, therefore we have to store the given values and apply them later.
6056
applyBrand();
6157
}

0 commit comments

Comments
 (0)