diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-17 12:23:55 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-17 12:23:55 +0300 |
commit | b19c751d70b65a3564e686de4366745091a7822c (patch) | |
tree | c0c53ea8a59a1de39361a58385b4961601c30a77 /app/src/main | |
parent | 2f588273d6fb9789a22bff32209bd08a2e49a265 (diff) |
Try to switch themes for influencing edittext in toolbar
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main')
11 files changed, 39 insertions, 27 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 432c2da98..1afa1dbe1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" + android:theme="@style/LightThemeDarkBrand" tools:ignore="GoogleAppIndexingWarning" tools:targetApi="q"> @@ -60,7 +60,7 @@ android:name=".ui.card.EditActivity" android:label="@string/edit" android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:theme="@style/LightThemeDarkBrand" /> <activity android:name=".ui.attachments.AttachmentsActivity" @@ -71,28 +71,28 @@ android:name=".ui.settings.SettingsActivity" android:label="@string/simple_settings" android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:theme="@style/LightThemeDarkBrand" /> <activity android:name=".ui.ImportAccountActivity" android:label="@string/app_name" - android:theme="@style/AppTheme" /> + android:theme="@style/LightThemeDarkBrand" /> <activity android:name=".ui.preparecreate.PrepareCreateActivity" android:label="@string/simple_select" - android:theme="@style/AppTheme" /> + android:theme="@style/LightThemeDarkBrand" /> <activity android:name=".ui.about.AboutActivity" android:label="@string/about" android:parentActivityName="it.niedermann.nextcloud.deck.ui.MainActivity" - android:theme="@style/AppTheme" /> + android:theme="@style/LightThemeDarkBrand" /> <activity android:name=".ui.PushNotificationActivity" android:label="@string/app_name" - android:theme="@style/AppTheme"> + android:theme="@style/LightThemeDarkBrand"> <intent-filter> <action android:name="android.intent.action.MAIN"/> </intent-filter> diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/Application.java b/app/src/main/java/it/niedermann/nextcloud/deck/Application.java index 8ee0a10fa..f05fdef5f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/Application.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/Application.java @@ -55,11 +55,11 @@ public class Application extends android.app.Application { // Day / Night theme // ----------------- - public static void setAppTheme(Boolean darkTheme) { + public static void setAppTheme(boolean darkTheme) { setDefaultNightMode(darkTheme ? MODE_NIGHT_YES : MODE_NIGHT_NO); } - public static boolean getAppTheme(Context context) { + public static boolean getAppTheme(@NonNull Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean(context.getString(R.string.pref_key_dark_theme), false); } 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 950e0011b..bede5efdd 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 @@ -151,7 +151,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); - setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); + setTheme(Application.getAppTheme(this) ? R.style.DarkThemeDarkBrand : R.style.LightThemeDarkBrand); binding = ActivityMainBinding.inflate(getLayoutInflater()); headerBinding = NavHeaderMainBinding.bind(binding.navigationView.getHeaderView(0)); 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 27dddabab..781826660 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 @@ -31,7 +31,7 @@ public class AboutActivity extends BrandedActivity { @Override protected void onCreate(Bundle savedInstanceState) { - setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); + setTheme(Application.getAppTheme(this) ? R.style.DarkThemeDarkBrand : R.style.LightThemeDarkBrand); super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this)); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java index 9b2e4d224..062825047 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedActivity.java @@ -63,6 +63,7 @@ public abstract class BrandedActivity extends AppCompatActivity implements Brand public void applyBrand(@ColorInt int mainColor, @ColorInt int textColor) { this.textColor = textColor; applyBrandToStatusbar(getWindow(), mainColor, textColor); + setTheme(isColorDark(mainColor) ? R.style.LightThemeDarkBrand : R.style.LightThemeLightBrand); } @Override 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 b4e8dbc1f..c72c9feda 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 @@ -101,7 +101,7 @@ public class EditActivity extends BrandedActivity implements CardDetailsListener super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this)); - setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); + setTheme(Application.getAppTheme(this) ? R.style.DarkThemeDarkBrand : R.style.LightThemeDarkBrand); binding = ActivityEditBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); 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 21c4eb7ed..7ececd17f 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 @@ -99,7 +99,7 @@ public class PrepareCreateActivity extends BrandedActivity { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); - setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); + setTheme(Application.getAppTheme(this) ? R.style.DarkThemeDarkBrand : R.style.LightThemeDarkBrand); brandingEnabled = getResources().getBoolean(R.bool.enable_brand); 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 32a9a1849..9ad8ac845 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 @@ -16,7 +16,7 @@ public class SettingsActivity extends BrandedActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); + setTheme(Application.getAppTheme(this) ? R.style.DarkThemeDarkBrand : R.style.LightThemeDarkBrand); super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this)); diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 1ae29b930..d2f9b103e 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -20,7 +20,7 @@ android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" - app:theme="@style/AppTheme.EditText" + app:theme="@style/EditTextOnPrimaryBackground" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" android:importantForAutofill="no" diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 715f8b814..0ccfa00b7 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -8,4 +8,5 @@ <attr name="description" format="string" /> <attr name="image" format="reference" /> </declare-styleable> + <attr name="editTextForegroundOnPrimaryBackground" format="reference"/> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bec19f14b..ec16220f6 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,37 +1,47 @@ <resources xmlns:tools="http://schemas.android.com/tools"> - <!-- Base application theme. --> - <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge"> + <!-- Default is a light theme with the dark blue brand --> + <style name="LightThemeDarkBrand" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge"> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary</item> <item name="colorAccent">@color/primary</item> + <item name="editTextForegroundOnPrimaryBackground">@android:color/white</item> <item name="android:windowContentOverlay">@null</item> <item name="android:elevation" tools:targetApi="lollipop">@null</item> - <item name="windowActionBar">false</item> - <item name="windowNoTitle">true</item> </style> - <style name="AppTheme.EditText" parent="ThemeOverlay.MaterialComponents.Dark"> - <item name="colorControlNormal">@android:color/white</item> - <item name="colorControlActivated">@android:color/white</item> - <item name="colorControlHighlight">@android:color/white</item> + <!-- This is a light theme with a bright brand color like yellow --> + <style name="LightThemeLightBrand" parent="LightThemeDarkBrand"> + <item name="editTextForegroundOnPrimaryBackground">@android:color/black</item> </style> - <style name="DarkAppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> + <!-- Enabled dark mode with a dark brand like the default Nextcloud blue --> + <style name="DarkThemeDarkBrand" parent="Theme.MaterialComponents.NoActionBar.Bridge"> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary</item> <item name="colorAccent">@color/primary</item> + <item name="editTextForegroundOnPrimaryBackground">@android:color/white</item> <item name="android:textColor">@color/fg_secondary</item> <item name="android:textViewStyle">@style/DarkTextView</item> - <item name="windowActionBar">false</item> - <item name="windowNoTitle">true</item> + </style> + + <!-- Enabled dark mode with a bright brand color like yellow --> + <style name="DarkThemeLightBrand" parent="DarkThemeDarkBrand"> + <item name="editTextForegroundOnPrimaryBackground">@android:color/black</item> + </style> + + <!-- This styles an EditText which is on a primary background like in the toolbar --> + <style name="EditTextOnPrimaryBackground" parent="ThemeOverlay.MaterialComponents.Dark"> + <item name="colorControlNormal">?editTextForegroundOnPrimaryBackground</item> + <item name="colorControlActivated">?editTextForegroundOnPrimaryBackground</item> + <item name="colorControlHighlight">?editTextForegroundOnPrimaryBackground</item> </style> <style name="DarkTextView" parent="Widget.AppCompat.TextView"> <item name="android:textColor">@color/dark_fg_primary</item> </style> - <style name="SplashTheme" parent="AppTheme"> + <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/splash_screen</item> </style> |