Filter status is not retained in App info

Selected filter is not retained after device orientation changed.

In old design, we only update selected index one time when the
enabled filter(filterType) equals the previous selected filter.
After that, the selected index won't be changed again.

But we sort the filter options every time(Collections.sort) when
we add a new filter. Therefore, it makes all indexes of filters
option could be changed.

For example,
Old filter options => All apps, Personal, Work
Selected index = 1

Add "Intsalled app" option => All apps, Installed app, Personal, Work
Selected filter option becomes "Installed app" but not Personal.

Since we saved previous selected filter option before device
orientation changes, we can check again whether or not the selected
index is previous filter type when we enable any new filter.

Test: manual test, robotest
Fixes: 120798975

Change-Id: I35de186a6a1fae3bd863bd31a6ce3f76861dc896
This commit is contained in:
tmfang
2018-12-12 19:05:38 +08:00
committed by Tsung-Mao Fang
parent 2602e42b65
commit 046c10ac30

View File

@@ -817,13 +817,12 @@ public class ManageApplications extends InstrumentedFragment
mManageApplications.onItemSelected(null, null, 0, 0);
}
if (mFilterOptions.size() > 1) {
if (filterType == mManageApplications.mFilterType) {
int index = mFilterOptions.indexOf(filter);
if (index != -1) {
mManageApplications.mFilterSpinner.setSelection(index);
mManageApplications.onItemSelected(null, null, index, 0);
mManageApplications.mFilterType = AppFilterRegistry.FILTER_APPS_ALL;
}
final AppFilterItem previousFilter = AppFilterRegistry.getInstance().get(
mManageApplications.mFilterType);
final int index = mFilterOptions.indexOf(previousFilter);
if (index != -1) {
mManageApplications.mFilterSpinner.setSelection(index);
mManageApplications.onItemSelected(null, null, index, 0);
}
}
}