From 57ca7b3d40c645cef5c78781bf6ad15d82f97862 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Fri, 22 Jan 2021 10:33:55 +0800 Subject: [PATCH] Update --- app/build.gradle | 2 +- .../com/finogeeks/mop/demo/AppletHandler.java | 124 ++++++++++++++++-- 2 files changed, 111 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5f4cd02..1f90c3b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,6 +69,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - implementation 'com.finogeeks.lib:finapplet:2.13.38' + implementation 'com.finogeeks.lib:finapplet:2.13.48-alpha20210121V04' implementation "com.tencent.tbs.tbssdk:sdk:43967" } \ No newline at end of file diff --git a/app/src/main/java/com/finogeeks/mop/demo/AppletHandler.java b/app/src/main/java/com/finogeeks/mop/demo/AppletHandler.java index de2254e..ed4392a 100644 --- a/app/src/main/java/com/finogeeks/mop/demo/AppletHandler.java +++ b/app/src/main/java/com/finogeeks/mop/demo/AppletHandler.java @@ -7,6 +7,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import com.finogeeks.lib.applet.page.view.moremenu.MoreMenuItem; +import com.finogeeks.lib.applet.page.view.moremenu.MoreMenuType; import com.finogeeks.lib.applet.rest.model.GrayAppletVersionConfig; import com.finogeeks.lib.applet.sdk.api.IAppletHandler; @@ -32,46 +33,141 @@ public class AppletHandler implements IAppletHandler { this.mContext = context; } + /** + * 获取灰度发布配置参数 + * + * @param appId 小程序ID + * @return 灰度发布配置参数 + */ @Nullable @Override public List getGrayAppletVersionConfigs(@NotNull String appId) { return null; } + /** + * 获取注册的"更多"菜单项 + * + * @param appId 小程序ID + * @return 注册的"更多"菜单项 + */ @Nullable @Override public List getRegisteredMoreMenuItems(@NotNull String appId) { - List moreMenuItems = new ArrayList<>(); - moreMenuItems.add(new MoreMenuItem(0x01, android.R.drawable.star_big_on, "菜单一", true)); - moreMenuItems.add(new MoreMenuItem(0x02, android.R.drawable.star_big_off, "菜单二", true)); - moreMenuItems.add(new MoreMenuItem(0x03, android.R.drawable.star_big_on, "菜单三菜单三菜单三菜单三菜单三", true)); - moreMenuItems.add(new MoreMenuItem(0x04, android.R.drawable.star_big_off, "菜单四", true)); - moreMenuItems.add(new MoreMenuItem(0x05, android.R.drawable.star_big_on, "菜单五", true)); - moreMenuItems.add(new MoreMenuItem(0x06, android.R.drawable.star_big_off, "菜单六", true)); - moreMenuItems.add(new MoreMenuItem(0x07, android.R.drawable.star_big_on, "菜单七", true)); - moreMenuItems.add(new MoreMenuItem(0x08, android.R.drawable.star_big_off, "菜单八", true)); - moreMenuItems.add(new MoreMenuItem(0x09, android.R.drawable.star_big_on, "菜单九", true)); - return moreMenuItems; + List items = new ArrayList<>(); + MoreMenuItem item0 = new MoreMenuItem("WXShareAPPFriends", "微信好朋友", MoreMenuType.ON_MINI_PROGRAM); + items.add(item0); + MoreMenuItem item1 = new MoreMenuItem("WXShareAPPMoments", "微信朋友圈", MoreMenuType.ON_MINI_PROGRAM, true); + items.add(item1); + MoreMenuItem item2 = new MoreMenuItem("ShareSinaWeibo", "新浪微博", MoreMenuType.ON_MINI_PROGRAM); + items.add(item2); + MoreMenuItem item3 = new MoreMenuItem("ShareQQFirends", "QQ", MoreMenuType.ON_MINI_PROGRAM); + items.add(item3); + MoreMenuItem item4 = new MoreMenuItem("ShareDingDing", "Dingding", MoreMenuType.ON_MINI_PROGRAM); + items.add(item4); + MoreMenuItem item5 = new MoreMenuItem("ShareLinks", "标题以后端配置为准", MoreMenuType.ON_MINI_PROGRAM); + items.add(item5); + MoreMenuItem item6 = new MoreMenuItem("SharePicture", "SharePicture", MoreMenuType.ON_MINI_PROGRAM); + items.add(item6); + MoreMenuItem item7 = new MoreMenuItem("Restart", "Restart", MoreMenuType.COMMON); + items.add(item7); + MoreMenuItem item8 = new MoreMenuItem("Desktop", "Desktop", MoreMenuType.COMMON); + items.add(item8); + return items; } + /** + * 获取用户信息 + * + * @return 用户信息[Map] + */ @Nullable @Override public Map getUserInfo() { return null; } + /** + * 小程序导航栏中的"关闭"按钮被点击 + * + * @param appId 小程序ID + */ @Override public void onNavigationBarCloseButtonClicked(@NotNull String appId) { Toast.makeText(mContext, "点击了小程序 " + appId + " 的导航栏关闭按钮", Toast.LENGTH_SHORT).show(); } + /** + * 注册的"更多"菜单项被点击 + * + * @param appId 小程序ID + * @param path 小程序页面路径 + * @param menuItemId 被点击的菜单条目的ID + * @param appInfo 小程序信息,是一串json,包含了小程序id、小程序名称、小程序图标、用户id、转发的数据内容等信息。 + * [appInfo]的内容格式如下: + * { + * "appTitle": "凡泰小程序", + * "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png", + * "appId": "5df36b3f687c5c00013e9fd1", + * "userId": "finogeeks", + * "params": { + * "title": "apt-test-tweet-接口测试发布的动态!@#¥%……&*(", + * "desc": "您身边的服务专家", + * "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png", + * "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654", + * "appInfo": { + * "weixin": { + * "path": "\/studio\/pages\/tweet\/tweet-detail", + * "query": { + * "fcid": "@staff_staff1:000000.finogeeks.com", + * "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d" + * } + * } + * } + * } + * } + * @param bitmap 小程序封面图片。如果[appInfo].params.imageUrl字段为http、https的链接地址,那么小程序封面图片 + * 就取[appInfo].params.imageUrl对应的图片,否则小程序的封面图片取[bitmap]。 + * @param callback 转发小程序结果回调。 + */ @Override - public void onRegisteredMoreMenuItemClicked(@NotNull String appId, int menuItemId) { - Toast.makeText(mContext, "点击了小程序 " + appId + " 注入的菜单 :" + menuItemId, Toast.LENGTH_SHORT).show(); + public void onRegisteredMoreMenuItemClicked(@NotNull String appId, @NotNull String path, @NotNull String menuItemId, @Nullable String appInfo, @Nullable Bitmap bitmap, @NotNull IAppletCallback callback) { + Toast.makeText(mContext, "小程序" + appId + "的" + path + "页面的菜单" + menuItemId + "被点击了,appInfo : " + appInfo + " bitmap : " + bitmap, Toast.LENGTH_SHORT).show(); + callback.onSuccess(null); } + /** + * 转发小程序 + * + * @param appInfo 小程序信息,是一串json,包含了小程序id、小程序名称、小程序图标、用户id、转发的数据内容等信息。 + * [appInfo]的内容格式如下: + * { + * "appTitle": "凡泰小程序", + * "appAvatar": "https:\/\/www.finogeeks.club\/statics\/images\/swan_mini\/swan_logo.png", + * "appId": "5df36b3f687c5c00013e9fd1", + * "userId": "finogeeks", + * "params": { + * "title": "apt-test-tweet-接口测试发布的动态!@#¥%……&*(", + * "desc": "您身边的服务专家", + * "imageUrl": "finfile:\/\/tmp_fc15edd8-2ff6-4c54-9ee9-fe5ee034033d1576550313667.png", + * "path": "pages\/tweet\/tweet-detail.html?fcid=%40staff_staff1%3A000000.finogeeks.com&timelineId=db0c2098-031e-41c4-b9c6-87a5bbcf681d&shareId=3dfa2f78-19fc-42fc-b3a9-4779a6dac654", + * "appInfo": { + * "weixin": { + * "path": "\/studio\/pages\/tweet\/tweet-detail", + * "query": { + * "fcid": "@staff_staff1:000000.finogeeks.com", + * "timelineId": "db0c2098-031e-41c4-b9c6-87a5bbcf681d" + * } + * } + * } + * } + * } + * @param bitmap 小程序封面图片。如果[appInfo].params.imageUrl字段为http、https的链接地址,那么小程序封面图片 + * 就取[appInfo].params.imageUrl对应的图片,否则小程序的封面图片取[bitmap]。 + * @param callback 转发小程序结果回调。 + */ @Override - public void shareAppMessage(@NotNull String appInfo, @Nullable Bitmap bitmap, @NotNull IAppletCallback iAppletCallback) { + public void shareAppMessage(@NotNull String appInfo, @Nullable Bitmap bitmap, @NotNull IAppletCallback callback) { Toast.makeText(mContext, "点击了转发按钮,去实现您的转发/分享逻辑吧", Toast.LENGTH_SHORT).show(); } } \ No newline at end of file