예제 #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int typeBits = GalleryUtils.determineTypeBits(this, getIntent());
    setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    Bundle data = extras == null ? new Bundle() : new Bundle(extras);

    data.putBoolean(Gallery.KEY_GET_CONTENT, true);
    data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(typeBits));
    getStateManager().startState(AlbumSetPage.class, data);
  }
  @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
  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;
  }