Search in sources :

Example 1 with SelectionManager

use of com.android.gallery3d.ui.SelectionManager in project android_packages_apps_Gallery2 by LineageOS.

the class AlbumSetPage method initializeViews.

private void initializeViews() {
    mSelectionManager = new SelectionManager(mActivity, true);
    mSelectionManager.setSelectionListener(this);
    mConfig = Config.AlbumSetPage.get(mActivity);
    mSlotView = new SlotView(mActivity, mConfig.slotViewSpec);
    mAlbumSetView = new AlbumSetSlotRenderer(mActivity, mSelectionManager, mSlotView, mConfig.labelSpec, mConfig.placeholderColor);
    mSlotView.setSlotRenderer(mAlbumSetView);
    mSlotView.setListener(new SlotView.SimpleListener() {

        @Override
        public void onDown(int index) {
            AlbumSetPage.this.onDown(index);
        }

        @Override
        public void onUp(boolean followedByLongPress) {
            AlbumSetPage.this.onUp(followedByLongPress);
        }

        @Override
        public void onSingleTapUp(int slotIndex) {
            AlbumSetPage.this.onSingleTapUp(slotIndex);
        }

        @Override
        public void onLongTap(int slotIndex) {
            AlbumSetPage.this.onLongTap(slotIndex);
        }
    });
    mActionModeHandler = new ActionModeHandler(mActivity, mSelectionManager);
    mActionModeHandler.setActionModeListener(new ActionModeListener() {

        @Override
        public boolean onActionItemClicked(MenuItem item) {
            return onItemSelected(item);
        }
    });
    mRootPane.addComponent(mSlotView);
}
Also used : SelectionManager(com.android.gallery3d.ui.SelectionManager) SlotView(com.android.gallery3d.ui.SlotView) ActionModeListener(com.android.gallery3d.ui.ActionModeHandler.ActionModeListener) AlbumSetSlotRenderer(com.android.gallery3d.ui.AlbumSetSlotRenderer) MenuItem(android.view.MenuItem) ActionModeHandler(com.android.gallery3d.ui.ActionModeHandler)

Example 2 with SelectionManager

use of com.android.gallery3d.ui.SelectionManager in project android_packages_apps_Gallery2 by LineageOS.

the class TimeLinePage method initializeViews.

private void initializeViews() {
    mSelectionManager = new SelectionManager(mActivity, false);
    mSelectionManager.setSelectionListener(this);
    Config.TimeLinePage config = Config.TimeLinePage.get(mActivity);
    mSlotView = new TimeLineSlotView(mActivity, config.slotViewSpec);
    mAlbumView = new TimeLineSlotRenderer(mActivity, mSlotView, mSelectionManager, config.labelSpec, config.placeholderColor);
    mSlotView.setSlotRenderer(mAlbumView);
    mRootPane.addComponent(mSlotView);
    mSlotView.setListener(new TimeLineSlotView.SimpleListener() {

        @Override
        public void onDown(int index) {
            TimeLinePage.this.onDown(index);
        }

        @Override
        public void onUp(boolean followedByLongPress) {
            TimeLinePage.this.onUp(followedByLongPress);
        }

        @Override
        public void onSingleTapUp(int slotIndex, boolean isTitle) {
            TimeLinePage.this.onSingleTapUp(slotIndex, isTitle);
        }

        @Override
        public void onLongTap(int slotIndex, boolean isTitle) {
            TimeLinePage.this.onLongTap(slotIndex, isTitle);
        }
    });
    mActionModeHandler = new ActionModeHandler(mActivity, mSelectionManager);
    mActionModeHandler.setActionModeListener(new ActionModeListener() {

        @Override
        public boolean onActionItemClicked(MenuItem item) {
            return onItemSelected(item);
        }
    });
}
Also used : TimeLineSlotRenderer(com.android.gallery3d.ui.TimeLineSlotRenderer) SelectionManager(com.android.gallery3d.ui.SelectionManager) ActionModeListener(com.android.gallery3d.ui.ActionModeHandler.ActionModeListener) TimeLineSlotView(com.android.gallery3d.ui.TimeLineSlotView) MenuItem(android.view.MenuItem) ActionModeHandler(com.android.gallery3d.ui.ActionModeHandler)

