Loading src/com/android/documentsui/base/State.java +7 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,11 @@ public class State implements android.os.Parcelable { public boolean openableOnly; public boolean restrictScopeStorage; /** * Represents whether the state supports cross-profile file picking. */ public boolean supportsCrossProfile = false; /** * Represents whether the intent is a cross-profile intent */ Loading Loading @@ -151,10 +156,10 @@ public class State implements android.os.Parcelable { } /** * Returns true if the action of the {@link State} can support cross-profile by DocsUI. * Returns true if DocsUI supports cross-profile for this {@link State}. */ public boolean supportsCrossProfile() { return action == ACTION_GET_CONTENT; return supportsCrossProfile; } @Override Loading src/com/android/documentsui/picker/PickActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import com.android.documentsui.util.CrossProfileUtils; import com.android.documentsui.util.VersionUtils; import java.util.Collection; import java.util.Collections; Loading Loading @@ -265,6 +266,9 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons { state.copyOperationSubType = intent.getIntExtra( FileOperationService.EXTRA_OPERATION_TYPE, FileOperationService.OPERATION_COPY); } else if (Features.CROSS_PROFILE_TABS && VersionUtils.isAtLeastR() && state.action == ACTION_GET_CONTENT) { state.supportsCrossProfile = true; } } Loading tests/unit/com/android/documentsui/GlobalSearchLoaderTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public class GlobalSearchLoaderTest { @Test public void testCrossProfileRoot_notInTextSearch_beIgnored() { mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; mQueryArgs.remove(DocumentsContract.QUERY_ARG_DISPLAY_NAME); TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.OtherUser.USER_ID; assertThat(mLoader.shouldIgnoreRoot(TestProvidersAccess.DOWNLOADS)).isTrue(); Loading @@ -116,7 +116,7 @@ public class GlobalSearchLoaderTest { @Test public void testCrossProfileRoot_inTextSearch_beIncluded() { mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.OtherUser.USER_ID; assertThat(mLoader.shouldIgnoreRoot(TestProvidersAccess.DOWNLOADS)).isFalse(); TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.USER_ID; Loading Loading @@ -250,7 +250,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_includeCurrentUserRootOnly() { mEnv.state.canShareAcrossProfile = false; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading Loading @@ -284,7 +284,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_includeBothUsersRoots() { mEnv.state.canShareAcrossProfile = true; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading Loading @@ -318,7 +318,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_emptyCurrentUsersRoot() { mEnv.state.canShareAcrossProfile = false; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading tests/unit/com/android/documentsui/ProfileTabsTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public class ProfileTabsTest { mContext.getTheme().applyStyle(R.style.DocumentsDefaultTheme, false); LayoutInflater layoutInflater = LayoutInflater.from(mContext); mState = new State(); mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; mState.stack.changeRoot(TestProvidersAccess.DOWNLOADS); mState.stack.push(TestEnv.FOLDER_0); View view = layoutInflater.inflate(R.layout.directory_header, null); Loading Loading @@ -104,10 +104,10 @@ public class ProfileTabsTest { } @Test public void testUpdateView_twoUsers_browse_shouldHide() { public void testUpdateView_twoUsers_doesNotSupportCrossProfile_shouldHide() { initializeWithUsers(systemUser, managedUser); mState.action = State.ACTION_BROWSE; mState.supportsCrossProfile = false; mProfileTabs.updateView(); assertThat(mTabLayout.getVisibility()).isEqualTo(View.GONE); Loading tests/unit/com/android/documentsui/dirlist/AppsRowManagerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -231,7 +231,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_crossProfileSearch_hideRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; when(mActivity.isSearchExpanded()).thenReturn(true); mState.stack.changeRoot(TestProvidersAccess.RECENTS); Loading @@ -252,7 +252,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_notCrossProfileSearch_showRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; when(mActivity.isSearchExpanded()).thenReturn(false); mState.stack.changeRoot(TestProvidersAccess.RECENTS); Loading @@ -273,7 +273,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_noItemsOnSelectedUser_hideRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; mState.stack.changeRoot(TestProvidersAccess.RECENTS); when(mActivity.getSelectedUser()).thenReturn(TestProvidersAccess.OtherUser.USER_ID); Loading Loading
src/com/android/documentsui/base/State.java +7 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,11 @@ public class State implements android.os.Parcelable { public boolean openableOnly; public boolean restrictScopeStorage; /** * Represents whether the state supports cross-profile file picking. */ public boolean supportsCrossProfile = false; /** * Represents whether the intent is a cross-profile intent */ Loading Loading @@ -151,10 +156,10 @@ public class State implements android.os.Parcelable { } /** * Returns true if the action of the {@link State} can support cross-profile by DocsUI. * Returns true if DocsUI supports cross-profile for this {@link State}. */ public boolean supportsCrossProfile() { return action == ACTION_GET_CONTENT; return supportsCrossProfile; } @Override Loading
src/com/android/documentsui/picker/PickActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import com.android.documentsui.sidebar.RootsFragment; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import com.android.documentsui.util.CrossProfileUtils; import com.android.documentsui.util.VersionUtils; import java.util.Collection; import java.util.Collections; Loading Loading @@ -265,6 +266,9 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons { state.copyOperationSubType = intent.getIntExtra( FileOperationService.EXTRA_OPERATION_TYPE, FileOperationService.OPERATION_COPY); } else if (Features.CROSS_PROFILE_TABS && VersionUtils.isAtLeastR() && state.action == ACTION_GET_CONTENT) { state.supportsCrossProfile = true; } } Loading
tests/unit/com/android/documentsui/GlobalSearchLoaderTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public class GlobalSearchLoaderTest { @Test public void testCrossProfileRoot_notInTextSearch_beIgnored() { mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; mQueryArgs.remove(DocumentsContract.QUERY_ARG_DISPLAY_NAME); TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.OtherUser.USER_ID; assertThat(mLoader.shouldIgnoreRoot(TestProvidersAccess.DOWNLOADS)).isTrue(); Loading @@ -116,7 +116,7 @@ public class GlobalSearchLoaderTest { @Test public void testCrossProfileRoot_inTextSearch_beIncluded() { mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.OtherUser.USER_ID; assertThat(mLoader.shouldIgnoreRoot(TestProvidersAccess.DOWNLOADS)).isFalse(); TestProvidersAccess.DOWNLOADS.userId = TestProvidersAccess.USER_ID; Loading Loading @@ -250,7 +250,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_includeCurrentUserRootOnly() { mEnv.state.canShareAcrossProfile = false; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading Loading @@ -284,7 +284,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_includeBothUsersRoots() { mEnv.state.canShareAcrossProfile = true; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading Loading @@ -318,7 +318,7 @@ public class GlobalSearchLoaderTest { @Test public void testSearchResult_emptyCurrentUsersRoot() { mEnv.state.canShareAcrossProfile = false; mEnv.state.action = State.ACTION_GET_CONTENT; mEnv.state.supportsCrossProfile = true; final DocumentInfo pdfDoc = mEnv.model.createFile(SEARCH_STRING + ".pdf"); pdfDoc.lastModified = System.currentTimeMillis(); Loading
tests/unit/com/android/documentsui/ProfileTabsTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public class ProfileTabsTest { mContext.getTheme().applyStyle(R.style.DocumentsDefaultTheme, false); LayoutInflater layoutInflater = LayoutInflater.from(mContext); mState = new State(); mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; mState.stack.changeRoot(TestProvidersAccess.DOWNLOADS); mState.stack.push(TestEnv.FOLDER_0); View view = layoutInflater.inflate(R.layout.directory_header, null); Loading Loading @@ -104,10 +104,10 @@ public class ProfileTabsTest { } @Test public void testUpdateView_twoUsers_browse_shouldHide() { public void testUpdateView_twoUsers_doesNotSupportCrossProfile_shouldHide() { initializeWithUsers(systemUser, managedUser); mState.action = State.ACTION_BROWSE; mState.supportsCrossProfile = false; mProfileTabs.updateView(); assertThat(mTabLayout.getVisibility()).isEqualTo(View.GONE); Loading
tests/unit/com/android/documentsui/dirlist/AppsRowManagerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -231,7 +231,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_crossProfileSearch_hideRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; when(mActivity.isSearchExpanded()).thenReturn(true); mState.stack.changeRoot(TestProvidersAccess.RECENTS); Loading @@ -252,7 +252,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_notCrossProfileSearch_showRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; when(mActivity.isSearchExpanded()).thenReturn(false); mState.stack.changeRoot(TestProvidersAccess.RECENTS); Loading @@ -273,7 +273,7 @@ public class AppsRowManagerTest { @Test public void testUpdateView_noItemsOnSelectedUser_hideRow() { mState.action = State.ACTION_GET_CONTENT; mState.supportsCrossProfile = true; mState.stack.changeRoot(TestProvidersAccess.RECENTS); when(mActivity.getSelectedUser()).thenReturn(TestProvidersAccess.OtherUser.USER_ID); Loading