feat: Android 10 support

This commit is contained in:
Pun Butrach committed 2026-01-10 20:51:29 +07:00
1 parent a2edbcbe75
commit c8cdde1531
19 files changed
+304 -94

No files matched your search

+33 -2
View File
@@ -113,6 +113,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
SavedStateRegistryController.create(this);
private final LifecycleRegistry mLifecycleRegistry = new LifecycleRegistry(this);
private final WeakCleanupSet mCleanupSet = new WeakCleanupSet(this);
// Keep a reference to the helper to manually dispatch events on older APIs
private final LifecycleHelper mLifecycleHelper;
protected DeviceProfile mDeviceProfile;
protected SystemUiController mSystemUiController;
@@ -198,8 +201,10 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
public BaseActivity() {
mSavedStateRegistryController.performAttach();
registerActivityLifecycleCallbacks(
new LifecycleHelper(this, mSavedStateRegistryController, mLifecycleRegistry));
mLifecycleHelper = new LifecycleHelper(this, mSavedStateRegistryController, mLifecycleRegistry);
if (Utilities.ATLEAST_Q) {
registerActivityLifecycleCallbacks(mLifecycleHelper);
}
}
@Override
@@ -256,6 +261,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityCreated(this, savedInstanceState);
}
registerBackDispatcher();
DisplayController.INSTANCE.get(this).addChangeListener(this);
}
@@ -264,6 +272,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
protected void onStart() {
addActivityFlags(ACTIVITY_STATE_STARTED);
super.onStart();
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityStarted(this);
}
mEventCallbacks[EVENT_STARTED].executeAllAndClear();
}
@@ -271,6 +282,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
protected void onResume() {
setResumed();
super.onResume();
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityResumed(this);
}
mEventCallbacks[EVENT_RESUMED].executeAllAndClear();
}
@@ -293,6 +307,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
removeActivityFlags(ACTIVITY_STATE_STARTED | ACTIVITY_STATE_USER_ACTIVE);
mForceInvisible = 0;
super.onStop();
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityStopped(this);
}
mEventCallbacks[EVENT_STOPPED].executeAllAndClear();
@@ -304,6 +321,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
@Override
protected void onDestroy() {
super.onDestroy();
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityDestroyed(this);
}
mEventCallbacks[EVENT_DESTROYED].executeAllAndClear();
DisplayController.INSTANCE.get(this).removeChangeListener(this);
}
@@ -312,6 +332,9 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
protected void onPause() {
setPaused();
super.onPause();
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivityPaused(this);
}
// Reset the overridden sysui flags used for the task-swipe launch animation, we do this
// here instead of at the end of the animation because the start of the new activity does
@@ -319,6 +342,14 @@ public abstract class BaseActivity extends Activity implements ActivityContext,
// back to the new app (causing a flash)
getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (Utilities.ATLEAST_Q) {
mLifecycleHelper.onActivitySaveInstanceState(this, outState);
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {