@Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu);
    MenuItem showHistory = menu.findItem(R.id.operationsButton);
    if (mShowingHistoryPanel) {
      showHistory.setTitle(R.string.hide_history_panel);
    } else {
      showHistory.setTitle(R.string.show_history_panel);
    }
    MenuItem showState = menu.findItem(R.id.showImageStateButton);
    if (mShowingImageStatePanel) {
      showState.setTitle(R.string.hide_imagestate_panel);
    } else {
      showState.setTitle(R.string.show_imagestate_panel);
    }
    mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
    mShareActionProvider.setShareIntent(getDefaultShareIntent());
    mShareActionProvider.setOnShareTargetSelectedListener(this);

    MenuItem undoItem = menu.findItem(R.id.undoButton);
    MenuItem redoItem = menu.findItem(R.id.redoButton);
    MenuItem resetItem = menu.findItem(R.id.resetHistoryButton);
    mImageShow.getHistory().setMenuItems(undoItem, redoItem, resetItem);
    return true;
  }
 public void setShareIntents(
     Intent sharePanoramaIntent,
     Intent shareIntent,
     ShareActionProvider.OnShareTargetSelectedListener onShareListener) {
   mSharePanoramaIntent = sharePanoramaIntent;
   if (mSharePanoramaActionProvider != null) {
     mSharePanoramaActionProvider.setShareIntent(sharePanoramaIntent);
   }
   mShareIntent = shareIntent;
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(shareIntent);
     mShareActionProvider.setOnShareTargetSelectedListener(onShareListener);
   }
 }
 @Override
 public void onResume() {
   super.onResume();
   if (mShareActionProvider != null) {
     mShareActionProvider.setOnShareTargetSelectedListener(this);
   }
 }
  public void createActionBarMenu(int menuRes, Menu menu) {
    mActivity.getMenuInflater().inflate(menuRes, menu);
    mActionBarMenu = menu;

    MenuItem item = menu.findItem(R.id.action_share_panorama);
    if (item != null) {
      mSharePanoramaActionProvider = (ShareActionProvider) item.getActionProvider();
      mSharePanoramaActionProvider.setShareHistoryFileName("panorama_share_history.xml");
      mSharePanoramaActionProvider.setShareIntent(mSharePanoramaIntent);
    }

    item = menu.findItem(R.id.action_share);
    if (item != null) {
      mShareActionProvider = (ShareActionProvider) item.getActionProvider();
      mShareActionProvider.setShareHistoryFileName("share_history.xml");
      mShareActionProvider.setShareIntent(mShareIntent);
    }
  }
Example #5
0
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.options, menu);

    // 搜索视窗,因为showAsAction="ifRoom",所以图三中出现了搜索按钮
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();

    // 分享视窗,因为showAsAction="never",所以只能在溢出菜单中才看见到
    ShareActionProvider mShareActionProvider =
        (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    mShareActionProvider.setShareIntent(shareIntent);

    // 设置视窗,MyActionProvider就是我们自定义的ActionProvider
    //		MyActionProvider myactionprovider = (MyActionProvider) menu.findItem(
    //				R.id.menu_setting).getActionProvider();
    return super.onCreateOptionsMenu(menu);
  };
