通过如下设置,宿主可以自定义小程序 UI。
@ProxyService(proxy = IMiniUiProxy.class)
public class MiniUiProxyImpl extends AbsMiniUiProxy
定义实现类并继承 AbsMiniUiProxy,并使用上面的注解进行修饰。
胶囊 UI
@DrawableRes
int navBarBackRes(int mode);
@DrawableRes
int homeButtonRes(int mode);
@DrawableRes
int moreButtonRes(int mode);
@DrawableRes
int closeButtonRes(int mode);
@DrawableRes
int lineSplitBackgroundColor();
小程序授权 UI
当小程序调用的 API 需要授权时,SDK 提供如下默认的授权 UI 样式,开发者也可以通过如下方法自定义授权 UI 样式。
@Override
public boolean authView(Context context, MiniAuthInfo authInfo, IAuthView authView) {
return true;
}
授权用户信息 UI
可以自定义用户授权信息中用户昵称和头像。
@Override
public void getUserInfo(String appId, AsyncResult result) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("nickName", "userInfo测试");
jsonObject.put("avatarUrl", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.daimg.com%2Fuploads%2Fallimg%2F210114%2F1-210114151951.jpg&refer=http%3A%2F%2Fimg.daimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673852149&t=e2a830d9fabd7e0818059d92c3883017");
result.onReceiveResult(true, jsonObject);
} catch (JSONException e) {
e.printStackTrace();
}
}
为了加载头像,还需要实现 BaseMiniAppProxyImpl 如下方法(参考小程序宿主自定义)。 public Drawable getDrawable(Context context, String source, int width, int hight, Drawable defaultDrawable)
小程序 Loading
小程序打开过程中有检查更新和启动加载loading,可以通过如下方式自定义 loading。
public abstract IMiniLoading updateLoadingView(Context context);
public abstract IMiniLoading startLoadingView(WeakReference<Activity> activityWeakRef, MiniAppLoading app);
示例:
@Override
public IMiniLoading updateLoadingView(Context context) {
return new IMiniLoading() {
@Override
public View create() {
return LayoutInflater.from(context).inflate(R.layout.applet_activity_custom_update_loading, null);
}
@Override
public void show(View v) {
}
@Override
public void stop(View v) {
}
};
}
小程序加载 loading 页面右上角胶囊
boolean hideLoadingCapsule();
本页内容是否解决了您的问题?