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
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
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
|
|
|
val themeColor = ThemeColor.getThemeColor(this)
|
|
|
|
if (cyanea.accent != themeColor){
|
2020-08-07 22:40:13 +02:00
|
|
|
changeThemeColor(themeColor)
|
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)
|
|
|
|
cyanea.edit{
|
|
|
|
accent(accentColor)
|
|
|
|
//accentDark(themeColor)
|
|
|
|
//accentLight(themeColor)
|
|
|
|
background(backgroundColor)
|
|
|
|
//backgroundDark(backgroundColor)
|
|
|
|
//backgroundLight(backgroundColor)
|
|
|
|
}.recreate(this)
|
|
|
|
}
|
2020-07-17 16:35:39 +02:00
|
|
|
}
|