Exemple #1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.repo_menu, menu);

    if (Gh4Application.THEME != R.style.LightTheme) {
      menu.getItem(0).setIcon(R.drawable.navigation_refresh_dark);
    }

    MenuItem watchAction = menu.getItem(1);
    if (isAuthorized()) {
      if (!isFinishLoadingWatching) {
        watchAction.setActionView(R.layout.ab_loading);
        watchAction.expandActionView();
      } else {
        if (isWatching) {
          watchAction.setTitle(R.string.repo_unwatch_action);
        } else {
          watchAction.setTitle(R.string.repo_watch_action);
        }
      }
    } else {
      menu.removeItem(R.id.watch);
    }

    return super.onPrepareOptionsMenu(menu);
  }
Exemple #2
0
  private void configureMenu(Menu menu) {
    // first run displayMessage() gets called before onCreateOptionMenu()
    if (menu == null) {
      return;
    }

    // enable them all
    menu.findItem(R.id.copy).setVisible(true);
    menu.findItem(R.id.move).setVisible(true);
    menu.findItem(R.id.archive).setVisible(true);
    menu.findItem(R.id.spam).setVisible(true);

    mToggleMessageViewMenu = menu.findItem(R.id.toggle_message_view_theme);
    if (K9.getK9MessageViewTheme() == K9.THEME_DARK) {
      mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_light);
    } else {
      mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_dark);
    }

    toggleActionsState(menu, true);

    updateUnreadToggleTitle();

    // comply with the setting
    if (!mAccount.getEnableMoveButtons()) {
      menu.findItem(R.id.move).setVisible(false);
      menu.findItem(R.id.archive).setVisible(false);
      menu.findItem(R.id.spam).setVisible(false);
    } else {
      // check message, folder capability
      if (!mController.isCopyCapable(mAccount)) {
        menu.findItem(R.id.copy).setVisible(false);
      }

      if (mController.isMoveCapable(mAccount)) {
        menu.findItem(R.id.move).setVisible(true);

        menu.findItem(R.id.archive)
            .setVisible(
                !mMessageReference.folderName.equals(mAccount.getArchiveFolderName())
                    && mAccount.hasArchiveFolder());

        menu.findItem(R.id.spam)
            .setVisible(
                !mMessageReference.folderName.equals(mAccount.getSpamFolderName())
                    && mAccount.hasSpamFolder());
      } else {
        menu.findItem(R.id.copy).setVisible(false);
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.archive).setVisible(false);
        menu.findItem(R.id.spam).setVisible(false);
      }
    }
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getSupportMenuInflater().inflate(R.menu.activity_main, menu);
   itemMenu = menu.findItem(R.id.item1);
   if (sesion.SesionActiva()) {
     itemMenu.setTitle("Salir de sesion");
   } else {
     itemMenu.setTitle("Iniciar sesion");
   }
   return super.onCreateOptionsMenu(menu);
 }
 public void toggleSatelliteView(MenuItem item) {
   int mapType = googleMap.getMapType();
   if (mapType == MAP_TYPE_NORMAL) {
     setSatelliteView(true);
     item.setTitle("Map view");
     item.setIcon(R.drawable.location_map);
   } else {
     setSatelliteView(false);
     item.setTitle("Satellite view");
     item.setIcon(R.drawable.da_layer_satellite);
   }
 }
Exemple #5
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.global, menu);

    MenuItem menuRestart = menu.findItem(R.id.menuRestart);

    menuRestart.setOnMenuItemClickListener(
        new OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {
            BrandManager.restart();
            return false;
          }
        });

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    menuGuessed = menu.findItem(R.id.menuGuessed);
    menuScore = menu.findItem(R.id.menuScore);
    updateScore();

    int total = BrandManager.size();
    int totalGuessed = BrandManager.sizeGuessed();

    menuGuessed.setTitle("Guessed: " + String.valueOf(totalGuessed) + "/" + String.valueOf(total));
    return true;
  }
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == 0) {
     if (resultCode == RESULT_OK) {
       itemMenu.setTitle(data.getStringExtra("result"));
     }
   }
 }
Exemple #7
0
  public void guessed() {
    BrandManager.guessed(brandIndex);
    brandName.setVisibility(View.VISIBLE);
    variants.setVisibility(View.GONE);
    setTitle(res.getString(R.string.guessed));

    if (BrandManager.allGuessed()) {
      nextButton.setVisibility(View.GONE);
      restartButton.setVisibility(View.VISIBLE);
    }

    if (menuGuessed != null) {
      int total = BrandManager.size();
      int totalGuessed = BrandManager.sizeGuessed();
      menuGuessed.setTitle("Guessed " + String.valueOf(totalGuessed) + "/" + String.valueOf(total));
    }
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.item1:
       if (sesion.SesionActiva()) {
         Toast.makeText(this, sesion.terminarSesion(), Toast.LENGTH_LONG).show();
         item.setTitle("Iniciar sesion");
       } else {
         Intent intentLog = new Intent(this, LoginActivity.class);
         startActivityForResult(intentLog, 0);
         itemMenu = item;
       }
       return true;
     case R.id.item3:
       this.finish();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Exemple #9
0
  public void handleShowDetails(boolean showDetails, MenuItem item) {
    currentFragment.setShowDetails(showDetails);

    item.setTitle(showDetails ? R.string.hide_details : R.string.show_details);
  }
Exemple #10
0
  // メニューを選んだ時の操作
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    // ツイッターログイン
    if (item.getItemId() == tw_login_menu_id) {
      // ログアウト
      // 認証データをカラに
      pref = getSherlockActivity().getSharedPreferences("t4jdata", Context.MODE_PRIVATE);
      editor = pref.edit();
      editor.putString("token", "");
      editor.putString("token_secret", "");
      editor.putString("screen_name", "");
      checkLoginTwitter();
    }

    // IPPログイン
    if (item.getItemId() == ipp_login_menu_id) {
      Intent intent = new Intent(getSherlockActivity(), IPPLoginActivity.class);
      startActivityForResult(intent, MainActivity.REQUEST_IPP_LOGIN);
      // スクリーンネーム消す
      // TextView result = (TextView) getSherlockActivity().findViewById(R.id.screen_name); //debug
      // result.setText("");
    }

    // リロード
    if (item.getItemId() == reload_menu_id) {
      showCommentList(target_year, target_month, 0, near);
    }

    // 追加読み込み
    if (item.getItemId() == addget_menu_id) {

      long until = last_timestamp;
      try {
        waitBar.setVisibility(View.VISIBLE);
      } catch (NullPointerException e) {

      }
      showCommentList(target_year, target_month, until, near);
    }

    // ストレス変更
    /*

    if(item.getItemId() == stress_change_menu_id){

    	//メインアクティビティに教えてやる
    	 Intent intent = new Intent(getSherlockActivity(), MainActivity.class);
    	 intent.putExtra("stress_now", MainActivity.RELAXED); //このフラグメントは密な方なので、ゆるい方にしか変わらない
    	 startActivity(intent);

    }
    */

    // 近くに限る
    if (item.getItemId() == near_menu_id) {
      if (near == 0) {
        near = 1;
        showCommentList(target_year, target_month, 0, near);
        nearMenu.setTitle(R.string.near_cancel);
      } else {
        near = 0;
        showCommentList(target_year, target_month, 0, near);
        nearMenu.setTitle(R.string.near);
      }
    }

    return false;
  }
Exemple #11
0
 public void updateScore() {
   if (menuScore != null) {
     menuScore.setTitle("Score: " + String.valueOf(BrandManager.getScore()));
   }
 }
Exemple #12
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);
      }
    }
  }