@Override public void onSelectionModeChange(int mode) { switch (mode) { case SelectionManager.ENTER_SELECTION_MODE: { mActionBar.disableClusterMenu(true); mActionModeHandler.startActionMode(); performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); break; } case SelectionManager.LEAVE_SELECTION_MODE: { mActionModeHandler.finishActionMode(); if (mShowClusterMenu) { mActionBar.enableClusterMenu(mSelectedAction, this); } mRootPane.invalidate(); break; } case SelectionManager.SELECT_ALL_MODE: { mActionModeHandler.updateSupportedOperation(); mRootPane.invalidate(); break; } } }
@Override public void onResume() { super.onResume(); mIsActive = true; setContentPane(mRootPane); // Set the reload bit here to prevent it exit this page in clearLoadingBit(). setLoadingBit(BIT_LOADING_RELOAD); mAlbumSetDataAdapter.resume(); mAlbumSetView.resume(); mEyePosition.resume(); mActionModeHandler.resume(); if (mShowClusterMenu) { mActionBar.enableClusterMenu(mSelectedAction, this); } if (!mInitialSynced) { setLoadingBit(BIT_LOADING_SYNC); mSyncTask = mMediaSet.requestSync(AlbumSetPage.this); } // jiangxd add for dockbar if (mActivity instanceof Gallery) { ((Gallery) mActivity).setDockBarVisible(false); } // end }
private String getSelectedString() { int count = mSelectionManager.getSelectedCount(); int action = mActionBar.getClusterTypeAction(); int string = action == FilterUtils.CLUSTER_BY_ALBUM ? R.plurals.number_of_albums_selected : R.plurals.number_of_groups_selected; String format = mActivity.getResources().getQuantityString(string, count); return String.format(format, count); }
@Override protected boolean onCreateActionBar(Menu menu) { GalleryActionBar actionBar = mActivity.getGalleryActionBar(); MenuInflater inflator = getSupportMenuInflater(); if (mGetContent) { inflator.inflate(R.menu.pickup, menu); int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE); actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); } else { inflator.inflate(R.menu.album, menu); actionBar.setTitle(mMediaSet.getName()); FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true); menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu); menu.findItem(R.id.action_camera) .setVisible( MediaSetUtils.isCameraSource(mMediaSetPath) && GalleryUtils.isCameraAvailable(mActivity)); } actionBar.setSubtitle(null); return true; }
@Override protected void onResume() { super.onResume(); mIsActive = true; mResumeEffect = mActivity.getTransitionStore().get(KEY_RESUME_ANIMATION); if (mResumeEffect != null) { mAlbumView.setSlotFilter(mResumeEffect); mResumeEffect.setPositionProvider(mPositionProvider); mResumeEffect.start(); } setContentPane(mRootPane); boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) | mParentMediaSetString != null; GalleryActionBar actionBar = mActivity.getGalleryActionBar(); actionBar.setDisplayOptions(enableHomeButton, false); if (!mGetContent) { actionBar.enableAlbumModeMenu(GalleryActionBar.ALBUM_GRID_MODE_SELECTED, this); } // Set the reload bit here to prevent it exit this page in clearLoadingBit(). setLoadingBit(BIT_LOADING_RELOAD); mLoadingFailed = false; mAlbumDataAdapter.resume(); mAlbumView.resume(); mAlbumView.setPressedIndex(-1); mActionModeHandler.resume(); if (!mInitialSynced) { setLoadingBit(BIT_LOADING_SYNC); mSyncTask = mMediaSet.requestSync(this); } mInCameraAndWantQuitOnPause = mInCameraApp; }
public static void setupMenuItems(GalleryActionBar actionBar, Path path, boolean inAlbum) { int[] result = new int[6]; getAppliedFilters(path, result); int ctype = result[CLUSTER_TYPE]; int ftype = result[FILTER_TYPE]; int ftypef = result[FILTER_TYPE_F]; int ccurrent = result[CLUSTER_CURRENT_TYPE]; int fcurrent = result[FILTER_CURRENT_TYPE]; setMenuItemApplied( actionBar, CLUSTER_BY_TIME, (ctype & CLUSTER_BY_TIME) != 0, (ccurrent & CLUSTER_BY_TIME) != 0); setMenuItemApplied( actionBar, CLUSTER_BY_LOCATION, (ctype & CLUSTER_BY_LOCATION) != 0, (ccurrent & CLUSTER_BY_LOCATION) != 0); setMenuItemApplied( actionBar, CLUSTER_BY_TAG, (ctype & CLUSTER_BY_TAG) != 0, (ccurrent & CLUSTER_BY_TAG) != 0); setMenuItemApplied( actionBar, CLUSTER_BY_FACE, (ctype & CLUSTER_BY_FACE) != 0, (ccurrent & CLUSTER_BY_FACE) != 0); actionBar.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0); setMenuItemApplied(actionBar, R.id.action_cluster_album, ctype == 0, ccurrent == 0); // A filtering is available if it's not applied, and the old filtering // (if any) is not fixed. setMenuItemAppliedEnabled( actionBar, R.string.show_images_only, (ftype & FILTER_IMAGE_ONLY) != 0, (ftype & FILTER_IMAGE_ONLY) == 0 && ftypef == 0, (fcurrent & FILTER_IMAGE_ONLY) != 0); setMenuItemAppliedEnabled( actionBar, R.string.show_videos_only, (ftype & FILTER_VIDEO_ONLY) != 0, (ftype & FILTER_VIDEO_ONLY) == 0 && ftypef == 0, (fcurrent & FILTER_VIDEO_ONLY) != 0); setMenuItemAppliedEnabled( actionBar, R.string.show_all, ftype == 0, ftype != 0 && ftypef == 0, fcurrent == 0); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { mEyePosition.resetPosition(); int slotViewTop = mActionBar.getHeight() + mConfig.paddingTop; int slotViewBottom = bottom - top - mConfig.paddingBottom; int slotViewRight = right - left - mConfig.paddingRight; if (mShowDetails) { mDetailsHelper.layout(left, slotViewTop, right, bottom); } else { mAlbumSetView.setHighlightItemPath(null); } mSlotView.layout(mConfig.paddingLeft, slotViewTop, slotViewRight, slotViewBottom); }
@Override protected boolean onCreateActionBar(Menu menu) { Activity activity = mActivity; final boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); MenuInflater inflater = getSupportMenuInflater(); if (mGetContent) { inflater.inflate(R.menu.pickup, menu); int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS, DataManager.INCLUDE_IMAGE); mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits)); } else if (mGetAlbum) { inflater.inflate(R.menu.pickup, menu); mActionBar.setTitle(R.string.select_album); } else { inflater.inflate(R.menu.albumset, menu); boolean wasShowingClusterMenu = mShowClusterMenu; mShowClusterMenu = !inAlbum; if (mShowClusterMenu != wasShowingClusterMenu) { if (mShowClusterMenu) { mActionBar.enableClusterMenu(mSelectedAction, this); } else { mActionBar.disableClusterMenu(true); } } boolean selectAlbums = !inAlbum && mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM; MenuItem selectItem = menu.findItem(R.id.action_select); selectItem.setTitle( activity.getString(selectAlbums ? R.string.select_album : R.string.select_group)); MenuItem cameraItem = menu.findItem(R.id.action_camera); cameraItem.setVisible(GalleryUtils.isCameraAvailable(activity)); FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false); Intent helpIntent = HelpUtils.getHelpIntent(activity); MenuItem helpItem = menu.findItem(R.id.action_general_help); helpItem.setVisible(helpIntent != null); if (helpIntent != null) helpItem.setIntent(helpIntent); MenuItem moreItem = menu.findItem(R.id.action_more_image); moreItem.setVisible(mActivity.getResources().getBoolean(R.bool.config_show_more_images)); mActionBar.setTitle(mTitle); mActionBar.setSubtitle(mSubtitle); } return true; }
@Override public void doCluster(int clusterType) { String basePath = mMediaSet.getPath().toString(); String newPath = FilterUtils.newClusterPath(basePath, clusterType); Bundle data = new Bundle(getData()); data.putString(AlbumSetPage.KEY_MEDIA_PATH, newPath); if (mShowClusterMenu) { Context context = mActivity.getAndroidContext(); data.putString(AlbumSetPage.KEY_SET_TITLE, mMediaSet.getName()); data.putString( AlbumSetPage.KEY_SET_SUBTITLE, GalleryActionBar.getClusterByTypeString(context, clusterType)); } // mAlbumView.savePositions(PositionRepository.getInstance(mActivity)); mActivity.getStateManager().startStateForResult(AlbumSetPage.class, REQUEST_DO_ANIMATION, data); }
@Override public void onPause() { super.onPause(); mIsActive = false; mAlbumSetDataAdapter.pause(); mAlbumSetView.pause(); mActionModeHandler.pause(); mEyePosition.pause(); DetailsHelper.pause(); // Call disableClusterMenu to avoid receiving callback after paused. // Don't hide menu here otherwise the list menu will disappear earlier than // the action bar, which is janky and unwanted behavior. mActionBar.disableClusterMenu(false); if (mSyncTask != null) { mSyncTask.cancel(); mSyncTask = null; clearLoadingBit(BIT_LOADING_SYNC); } }
private static void setMenuItemAppliedEnabled( GalleryActionBar model, int id, boolean applied, boolean enabled, boolean updateTitle) { model.setClusterItemEnabled(id, enabled); }