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

Commit f7b51308 authored by Kelvin Kwan's avatar Kelvin Kwan Committed by Automerger Merge Worker
Browse files

Merge "Split up side menu to order personal / work apps" into rvc-dev am:...

Merge "Split up side menu to order personal / work apps" into rvc-dev am: 182830e5 am: c7288db9 am: 34df513f am: 883a8789

Change-Id: If338f2c7f3cfc2aa61bfd7805233fbdef911ae2b
parents 87ab917d 883a8789
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -14,14 +14,20 @@
     limitations under the License.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="12dp">
    android:paddingTop="8dp"
    android:paddingBottom="8dp"
    android:gravity="center_vertical">

    <TextView
        android:id="@android:id/title"
        android:textColor="?android:attr/textColorTertiary"
        style="?android:attr/listSeparatorTextViewStyle" />
        android:paddingStart="64dp"
        android:layout_width="wrap_content"
        android:layout_height="44dp"
        android:gravity="center_vertical"
        style="@style/DrawerMenuHeader"/>

</FrameLayout>
</LinearLayout>
+2 −2
Original line number Diff line number Diff line
@@ -526,10 +526,10 @@
    <!-- Content description for deleting search history. [CHAR_LIMIT=60] -->
    <string name="delete_search_history">Delete search history <xliff:g id="text" example="image">%1$s</xliff:g></string>

    <!-- Label of tab to indicate personal directory [CHAR LIMIT=40] -->
    <!-- Label in tab and sidebar to indicate personal content [CHAR LIMIT=40] -->
    <string name="personal_tab">Personal</string>

    <!-- Label of tab to indicate work directory [CHAR LIMIT=40] -->
    <!-- Label in tab and sidebar tab to indicate work content [CHAR LIMIT=40] -->
    <string name="work_tab">Work</string>

    <!-- Accessibility label to indicate the subject(e.g. file/folder) is from work profile -->
+7 −0
Original line number Diff line number Diff line
@@ -64,6 +64,13 @@
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>

    <style name="DrawerMenuHeader" parent="@android:style/TextAppearance.Material.Subhead">
        <item name="android:textColor">?android:attr/textColorSecondary</item>
        <item name="android:textAllCaps">true</item>
        <item name="android:textSize">11sp</item>
        <item name="fontFamily">@string/config_fontFamilyMedium</item>
    </style>

    <style name="DrawerMenuPrimary" parent="android:style/TextAppearance.Material.Body2">
        <item name="android:textSize">14sp</item>
        <item name="android:textColor">@color/item_root_primary_text</item>
+57 −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.sidebar;

import static com.android.documentsui.base.SharedMinimal.DEBUG;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.android.documentsui.R;
import com.android.documentsui.base.UserId;

/**
 * An {@link Item} for displaying text in the side bar.
 */
class HeaderItem extends Item {
    private static final String TAG = "HeaderItem";

    private static final String STRING_ID = "HeaderItem";

    HeaderItem(String title) {
        super(R.layout.item_root_header, title, STRING_ID, UserId.UNSPECIFIED_USER);
    }

    @Override
    void bindView(View convertView) {
        final TextView titleView = convertView.findViewById(android.R.id.title);
        titleView.setText(title);
    }

    @Override
    boolean isRoot() {
        return false;
    }

    @Override
    void open() {
        if (DEBUG) {
            Log.d(TAG, "Ignoring click/hover on spacer item.");
        }
    }
}
+52 −13
Original line number Diff line number Diff line
@@ -377,6 +377,7 @@ public class RootsFragment extends Fragment {
        Context context = getContext();
        final List<Item> rootList = new ArrayList<>();
        final List<Item> rootListOtherUser = new ArrayList<>();
        final List<Item> resultRootList = new ArrayList<>();
        final Map<UserPackage, ResolveInfo> appsMapping = new HashMap<>();
        final Map<UserPackage, Item> appItems = new HashMap<>();
        ProfileItem profileItem = null;
@@ -458,24 +459,54 @@ public class RootsFragment extends Fragment {
            }
        }

        if (canShareAcrossProfile && Features.CROSS_PROFILE_TABS) {
            // Combine lists only if we enabled profile tab feature.
            rootList.addAll(rootListOtherUser);
        }

        if (!result.isEmpty() && !rootList.isEmpty()) {
            result.add(new SpacerItem());
        }

        final String preferredRootPackage = getResources().getString(
                R.string.preferred_root_package, "");

        final ItemComparator comp = new ItemComparator(preferredRootPackage);
        Collections.sort(rootList, comp);
        result.addAll(rootList);

        mApplicationItemList = rootList;
        if (canShareAcrossProfile && Features.CROSS_PROFILE_TABS) {
            // Combine lists only if we enabled profile tab feature.
            if (!rootList.isEmpty() && !rootListOtherUser.isEmpty()) {
                // Identify personal and work root list.
                final List<Item> personalRootList;
                final List<Item> workRootList;
                if (UserId.CURRENT_USER.isSystem()) {
                    personalRootList = rootList;
                    workRootList = rootListOtherUser;
                } else {
                    personalRootList = rootListOtherUser;
                    workRootList = rootList;
                }
                Collections.sort(personalRootList, comp);
                Collections.sort(workRootList, comp);

                // Make sure mApplicationItemList has items from both profiles.
                final List<Item> mergeRootList =
                        new ArrayList<>(rootList.size() + rootListOtherUser.size());
                mergeRootList.addAll(rootList);
                mergeRootList.addAll(rootListOtherUser);
                mApplicationItemList = mergeRootList;

                // Add header and list to the result
                resultRootList.add(new HeaderItem(getString(R.string.personal_tab)));
                resultRootList.addAll(personalRootList);
                resultRootList.add(new HeaderItem(getString(R.string.work_tab)));
                resultRootList.addAll(workRootList);
            } else {
                // There is no more than 1 user, we can add all lists to result without inserting
                // personal or work header.
                resultRootList.addAll(rootList);
                resultRootList.addAll(rootListOtherUser);
                Collections.sort(resultRootList, comp);
                mApplicationItemList = resultRootList;
            }
        } else {
            resultRootList.addAll(rootList);
            Collections.sort(resultRootList, comp);
            mApplicationItemList = resultRootList;
        }
        addListToResult(result, resultRootList);

        // This will be removed when feature flag is removed.
        if (canShareAcrossProfile && !Features.CROSS_PROFILE_TABS) {
            // Add profile item if we don't support cross-profile tab.
            result.add(new SpacerItem());
@@ -483,6 +514,14 @@ public class RootsFragment extends Fragment {
        }
    }

    private void addListToResult(List<Item> result, List<Item> rootList) {
        if (!result.isEmpty() && !rootList.isEmpty()) {
            result.add(new SpacerItem());
        }

        result.addAll(rootList);
    }

    @Override
    public void onResume() {
        super.onResume();