summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app/AlbumSetPage.java
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-08-22 18:26:03 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-26 22:32:39 -0700
commit75da47f8d384e58367c5458c366978918c0b6696 (patch)
tree08a1c710aa08b352f23bb9200000aa17a01b61ae /src/com/android/gallery3d/app/AlbumSetPage.java
parentfa3e84a0ce70f03b47c94434fdb52780a8b08e62 (diff)
downloadandroid_packages_apps_Snap-75da47f8d384e58367c5458c366978918c0b6696.tar.gz
android_packages_apps_Snap-75da47f8d384e58367c5458c366978918c0b6696.tar.bz2
android_packages_apps_Snap-75da47f8d384e58367c5458c366978918c0b6696.zip
Offer to launch camera when Gallery completely empty
Bug: 7009464 Rather than showing a blank screen, alerts the user that the gallery is empty and offers to launch the camera, if the device has one. Change-Id: I0bf71f1cbe7c96a4dc063b5d38b9a282538234c9
Diffstat (limited to 'src/com/android/gallery3d/app/AlbumSetPage.java')
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index a3d7dc430..f0f4354e1 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -17,8 +17,12 @@
package com.android.gallery3d.app;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnClickListener;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
@@ -299,16 +303,50 @@ public class AlbumSetPage extends ActivityState implements
private void clearLoadingBit(int loadingBit) {
mLoadingBits &= ~loadingBit;
if (mLoadingBits == 0 && mIsActive) {
- // Only show toast when there's no album and we are going to finish
- // the page. Toast is redundant if we are going to stay on this page.
if ((mAlbumSetDataAdapter.size() == 0)) {
+ // Only show toast when there's no album and we are going to
+ // finish, otherwise prompt user to add some pictures
if (mActivity.getStateManager().getStateCount() > 1) {
Toast.makeText(mActivity,
R.string.empty_album, Toast.LENGTH_LONG).show();
mActivity.getStateManager().finishState(this);
+ } else {
+ emptyGalleryPrompt((Activity) mActivity);
}
+ } else if (mEmptyGalleryPrompt != null) {
+ mEmptyGalleryPrompt = null;
+ }
+ }
+ }
+
+ private AlertDialog mEmptyGalleryPrompt;
+
+ private void emptyGalleryPrompt(final Context c) {
+ if (mEmptyGalleryPrompt != null) {
+ mEmptyGalleryPrompt.show();
+ return;
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(c);
+ builder.setTitle(R.string.empty_album);
+ builder.setNegativeButton(android.R.string.ok, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
}
+ });
+ if(GalleryUtils.isCameraAvailable(c)) {
+ builder.setPositiveButton(R.string.switch_to_camera,
+ new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ GalleryUtils.startCameraActivity(c);
+ }
+ });
}
+ mEmptyGalleryPrompt = builder.create();
+ mEmptyGalleryPrompt.show();
}
private void setLoadingBit(int loadingBit) {
@@ -317,6 +355,7 @@ public class AlbumSetPage extends ActivityState implements
@Override
public void onPause() {
+ if (mEmptyGalleryPrompt != null) mEmptyGalleryPrompt.dismiss();
super.onPause();
mIsActive = false;
mActionModeHandler.pause();