/**
   * Shows "call via" menu allowing user to selected from multiple providers.
   *
   * @param context the android context
   * @param v the View that will contain the popup menu.
   * @param destination target callee name.
   */
  private static void showCallViaMenu(final Context context, View v, final String destination) {
    PopupMenu popup = new PopupMenu(context, v);

    Menu menu = popup.getMenu();

    Iterator<ProtocolProviderService> registeredProviders =
        AccountUtils.getRegisteredProviders().iterator();

    while (registeredProviders.hasNext()) {
      final ProtocolProviderService provider = registeredProviders.next();
      String accountAddress = provider.getAccountID().getAccountAddress();

      MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress);

      menuItem.setOnMenuItemClickListener(
          new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
              createCall(context, destination, provider);

              return false;
            }
          });
    }

    popup.show();
  }
  /** Called when one of the menu items is selected. */
  public boolean onOptionsItemSelected(MenuItem item) {

    int itemId = item.getItemId();
    Utilities.LogInfo("Option item selected - " + String.valueOf(item.getTitle()));

    switch (itemId) {
      case R.id.mnuSettings:
        Intent settingsActivity = new Intent(getApplicationContext(), GpsSettingsActivity.class);
        startActivity(settingsActivity);
        break;
      case R.id.mnuOSM:
        UploadToOpenStreetMap();
        break;
      case R.id.mnuDropBox:
        UploadToDropBox();
        break;
      case R.id.mnuAnnotate:
        Annotate();
        break;
      case R.id.mnuShare:
        Share();
        break;
      case R.id.mnuEmailnow:
        EmailNow();
        break;
      case R.id.mnuExit:
        loggingService.StopLogging();
        loggingService.stopSelf();
        finish();
        break;
    }
    return false;
  }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
   final ListView view = (ListView) getTabHost().getCurrentView();
   final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position);
   switch (item.getItemId()) {
     case OPEN_ITEM_ID:
       gotoBookmark(bookmark);
       return true;
     case EDIT_ITEM_ID:
       final Intent intent = new Intent(this, BookmarkEditActivity.class);
       OrientationUtil.startActivityForResult(this, intent, 1);
       // TODO: implement
       return true;
     case DELETE_ITEM_ID:
       myCollection.deleteBookmark(bookmark);
       if (myThisBookAdapter != null) {
         myThisBookAdapter.remove(bookmark);
       }
       if (myAllBooksAdapter != null) {
         myAllBooksAdapter.remove(bookmark);
       }
       if (mySearchResultsAdapter != null) {
         mySearchResultsAdapter.remove(bookmark);
       }
       return true;
   }
   return super.onContextItemSelected(item);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   final MenuItem item =
       menu.add(0, 1, Menu.NONE, myResource.getResource("menu").getResource("search").getValue());
   item.setOnMenuItemClickListener(this);
   item.setIcon(R.drawable.ic_menu_search);
   return true;
 }
  public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 1:
        mBtn.setTextColor(Color.RED);
        return true;
      case 2:
        mBtn.setTextColor(Color.GREEN);
        return true;
      case 3:
        mBtn.setTextColor(Color.BLUE);
        return true;
      case 4:
        Toast.makeText(this, "번역했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 5:
        Toast.makeText(this, "필기 인식했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 100:
        Toast.makeText(this, "회전했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
      case 101:
        Toast.makeText(this, "크기 변경 했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
    }

    return true;
  }
 public boolean onMenuItemClick(MenuItem item) {
   switch (item.getItemId()) {
     case 1:
       return onSearchRequested();
     default:
       return true;
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.contactMenu:
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);
        break;
    }
    return super.onOptionsItemSelected(item);
  }
Exemple #8
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.set_menu_save:
       save();
       return true;
     case R.id.set_menu_return:
       Toast.makeText(getApplicationContext(), "操作无效。", Toast.LENGTH_SHORT).show();
       return true;
   }
   return (super.onOptionsItemSelected(item));
 }
Exemple #9
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Exemple #10
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected: itemId: " + item.getItemId());

    switch (item.getItemId()) {
      case R.id.menu_clear:
        Log.d(TAG, "onOptionsItemSelected: menu_clear");
        clear();
        break;

      case R.id.menu_help:
        Log.d(TAG, "onOptionsItemSelected: menu_help");
        startActivity(new Intent(Intent.ACTION_VIEW, null, this, Help.class));
        break;

      case R.id.menu_about:
        Log.d(TAG, "onOptionsItemSelected: menu_about");
        Messages.about(this);
        break;
    }

    return super.onOptionsItemSelected(item);
  }
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
       /**
        * case R.id.hash_change_item:
        *
        * <p>return true;
        */
     case R.id.about:
       Intent about = new Intent("com.tomasmichalkevic.md5check.ABOUTME");
       startActivity(about);
       return true;
     default:
       return false;
   }
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.menu_connect:
       mBluetoothLeService.connect(mDeviceAddress);
       return true;
     case R.id.menu_disconnect:
       mBluetoothLeService.disconnect();
       return true;
     case android.R.id.home:
       onBackPressed();
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
      case R.id.mnu_exit:
        if (!isTaskRunning) finish();
        else
          Toast.makeText(RssReaderActivity.this, R.string.rss_keep_updating, Toast.LENGTH_SHORT)
              .show();
        break;
      case R.id.mnu_about:
        break;
      default:
        break;
    }
    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.loader_menu_set_user_id:
        {
          showUserHashDialog();
          return true;
        }

      case R.id.loader_menu_refresh_map_list:
        {
          refreshMapList();
          return true;
        }

      default:
        return super.onOptionsItemSelected(item);
    }
  }
  // code which handles the action for each menu item
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.settings:
        {
          Intent preferences_intent = new Intent();
          preferences_intent.setComponent(
              new ComponentName(download_photos.this, preferences.class));
          preferences_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplicationContext().startActivity(preferences_intent);

          return true;
        }
      case R.id.logout:
        {
          try {
            download_photos.this.facebook.logout(getApplicationContext());
          } catch (IOException e) {
            e.printStackTrace();
          }

          mPrefs = getSharedPreferences("COMMON", MODE_PRIVATE);

          SharedPreferences.Editor editor = mPrefs.edit();
          editor.putString("access_token", null);
          editor.putLong("access_expires", 0);
          editor.putBoolean("logout", true);
          editor.commit();
          finish();
          return true;
        }
      case R.id.about:
        {
          // shows our customized about dialog
          AboutDialog about = new AboutDialog(this);

          about.show();
          return true;
        }
        // lets deal with default case
      default:
        return super.onOptionsItemSelected(item);
    }
  }