OSDN Git Service

Enable gallery button.
authorAngus Kong <shkong@google.com>
Fri, 13 Dec 2013 06:01:12 +0000 (22:01 -0800)
committerAngus Kong <shkong@google.com>
Fri, 13 Dec 2013 06:16:02 +0000 (22:16 -0800)
bug:11898278

Change-Id: Id7953f5fa95a6597e5cd223094ab7ccb21f53e2c

src/com/android/camera/CameraActivity.java
src/com/android/camera/app/FilmstripBottomControls.java
src_pd/com/android/camera/util/IntentHelper.java

index 660c889..77566bf 100644 (file)
@@ -269,7 +269,7 @@ public class CameraActivity extends Activity
 
                 @Override
                 public void onGallery() {
-                    // TODO: Implement.
+                    startGallery();
                 }
 
                 private int getCurrentDataId() {
@@ -951,13 +951,7 @@ public class CameraActivity extends Activity
             v.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
-                    try {
-                        UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
-                                UsageStatistics.ACTION_GALLERY, null);
-                        startActivity(IntentHelper.getGalleryIntent(CameraActivity.this));
-                    } catch (ActivityNotFoundException e) {
-                        Log.w(TAG, "Failed to launch gallery activity, closing");
-                    }
+                    startGallery();
                     finish();
                 }
             });
@@ -1567,6 +1561,17 @@ public class CameraActivity extends Activity
         getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
     }
 
+    private void startGallery() {
+        try {
+            UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+                    UsageStatistics.ACTION_GALLERY, null);
+            startActivityForResult(IntentHelper.getGalleryIntent(CameraActivity.this),
+                    REQ_CODE_DONT_SWITCH_TO_PREVIEW);
+        } catch (ActivityNotFoundException e) {
+            Log.w(TAG, "Failed to launch gallery activity, closing");
+        }
+    }
+
     private void setNfcBeamPushUriFromData(LocalData data) {
         final Uri uri = data.getContentUri();
         if (uri != Uri.EMPTY) {
index 29354d8..db168c9 100644 (file)
@@ -22,6 +22,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageButton;
 
+import com.android.camera.util.IntentHelper;
 import com.android.camera2.R;
 
 /**
@@ -119,6 +120,7 @@ class FilmstripBottomControls implements CameraAppUI.BottomControls {
 
     private void setupGalleryButton() {
         mGalleryButton = (ImageButton) mLayout.findViewById(R.id.filmstrip_bottom_control_gallery);
+        mGalleryButton.setImageResource(IntentHelper.getGalleryIntentIcon());
         mGalleryButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
index 6f17a62..f0ddbb8 100644 (file)
@@ -19,12 +19,18 @@ import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 
+import com.android.camera2.R;
+
 public class IntentHelper {
 
     private static final String GALLERY_PACKAGE_NAME = "com.android.gallery3d";
     private static final String GALLERY_ACTIVITY_CLASS =
         "com.android.gallery3d.app.GalleryActivity";
 
+    public static int getGalleryIntentIcon() {
+        return R.mipmap.ic_launcher_gallery;
+    }
+
     public static Intent getGalleryIntent(Context context) {
         return new Intent(Intent.ACTION_MAIN)
             .setClassName(GALLERY_PACKAGE_NAME, GALLERY_ACTIVITY_CLASS);