diff options
Diffstat (limited to 'app')
6 files changed, 22 insertions, 19 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/AbstractThemableActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/AbstractThemableActivity.java index c2392184d..f542c3d7c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/AbstractThemableActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/AbstractThemableActivity.java @@ -1,5 +1,6 @@ package it.niedermann.nextcloud.deck.ui; +import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; @@ -15,10 +16,15 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.graphics.drawable.DrawableCompat; +import com.google.android.material.tabs.TabLayout; + import it.niedermann.nextcloud.deck.Application; public abstract class AbstractThemableActivity extends AppCompatActivity implements Application.NextcloudTheme { + /** + * Member variable needed for onCreateOptionsMenu()-callback + */ @Nullable @ColorInt private Integer textColor = null; @@ -44,6 +50,7 @@ public abstract class AbstractThemableActivity extends AppCompatActivity impleme @CallSuper @Override public void applyNextcloudTheme(@ColorInt int mainColor, @ColorInt int textColor) { + this.textColor = textColor; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); @@ -66,8 +73,7 @@ public abstract class AbstractThemableActivity extends AppCompatActivity impleme return super.onCreateOptionsMenu(menu); } - protected void applyNextcloudTheme(@ColorInt int mainColor, @ColorInt int textColor, @NonNull Toolbar toolbar) { - this.textColor = textColor; + protected void applyNextcloudThemeToToolbar(@ColorInt int mainColor, @ColorInt int textColor, @NonNull Toolbar toolbar) { toolbar.setBackgroundColor(mainColor); toolbar.setTitleTextColor(textColor); final Drawable overflowDrawable = toolbar.getOverflowIcon(); @@ -82,4 +88,10 @@ public abstract class AbstractThemableActivity extends AppCompatActivity impleme toolbar.setNavigationIcon(navigationDrawable); } } + + protected void applyNextcloudThemeToTablayout(@ColorInt int mainColor, @ColorInt int textColor, @NonNull TabLayout tabLayout) { + tabLayout.setBackgroundColor(mainColor); + tabLayout.setTabIconTint(new ColorStateList(new int[][]{new int[]{}}, new int[]{textColor})); + tabLayout.setSelectedTabIndicatorColor(textColor); + } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 3948f2c23..f5f97cee5 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -336,10 +336,8 @@ public class MainActivity extends AbstractThemableActivity implements EditStackL @Override public void applyNextcloudTheme(@ColorInt int mainColor, @ColorInt int textColor) { super.applyNextcloudTheme(mainColor, textColor); - applyNextcloudTheme(mainColor, textColor, binding.toolbar); - binding.stackTitles.setBackgroundColor(mainColor); - binding.stackTitles.setTabTextColors(textColor, textColor); - binding.stackTitles.setSelectedTabIndicatorColor(textColor); + applyNextcloudThemeToToolbar(mainColor, textColor, binding.toolbar); + applyNextcloudThemeToTablayout(mainColor, textColor, binding.stackTitles); binding.addStackButton.setBackgroundColor(mainColor); binding.addStackButton.setColorFilter(textColor); headerBinding.drawerHeaderView.setBackgroundColor(mainColor); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java index 66a49f218..9b226a300 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/about/AboutActivity.java @@ -85,9 +85,7 @@ public class AboutActivity extends AbstractThemableActivity { @Override public void applyNextcloudTheme(int mainColor, int textColor) { super.applyNextcloudTheme(mainColor, textColor); - binding.toolbar.setBackgroundColor(mainColor); - binding.toolbar.setTitleTextColor(textColor); - binding.tabLayout.setBackgroundColor(mainColor); - binding.tabLayout.setTabTextColors(textColor, textColor); + applyNextcloudThemeToToolbar(mainColor, textColor, binding.toolbar); + applyNextcloudThemeToTablayout(mainColor, textColor, binding.tabLayout); } }
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java index 48a817fb6..d7270a598 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java @@ -1,6 +1,5 @@ package it.niedermann.nextcloud.deck.ui.card; -import android.content.res.ColorStateList; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; @@ -340,10 +339,8 @@ public class EditActivity extends AbstractThemableActivity implements CardDetail @Override public void applyNextcloudTheme(int mainColor, int textColor) { super.applyNextcloudTheme(mainColor, textColor); - applyNextcloudTheme(mainColor, textColor, binding.toolbar); + applyNextcloudThemeToToolbar(mainColor, textColor, binding.toolbar); + applyNextcloudThemeToTablayout(mainColor, textColor, binding.tabLayout); binding.title.setTextColor(textColor); - binding.tabLayout.setBackgroundColor(mainColor); - binding.tabLayout.setTabIconTint(new ColorStateList(new int[][]{new int[]{}}, new int[]{textColor})); - binding.tabLayout.setSelectedTabIndicatorColor(textColor); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/PrepareCreateActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/PrepareCreateActivity.java index 632391a3d..cf442fc6f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/PrepareCreateActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/preparecreate/PrepareCreateActivity.java @@ -190,8 +190,7 @@ public class PrepareCreateActivity extends AbstractThemableActivity { @Override public void applyNextcloudTheme(int mainColor, int textColor) { super.applyNextcloudTheme(mainColor, textColor); - binding.toolbar.setBackgroundColor(mainColor); - binding.toolbar.setTitleTextColor(textColor); + applyNextcloudThemeToToolbar(mainColor, textColor, binding.toolbar); binding.submit.setBackgroundColor(mainColor); binding.submit.setTextColor(textColor); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java index d521750ee..1a3b03aad 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsActivity.java @@ -41,7 +41,6 @@ public class SettingsActivity extends AbstractThemableActivity { @Override public void applyNextcloudTheme(int mainColor, int textColor) { super.applyNextcloudTheme(mainColor, textColor); - binding.toolbar.setBackgroundColor(mainColor); - binding.toolbar.setTitleTextColor(textColor); + applyNextcloudThemeToToolbar(mainColor, textColor, binding.toolbar); } } |