Retain and restore showSystem state when rotated

Bug: 182275573
Test: on device
Change-Id: I8a7e2d1ceb715cb6df470d7e3131b82d12ba6fa1
This commit is contained in:
Yu-Han Yang
2021-04-29 15:39:28 -07:00
parent 54e74cae5f
commit c2ea62d1f8

View File

@@ -16,6 +16,7 @@
package com.android.settings.location; package com.android.settings.location;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@@ -36,6 +37,7 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
private static final int MENU_SHOW_SYSTEM = Menu.FIRST + 1; private static final int MENU_SHOW_SYSTEM = Menu.FIRST + 1;
private static final int MENU_HIDE_SYSTEM = Menu.FIRST + 2; private static final int MENU_HIDE_SYSTEM = Menu.FIRST + 2;
private static final String EXTRA_SHOW_SYSTEM = "show_system";
private boolean mShowSystem = false; private boolean mShowSystem = false;
private MenuItem mShowSystemMenu; private MenuItem mShowSystemMenu;
@@ -59,6 +61,23 @@ public class RecentLocationAccessSeeAllFragment extends DashboardFragment {
} }
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mShowSystem = savedInstanceState.getBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
}
if (mController != null) {
mController.setShowSystem(mShowSystem);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
}
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.location_recent_access_see_all; return R.xml.location_recent_access_see_all;