Rewrote Theme
This commit is contained in:
@@ -21,9 +21,10 @@ class SettingsActivity : BaseActivity() {
|
||||
@Inject lateinit var syncManager: MangaSyncManager
|
||||
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
setAppTheme()
|
||||
super.onCreate(savedState)
|
||||
setContentView(R.layout.activity_preferences)
|
||||
applicationComponent.inject(this)
|
||||
app.component.inject(this)
|
||||
|
||||
setupToolbar(toolbar)
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.TaskStackBuilder
|
||||
import android.support.v7.preference.Preference
|
||||
import android.view.View
|
||||
import eu.kanade.tachiyomi.App
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateAlarm
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||
import eu.kanade.tachiyomi.widget.preference.LibraryColumnsDialog
|
||||
import eu.kanade.tachiyomi.widget.preference.SimpleDialogPreference
|
||||
@@ -29,6 +33,10 @@ class SettingsGeneralFragment : SettingsNestedFragment() {
|
||||
findPreference(getString(R.string.pref_library_update_interval_key)) as IntListPreference
|
||||
}
|
||||
|
||||
val themePreference by lazy {
|
||||
findPreference(getString(R.string.pref_theme_key)) as IntListPreference
|
||||
}
|
||||
|
||||
var columnsSubscription: Subscription? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -36,6 +44,17 @@ class SettingsGeneralFragment : SettingsNestedFragment() {
|
||||
LibraryUpdateAlarm.startAlarm(activity, (newValue as String).toInt())
|
||||
true
|
||||
}
|
||||
|
||||
themePreference.setOnPreferenceChangeListener { preference, newValue ->
|
||||
App.get(activity).appTheme = (newValue as String).toInt()
|
||||
|
||||
// Rebuild activity's to apply themes.
|
||||
TaskStackBuilder.create(activity)
|
||||
.addNextIntent(Intent(activity, MainActivity::class.java))
|
||||
.addNextIntent(activity.intent)
|
||||
.startActivities()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
||||
Reference in New Issue
Block a user