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

Commit ce5c324c authored by Kelvin Kwan's avatar Kelvin Kwan Committed by Android (Google) Code Review
Browse files

Merge "Grey out and disable tabs when selecting files."

parents b9e8a8ec cf0bd746
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -434,6 +434,10 @@ public abstract class BaseActivity
        updateHeaderTitle();
    }

    protected ProfileTabsAddons getProfileTabsAddon() {
        return mNavigator.getProfileTabsAddons();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

+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.
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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;
@@ -67,6 +67,9 @@ public class Injector<T extends ActionHandler> {
    @ContentScoped
    public ActionModeController actionModeController;

    @ContentScoped
    public ProfileTabsController profileTabsController;

    @ContentScoped
    public T actions;

+4 −0
Original line number Diff line number Diff line
@@ -106,6 +106,10 @@ public class NavigationViewManager {
        mSearchBarView.setOnClickListener(listener);
    }

    public ProfileTabsAddons getProfileTabsAddons() {
        return mProfileTabs;
    }

    private void onNavigationIconClicked() {
        if (mDrawer.isPresent()) {
            mDrawer.setOpen(true);
+19 −1
Original line number Diff line number Diff line
@@ -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;

@@ -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;
@@ -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