workaround to theme settings
This commit is contained in:
parent
1ac9a68c35
commit
d14ccb66f4
|
@ -44,6 +44,8 @@ import org.mariotaku.twidere.R
|
|||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.ACTION_NAVIGATION_BACK
|
||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.CONTEXT_TAG_NAVIGATION
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_DARK
|
||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_LIGHT
|
||||
import org.mariotaku.twidere.fragment.*
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler
|
||||
import org.mariotaku.twidere.util.ThemeUtils
|
||||
|
@ -206,6 +208,18 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
|||
openDetails(position)
|
||||
}
|
||||
|
||||
override fun getThemeResource(theme: String, themeColor: Int, nightMode: Int): Int {
|
||||
when (theme) {
|
||||
VALUE_THEME_NAME_LIGHT -> {
|
||||
return R.style.Theme_Twidere_Light
|
||||
}
|
||||
VALUE_THEME_NAME_DARK -> {
|
||||
return R.style.Theme_Twidere_Dark
|
||||
}
|
||||
}
|
||||
return super.getThemeResource(theme, themeColor, nightMode)
|
||||
}
|
||||
|
||||
private fun openDetails(position: Int) {
|
||||
if (isFinishing) return
|
||||
val entry = entriesAdapter.getItem(position) as? PreferenceEntry ?: return
|
||||
|
@ -241,13 +255,8 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
|
|||
}
|
||||
|
||||
internal class EntriesAdapter(context: Context) : BaseAdapter() {
|
||||
private val inflater: LayoutInflater
|
||||
private val entries: MutableList<Entry>
|
||||
|
||||
init {
|
||||
inflater = LayoutInflater.from(context)
|
||||
entries = ArrayList<Entry>()
|
||||
}
|
||||
private val inflater: LayoutInflater = LayoutInflater.from(context)
|
||||
private val entries: MutableList<Entry> = ArrayList()
|
||||
|
||||
fun addPreference(tag: String, @DrawableRes icon: Int, title: String, @XmlRes preference: Int) {
|
||||
entries.add(PreferenceEntry(tag, icon, title, preference, null, null))
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.database.sqlite.SQLiteDatabase
|
|||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import android.os.AsyncTask
|
||||
import android.support.multidex.MultiDex
|
||||
import android.support.v7.app.AppCompatDelegate
|
||||
import android.util.Log
|
||||
import nl.komponents.kovenant.android.startKovenant
|
||||
import nl.komponents.kovenant.android.stopKovenant
|
||||
|
@ -48,7 +47,6 @@ import org.mariotaku.twidere.activity.MainHondaJOJOActivity
|
|||
import org.mariotaku.twidere.constant.apiLastChangeKey
|
||||
import org.mariotaku.twidere.constant.bugReportsKey
|
||||
import org.mariotaku.twidere.constant.defaultFeatureLastUpdated
|
||||
import org.mariotaku.twidere.constant.nightModeKey
|
||||
import org.mariotaku.twidere.model.DefaultFeatures
|
||||
import org.mariotaku.twidere.util.*
|
||||
import org.mariotaku.twidere.util.content.TwidereSQLiteOpenHelper
|
||||
|
@ -98,8 +96,6 @@ class TwidereApplication : Application(), Constants, OnSharedPreferenceChangeLis
|
|||
if (BuildConfig.DEBUG) {
|
||||
StrictModeUtils.detectAllVmPolicy()
|
||||
}
|
||||
val preferences = sharedPreferences
|
||||
resetTheme(preferences)
|
||||
super.onCreate()
|
||||
startKovenant()
|
||||
initializeAsyncTask()
|
||||
|
@ -238,15 +234,6 @@ class TwidereApplication : Application(), Constants, OnSharedPreferenceChangeLis
|
|||
KEY_EMOJI_SUPPORT -> {
|
||||
externalThemeManager.reloadEmojiPreferences()
|
||||
}
|
||||
KEY_THEME -> {
|
||||
resetTheme(preferences)
|
||||
}
|
||||
KEY_THEME_BACKGROUND -> {
|
||||
}
|
||||
KEY_PROFILE_IMAGE_STYLE -> {
|
||||
}
|
||||
KEY_THEME_COLOR -> {
|
||||
}
|
||||
KEY_THUMBOR_ADDRESS, KEY_THUMBOR_ENABLED, KEY_THUMBOR_SECURITY_KEY -> {
|
||||
(mediaDownloader as TwidereMediaDownloader).reloadConnectivitySettings()
|
||||
}
|
||||
|
@ -258,10 +245,6 @@ class TwidereApplication : Application(), Constants, OnSharedPreferenceChangeLis
|
|||
stopKovenant()
|
||||
}
|
||||
|
||||
private fun resetTheme(preferences: SharedPreferences) {
|
||||
AppCompatDelegate.setDefaultNightMode(preferences[nightModeKey])
|
||||
}
|
||||
|
||||
private fun reloadDnsSettings() {
|
||||
dns.reloadDnsSettings()
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:title="@string/theme">
|
||||
<extra
|
||||
android:name="recreate_activity"
|
||||
android:value="false"/>
|
||||
android:value="true"/>
|
||||
</org.mariotaku.twidere.preference.EntrySummaryListPreference>
|
||||
|
||||
<org.mariotaku.twidere.preference.ThemeBackgroundPreference
|
||||
|
|
Loading…
Reference in New Issue