Apply settings immediately, like other wallpapers.
Don't have an explicit "OK" button to apply the current preset, but just
apply it immediately, like other wallpapers with settings do.
Also use a different default setting that is more in line with the
overall ICS theme, and update the thumbnail accordingly.
b/5288769
Change-Id: Ibe35b74c3d5c9ad35708b98007d9bb0a396a25c2
diff --git a/res/drawable/magicsmoke_thumb.png b/res/drawable/magicsmoke_thumb.png
index 8c937b8..0349547 100644
--- a/res/drawable/magicsmoke_thumb.png
+++ b/res/drawable/magicsmoke_thumb.png
Binary files differ
diff --git a/res/layout/selector.xml b/res/layout/selector.xml
index 9b6b22f..304d305 100644
--- a/res/layout/selector.xml
+++ b/res/layout/selector.xml
@@ -31,13 +31,4 @@
android:background="#40000000"
/>
- <Button
- android:layout_width="160dip"
- android:layout_height="wrap_content"
- android:text="@string/ok"
- android:onClick="setLiveWallpaper"
- android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
- />
-
</RelativeLayout>
diff --git a/src/com/android/magicsmoke/MagicSmokeRS.java b/src/com/android/magicsmoke/MagicSmokeRS.java
index 201aacd..50c3b2e 100644
--- a/src/com/android/magicsmoke/MagicSmokeRS.java
+++ b/src/com/android/magicsmoke/MagicSmokeRS.java
@@ -29,7 +29,6 @@
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.os.Handler;
-import android.renderscript.Mesh.Primitive;
import android.renderscript.*;
import android.renderscript.Element.Builder;
import android.renderscript.ProgramStore.BlendDstFunc;
@@ -116,7 +115,7 @@
public boolean mPreMul;
}
- public static final int DEFAULT_PRESET = 4;
+ public static final int DEFAULT_PRESET = 16;
public static final Preset [] mPreset = new Preset[] {
// proc back low high alph mask rot swap premul
new Preset(1, 0x000000, 0x000000, 0xffffff, 2.0f, 0x0f, true, false, false),
@@ -149,12 +148,19 @@
mHeight = height;
mContext = context;
mSharedPref = mContext.getSharedPreferences("magicsmoke", Context.MODE_PRIVATE);
+ mSharedPref.registerOnSharedPreferenceChangeListener(this);
makeNewState();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- makeNewState();
+ if (!mIsStarted) {
+ start();
+ mRS.finish();
+ stop(false);
+ } else {
+ makeNewState();
+ }
}
void makeNewState() {
@@ -236,16 +242,17 @@
}
@Override
- public void stop() {
- mSharedPref.unregisterOnSharedPreferenceChangeListener(this);
- super.stop();
+ public void stop(boolean forReal) {
+ if (forReal) {
+ mSharedPref.unregisterOnSharedPreferenceChangeListener(this);
+ }
+ super.stop(forReal);
}
@Override
public void start() {
- super.start();
- mSharedPref.registerOnSharedPreferenceChangeListener(this);
makeNewState();
+ super.start();
}
float alphafactor;
diff --git a/src/com/android/magicsmoke/MagicSmokeSelector.java b/src/com/android/magicsmoke/MagicSmokeSelector.java
index 55addf6..22c7675 100644
--- a/src/com/android/magicsmoke/MagicSmokeSelector.java
+++ b/src/com/android/magicsmoke/MagicSmokeSelector.java
@@ -73,12 +73,6 @@
}
}
- // button hook
- public void setLiveWallpaper(View v) {
- finish();
- }
-
-
@Override
public void onResume() {
super.onResume();
diff --git a/src/com/android/magicsmoke/RenderScriptScene.java b/src/com/android/magicsmoke/RenderScriptScene.java
index fdf4935..fbab205 100644
--- a/src/com/android/magicsmoke/RenderScriptScene.java
+++ b/src/com/android/magicsmoke/RenderScriptScene.java
@@ -27,6 +27,7 @@
protected int mWidth;
protected int mHeight;
protected boolean mPreview;
+ protected boolean mIsStarted;
protected Resources mResources;
protected RenderScriptGL mRS;
protected ScriptC mScript;
@@ -69,12 +70,14 @@
protected abstract ScriptC createScript();
- public void stop() {
+ public void stop(boolean forReal) {
mRS.bindRootScript(null);
+ mIsStarted = false;
}
public void start() {
mRS.bindRootScript(mScript);
+ mIsStarted = true;
}
public void resize(int width, int height) {
diff --git a/src/com/android/magicsmoke/RenderScriptWallpaper.java b/src/com/android/magicsmoke/RenderScriptWallpaper.java
index c9bbdd9..c0bf50d 100644
--- a/src/com/android/magicsmoke/RenderScriptWallpaper.java
+++ b/src/com/android/magicsmoke/RenderScriptWallpaper.java
@@ -54,7 +54,7 @@
private void destroyRenderer() {
if (mRenderer != null) {
- mRenderer.stop();
+ mRenderer.stop(true);
mRenderer = null;
}
if (mRs != null) {
@@ -70,7 +70,7 @@
if (visible) {
mRenderer.start();
} else {
- mRenderer.stop();
+ mRenderer.stop(false);
}
}
}