@Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   MenuItem item = menu.add(Menu.NONE, MENU_DISCARD, MENU_DISCARD, R.string.rate_offline_discard);
   item.setIcon(R.drawable.ic_action_discard);
   item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
   super.onCreateOptionsMenu(menu, inflater);
 }
Example #2
0
 protected void addMenuItem(Menu menu, int title, int imageRes, int id, boolean showAsAction) {
   AstridActivity activity = (AstridActivity) getActivity();
   if ((activity.getFragmentLayout() != AstridActivity.LAYOUT_SINGLE && showAsAction)
       || !(activity instanceof TaskListActivity)) {
     MenuItem item = menu.add(Menu.NONE, id, Menu.NONE, title);
     item.setIcon(imageRes);
     if (activity instanceof TaskListActivity)
       item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
   } else {
     ((TaskListActivity) activity).getMainMenuPopover().addMenuItem(title, imageRes, id);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      finish();
      return true;

    } else if (item.getItemId() == R.id.menu_comment) {
      goToAddComment(checkinId);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
Example #4
0
 protected void addMenuItem(
     Menu menu, CharSequence title, Drawable image, Intent customIntent, int id) {
   Activity activity = getActivity();
   if (activity instanceof TaskListActivity) {
     ((TaskListActivity) activity)
         .getMainMenuPopover()
         .addMenuItem(title, image, customIntent, id);
   } else {
     MenuItem item = menu.add(Menu.NONE, id, Menu.NONE, title);
     item.setIcon(image);
     item.setIntent(customIntent);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      showDialog();
      return true;

    } else if (item.getItemId() == R.id.menu_send) {
      validateReports();
      return true;
    } else if (item.getItemId() == R.id.menu_clear) {
      showDialog(DIALOG_SHOW_PROMPT);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
Example #6
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (weChatUtils.getIWXAPI().isWXAppInstalled()) {
      inflater.inflate(R.menu.main_wechat, menu);
    } else {
      inflater.inflate(R.menu.main, menu);
    }

    MenuItem shareItem = menu.findItem(R.id.action_share);
    android.support.v4.view.ActionProvider actionProvider =
        MenuItemCompat.getActionProvider(shareItem);
    if (null != actionProvider && actionProvider instanceof ShareActionProvider) {
      mShareActionProvider.setShareHistoryFileName(
          ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
      // mShareActionProvider.setShareIntent(Utils.getShareRawIntent(this));

      mShareActionProvider.setOnShareTargetSelectedListener(
          new ShareActionProvider.OnShareTargetSelectedListener() {
            @Override
            public boolean onShareTargetSelected(
                ShareActionProvider shareActionProvider, Intent intent) {
              updateShareIntent();
              return false;
            }
          });
      updateShareIntent();

      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == R.id.action_share) {
          View itemChooser = MenuItemCompat.getActionView(item);
          if (itemChooser != null) {
            itemChooser.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    EFLogger.i(TAG, "onClick");
                    ScreenshotUtils.shotBitmap(MainActivity.this, shareFileName);
                  }
                });
          }
        }
      }
    }

    return super.onCreateOptionsMenu(menu);
  }
