Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1063771 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add ability to force rebuild list

So that you can change between filters that
have the same sort order.

Test: robotests, manually switch between notifications (off) to
notifications (all)
Fixes: 169943424

Change-Id: I62bbe90f30abada2ec342487a1fa420e451b3caf
parent bf6c779c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -768,7 +768,7 @@ public class ManageApplications extends InstrumentedFragment
        int i = item.getItemId();
        if (i == R.id.sort_order_alpha || i == R.id.sort_order_size) {
            if (mApplications != null) {
                mApplications.rebuild(menuId);
                mApplications.rebuild(menuId, false);
            }
        } else if (i == R.id.show_system || i == R.id.hide_system) {
            mShowSystem = !mShowSystem;
@@ -1097,13 +1097,13 @@ public class ManageApplications extends InstrumentedFragment
            // Notification filters require resorting the list
            if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
                if (FILTER_APPS_FREQUENT == appFilter.getFilterType()) {
                    rebuild(R.id.sort_order_frequent_notification);
                    rebuild(R.id.sort_order_frequent_notification, false);
                } else if (FILTER_APPS_RECENT == appFilter.getFilterType()) {
                    rebuild(R.id.sort_order_recent_notification);
                    rebuild(R.id.sort_order_recent_notification, false);
                } else if (FILTER_APPS_BLOCKED == appFilter.getFilterType()) {
                    rebuild(R.id.sort_order_alpha);
                    rebuild(R.id.sort_order_alpha, true);
                } else {
                    rebuild(R.id.sort_order_alpha);
                    rebuild(R.id.sort_order_alpha, true);
                }
            } else {
                rebuild();
@@ -1121,7 +1121,7 @@ public class ManageApplications extends InstrumentedFragment
                }
                rebuild();
            } else {
                rebuild(sort);
                rebuild(sort, false);
            }
        }

@@ -1149,8 +1149,8 @@ public class ManageApplications extends InstrumentedFragment
            }
        }

        public void rebuild(int sort) {
            if (sort == mLastSortMode) {
        public void rebuild(int sort, boolean force) {
            if (sort == mLastSortMode && !force) {
                return;
            }
            mManageApplications.mSortOrder = sort;
+5 −2
Original line number Diff line number Diff line
@@ -455,10 +455,13 @@ public class ManageApplicationsTest {
        ManageApplications.ApplicationsAdapter adapter = new ManageApplications.ApplicationsAdapter(
                mState, mFragment, mock(AppFilterItem.class), mock(Bundle.class));

        adapter.rebuild(mSortRecent.getItemId());
        adapter.rebuild(mSortRecent.getItemId(), false);
        assertThat(mFragment.mSortOrder).isEqualTo(mSortRecent.getItemId());

        adapter.rebuild(mSortFrequent.getItemId());
        adapter.rebuild(mSortFrequent.getItemId(), false);
        assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());

        adapter.rebuild(mSortFrequent.getItemId(), true);
        assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());
    }