diff options
-rw-r--r-- | app/src/main/java/com/no_name/no_name/Util/ThemeUtil.kt | 35 | ||||
-rw-r--r-- | app/src/main/res/xml/pref_account.xml | 27 |
2 files changed, 46 insertions, 16 deletions
diff --git a/app/src/main/java/com/no_name/no_name/Util/ThemeUtil.kt b/app/src/main/java/com/no_name/no_name/Util/ThemeUtil.kt index d777281..5125f12 100644 --- a/app/src/main/java/com/no_name/no_name/Util/ThemeUtil.kt +++ b/app/src/main/java/com/no_name/no_name/Util/ThemeUtil.kt @@ -1,14 +1,18 @@ -package com.no_name.no_name.Util +package com.no_name.no_name.util import android.content.Context -import com.afollestad.aesthetic.Aesthetic import com.madapps.prefrences.EasyPrefrences -import com.no_name.no_name.R +import com.no_name.no_name.util.ThemeUtil.isDarkTheme -class ThemeUtil(context: Context) { - private val sharedPrefs = EasyPrefrences(context) - - private fun isDarkTheme(): Boolean { +/** + * Get the name of the theme depending on [actionBar] and [isDarkTheme] + */ +object ThemeUtil { + /** + * Checks if the theme saved in sharedPreferences is dark/light + */ + private fun isDarkTheme(context: Context): Boolean { + val sharedPrefs = EasyPrefrences(context) val darkTheme: Boolean? = sharedPrefs.getBoolean("dark_theme_switch") darkTheme?.let { return darkTheme @@ -17,15 +21,14 @@ class ThemeUtil(context: Context) { } } - fun setActivityTheme(ActionBar: Boolean) { - val theme: Int = if (!ActionBar) { - if (isDarkTheme()) R.style.AppTheme_Dark_NoActionBar else R.style.AppTheme_NoActionBar - } else - if (isDarkTheme()) R.style.AppTheme_Dark else R.style.AppTheme - - Aesthetic.config { - activityTheme(R.style.AppTheme_NoActionBar) - isDark(isDarkTheme()) + /** + * Get the name of the theme depending on [actionBar] and [isDarkTheme] + */ + fun getThemeName(context: Context): String { + return if (isDarkTheme(context)) { + "dark" + } else { + "light" } } }
\ No newline at end of file diff --git a/app/src/main/res/xml/pref_account.xml b/app/src/main/res/xml/pref_account.xml new file mode 100644 index 0000000..f410996 --- /dev/null +++ b/app/src/main/res/xml/pref_account.xml @@ -0,0 +1,27 @@ +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- NOTE: EditTextPreference accepts EditText attributes. --> + <!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. --> + <EditTextPreference + android:capitalize="words" + android:defaultValue="@string/pref_default_username" + android:inputType="textCapWords" + android:key="username" + android:maxLines="1" + android:selectAllOnFocus="true" + android:singleLine="true" + android:title="@string/pref_title_username" /> + + <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to + dismiss it. --> + <!-- NOTE: ListPreference's summary should be set to its value by the activity code. --> + + <!--<ListPreference + android:defaultValue="-1" + android:entries="@array/pref_example_list_titles" + android:entryValues="@array/pref_example_list_values" + android:key="example_list" + android:negativeButtonText="@null" + android:positiveButtonText="@null" + android:title="@string/pref_title_add_friends_to_messages" />--> + +</PreferenceScreen> |