[Settings] Save query status of search view
Bug: 394494567 Test: manual Flag: EXEMPT bugfix Change-Id: Ic82d9ae98c843d96378427aa9e8c9d5e3aa3b5ac
This commit is contained in:
@@ -76,6 +76,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
|
|||||||
|
|
||||||
private static final String TAG = "AppLocalePickerFragment";
|
private static final String TAG = "AppLocalePickerFragment";
|
||||||
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
|
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
|
||||||
|
private static final String EXTRA_SEARCH_VIEW_QUERY = "search_view_query";
|
||||||
private static final String KEY_PREFERENCE_APP_LOCALE_LIST = "app_locale_list";
|
private static final String KEY_PREFERENCE_APP_LOCALE_LIST = "app_locale_list";
|
||||||
private static final String KEY_PREFERENCE_APP_LOCALE_SUGGESTED_LIST =
|
private static final String KEY_PREFERENCE_APP_LOCALE_SUGGESTED_LIST =
|
||||||
"app_locale_suggested_list";
|
"app_locale_suggested_list";
|
||||||
@@ -108,6 +109,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
|
|||||||
@Nullable
|
@Nullable
|
||||||
private ApplicationInfo mApplicationInfo;
|
private ApplicationInfo mApplicationInfo;
|
||||||
private boolean mIsNumberingMode;
|
private boolean mIsNumberingMode;
|
||||||
|
private CharSequence mPreviousSearch = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@NonNull Bundle icicle) {
|
public void onCreate(@NonNull Bundle icicle) {
|
||||||
@@ -137,6 +139,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
|
|||||||
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
|
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
|
||||||
|
mPreviousSearch = icicle.getCharSequence(EXTRA_SEARCH_VIEW_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppLocaleCollector appLocaleCollector = new AppLocaleCollector(mActivity, mPackageName);
|
AppLocaleCollector appLocaleCollector = new AppLocaleCollector(mActivity, mPackageName);
|
||||||
@@ -163,6 +166,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
if (mSearchView != null) {
|
if (mSearchView != null) {
|
||||||
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
|
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
|
||||||
|
outState.putCharSequence(EXTRA_SEARCH_VIEW_QUERY, mSearchView.getQuery());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +185,15 @@ public class AppLocalePickerFragment extends DashboardFragment implements
|
|||||||
if (mExpandSearch) {
|
if (mExpandSearch) {
|
||||||
searchMenuItem.expandActionView();
|
searchMenuItem.expandActionView();
|
||||||
}
|
}
|
||||||
|
// Restore previous search status
|
||||||
|
if (!TextUtils.isEmpty(mPreviousSearch)) {
|
||||||
|
searchMenuItem.expandActionView();
|
||||||
|
mSearchView.setIconified(false);
|
||||||
|
mSearchView.setActivated(true);
|
||||||
|
mSearchView.setQuery(mPreviousSearch, true /* submit */);
|
||||||
|
} else {
|
||||||
|
mSearchView.setQuery(null, false /* submit */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
|
|||||||
|
|
||||||
private static final String TAG = "SystemLocalePickerFragment";
|
private static final String TAG = "SystemLocalePickerFragment";
|
||||||
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
|
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
|
||||||
|
private static final String EXTRA_SEARCH_VIEW_QUERY = "search_view_query";
|
||||||
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list";
|
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list";
|
||||||
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST =
|
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST =
|
||||||
"system_locale_suggested_list";
|
"system_locale_suggested_list";
|
||||||
@@ -90,6 +91,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
|
|||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private boolean mExpandSearch;
|
private boolean mExpandSearch;
|
||||||
|
private CharSequence mPreviousSearch = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@NonNull Bundle icicle) {
|
public void onCreate(@NonNull Bundle icicle) {
|
||||||
@@ -103,6 +105,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
|
|||||||
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
|
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
|
||||||
|
mPreviousSearch = icicle.getCharSequence(EXTRA_SEARCH_VIEW_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemLocaleCollector systemLocaleCollector = new SystemLocaleCollector(getContext(), null);
|
SystemLocaleCollector systemLocaleCollector = new SystemLocaleCollector(getContext(), null);
|
||||||
@@ -135,6 +138,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
if (mSearchView != null) {
|
if (mSearchView != null) {
|
||||||
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
|
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
|
||||||
|
outState.putCharSequence(EXTRA_SEARCH_VIEW_QUERY, mSearchView.getQuery());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +157,15 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
|
|||||||
if (mExpandSearch) {
|
if (mExpandSearch) {
|
||||||
searchMenuItem.expandActionView();
|
searchMenuItem.expandActionView();
|
||||||
}
|
}
|
||||||
|
// Restore previous search status
|
||||||
|
if (!TextUtils.isEmpty(mPreviousSearch)) {
|
||||||
|
searchMenuItem.expandActionView();
|
||||||
|
mSearchView.setIconified(false);
|
||||||
|
mSearchView.setActivated(true);
|
||||||
|
mSearchView.setQuery(mPreviousSearch, true /* submit */);
|
||||||
|
} else {
|
||||||
|
mSearchView.setQuery(null, false /* submit */);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user