Example #7
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
      return true;
    }
    // Handle action buttons
    switch (item.getItemId()) {
      case R.id.action_share:
        //                updateShareIntent();
        showShare();
        return true;

      case R.id.action_share_wechat:
        //                updateShareIntent();
        showShareWeChat();
        return true;
        //            case R.id.action_about:
        //                showAbout();
        //                return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
Example #8
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.subjects:
        Intent intentsubjects = new Intent(this, SubjectList.class);
        startActivity(intentsubjects);
        break;
      case R.id.gotoday:
        showDialog(DATE_DIALOG_ID);
        break;
      case R.id.timetable:
        Intent openTimetable = new Intent(this, WeekTimetable.class);
        startActivity(openTimetable);
        break;
      case R.id.examlist:
        Intent openExamList = new Intent(this, ExamList.class);
        startActivity(openExamList);
        break;
      case R.id.settings:
        Intent openSettings = new Intent(this, Settings.class);
        startActivity(openSettings);
        break;
    }

    return super.onOptionsItemSelected(item);
  }
 public boolean onOptionsItemSelected(MenuItem item) {
   // Handle item selection
   switch (item.getItemId()) {
     case R.id.menu_shortcut:
       shortcutAlert();
       return true;
     case R.id.menu_favs:
       if (UiUtils.isProVersion()) {
         addFavorite();
       } else {
         final AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
         alertDialog.setTitle("Pro Version");
         alertDialog.setMessage("Must buy Pro Version to use this feature!");
         alertDialog.setButton(
             "Cancel",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int which) {
                 alertDialog.dismiss();
                 return;
               }
             });
         alertDialog.show();
       }
       return true;
     default:
       return true;
   }
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    final SipProfile account = profileFromContextMenuInfo(item.getMenuInfo());
    if (account == null) {
      // For some reason the requested item isn't available, do nothing
      return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
      case MENU_ITEM_DELETE:
        {
          getActivity()
              .getContentResolver()
              .delete(
                  ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id),
                  null,
                  null);
          return true;
        }
      case MENU_ITEM_MODIFY:
        {
          showDetails(account.id, account.wizard);
          return true;
        }
      case MENU_ITEM_ACTIVATE:
        {
          ContentValues cv = new ContentValues();
          cv.put(SipProfile.FIELD_ACTIVE, !account.active);
          getActivity()
              .getContentResolver()
              .update(
                  ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id),
                  cv,
                  null,
                  null);
          return true;
        }
      case MENU_ITEM_WIZARD:
        {
          Intent it = new Intent(getActivity(), WizardChooser.class);
          it.putExtra(Intent.EXTRA_UID, account.id);
          startActivityForResult(it, CHANGE_WIZARD);
          return true;
        }
    }
    return super.onContextItemSelected(item);
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == Compatibility.getHomeMenuId()) {
      finish();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
 /** {@inheritDoc} */
 @Override
 public final boolean onOptionsItemSelected(final MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       this.finish();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Example #13
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       finish();
       return true;
     default:
       return mEditFragment.onOptionsItemSelected(item);
   }
 }
Example #14
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
      finish();
      return true;
    } else if (item.getItemId() == R.id.menu_forward) {

      if (listCheckin != null) {
        position++;
        if (!(position > (listCheckin.size() - 1))) {
          initCheckin(position);
          view.goNext();
        } else {
          position = listCheckin.size() - 1;
        }
      }
      return true;

    } else if (item.getItemId() == R.id.menu_backward) {

      if (listCheckin != null) {
        position--;
        if ((position < (listCheckin.size() - 1)) && (position != -1)) {
          initCheckin(position);
          view.goPrevious();
        } else {
          position = 0;
        }
      }
      return true;

    } else if (item.getItemId() == R.id.menu_comment) {
      Intent i = new Intent(ViewCheckinActivity.this, AddCommentActivity.class);

      i.putExtra("checkinid", checkinId);
      startActivityForResult(i, 0);
      overridePendingTransition(R.anim.home_enter, R.anim.home_exit);
    }

    return super.onOptionsItemSelected(item);
  }
