summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/ApiHelper.java6
-rw-r--r--src/com/android/gallery3d/app/AbstractGalleryActivity.java18
-rw-r--r--src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java9
3 files changed, 28 insertions, 5 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
index 753cacdf7..620e1ae7a 100644
--- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
+++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
@@ -61,6 +61,9 @@ public class ApiHelper {
"android.graphics.SurfaceTexture", "setDefaultBufferSize",
int.class, int.class);
+ public static final boolean HAS_RELEASE_SURFACE_TEXTURE = hasMethod(
+ "android.graphics.SurfaceTexture", "release");
+
public static final boolean HAS_MTP =
Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1;
@@ -102,6 +105,9 @@ public class ApiHelper {
}
}
+ public static final boolean HAS_SET_ICON_ATTRIBUTE =
+ Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
+
private static boolean hasField(Class<?> klass, String fieldName) {
try {
klass.getDeclaredField(fieldName);
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
index 24d5dbcdf..6b0b106aa 100644
--- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java
+++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
@@ -171,17 +171,27 @@ public class AbstractGalleryActivity extends Activity implements GalleryActivity
dialog.cancel();
}
};
- mAlertDialog = new AlertDialog.Builder(this)
- .setIconAttribute(android.R.attr.alertDialogIcon)
+ AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.no_external_storage_title)
.setMessage(R.string.no_external_storage)
.setNegativeButton(android.R.string.cancel, onClick)
- .setOnCancelListener(onCancel)
- .show();
+ .setOnCancelListener(onCancel);
+ if (ApiHelper.HAS_SET_ICON_ATTRIBUTE) {
+ setAlertDialogIconAttribute(builder);
+ } else {
+ builder.setIcon(android.R.drawable.ic_dialog_alert);
+ }
+ mAlertDialog = builder.show();
registerReceiver(mMountReceiver, mMountFilter);
}
}
+ @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
+ private static void setAlertDialogIconAttribute(
+ AlertDialog.Builder builder) {
+ builder.setIconAttribute(android.R.attr.alertDialogIcon);
+ }
+
@Override
protected void onStop() {
super.onStop();
diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java
index a04313b8b..dd9b7ce1f 100644
--- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java
+++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java
@@ -57,6 +57,13 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail,
}
}
+ @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
+ private static void releaseSurfaceTexture(SurfaceTexture st) {
+ if (ApiHelper.HAS_RELEASE_SURFACE_TEXTURE) {
+ st.release();
+ }
+ }
+
public SurfaceTexture getSurfaceTexture() {
return mSurfaceTexture;
}
@@ -67,7 +74,7 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail,
}
mExtTexture.recycle();
mExtTexture = null;
- mSurfaceTexture.release();
+ releaseSurfaceTexture(mSurfaceTexture);
mSurfaceTexture = null;
}