Skip to content

Commit

Permalink
setup 方法新增 setControlWifiSwitch 参数,默认为true
Browse files Browse the repository at this point in the history
  • Loading branch information
qingqing.wang committed Apr 8, 2021
1 parent befdf4f commit c742ced
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 25 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

## 2.0.3
+ 新增:setup 方法新增 setControlWifiSwitch 参数,默认为true
## 2.0.1
+ 新增:适配Flutter 2.0,flutter sdk 2.0以下版本请使用0.6.23。
## 0.6.23
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:

```
dependencies:
jverify: 2.0.1
jverify: 2.0.3
```

### 配置
Expand Down
29 changes: 24 additions & 5 deletions android/src/main/java/com/jiguang/jverify/JverifyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.widget.TextView;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -44,7 +45,7 @@
/**
* JverifyPlugin
*/
public class JverifyPlugin implements FlutterPlugin,MethodCallHandler {
public class JverifyPlugin implements FlutterPlugin, MethodCallHandler {

// 定义日志 TAG
private static final String TAG = "| JVER | Android | -";
Expand All @@ -69,21 +70,21 @@ public class JverifyPlugin implements FlutterPlugin,MethodCallHandler {


@Override
public void onAttachedToEngine( FlutterPluginBinding flutterPluginBinding) {
public void onAttachedToEngine(FlutterPluginBinding flutterPluginBinding) {
channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "jverify");
channel.setMethodCallHandler(this);
context = flutterPluginBinding.getApplicationContext();
}


@Override
public void onDetachedFromEngine( FlutterPluginBinding binding) {
public void onDetachedFromEngine(FlutterPluginBinding binding) {
channel.setMethodCallHandler(null);
}


@Override
public void onMethodCall( MethodCall call, Result result) {
public void onMethodCall(MethodCall call, Result result) {
Log.d(TAG, "onMethodCall:" + call.method);

Log.d(TAG, "processMethod:" + call.method);
Expand Down Expand Up @@ -148,6 +149,12 @@ private void setup(MethodCall call, Result result) {
Log.d(TAG, "Action - setup:");

Object timeout = getValueByKey(call, "timeout");
boolean setControlWifiSwitch = (boolean) getValueByKey(call, "setControlWifiSwitch");
if (!setControlWifiSwitch) {
Log.d(TAG, "Action - setup: setControlWifiSwitch==" + false);
setControlWifiSwitch();
}

JVerificationInterface.init(context, (Integer) timeout, new RequestCallback<String>() {
@Override
public void onResult(int code, String message) {
Expand All @@ -160,6 +167,18 @@ public void onResult(int code, String message) {
});
}

private void setControlWifiSwitch() {
try {
Class<JVerificationInterface> aClass = JVerificationInterface.class;
Method method = aClass.getDeclaredMethod("setControlWifiSwitch", boolean.class);
method.setAccessible(true);
method.invoke(aClass, false);
} catch (Exception e) {
e.printStackTrace();
}
}


/**
* SDK设置debug模式
*/
Expand Down Expand Up @@ -858,7 +877,7 @@ private void layoutOriginOuthView(Map uiconfig, JVerifyUIConfig.Builder builder)
}
}

builder.enableHintToast((Boolean)privacyHintToast, null);
builder.enableHintToast((Boolean) privacyHintToast, null);
/************** 授权页弹窗模式 ***************/
if (popViewConfig != null) {
Map popViewConfigMap = (Map) popViewConfig;
Expand Down
7 changes: 7 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ class _MyAppState extends State<MyApp> {
uiConfig.privacyNavTitleTitle2 = "协议22 web页标题";
uiConfig.privacyNavReturnBtnImage = "return_bg"; //图片必须存在;

//弹框模式
// JVPopViewConfig popViewConfig = JVPopViewConfig();
// popViewConfig.width = (screenWidth - 100.0).toInt();
// popViewConfig.height = (screenHeight - 150.0).toInt();
//
// uiConfig.popViewConfig = popViewConfig;

/// 添加自定义的 控件 到授权界面
List<JVCustomWidget> widgetList = [];

Expand Down
40 changes: 23 additions & 17 deletions lib/jverify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class Jverify {
static final _instance = new Jverify.private(const MethodChannel("jverify"));

/// 自定义控件的点击事件
addClikWidgetEventListener(
String eventId, JVClickWidgetEventListener callback) {
addClikWidgetEventListener(String eventId,
JVClickWidgetEventListener callback) {
_eventHanders.clickEventsMap[eventId] = callback;
}

Expand Down Expand Up @@ -98,7 +98,7 @@ class Jverify {
bool isContains = _eventHanders.clickEventsMap.containsKey(widgetId);
if (isContains) {
JVClickWidgetEventListener cb =
_eventHanders.clickEventsMap[widgetId];
_eventHanders.clickEventsMap[widgetId];
cb(widgetId);
}
}
Expand All @@ -115,7 +115,7 @@ class Jverify {
case 'onReceiveLoginAuthCallBackEvent':
{
for (JVLoginAuthCallBackListener cb
in _eventHanders.loginAuthCallBackEvents) {
in _eventHanders.loginAuthCallBackEvents) {
Map json = call.arguments.cast<dynamic, dynamic>();
JVListenerEvent event = JVListenerEvent.fromJson(json);
cb(event);
Expand Down Expand Up @@ -154,11 +154,10 @@ class Jverify {
}

/// 初始化, timeout单位毫秒,合法范围是(0,30000],推荐设置为5000-10000,默认值为10000
void setup(
{@required String appKey,
String channel,
bool useIDFA,
int timeout = 10000}) {
void setup({@required String appKey,
String channel,
bool useIDFA,
int timeout = 10000, bool setControlWifiSwitch = true}) {
print("$flutter_log" + "setup");

_channel.setMethodCallHandler(_handlerMethod);
Expand All @@ -167,7 +166,8 @@ class Jverify {
"appKey": appKey,
"channel": channel,
"useIDFA": useIDFA,
"timeout": timeout
"timeout": timeout,
"setControlWifiSwitch":setControlWifiSwitch
});
}

Expand Down Expand Up @@ -561,7 +561,7 @@ class JVUIConfig {
JVPopViewConfig popViewConfig;

JVIOSUIModalTransitionStyle modelTransitionStyle = //弹出方式 only ios
JVIOSUIModalTransitionStyle.CoverVertical;
JVIOSUIModalTransitionStyle.CoverVertical;

Map toJsonMap() {
return {
Expand Down Expand Up @@ -650,7 +650,8 @@ class JVUIConfig {
"needStartAnim": needStartAnim,
"needCloseAnim": needCloseAnim,
"privacyNavTitleTitle": privacyNavTitleTitle ??= null,
}..removeWhere((key, value) => value == null);
}
..removeWhere((key, value) => value == null);
}
}

Expand All @@ -666,9 +667,9 @@ class JVPopViewConfig {
int offsetCenterY = 0; // 窗口相对屏幕中心的y轴偏移量
bool isBottom = false; // only Android,窗口是否居屏幕底部。设置后 offsetCenterY 将失效,
double popViewCornerRadius =
5.0; // only ios,弹窗圆角大小,Android 从 AndroidManifest 配置中读取
5.0; // only ios,弹窗圆角大小,Android 从 AndroidManifest 配置中读取
double backgroundAlpha =
0.3; // only ios,背景的透明度,Android 从 AndroidManifest 配置中读取
0.3; // only ios,背景的透明度,Android 从 AndroidManifest 配置中读取

bool isPopViewTheme; // 是否支持弹窗模式
JVPopViewConfig() {
Expand All @@ -685,7 +686,8 @@ class JVPopViewConfig {
"isBottom": isBottom ??= null,
"popViewCornerRadius": popViewCornerRadius,
"backgroundAlpha": backgroundAlpha,
}..removeWhere((key, value) => value == null);
}
..removeWhere((key, value) => value == null);
}
}

Expand Down Expand Up @@ -751,7 +753,8 @@ class JVCustomWidget {
"top": top,
"width": width,
"height": height,
}..removeWhere((key, value) => value == null);
}
..removeWhere((key, value) => value == null);
}
}

Expand Down Expand Up @@ -859,5 +862,8 @@ String getStringFromEnum<T>(T) {
return null;
}

return T.toString().split('.').last;
return T
.toString()
.split('.')
.last;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: jverify
description: JIGUANG Official Jverifycation SDK flutter plugin project.
version: 2.0.1
version: 2.0.3
homepage: https://www.jiguang.cn

environment:
Expand Down

0 comments on commit c742ced

Please sign in to comment.