Fixes ApnEditor not restoring previous UI

ApnEditor tries read and set the UI in onCreate, before the previous bundle
is restored. This caused problems when the configuration has changed (such
as switching to Dark Theme).

This moves the UI changes to onViewRestored

Fixes: 146399432
Test: make SettingsGoogle and manual test UI
Change-Id: I8147ec96569fa28867c088d6c36584aa344f40ed
This commit is contained in:
Lee Chou
2020-02-27 11:50:03 +08:00
parent 9f6351b596
commit c12b1b40ee

View File

@@ -39,6 +39,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
@@ -388,8 +389,12 @@ public class ApnEditor extends SettingsPreferenceFragment
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) { for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(this); getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(this);
} }
}
fillUI(icicle == null); @Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
fillUI(savedInstanceState == null);
} }
@VisibleForTesting @VisibleForTesting