From: Angus Kong Date: Fri, 13 Dec 2013 06:01:12 +0000 (-0800) Subject: Enable gallery button. X-Git-Tag: android-x86-6.0-r3~1582 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d3de171d6afa5ebd74d56dde6d4818b14a001286;p=android-x86%2Fpackages-apps-Camera2.git Enable gallery button. bug:11898278 Change-Id: Id7953f5fa95a6597e5cd223094ab7ccb21f53e2c --- diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 660c88940..77566bf74 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -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) { diff --git a/src/com/android/camera/app/FilmstripBottomControls.java b/src/com/android/camera/app/FilmstripBottomControls.java index 29354d861..db168c919 100644 --- a/src/com/android/camera/app/FilmstripBottomControls.java +++ b/src/com/android/camera/app/FilmstripBottomControls.java @@ -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) { diff --git a/src_pd/com/android/camera/util/IntentHelper.java b/src_pd/com/android/camera/util/IntentHelper.java index 6f17a624b..f0ddbb888 100644 --- a/src_pd/com/android/camera/util/IntentHelper.java +++ b/src_pd/com/android/camera/util/IntentHelper.java @@ -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);