From 1c8244f8914ae3df40f14f87c7a8ce605707c481 Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Fri, 10 Jul 2020 13:07:03 -0700 Subject: Make sure SearchFragment was dismissed when closing search. Bug: 160955461 Test: atest DocumentsUIGoogleTests Change-Id: I431ebfa095b51632eb3a794bb16ec02789cd0aec --- src/com/android/documentsui/queries/SearchViewManager.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/com/android/documentsui/queries/SearchViewManager.java b/src/com/android/documentsui/queries/SearchViewManager.java index e94e900e8..a978ceaab 100644 --- a/src/com/android/documentsui/queries/SearchViewManager.java +++ b/src/com/android/documentsui/queries/SearchViewManager.java @@ -420,6 +420,11 @@ public class SearchViewManager implements // Refresh the directory if a search was done if (mCurrentSearch != null || mChipViewManager.hasCheckedItems()) { + // Make sure SearchFragment was dismissed. + if (mFragmentManager != null) { + SearchFragment.dismissFragment(mFragmentManager); + } + // Clear checked chips mChipViewManager.clearCheckedChips(); mCurrentSearch = null; -- cgit v1.2.3 From ff9e2bc5e05099a4f58ed13407d084d131d81bbb Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Fri, 10 Jul 2020 13:07:03 -0700 Subject: Make sure SearchFragment was dismissed when closing search. Bug: 160955461 Test: atest DocumentsUIGoogleTests Change-Id: I431ebfa095b51632eb3a794bb16ec02789cd0aec (cherry picked from commit 1c8244f8914ae3df40f14f87c7a8ce605707c481) --- src/com/android/documentsui/queries/SearchViewManager.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/com/android/documentsui/queries/SearchViewManager.java b/src/com/android/documentsui/queries/SearchViewManager.java index e94e900e8..a978ceaab 100644 --- a/src/com/android/documentsui/queries/SearchViewManager.java +++ b/src/com/android/documentsui/queries/SearchViewManager.java @@ -420,6 +420,11 @@ public class SearchViewManager implements // Refresh the directory if a search was done if (mCurrentSearch != null || mChipViewManager.hasCheckedItems()) { + // Make sure SearchFragment was dismissed. + if (mFragmentManager != null) { + SearchFragment.dismissFragment(mFragmentManager); + } + // Clear checked chips mChipViewManager.clearCheckedChips(); mCurrentSearch = null; -- cgit v1.2.3 From 7f7a52c3aa81b71d9fb5b17d79320fe8e0c6ec44 Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Thu, 23 Jul 2020 16:59:06 -0700 Subject: Clear SearchView focus after selecting search history. Bug: 161677790 Test: atest DocumentsUIGoogleTests Change-Id: I0e90e5c1dce0d3395b55f7512545e0e00b810e88 --- src/com/android/documentsui/queries/SearchFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/documentsui/queries/SearchFragment.java b/src/com/android/documentsui/queries/SearchFragment.java index 7f2e779bb..667dc8e48 100644 --- a/src/com/android/documentsui/queries/SearchFragment.java +++ b/src/com/android/documentsui/queries/SearchFragment.java @@ -150,7 +150,7 @@ public class SearchFragment extends Fragment{ final String item = mHistoryList.get(position); mSearchViewManager.setHistorySearch(); mSearchViewManager.setCurrentSearch(item); - mSearchViewManager.restoreSearch(true); + mSearchViewManager.restoreSearch(/* keepFocus= */ false); } private void dismiss() { -- cgit v1.2.3 From 90658fd5225a6d137f8a3bee684f96f04ef2fd99 Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Thu, 23 Jul 2020 16:59:06 -0700 Subject: Clear SearchView focus after selecting search history. Bug: 161677790 Test: atest DocumentsUIGoogleTests Change-Id: I0e90e5c1dce0d3395b55f7512545e0e00b810e88 --- src/com/android/documentsui/queries/SearchFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/documentsui/queries/SearchFragment.java b/src/com/android/documentsui/queries/SearchFragment.java index 7f2e779bb..667dc8e48 100644 --- a/src/com/android/documentsui/queries/SearchFragment.java +++ b/src/com/android/documentsui/queries/SearchFragment.java @@ -150,7 +150,7 @@ public class SearchFragment extends Fragment{ final String item = mHistoryList.get(position); mSearchViewManager.setHistorySearch(); mSearchViewManager.setCurrentSearch(item); - mSearchViewManager.restoreSearch(true); + mSearchViewManager.restoreSearch(/* keepFocus= */ false); } private void dismiss() { -- cgit v1.2.3 From f10b6f4d247f68cd5f90cfbb1a4b8dd931875c49 Mon Sep 17 00:00:00 2001 From: Diksha Gohlyan Date: Tue, 28 Jul 2020 06:41:48 -0700 Subject: isAtleastR to include S as well Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.DocumentsTest Bug: 161370998 Change-Id: Ia9cbab5d947920ba05e01e83cafa08415ed349c2 --- src/com/android/documentsui/util/VersionUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/documentsui/util/VersionUtils.java b/src/com/android/documentsui/util/VersionUtils.java index 58ae3cdca..eecd63132 100644 --- a/src/com/android/documentsui/util/VersionUtils.java +++ b/src/com/android/documentsui/util/VersionUtils.java @@ -31,6 +31,6 @@ public class VersionUtils { */ public static boolean isAtLeastR() { return Build.VERSION.CODENAME.equals("R") - || (Build.VERSION.CODENAME.equals("REL") && Build.VERSION.SDK_INT >= 30); + || Build.VERSION.SDK_INT >= 30; } } -- cgit v1.2.3 From 2dd8b1ccff9601adf13194b02fce90ac1e832867 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Wed, 5 Aug 2020 14:33:46 -0700 Subject: apps/DocumentsUI - Update language to comply with Android's inclusive language guidance. See https://source.android.com/setup/contribute/respectful-code for reference BUG=161896447 Test: PresubmitVerify Change-Id: Ib988d550fb4da2dac7dad02ab0d853418f56d7f4 --- .../android/documentsui/AbstractActionHandler.java | 2 +- src/com/android/documentsui/BaseActivity.java | 2 +- .../android/documentsui/DocsSelectionHelper.java | 4 +- src/com/android/documentsui/DrawerController.java | 10 +- .../documentsui/DummyProfileTabsAddons.java | 28 ----- .../android/documentsui/DummySelectionTracker.java | 131 -------------------- .../android/documentsui/StubProfileTabsAddons.java | 28 +++++ .../android/documentsui/StubSelectionTracker.java | 132 +++++++++++++++++++++ src/com/android/documentsui/base/DummyLookup.java | 26 ---- src/com/android/documentsui/base/StubLookup.java | 28 +++++ .../documentsui/dirlist/DirectoryFragment.java | 4 +- .../documentsui/dirlist/DocumentsAdapter.java | 4 +- .../documentsui/dirlist/DragStartListener.java | 2 +- .../android/documentsui/files/FilesActivity.java | 6 +- .../android/documentsui/inspector/DebugView.java | 4 +- src/com/android/documentsui/sidebar/RootItem.java | 12 +- .../documentsui/sidebar/RootItemListBuilder.java | 10 +- .../android/documentsui/sidebar/SpacerItem.java | 2 +- 18 files changed, 219 insertions(+), 216 deletions(-) delete mode 100644 src/com/android/documentsui/DummyProfileTabsAddons.java delete mode 100644 src/com/android/documentsui/DummySelectionTracker.java create mode 100644 src/com/android/documentsui/StubProfileTabsAddons.java create mode 100644 src/com/android/documentsui/StubSelectionTracker.java delete mode 100644 src/com/android/documentsui/base/DummyLookup.java create mode 100644 src/com/android/documentsui/base/StubLookup.java (limited to 'src') diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java index 0c612eddd..d2f7e41c6 100644 --- a/src/com/android/documentsui/AbstractActionHandler.java +++ b/src/com/android/documentsui/AbstractActionHandler.java @@ -745,7 +745,7 @@ public abstract class AbstractActionHandler { private final DelegateFactory mFactory; - // initialize to a dummy object incase we get some input + // initialize to a stub object incase we get some input // event drive calls before we're properly initialized. // See: b/69306667. - private SelectionTracker mDelegate = new DummySelectionTracker<>(); + private SelectionTracker mDelegate = new StubSelectionTracker<>(); @VisibleForTesting DocsSelectionHelper(DelegateFactory factory) { diff --git a/src/com/android/documentsui/DrawerController.java b/src/com/android/documentsui/DrawerController.java index cb536162d..56b3a879f 100644 --- a/src/com/android/documentsui/DrawerController.java +++ b/src/com/android/documentsui/DrawerController.java @@ -55,7 +55,7 @@ public abstract class DrawerController implements DrawerListener { DrawerLayout layout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); if (layout == null) { - return new DummyDrawerController(); + return new StubDrawerController(); } View drawer = activity.findViewById(R.id.drawer_roots); @@ -76,8 +76,8 @@ public abstract class DrawerController implements DrawerListener { /** * Returns a controller suitable for {@code Layout}. */ - static DrawerController createDummy() { - return new DummyDrawerController(); + static DrawerController createStub() { + return new StubDrawerController(); } private static int calculateDrawerWidth(Activity activity) { @@ -235,9 +235,9 @@ public abstract class DrawerController implements DrawerListener { } /* - * Dummy controller useful with clients that don't host a real drawer. + * Stub controller useful with clients that don't host a real drawer. */ - private static final class DummyDrawerController extends DrawerController { + private static final class StubDrawerController extends DrawerController { @Override public void setOpen(boolean open) {} diff --git a/src/com/android/documentsui/DummyProfileTabsAddons.java b/src/com/android/documentsui/DummyProfileTabsAddons.java deleted file mode 100644 index 697025e23..000000000 --- a/src/com/android/documentsui/DummyProfileTabsAddons.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.documentsui; - -/** - * A dummy {@ProfileTabsAddons} implementation. - */ -public class DummyProfileTabsAddons implements ProfileTabsAddons { - - @Override - public void setEnabled(boolean enabled) { - // Do nothing. - } -} diff --git a/src/com/android/documentsui/DummySelectionTracker.java b/src/com/android/documentsui/DummySelectionTracker.java deleted file mode 100644 index 49b9ad918..000000000 --- a/src/com/android/documentsui/DummySelectionTracker.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.documentsui; - -import android.os.Bundle; - -import androidx.recyclerview.selection.MutableSelection; -import androidx.recyclerview.selection.Selection; -import androidx.recyclerview.selection.SelectionTracker; -import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver; - -import java.util.Set; - -/** - * A dummy SelectionTracker used by DocsSelectionHelper before a real SelectionTracker has been - * initialized by DirectoryFragment. - */ -public class DummySelectionTracker extends SelectionTracker { - - @Override - public void addObserver(SelectionObserver observer) { - } - - @Override - public boolean hasSelection() { - return false; - } - - @Override - public Selection getSelection() { - return new MutableSelection(); - } - - @Override - public void copySelection(MutableSelection dest) { - } - - @Override - public boolean isSelected(K key) { - return false; - } - - @Override - public void restoreSelection(Selection selection) { - } - - @Override - public boolean clearSelection() { - return false; - } - - @Override - public boolean setItemsSelected(Iterable keys, boolean selected) { - return false; - } - - @Override - public boolean select(K key) { - return false; - } - - @Override - public boolean deselect(K key) { - return false; - } - - @Override - protected AdapterDataObserver getAdapterDataObserver() { - return null; - } - - @Override - public void startRange(int position) { - } - - @Override - public void extendRange(int position) { - } - - @Override - public void endRange() { - } - - @Override - public boolean isRangeActive() { - return false; - } - - @Override - public void anchorRange(int position) { - } - - @Override - public void extendProvisionalRange(int position) { - } - - @Override - public void setProvisionalSelection(Set newSelection) { - } - - @Override - public void clearProvisionalSelection() { - } - - @Override - public void mergeProvisionalSelection() { - } - - @Override - public void onSaveInstanceState(Bundle state) { - } - - @Override - public void onRestoreInstanceState(Bundle state) { - } - -} diff --git a/src/com/android/documentsui/StubProfileTabsAddons.java b/src/com/android/documentsui/StubProfileTabsAddons.java new file mode 100644 index 000000000..cac175945 --- /dev/null +++ b/src/com/android/documentsui/StubProfileTabsAddons.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.documentsui; + +/** + * A stub {@ProfileTabsAddons} implementation. + */ +public class StubProfileTabsAddons implements ProfileTabsAddons { + + @Override + public void setEnabled(boolean enabled) { + // Do nothing. + } +} diff --git a/src/com/android/documentsui/StubSelectionTracker.java b/src/com/android/documentsui/StubSelectionTracker.java new file mode 100644 index 000000000..1a392144f --- /dev/null +++ b/src/com/android/documentsui/StubSelectionTracker.java @@ -0,0 +1,132 @@ +/* + * Copyright 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.documentsui; + +import android.os.Bundle; + +import androidx.recyclerview.selection.MutableSelection; +import androidx.recyclerview.selection.Selection; +import androidx.recyclerview.selection.SelectionTracker; +import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver; + +import java.util.Set; + +/** + * A stub SelectionTracker used by DocsSelectionHelper before a real SelectionTracker has been + * initialized by DirectoryFragment. + * @param Selection key type which extends {@link SelectionTracker}. + */ +public class StubSelectionTracker extends SelectionTracker { + + @Override + public void addObserver(SelectionObserver observer) { + } + + @Override + public boolean hasSelection() { + return false; + } + + @Override + public Selection getSelection() { + return new MutableSelection(); + } + + @Override + public void copySelection(MutableSelection dest) { + } + + @Override + public boolean isSelected(K key) { + return false; + } + + @Override + public void restoreSelection(Selection selection) { + } + + @Override + public boolean clearSelection() { + return false; + } + + @Override + public boolean setItemsSelected(Iterable keys, boolean selected) { + return false; + } + + @Override + public boolean select(K key) { + return false; + } + + @Override + public boolean deselect(K key) { + return false; + } + + @Override + protected AdapterDataObserver getAdapterDataObserver() { + return null; + } + + @Override + public void startRange(int position) { + } + + @Override + public void extendRange(int position) { + } + + @Override + public void endRange() { + } + + @Override + public boolean isRangeActive() { + return false; + } + + @Override + public void anchorRange(int position) { + } + + @Override + public void extendProvisionalRange(int position) { + } + + @Override + public void setProvisionalSelection(Set newSelection) { + } + + @Override + public void clearProvisionalSelection() { + } + + @Override + public void mergeProvisionalSelection() { + } + + @Override + public void onSaveInstanceState(Bundle state) { + } + + @Override + public void onRestoreInstanceState(Bundle state) { + } + +} diff --git a/src/com/android/documentsui/base/DummyLookup.java b/src/com/android/documentsui/base/DummyLookup.java deleted file mode 100644 index 11a637580..000000000 --- a/src/com/android/documentsui/base/DummyLookup.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.documentsui.base; - -/** - * Lookup that always returns null. - */ -public final class DummyLookup implements Lookup { - @Override - public V lookup(K key) { - return null; - } -} diff --git a/src/com/android/documentsui/base/StubLookup.java b/src/com/android/documentsui/base/StubLookup.java new file mode 100644 index 000000000..2a2dc9bf1 --- /dev/null +++ b/src/com/android/documentsui/base/StubLookup.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.documentsui.base; + +/** + * Lookup that always returns null. + * @param input type (the "key") which implements {@link Lookup}. + * @param output type (the "value") which implements {@link Lookup}. + */ +public final class StubLookup implements Lookup { + @Override + public V lookup(K key) { + return null; + } +} diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java index 8fa02ca46..91e355a1b 100644 --- a/src/com/android/documentsui/dirlist/DirectoryFragment.java +++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java @@ -367,7 +367,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On mRecView.setItemAnimator(new DirectoryItemAnimator()); mInjector = mActivity.getInjector(); - // Initially, this selection tracker (delegator) uses a dummy implementation, so it must be + // Initially, this selection tracker (delegator) uses a stub implementation, so it must be // updated (reset) when necessary things are ready. mSelectionMgr = mInjector.selectionMgr; mModel = mInjector.getModel(); @@ -492,7 +492,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On this::getModelId, mRecView::findChildViewUnder, DocumentsApplication.getDragAndDropManager(mActivity)) - : DragStartListener.DUMMY; + : DragStartListener.STUB; { // Limiting the scope of the localTracker so nobody uses it. diff --git a/src/com/android/documentsui/dirlist/DocumentsAdapter.java b/src/com/android/documentsui/dirlist/DocumentsAdapter.java index 7d09d689f..41ce73c8c 100644 --- a/src/com/android/documentsui/dirlist/DocumentsAdapter.java +++ b/src/com/android/documentsui/dirlist/DocumentsAdapter.java @@ -36,8 +36,8 @@ import java.util.List; /** * DocumentsAdapter provides glue between a directory Model, and RecyclerView. We've * abstracted this a bit in order to decompose some specialized support - * for adding dummy layout objects (@see SectionBreakDocumentsAdapter). Handling of the - * dummy layout objects was error prone when interspersed with the core mode / adapter code. + * for adding stub layout objects (@see SectionBreakDocumentsAdapter). Handling of the + * stub layout objects was error prone when interspersed with the core mode / adapter code. * * @see ModelBackedDocumentsAdapter * @see DirectoryAddonsAdapter diff --git a/src/com/android/documentsui/dirlist/DragStartListener.java b/src/com/android/documentsui/dirlist/DragStartListener.java index 8fe087229..0adddcca8 100644 --- a/src/com/android/documentsui/dirlist/DragStartListener.java +++ b/src/com/android/documentsui/dirlist/DragStartListener.java @@ -48,7 +48,7 @@ import javax.annotation.Nullable; */ interface DragStartListener { - static final DragStartListener DUMMY = new DragStartListener() { + DragStartListener STUB = new DragStartListener() { @Override public boolean onDragEvent(MotionEvent event) { return false; diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java index 1afb38eac..232f29809 100644 --- a/src/com/android/documentsui/files/FilesActivity.java +++ b/src/com/android/documentsui/files/FilesActivity.java @@ -37,7 +37,6 @@ import com.android.documentsui.ActionModeController; import com.android.documentsui.BaseActivity; import com.android.documentsui.DocsSelectionHelper; import com.android.documentsui.DocumentsApplication; -import com.android.documentsui.DummyProfileTabsAddons; import com.android.documentsui.FocusManager; import com.android.documentsui.Injector; import com.android.documentsui.MenuManager.DirectoryDetails; @@ -49,6 +48,7 @@ import com.android.documentsui.ProviderExecutor; import com.android.documentsui.R; import com.android.documentsui.SharedInputHandler; import com.android.documentsui.ShortcutsUpdater; +import com.android.documentsui.StubProfileTabsAddons; import com.android.documentsui.base.DocumentInfo; import com.android.documentsui.base.Features; import com.android.documentsui.base.RootInfo; @@ -76,7 +76,7 @@ public class FilesActivity extends BaseActivity implements AbstractActionHandler private Injector> mInjector; private ActivityInputHandler mActivityInputHandler; private SharedInputHandler mSharedInputHandler; - private final ProfileTabsAddons mProfileTabsAddonsStub = new DummyProfileTabsAddons(); + private final ProfileTabsAddons mProfileTabsAddonsStub = new StubProfileTabsAddons(); public FilesActivity() { super(R.layout.files_activity, TAG); @@ -150,7 +150,7 @@ public class FilesActivity extends BaseActivity implements AbstractActionHandler mInjector.searchManager = mSearchManager; - // No profile tabs will be shown on FilesActivity. Use a dummy to avoid unnecessary + // No profile tabs will be shown on FilesActivity. Use a stub to avoid unnecessary // operations. mInjector.profileTabsController = new ProfileTabsController( mInjector.selectionMgr, diff --git a/src/com/android/documentsui/inspector/DebugView.java b/src/com/android/documentsui/inspector/DebugView.java index ffd4b7e05..908d19242 100644 --- a/src/com/android/documentsui/inspector/DebugView.java +++ b/src/com/android/documentsui/inspector/DebugView.java @@ -27,8 +27,8 @@ import androidx.annotation.StringRes; import com.android.documentsui.R; import com.android.documentsui.base.DocumentInfo; -import com.android.documentsui.base.DummyLookup; import com.android.documentsui.base.Lookup; +import com.android.documentsui.base.StubLookup; import com.android.documentsui.inspector.InspectorController.DebugDisplay; import java.text.NumberFormat; @@ -47,7 +47,7 @@ public class DebugView extends TableView implements DebugDisplay { private final Context mContext; private final Resources mRes; - private Lookup mExecutors = new DummyLookup<>(); + private Lookup mExecutors = new StubLookup<>(); public DebugView(Context context) { this(context, null); diff --git a/src/com/android/documentsui/sidebar/RootItem.java b/src/com/android/documentsui/sidebar/RootItem.java index 9af396e4c..a0a3210f8 100644 --- a/src/com/android/documentsui/sidebar/RootItem.java +++ b/src/com/android/documentsui/sidebar/RootItem.java @@ -210,13 +210,13 @@ public class RootItem extends Item { } /** - * Creates a dummy root item for a user. A dummy root item is used as a place holder when + * Creates a stub root item for a user. A stub root item is used as a place holder when * there is no such root available. We can therefore show the item on the UI. */ - public static RootItem createDummyItem(RootItem item, UserId targetUser) { - RootInfo dummyRootInfo = RootInfo.copyRootInfo(item.root); - dummyRootInfo.userId = targetUser; - RootItem dummy = new RootItem(dummyRootInfo, item.mActionHandler, item.mMaybeShowBadge); - return dummy; + public static RootItem createStubItem(RootItem item, UserId targetUser) { + RootInfo stubRootInfo = RootInfo.copyRootInfo(item.root); + stubRootInfo.userId = targetUser; + RootItem stub = new RootItem(stubRootInfo, item.mActionHandler, item.mMaybeShowBadge); + return stub; } } diff --git a/src/com/android/documentsui/sidebar/RootItemListBuilder.java b/src/com/android/documentsui/sidebar/RootItemListBuilder.java index 4bdce15f3..b29bd0d87 100644 --- a/src/com/android/documentsui/sidebar/RootItemListBuilder.java +++ b/src/com/android/documentsui/sidebar/RootItemListBuilder.java @@ -37,7 +37,7 @@ import java.util.List; * selected user. * *

