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

Commit 8ae5af8a authored by Danesh M's avatar Danesh M
Browse files

Framework : Lockscreen - Customizable shortcuts

Allow users to choose lockscreen shortcuts / icons :
	Phone - 1-5 targets
	Tablets - 1-8 targets

CM10 port
---------
Patchset 1-8: Initial port
Patchset 9  : Revert to CM9 drawables
Patchset 10 : Rebase

Change-Id: I9b163efeef8f47b1d21f7f61552ebe424049cfeb
parent a9e0830c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2208,6 +2208,12 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_DISABLED = "lockscreen.disabled";

        /**
         * Stores values for custom lockscreen targets
         * @hide
         */
        public static final String LOCKSCREEN_TARGETS = "lockscreen_targets";

        /**
         * URI for the low battery sound file.
         * @hide
+73 −2
Original line number Diff line number Diff line
@@ -61,6 +61,50 @@ public class GlowPadView extends View {
    private static final int STATE_SNAP = 4;
    private static final int STATE_FINISH = 5;

    //Lockscreen targets
    /**
     * @hide
     */
    public final static String ICON_RESOURCE = "icon_resource";

    /**
     * @hide
     */
    public final static String ICON_PACKAGE = "icon_package";

    /**
     * @hide
     */
    public final static String ICON_FILE = "icon_file";

    /**
     * Number of customizable lockscreen targets for tablets
     * @hide
     */
    public final static int MAX_TABLET_TARGETS = 7;

    /**
     * Number of customizable lockscreen targets for phones
     * @hide
     */
    public final static int MAX_PHONE_TARGETS = 4;

    /**
     * Empty target used to reference unused lockscreen targets
     * @hide
     */
    public final static String EMPTY_TARGET = "empty";

    /**
     * Default stock configuration for lockscreen targets
     * @hide
     */
    public final static String DEFAULT_TARGETS =
            "empty|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;" +
            "component=com.google.android.googlequicksearchbox/.SearchActivity;S.icon_resource=ic_lockscreen_google_normal;" +
            "end|empty|#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;" +
            "component=com.android.gallery3d/com.android.camera.CameraLauncher;S.icon_resource=ic_lockscreen_camera_normal;end";

    // Animation properties.
    private static final float SNAP_MARGIN_DEFAULT = 20.0f; // distance to ring before we snap to it

@@ -117,6 +161,7 @@ public class GlowPadView extends View {
    private float mSnapMargin = 0.0f;
    private boolean mDragging;
    private int mNewTargetResources;
    private ArrayList<TargetDrawable> mNewTargetDrawables;

    private class AnimationBundle extends ArrayList<Tweener> {
        private static final long serialVersionUID = 0xA84D78726F127468L;
@@ -182,6 +227,10 @@ public class GlowPadView extends View {
                internalSetTargetResources(mNewTargetResources);
                mNewTargetResources = 0;
                hideTargets(false, false);
            } else if (mNewTargetDrawables != null) {
                internalSetTargetResources(mNewTargetDrawables);
                mNewTargetDrawables = null;
                hideTargets(false, false);
            }
            mAnimatingTargets = false;
        }
@@ -452,6 +501,7 @@ public class GlowPadView extends View {
                // Force ring and targets to finish animation to final expanded state
                mTargetAnimations.stop();
            }
            hideTargets(false, false);
        } else {
            // Animate handle back to the center based on current state.
            hideGlow(HIDE_ANIMATION_DURATION, 0, 0.0f, mResetListenerWithPing);
@@ -585,6 +635,14 @@ public class GlowPadView extends View {
        }
    }

    private void internalSetTargetResources(ArrayList<TargetDrawable> drawList) {
        mTargetResourceId = 0;
        mTargetDrawables = drawList;
        updateTargetPositions(mWaveCenterX, mWaveCenterY);
        updatePointCloudPosition(mWaveCenterX, mWaveCenterY);
        hideTargets(false, false);
    }

    /**
     * Loads an array of drawables from the given resourceId.
     *
@@ -599,10 +657,23 @@ public class GlowPadView extends View {
        }
    }

    public void setTargetResources(ArrayList<TargetDrawable> drawList) {
        if (mAnimatingTargets) {
            // postpone this change until we return to the initial state
            mNewTargetDrawables = drawList;
        } else {
            internalSetTargetResources(drawList);
        }
    }

    public int getTargetResourceId() {
        return mTargetResourceId;
    }

    public ArrayList<TargetDrawable> getTargetDrawables() {
        return mTargetDrawables;
    }

    /**
     * Sets the resource id specifying the target descriptions for accessibility.
     *
@@ -1096,7 +1167,7 @@ public class GlowPadView extends View {
    }

    private String getTargetDescription(int index) {
        if (mTargetDescriptions == null || mTargetDescriptions.isEmpty()) {
        if (mTargetDescriptions == null || mTargetDescriptions.isEmpty() || index >= mTargetDescriptions.size()) {
            mTargetDescriptions = loadDescriptions(mTargetDescriptionsResourceId);
            if (mTargetDrawables.size() != mTargetDescriptions.size()) {
                Log.w(TAG, "The number of target drawables must be"
@@ -1108,7 +1179,7 @@ public class GlowPadView extends View {
    }

    private String getDirectionDescription(int index) {
        if (mDirectionDescriptions == null || mDirectionDescriptions.isEmpty()) {
        if (mDirectionDescriptions == null || mDirectionDescriptions.isEmpty() || index >= mDirectionDescriptions.size()) {
            mDirectionDescriptions = loadDescriptions(mDirectionDescriptionsResourceId);
            if (mTargetDrawables.size() != mDirectionDescriptions.size()) {
                Log.w(TAG, "The number of target drawables must be"
+10 −2
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ public class TargetDrawable {
    private static final boolean DEBUG = false;

    public static final int[] STATE_ACTIVE =
            { android.R.attr.state_enabled, android.R.attr.state_active };
            { android.R.attr.state_enabled, android.R.attr.state_active, -android.R.attr.state_focused };
    public static final int[] STATE_INACTIVE =
            { android.R.attr.state_enabled, -android.R.attr.state_active };
            { android.R.attr.state_enabled, -android.R.attr.state_active , -android.R.attr.state_focused };
    public static final int[] STATE_FOCUSED =
            { android.R.attr.state_enabled, -android.R.attr.state_active,
                android.R.attr.state_focused };
@@ -91,6 +91,14 @@ public class TargetDrawable {
        setState(STATE_INACTIVE);
    }

    public TargetDrawable(Resources res, Drawable drawable) {
        mResourceId = 0;
        // Mutate the drawable so we can animate shared drawable properties.
        mDrawable = drawable != null ? drawable.mutate() : null;
        resizeDrawables();
        setState(STATE_INACTIVE);
    }

    public TargetDrawable(TargetDrawable other) {
        mResourceId = other.mResourceId;
        // Mutate the drawable so we can animate shared drawable properties.
+7.69 KiB
Loading image diff...
+2.38 KiB
Loading image diff...
Loading