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

Commit 946346e8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix tinting and sizing of tuner lock screen shortcuts"

parents 2598baa1 ca215689
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public interface IntentButtonProvider extends Plugin {
            public boolean isVisible = true;
            public CharSequence contentDescription = null;
            public Drawable drawable;
            public boolean tint = true;
        }

        public IconState getIcon();
+0 −2
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@
        android:layout_height="@dimen/keyguard_affordance_height"
        android:layout_width="@dimen/keyguard_affordance_width"
        android:layout_gravity="bottom|end"
        android:tint="#ffffffff"
        android:src="@drawable/ic_camera_alt_24dp"
        android:scaleType="center"
        android:contentDescription="@string/accessibility_camera_button" />
@@ -76,7 +75,6 @@
        android:layout_height="@dimen/keyguard_affordance_height"
        android:layout_width="@dimen/keyguard_affordance_width"
        android:layout_gravity="bottom|start"
        android:tint="#ffffffff"
        android:src="@drawable/ic_phone_24dp"
        android:scaleType="center"
        android:contentDescription="@string/accessibility_phone_button" />
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.CanvasProperty;
@@ -78,6 +79,7 @@ public class KeyguardAffordanceView extends ImageView {
    private boolean mSupportHardware;
    private boolean mFinishing;
    private boolean mLaunchingAffordance;
    private boolean mShouldTint = true;

    private CanvasProperty<Float> mHwCircleRadius;
    private CanvasProperty<Float> mHwCenterX;
@@ -137,6 +139,12 @@ public class KeyguardAffordanceView extends ImageView {
        mFlingAnimationUtils = new FlingAnimationUtils(mContext, 0.3f);
    }

    public void setImageDrawable(@Nullable Drawable drawable, boolean tint) {
        super.setImageDrawable(drawable);
        mShouldTint = tint;
        updateIconColor();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
@@ -165,6 +173,7 @@ public class KeyguardAffordanceView extends ImageView {
    }

    private void updateIconColor() {
        if (!mShouldTint) return;
        Drawable drawable = getDrawable().mutate();
        float alpha = mCircleRadius / mMinBackgroundRadius;
        alpha = Math.min(1.0f, alpha);
+2 −2
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private void updateRightAffordanceIcon() {
        IconState state = mRightButton.getIcon();
        mRightAffordanceView.setVisibility(state.isVisible ? View.VISIBLE : View.GONE);
        mRightAffordanceView.setImageDrawable(state.drawable);
        mRightAffordanceView.setImageDrawable(state.drawable, state.tint);
        mRightAffordanceView.setContentDescription(state.contentDescription);
    }

@@ -376,7 +376,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private void updateLeftAffordanceIcon() {
        IconState state = mLeftButton.getIcon();
        mLeftAffordanceView.setVisibility(state.isVisible ? View.VISIBLE : View.GONE);
        mLeftAffordanceView.setImageDrawable(state.drawable);
        mLeftAffordanceView.setImageDrawable(state.drawable, state.tint);
        mLeftAffordanceView.setContentDescription(state.contentDescription);
    }

+17 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.pm.LauncherApps.ShortcutQuery;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ScaleDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
@@ -37,6 +38,9 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -46,6 +50,7 @@ import android.widget.TextView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.IntentButtonProvider.IntentButton;
import com.android.systemui.statusbar.ScalingDrawableWrapper;
import com.android.systemui.statusbar.phone.ExpandableIndicator;
import com.android.systemui.tuner.ShortcutParser.Shortcut;
import com.android.systemui.tuner.TunerService.Tunable;
@@ -365,8 +370,13 @@ public class LockscreenFragment extends PreferenceFragment {
            mShortcut = shortcut;
            mIconState = new IconState();
            mIconState.isVisible = true;
            mIconState.drawable = shortcut.icon.loadDrawable(context);
            mIconState.drawable = shortcut.icon.loadDrawable(context).mutate();
            mIconState.contentDescription = mShortcut.label;
            int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32,
                    context.getResources().getDisplayMetrics());
            mIconState.drawable = new ScalingDrawableWrapper(mIconState.drawable,
                    size / (float) mIconState.drawable.getIntrinsicWidth());
            mIconState.tint = false;
        }

        @Override
@@ -388,8 +398,13 @@ public class LockscreenFragment extends PreferenceFragment {
            mIntent = new Intent().setComponent(new ComponentName(info.packageName, info.name));
            mIconState = new IconState();
            mIconState.isVisible = true;
            mIconState.drawable = info.loadIcon(context.getPackageManager());
            mIconState.drawable = info.loadIcon(context.getPackageManager()).mutate();
            mIconState.contentDescription = info.loadLabel(context.getPackageManager());
            int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32,
                    context.getResources().getDisplayMetrics());
            mIconState.drawable = new ScalingDrawableWrapper(mIconState.drawable,
                    size / (float) mIconState.drawable.getIntrinsicWidth());
            mIconState.tint = false;
        }

        @Override