Ejemplo n.º 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    // Only show favourites and access tokens (DB-related) if the connected server has a DB
    // representation (non-public).
    MenuItem fullscreenItem = menu.findItem(R.id.menu_fullscreen);
    MenuItem favouritesViewItem = menu.findItem(R.id.menu_view_favorites_button);
    MenuItem accessTokensItem = menu.findItem(R.id.menu_access_tokens_button);

    userRegisterItem = menu.findItem(R.id.menu_user_register);
    userCommentItem = menu.findItem(R.id.menu_user_comment);
    userInformationItem = menu.findItem(R.id.menu_user_information);

    if (mService != null && mService.getConnectedServer() != null) {

      favouritesViewItem.setVisible(!mService.isConnectedServerPublic());
      accessTokensItem.setVisible(!mService.isConnectedServerPublic());
    }

    fullscreenItem.setVisible(mViewPager == null); // Only show fullscreen option if in tablet mode

    // Show whether or not SCO is enabled
    AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
    bluetoothItem = menu.findItem(R.id.menu_bluetooth);
    bluetoothItem.setChecked(audioManager.isBluetoothScoOn());

    return super.onPrepareOptionsMenu(menu);
  }
Ejemplo n.º 2
0
  @Override
  protected boolean prepareActionMode(ActionMode mode, Menu menu, QuranRow[] selected) {
    MenuItem editItem = menu.findItem(R.id.cab_edit_tag);
    MenuItem removeItem = menu.findItem(R.id.cab_delete_tag);
    MenuItem tagItem = menu.findItem(R.id.cab_tag_bookmark);

    int headers = 0;
    int bookmarks = 0;

    for (QuranRow row : selected) {
      if (row.isBookmarkHeader()) {
        headers++;
      } else if (row.isBookmark()) {
        bookmarks++;
      }
    }

    boolean canEdit = headers == 1 && bookmarks == 0;
    boolean canRemove = (headers + bookmarks) > 0;
    boolean canTag = headers == 0 && bookmarks > 0;
    editItem.setVisible(canEdit);
    removeItem.setVisible(canRemove);
    tagItem.setVisible(canTag);
    return true;
  }
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   MenuItem menuProgress = menu.findItem(R.id.menu_progress);
   MenuItem menuRefresh = menu.findItem(R.id.menu_refresh);
   menuProgress.setVisible(mProgressIndicator);
   menuRefresh.setVisible(!mProgressIndicator);
 }
Ejemplo n.º 4
0
  private void setReloadingState(boolean reloading) {
    LinearLayout llContent = (LinearLayout) getActivity().findViewById(R.id.llContent);
    RelativeLayout rlSplashScreen =
        (RelativeLayout) getActivity().findViewById(R.id.rlSplashScreen);
    ImageButton btnRefresh = (ImageButton) getActivity().findViewById(R.id.btnRefresh);
    ProgressBar pbRefreshing = (ProgressBar) getActivity().findViewById(R.id.pbRefreshing);

    _menuReload.setVisible(!reloading);
    _menuReloading.setVisible(reloading);

    if (reloading) {
      btnRefresh.setVisibility(View.INVISIBLE);
      llContent.setVisibility(View.INVISIBLE);

      pbRefreshing.setVisibility(View.VISIBLE);
      rlSplashScreen.setVisibility(View.VISIBLE);

      _menuReloading.setActionView(R.layout.menu_progress);
    } else {
      pbRefreshing.setVisibility(View.INVISIBLE);
      rlSplashScreen.setVisibility(View.GONE);

      btnRefresh.setVisibility(View.VISIBLE);
      llContent.setVisibility(View.VISIBLE);

      _menuReload.setIcon(R.drawable.ic_action_refresh);
      _menuReloading.setActionView(null);

      View control = null;
      for (int i = 0; i < llContent.getChildCount(); i++) {
        control = llContent.getChildAt(i);
        control.setVisibility(View.VISIBLE);
      }
    }
  }
