From 4b136ce458795f54cec71d4be251967603e35da6 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Sun, 26 Mar 2017 22:59:16 -0400 Subject: [PATCH] Light theme properly separated again, making it ready for palette changes. --- app/src/main/AndroidManifest.xml | 4 +-- .../com/keylesspalace/tusky/MainActivity.java | 21 +++++++------- .../keylesspalace/tusky/SplashActivity.java | 10 +++++-- app/src/main/res/layout/activity_account.xml | 1 - app/src/main/res/layout/activity_main.xml | 9 ------ app/src/main/res/layout/activity_report.xml | 6 ++-- app/src/main/res/layout/activity_splash.xml | 4 +-- app/src/main/res/layout/activity_view_tag.xml | 3 -- .../main/res/layout/activity_view_thread.xml | 6 ++-- app/src/main/res/values/attrs.xml | 3 ++ app/src/main/res/values/styles.xml | 28 ++++++++++++++++++- 11 files changed, 55 insertions(+), 40 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 01ee20319..31a914ec8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,9 +12,7 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index dba8966d9..50d63945f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -19,7 +19,6 @@ import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -27,7 +26,6 @@ import android.os.Bundle; import android.os.PersistableBundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; -import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -158,17 +156,19 @@ public class MainActivity extends BaseActivity { Intent intent = getIntent(); + int tabSelected = 0; if (intent != null) { int tabPosition = intent.getIntExtra("tab_position", 0); - if (tabPosition != 0) { - tabLayout.getTabAt(tabPosition).select(); - tintTab(tabLayout.getTabAt(tabPosition), true); - } else { - tintTab(tabLayout.getTabAt(0), true); + TabLayout.Tab tab = tabLayout.getTabAt(tabPosition); + if (tab != null) { + tab.select(); + tabSelected = tabPosition; + } } - } else { - tintTab(tabLayout.getTabAt(0), true); + } + for (int i = 0; i < 3; i++) { + tintTab(tabLayout.getTabAt(i), i == tabSelected); } // Setup push notifications @@ -196,7 +196,8 @@ public class MainActivity extends BaseActivity { } private void tintTab(TabLayout.Tab tab, boolean tinted) { - tab.getIcon().setColorFilter(ContextCompat.getColor(this, tinted ? R.color.color_accent_dark : R.color.toolbar_icon_dark), PorterDuff.Mode.SRC_IN); + int color = (tinted) ? R.attr.tab_icon_selected_tint : R.attr.toolbar_icon_tint; + ThemeUtils.setDrawableTint(this, tab.getIcon(), color); } private void setupDrawer() { diff --git a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java index 69a9df5e9..a5123bbe0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java @@ -15,23 +15,27 @@ package com.keylesspalace.tusky; -import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.view.Window; import android.view.WindowManager; -public class SplashActivity extends Activity { - private static int SPLASH_TIME_OUT = 2000; +public class SplashActivity extends AppCompatActivity { + private static final int SPLASH_TIME_OUT = 2000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) { + setTheme(R.style.AppTheme_Light); + } + requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index c8993720d..123067576 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.Account.AppBarLayout" - app:popupTheme="@style/AppTheme.Account.ToolbarPopupTheme.Dark" android:id="@+id/account_app_bar_layout"> - - - + app:cfl_wave_color="?attr/splash_wave_color" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_view_tag.xml b/app/src/main/res/layout/activity_view_tag.xml index 808c03579..f2afb8b07 100644 --- a/app/src/main/res/layout/activity_view_tag.xml +++ b/app/src/main/res/layout/activity_view_tag.xml @@ -1,7 +1,6 @@ diff --git a/app/src/main/res/layout/activity_view_thread.xml b/app/src/main/res/layout/activity_view_thread.xml index e714bf438..8b2a203a4 100644 --- a/app/src/main/res/layout/activity_view_thread.xml +++ b/app/src/main/res/layout/activity_view_thread.xml @@ -1,7 +1,7 @@ - diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index a46e72a05..8d99b4472 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -11,6 +11,8 @@ + + @@ -22,6 +24,7 @@ + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d7c933cf8..2d5dc4ab5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -31,6 +31,8 @@ @style/AppTheme.BottomSheetDialog.Dark + @color/color_background_dark + @color/color_primary_dark @color/toolbar_background_dark @color/toolbar_icon_dark @style/AppTheme.ImageButton.Dark @@ -42,6 +44,7 @@ @color/color_background_dark @drawable/media_preview_unloaded_dark @drawable/status_divider_dark + @color/color_accent_dark @drawable/tab_page_margin_dark @color/account_header_background_dark @color/toolbar_icon_dark @@ -75,7 +78,7 @@ @color/toolbar_icon_dark @color/toolbar_icon_dark @color/toolbar_icon_dark - @color/toolbar_icon_dark--> + @color/toolbar_icon_dark