Exemplo n.º 1
0
 public void onPrepareSubMenu(SubMenu subMenu) {
   int i;
   subMenu.clear();
   ActivityChooserModel dataModel =
       ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
   PackageManager packageManager = this.mContext.getPackageManager();
   int expandedActivityCount = dataModel.getActivityCount();
   int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
   for (i = 0; i < collapsedActivityCount; i++) {
     ResolveInfo activity = dataModel.getActivity(i);
     subMenu
         .add(0, i, i, activity.loadLabel(packageManager))
         .setIcon(activity.loadIcon(packageManager))
         .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
   }
   if (collapsedActivityCount < expandedActivityCount) {
     SubMenu expandedSubMenu =
         subMenu.addSubMenu(
             0,
             collapsedActivityCount,
             collapsedActivityCount,
             this.mContext.getString(C0103R.string.abc_activity_chooser_view_see_all));
     for (i = 0; i < expandedActivityCount; i++) {
       activity = dataModel.getActivity(i);
       expandedSubMenu
           .add(0, i, i, activity.loadLabel(packageManager))
           .setIcon(activity.loadIcon(packageManager))
           .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
     }
   }
 }
 /**
  * Sets an intent with information about the share action. Here is a sample for constructing a
  * share intent:
  *
  * <p>
  *
  * <pre>
  * <code>
  *  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  *  shareIntent.setType("image/*");
  *  Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
  *  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
  * </pre>
  * </code>
  *
  * @param shareIntent The share intent.
  * @see Intent#ACTION_SEND
  * @see Intent#ACTION_SEND_MULTIPLE
  */
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2014-09-18 21:46:52.216 -0400",
     hash_original_method = "0DAF31F3B630D54C36D98C14F5BC8D8F",
     hash_generated_method = "CC784081647578CB91B85D7C5DF7179C")
 public void setShareIntent(Intent shareIntent) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
   dataModel.setIntent(shareIntent);
 }
 @DSSafe(DSCat.SAFE_LIST)
 @Override
 public boolean onMenuItemClick(MenuItem item) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
   final int itemId = item.getItemId();
   Intent launchIntent = dataModel.chooseActivity(itemId);
   if (launchIntent != null) {
     launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
     mContext.startActivity(launchIntent);
   }
   return true;
 }
  /** {@inheritDoc} */
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2014-09-18 21:46:52.206 -0400",
      hash_original_method = "1BC9B35CED3034C73A3301B7F5D599F4",
      hash_generated_method = "4FE3EAC5A4FBA931A0EB238AB5D7D2F5")
  @Override
  public View onCreateActionView() {
    // Create the view and set its data model.
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    ActivityChooserView activityChooserView = new ActivityChooserView(mContext);
    activityChooserView.setActivityChooserModel(dataModel);

    // Lookup and set the expand action icon.
    TypedValue outTypedValue = new TypedValue();
    mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true);
    Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId);
    activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
    activityChooserView.setProvider(this);

    // Set content description.
    activityChooserView.setDefaultActionButtonContentDescription(
        R.string.abc_shareactionprovider_share_with_application);
    activityChooserView.setExpandActivityOverflowButtonContentDescription(
        R.string.abc_shareactionprovider_share_with);

    return activityChooserView;
  }
 /**
  * Set the activity chooser policy of the model backed by the current share history file if needed
  * which is if there is a registered callback.
  */
 @DSSafe(DSCat.SAFE_LIST)
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2014-09-18 21:46:52.224 -0400",
     hash_original_method = "344268FF5DC4DDF2FCAEC43573B8D180",
     hash_generated_method = "58ADB291D16E488FEC9DB54F6A735676")
 private void setActivityChooserPolicyIfNeeded() {
   if (mOnShareTargetSelectedListener == null) {
     return;
   }
   if (mOnChooseActivityListener == null) {
     mOnChooseActivityListener = new ShareActivityChooserModelPolicy();
   }
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
   dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
 }
Exemplo n.º 6
0
 private void setActivityChooserPolicyIfNeeded() {
   if (this.mOnShareTargetSelectedListener != null) {
     if (this.mOnChooseActivityListener == null) {
       this.mOnChooseActivityListener = new ShareActivityChooserModelPolicy();
     }
     ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName)
         .setOnChooseActivityListener(this.mOnChooseActivityListener);
   }
 }
  /** {@inheritDoc} */
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2014-09-18 21:46:52.211 -0400",
      hash_original_method = "5458A50E7CC261A43D8FD66D69514BF7",
      hash_generated_method = "9C9DCF571226F099D8D0DA86C844CB03")
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);

    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mOnMenuItemClickListener);
    }

    if (collapsedActivityCount < expandedActivityCount) {
      // Add a sub-menu for showing all activities as a list item.
      SubMenu expandedSubMenu =
          subMenu.addSubMenu(
              Menu.NONE,
              collapsedActivityCount,
              collapsedActivityCount,
              mContext.getString(R.string.abc_activity_chooser_view_see_all));
      for (int i = 0; i < expandedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        expandedSubMenu
            .add(0, i, i, activity.loadLabel(packageManager))
            .setIcon(activity.loadIcon(packageManager))
            .setOnMenuItemClickListener(mOnMenuItemClickListener);
      }
    }
  }
 public boolean onMenuItemClick(MenuItem paramMenuItem) {
   Intent localIntent =
       ActivityChooserModel.a(ShareActionProvider.a(this.a), ShareActionProvider.b(this.a))
           .b(paramMenuItem.getItemId());
   if (localIntent != null) {
     localIntent.addFlags(524288);
     ShareActionProvider.a(this.a).startActivity(localIntent);
   }
   return true;
 }
Exemplo n.º 9
0
 public void setShareIntent(Intent shareIntent) {
   if (shareIntent != null) {
     String action = shareIntent.getAction();
     if ("android.intent.action.SEND".equals(action)
         || "android.intent.action.SEND_MULTIPLE".equals(action)) {
       updateIntent(shareIntent);
     }
   }
   ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName).setIntent(shareIntent);
 }
Exemplo n.º 10
0
 public boolean onMenuItemClick(MenuItem item) {
   Intent launchIntent =
       ActivityChooserModel.get(
               ShareActionProvider.this.mContext, ShareActionProvider.this.mShareHistoryFileName)
           .chooseActivity(item.getItemId());
   if (launchIntent != null) {
     String action = launchIntent.getAction();
     if ("android.intent.action.SEND".equals(action)
         || "android.intent.action.SEND_MULTIPLE".equals(action)) {
       ShareActionProvider.this.updateIntent(launchIntent);
     }
     ShareActionProvider.this.mContext.startActivity(launchIntent);
   }
   return true;
 }
Exemplo n.º 11
0
 public View onCreateActionView() {
   ActivityChooserView activityChooserView = new ActivityChooserView(this.mContext);
   if (!activityChooserView.isInEditMode()) {
     activityChooserView.setActivityChooserModel(
         ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName));
   }
   TypedValue outTypedValue = new TypedValue();
   this.mContext
       .getTheme()
       .resolveAttribute(C0103R.attr.actionModeShareDrawable, outTypedValue, true);
   activityChooserView.setExpandActivityOverflowButtonDrawable(
       TintManager.getDrawable(this.mContext, outTypedValue.resourceId));
   activityChooserView.setProvider(this);
   activityChooserView.setDefaultActionButtonContentDescription(
       C0103R.string.abc_shareactionprovider_share_with_application);
   activityChooserView.setExpandActivityOverflowButtonContentDescription(
       C0103R.string.abc_shareactionprovider_share_with);
   return activityChooserView;
 }