Example 3 with SelectionManager

use of com.android.gallery3d.ui.SelectionManager in project android_packages_apps_Gallery2 by LineageOS.

the class ManageCachePage method initializeViews.

private void initializeViews() {
    Activity activity = mActivity;
    mSelectionManager = new SelectionManager(mActivity, true);
    mSelectionManager.setSelectionListener(this);
    Config.ManageCachePage config = Config.ManageCachePage.get(activity);
    mSlotView = new SlotView(mActivity, config.slotViewSpec);
    mSelectionDrawer = new ManageCacheDrawer(mActivity, mSelectionManager, mSlotView, config.labelSpec, config.cachePinSize, config.cachePinMargin);
    mSlotView.setSlotRenderer(mSelectionDrawer);
    mSlotView.setListener(new SlotView.SimpleListener() {

        @Override
        public void onDown(int index) {
            ManageCachePage.this.onDown(index);
        }

        @Override
        public void onUp(boolean followedByLongPress) {
            ManageCachePage.this.onUp();
        }

        @Override
        public void onSingleTapUp(int slotIndex) {
            ManageCachePage.this.onSingleTapUp(slotIndex);
        }
    });
    mRootPane.addComponent(mSlotView);
    initializeFooterViews();
}
Also used : ManageCacheDrawer(com.android.gallery3d.ui.ManageCacheDrawer) SelectionManager(com.android.gallery3d.ui.SelectionManager) SlotView(com.android.gallery3d.ui.SlotView) Activity(android.app.Activity)

Example 4 with SelectionManager

use of com.android.gallery3d.ui.SelectionManager in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoPage method onCreate.

