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

Commit 6b91e762 authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Update apps row show rule"

parents 1dead30e 1e67177e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -353,7 +353,6 @@ public abstract class BaseActivity
        }

        updateHeaderTitle();
        mAppsRowManager.updateView(this);
    }

    @Override
@@ -480,6 +479,7 @@ public abstract class BaseActivity
        invalidateOptionsMenu();
        mSortController.onViewModeChanged(mState.derivedMode);
        mSearchManager.updateChips(getCurrentRoot().derivedMimeTypes);
        mAppsRowManager.updateView(this);
    }

    private final List<String> getExcludedAuthorities() {
+3 −3
Original line number Diff line number Diff line
@@ -69,17 +69,17 @@ public class AppsRowManager {
        return mDataList;
    }

    private boolean shouldShow(State state, boolean isSearching) {
    private boolean shouldShow(State state) {
        boolean isHiddenAction = state.action == State.ACTION_CREATE
                || state.action == State.ACTION_OPEN_TREE
                || state.action == State.ACTION_PICK_COPY_DESTINATION;
        return state.stack.isRecents() && !isSearching && !isHiddenAction && mDataList.size() > 0;
        return state.stack.isRecents() && !isHiddenAction && mDataList.size() > 0;
    }

    public void updateView(BaseActivity activity) {
        final View appsRowLayout = activity.findViewById(R.id.apps_row);

        if (!shouldShow(activity.getDisplayState(), activity.isSearchExpanded())) {
        if (!shouldShow(activity.getDisplayState())) {
            appsRowLayout.setVisibility(View.GONE);
            return;
        }
+0 −19
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ public class AppsRowManagerTest {
    public void testUpdateView_matchedState_showRow() {
        mState.action = State.ACTION_BROWSE;
        mState.stack.changeRoot(TestProvidersAccess.RECENTS);
        when(mActivity.isSearchExpanded()).thenReturn(false);
        final List<Item> rootList = new ArrayList<>();
        rootList.add(new RootItem(TestProvidersAccess.INSPECTOR, mActionHandler));
        mAppsRowManager.updateList(rootList);
@@ -130,7 +129,6 @@ public class AppsRowManagerTest {
    @Test
    public void testUpdateView_notInRecent_hideRow() {
        mState.action = State.ACTION_BROWSE;
        when(mActivity.isSearchExpanded()).thenReturn(false);
        final List<Item> rootList = new ArrayList<>();
        rootList.add(new RootItem(TestProvidersAccess.INSPECTOR, mActionHandler));
        mAppsRowManager.updateList(rootList);
@@ -147,7 +145,6 @@ public class AppsRowManagerTest {
        mState.action = State.ACTION_OPEN_TREE;

        mState.stack.changeRoot(TestProvidersAccess.RECENTS);
        when(mActivity.isSearchExpanded()).thenReturn(false);
        final List<Item> rootList = new ArrayList<>();
        rootList.add(new RootItem(TestProvidersAccess.INSPECTOR, mActionHandler));
        mAppsRowManager.updateList(rootList);
@@ -161,7 +158,6 @@ public class AppsRowManagerTest {
    public void testUpdateView_noItems_hideRow() {
        mState.action = State.ACTION_BROWSE;
        mState.stack.changeRoot(TestProvidersAccess.RECENTS);
        when(mActivity.isSearchExpanded()).thenReturn(false);

        final List<Item> rootList = new ArrayList<>();
        mAppsRowManager.updateList(rootList);
@@ -170,20 +166,5 @@ public class AppsRowManagerTest {

        assertEquals(View.GONE, mAppsRow.getVisibility());
    }

    @Test
    public void testUpdateView_inSearching_hideRow() {
        mState.action = State.ACTION_BROWSE;
        mState.stack.changeRoot(TestProvidersAccess.RECENTS);
        final List<Item> rootList = new ArrayList<>();
        rootList.add(new RootItem(TestProvidersAccess.INSPECTOR, mActionHandler));
        mAppsRowManager.updateList(rootList);

        when(mActivity.isSearchExpanded()).thenReturn(true);

        mAppsRowManager.updateView(mActivity);

        assertEquals(View.GONE, mAppsRow.getVisibility());
    }
}