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

Commit 4467ed9c authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Fix drawable being displayed empty when re-entering the target edit dialog." into cm-10.2

parents 32d04ad4 affc6dfa
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -361,13 +361,22 @@ public class LockscreenTargets extends Fragment implements
            activeLayer.setDrawableByLayerId(0, new InsetDrawable(activeBack, 0, 0, 0, 0));
        }

        item.defaultIcon = mDialogIcon.getDrawable();
        item.defaultIcon = getPickedIconFromDialog();
        item.uri = uri;
        item.iconType = iconType;
        item.iconSource = iconSource;
        item.packageName = packageName;
    }

    private Drawable getPickedIconFromDialog() {
        return mDialogIcon.getDrawable().mutate();
    }

    private void setIconForDialog(Drawable icon) {
        // need to mutate the drawable here to not share drawable state with GlowPadView
        mDialogIcon.setImageDrawable(icon.getConstantState().newDrawable().mutate());
    }

    @Override
    public void shortcutPicked(String uri, String friendlyName, boolean isApplication) {
        try {
@@ -376,6 +385,7 @@ public class LockscreenTargets extends Fragment implements

            mDialogLabel.setText(friendlyName);
            mDialogLabel.setTag(uri);
            // this is a fresh drawable, so we can assign it directly
            mDialogIcon.setImageDrawable(icon);
            mDialogIcon.setTag(null);
        } catch (URISyntaxException e) {
@@ -394,6 +404,7 @@ public class LockscreenTargets extends Fragment implements
            mDialogLabel.setText(mEmptyLabel);
            mDialogLabel.setTag(GlowPadView.EMPTY_TARGET);
            mDialogIcon.setImageResource(R.drawable.ic_empty);
            mDialogIcon.setTag(null);
        } else if (requestCode == IconPicker.REQUEST_PICK_SYSTEM
                || requestCode == IconPicker.REQUEST_PICK_GALLERY
                || requestCode == IconPicker.REQUEST_PICK_ICON_PACK) {
@@ -432,7 +443,7 @@ public class LockscreenTargets extends Fragment implements
                        String packageName = info != null ? info.packageName : null;
                        int inset = LockscreenTargetUtils.getInsetForIconType(mActivity, type);

                        InsetDrawable drawable = new InsetDrawable(mDialogIcon.getDrawable(),
                        InsetDrawable drawable = new InsetDrawable(getPickedIconFromDialog(),
                                inset, inset, inset, inset);
                        setTarget(mTargetIndex, mDialogLabel.getTag().toString(),
                                drawable, type, source, packageName);
@@ -474,7 +485,7 @@ public class LockscreenTargets extends Fragment implements
        mDialogLabel = (Button) view.findViewById(R.id.label);

        TargetInfo item = mTargetStore.get(target);
        mDialogIcon.setImageDrawable(item.defaultIcon);
        setIconForDialog(item.defaultIcon);

        TargetInfo icon = new TargetInfo(null);
        icon.iconType = item.iconType;
@@ -538,7 +549,7 @@ public class LockscreenTargets extends Fragment implements

        if (iconDrawable != null) {
            mDialogIcon.setTag(icon);
            mDialogIcon.setImageDrawable(iconDrawable);
            setIconForDialog(iconDrawable);
        } else {
            Log.w(TAG, "Could not fetch icon, keeping old one (type=" + icon.iconType
                    + ", source=" + icon.iconSource + ", package= " + icon.packageName + ")");