Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cddf57d6 authored by cketti's avatar cketti
Browse files

Restart activities if theme or language settings have changed

parent ec9d82dd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -39,6 +39,12 @@ public abstract class K9Activity extends AppCompatActivity implements K9Activity
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onResume() {
        base.preOnResume();
        super.onResume();
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        base.preDispatchTouchEvent(event);
+14 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import android.view.MotionEvent
import com.fsck.k9.K9
import com.fsck.k9.activity.misc.SwipeGestureDetector
import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener
import com.fsck.k9.ui.Theme
import com.fsck.k9.ui.ThemeManager
import org.koin.standalone.KoinComponent
import org.koin.standalone.inject
@@ -25,6 +26,8 @@ class K9ActivityCommon(
        private val themeType: ThemeType
) {
    private var gestureDetector: GestureDetector? = null
    private lateinit var currentLanguage: String
    private lateinit var currentTheme: Theme

    val themeManager = Companion.themeManager

@@ -33,8 +36,12 @@ class K9ActivityCommon(
     * Call this before calling `super.onCreate(Bundle)`.
     */
    fun preOnCreate() {
        setLanguage(K9.k9Language)
        K9.k9Language.let { language ->
            currentLanguage = language
            setLanguage(language)
        }

        currentTheme = themeManager.appTheme
        val theme = when (themeType) {
            ThemeType.DEFAULT -> themeManager.appThemeResourceId
            ThemeType.ACTION_BAR -> themeManager.appActionBarThemeResourceId
@@ -43,6 +50,12 @@ class K9ActivityCommon(
        activity.setTheme(theme)
    }

    fun preOnResume() {
        if (currentTheme != themeManager.appTheme || currentLanguage != K9.k9Language) {
            activity.recreate()
        }
    }

    /**
     * Call this before calling `super.dispatchTouchEvent(MotionEvent)`.
     */
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public abstract class K9PreferenceActivity extends AppCompatPreferenceActivity i

    @Override
    protected void onResume() {
        base.preOnResume();
        super.onResume();
        lifecycleRegistry.markState(State.RESUMED);
    }
+6 −0
Original line number Diff line number Diff line
@@ -61,6 +61,12 @@ public class NotificationDeleteConfirmation extends AppCompatActivity {
        showDialog(DIALOG_CONFIRM);
    }

    @Override
    protected void onResume() {
        base.preOnResume();
        super.onResume();
    }

    private void extractExtras() {
        Intent intent = getIntent();
        String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT_UUID);
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,12 @@ public class OpenPgpAppSelectDialog extends FragmentActivity {
        }
    }

    @Override
    protected void onResume() {
        base.preOnResume();
        super.onResume();
    }

    @Override
    protected void onStop() {
        isStopped = true;