summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-09-14 13:54:54 -0700
committerBobby Georgescu <georgescu@google.com>2012-09-17 10:59:50 -0700
commitba9c3f7993b817c2b1310138c8a2a48d681a000e (patch)
treee89d90d30ae0db6dbcad51fed695996e2e1d3b9f /src
parent6dc73063d683a05509467c915d306c2f68434bc0 (diff)
downloadandroid_packages_apps_Snap-ba9c3f7993b817c2b1310138c8a2a48d681a000e.tar.gz
android_packages_apps_Snap-ba9c3f7993b817c2b1310138c8a2a48d681a000e.tar.bz2
android_packages_apps_Snap-ba9c3f7993b817c2b1310138c8a2a48d681a000e.zip
Show large button to open the camera when gallery is empty
Bug: 7156303 Change-Id: I0447c3eaee680e80f09cc3aff714aace85ee77d9
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index dafe37921..a6ed8e948 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -24,6 +24,10 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.RelativeLayout;
import android.widget.Toast;
import com.actionbarsherlock.view.Menu;
@@ -112,6 +116,9 @@ public class AlbumSetPage extends ActivityState implements
private int mLoadingBits = 0;
private boolean mInitialSynced = false;
+ private Button mCameraButton;
+ private boolean mShowedEmptyToastForSelf = false;
+
@Override
protected int getBackgroundColorId() {
return R.color.albumset_background;
@@ -346,11 +353,57 @@ public class AlbumSetPage extends ActivityState implements
};
}
- private boolean mShowedEmptyToastForSelf = false;
+ @Override
+ public void onDestroy() {
+ cleanupCameraButton();
+ super.onDestroy();
+ }
+
+ private boolean setupCameraButton() {
+ RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity)
+ .findViewById(R.id.gallery_root);
+ if (galleryRoot == null) return false;
+
+ mCameraButton = new Button(mActivity);
+ mCameraButton.setText(R.string.camera_label);
+ mCameraButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.camera_white, 0, 0);
+ mCameraButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ GalleryUtils.startCameraActivity(mActivity);
+ }
+ });
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ lp.addRule(RelativeLayout.CENTER_IN_PARENT);
+ galleryRoot.addView(mCameraButton, lp);
+ return true;
+ }
+
+ private void cleanupCameraButton() {
+ if (mCameraButton == null) return;
+ RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity)
+ .findViewById(R.id.gallery_root);
+ if (galleryRoot == null) return;
+ galleryRoot.removeView(mCameraButton);
+ mCameraButton = null;
+ }
+
+ private void showCameraButton() {
+ if (mCameraButton == null && !setupCameraButton()) return;
+ mCameraButton.setVisibility(View.VISIBLE);
+ }
+
+ private void hideCameraButton() {
+ if (mCameraButton == null) return;
+ mCameraButton.setVisibility(View.GONE);
+ }
+
private void clearLoadingBit(int loadingBit) {
mLoadingBits &= ~loadingBit;
if (mLoadingBits == 0 && mIsActive) {
- if ((mAlbumSetDataAdapter.size() == 0)) {
+ if (mAlbumSetDataAdapter.size() == 0) {
// If this is not the top of the gallery folder hierarchy,
// tell the parent AlbumSetPage instance to handle displaying
// the empty album toast, otherwise show it within this
@@ -363,6 +416,7 @@ public class AlbumSetPage extends ActivityState implements
} else {
mShowedEmptyToastForSelf = true;
showEmptyAlbumToast(Toast.LENGTH_LONG);
+ showCameraButton();
}
return;
}
@@ -373,6 +427,7 @@ public class AlbumSetPage extends ActivityState implements
if (mShowedEmptyToastForSelf) {
mShowedEmptyToastForSelf = false;
hideEmptyAlbumToast();
+ hideCameraButton();
}
}