Significantly improve app theming (#679)
* Update CHANGELOG * Use outlined box style in folder creation dialog * Add user-facing choice for app theme Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
6e84ca1f3c
commit
bc463f3c64
17 changed files with 98 additions and 37 deletions
|
@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file.
|
|||
### Added
|
||||
- Oreo Autofill support
|
||||
|
||||
### Fixed
|
||||
- Text input box theming
|
||||
|
||||
## [1.6.0] - 2020-03-20
|
||||
|
||||
### Added
|
||||
|
|
|
@ -4,11 +4,19 @@
|
|||
*/
|
||||
package com.zeapo.pwdstore
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.haroldadmin.whatthestack.WhatTheStack
|
||||
import timber.log.Timber
|
||||
|
||||
@Suppress("Unused")
|
||||
class Application : android.app.Application() {
|
||||
class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private var prefs: SharedPreferences? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
@ -16,5 +24,28 @@ class Application : android.app.Application() {
|
|||
if (BuildConfig.ENABLE_DEBUG_FEATURES) {
|
||||
WhatTheStack(this).init()
|
||||
}
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
prefs?.registerOnSharedPreferenceChangeListener(this)
|
||||
setNightMode()
|
||||
}
|
||||
|
||||
override fun onTerminate() {
|
||||
prefs?.unregisterOnSharedPreferenceChangeListener(this)
|
||||
super.onTerminate()
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String) {
|
||||
if (key == "app_theme") {
|
||||
setNightMode()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setNightMode() {
|
||||
AppCompatDelegate.setDefaultNightMode(when (prefs?.getString("app_theme", getString(R.string.app_theme_def))) {
|
||||
"light" -> MODE_NIGHT_NO
|
||||
"dark" -> MODE_NIGHT_YES
|
||||
"follow_system" -> MODE_NIGHT_FOLLOW_SYSTEM
|
||||
else -> MODE_NIGHT_AUTO_BATTERY
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,13 +37,11 @@
|
|||
app:layout_constraintStart_toEndOf="@id/label_server_protocol" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/server_user_layout"
|
||||
android:hint="@string/server_user"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/label_server_protocol">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/server_user"
|
||||
|
@ -53,13 +51,11 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/label_server_url"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/server_url"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/server_user_layout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/label_server_port">
|
||||
|
@ -73,13 +69,11 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/label_server_port"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/server_port_hint"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintStart_toEndOf="@id/label_server_url"
|
||||
app:layout_constraintTop_toBottomOf="@id/server_user_layout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -94,13 +88,11 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/label_server_path"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/server_path"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/label_server_url">
|
||||
|
||||
|
@ -113,14 +105,12 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/label_clone_uri"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/repository_uri"
|
||||
android:editable="false"
|
||||
android:layout_margin="8dp"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/label_server_path">
|
||||
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/username_input_layout"
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/git_user_name_hint"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:layout_editor_absoluteY="64dp">
|
||||
|
@ -30,13 +28,11 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/email_input_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/git_user_email"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/username_input_layout"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/searchLayout"
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
|
|
|
@ -22,14 +22,12 @@
|
|||
tools:text="CATEGORY HERE" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/name_input_layout"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/crypto_name_hint"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/crypto_password_category"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
@ -39,14 +37,12 @@
|
|||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/password_input_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/crypto_pass_label"
|
||||
app:endIconMode="password_toggle"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/name_input_layout"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
@ -69,13 +65,11 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:id="@+id/extra_input_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:hint="@string/crypto_extra_label"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/generate_password"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
style="@style/TextInputLayoutBase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/crypto_name_hint"
|
||||
app:hintTextColor="@color/color_control_normal"
|
||||
app:hintEnabled="true">
|
||||
android:hint="@string/crypto_name_hint">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/folder_name_text"
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="URL"
|
||||
app:hintEnabled="true">
|
||||
android:hint="URL">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/webURL"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -24,12 +24,10 @@
|
|||
android:spinnerMode="dropdown" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/ssh_keygen_passphrase"
|
||||
app:hintEnabled="true">
|
||||
android:hint="@string/ssh_keygen_passphrase">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/passphrase"
|
||||
|
@ -49,12 +47,10 @@
|
|||
android:text="@string/ssh_keygen_show_passphrase" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/TextInputLayoutBase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/ssh_keygen_comment"
|
||||
app:hintEnabled="true">
|
||||
android:hint="@string/ssh_keygen_comment">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/comment"
|
||||
|
|
13
app/src/main/res/values-v29/arrays.xml
Normal file
13
app/src/main/res/values-v29/arrays.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="app_theme_options">
|
||||
<item>@string/theme_light</item>
|
||||
<item>@string/theme_dark</item>
|
||||
<item>@string/theme_follow_system</item>
|
||||
</string-array>
|
||||
<string-array name="app_theme_values">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>follow_system</item>
|
||||
</string-array>
|
||||
</resources>
|
4
app/src/main/res/values-v29/prefs.xml
Normal file
4
app/src/main/res/values-v29/prefs.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_theme_def" translatable="false">follow_system</string>
|
||||
</resources>
|
|
@ -59,5 +59,15 @@
|
|||
<item>file</item>
|
||||
<item>directory</item>
|
||||
</string-array>
|
||||
<string-array name="app_theme_options">
|
||||
<item>@string/theme_light</item>
|
||||
<item>@string/theme_dark</item>
|
||||
<item>@string/theme_battery_saver</item>
|
||||
</string-array>
|
||||
<string-array name="app_theme_values">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>battery_saver</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base palette -->
|
||||
<color name="primary_color">#607d8b</color>
|
||||
<color name="primary_light_color">#8eacbb</color>
|
||||
|
@ -19,4 +19,9 @@
|
|||
<color name="list_multiselect_background">#668eacbb</color>
|
||||
<color name="navigation_bar_color">#000000</color>
|
||||
<color name="status_bar_color">@color/primary_dark_color</color>
|
||||
|
||||
<!-- Override TextInputEditText stroke color like a boss -->
|
||||
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">
|
||||
@color/secondary_color
|
||||
</color>
|
||||
</resources>
|
||||
|
|
4
app/src/main/res/values/prefs.xml
Normal file
4
app/src/main/res/values/prefs.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_theme_def" translatable="false">battery_saver</string>
|
||||
</resources>
|
|
@ -334,4 +334,9 @@
|
|||
<string name="password_generator_category_title">Password Generator</string>
|
||||
<string name="tap_clear_clipboard">Tap here to clear clipboard</string>
|
||||
<string name="clone_git_repo">Clone a git repository to sync changes</string>
|
||||
<string name="theme_title">App theme</string>
|
||||
<string name="theme_light">Light</string>
|
||||
<string name="theme_dark">Dark</string>
|
||||
<string name="theme_battery_saver">Set by Battery Saver</string>
|
||||
<string name="theme_follow_system">System default</string>
|
||||
</resources>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<item name="alertDialogTheme">@style/AppTheme.Dialog</item>
|
||||
<item name="materialAlertDialogTheme">@style/AppTheme.Dialog</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents.ActionBar</item>
|
||||
<item name="textInputStyle">@style/TextInputLayoutBase</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
|
||||
|
@ -32,9 +33,15 @@
|
|||
<item name="background">@color/primary_color</item>
|
||||
</style>
|
||||
|
||||
<style name="TextInputLayoutBase" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
|
||||
<item name="boxStrokeColor">?attr/colorSecondary</item>
|
||||
<item name="hintTextColor">?attr/colorOnPrimary</item>
|
||||
<style name="ThemeOverlay.AppTheme.TextInputEditText.OutlinedBox" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
|
||||
<item name="colorControlActivated">@color/color_control_normal</item>
|
||||
</style>
|
||||
|
||||
<style name="TextInputLayoutBase" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
|
||||
<item name="boxStrokeColor">@color/secondary_color</item>
|
||||
<item name="hintTextColor">@color/color_control_normal</item>
|
||||
<item name="hintEnabled">true</item>
|
||||
<item name="materialThemeOverlay">@style/ThemeOverlay.AppTheme.TextInputEditText.OutlinedBox</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogLikeTheme" parent="AppTheme">
|
||||
|
|
|
@ -102,6 +102,13 @@
|
|||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory app:title="@string/pref_general_title">
|
||||
<ListPreference
|
||||
android:defaultValue="@string/app_theme_def"
|
||||
android:key="app_theme"
|
||||
android:entries="@array/app_theme_options"
|
||||
android:entryValues="@array/app_theme_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/theme_title" />
|
||||
<androidx.preference.EditTextPreference
|
||||
app:defaultValue="45"
|
||||
app:dialogTitle="@string/pref_show_time_summary"
|
||||
|
|
Loading…
Reference in a new issue