Example #1
0
 protected internal override void onAttachedToWindow()
 {
     base.onAttachedToWindow();
     android.widget.ActivityChooserModel dataModel = mAdapter.getDataModel();
     if (dataModel != null)
     {
         dataModel.registerObserver(mModelDataSetOberver);
     }
     mIsAttachedToWindow = true;
 }
 public virtual bool onChooseActivity(android.widget.ActivityChooserModel host, android.content.Intent
                                      intent)
 {
     if (this._enclosing.mOnShareTargetSelectedListener != null)
     {
         return(this._enclosing.mOnShareTargetSelectedListener.onShareTargetSelected(this.
                                                                                     _enclosing, intent));
     }
     return(false);
 }
Example #3
0
 public virtual void setActivityChooserModel(android.widget.ActivityChooserModel dataModel
                                             )
 {
     mAdapter.setDataModel(dataModel);
     if (isShowingPopup())
     {
         dismissPopup();
         showPopup();
     }
 }
            public virtual bool onMenuItemClick(android.view.MenuItem item)
            {
                android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                                .get(this._enclosing.mContext, this._enclosing.mShareHistoryFileName);
                int itemId = item.getItemId();

                android.content.Intent launchIntent = dataModel.chooseActivity(itemId);
                if (launchIntent != null)
                {
                    this._enclosing.mContext.startActivity(launchIntent);
                }
                return(true);
            }
Example #5
0
 public virtual void setDataModel(android.widget.ActivityChooserModel dataModel)
 {
     android.widget.ActivityChooserModel oldDataModel = this._enclosing.mAdapter.getDataModel
                                                            ();
     if (oldDataModel != null && this._enclosing.isShown())
     {
         oldDataModel.unregisterObserver(this._enclosing.mModelDataSetOberver);
     }
     this.mDataModel = dataModel;
     if (dataModel != null && this._enclosing.isShown())
     {
         dataModel.registerObserver(this._enclosing.mModelDataSetOberver);
     }
     this.notifyDataSetChanged();
 }
Example #6
0
 protected internal override void onDetachedFromWindow()
 {
     base.onDetachedFromWindow();
     android.widget.ActivityChooserModel dataModel = mAdapter.getDataModel();
     if (dataModel != null)
     {
         dataModel.unregisterObserver(mModelDataSetOberver);
     }
     android.view.ViewTreeObserver viewTreeObserver = getViewTreeObserver();
     if (viewTreeObserver.isAlive())
     {
         viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
     }
     mIsAttachedToWindow = false;
 }
 /// <summary>
 /// 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.
 /// </summary>
 /// <remarks>
 /// 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.
 /// </remarks>
 private void setActivityChooserPolicyIfNeeded()
 {
     if (mOnShareTargetSelectedListener == null)
     {
         return;
     }
     if (mOnChooseActivityListener == null)
     {
         mOnChooseActivityListener = new android.widget.ShareActionProvider.ShareAcitivityChooserModelPolicy
                                         (this);
     }
     android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                     .get(mContext, mShareHistoryFileName);
     dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
 }
 public override android.view.View onCreateActionView()
 {
     // Create the view and set its data model.
     android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                     .get(mContext, mShareHistoryFileName);
     android.widget.ActivityChooserView activityChooserView = new android.widget.ActivityChooserView
                                                                  (mContext);
     activityChooserView.setActivityChooserModel(dataModel);
     // Lookup and set the expand action icon.
     android.util.TypedValue outTypedValue = new android.util.TypedValue();
     mContext.getTheme().resolveAttribute([email protected]
                                          , outTypedValue, true);
     android.graphics.drawable.Drawable drawable = mContext.getResources().getDrawable
                                                       (outTypedValue.resourceId);
     activityChooserView.setExpandActivityOverflowButtonDrawable(drawable);
     activityChooserView.setProvider(this);
     // Set content description.
     activityChooserView.setDefaultActionButtonContentDescription([email protected].
                                                                  @string.shareactionprovider_share_with_application);
     activityChooserView.setExpandActivityOverflowButtonContentDescription([email protected]
                                                                           [email protected]_share_with);
     return(activityChooserView);
 }
        public override void onPrepareSubMenu(android.view.SubMenu subMenu)
        {
            // Clear since the order of items may change.
            subMenu.clear();
            android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                            .get(mContext, mShareHistoryFileName);
            android.content.pm.PackageManager packageManager = mContext.getPackageManager();
            int expandedActivityCount  = dataModel.getActivityCount();
            int collapsedActivityCount = System.Math.Min(expandedActivityCount, mMaxShownActivityCount
                                                         );

            {
                // Populate the sub-menu with a sub set of the activities.
                for (int i = 0; i < collapsedActivityCount; i++)
                {
                    android.content.pm.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.
                android.view.SubMenu expandedSubMenu = subMenu.addSubMenu(android.view.MenuClass.NONE
                                                                          , collapsedActivityCount, collapsedActivityCount, java.lang.CharSequenceProxy.Wrap
                                                                              (mContext.getString([email protected][email protected]_chooser_view_see_all)));
                {
                    for (int i_1 = 0; i_1 < expandedActivityCount; i_1++)
                    {
                        android.content.pm.ResolveInfo activity = dataModel.getActivity(i_1);
                        expandedSubMenu.add(0, i_1, i_1, activity.loadLabel(packageManager)).setIcon(activity
                                                                                                     .loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
                    }
                }
            }
        }
Example #10
0
			public virtual void setDataModel(android.widget.ActivityChooserModel dataModel)
			{
				android.widget.ActivityChooserModel oldDataModel = this._enclosing.mAdapter.getDataModel
					();
				if (oldDataModel != null && this._enclosing.isShown())
				{
					oldDataModel.unregisterObserver(this._enclosing.mModelDataSetOberver);
				}
				this.mDataModel = dataModel;
				if (dataModel != null && this._enclosing.isShown())
				{
					dataModel.registerObserver(this._enclosing.mModelDataSetOberver);
				}
				this.notifyDataSetChanged();
			}
 /// <summary>Sets an intent with information about the share action.</summary>
 /// <remarks>
 /// 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>
 /// </p>
 /// </remarks>
 /// <param name="shareIntent">The share intent.</param>
 /// <seealso cref="android.content.Intent.ACTION_SEND">android.content.Intent.ACTION_SEND
 ///     </seealso>
 /// <seealso cref="android.content.Intent.ACTION_SEND_MULTIPLE">android.content.Intent.ACTION_SEND_MULTIPLE
 ///     </seealso>
 public virtual void setShareIntent(android.content.Intent shareIntent)
 {
     android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel
                                                     .get(mContext, mShareHistoryFileName);
     dataModel.setIntent(shareIntent);
 }