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

Commit ebf50c93 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Merging Motorola's patch to disable apps when is safe mode." into ub-now-master

parents cc83d8db c5c60ad3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@
    <string name="folder_name"></string>
    <!-- Displayed when user selects a shortcut for an app that was uninstalled [CHAR_LIMIT=none]-->
    <string name="activity_not_found">App isn\'t installed.</string>
    <!-- SafeMode shortcut error string -->
    <string name="safemode_shortcut_error">Downloaded app disabled in Safe mode</string>
    <!--  Labels for the tabs in the customize drawer -->
    <string name="widgets_tab_label">Widgets</string>

+12 −10
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ public class BubbleTextView extends TextView {

    private static final boolean DEBUG = false;

    private int mPrevAlpha = -1;

    private HolographicOutlineHelper mOutlineHelper;
    private final Canvas mTempCanvas = new Canvas();
    private final Rect mTempRect = new Rect();
@@ -124,14 +122,22 @@ public class BubbleTextView extends TextView {
        }
    }

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

        Drawable iconDrawable = Utilities.createIconDrawable(b);
        FastBitmapDrawable iconDrawable = Utilities.createIconDrawable(b);
        if (info.isDisabled) {
            iconDrawable.setSaturation(0);
            iconDrawable.setBrightness(20);
        }

        setCompoundDrawables(null, iconDrawable, null, null);
        if (setDefaultPadding) {
            DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
            setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
        }
        if (info.contentDescription != null) {
            setContentDescription(info.contentDescription);
        }
@@ -417,10 +423,6 @@ public class BubbleTextView extends TextView {

    @Override
    protected boolean onSetAlpha(int alpha) {
        if (mPrevAlpha != alpha) {
            mPrevAlpha = alpha;
            super.onSetAlpha(alpha);
        }
        return true;
    }

+59 −2
Original line number Diff line number Diff line
@@ -19,15 +19,24 @@ package com.android.launcher3;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

class FastBitmapDrawable extends Drawable {

    private static final ColorMatrix sTempSaturationMatrix = new ColorMatrix();
    private static final ColorMatrix sTempBrightnessMatrix = new ColorMatrix();

    private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    private Bitmap mBitmap;
    private int mAlpha;
    private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);

    private float mSatutation = 1;
    private int mBrightness = 0;

    FastBitmapDrawable(Bitmap b) {
        mAlpha = 255;
@@ -44,7 +53,7 @@ class FastBitmapDrawable extends Drawable {

    @Override
    public void setColorFilter(ColorFilter cf) {
        mPaint.setColorFilter(cf);
        // No op
    }

    @Override
@@ -58,6 +67,7 @@ class FastBitmapDrawable extends Drawable {
        mPaint.setAlpha(alpha);
    }

    @Override
    public void setFilterBitmap(boolean filterBitmap) {
        mPaint.setFilterBitmap(filterBitmap);
        mPaint.setAntiAlias(filterBitmap);
@@ -90,4 +100,51 @@ class FastBitmapDrawable extends Drawable {
    public Bitmap getBitmap() {
        return mBitmap;
    }

    public float getSaturation() {
        return mSatutation;
    }

    public void setSaturation(float saturation) {
        mSatutation = saturation;
        updateFilter();
    }

    public int getBrightness() {
        return mBrightness;
    }

    public void addBrightness(int amount) {
        mBrightness += amount;
        updateFilter();
    }

    public void setBrightness(int brightness) {
        mBrightness = brightness;
        updateFilter();
    }

    private void updateFilter() {
        if (mSatutation != 1 || mBrightness != 0) {
            sTempSaturationMatrix.setSaturation(mSatutation);

            if (mBrightness != 0) {
                // Brightness: C-new = C-old*(1-amount) + amount
                float scale = 1 - mBrightness / 255.0f;
                sTempBrightnessMatrix.setScale(scale, scale, scale, 1);
                float[] array = sTempBrightnessMatrix.getArray();

                // Add the amount to RGB components of the matrix, as per the above formula.
                // Fifth elements in the array correspond to the constant being added to
                // red, blue, green, and alpha channel respectively.
                array[4] = mBrightness;
                array[9] = mBrightness;
                array[14] = mBrightness;
                sTempSaturationMatrix.preConcat(sTempBrightnessMatrix);
            }
            mPaint.setColorFilter(new ColorMatrixColorFilter(sTempSaturationMatrix));
        } else {
            mPaint.setColorFilter(null);
        }
    }
}
+4 −9
Original line number Diff line number Diff line
@@ -566,15 +566,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
    }

    protected View createAndAddShortcut(ShortcutInfo item) {
        final TextView textView =
            (TextView) mInflater.inflate(R.layout.folder_application, this, false);
        textView.setCompoundDrawables(null,
                Utilities.createIconDrawable(item.getIcon(mIconCache)), null, null);
        textView.setText(item.title);
        if (item.contentDescription != null) {
            textView.setContentDescription(item.contentDescription);
        }
        textView.setTag(item);
        final BubbleTextView textView =
            (BubbleTextView) mInflater.inflate(R.layout.folder_application, this, false);
        textView.applyFromShortcutInfo(item, mIconCache, false);

        textView.setOnClickListener(this);
        textView.setOnLongClickListener(this);

+11 −4
Original line number Diff line number Diff line
@@ -580,10 +580,17 @@ public class FolderIcon extends FrameLayout implements FolderListener {
        if (d != null) {
            mOldBounds.set(d.getBounds());
            d.setBounds(0, 0, mIntrinsicIconSize, mIntrinsicIconSize);
            if (d instanceof FastBitmapDrawable) {
                FastBitmapDrawable fd = (FastBitmapDrawable) d;
                fd.addBrightness(params.overlayAlpha);
                d.draw(canvas);
                fd.addBrightness(-params.overlayAlpha);
            } else {
                d.setColorFilter(Color.argb(params.overlayAlpha, 255, 255, 255),
                        PorterDuff.Mode.SRC_ATOP);
                d.draw(canvas);
                d.clearColorFilter();
            }
            d.setBounds(mOldBounds);
        }
        canvas.restore();
Loading