@Override
public void onCreate(Bundle data, Bundle restoreState) {
    super.onCreate(data, restoreState);
    mActionBar = mActivity.getGalleryActionBar();
    mActionBar.setBackGroundTransparent();
    mSelectionManager = new SelectionManager(mActivity, false);
    mMenuExecutor = new MenuExecutor(mActivity, mSelectionManager);
    mPhotoView = new PhotoView(mActivity);
    mPhotoView.setListener(this);
    mRootPane.addComponent(mPhotoView);
    mApplication = (GalleryApp) ((Activity) mActivity).getApplication();
    mOrientationManager = mActivity.getOrientationManager();
    mActivity.getGLRoot().setOrientationSource(mOrientationManager);
    mIsFromVideoScreen = data.getBoolean(KEY_FROM_VIDEOS_SCREEN, false);
    mIsFromTimelineScreen = data.getBoolean(KEY_FROM_TIMELINE_SCREEN, false);
    mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {

        @Override
        public void handleMessage(Message message) {
            switch(message.what) {
                case MSG_HIDE_BARS:
                    {
                        hideBars();
                        break;
                    }
                case MSG_REFRESH_BOTTOM_CONTROLS:
                    {
                        if (mCurrentPhoto == message.obj && mBottomControls != null) {
                            mIsPanorama = message.arg1 == 1;
                            mIsPanorama360 = message.arg2 == 1;
                            mBottomControls.refresh();
                            if (null != m3DButton) {
                                m3DButton.refresh();
                            }
                        }
                        break;
                    }
                case MSG_ON_FULL_SCREEN_CHANGED:
                    {
                        if (mAppBridge != null) {
                            mAppBridge.onFullScreenChanged(message.arg1 == 1);
                        }
                        break;
                    }
                case MSG_UPDATE_ACTION_BAR:
                    {
                        updateBars();
                        break;
                    }
                case MSG_WANT_BARS:
                    {
                        wantBars();
                        break;
                    }
                case MSG_UPDATE_DEFERRED:
                    {
                        long nextUpdate = mDeferUpdateUntil - SystemClock.uptimeMillis();
                        if (nextUpdate <= 0) {
                            mDeferredUpdateWaiting = false;
                            updateUIForCurrentPhoto();
                        } else {
                            mHandler.sendEmptyMessageDelayed(MSG_UPDATE_DEFERRED, nextUpdate);
                        }
                        break;
                    }
                case MSG_ON_CAMERA_CENTER:
                    {
                        mSkipUpdateCurrentPhoto = false;
                        boolean stayedOnCamera = false;
                        if (!mPhotoView.getFilmMode()) {
                            stayedOnCamera = true;
                        } else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff && mMediaSet.getMediaItemCount() > 1) {
                            mPhotoView.switchToImage(1);
                        } else {
                            if (mAppBridge != null)
                                mPhotoView.setFilmMode(false);
                            stayedOnCamera = true;
                        }
                        if (stayedOnCamera) {
                            if (mAppBridge == null && mMediaSet.getTotalMediaItemCount() > 1) {
                                launchCamera();
                                /* We got here by swiping from photo 1 to the
                                   placeholder, so make it be the thing that
                                   is in focus when the user presses back from
                                   the camera app */
                                mPhotoView.switchToImage(1);
                            } else {
                                updateBars();
                                updateCurrentPhoto(mModel.getMediaItem(0));
                            }
                        }
                        break;
                    }
                case MSG_ON_PICTURE_CENTER:
                    {
                        if (!mPhotoView.getFilmMode() && mCurrentPhoto != null && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) {
                            mPhotoView.setFilmMode(true);
                        }
                        break;
                    }
                case MSG_REFRESH_IMAGE:
                    {
                        final MediaItem photo = mCurrentPhoto;
                        mCurrentPhoto = null;
                        updateCurrentPhoto(photo);
                        break;
                    }
                case MSG_UPDATE_PHOTO_UI:
                    {
                        updateUIForCurrentPhoto();
                        break;
                    }
                case MSG_UPDATE_SHARE_URI:
                    {
                        if (mCurrentPhoto == message.obj) {
                            boolean isPanorama360 = message.arg1 != 0;
                            Uri contentUri = mCurrentPhoto.getContentUri();
                            Intent panoramaIntent = null;
                            if (isPanorama360) {
                                panoramaIntent = createSharePanoramaIntent(contentUri);
                            }
                            Intent shareIntent = createShareIntent(mCurrentPhoto);
                            if (shareIntent != null) {
                                mActionBar.setShareIntents(panoramaIntent, shareIntent);
                            }
                            setNfcBeamPushUri(contentUri);
                        }
                        break;
                    }
                case MSG_UPDATE_PANORAMA_UI:
                    {
                        if (mCurrentPhoto == message.obj) {
                            boolean isPanorama360 = message.arg1 != 0;
                            updatePanoramaUI(isPanorama360);
                        }
                        break;
                    }
                default:
                    throw new AssertionError(message.what);
            }
        }
    };
    mSetPathString = data.getString(KEY_MEDIA_SET_PATH);
    mReadOnlyView = data.getBoolean(KEY_READONLY);
    mOriginalSetPathString = mSetPathString;
    setupNfcBeamPush();
    String itemPathString = data.getString(KEY_MEDIA_ITEM_PATH);
    Path itemPath = itemPathString != null ? Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) : null;
    mTreatBackAsUp = data.getBoolean(KEY_TREAT_BACK_AS_UP, false);
    mIsFromWidget = data.getBoolean(KEY_IS_FROM_WIDGET, false);
    mStartInFilmstrip = data.getBoolean(KEY_START_IN_FILMSTRIP, false);
    boolean inCameraRoll = data.getBoolean(KEY_IN_CAMERA_ROLL, false);
    if (restoreState == null || mSetPathString == null) {
        mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
    } else {
        mCurrentIndex = restoreState.getInt(KEY_INDEX_HINT, 0);
        // we only save index in onSaveState, set itemPath to null to get the right path later
        itemPath = null;
    }
    if ((mCurrentPhoto == null) && (restoreState != null)) {
        String curPath = restoreState.getString(KEY_CURRENT_PHOTO_HINT, null);
        if (curPath != null)
            mCurrentPhoto = (MediaItem) mActivity.getDataManager().getMediaObject(curPath);
    }
    if (mSetPathString != null) {
        mShowSpinner = true;
        mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE);
        if (mAppBridge != null) {
            mShowBars = false;
            mHasCameraScreennailOrPlaceholder = true;
            mAppBridge.setServer(this);
            // Get the ScreenNail from AppBridge and register it.
            int id = SnailSource.newId();
            Path screenNailSetPath = SnailSource.getSetPath(id);
            Path screenNailItemPath = SnailSource.getItemPath(id);
            mScreenNailSet = (SnailAlbum) mActivity.getDataManager().getMediaObject(screenNailSetPath);
            mScreenNailItem = (SnailItem) mActivity.getDataManager().getMediaObject(screenNailItemPath);
            mScreenNailItem.setScreenNail(mAppBridge.attachScreenNail());
            if (data.getBoolean(KEY_SHOW_WHEN_LOCKED, false)) {
                // Set the flag to be on top of the lock screen.
                mFlags |= FLAG_SHOW_WHEN_LOCKED;
            }
            // Don't display "empty album" action item for capture intents.
            if (!mSetPathString.equals("/local/all/0")) {
                // Check if the path is a secure album.
                if (SecureSource.isSecurePath(mSetPathString)) {
                    mSecureAlbum = (SecureAlbum) mActivity.getDataManager().getMediaSet(mSetPathString);
                    mShowSpinner = false;
                }
                mSetPathString = "/filter/empty/{" + mSetPathString + "}";
            }
            // Combine the original MediaSet with the one for ScreenNail
            // from AppBridge.
            mSetPathString = "/combo/item/{" + screenNailSetPath + "," + mSetPathString + "}";
            // Start from the screen nail.
            itemPath = screenNailItemPath;
        } else if (inCameraRoll && GalleryUtils.isCameraAvailable(mActivity)) {
            mSetPathString = "/combo/item/{" + FilterSource.FILTER_CAMERA_SHORTCUT + "," + mSetPathString + "}";
            mCurrentIndex++;
            mHasCameraScreennailOrPlaceholder = true;
        }
        MediaSet originalSet = mActivity.getDataManager().getMediaSet(mSetPathString);
        if (mHasCameraScreennailOrPlaceholder && originalSet instanceof ComboAlbum) {
            // Use the name of the camera album rather than the default
            // ComboAlbum behavior
            ((ComboAlbum) originalSet).useNameOfChild(1);
        }
        mSelectionManager.setSourceMediaSet(originalSet);
        mSetPathString = "/filter/delete/{" + mSetPathString + "}";
        mMediaSet = (FilterDeleteSet) mActivity.getDataManager().getMediaSet(mSetPathString);
        if (mMediaSet != null && mIsFromTimelineScreen) {
            mMediaSet.setShowAlbumsetTimeTitle(false);
        }
        if (mMediaSet == null) {
            Log.w(TAG, "failed to restore " + mSetPathString);
        }
        if (itemPath == null) {
            int mediaItemCount = mMediaSet.getMediaItemCount();
            if (mediaItemCount > 0) {
                if (mCurrentIndex >= mediaItemCount)
                    mCurrentIndex = 0;
                itemPath = mMediaSet.getMediaItem(mCurrentIndex, 1).get(0).getPath();
            } else {
                // Bail out, PhotoPage can't load on an empty album
                return;
            }
        }
        PhotoDataAdapter pda = new PhotoDataAdapter(mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex, mAppBridge == null ? -1 : 0, mAppBridge == null ? false : mAppBridge.isPanorama(), mAppBridge == null ? false : mAppBridge.isStaticCamera());
        mModel = pda;
        mPhotoView.setModel(mModel);
        // If RTL and from widget, set the flag into PhotoDataAdapter.
        if (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) && mIsFromWidget) {
            pda.setFromWidget(mIsFromWidget);
        }
        pda.setDataListener(new PhotoDataAdapter.DataListener() {

            @Override
            public void onPhotoChanged(int index, Path item) {
                int oldIndex = mCurrentIndex;
                mCurrentIndex = index;
                if (mHasCameraScreennailOrPlaceholder) {
                    if (mCurrentIndex > 0) {
                        mSkipUpdateCurrentPhoto = false;
                    }
                    if (oldIndex == 0 && mCurrentIndex > 0 && !mPhotoView.getFilmMode()) {
                        mPhotoView.setFilmMode(true);
                        if (mAppBridge != null) {
                            UsageStatistics.onEvent("CameraToFilmstrip", UsageStatistics.TRANSITION_SWIPE, null);
                        }
                    } else if (oldIndex == 2 && mCurrentIndex == 1) {
                        mCameraSwitchCutoff = SystemClock.uptimeMillis() + CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
                        mPhotoView.stopScrolling();
                    } else if (oldIndex >= 1 && mCurrentIndex == 0) {
                        mPhotoView.setWantPictureCenterCallbacks(true);
                        mSkipUpdateCurrentPhoto = true;
                    }
                }
                if (!mSkipUpdateCurrentPhoto) {
                    if (item != null) {
                        MediaItem photo = mModel.getMediaItem(0);
                        if (photo != null) {
                            mActionBar.setTitle(photo.getName());
                            updateCurrentPhoto(photo);
                        }
                    }
                    updateBars();
                }
                // Reset the timeout for the bars after a swipe
                refreshHidingMessage();
            }

            @Override
            public void onLoadingFinished(boolean loadingFailed) {
                if (!mModel.isEmpty()) {
                    MediaItem photo = mModel.getMediaItem(0);
                    if (photo != null) {
                        updateCurrentPhoto(photo);
                    } else {
                        mModel.resume();
                    }
                } else if (mIsActive) {
                    // deletion that the user can undo.
                    if (mMediaSet.getNumberOfDeletions() == 0) {
                        onBackPressed();
                    }
                }
            }

            @Override
            public void onLoadingStarted() {
            }
        });
    } else {
        // Get default media set by the URI
        MediaItem mediaItem = (MediaItem) mActivity.getDataManager().getMediaObject(itemPath);
        mModel = new SinglePhotoDataAdapter(mActivity, mPhotoView, mediaItem);
        mPhotoView.setModel(mModel);
        updateCurrentPhoto(mediaItem);
        mShowSpinner = false;
    }
    mPhotoView.setFilmMode(mStartInFilmstrip && mMediaSet.getMediaItemCount() > 1);
    RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity).findViewById(mAppBridge != null ? R.id.content : R.id.gallery_root);
    if (galleryRoot != null) {
        if (mSecureAlbum == null) {
            mBottomControls = new PhotoPageBottomControls(this, mActivity, galleryRoot);
            m3DButton = new ThreeDButton(this, mActivity, galleryRoot);
        }
    }
    ((GLRootView) mActivity.getGLRoot()).setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            int diff = mLastSystemUiVis ^ visibility;
            mLastSystemUiVis = visibility;
            if ((diff & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0 && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                showBars();
            }
        }
    });
}
Also used : Message(android.os.Message) ThreeDimensionalActivity(com.android.gallery3d.app.dualcam3d.ThreeDimensionalActivity) Activity(android.app.Activity) FilterShowActivity(com.android.gallery3d.filtershow.FilterShowActivity) Uri(android.net.Uri) MediaSet(com.android.gallery3d.data.MediaSet) SynchronizedHandler(com.android.gallery3d.ui.SynchronizedHandler) Path(com.android.gallery3d.data.Path) SelectionManager(com.android.gallery3d.ui.SelectionManager) Intent(android.content.Intent) MenuExecutor(com.android.gallery3d.ui.MenuExecutor) GLView(com.android.gallery3d.ui.GLView) View(android.view.View) GLRootView(com.android.gallery3d.ui.GLRootView) PhotoView(com.android.gallery3d.ui.PhotoView) PhotoView(com.android.gallery3d.ui.PhotoView) GLRootView(com.android.gallery3d.ui.GLRootView) MediaItem(com.android.gallery3d.data.MediaItem) RelativeLayout(android.widget.RelativeLayout) ComboAlbum(com.android.gallery3d.data.ComboAlbum)