Example #6
0
 private void setShareIntent() {
   Intent shareIntent = new Intent();
   shareIntent.setAction(Intent.ACTION_SEND);
   shareIntent.setType("message/rfc822");
   shareIntent.putExtra(Intent.EXTRA_SUBJECT, "UriBeacon Test Results");
   Spanned body = createTestResults();
   shareIntent.putExtra(Intent.EXTRA_TEXT, body);
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(shareIntent);
   }
 }
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {

    switch (item.getItemId()) {
      case R.id.bold:
        {
          Format.toggleStyleSpan(this.editText, Typeface.BOLD);
          editText.setModified(
              true); // apparently doesnt get set automatically by DroidWriterEditText's TextWatcher
          return true;
        }
      case R.id.italic:
        {
          Format.toggleStyleSpan(this.editText, Typeface.ITALIC);
          editText.setModified(true);
          return true;
        }
      case R.id.underline:
        {
          Format.toggleCharacterStyle(this.editText, UnderlineSpan.class);
          editText.setModified(true);
          return true;
        }
      case R.id.strikethrough:
        {
          Format.toggleCharacterStyle(this.editText, StrikethroughSpan.class);
          editText.setModified(true);
          return true;
        }
      case R.id.menu_item_share:
        {
          int selectionStart = editText.getSelectionStart();
          int selectionEnd = editText.getSelectionEnd();
          if (selectionStart > selectionEnd) {
            int tmp = selectionEnd;
            selectionEnd = selectionStart;
            selectionStart = tmp;
          }
          CharSequence selectedText = editText.getText().subSequence(selectionStart, selectionEnd);

          Intent sendIntent = new Intent();
          sendIntent.setAction(Intent.ACTION_SEND);
          sendIntent.putExtra(
              Intent.EXTRA_TEXT,
              selectedText.toString() /*deep copy*/); // sharing spanned string does not work here
          sendIntent.setType("text/plain");
          if (mShareActionProvider != null) mShareActionProvider.setShareIntent(sendIntent);
          return true;
        }
    }
    return false;
  }
 private void buildShareActionMenu() {
   Intent sharingIntent = new Intent(Intent.ACTION_SEND);
   sharingIntent.setType("text/plain");
   if (msg != null) {
     sharingIntent.putExtra(Intent.EXTRA_TEXT, msg.getText());
     PackageManager packageManager = getPackageManager();
     List<ResolveInfo> activities = packageManager.queryIntentActivities(sharingIntent, 0);
     boolean isIntentSafe = activities.size() > 0;
     if (isIntentSafe && mShareActionProvider != null) {
       mShareActionProvider.setShareIntent(sharingIntent);
     }
   }
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    /** Inflating the current activity's menu with res/menu/items.xml */
    getMenuInflater().inflate(R.menu.menu_main, menu);

    /** Getting the actionprovider associated with the menu item whose id is share */
    mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.share).getActionProvider();

    /** Setting a share intent */
    mShareActionProvider.setShareIntent(getDefaultShareIntent());

    return super.onCreateOptionsMenu(menu);
  }
 private void setShareIntent(Menu menu) {
   if (menu != null) {
     MenuItem item = menu.findItem(R.id.menu_item_share);
     Intent shareIntent = new Intent();
     shareIntent.setAction(Intent.ACTION_SEND);
     shareIntent.putExtra(Intent.EXTRA_TITLE, mTitle);
     shareIntent.putExtra(Intent.EXTRA_TEXT, getSharedContent());
     shareIntent.putExtra(Intent.EXTRA_ORIGINATING_URI, mUrl);
     shareIntent.setType("text/plain");
     mShareActionProvider = (ShareActionProvider) item.getActionProvider();
     if (mShareActionProvider != null) {
       mShareActionProvider.setShareIntent(shareIntent);
     }
   }
 }
 // This is the share menu
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.share_menu, menu);
   MenuItem item = menu.findItem(R.id.menu_item_share);
   mShareActionProvider = (ShareActionProvider) item.getActionProvider();
   // Create the share Intent
   String playStoreLink = " https://play.google.com/store/apps/details?id=" + getPackageName();
   String yourShareText = getString(R.string.share_this) + playStoreLink;
   Intent shareIntent =
       ShareCompat.IntentBuilder.from(this)
           .setType("text/plain")
           .setText(yourShareText)
           .getIntent();
   // Set the share Intent
   mShareActionProvider.setShareIntent(shareIntent);
   return true;
 }
Example #12
0
 private void setShareIntent() {
   Intent intent = new Intent(Intent.ACTION_SEND);
   intent.setType("text/plain");
   intent.putExtra(Intent.EXTRA_TEXT, "There is no law that prohibits a woman from being a Bro.");
   mShareActionProvider.setShareIntent(intent);
 }