From 743f2f35afbd510d428d3d5982a1dd5da67fe0c2 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 13 Sep 2018 16:25:25 +0200 Subject: Applied naming convention for util package :art: --- app/src/main/java/me/texx/Texx/util/ThemeUtil.kt | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/src/main/java/me/texx/Texx/util/ThemeUtil.kt (limited to 'app/src/main/java/me/texx/Texx/util/ThemeUtil.kt') 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 -- cgit v1.2.3