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

Commit 1e56a10e authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Remove the action icon on "Switch to personal profile"

Add a new class ProfileItem extends AppItem.
Don't show the action icon on ProfileItem.

Test: atest DocumentsUITests
Change-Id: I255aed31871632a33c49b568a45cfc24590ddbd5
Fix: 121000424
parent 46f01c16
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -54,6 +54,15 @@ class AppItem extends Item {
        return component;
    }

    protected void bindActionIcon(View actionIconArea, ImageView actionIcon) {
        actionIconArea.setVisibility(View.VISIBLE);
        actionIconArea.setFocusable(false);
        actionIcon.setImageDrawable(
                IconUtils.applyTintColor(actionIcon.getContext(), R.drawable.ic_exit_to_app,
                        R.color.item_action_icon));

    }

    @Override
    boolean showAppDetails() {
        mActionHandler.showAppDetails(info);
@@ -73,10 +82,7 @@ class AppItem extends Item {
        icon.setImageDrawable(info.loadIcon(pm));
        titleView.setText(title);

        actionIconArea.setVisibility(View.VISIBLE);
        actionIconArea.setFocusable(false);
        actionIcon.setImageDrawable(IconUtils.applyTintColor(context, R.drawable.ic_exit_to_app,
                R.color.item_action_icon));
        bindActionIcon(actionIconArea, actionIcon);

        // TODO: match existing summary behavior from disambig dialog
        summary.setVisibility(View.GONE);
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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.sidebar;

import android.content.pm.ResolveInfo;
import android.view.View;
import android.widget.ImageView;

import com.android.documentsui.ActionHandler;

/**
 * An {@link Item} for switch profile. This is only used in pickers.
 */
class ProfileItem extends AppItem {

    public ProfileItem(ResolveInfo info, String title, ActionHandler actionHandler) {
        super(info, title, actionHandler);
    }

    @Override
    protected void bindActionIcon(View actionIconArea, ImageView actionIcon) {
        actionIconArea.setVisibility(View.GONE);
    }

    @Override
    public String toString() {
        return "ProfileItem{"
                + "id=" + stringId
                + ", resolveInfo=" + info
                + "}";
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -45,14 +45,14 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.loader.app.LoaderManager;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.documentsui.ActionHandler;
import com.android.documentsui.BaseActivity;
@@ -342,7 +342,7 @@ public class RootsFragment extends Fragment {
        final List<Item> rootList = new ArrayList<>();
        final Map<String, ResolveInfo> appsMapping = new HashMap<>();
        final Map<String, Item> appItems = new HashMap<>();
        Item profileItem = null;
        ProfileItem profileItem = null;

        // Omit ourselves and maybe calling package from the list
        for (ResolveInfo info : infos) {
@@ -351,15 +351,15 @@ public class RootsFragment extends Fragment {
                    !TextUtils.equals(excludePackage, packageName)) {
                appsMapping.put(packageName, info);

                final Item item = new AppItem(info, info.loadLabel(pm).toString(), mActionHandler);

                if (VERBOSE) Log.v(TAG, "Adding handler app: " + item);

                // for change personal profile root.
                if (PROFILE_TARGET_ACTIVITY.equals(info.activityInfo.targetActivity)) {
                    profileItem = item;
                    profileItem = new ProfileItem(info, info.loadLabel(pm).toString(),
                            mActionHandler);
                } else {
                    final Item item = new AppItem(info, info.loadLabel(pm).toString(),
                            mActionHandler);
                    appItems.put(packageName, item);
                    if (VERBOSE) Log.v(TAG, "Adding handler app: " + item);
                }
            }
        }