diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-12 00:54:34 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-12 00:54:34 +0200 |
commit | 493a43fe8cbdd5b6c30733cc8c7024bc89acd780 (patch) | |
tree | 34747fd027c6d6432956ca5d940109f0b4c56633 | |
parent | 8b11ba2e0c6d9b90d63dde362f7af59c147ce002 (diff) | |
download | android_packages_wallpapers_PhotoPhase-493a43fe8cbdd5b6c30733cc8c7024bc89acd780.tar.gz android_packages_wallpapers_PhotoPhase-493a43fe8cbdd5b6c30733cc8c7024bc89acd780.tar.bz2 android_packages_wallpapers_PhotoPhase-493a43fe8cbdd5b6c30733cc8c7024bc89acd780.zip |
Make it compatible with API 15 (4.0.3)
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
7 files changed, 49 insertions, 25 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 78c4169..4ee38e0 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -21,7 +21,7 @@ <original-package android:name="org.cyanogenmod.wallpapers.photophase" /> - <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="18" /> + <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="18" /> <uses-feature android:name="android.software.live_wallpaper" android:required="true" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> diff --git a/libs/color-picker-view/src/afzkl/development/mColorPicker/views/ColorDialogView.java b/libs/color-picker-view/src/afzkl/development/mColorPicker/views/ColorDialogView.java index 2333002..ad0b9cf 100644 --- a/libs/color-picker-view/src/afzkl/development/mColorPicker/views/ColorDialogView.java +++ b/libs/color-picker-view/src/afzkl/development/mColorPicker/views/ColorDialogView.java @@ -41,6 +41,9 @@ import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; +import java.util.Locale; +import java.util.concurrent.atomic.AtomicInteger; + /** * A view use directly into a dialog. It contains a one {@link ColorPickerView} * and two {@link ColorPanelView} (the current color and the new color) @@ -66,6 +69,8 @@ public class ColorDialogView extends RelativeLayout private String mColorLabelText = "Color:"; //$NON-NLS-1$ + private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1); + /** * Constructor of <code>ColorDialogView</code> * @@ -111,7 +116,7 @@ public class ColorDialogView extends RelativeLayout // Create the scrollview over the dialog final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP); ScrollView sv = new ScrollView(getContext()); - sv.setId(generateViewId()); + sv.setId(internalGenerateViewId()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); @@ -121,7 +126,7 @@ public class ColorDialogView extends RelativeLayout // Now the vertical layout LinearLayout ll = new LinearLayout(getContext()); - ll.setId(generateViewId()); + ll.setId(internalGenerateViewId()); lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); @@ -192,14 +197,14 @@ public class ColorDialogView extends RelativeLayout sb.append(c); } } - return sb.toString().toUpperCase(); + return sb.toString().toUpperCase(Locale.getDefault()); } }; this.etColor.setFilters(filters); this.etColor.addTextChangedListener(this); LinearLayout ll1 = new LinearLayout(getContext()); - ll1.setId(generateViewId()); + ll1.setId(internalGenerateViewId()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); @@ -223,7 +228,7 @@ public class ColorDialogView extends RelativeLayout private int createColorPicker(ViewGroup parent, int belowOf) { final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP); this.mPickerView = new ColorPickerView(getContext()); - this.mPickerView.setId(generateViewId()); + this.mPickerView.setId(internalGenerateViewId()); this.mPickerView.setOnColorChangedListener(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, @@ -274,7 +279,7 @@ public class ColorDialogView extends RelativeLayout sep1.setTextSize(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TEXT_SIZE_SP); LinearLayout ll1 = new LinearLayout(getContext()); - ll1.setId(generateViewId()); + ll1.setId(internalGenerateViewId()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); @@ -306,7 +311,7 @@ public class ColorDialogView extends RelativeLayout sep2.setTextSize(TypedValue.COMPLEX_UNIT_SP, DEFAULT_TEXT_SIZE_SP); LinearLayout ll2 = new LinearLayout(getContext()); - ll2.setId(generateViewId()); + ll2.setId(internalGenerateViewId()); lp = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, panelHeight); lp.setMargins(dlgMarging, 0, dlgMarging, dlgMarging/2); @@ -489,6 +494,24 @@ public class ColorDialogView extends RelativeLayout if (hex.length() == 1) { hex = "0" + hex; //$NON-NLS-1$ } - return hex.toUpperCase(); + return hex.toUpperCase(Locale.getDefault()); + } + + /** + * Generate a value suitable for use in {@link #setId(int)}. + * This value will not collide with ID values generated at build time by aapt for R.id. + * + * @return a generated ID value + */ + private static int internalGenerateViewId() { + for (;;) { + final int result = sNextGeneratedId.get(); + // aapt-generated IDs have the high byte nonzero; clamp to the range under that. + int newValue = result + 1; + if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0. + if (sNextGeneratedId.compareAndSet(result, newValue)) { + return result; + } + } } } diff --git a/res/layout/choose_disposition_fragment.xml b/res/layout/choose_disposition_fragment.xml index 2df83c3..b169b14 100644 --- a/res/layout/choose_disposition_fragment.xml +++ b/res/layout/choose_disposition_fragment.xml @@ -25,8 +25,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_blue_light" - android:layout_marginStart="@dimen/disposition_frame_margin" - android:layout_marginEnd="@dimen/disposition_frame_margin" + android:layout_marginLeft="@dimen/disposition_frame_margin" + android:layout_marginRight="@dimen/disposition_frame_margin" android:padding="@dimen/disposition_advise_frame_padding" android:gravity="center_horizontal" android:textColor="@color/notification_text_color" diff --git a/res/layout/preference_widget_seekbar.xml b/res/layout/preference_widget_seekbar.xml index e528abc..35c924e 100644 --- a/res/layout/preference_widget_seekbar.xml +++ b/res/layout/preference_widget_seekbar.xml @@ -20,7 +20,7 @@ android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:baselineAligned="false" - android:paddingEnd="?android:attr/scrollbarSize"> + android:paddingRight="?android:attr/scrollbarSize"> <LinearLayout android:layout_width="wrap_content" @@ -40,8 +40,8 @@ <RelativeLayout android:layout_width="0dip" android:layout_height="wrap_content" - android:layout_marginStart="8dip" - android:layout_marginEnd="8dip" + android:layout_marginLeft="8dip" + android:layout_marginRight="8dip" android:layout_marginTop="6dip" android:layout_marginBottom="6dip" android:layout_weight="1"> @@ -54,11 +54,11 @@ android:ellipsize="marquee" android:fadingEdge="horizontal" /> - <TextView android:id="@+android:id/summary" + <TextView android:id="@+id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@android:id/title" - android:layout_alignStart="@android:id/title" + android:layout_alignLeft="@android:id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary" android:maxLines="4" /> @@ -68,7 +68,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_below="@android:id/summary" - android:layout_alignStart="@android:id/title" + android:layout_alignLeft="@android:id/title" android:minWidth="@dimen/preference_widget_width" android:gravity="center" android:orientation="vertical" /> @@ -77,8 +77,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@android:id/summary" - android:layout_toEndOf="@android:id/widget_frame" - android:layout_alignParentEnd="true" /> + android:layout_toRightOf="@android:id/widget_frame" + android:layout_alignParentRight="true" /> </RelativeLayout> diff --git a/res/values/styles.xml b/res/values/styles.xml index dca561d..45387e5 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -20,7 +20,6 @@ </style> <style name="PhotoPhase.TextAppearance"> - <item name="android:fontFamily">sans-serif</item> <item name="android:textColor">@color/text_color</item> </style> @@ -50,7 +49,6 @@ <item name="android:gravity">center</item> <item name="android:background">@drawable/bg_notification</item> <item name="android:textSize">@dimen/notification_text_size</item> - <item name="android:fontFamily">sans-serif</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/notification_text_color</item> </style> @@ -61,7 +59,6 @@ <style name="PhotoPhase.Album.Title"> <item name="android:background">@null</item> <item name="android:textSize">@dimen/secondary_text_size</item> - <item name="android:fontFamily">sans-serif</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/text_color</item> <item name="android:rotation">-90</item> diff --git a/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java b/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java index 504601a..f078573 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java +++ b/src/org/cyanogenmod/wallpapers/photophase/preferences/DispositionFragment.java @@ -44,8 +44,12 @@ public abstract class DispositionFragment private Runnable mRedraw = new Runnable() { @Override public void run() { - if (getActivity() == null || getActivity().isDestroyed()) return; - mDispositionView.setDispositions(getUserDispositions(), getCols(), getRows()); + if (getActivity() == null) return; + try { + mDispositionView.setDispositions(getUserDispositions(), getCols(), getRows()); + } catch (Exception ex) { + // Ignored + } } }; diff --git a/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java b/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java index 13b3b17..7b50921 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java +++ b/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java @@ -87,7 +87,7 @@ public class OopsShape implements DrawableShape { */ public OopsShape(Context ctx, int resourceMessageId) { super(); - + int orientation = ctx.getResources().getConfiguration().orientation; float[] vertex = VERTEX_COORDS_PORTRAIT; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { |