Example #1
0
 private void startPlayVideoActivity() {
     IImage image = mAllImages.getImageAt(mCurrentPosition);
     Intent intent = new Intent(
             Intent.ACTION_VIEW, image.fullSizeImageUri());
     try {
         startActivity(intent);
     } catch (android.content.ActivityNotFoundException ex) {
         Log.e(TAG, "Couldn't view video " + image.fullSizeImageUri(), ex);
     }
 }
Example #2
0
 public boolean removeImage(IImage image) {
   // TODO: need to delete the thumbnails as well
   if (mContentResolver.delete(image.fullSizeImageUri(), null, null) > 0) {
     ((BaseImage) image).onRemove();
     invalidateCursor();
     invalidateCache();
     return true;
   } else {
     return false;
   }
 }
Example #3
0
 private void startShareMediaActivity(IImage image) {
     boolean isVideo = image instanceof VideoObject;
     Intent intent = new Intent();
     intent.setAction(Intent.ACTION_SEND);
     intent.setType(image.getMimeType());
     intent.putExtra(Intent.EXTRA_STREAM, image.fullSizeImageUri());
     try {
         startActivity(Intent.createChooser(intent, getText(
                 isVideo ? R.string.sendVideo : R.string.sendImage)));
     } catch (android.content.ActivityNotFoundException ex) {
         Toast.makeText(this, isVideo
                 ? R.string.no_way_to_share_image
                 : R.string.no_way_to_share_video,
                 Toast.LENGTH_SHORT).show();
     }
 }
Example #4
0
 public void onClick(View v) {
     switch (v.getId()) {
         case R.id.btn_delete:
             MenuHelper.deleteImage(this, mDeletePhotoRunnable,
                     mAllImages.getImageAt(mCurrentPosition));
             break;
         case R.id.btn_play:
             startPlayVideoActivity();
             break;
         case R.id.btn_share: {
             IImage image = mAllImages.getImageAt(mCurrentPosition);
             if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) {
                 return;
             }
             startShareMediaActivity(image);
             break;
         }
         case R.id.btn_set_as: {
             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.btn_done:
             finish();
             break;
         case R.id.next_image:
             moveNextOrPrevious(1);
             break;
         case R.id.prev_image:
             moveNextOrPrevious(-1);
             break;
     }
 }
Example #5
0
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (mViewImage.mPaused) return false;

        // Don't respond to arrow keys if trackball scrolling is not enabled
        if (!mEnableTrackballScroll) {
            if ((keyCode >= KeyEvent.KEYCODE_DPAD_UP)
                    && (keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT)) {
                return super.onKeyDown(keyCode, event);
            }
        }

        int current = mViewImage.mCurrentPosition;

        int nextImagePos = -2; // default no next image
        try {
            switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER: {
                    if (mViewImage.isPickIntent()) {
                        IImage img = mViewImage.mAllImages
                                .getImageAt(mViewImage.mCurrentPosition);
                        mViewImage.setResult(ReviewImage.RESULT_OK,
                                 new Intent().setData(img.fullSizeImageUri()));
                        mViewImage.finish();
                    }
                    break;
                }
                case KeyEvent.KEYCODE_DPAD_LEFT: {
                    if (getScale() <= 1F && event.getEventTime()
                            >= mNextChangePositionTime) {
                        nextImagePos = current - 1;
                        mNextChangePositionTime = event.getEventTime() + 500;
                    } else {
                        panBy(PAN_RATE, 0);
                        center(true, false);
                    }
                    return true;
                }
                case KeyEvent.KEYCODE_DPAD_RIGHT: {
                    if (getScale() <= 1F && event.getEventTime()
                            >= mNextChangePositionTime) {
                        nextImagePos = current + 1;
                        mNextChangePositionTime = event.getEventTime() + 500;
                    } else {
                        panBy(-PAN_RATE, 0);
                        center(true, false);
                    }
                    return true;
                }
                case KeyEvent.KEYCODE_DPAD_UP: {
                    panBy(0, PAN_RATE);
                    center(false, true);
                    return true;
                }
                case KeyEvent.KEYCODE_DPAD_DOWN: {
                    panBy(0, -PAN_RATE);
                    center(false, true);
                    return true;
                }
                case KeyEvent.KEYCODE_DEL:
                    MenuHelper.deletePhoto(
                            mViewImage, mViewImage.mDeletePhotoRunnable);
                    break;
            }
        } finally {
            if (nextImagePos >= 0
                    && nextImagePos < mViewImage.mAllImages.getCount()) {
                synchronized (mViewImage) {
                    mViewImage.setImage(nextImagePos, true);
                }
           } else if (nextImagePos != -2) {
               center(true, true);
           }
        }

        return super.onKeyDown(keyCode, event);
    }
Example #6
0
 private Uri getCurrentUri() {
     if (mAllImages.getCount() == 0) return null;
     IImage image = mAllImages.getImageAt(mCurrentPosition);
     return image.fullSizeImageUri();
 }