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

Commit 3c30f3ec authored by Artem Shvadskiy's avatar Artem Shvadskiy Committed by Gerrit Code Review
Browse files

Implement placeholder icons for remote folder.

Patch 1: Unfinished temporary commit before rebase.
Patch 2: Rebase.
Patch 3:
	1. Add additional RemoteFolderManager hook for drawer adapter setApps().
	2. Replace method arguments in drawer adapter from ArrayList to List,
	which allows us to use Collections.singletonList(), which is more memory
	efficient.
	3. Allow folders to batch remove a subset of their entries.
	4. Remove unused remote flag in ShortcutInfo.
Patch 4: Fix placeholder animation for folder and folder icon.
Patch 5: Remove unused import.
Patch 6: Move app drawer bg color to overlay.

Change-Id: I5ae3b976e2d04dcfbe5ea2e563ef94dcae48b7d4
issue-id: CYNGNOS-1329
parent d0cb9ae5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -21,6 +21,15 @@ public class RemoteFolderManager {
     */
    public Folder createRemoteFolder(final FolderIcon icon, ViewGroup root) { return null; }

    /**
     * Get a drawable for the supplied item in the folder icon preview.
     * @param items list of views in the folder.
     * @param position index of icon to retreive.
     * @return an icon to draw in the folder preview.
     */
    public Drawable getFolderIconDrawable(final ArrayList<View> items,
                                          final int position) { return null; }

    /**
     * Called when Launcher finishes binding items from the model.
     */
@@ -48,6 +57,11 @@ public class RemoteFolderManager {
     */
    public void onBindAddApps(ArrayList<AppInfo> apps) { }

    /**
     * Called when launcher loads apps and applies them to the drawer.
     */
    public void onSetApps() { }

    /**
     * Called when the info icon is clicked
     */
+0 −3
Original line number Diff line number Diff line
@@ -57,8 +57,5 @@
    <color name="scrubber_background">#CC14191E</color>
    <color name="drawer_header_text_shadow">#b0000000</color>

    <color name="drawer_container_background_default">#00000000</color>
    <color name="drawer_container_background_custom">#66000000</color>

    <color name="folder_background">#141a1e</color>
</resources>
+23 −19
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.provider.Settings;
@@ -34,11 +33,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SectionIndexer;
import android.widget.TextView;
import com.android.launcher3.locale.LocaleSetManager;
import com.android.launcher3.locale.LocaleUtils;
import com.android.launcher3.settings.SettingsProvider;
@@ -48,6 +44,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * AppDrawerListAdapter - list adapter for the vertical app drawer
@@ -519,7 +516,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
        Collections.sort(mHeaderList);
    }

    public void setApps(ArrayList<AppInfo> list) {
    public void setApps(List<AppInfo> list) {
        if (!LauncherAppState.isDisableAllApps()) {
            initParams();

@@ -559,7 +556,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
        processApps();
    }

    public void updateApps(ArrayList<AppInfo> list) {
    public void updateApps(List<AppInfo> list) {
        if (!LauncherAppState.isDisableAllApps()) {
            mAllApps.removeAll(list);
            mAllApps.addAll(list);
@@ -567,11 +564,11 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
        }
    }

    public void addApps(ArrayList<AppInfo> list) {
    public void addApps(List<AppInfo> list) {
        updateApps(list);
    }

    public void removeApps(ArrayList<AppInfo> appInfos) {
    public void removeApps(List<AppInfo> appInfos) {
        if (!LauncherAppState.isDisableAllApps()) {
            mAllApps.removeAll(appInfos);
            reset();
@@ -597,6 +594,11 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
            icon.setOnClickListener(mLauncher);
            icon.setOnLongClickListener(this);
            holder.mIconLayout.addView(icon);

            icon.mIcon.setPadding(mDeviceProfile.iconDrawablePaddingPx,
                    mDeviceProfile.iconDrawablePaddingPx,
                    mDeviceProfile.iconDrawablePaddingPx,
                    mDeviceProfile.iconDrawablePaddingPx);
        }

        if (viewType == ViewHolder.TYPE_CUSTOM) {
@@ -641,6 +643,10 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
    public void onBindViewHolder(ViewHolder holder, int position) {
        AppItemIndexedInfo indexedInfo = mHeaderList.get(position);

        if (indexedInfo.isRemote()) {
            mRemoteFolderManager.onBindViewHolder(holder, indexedInfo);
        }

        holder.mHeaderTextView.setVisibility(indexedInfo.isChild ? View.INVISIBLE : View.VISIBLE);
        if (!indexedInfo.isChild) {
            holder.mHeaderTextView.setText(indexedInfo.mStartString);
@@ -674,24 +680,22 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
            } else {
                icon.setVisibility(View.VISIBLE);
                AppInfo info = indexedInfo.mInfo.get(i);

                icon.setTag(info);
                Drawable d = Utilities.createIconDrawable(info.iconBitmap);

                Drawable d;
                if (info.customDrawable != null) {
                    d = info.customDrawable;
                } else {
                    d = Utilities.createIconDrawable(info.iconBitmap);
                }
                d.setBounds(mIconRect);
                icon.mIcon.setImageDrawable(d);
                icon.mIcon.setPadding(mDeviceProfile.iconDrawablePaddingPx,
                        mDeviceProfile.iconDrawablePaddingPx,
                        mDeviceProfile.iconDrawablePaddingPx,
                        mDeviceProfile.iconDrawablePaddingPx);

                icon.mLabel.setText(info.title);
                icon.mLabel.setVisibility(mHideIconLabels ? View.INVISIBLE : View.VISIBLE);
            }
        }
        holder.itemView.setTag(indexedInfo);

        if (indexedInfo.isRemote()) {
            mRemoteFolderManager.onBindViewHolder(holder, indexedInfo);
        }
    }

    @Override
@@ -862,7 +866,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
        return index;
    }

    private void filterProtectedApps(ArrayList<AppInfo> list) {
    private void filterProtectedApps(List<AppInfo> list) {
        updateProtectedAppsList(mLauncher);

        Iterator<AppInfo> iterator = list.iterator();
+9 −4
Original line number Diff line number Diff line
@@ -93,16 +93,13 @@ public class AppInfo extends ItemInfo {
        this.user = user;
    }

    public AppInfo(Intent intent, String title, Bitmap icon, UserHandleCompat user,
                   boolean remote) {
    public AppInfo(Intent intent, String title, UserHandleCompat user) {
        this.componentName = intent.getComponent();
        this.container = ItemInfo.NO_ID;

        this.intent = intent;
        this.title = title;
        iconBitmap = icon;
        this.user = user;
        flags = remote ? REMOTE_APP_FLAG : 0;
    }

    public static int initFlags(LauncherActivityInfoCompat info) {
@@ -150,6 +147,14 @@ public class AppInfo extends ItemInfo {
        return (flags & flag) != 0;
    }

    /**
     * Set a flag for this app
     * @param flag flag to apply.
     */
    public void setFlag(int flag) {
        flags |= flag;
    }

    @Override
    public String toString() {
        return "ApplicationInfo(title=" + title.toString() + " id=" + this.id
+16 −6
Original line number Diff line number Diff line
@@ -118,15 +118,21 @@ public class BubbleTextView extends TextView {

    public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache,
            boolean setDefaultPadding, boolean promiseStateChanged) {
        Bitmap b = info.getIcon(iconCache);
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

        FastBitmapDrawable iconDrawable = Utilities.createIconDrawable(b);
        iconDrawable.setGhostModeEnabled(info.isDisabled != 0);
        Drawable iconDrawable;
        if (info.customDrawable != null) {
            iconDrawable = info.customDrawable;
        } else {
            Bitmap b = info.getIcon(iconCache);
            iconDrawable = Utilities.createIconDrawable(b);
            ((FastBitmapDrawable) iconDrawable).setGhostModeEnabled(info.isDisabled != 0);
        }

        iconDrawable.setBounds(0, 0, grid.iconSizePx, grid.iconSizePx);
        setCompoundDrawables(null, iconDrawable, null, null);
        if (setDefaultPadding) {
            DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
            setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
        }
        if (info.contentDescription != null) {
@@ -144,7 +150,12 @@ public class BubbleTextView extends TextView {
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

        Drawable topDrawable = Utilities.createIconDrawable(info.iconBitmap);
        Drawable topDrawable;
        if (info.customDrawable != null) {
            topDrawable = info.customDrawable;
        } else {
            topDrawable = Utilities.createIconDrawable(info.iconBitmap);
        }
        topDrawable.setBounds(0, 0, grid.allAppsIconSizePx, grid.allAppsIconSizePx);
        setCompoundDrawables(null, topDrawable, null, null);
        setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
@@ -155,7 +166,6 @@ public class BubbleTextView extends TextView {
        setTag(info);
    }


    @Override
    protected boolean setFrame(int left, int top, int right, int bottom) {
        if (getLeft() != left || getRight() != right || getTop() != top || getBottom() != bottom) {
Loading