DroidFS/app/src/main/java/sushi/hardcore/droidfs/BaseActivity.kt

38 lines
1.5 KiB
Kotlin
Raw Normal View History

2020-07-17 16:35:39 +02:00
package sushi.hardcore.droidfs
import android.content.SharedPreferences
import android.os.Bundle
import android.view.WindowManager
import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager
import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity
import sushi.hardcore.droidfs.widgets.ThemeColor
2020-07-21 15:05:05 +02:00
open class BaseActivity: CyaneaAppCompatActivity() {
2020-07-17 16:35:39 +02:00
protected lateinit var sharedPrefs: SharedPreferences
2020-10-22 22:14:22 +02:00
protected var isRecreating = false
2020-07-17 16:35:39 +02:00
override fun onCreate(savedInstanceState: Bundle?) {
val themeColor = ThemeColor.getThemeColor(this)
if (cyanea.accent != themeColor){
changeThemeColor(themeColor)
}
2020-07-17 16:35:39 +02:00
super.onCreate(savedInstanceState)
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
2020-07-21 15:05:05 +02:00
if (!sharedPrefs.getBoolean("usf_screenshot", false)){
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
}
2020-07-17 16:35:39 +02:00
}
2020-08-07 22:40:13 +02:00
fun changeThemeColor(themeColor: Int? = null){
val accentColor = themeColor ?: ThemeColor.getThemeColor(this)
val backgroundColor = ContextCompat.getColor(this, R.color.backgroundColor)
2020-10-22 22:14:22 +02:00
isRecreating = true
2020-08-07 22:40:13 +02:00
cyanea.edit{
accent(accentColor)
//accentDark(themeColor)
//accentLight(themeColor)
background(backgroundColor)
//backgroundDark(backgroundColor)
//backgroundLight(backgroundColor)
}.recreate(this)
}
2020-07-17 16:35:39 +02:00
}