If no root of the selected user was added but that of the other user was added, - * a dummy root of that root for the selected user will be generated. + * a stub root of that root for the selected user will be generated. * *

The builder group the roots using {@link Item#stringId} as key. * @@ -45,9 +45,9 @@ import java.util.List; * itemC[10], itemX[0],itemY[10] where root itemX, itemY do not support cross profile. * *

When the selected user is user 0, {@link #getList()} returns itemA[0], itemB[0], - * dummyC[0], itemX[0], itemY[10]. + * stubC[0], itemX[0], itemY[10]. * - *

When the selected user is user 10, {@link #getList()} returns itemA[10], dummyB[10], + *

When the selected user is user 10, {@link #getList()} returns itemA[10], stubB[10], * itemC[10], itemX[0], itemY[10]. */ class RootItemListBuilder { @@ -87,7 +87,7 @@ class RootItemListBuilder { return items; } - // If the root supports cross-profile, we return the added root or create a dummy root if + // If the root supports cross-profile, we return the added root or create a stub root if // it was not added for the selected user. for (RootItem item : items) { if (item.userId.equals(mSelectedUser)) { @@ -96,6 +96,6 @@ class RootItemListBuilder { } } - return Collections.singletonList(RootItem.createDummyItem(testRootItem, mSelectedUser)); + return Collections.singletonList(RootItem.createStubItem(testRootItem, mSelectedUser)); } } diff --git a/src/com/android/documentsui/sidebar/SpacerItem.java b/src/com/android/documentsui/sidebar/SpacerItem.java index d0f49c9d1..44dd75cbb 100644 --- a/src/com/android/documentsui/sidebar/SpacerItem.java +++ b/src/com/android/documentsui/sidebar/SpacerItem.java @@ -25,7 +25,7 @@ import com.android.documentsui.R; import com.android.documentsui.base.UserId; /** - * Dummy {@link Item} for dividers between different types of {@link Item}s. + * Stub {@link Item} for dividers between different types of {@link Item}s. */ class SpacerItem extends Item { private static final String TAG = "SpacerItem"; -- cgit v1.2.3 From 5fa73d1d38d26d9a8c278f06a079accc4846b4fe Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Fri, 7 Aug 2020 15:37:19 -0700 Subject: Hide files with hidden folder on the path(documentID). Bug: 138309749 Test: atest DocumentsUIGoogleTests Change-Id: I5ef3f8a44c4b6acbe07a3ba2aaf08fa50e355094 --- src/com/android/documentsui/base/FilteringCursorWrapper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/documentsui/base/FilteringCursorWrapper.java b/src/com/android/documentsui/base/FilteringCursorWrapper.java index 9e557b4aa..67b7533e5 100644 --- a/src/com/android/documentsui/base/FilteringCursorWrapper.java +++ b/src/com/android/documentsui/base/FilteringCursorWrapper.java @@ -80,8 +80,9 @@ public class FilteringCursorWrapper extends AbstractCursor { cursor.moveToPosition(-1); while (cursor.moveToNext() && mCount < count) { - final String name = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME); - if (!showHiddenFiles && name != null && name.startsWith(".")) { + final String documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID); + if (!showHiddenFiles && documentId != null + && (documentId.startsWith(".") || documentId.contains("/."))) { continue; } mPosition[mCount++] = cursor.getPosition(); -- cgit v1.2.3 From ed7ac98aca0f96ab611e6034ee0efafe4e48b03d Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Fri, 7 Aug 2020 15:37:19 -0700 Subject: Hide files with hidden folder on the path(documentID). Bug: 138309749 Test: atest DocumentsUIGoogleTests Change-Id: I5ef3f8a44c4b6acbe07a3ba2aaf08fa50e355094 (cherry picked from commit 5fa73d1d38d26d9a8c278f06a079accc4846b4fe) --- src/com/android/documentsui/base/FilteringCursorWrapper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/documentsui/base/FilteringCursorWrapper.java b/src/com/android/documentsui/base/FilteringCursorWrapper.java index 9e557b4aa..67b7533e5 100644 --- a/src/com/android/documentsui/base/FilteringCursorWrapper.java +++ b/src/com/android/documentsui/base/FilteringCursorWrapper.java @@ -80,8 +80,9 @@ public class FilteringCursorWrapper extends AbstractCursor { cursor.moveToPosition(-1); while (cursor.moveToNext() && mCount < count) { - final String name = getCursorString(cursor, Document.COLUMN_DISPLAY_NAME); - if (!showHiddenFiles && name != null && name.startsWith(".")) { + final String documentId = getCursorString(cursor, Document.COLUMN_DOCUMENT_ID); + if (!showHiddenFiles && documentId != null + && (documentId.startsWith(".") || documentId.contains("/."))) { continue; } mPosition[mCount++] = cursor.getPosition(); -- cgit v1.2.3 From 43199239dc9709cfeb6fc361ff1d53b3e946b314 Mon Sep 17 00:00:00 2001 From: Zemiao Zhu Date: Mon, 10 Aug 2020 20:12:02 -0700 Subject: Refactor FilteringCursorWrapper to make it easier to extend. Bug: 162368496 Test: atest DocumentsUIGoogleTests Change-Id: Ie971d04f4591432df6342bb7dbeef7bfb55376b8 --- src/com/android/documentsui/DirectoryLoader.java | 12 +-- .../documentsui/MultiRootDocumentsLoader.java | 13 +-- .../documentsui/base/FilteringCursorWrapper.java | 111 ++++++++++++--------- 3 files changed, 76 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/com/android/documentsui/DirectoryLoader.java b/src/com/android/documentsui/DirectoryLoader.java index 458f86112..90dc19ef9 100644 --- a/src/com/android/documentsui/DirectoryLoader.java +++ b/src/com/android/documentsui/DirectoryLoader.java @@ -56,7 +56,6 @@ import java.util.concurrent.Executor; public class DirectoryLoader extends AsyncTaskLoader { private static final String TAG = "DirectoryLoader"; - private static final String[] SEARCH_REJECT_MIMES = new String[] { Document.MIME_TYPE_DIR }; private static final String[] PHOTO_PICKING_ACCEPT_MIMES = new String[] {Document.MIME_TYPE_DIR, MimeTypes.IMAGE_MIME}; @@ -178,17 +177,16 @@ public class DirectoryLoader extends AsyncTaskLoader { } cursor.registerContentObserver(mObserver); - // Filter hidden files. - cursor = new FilteringCursorWrapper(cursor, mState.showHiddenFiles); - + FilteringCursorWrapper filteringCursor = new FilteringCursorWrapper(cursor); + filteringCursor.filterHiddenFiles(mState.showHiddenFiles); if (mSearchMode && !mFeatures.isFoldersInSearchResultsEnabled()) { // There is no findDocumentPath API. Enable filtering on folders in search mode. - cursor = new FilteringCursorWrapper(cursor, null, SEARCH_REJECT_MIMES); + filteringCursor.filterMimes(/* acceptMimes= */ null, SEARCH_REJECT_MIMES); } - if (mPhotoPicking) { - cursor = new FilteringCursorWrapper(cursor, PHOTO_PICKING_ACCEPT_MIMES, null); + filteringCursor.filterMimes(PHOTO_PICKING_ACCEPT_MIMES, /* rejectMimes= */ null); } + cursor = filteringCursor; // TODO: When API tweaks have landed, use ContentResolver.EXTRA_HONORED_ARGS // instead of checking directly for ContentResolver.QUERY_ARG_SORT_COLUMNS (won't work) diff --git a/src/com/android/documentsui/MultiRootDocumentsLoader.java b/src/com/android/documentsui/MultiRootDocumentsLoader.java index 643f122ff..62c4ba828 100644 --- a/src/com/android/documentsui/MultiRootDocumentsLoader.java +++ b/src/com/android/documentsui/MultiRootDocumentsLoader.java @@ -181,17 +181,18 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader