Loading src/com/android/documentsui/BaseActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,10 @@ public abstract class BaseActivity updateHeaderTitle(); } protected ProfileTabsAddons getProfileTabsAddon() { return mNavigator.getProfileTabsAddons(); } @Override public boolean onOptionsItemSelected(MenuItem item) { Loading src/com/android/documentsui/DummyProfileTabsAddons.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * 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. } } src/com/android/documentsui/Injector.java +4 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.view.MenuItem; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.recyclerview.selection.SelectionTracker; import androidx.recyclerview.widget.RecyclerView; Loading @@ -36,7 +37,6 @@ import com.android.documentsui.prefs.ScopedPreferences; import com.android.documentsui.queries.SearchViewManager; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import androidx.annotation.VisibleForTesting; import java.lang.annotation.Retention; import java.lang.annotation.Target; Loading Loading @@ -67,6 +67,9 @@ public class Injector<T extends ActionHandler> { @ContentScoped public ActionModeController actionModeController; @ContentScoped public ProfileTabsController profileTabsController; @ContentScoped public T actions; Loading src/com/android/documentsui/NavigationViewManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public class NavigationViewManager { mSearchBarView.setOnClickListener(listener); } public ProfileTabsAddons getProfileTabsAddons() { return mProfileTabs; } private void onNavigationIconClicked() { if (mDrawer.isPresent()) { mDrawer.setOpen(true); Loading src/com/android/documentsui/ProfileTabs.java +19 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.documentsui; import static androidx.core.util.Preconditions.checkNotNull; import android.view.View; import android.view.ViewGroup; import androidx.annotation.VisibleForTesting; Loading @@ -33,7 +34,8 @@ import java.util.List; /** * A manager class to control UI on a {@link TabLayout} for cross-profile purpose. */ public class ProfileTabs { public class ProfileTabs implements ProfileTabsAddons { private static final float DISABLED_TAB_OPACITY = 0.38f; private final TabLayout mTabs; private final State mState; Loading Loading @@ -103,4 +105,20 @@ public class ProfileTabs { private TabLayout.Tab createTab(int resId, UserId userId) { return mTabs.newTab().setText(resId).setTag(userId); } @Override public void setEnabled(boolean enabled) { if (mTabs.getChildCount() > 0) { View view = mTabs.getChildAt(0); if (view instanceof ViewGroup) { ViewGroup tabs = (ViewGroup) view; for (int i = 0; i < tabs.getChildCount(); i++) { View tabView = tabs.getChildAt(i); tabView.setEnabled(enabled); tabView.setAlpha((enabled || mTabs.getSelectedTabPosition() == i) ? 1f : DISABLED_TAB_OPACITY); } } } } } Loading
src/com/android/documentsui/BaseActivity.java +4 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,10 @@ public abstract class BaseActivity updateHeaderTitle(); } protected ProfileTabsAddons getProfileTabsAddon() { return mNavigator.getProfileTabsAddons(); } @Override public boolean onOptionsItemSelected(MenuItem item) { Loading
src/com/android/documentsui/DummyProfileTabsAddons.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * 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. } }
src/com/android/documentsui/Injector.java +4 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.view.MenuItem; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.recyclerview.selection.SelectionTracker; import androidx.recyclerview.widget.RecyclerView; Loading @@ -36,7 +37,6 @@ import com.android.documentsui.prefs.ScopedPreferences; import com.android.documentsui.queries.SearchViewManager; import com.android.documentsui.ui.DialogController; import com.android.documentsui.ui.MessageBuilder; import androidx.annotation.VisibleForTesting; import java.lang.annotation.Retention; import java.lang.annotation.Target; Loading Loading @@ -67,6 +67,9 @@ public class Injector<T extends ActionHandler> { @ContentScoped public ActionModeController actionModeController; @ContentScoped public ProfileTabsController profileTabsController; @ContentScoped public T actions; Loading
src/com/android/documentsui/NavigationViewManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public class NavigationViewManager { mSearchBarView.setOnClickListener(listener); } public ProfileTabsAddons getProfileTabsAddons() { return mProfileTabs; } private void onNavigationIconClicked() { if (mDrawer.isPresent()) { mDrawer.setOpen(true); Loading
src/com/android/documentsui/ProfileTabs.java +19 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.documentsui; import static androidx.core.util.Preconditions.checkNotNull; import android.view.View; import android.view.ViewGroup; import androidx.annotation.VisibleForTesting; Loading @@ -33,7 +34,8 @@ import java.util.List; /** * A manager class to control UI on a {@link TabLayout} for cross-profile purpose. */ public class ProfileTabs { public class ProfileTabs implements ProfileTabsAddons { private static final float DISABLED_TAB_OPACITY = 0.38f; private final TabLayout mTabs; private final State mState; Loading Loading @@ -103,4 +105,20 @@ public class ProfileTabs { private TabLayout.Tab createTab(int resId, UserId userId) { return mTabs.newTab().setText(resId).setTag(userId); } @Override public void setEnabled(boolean enabled) { if (mTabs.getChildCount() > 0) { View view = mTabs.getChildAt(0); if (view instanceof ViewGroup) { ViewGroup tabs = (ViewGroup) view; for (int i = 0; i < tabs.getChildCount(); i++) { View tabView = tabs.getChildAt(i); tabView.setEnabled(enabled); tabView.setAlpha((enabled || mTabs.getSelectedTabPosition() == i) ? 1f : DISABLED_TAB_OPACITY); } } } } }