Example 5 with SelectionManager

use of com.android.gallery3d.ui.SelectionManager in project android_packages_apps_Gallery2 by LineageOS.

the class AlbumPage method initializeViews.

private void initializeViews() {
    mSelectionManager = new SelectionManager(mActivity, false);
    mSelectionManager.setSelectionListener(this);
    mConfig = Config.AlbumPage.get(mActivity);
    mConfigList = Config.AlbumPageList.get(mActivity);
    if (mViewType) {
        mSlotView = new SlotView(mActivity, mConfig.slotViewSpec);
        mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, mConfig.labelSpec, mSelectionManager, mConfig.placeholderColor, mViewType);
    } else {
        mSlotView = new SlotView(mActivity, mConfigList.slotViewSpec);
        mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView, mConfigList.labelSpec, mSelectionManager, mConfig.placeholderColor, mViewType);
    }
    mSlotView.setSlotRenderer(mAlbumView);
    mRootPane.addComponent(mSlotView);
    mSlotView.setListener(new SlotView.SimpleListener() {

        @Override
        public void onDown(int index) {
            AlbumPage.this.onDown(index);
        }

        @Override
        public void onUp(boolean followedByLongPress) {
            AlbumPage.this.onUp(followedByLongPress);
        }

        @Override
        public void onSingleTapUp(int slotIndex) {
            AlbumPage.this.onSingleTapUp(slotIndex);
        }

        @Override
        public void onLongTap(int slotIndex) {
            AlbumPage.this.onLongTap(slotIndex);
        }
    });
    mActionModeHandler = new ActionModeHandler(mActivity, mSelectionManager);
    mActionModeHandler.setActionModeListener(new ActionModeListener() {

        @Override
        public boolean onActionItemClicked(MenuItem item) {
            return onItemSelected(item);
        }
    });
}
Also used : SelectionManager(com.android.gallery3d.ui.SelectionManager) SlotView(com.android.gallery3d.ui.SlotView) ActionModeListener(com.android.gallery3d.ui.ActionModeHandler.ActionModeListener) AlbumSlotRenderer(com.android.gallery3d.ui.AlbumSlotRenderer) MenuItem(android.view.MenuItem) ActionModeHandler(com.android.gallery3d.ui.ActionModeHandler)

Aggregations

SelectionManager (com.android.gallery3d.ui.SelectionManager)5 MenuItem (android.view.MenuItem)3 ActionModeHandler (com.android.gallery3d.ui.ActionModeHandler)3 ActionModeListener (com.android.gallery3d.ui.ActionModeHandler.ActionModeListener)3 SlotView (com.android.gallery3d.ui.SlotView)3 Activity (android.app.Activity)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Message (android.os.Message)1 View (android.view.View)1 RelativeLayout (android.widget.RelativeLayout)1 ThreeDimensionalActivity (com.android.gallery3d.app.dualcam3d.ThreeDimensionalActivity)1 ComboAlbum (com.android.gallery3d.data.ComboAlbum)1 MediaItem (com.android.gallery3d.data.MediaItem)1 MediaSet (com.android.gallery3d.data.MediaSet)1 Path (com.android.gallery3d.data.Path)1 FilterShowActivity (com.android.gallery3d.filtershow.FilterShowActivity)1 AlbumSetSlotRenderer (com.android.gallery3d.ui.AlbumSetSlotRenderer)1 AlbumSlotRenderer (com.android.gallery3d.ui.AlbumSlotRenderer)1 GLRootView (com.android.gallery3d.ui.GLRootView)1