@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mPaused) return false; setMode(MODE_NORMAL); IImage image = mAllImages.getImageAt(mCurrentPosition); if (mImageMenuRunnable != null) { mImageMenuRunnable.gettingReadyToOpen(menu, image); } Uri uri = mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri(); MenuHelper.enableShareMenuItem(menu, MenuHelper.isWhiteListUri(uri)); MenuHelper.enableShowOnMapMenuItem(menu, MenuHelper.hasLatLngData(image)); return true; }
public void onClick(View v) { switch (v.getId()) { case R.id.discard: MenuHelper.deletePhoto(this, mDeletePhotoRunnable); break; case R.id.play: startPlayVideoActivity(); break; case R.id.share: { IImage image = mAllImages.getImageAt(mCurrentPosition); if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) { return; } startShareMediaActivity(image); break; } case R.id.setas: { IImage image = mAllImages.getImageAt(mCurrentPosition); Intent intent = Util.createSetAsIntent(image); try { startActivity(Intent.createChooser(intent, getText(R.string.setImage))); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(this, R.string.no_way_to_share_video, Toast.LENGTH_SHORT).show(); } break; } case R.id.next_image: moveNextOrPrevious(1); break; case R.id.prev_image: moveNextOrPrevious(-1); break; } }
@Override public void onCreate(Bundle instanceState) { super.onCreate(instanceState); Intent intent = getIntent(); mFullScreenInNormalMode = intent.getBooleanExtra(MediaStore.EXTRA_FULL_SCREEN, true); mShowActionIcons = intent.getBooleanExtra(MediaStore.EXTRA_SHOW_ACTION_ICONS, true); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.viewimage); mImageView = (ImageViewTouch) findViewById(R.id.image); mImageView.setEnableTrackballScroll(true); mCache = new BitmapCache(3); mImageView.setRecycler(mCache); makeGetter(); mAnimationIndex = -1; mSlideShowInAnimation = new Animation[] { makeInAnimation(R.anim.transition_in), makeInAnimation(R.anim.slide_in), makeInAnimation(R.anim.slide_in_vertical), }; mSlideShowOutAnimation = new Animation[] { makeOutAnimation(R.anim.transition_out), makeOutAnimation(R.anim.slide_out), makeOutAnimation(R.anim.slide_out_vertical), }; mSlideShowImageViews[0] = (ImageViewTouchBase) findViewById(R.id.image1_slideShow); mSlideShowImageViews[1] = (ImageViewTouchBase) findViewById(R.id.image2_slideShow); for (ImageViewTouchBase v : mSlideShowImageViews) { v.setVisibility(View.INVISIBLE); v.setRecycler(mCache); } mActionIconPanel = findViewById(R.id.action_icon_panel); mParam = getIntent().getParcelableExtra(KEY_IMAGE_LIST); boolean slideshow; if (instanceState != null) { mSavedUri = instanceState.getParcelable(STATE_URI); slideshow = instanceState.getBoolean(STATE_SLIDESHOW, false); mShowControls = instanceState.getBoolean(STATE_SHOW_CONTROLS, true); } else { mSavedUri = getIntent().getData(); slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false); } // We only show action icons for URIs that we know we can share and // delete. Although we get read permission (for the images) from // applications like MMS, we cannot pass the permission to other // activities due to the current framework design. if (!MenuHelper.isWhiteListUri(mSavedUri)) { mShowActionIcons = false; } if (mShowActionIcons) { int[] pickIds = {R.id.attach, R.id.cancel}; int[] normalIds = {R.id.setas, R.id.play, R.id.share, R.id.discard}; int[] connectIds = isPickIntent() ? pickIds : normalIds; for (int id : connectIds) { View view = mActionIconPanel.findViewById(id); view.setVisibility(View.VISIBLE); view.setOnClickListener(this); } } // Don't show the "delete" icon for SingleImageList. if (ImageManager.isSingleImageMode(mSavedUri.toString())) { mActionIconPanel.findViewById(R.id.discard).setVisibility(View.GONE); } if (slideshow) { setMode(MODE_SLIDESHOW); } else { if (mFullScreenInNormalMode) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } if (mShowActionIcons) { mActionIconPanel.setVisibility(View.VISIBLE); } } setupOnScreenControls(findViewById(R.id.rootLayout), mImageView); }