aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/me/texx/Texx/Util/ThemeUtil.kt
blob: c8b00f12bacca1e9cf8e7ef3427fea2e7b38635a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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"
        }
    }
}