Example #15
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.options_menu_list_places_insert:
       {
         createPlace();
         return true;
       }
     default:
       return super.onOptionsItemSelected(item);
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.clear_map) {
      createDialog(DIALOG_CLEAR_DEPLOYMENT);
      return true;
    } else if (item.getItemId() == R.id.menu_find) {
      createDialog(DIALOG_DISTANCE);
      return true;
    } else if (item.getItemId() == R.id.menu_add) {
      edit = false;
      createDialog(DIALOG_ADD_DEPLOYMENT);
      return true;
    } else if (item.getItemId() == R.id.app_settings) {
      startActivity(new Intent(this, Settings.class));
      setResult(RESULT_OK);
      return true;
    } else if (item.getItemId() == R.id.app_about) {
      startActivity(new Intent(this, AboutActivity.class));
      setResult(RESULT_OK);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
 /** {@inheritDoc} */
 @Override
 public boolean onOptionsItemSelected(final MenuItem item) {
   switch (item.getItemId()) {
     case R.id.item_compose:
       final Intent i = getComposeIntent(this, null);
       try {
         this.startActivity(i);
       } catch (ActivityNotFoundException e) {
         Log.e(TAG, "error launching intent: " + i.getAction() + ", " + i.getData());
         Toast.makeText(
                 this,
                 "error launching messaging app!\n" + "Please contact the developer.",
                 Toast.LENGTH_LONG)
             .show();
       }
       return true;
     case R.id.item_settings: // start settings activity
       if (Utils.isApi(Build.VERSION_CODES.HONEYCOMB)) {
         this.startActivity(
             new Intent(
                 this, // .
                 Preferences11Activity.class));
       } else {
         this.startActivity(new Intent(this, PreferencesActivity.class));
       }
       return true;
     case R.id.item_donate:
       DonationHelper.startDonationActivity(this, true);
       return true;
     case R.id.item_delete_all_threads:
       deleteMessages(
           this,
           Uri.parse("content://sms/"),
           R.string.delete_threads_,
           R.string.delete_threads_question,
           null);
       return true;
     case R.id.item_mark_all_read:
       markRead(this, Uri.parse("content://sms/"), 1);
       markRead(this, Uri.parse("content://mms/"), 1);
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
 /**
  * @author aosobov Called when an item is selected from the options menu
  * @param item the menu item selected
  */
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.help) {
     // inflate the help dialog from xml and display it
     AlertDialog.Builder builder = new AlertDialog.Builder(this);
     builder
         .setTitle("Help and Instructions")
         .setCancelable(false)
         .setPositiveButton(
             "Ok",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                 dialog.cancel();
               }
             });
     builder.setView(LayoutInflater.from(this).inflate(R.menu.help_dialog, null));
     AlertDialog alert = builder.create();
     alert.show();
   }
   return true;
 }
Example #19
0
  @Override
  public boolean onOptionsItemSelected(final MenuItem item) {
    Intent intent;
    long itemId;

    if (!isCurrentTaskListFragment()) return false;

    // handle my own menus
    if (handleOptionsMenuItemSelected(item.getItemId(), item.getIntent())) return true;

    switch (item.getItemId()) {
        // --- context menu items

      case CONTEXT_MENU_BROADCAST_INTENT_ID:
        {
          intent = item.getIntent();
          getActivity().sendBroadcast(intent);
          return true;
        }
      case CONTEXT_MENU_EDIT_TASK_ID:
        {
          itemId = item.getGroupId();
          mListener.onTaskListItemClicked(itemId);
          return true;
        }
      case CONTEXT_MENU_COPY_TASK_ID:
        {
          itemId = item.getGroupId();
          duplicateTask(itemId);
          return true;
        }
      case CONTEXT_MENU_DELETE_TASK_ID:
        {
          itemId = item.getGroupId();
          Task task = new Task();
          task.setId(itemId);
          deleteTask(task);
          return true;
        }
      case CONTEXT_MENU_UNDELETE_TASK_ID:
        {
          itemId = item.getGroupId();
          Task task = new Task();
          task.setId(itemId);
          task.setValue(Task.DELETION_DATE, 0L);
          taskService.save(task);
          loadTaskListContent(true);
          return true;
        }
      case CONTEXT_MENU_PURGE_TASK_ID:
        {
          itemId = item.getGroupId();
          Task task = new Task();
          task.setId(itemId);
          TimerPlugin.updateTimer(getActivity(), task, false);
          taskService.purge(itemId);
          loadTaskListContent(true);
          return true;
        }
      default:
        {
          if (item.getItemId() < CONTEXT_MENU_PLUGIN_ID_FIRST) return false;
          if (item.getItemId() - CONTEXT_MENU_PLUGIN_ID_FIRST >= contextItemExposers.length)
            return false;

          AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) item.getMenuInfo();
          Task task = ((ViewHolder) adapterInfo.targetView.getTag()).task;
          contextItemExposers[item.getItemId() - CONTEXT_MENU_PLUGIN_ID_FIRST].invoke(task);

          return true;
        }
    }
  }