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

Commit 3933cc60 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Fix chips row does not update when new window

Update the chips row in refreshCurrentRootAndDirectory.

Change-Id: I4907df9cb70814196adf23851f60e0f717d14737
Fix: 123698137
Test: atest ActionHandlerTest
parent 521a0147
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -201,8 +201,6 @@ public abstract class BaseActivity
                chipGroup, icicle);
        // initialize the chip sets by accept mime types
        mSearchManager.initChipSets(mState.acceptMimes);
        // update the chip items by the mime types of the root
        mSearchManager.updateChips(getCurrentRoot().derivedMimeTypes);
        // parse the query content from intent when launch the
        // activity at the first time
        if (icicle == null) {
@@ -355,7 +353,6 @@ public abstract class BaseActivity
        }

        updateHeaderTitle();
        mSearchManager.updateChips(root.derivedMimeTypes);
        mAppsRowManager.updateView(this);
    }

@@ -482,6 +479,7 @@ public abstract class BaseActivity

        invalidateOptionsMenu();
        mSortController.onViewModeChanged(mState.derivedMode);
        mSearchManager.updateChips(getCurrentRoot().derivedMimeTypes);
    }

    private final List<String> getExcludedAuthorities() {
+12 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.google.android.material.chip.Chip;
import com.google.common.primitives.Ints;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -71,6 +72,8 @@ public class SearchChipViewManager {
    private final ViewGroup mChipGroup;
    private final List<Integer> mDefaultChipTypes = new ArrayList<>();
    private SearchChipViewManagerListener mListener;
    private String[] mCurrentUpdateMimeTypes;
    private boolean mIsFirstUpdateChipsReady;

    @VisibleForTesting
    Set<SearchChipData> mCheckedChipItems = new HashSet<>();
@@ -194,6 +197,10 @@ public class SearchChipViewManager {
     * @param acceptMimeTypes use this values to filter chips
     */
    public void updateChips(String[] acceptMimeTypes) {
        if (mIsFirstUpdateChipsReady && Arrays.equals(mCurrentUpdateMimeTypes, acceptMimeTypes)) {
            return;
        }

        final Context context = mChipGroup.getContext();
        mChipGroup.removeAllViews();

@@ -209,6 +216,11 @@ public class SearchChipViewManager {
            }
        }
        reorderCheckedChips(null /* clickedChip */, false /* hasAnim */);
        mIsFirstUpdateChipsReady = true;
        mCurrentUpdateMimeTypes = acceptMimeTypes;
        if (mChipGroup.getChildCount() < 2) {
            mChipGroup.setVisibility(View.GONE);
        }
    }


+11 −0
Original line number Diff line number Diff line
@@ -381,6 +381,17 @@ public class ActionHandlerTest {
        mActivity.assertActivityStarted(Intent.ACTION_CHOOSER);
    }

    @Test
    public void testInitLocation_LaunchToStackLocation() {
        DocumentStack path = new DocumentStack(Roots.create("123"), mEnv.model.getDocument("1"));

        Intent intent = LauncherActivity.createLaunchIntent(mActivity);
        intent.putExtra(Shared.EXTRA_STACK, (Parcelable) path);

        mHandler.initLocation(intent);
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
    }

    @Test
    public void testInitLocation_RestoresIfStackIsLoaded() throws Exception {
        mEnv.state.stack.changeRoot(TestProvidersAccess.DOWNLOADS);