Restore homepage dialog state on screen rotation.
Homepage dialog activity was not saving search url text while
doing screen rotation. Fixed issue via saving url text inside
bundle when 'onSavedInstance' is called and restoring url
from bundle when onCreateDialog is called.
CR-Fixed: 724867
Change-Id: I85e5ddce48f95c398959a2e64141c87e4c83e022
diff --git a/src/com/android/browser/preferences/GeneralPreferencesFragment.java b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
index c2c72b2..f481e73 100644
--- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java
+++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
@@ -230,6 +230,8 @@
Add this class to manage AlertDialog lifecycle.
*/
public static class MyAlertDialogFragment extends DialogFragment {
+ private final String HOME_PAGE = "homepage";
+ private EditText editText = null;
public static MyAlertDialogFragment newInstance() {
MyAlertDialogFragment frag = new MyAlertDialogFragment();
return frag;
@@ -238,10 +240,12 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final BrowserSettings settings = BrowserSettings.getInstance();
- final EditText editText = new EditText(getActivity());
+ editText = new EditText(getActivity());
+ String homePage = savedInstanceState != null ?
+ savedInstanceState.getString(HOME_PAGE): settings.getHomePage();
editText.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_URI);
- editText.setText(settings.getHomePage());
+ editText.setText(homePage);
editText.setSelectAllOnFocus(true);
editText.setSingleLine(true);
editText.setImeActionLabel(null, EditorInfo.IME_ACTION_DONE);
@@ -290,5 +294,11 @@
return dialog;
}
+
+ @Override
+ public void onSaveInstanceState(Bundle outState){
+ super.onSaveInstanceState(outState);
+ outState.putString(HOME_PAGE, editText.getText().toString().trim());
+ }
}
}