예제 #1
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Shortcuts that work no matter what is selected

    if (
    // TODO - when we move to android 2.0, uncomment this.
    // android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&

    keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && K9.manageBack()) {
      // Take care of calling this method on earlier versions of
      // the platform where it doesn't exist.
      onBackPressed();
      return true;
    }

    switch (keyCode) {
      case KeyEvent.KEYCODE_Q:
        // case KeyEvent.KEYCODE_BACK:
        {
          onAccounts();
          return true;
        }

      case KeyEvent.KEYCODE_S:
        {
          onEditAccount();
          return true;
        }

      case KeyEvent.KEYCODE_H:
        {
          Toast toast = Toast.makeText(this, R.string.folder_list_help_key, Toast.LENGTH_LONG);
          toast.show();
          return true;
        }

      case KeyEvent.KEYCODE_1:
        {
          setDisplayMode(FolderMode.FIRST_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_2:
        {
          setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_3:
        {
          setDisplayMode(FolderMode.NOT_SECOND_CLASS);
          return true;
        }
      case KeyEvent.KEYCODE_4:
        {
          setDisplayMode(FolderMode.ALL);
          return true;
        }
    } // switch

    return super.onKeyDown(keyCode, event);
  } // onKeyDown
예제 #2
0
 @Override
 public void onBackPressed() {
   // This will be called either automatically for you on 2.0
   // or later, or by the code above on earlier versions of the
   // platform.
   if (K9.manageBack()) {
     onAccounts();
   } else {
     // TODO - when we move to android 2.0, uncomment this instead.
     // super.onBackPressed()
     finish();
   }
 }
예제 #3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.compose:
        MessageCompose.actionCompose(this, mAccount);

        return true;

      case R.id.check_mail:
        MessagingController.getInstance(getApplication())
            .checkMail(this, mAccount, true, true, mAdapter.mListener);

        return true;

      case R.id.send_messages:
        MessagingController.getInstance(getApplication()).sendPendingMessages(mAccount, null);
        return true;
      case R.id.accounts:
        onAccounts();

        return true;

      case R.id.list_folders:
        onRefresh(REFRESH_REMOTE);

        return true;

      case R.id.account_settings:
        onEditAccount();

        return true;

      case R.id.app_settings:
        onEditPrefs();

        return true;

      case R.id.empty_trash:
        onEmptyTrash(mAccount);

        return true;

      case R.id.compact:
        onCompact(mAccount);

        return true;

      case R.id.export:
        onExport(mAccount);
        return true;

      case R.id.export_all:
        onExport(null);
        return true;

      case R.id.display_1st_class:
        {
          setDisplayMode(FolderMode.FIRST_CLASS);
          return true;
        }
      case R.id.display_1st_and_2nd_class:
        {
          setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS);
          return true;
        }
      case R.id.display_not_second_class:
        {
          setDisplayMode(FolderMode.NOT_SECOND_CLASS);
          return true;
        }
      case R.id.display_all:
        {
          setDisplayMode(FolderMode.ALL);
          return true;
        }
      default:
        return super.onOptionsItemSelected(item);
    }
  }