/*** Adds a custom share item, which is currently used in the ActionSheet triggered by tapping the More button or a button component with open-type="share".** @param text The title of the share menu.* @param drawableResId The resource ID of the icon.* @param id The ID of the custom share item. Must be a value within the range [100, 200]. This ID will be passed as shareTarget to ShareProxy to distinguish sharing channels.* @param shareKey The key of the custom share item, which should match the definition in the mini program.* @param contentDescription The description of the custom share item, provided for accessibility purposes.* @return Returns the builder object for chaining calls.*/public Builder addCustomShareItem(String text, int drawableResId, int id, String shareKey, String contentDescription)
private static final String SHARE_TWITTER = "twitter";/*** Returns the the "More" button in the capsule. The IDs for extension buttons must be set within the range of [100, 200]; otherwise, the addition will be invalid.* Calling environment: Subprocess** @param miniAppContext Mini program runtime environment (mini program process, not main process)* @param builder* @return*/@Overridepublic ArrayList<MoreItem> getMoreItems(IMiniAppContext miniAppContext, MoreItemList.Builder builder) {// Adjust the order as neededbuilder.addCustomShareItem(getString(miniAppContext, R.string.applet_mini_proxy_impl_other2),R.mipmap.mini_demo_about,ShareProxyImpl.OTHER_MORE_ITEM_2,SHARE_TWITTER, null).addCustomShareItem(getString(miniAppContext, R.string.applet_mini_proxy_impl_other3),R.drawable.tcmpp_demo_share_whatsapp,ShareProxyImpl.SHARE_TO_WHATSAPP,ShareProxyImpl.SHARE_TO_WHATSAPP_KEY, null).addCustomShareItem(getString(miniAppContext, R.string.applet_mini_proxy_impl_other4),R.drawable.tcmpp_demo_share_more,ShareProxyImpl.SHARE_TO_MORE,ShareProxyImpl.SHARE_TO_MORE_KEY, null);return super.getMoreItems(miniAppContext, builder);}


@ProxyService(proxy = ShareProxy.class)public class ShareProxyImpl extends BaseShareProxy {/*** Share** @param shareData Share data*/@Overridepublic void share(Activity activity, ShareData shareData) {//todo share}}
@Overridepublic ShareImageCustomInfo getImageShareCustomInfo(IMiniAppContext miniAppContext) {// Create a list of share itemsArrayList<ShareImageItem> items = new ArrayList<>();// Add custom share item 1items.add(new ShareImageItem(miniAppContext.getContext().getString(R.string.applet_mini_proxy_impl_favorite),ContextCompat.getDrawable(miniAppContext.getContext(), R.drawable.mini_sdk_favorite), (context, path) -> Toast.makeText(context.getAttachedActivity(),"custom image share: " + path, Toast.LENGTH_SHORT).show()));// Add custom share item 2items.add(new ShareImageItem("custom share",ContextCompat.getDrawable(miniAppContext.getContext(), R.drawable.mini_sdk_favorite), ShareProxyImpl.OTHER_MORE_ITEM_2));return new ShareImageCustomInfo(items);}// Custom share item class definitionpublic class ShareImageItem {// Item titlepublic String title;// Item iconpublic Drawable icon;// Tap event callback for the itempublic ClickEvent clickEvent;// The targetId of the item event; tap events will be forwarded through ShareProxy.share and will no longer trigger clickEvent directly.public Integer shareTarget;}

Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback