pull/1403/head
gedoor 3 years ago
parent d942aeca12
commit 637f31a3b7
  1. 5
      app/src/main/java/io/legado/app/App.kt
  2. 4
      app/src/main/java/io/legado/app/help/LifecycleHelp.kt
  3. 2
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt

@ -7,6 +7,7 @@ import android.content.res.Configuration
import android.os.Build import android.os.Build
import androidx.multidex.MultiDexApplication import androidx.multidex.MultiDexApplication
import com.jeremyliao.liveeventbus.LiveEventBus import com.jeremyliao.liveeventbus.LiveEventBus
import io.legado.app.base.AppContextWrapper
import io.legado.app.constant.AppConst.channelIdDownload import io.legado.app.constant.AppConst.channelIdDownload
import io.legado.app.constant.AppConst.channelIdReadAloud import io.legado.app.constant.AppConst.channelIdReadAloud
import io.legado.app.constant.AppConst.channelIdWeb import io.legado.app.constant.AppConst.channelIdWeb
@ -37,6 +38,10 @@ class App : MultiDexApplication() {
defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig) defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig)
} }
override fun attachBaseContext(base: Context) {
super.attachBaseContext(AppContextWrapper.wrap(base))
}
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
when (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) { when (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) {

@ -3,7 +3,6 @@ package io.legado.app.help
import android.app.Activity import android.app.Activity
import android.app.Application import android.app.Application
import android.os.Bundle import android.os.Bundle
import io.legado.app.base.AppContextWrapper
import io.legado.app.base.BaseService import io.legado.app.base.BaseService
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.util.* import java.util.*
@ -86,9 +85,6 @@ object LifecycleHelp : Application.ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
activities.add(WeakReference(activity)) activities.add(WeakReference(activity))
if (!AppContextWrapper.isSameWithSetting(activity)) {
AppContextWrapper.wrap(activity)
}
} }
@Synchronized @Synchronized

@ -11,7 +11,6 @@ import android.view.View
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.AppContextWrapper
import io.legado.app.base.BasePreferenceFragment import io.legado.app.base.BasePreferenceFragment
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
@ -114,7 +113,6 @@ class OtherConfigFragment : BasePreferenceFragment(),
} }
PreferKey.showDiscovery, PreferKey.showRss -> postEvent(EventBus.NOTIFY_MAIN, true) PreferKey.showDiscovery, PreferKey.showRss -> postEvent(EventBus.NOTIFY_MAIN, true)
PreferKey.language -> listView.postDelayed({ PreferKey.language -> listView.postDelayed({
AppContextWrapper.wrap(appCtx)
val intent = Intent(appCtx, MainActivity::class.java) val intent = Intent(appCtx, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
appCtx.startActivity(intent) appCtx.startActivity(intent)

Loading…
Cancel
Save