diff options
author | Marvin Borner | 2018-08-30 00:12:53 +0200 |
---|---|---|
committer | Marvin Borner | 2018-08-30 00:12:53 +0200 |
commit | 9559ad90e9e5542518602f2f5cffd64cb6a96974 (patch) | |
tree | 518aec7492eaf5056c1d076274784a7861ac321d /app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt | |
parent | 91f2e2e884503fa370aca76c329eff232c2fc8c9 (diff) |
Renamed project to Texx
Diffstat (limited to 'app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt')
-rw-r--r-- | app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt b/app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt new file mode 100644 index 0000000..c8b00f1 --- /dev/null +++ b/app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt @@ -0,0 +1,34 @@ +package me.texx.Texx.util + +import android.content.Context +import com.madapps.prefrences.EasyPrefrences +import me.texx.Texx.util.ThemeUtil.isDarkTheme + +/** + * 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 + } ?: run { + return false + } + } + + /** + * 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 |