Ejemplo n.º 5
0
  @TargetApi(Build.VERSION_CODES.FROYO)
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.activity_channel, menu);

    searchItem = menu.findItem(R.id.menu_search);

    if (mViewPager == null) fullscreenButton = menu.findItem(R.id.menu_fullscreen);

    if (VERSION.SDK_INT >= 8) { // SearchManager supported by Froyo+.
      SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    } else {
      searchItem.setVisible(false);
    }

    mutedButton = menu.findItem(R.id.menu_mute_button);
    deafenedButton = menu.findItem(R.id.menu_deafen_button);

    if (mService != null && mService.getCurrentUser() != null) {
      updateMuteDeafenMenuItems(mService.isMuted(), mService.isDeafened());
    }

    return true;
  }
Ejemplo n.º 6
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getSupportMenuInflater().inflate(R.menu.weibo, menu);
   loveItem = menu.findItem(R.id.menu_favorite);
   if (status.isFavorited()) {
     loveItem.setIcon(R.drawable.rating_favorite_r);
   }
   loveItem.setVisible(false);
   return super.onCreateOptionsMenu(menu);
 }
 private void setEvernoteMenuEnabled(MenuItem item) {
   if (item != null) {
     boolean loggedIn = false;
     if (session != null) {
       loggedIn = session.isLoggedIn();
     }
     item.setEnabled(loggedIn);
     item.setVisible(loggedIn);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_logout:
        logOut();
        item.setVisible(false);
        break;
    }

    return true;
  }
Ejemplo n.º 9
0
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   // If the nav drawer is open, hide action items related to the content view
   boolean isDrawerOpen = ((BaseNavDrawerActivity) getActivity()).isDrawerOpen();
   MenuItem filter = menu.findItem(R.id.menu_action_shows_filter);
   filter.setVisible(!isDrawerOpen);
   filter.setIcon(
       mIsFilterFavorites || mIsFilterUnwatched || mIsFilterUpcoming || mIsFilterHidden
           ? R.drawable.ic_action_filter_selected
           : R.drawable.ic_action_filter);
 }
Ejemplo n.º 10
0
  @Override
  public void onCreateOptionsMenu(
      com.actionbarsherlock.view.Menu menu, com.actionbarsherlock.view.MenuInflater inflater) {
    // disable search menu item
    MenuItem search = menu.findItem(R.id.actionBar_chat);
    search.setVisible(false);

    inflater.inflate(R.menu.slide_bar, menu);

    super.onCreateOptionsMenu(menu, inflater);
  }
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    if (this.mDrawerLayout != null && this.mDrawerList != null) {
      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        item.setVisible(!mDrawerLayout.isDrawerOpen(mDrawerList));
      }
    }

    return super.onPrepareOptionsMenu(menu);
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.frag1act1, menu);
    com.actionbarsherlock.view.MenuItem menucart = menu.findItem(R.id.menu_cart);
    menucart.setVisible(true);
    /*
       menucart.setOnMenuItemClickListener(new OnMenuItemClickListener() {

    	@Override
    	public boolean onMenuItemClick(MenuItem arg0) {
    		Intent inten = new Intent (getActivity() , ShoppingCartActivity.class);
    		startActivity(inten);
    		return false;
    	}
    }); */

    SearchView searchView = new SearchView(getActivity());

    searchView.setQueryHint("Search Product");
    searchView.setOnQueryTextListener(
        new OnQueryTextListener() {

          @Override
          public boolean onQueryTextSubmit(String searchtext) {
            String text = searchtext.toString().toLowerCase(Locale.getDefault());
            if (text.length() <= 0) {
              t.setVisibility(View.INVISIBLE);
              listview.setVisibility(View.VISIBLE);
              adapter.filter(text);
            } else {
              adapter.filter(text);
              if (adapter == null || adapter.isEmpty()) {
                t.setVisibility(View.VISIBLE);
                listview.setVisibility(View.INVISIBLE);
              } else {
                t.setVisibility(View.INVISIBLE);
                listview.setVisibility(View.VISIBLE);
              }
            }
            return true;
          }

          @Override
          public boolean onQueryTextChange(String searchtext) {
            String text = searchtext.toString().toLowerCase(Locale.getDefault());
            if (text.length() <= 0) {
              t.setVisibility(View.INVISIBLE);
              listview.setVisibility(View.VISIBLE);
              adapter.filter(text);
            } else {
              adapter.filter(text);
              if (adapter == null || adapter.isEmpty()) {
                t.setVisibility(View.VISIBLE);
                listview.setVisibility(View.INVISIBLE);
              } else {
                t.setVisibility(View.INVISIBLE);
                listview.setVisibility(View.VISIBLE);
              }
            }
            return false;
          }
        });

    menu.add("Search Products")
        .setIcon(R.drawable.ic_action_search)
        .setActionView(searchView)
        .setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
  }
