diff options
author | Sven Dawitz <sven@dawitz.de> | 2011-10-09 10:56:40 +0200 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2012-01-09 23:25:32 +0000 |
commit | 0ef5bab19adf26e7f4ebe64e72b9cd5fedc6c6de (patch) | |
tree | 6b3abdc6f74211cc39b92bdb938daa1b9f4fb40a /core | |
parent | 37d8da1876eb4583fa6a287259cb4e059c61a6eb (diff) | |
download | frameworks_base-0ef5bab19adf26e7f4ebe64e72b9cd5fedc6c6de.zip frameworks_base-0ef5bab19adf26e7f4ebe64e72b9cd5fedc6c6de.tar.gz frameworks_base-0ef5bab19adf26e7f4ebe64e72b9cd5fedc6c6de.tar.bz2 |
Ringlock (1/3): Style options added to CM settings
This patch combines the two concurent lockscreen designs in an option:
http://review.cyanogenmod.com/8564 - http://review.cyanogenmod.com/8674
credits to Stefano Pignataro for the first and Prash for the second redesign
this patch also can be used to add even more styles in the future - if provied.
this patch also cleans up some coding.
Background Info: Lockscreen cannot be themed - so this is the only way except
tempering with framework-res.apk
Change-Id: I055fb5f1c760656c3b1f750543cc6f054ee30fbe
Diffstat (limited to 'core')
19 files changed, 294 insertions, 3 deletions
diff --git a/core/java/android/provider/CmSystem.java b/core/java/android/provider/CmSystem.java index 5fe9a80..d7361b8 100644 --- a/core/java/android/provider/CmSystem.java +++ b/core/java/android/provider/CmSystem.java @@ -68,6 +68,151 @@ public final class CmSystem { public static final int KEYCODE_NONE = -1; + public enum LockscreenStyle { + Slider, + Rotary, + Lense, + Ring; + + static public LockscreenStyle getStyleById(int id) { + switch (id) { + case 1: + return Slider; + case 2: + return Rotary; + case 3: + /* backwards compat */ + return Rotary; + case 4: + return Lense; + case 5: + return Ring; + default: + return Ring; + } + } + + static public LockscreenStyle getStyleById(String id) { + return getStyleById(Integer.valueOf(id)); + } + + static public int getIdByStyle(LockscreenStyle lockscreenstyle) { + switch (lockscreenstyle){ + case Slider: + return 1; + case Rotary: + return 2; + case Lense: + return 4; + case Ring: + return 5; + default: + return 5; + } + } + } + + public enum InCallStyle { + Slider, + Rotary, + Ring; + + static public InCallStyle getStyleById(int id) { + switch (id) { + case 1: + return Slider; + case 2: + return Rotary; + case 3: + /* backwards compat */ + return Rotary; + case 4: + return Ring; + default: + return Ring; + } + } + + static public InCallStyle getStyleById(String id) { + return getStyleById(Integer.valueOf(id)); + } + + static public int getIdByStyle(InCallStyle inCallStyle) { + switch (inCallStyle) { + case Slider: + return 1; + case Rotary: + return 2; + case Ring: + return 4; + default: + return 4; + } + } + } + + public enum RotaryStyle { + Normal, + Revamped; + + static public RotaryStyle getStyleById(int id) { + switch (id) { + case 1: + return Normal; + case 2: + return Revamped; + default: + return Normal; + } + } + + static public RotaryStyle getStyleById(String id) { + return getStyleById(Integer.valueOf(id)); + } + + static public int getIdByStyle(RotaryStyle style) { + switch (style) { + case Normal: + return 1; + case Revamped: + return 2; + default: + return 1; + } + } + } + + public enum RinglockStyle { + Bubble, + Revamped; + + static public RinglockStyle getStyleById(int id) { + switch (id) { + case 1: + return Bubble; + case 2: + return Revamped; + default: + return Bubble; + } + } + + static public RinglockStyle getStyleById(String id) { + return getStyleById(Integer.valueOf(id)); + } + + static public int getIdByStyle(RinglockStyle style) { + switch (style) { + case Bubble: + return 1; + case Revamped: + return 2; + default: + return 1; + } + } + } + public CmSystem(){ //nothing to be done, as long as only static functions in here } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index dc2bb87..e2caf7b 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2586,6 +2586,18 @@ public final class Settings { public static final String IN_CALL_STYLE_PREF = "in_call_style_pref"; /** + * Sets the rotary lock style + * @hide + */ + public static final String ROTARY_STYLE_PREF = "rotary_style_pref"; + + /** + * Sets the ringlock style + * @hide + */ + public static final String RINGLOCK_STYLE_PREF = "ringlock_style_pref"; + + /** * Pulse the Trackball with Screen On. The value is boolean (1 or 0). * @hide */ diff --git a/core/java/com/android/internal/widget/RingSelector.java b/core/java/com/android/internal/widget/RingSelector.java index 0ef9066..72ce320 100644 --- a/core/java/com/android/internal/widget/RingSelector.java +++ b/core/java/com/android/internal/widget/RingSelector.java @@ -90,6 +90,7 @@ public class RingSelector extends ViewGroup { */ private int mOrientation; private int mSelectedRingId; + private int mHighlightBackgroundResId; private Ring mLeftRing; private Ring mRightRing; private Ring mMiddleRing; @@ -207,6 +208,8 @@ public class RingSelector extends ViewGroup { private int alignCenterX; private int alignCenterY; + private int backgroundId; + /** * Constructor * @@ -222,6 +225,8 @@ public class RingSelector extends ViewGroup { ring.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + backgroundId = ringId; + // Create target target = new ImageView(parent.getContext()); target.setImageResource(targetId); @@ -252,9 +257,17 @@ public class RingSelector extends ViewGroup { } void setRingBackgroundResource(int ringId) { + backgroundId = ringId; ring.setBackgroundResource(ringId); } + void setHighlighted(int highlightId) { + if (highlightId == 0) { + highlightId = backgroundId; + } + ring.setBackgroundResource(highlightId); + } + void hide() { if (isHidden) return; if (ring.getVisibility() == View.INVISIBLE) return; @@ -704,6 +717,8 @@ public class RingSelector extends ViewGroup { mSecRingBottomOffset = (int) (mDensity * mDensityScaleFactor * mSecRingBottomOffsetDIP); mSecRingCenterOffset = (int) (mDensity * mDensityScaleFactor * mSecRingCenterOffsetDIP); + mHighlightBackgroundResId = R.drawable.jog_ring_ring_pressed_red; + mSecRings = new SecRing[] { new SecRing(this, R.drawable.jog_ring_secback_normal), new SecRing(this, R.drawable.jog_ring_secback_normal), @@ -982,7 +997,7 @@ public class RingSelector extends ViewGroup { super.setVisibility(View.INVISIBLE); if ((mMiddlePrimary && isLeft) || (!mMiddlePrimary && !isRight && !isLeft)) { if (mPrevTriggered) { - mCurrentRing.setRingBackgroundResource(R.drawable.jog_ring_ring_green); + mCurrentRing.setHighlighted(0); } mSecRings[mSelectedRingId].deactivate(); } @@ -1039,14 +1054,21 @@ public class RingSelector extends ViewGroup { } } if (ringsTouched && !mPrevTriggered) { - mCurrentRing.setRingBackgroundResource(R.drawable.jog_ring_ring_pressed_red); + mCurrentRing.setHighlighted(mHighlightBackgroundResId); mPrevTriggered = true; } else if (!ringsTouched && mPrevTriggered) { - mCurrentRing.setRingBackgroundResource(R.drawable.jog_ring_ring_green); + mCurrentRing.setHighlighted(0); mPrevTriggered = false; } } + public void setHighlightBackgroundResource(int backgroundId) { + mHighlightBackgroundResId = backgroundId; + if (mPrevTriggered) { + mCurrentRing.setHighlighted(backgroundId); + } + } + /** * Sets the left ring icon to a given resource. * diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_ring_normal.png b/core/res/res/drawable-hdpi/jog_ring_rev_ring_normal.png Binary files differnew file mode 100644 index 0000000..ef5376f --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_ring_normal.png diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_gray.png b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_gray.png Binary files differnew file mode 100644 index 0000000..4adaf32 --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_gray.png diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_green.png b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_green.png Binary files differnew file mode 100644 index 0000000..b861d2b --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_green.png diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_red.png b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_red.png Binary files differnew file mode 100644 index 0000000..7791a1e --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_red.png diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_yellow.png b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_yellow.png Binary files differnew file mode 100644 index 0000000..1b61a71 --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_ring_pressed_yellow.png diff --git a/core/res/res/drawable-hdpi/jog_ring_rev_secback_normal.png b/core/res/res/drawable-hdpi/jog_ring_rev_secback_normal.png Binary files differnew file mode 100644 index 0000000..5e50c53 --- /dev/null +++ b/core/res/res/drawable-hdpi/jog_ring_rev_secback_normal.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_ring_normal.png b/core/res/res/drawable-mdpi/jog_ring_rev_ring_normal.png Binary files differnew file mode 100644 index 0000000..f303266 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_ring_normal.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_gray.png b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_gray.png Binary files differnew file mode 100644 index 0000000..d1967e2 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_gray.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_green.png b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_green.png Binary files differnew file mode 100644 index 0000000..90506f0 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_green.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_red.png b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_red.png Binary files differnew file mode 100644 index 0000000..e0e9aa4 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_red.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_yellow.png b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_yellow.png Binary files differnew file mode 100644 index 0000000..6f5c307 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_ring_pressed_yellow.png diff --git a/core/res/res/drawable-mdpi/jog_ring_rev_secback_normal.png b/core/res/res/drawable-mdpi/jog_ring_rev_secback_normal.png Binary files differnew file mode 100644 index 0000000..953b5f4 --- /dev/null +++ b/core/res/res/drawable-mdpi/jog_ring_rev_secback_normal.png diff --git a/core/res/res/drawable/jog_ring_rev_ring_gray.xml b/core/res/res/drawable/jog_ring_rev_ring_gray.xml new file mode 100644 index 0000000..8abbb03 --- /dev/null +++ b/core/res/res/drawable/jog_ring_rev_ring_gray.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- StateListDrawable used for buttons in the in-call onscreen touch UI. --> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_gray" /> + + <item android:state_enabled="true" + android:drawable="@drawable/jog_ring_rev_ring_normal" /> + + <item android:state_active="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_gray" /> + +</selector> diff --git a/core/res/res/drawable/jog_ring_rev_ring_green.xml b/core/res/res/drawable/jog_ring_rev_ring_green.xml new file mode 100644 index 0000000..7013a6b --- /dev/null +++ b/core/res/res/drawable/jog_ring_rev_ring_green.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- StateListDrawable used for buttons in the in-call onscreen touch UI. --> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_green" /> + + <item android:state_enabled="true" + android:drawable="@drawable/jog_ring_rev_ring_normal" /> + + <item android:state_active="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_green" /> + +</selector> diff --git a/core/res/res/drawable/jog_ring_rev_ring_red.xml b/core/res/res/drawable/jog_ring_rev_ring_red.xml new file mode 100644 index 0000000..c8a6988 --- /dev/null +++ b/core/res/res/drawable/jog_ring_rev_ring_red.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- StateListDrawable used for buttons in the in-call onscreen touch UI. --> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_red" /> + + <item android:state_enabled="true" + android:drawable="@drawable/jog_ring_rev_ring_normal" /> + + <item android:state_active="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_red" /> + +</selector> diff --git a/core/res/res/drawable/jog_ring_rev_ring_yellow.xml b/core/res/res/drawable/jog_ring_rev_ring_yellow.xml new file mode 100644 index 0000000..39d7154 --- /dev/null +++ b/core/res/res/drawable/jog_ring_rev_ring_yellow.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- StateListDrawable used for buttons in the in-call onscreen touch UI. --> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_yellow" /> + + <item android:state_enabled="true" + android:drawable="@drawable/jog_ring_rev_ring_normal" /> + + <item android:state_active="true" + android:drawable="@drawable/jog_ring_rev_ring_pressed_yellow" /> + +</selector> |