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

Commit 3f8d8681 authored by Winson Chung's avatar Winson Chung
Browse files

Defer recreation until resumed

- Temporarily work around issue with activity recreation while started
  but not resumed by deferring recreating the activity on theme
  change until after launcher has resumed.

Bug: 162812884
Test: Switch dark mode via QuickSettings, Settings
Test: Change system theme
Change-Id: Ifbc0d538907a30d6b23176cd67353a81b6f8c617
parent ffc06198
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.widget.Toast;

import androidx.annotation.Nullable;

import com.android.launcher3.Launcher.OnResumeCallback;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
@@ -108,10 +109,20 @@ public abstract class BaseDraggingActivity extends BaseActivity

    private void updateTheme() {
        if (mThemeRes != Themes.getActivityThemeRes(this)) {
            // Workaround (b/162812884): The system currently doesn't allow recreating an activity
            // when it is not resumed, in such a case defer recreation until it is possible
            if (hasBeenResumed()) {
                recreate();
            } else {
                addOnResumeCallback(this::recreate);
            }
        }
    }

    protected void addOnResumeCallback(OnResumeCallback callback) {
        // To be overridden
    }

    @Override
    public void onActionModeStarted(ActionMode mode) {
        super.onActionModeStarted(mode);
+1 −0
Original line number Diff line number Diff line
@@ -1943,6 +1943,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        return result;
    }

    @Override
    public void addOnResumeCallback(OnResumeCallback callback) {
        mOnResumeCallbacks.add(callback);
    }