Ejemplo n.º 13
0
  @SuppressWarnings("UnusedDeclaration")
  public void onEventMainThread(SetUpActionBarEvent event) {
    if (mMenueSearch != null) mMenueSearch.setVisible(event.isSearchEnabled());

    if (mMenueRefresh != null) mMenueRefresh.setVisible(event.isRefreshEnabled());
  }
Ejemplo n.º 14
0
  /**
   * Hide menu items not appropriate for the current context.
   *
   * <p><strong>Note:</strong> Please adjust the comments in {@code
   * res/menu/message_list_option.xml} if you change the visibility of a menu item in this method.
   *
   * @param menu The {@link Menu} instance that should be modified. May be {@code null}; in that
   *     case the method does nothing and immediately returns.
   */
  private void configureMenu(Menu menu) {
    if (menu == null) {
      return;
    }

    // Set visibility of account/folder settings menu items
    if (mMessageListFragment == null) {
      menu.findItem(R.id.account_settings).setVisible(false);
      menu.findItem(R.id.folder_settings).setVisible(false);
    } else {
      menu.findItem(R.id.account_settings).setVisible(mMessageListFragment.isSingleAccountMode());
      menu.findItem(R.id.folder_settings).setVisible(mMessageListFragment.isSingleFolderMode());
    }

    /*
     * Set visibility of menu items related to the message view
     */

    if (mDisplayMode == DisplayMode.MESSAGE_LIST
        || mMessageViewFragment == null
        || !mMessageViewFragment.isInitialized()) {
      menu.findItem(R.id.next_message).setVisible(false);
      menu.findItem(R.id.previous_message).setVisible(false);
      menu.findItem(R.id.delete).setVisible(false);
      menu.findItem(R.id.single_message_options).setVisible(false);
      menu.findItem(R.id.refile).setVisible(false);
      menu.findItem(R.id.toggle_unread).setVisible(false);
      menu.findItem(R.id.select_text).setVisible(false);
      menu.findItem(R.id.toggle_message_view_theme).setVisible(false);
      menu.findItem(R.id.show_headers).setVisible(false);
      menu.findItem(R.id.hide_headers).setVisible(false);
    } else {
      // hide prev/next buttons in split mode
      if (mDisplayMode != DisplayMode.MESSAGE_VIEW) {
        menu.findItem(R.id.next_message).setVisible(false);
        menu.findItem(R.id.previous_message).setVisible(false);
      } else {
        MessageReference ref = mMessageViewFragment.getMessageReference();
        boolean initialized =
            (mMessageListFragment != null && mMessageListFragment.isLoadFinished());
        boolean canDoPrev = (initialized && !mMessageListFragment.isFirst(ref));
        boolean canDoNext = (initialized && !mMessageListFragment.isLast(ref));

        MenuItem prev = menu.findItem(R.id.previous_message);
        prev.setEnabled(canDoPrev);
        prev.getIcon().setAlpha(canDoPrev ? 255 : 127);

        MenuItem next = menu.findItem(R.id.next_message);
        next.setEnabled(canDoNext);
        next.getIcon().setAlpha(canDoNext ? 255 : 127);
      }

      MenuItem toggleTheme = menu.findItem(R.id.toggle_message_view_theme);
      if (K9.useFixedMessageViewTheme()) {
        toggleTheme.setVisible(false);
      } else {
        // Set title of menu item to switch to dark/light theme
        if (K9.getK9MessageViewTheme() == K9.Theme.DARK) {
          toggleTheme.setTitle(R.string.message_view_theme_action_light);
        } else {
          toggleTheme.setTitle(R.string.message_view_theme_action_dark);
        }
        toggleTheme.setVisible(true);
      }

      // Set title of menu item to toggle the read state of the currently displayed message
      if (mMessageViewFragment.isMessageRead()) {
        menu.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_unread_action);
      } else {
        menu.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_read_action);
      }

      menu.findItem(R.id.copy).setVisible(mMessageViewFragment.isCopyCapable());

      // Jellybean has built-in long press selection support
      menu.findItem(R.id.select_text).setVisible(Build.VERSION.SDK_INT < 16);

      if (mMessageViewFragment.isMoveCapable()) {
        menu.findItem(R.id.move).setVisible(true);
        menu.findItem(R.id.archive).setVisible(mMessageViewFragment.canMessageBeArchived());
        menu.findItem(R.id.spam).setVisible(mMessageViewFragment.canMessageBeMovedToSpam());
      } else {
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.archive).setVisible(false);
        menu.findItem(R.id.spam).setVisible(false);
      }

      if (mMessageViewFragment.allHeadersVisible()) {
        menu.findItem(R.id.show_headers).setVisible(false);
      } else {
        menu.findItem(R.id.hide_headers).setVisible(false);
      }
    }

    /*
     * Set visibility of menu items related to the message list
     */

    // Hide both search menu items by default and enable one when appropriate
    menu.findItem(R.id.search).setVisible(false);
    menu.findItem(R.id.search_remote).setVisible(false);

    if (mDisplayMode == DisplayMode.MESSAGE_VIEW
        || mMessageListFragment == null
        || !mMessageListFragment.isInitialized()) {
      menu.findItem(R.id.check_mail).setVisible(false);
      menu.findItem(R.id.set_sort).setVisible(false);
      menu.findItem(R.id.select_all).setVisible(false);
      menu.findItem(R.id.send_messages).setVisible(false);
      menu.findItem(R.id.expunge).setVisible(false);
    } else {
      menu.findItem(R.id.set_sort).setVisible(true);
      menu.findItem(R.id.select_all).setVisible(true);

      if (!mMessageListFragment.isSingleAccountMode()) {
        menu.findItem(R.id.expunge).setVisible(false);
        menu.findItem(R.id.check_mail).setVisible(false);
        menu.findItem(R.id.send_messages).setVisible(false);
      } else {
        menu.findItem(R.id.send_messages).setVisible(mMessageListFragment.isOutbox());

        if (mMessageListFragment.isRemoteFolder()) {
          menu.findItem(R.id.check_mail).setVisible(true);
          menu.findItem(R.id.expunge).setVisible(mMessageListFragment.isAccountExpungeCapable());
        } else {
          menu.findItem(R.id.check_mail).setVisible(false);
          menu.findItem(R.id.expunge).setVisible(false);
        }
      }

      // If this is an explicit local search, show the option to search on the server
      if (!mMessageListFragment.isRemoteSearch() && mMessageListFragment.isRemoteSearchAllowed()) {
        menu.findItem(R.id.search_remote).setVisible(true);
      } else if (!mMessageListFragment.isManualSearch()) {
        menu.findItem(R.id.search).setVisible(true);
      }
    }
  }