Example #1
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);
  }
 @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);
 }
 /** {@inheritDoc} */
 @Override
 public boolean onCreateOptionsMenu(final Menu menu) {
   this.getMenuInflater().inflate(R.menu.conversationlist, menu);
   if (prefsNoAds) {
     menu.removeItem(R.id.item_donate);
   }
   return true;
 }
Example #4
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);
   }
 }
Example #5
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);
   }
 }
  // Menu stuff
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(R.string.add_account)
        .setIcon(android.R.drawable.ic_menu_add)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {
                startActivityForResult(
                    new Intent(getActivity(), WizardChooser.class), CHOOSE_WIZARD);
                return true;
              }
            })
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(R.string.reorder)
        .setIcon(android.R.drawable.ic_menu_sort_by_size)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {
                AccountsEditListAdapter ad = (AccountsEditListAdapter) getListAdapter();
                ad.toggleDraggable();
                return true;
              }
            })
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    menu.add(R.string.backup_restore)
        .setIcon(android.R.drawable.ic_menu_save)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {

                // Populate choice list
                List<String> items = new ArrayList<String>();
                items.add(getResources().getString(R.string.backup));
                final File backupDir = PreferencesWrapper.getConfigFolder(getActivity());
                if (backupDir != null) {
                  String[] filesNames = backupDir.list();
                  for (String fileName : filesNames) {
                    items.add(fileName);
                  }
                }

                final String[] fItems = (String[]) items.toArray(new String[0]);
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.backup_restore);
                builder.setItems(
                    fItems,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int item) {
                        if (item == 0) {
                          SipProfileJson.saveSipConfiguration(getActivity());
                        } else {
                          File fileToRestore = new File(backupDir + File.separator + fItems[item]);
                          SipProfileJson.restoreSipConfiguration(getActivity(), fileToRestore);
                        }
                      }
                    });
                builder.setCancelable(true);
                AlertDialog backupDialog = builder.create();
                backupDialog.show();
                return true;
              }
            });

    super.onCreateOptionsMenu(menu, inflater);
  }