From 1b35752cec7aa43481b95ff5ac616bcd53e40ff1 Mon Sep 17 00:00:00 2001 From: weiry Date: Tue, 28 Apr 2020 15:30:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?android=20=E5=8A=A8=E6=80=81=E8=83=8C?= =?UTF-8?q?=E6=99=AF=EF=BC=8C=E6=96=87=E5=AD=97=E5=8A=A0=E7=B2=97=20ios=20?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=83=8C=E5=BD=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/android.md | 30 ++++++++-- doc/ios.md | 2 + plugin.xml | 1 + .../verification/JVerificationPlugin.java | 58 ++++++++++++++++++- src/ios/JVerificationPlugin.m | 9 +++ 5 files changed, 93 insertions(+), 7 deletions(-) diff --git a/doc/android.md b/doc/android.md index 05be7bc..e8009b7 100644 --- a/doc/android.md +++ b/doc/android.md @@ -7,19 +7,21 @@ ***以下设置图片名都为drawable下的图片名。(图片名不要后缀,图片自行放到res下的drawable文件夹内)*** ***x轴未设置偏移则所有组件默认横向居中*** - + + 设置授权页背景 + 支持的版本 :2.1.1 + 说明: + 图片会默认拉伸铺满整个屏幕,适配不同尺寸手机,建议使用 .9.png 图片来解决适配问题。 - + |方法|参数类型|说明| |:-----:|:----:|:----:| |setAuthBGImgPath|String|设置背景图片| - - +|setAuthBGGifPath|String|设置本地gif背景图片,需要放置到drawable文件中,传入图片名称即可| +|setAuthBGVideoPath|String,String|设置背景Video文件路径:(支持本地路径如:需把文件放入到raw文件夹中,传入参数为, "raw:"+文件名称,如:raw:testvideo 支持网络路径(建议下载到本地后使用本地路径,网络路径会出现卡顿等网络问题)如:"https://xxx"),设置默认第一频图片:(需要放置到drawable文件中,传入图片名称即可,如果Video文件路径为本地,则可以填null)| + + + 授权页状态栏 - + |方法|参数类型|说明| |:-----:|:----:|:----:| |setStatusBarColorWithNav|boolean|设置状态栏与导航栏同色。仅在android 5.0以上设备生效。 since 2.4.1| @@ -46,6 +48,7 @@ |setNavReturnBtnRightOffsetX|int|设置导航栏返回按钮距屏幕右侧偏移。since 2.4.8| |setNavReturnBtnOffsetY|int|设置导航栏返回按钮距上端偏移。since 2.4.8| |setNavHidden|boolean|设置导航栏是否隐藏。since 2.4.8| +|setNavTextBold|boolean|设置导航栏标题字体是否加粗。since 2.5.4| + 授权页logo @@ -70,6 +73,7 @@ |setNumberFieldOffsetBottomY|int|设置号码栏相对于屏幕底部y轴偏移。since 2.4.8| |setNumberFieldWidth|int|设置号码栏宽度。since 2.4.8| |setNumberFieldHeight|int|设置号码栏高度。since 2.4.8| +|setNumberTextBold|boolean|设置手机号码字体是否加粗。since 2.5.4| + 授权页登录按钮 @@ -84,6 +88,7 @@ |setLogBtnHeight|int|设置登录按钮高度。since 2.3.8| |setLogBtnTextSize|int|设置登录按钮字体大小。since 2.3.8| |setLogBtnBottomOffsetY|int|设置登录按钮相对屏幕底部y轴偏移。since 2.4.8| +|setLogBtnTextBold|boolean|设置登录按钮字体是否加粗。since 2.5.4| + 授权页隐私栏 @@ -106,6 +111,8 @@ |setPrivacyWithBookTitleMark|boolean|设置隐私条款运营商协议名是否加书名号。since 2.4.8| |setPrivacyCheckboxInCenter|boolean|设置隐私条款checkbox是否相对协议文字纵向居中。默认居顶。since 2.4.8| |setPrivacyTextWidth|int|设置隐私条款文字栏宽度。since 2.5.0| +|setPrivacyTextBold|boolean|设置隐私条款文字字体是否加粗。since 2.5.4| +|setPrivacyUnderlineText|boolean|设置隐私条款文字字体是否加下划线。since 2.5.4| + 授权页隐私协议web页面 @@ -114,6 +121,7 @@ |setPrivacyNavColor|int|设置协议展示web页面导航栏背景颜色。since 2.4.8| |setPrivacyNavTitleTextColor|int|设置协议展示web页面导航栏标题文字颜色。since 2.4.8| |setPrivacyNavTitleTextSize|int|设置协议展示web页面导航栏标题文字大小(sp)。since 2.4.8| +|setPrivacyNavTitleTextBold|boolean|设置协议展示web页面导航栏字体是否加粗。since 2.5.4| |setAppPrivacyNavTitle1|String|设置自定义协议1对应web页面导航栏文字内容。since 2.5.2| |setAppPrivacyNavTitle2|String|设置自定义协议2对应web页面导航栏文字内容。since 2.5.2| |setPrivacyStatusBarColorWithNav|boolean|设置授权协议web页面状态栏与导航栏同色。仅在android 5.0以上设备生效。since 2.5.2| @@ -132,6 +140,7 @@ |setSloganBottomOffsetY|int|设置slogan相对于屏幕底部下边缘y轴偏移。since 2.3.8| |setSloganTextSize|int|设置slogan字体大小。since 2.4.8| |setSloganHidden|boolean|设置slogan是否隐藏。since 2.4.8| +|setSloganTextBold|boolean|设置slogan字体是否加粗。since 2.5.4| + 授权页动画 @@ -180,6 +189,13 @@ |2013|内容为具体错误原因|网络发生异常| |2014|internal error while requesting token|请求token时发生内部错误| |2016|network type not supported|当前网络环境不支持认证| +|2017|carrier config invalid|运营商配置错误| +|2018|Local unsupported operator|本地不支持的运营商| +|3000|获取短信验证码成功|获取短信验证码成功| +|3001|没有初始化|没有初始化| +|3002|无效电话号码|无效电话号码| +|3003|前后两次请求少于设定时间|前后两次请求少于设定时间| +|3004|未知错误|未知错误,主要看错误信息| |4001|parameter invalid|参数错误。请检查参数,比如是否手机号格式不对| |4018||没有足够的余额| |4031||不是认证SDK用户| @@ -191,9 +207,13 @@ |6002|fetch loginToken canceled|用户取消获取loginToken| |6003|UI 资源加载异常|未正常添加sdk所需的资源文件| |6004|authorization requesting, please try again later|正在登录中,稍后再试| +|6006|prelogin scrip expired.|预取号结果超时,需要重新预取号| |7000|preLogin success|sdk 预取号成功| |7001|preLogin failed|sdk 预取号失败| |7002|preLogin requesting, please try again later|正在预取号中,稍后再试| +|8000|init success|初始化成功| +|8004|init failed|初始化失败,详见日志| +|8005|init timeout|初始化超时,稍后再试| |-994|网络连接超时| | |-996|网络连接断开| | |-997|注册失败/登录失败|(一般是由于没有网络造成的)如果确保设备网络正常,还是一直遇到此问题,则还有另外一个原因:JPush 服务器端拒绝注册。而这个的原因一般是:你当前 App 的 Android 包名以及 AppKey,与你在 Portal 上注册的应用的 Android 包名与 AppKey 不相同。| diff --git a/doc/ios.md b/doc/ios.md index ca3f2a1..cd929de 100644 --- a/doc/ios.md +++ b/doc/ios.md @@ -12,6 +12,8 @@ |参数名称|参数类型|参数说明| |:-----:|:----:|:-----:| |authPageBackgroundImage|String|授权界面背景图片| +|authPageGifImagePath|String|授权界面背景gif资源路径,与authPageBackgroundImage属性互斥| +|setVideoBackgroudResource|String,String|视频路径支持在线url或者本地视频路径,视频未准备好播放时的占位图片名称| |autoLayout|BOOL|是否使用autoLayout,默认YES,| |shouldAutorotate|BOOL|是否支持自动旋转 默认YES| |dismissAnimationFlag|BOOL|关闭授权页是否有动画。默认YES,有动画。参数仅作用于以下两种情况:1、一键登录接口设置登录完成后,自动关闭授权页 2、用户点击授权页关闭按钮,关闭授权页| diff --git a/plugin.xml b/plugin.xml index f3536c6..6a1ef3e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -48,6 +48,7 @@ + diff --git a/src/android/cn/jiguang/cordova/verification/JVerificationPlugin.java b/src/android/cn/jiguang/cordova/verification/JVerificationPlugin.java index a8a6015..dcc51ac 100644 --- a/src/android/cn/jiguang/cordova/verification/JVerificationPlugin.java +++ b/src/android/cn/jiguang/cordova/verification/JVerificationPlugin.java @@ -1,6 +1,7 @@ package cn.jiguang.cordova.verification; import android.content.Context; +import android.content.res.Resources; import android.util.Log; import org.apache.cordova.CallbackContext; @@ -255,6 +256,8 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { //设置授权页背景 private static final String setAuthBGImgPath = "setAuthBGImgPath"; + private static final String setAuthBGGifPath = "setAuthBGGifPath"; + private static final String setAuthBGVideoPath = "setAuthBGVideoPath"; // 状态栏 private static final String setStatusBarColorWithNav = "setStatusBarColorWithNav"; private static final String setStatusBarDarkMode = "setStatusBarDarkMode"; @@ -275,6 +278,7 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { private static final String setNavReturnBtnRightOffsetX = "setNavReturnBtnRightOffsetX"; private static final String setNavReturnBtnOffsetY = "setNavReturnBtnOffsetY"; private static final String setNavHidden = "setNavHidden"; + private static final String setNavTextBold = "setNavTextBold"; // 授权页logo private static final String setLogoWidth = "setLogoWidth"; private static final String setLogoHeight = "setLogoHeight"; @@ -291,6 +295,7 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { private static final String setNumberFieldOffsetBottomY = "setNumberFieldOffsetBottomY"; private static final String setNumberFieldWidth = "setNumberFieldWidth"; private static final String setNumberFieldHeight = "setNumberFieldHeight"; + private static final String setNumberTextBold = "setNumberTextBold"; // 授权页登录按钮 private static final String setLogBtnText = "setLogBtnText"; private static final String setLogBtnTextColor = "setLogBtnTextColor"; @@ -301,6 +306,7 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { private static final String setLogBtnHeight = "setLogBtnHeight"; private static final String setLogBtnTextSize = "setLogBtnTextSize"; private static final String setLogBtnBottomOffsetY = "setLogBtnBottomOffsetY"; + private static final String setLogBtnTextBold = "setLogBtnTextBold"; // 授权页隐私栏 private static final String setAppPrivacyOne = "setAppPrivacyOne"; private static final String setAppPrivacyTwo = "setAppPrivacyTwo"; @@ -319,11 +325,14 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { private static final String setPrivacyWithBookTitleMark = "setPrivacyWithBookTitleMark"; private static final String setPrivacyCheckboxInCenter = "setPrivacyCheckboxInCenter"; private static final String setPrivacyTextWidth = "setPrivacyTextWidth"; + private static final String setPrivacyTextBold = "setPrivacyTextBold"; + private static final String setPrivacyUnderlineText = "setPrivacyUnderlineText"; // private static final String enableHintToast = "enableHintToast"; // 授权页隐私协议web页面 private static final String setPrivacyNavColor = "setPrivacyNavColor"; private static final String setPrivacyNavTitleTextColor = "setPrivacyNavTitleTextColor"; private static final String setPrivacyNavTitleTextSize = "setPrivacyNavTitleTextSize"; + private static final String setPrivacyNavTitleTextBold = "setPrivacyNavTitleTextBold"; private static final String setAppPrivacyNavTitle1 = "setAppPrivacyNavTitle1"; private static final String setAppPrivacyNavTitle2 = "setAppPrivacyNavTitle2"; private static final String setPrivacyStatusBarColorWithNav = "setPrivacyStatusBarColorWithNav"; @@ -338,6 +347,7 @@ void setSmsIntervalTime(JSONArray data, CallbackContext callbackContext) { private static final String setSloganBottomOffsetY = "setSloganBottomOffsetY"; private static final String setSloganTextSize = "setSloganTextSize"; private static final String setSloganHidden = "setSloganHidden"; + private static final String setSloganTextBold = "setSloganTextBold"; // 授权页动画 private static final String setNeedStartAnim = "setNeedStartAnim"; private static final String setNeedCloseAnim = "setNeedCloseAnim"; @@ -348,8 +358,6 @@ void setCustomUIWithConfig(JSONArray data, CallbackContext callbackContext) thro JSONObject jsonObjectPortrait = new JSONObject(data.getString(0)); JVerifyUIConfig.Builder uiConfigPortrait = getBuilder(jsonObjectPortrait); JVerificationInterface.setCustomUIWithConfig(uiConfigPortrait.build()); - - } void setCustomUIWithConfigAndroid(JSONArray data, CallbackContext callbackContext) throws JSONException { @@ -381,6 +389,18 @@ private void setUiConfig(JVerifyUIConfig.Builder uiConfigBuilder, JSONObject jso //设置授权页背景 if (setAuthBGImgPath.equals(key)) { uiConfigBuilder.setAuthBGImgPath(jsonObject.getString(key)); + } else if (setAuthBGGifPath.equals(key)) { + uiConfigBuilder.setAuthBGGifPath(jsonObject.getString(key)); + } else if (setAuthBGVideoPath.equals(key)) { + JSONArray jsonArray = jsonObject.getJSONArray(key); + String videoPath = jsonArray.getString(0); + if (null != videoPath) { + if (videoPath.startsWith("raw:")) { + videoPath = videoPath.replace("raw:", ""); + videoPath = "android.resource://" + mContext.getPackageName() + "/" + getRawResourceId(mContext, videoPath); + } + } + uiConfigBuilder.setAuthBGVideoPath(videoPath, jsonArray.getString(1)); } // 授权页导航栏 else if (setNavColor.equals(key)) { @@ -409,6 +429,8 @@ else if (setNavColor.equals(key)) { uiConfigBuilder.setNavReturnBtnOffsetY(jsonObject.getInt(key)); } else if (setNavHidden.equals(key)) { uiConfigBuilder.setNavHidden(jsonObject.getBoolean(key)); + } else if (setNavTextBold.equals(key)) { + uiConfigBuilder.setNavTextBold(jsonObject.getBoolean(key)); } // 授权页logo @@ -443,6 +465,8 @@ else if (setNumberColor.equals(key)) { uiConfigBuilder.setNumberFieldWidth(jsonObject.getInt(key)); } else if (setNumberFieldHeight.equals(key)) { uiConfigBuilder.setNumberFieldHeight(jsonObject.getInt(key)); + } else if (setNumberTextBold.equals(key)) { + uiConfigBuilder.setNumberTextBold(jsonObject.getBoolean(key)); } @@ -465,6 +489,8 @@ else if (setLogBtnText.equals(key)) { uiConfigBuilder.setLogBtnTextSize(jsonObject.getInt(key)); } else if (setLogBtnBottomOffsetY.equals(key)) { uiConfigBuilder.setLogBtnBottomOffsetY(jsonObject.getInt(key)); + } else if (setLogBtnTextBold.equals(key)) { + uiConfigBuilder.setLogBtnTextBold(jsonObject.getBoolean(key)); } // 授权页隐私栏 @@ -506,6 +532,10 @@ else if (setAppPrivacyOne.equals(key)) { uiConfigBuilder.setPrivacyCheckboxInCenter(jsonObject.getBoolean(key)); } else if (setPrivacyTextWidth.equals(key)) { uiConfigBuilder.setPrivacyTextWidth(jsonObject.getInt(key)); + } else if (setPrivacyTextBold.equals(key)) { + uiConfigBuilder.setPrivacyTextBold(jsonObject.getBoolean(key)); + } else if (setPrivacyUnderlineText.equals(key)) { + uiConfigBuilder.setPrivacyUnderlineText(jsonObject.getBoolean(key)); } // 授权页隐私协议web页面 @@ -515,6 +545,8 @@ else if (setPrivacyNavColor.equals(key)) { uiConfigBuilder.setPrivacyNavTitleTextColor(jsonObject.getInt(key)); } else if (setPrivacyNavTitleTextSize.equals(key)) { uiConfigBuilder.setPrivacyNavTitleTextSize(jsonObject.getInt(key)); + } else if (setPrivacyNavTitleTextBold.equals(key)) { + uiConfigBuilder.setPrivacyNavTitleTextBold(jsonObject.getBoolean(key)); } else if (setAppPrivacyNavTitle1.equals(key)) { uiConfigBuilder.setAppPrivacyNavTitle1(jsonObject.getString(key)); } else if (setAppPrivacyNavTitle2.equals(key)) { @@ -544,6 +576,8 @@ else if (setSloganTextColor.equals(key)) { uiConfigBuilder.setSloganTextSize(jsonObject.getInt(key)); } else if (setSloganHidden.equals(key)) { uiConfigBuilder.setSloganHidden(jsonObject.getBoolean(key)); + } else if (setSloganTextBold.equals(key)) { + uiConfigBuilder.setSloganTextBold(jsonObject.getBoolean(key)); } // 授权页动画 else if (setNeedStartAnim.equals(key)) { @@ -558,4 +592,24 @@ else if (setDialogTheme.equals(key)) { jsonArray.getInt(2), jsonArray.getInt(3), jsonArray.getBoolean(4)); } } + + + public static int getRawResourceId(Context context, String resourceName) { + int resourceId = getResourceId(context, resourceName, "raw"); + if (resourceId == 0) { + throw new Resources.NotFoundException(resourceName); + } else { + return resourceId; + } + } + + private static int getResourceId(Context context, String resourceName, String resourceType) { + int resouceId = 0; + try { + resouceId = context.getResources().getIdentifier(resourceName, resourceType, context.getPackageName()); + } catch (Throwable e) { + e.printStackTrace(); + } + return resouceId; + } } \ No newline at end of file diff --git a/src/ios/JVerificationPlugin.m b/src/ios/JVerificationPlugin.m index a2c2ee4..591aee5 100644 --- a/src/ios/JVerificationPlugin.m +++ b/src/ios/JVerificationPlugin.m @@ -333,6 +333,8 @@ - (void)setCustomUIWithConfig:(CDVInvokedUrlCommand*)command //授权页面设置 static NSString* authPageBackgroundImage=@"authPageBackgroundImage"; +static NSString* authPageGifImagePath=@"authPageGifImagePath"; +static NSString* setVideoBackgroudResource=@"setVideoBackgroudResource"; static NSString* autoLayout=@"autoLayout"; static NSString* shouldAutorotate=@"shouldAutorotate"; static NSString* dismissAnimationFlag=@"dismissAnimationFlag"; @@ -417,6 +419,13 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict, //授权页面设置 if ([key containsString:authPageBackgroundImage]) { jvUIConfig.authPageBackgroundImage = [UIImage imageNamed:dict[key]]; + }else if([key containsString:authPageGifImagePath]){ + jvUIConfig.authPageGifImagePath = dict[key]; + }else if([key containsString:setVideoBackgroudResource]){ + NSArray* textArry = dict[key]; + NSString *path = textArry[0]; + NSString *imageName = textArry[1]; + [jvUIConfig setVideoBackgroudResource:path placeHolder:imageName]; }else if([key containsString:autoLayout]){ jvUIConfig.autoLayout = [dict[key] boolValue]; }else if([key containsString:shouldAutorotate]){ From 82c5c19679b8b0be17b159b153254332926863b9 Mon Sep 17 00:00:00 2001 From: weiry Date: Tue, 28 Apr 2020 15:49:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4cfc290..66ef6cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jg-jverification-cordova-plugin", - "version": "1.2.6", + "version": "1.2.7", "description": "JVerification-cordova-plugin", "cordova": { "id": "jg-jverification-cordova-plugin", diff --git a/plugin.xml b/plugin.xml index 6a1ef3e..25b5d2f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ JVerification-cordova-plugin