Showing
53 changed files
with
1220 additions
and
3305 deletions
Too many changes to show.
To preserve performance only 53 of 53+ files are displayed.
| @@ -12,14 +12,14 @@ if (flutterRoot == null) { | @@ -12,14 +12,14 @@ if (flutterRoot == null) { | ||
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | -def flutterVersionCode = "3580" | 15 | +def flutterVersionCode = "3581" |
| 16 | if (flutterVersionCode == null) { | 16 | if (flutterVersionCode == null) { |
| 17 | - flutterVersionCode = '3580' | 17 | + flutterVersionCode = '3581' |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | -def flutterVersionName = "3.5.8.0" | 20 | +def flutterVersionName = "3.5.8.1" |
| 21 | if (flutterVersionName == null) { | 21 | if (flutterVersionName == null) { |
| 22 | - flutterVersionName = '3.5.8.0' | 22 | + flutterVersionName = '3.5.8.1' |
| 23 | } | 23 | } |
| 24 | apply plugin: 'com.android.application' | 24 | apply plugin: 'com.android.application' |
| 25 | apply plugin: 'kotlin-android' | 25 | apply plugin: 'kotlin-android' |
| @@ -28,7 +28,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | @@ -28,7 +28,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
| 28 | apply plugin: 'com.huawei.agconnect' | 28 | apply plugin: 'com.huawei.agconnect' |
| 29 | 29 | ||
| 30 | android { | 30 | android { |
| 31 | - compileSdkVersion 28 | 31 | + compileSdkVersion 31 |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | sourceSets { | 34 | sourceSets { |
| @@ -43,7 +43,7 @@ android { | @@ -43,7 +43,7 @@ android { | ||
| 43 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | 43 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). |
| 44 | applicationId "com.naji.one_key" | 44 | applicationId "com.naji.one_key" |
| 45 | minSdkVersion 21 | 45 | minSdkVersion 21 |
| 46 | - targetSdkVersion 28 | 46 | + targetSdkVersion 31 |
| 47 | versionCode flutterVersionCode.toInteger() | 47 | versionCode flutterVersionCode.toInteger() |
| 48 | versionName flutterVersionName | 48 | versionName flutterVersionName |
| 49 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 49 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/> | 21 | <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/> |
| 22 | 22 | ||
| 23 | <application | 23 | <application |
| 24 | - android:name="io.flutter.app.FlutterApplication" | 24 | + |
| 25 | android:label="一键订" | 25 | android:label="一键订" |
| 26 | tools:replace="android:label" | 26 | tools:replace="android:label" |
| 27 | android:icon="@mipmap/ic_launcher"> | 27 | android:icon="@mipmap/ic_launcher"> |
| @@ -44,6 +44,10 @@ | @@ -44,6 +44,10 @@ | ||
| 44 | android:name="io.flutter.embedding.android.SplashScreenDrawable" | 44 | android:name="io.flutter.embedding.android.SplashScreenDrawable" |
| 45 | android:resource="@drawable/launch_background" /> | 45 | android:resource="@drawable/launch_background" /> |
| 46 | 46 | ||
| 47 | + <meta-data | ||
| 48 | + android:name="flutterEmbedding" | ||
| 49 | + android:value="2" /> | ||
| 50 | + | ||
| 47 | <intent-filter> | 51 | <intent-filter> |
| 48 | <action android:name="android.intent.action.MAIN"/> | 52 | <action android:name="android.intent.action.MAIN"/> |
| 49 | <category android:name="android.intent.category.LAUNCHER"/> | 53 | <category android:name="android.intent.category.LAUNCHER"/> |
| 1 | -# <<<<<<< HEAD | ||
| 2 | -# #Mon Dec 20 13:10:07 CST 2021 | ||
| 3 | -# distributionBase=GRADLE_USER_HOME | ||
| 4 | -# distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip | ||
| 5 | -# ======= | ||
| 6 | -#Thu Dec 23 01:26:57 CST 2021 | ||
| 7 | distributionBase=GRADLE_USER_HOME | 1 | distributionBase=GRADLE_USER_HOME |
| 8 | -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip | ||
| 9 | distributionPath=wrapper/dists | 2 | distributionPath=wrapper/dists |
| 10 | -zipStorePath=wrapper/dists | 3 | +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip |
| 11 | zipStoreBase=GRADLE_USER_HOME | 4 | zipStoreBase=GRADLE_USER_HOME |
| 5 | +zipStorePath=wrapper/dists |
| @@ -66,7 +66,7 @@ Future<void> main() async { | @@ -66,7 +66,7 @@ Future<void> main() async { | ||
| 66 | FluroRouter router = FluroRouter(); | 66 | FluroRouter router = FluroRouter(); |
| 67 | Routes.configureRoutes(router); | 67 | Routes.configureRoutes(router); |
| 68 | App.router = router; | 68 | App.router = router; |
| 69 | - await App.initSp(); | 69 | + // await App.initSp(); |
| 70 | 70 | ||
| 71 | SystemChrome.setPreferredOrientations( | 71 | SystemChrome.setPreferredOrientations( |
| 72 | [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]).then((_) { | 72 | [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]).then((_) { |
| @@ -79,7 +79,7 @@ Future<void> main() async { | @@ -79,7 +79,7 @@ Future<void> main() async { | ||
| 79 | create: (_) => UserModel(), | 79 | create: (_) => UserModel(), |
| 80 | ), | 80 | ), |
| 81 | ChangeNotifierProvider<MessageDialogModel>( | 81 | ChangeNotifierProvider<MessageDialogModel>( |
| 82 | - create: (_) => MessageDialogModel()..init(), | 82 | + create: (_) => MessageDialogModel(), |
| 83 | ), | 83 | ), |
| 84 | // ChangeNotifierProvider<OnlineCheckEditProvider>( | 84 | // ChangeNotifierProvider<OnlineCheckEditProvider>( |
| 85 | // create: (_) => OnlineCheckEditProvider(), | 85 | // create: (_) => OnlineCheckEditProvider(), |
| @@ -181,7 +181,7 @@ class MyAppState extends State<MyApp> { | @@ -181,7 +181,7 @@ class MyAppState extends State<MyApp> { | ||
| 181 | 181 | ||
| 182 | //第一次打开应用 | 182 | //第一次打开应用 |
| 183 | _isFirst() async { | 183 | _isFirst() async { |
| 184 | - isFirst = App.sp.getBool("isFirst") ?? true; | 184 | + // isFirst = App.sp.getBool("isFirst") ?? true; |
| 185 | isFirst = true; | 185 | isFirst = true; |
| 186 | if (!isFirst) { | 186 | if (!isFirst) { |
| 187 | await _ontherInit(); | 187 | await _ontherInit(); |
| @@ -228,28 +228,28 @@ class DioUtil { | @@ -228,28 +228,28 @@ class DioUtil { | ||
| 228 | } catch (e) { | 228 | } catch (e) { |
| 229 | Loading.hideLoading(context); | 229 | Loading.hideLoading(context); |
| 230 | return new Future.error(new DioError( | 230 | return new Future.error(new DioError( |
| 231 | - // requestOptions: response.requestOptions, | 231 | + requestOptions: response.requestOptions, |
| 232 | response: response, | 232 | response: response, |
| 233 | error: "data parsing exception...", | 233 | error: "data parsing exception...", |
| 234 | - type: DioErrorType.RESPONSE, | 234 | + type: DioErrorType.response, |
| 235 | )); | 235 | )); |
| 236 | } | 236 | } |
| 237 | } | 237 | } |
| 238 | Loading.hideLoading(context); | 238 | Loading.hideLoading(context); |
| 239 | return new Future.error(new DioError( | 239 | return new Future.error(new DioError( |
| 240 | - // requestOptions: response.requestOptions, | 240 | + requestOptions: response.requestOptions, |
| 241 | response: response, | 241 | response: response, |
| 242 | error: "statusCode: $response.statusCode, service error", | 242 | error: "statusCode: $response.statusCode, service error", |
| 243 | - type: DioErrorType.RESPONSE, | 243 | + type: DioErrorType.response, |
| 244 | )); | 244 | )); |
| 245 | } on DioError catch (error) { | 245 | } on DioError catch (error) { |
| 246 | if (showLoading) { | 246 | if (showLoading) { |
| 247 | Loading.hideLoading(context); | 247 | Loading.hideLoading(context); |
| 248 | } | 248 | } |
| 249 | - if (error is DioError && error.type == DioErrorType.CONNECT_TIMEOUT) { | 249 | + if (error is DioError && error.type == DioErrorType.connectTimeout) { |
| 250 | // Utils.showToast("网络链接超时,请稍后重试"); | 250 | // Utils.showToast("网络链接超时,请稍后重试"); |
| 251 | } | 251 | } |
| 252 | - if (error.type != DioErrorType.CANCEL) { | 252 | + if (error.type != DioErrorType.cancel) { |
| 253 | throw MyError(type: 2); | 253 | throw MyError(type: 2); |
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| @@ -298,18 +298,18 @@ class DioUtil { | @@ -298,18 +298,18 @@ class DioUtil { | ||
| 298 | return new BaseRespR(_status, _code, _msg, _data, response); | 298 | return new BaseRespR(_status, _code, _msg, _data, response); |
| 299 | } catch (e) { | 299 | } catch (e) { |
| 300 | return new Future.error(new DioError( | 300 | return new Future.error(new DioError( |
| 301 | - // requestOptions: response.requestOptions, | 301 | + requestOptions: response.requestOptions, |
| 302 | response: response, | 302 | response: response, |
| 303 | error: "data parsing exception...", | 303 | error: "data parsing exception...", |
| 304 | - type: DioErrorType.RESPONSE, | 304 | + type: DioErrorType.response, |
| 305 | )); | 305 | )); |
| 306 | } | 306 | } |
| 307 | } | 307 | } |
| 308 | return new Future.error(new DioError( | 308 | return new Future.error(new DioError( |
| 309 | - // requestOptions: response.requestOptions, | 309 | + requestOptions: response.requestOptions, |
| 310 | response: response, | 310 | response: response, |
| 311 | error: "statusCode: $response.statusCode, service error", | 311 | error: "statusCode: $response.statusCode, service error", |
| 312 | - type: DioErrorType.RESPONSE, | 312 | + type: DioErrorType.response, |
| 313 | )); | 313 | )); |
| 314 | } | 314 | } |
| 315 | 315 |
| @@ -206,7 +206,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | @@ -206,7 +206,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { | ||
| 206 | // } | 206 | // } |
| 207 | }, | 207 | }, |
| 208 | onMapMoveEnd: (MapMove move) async { | 208 | onMapMoveEnd: (MapMove move) async { |
| 209 | - _loadData(move.latLng); | 209 | + _loadData(move.coordinate); |
| 210 | }, | 210 | }, |
| 211 | ), | 211 | ), |
| 212 | Center( | 212 | Center( |
| @@ -2385,7 +2385,7 @@ class _ButtonState extends State<CustomButton> { | @@ -2385,7 +2385,7 @@ class _ButtonState extends State<CustomButton> { | ||
| 2385 | 2385 | ||
| 2386 | inputFormatters: [ | 2386 | inputFormatters: [ |
| 2387 | LengthLimitingTextInputFormatter(3), | 2387 | LengthLimitingTextInputFormatter(3), |
| 2388 | - WhitelistingTextInputFormatter.digitsOnly | 2388 | + FilteringTextInputFormatter.digitsOnly |
| 2389 | ], | 2389 | ], |
| 2390 | //光标颜色 | 2390 | //光标颜色 |
| 2391 | cursorColor: widget.isSelect | 2391 | cursorColor: widget.isSelect |
| @@ -885,7 +885,7 @@ class _ButtonState extends State<CustomButton> { | @@ -885,7 +885,7 @@ class _ButtonState extends State<CustomButton> { | ||
| 885 | 885 | ||
| 886 | inputFormatters: [ | 886 | inputFormatters: [ |
| 887 | LengthLimitingTextInputFormatter(3), | 887 | LengthLimitingTextInputFormatter(3), |
| 888 | - WhitelistingTextInputFormatter.digitsOnly | 888 | + FilteringTextInputFormatter.digitsOnly |
| 889 | ], | 889 | ], |
| 890 | //光标颜色 | 890 | //光标颜色 |
| 891 | cursorColor: widget.isSelect | 891 | cursorColor: widget.isSelect |
| @@ -65,96 +65,101 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -65,96 +65,101 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 65 | 65 | ||
| 66 | @override | 66 | @override |
| 67 | void initState() { | 67 | void initState() { |
| 68 | - // TODO: implement initState | ||
| 69 | super.initState(); | 68 | super.initState(); |
| 70 | - LogUtil.v("home_initState"); | ||
| 71 | - | ||
| 72 | - AzhonAppUpdate.listener( | ||
| 73 | - // () { | ||
| 74 | - // needUpdate = false; | ||
| 75 | - // // print(map['type']); | ||
| 76 | - // } | ||
| 77 | - ); | ||
| 78 | - WidgetsBinding.instance.addObserver(this); | ||
| 79 | - | ||
| 80 | - _currIndex = widget.initialIndex; | ||
| 81 | - _pageController = PageController(initialPage: _currIndex); | ||
| 82 | - pages | ||
| 83 | - // ..add(ChangeNotifierProvider<HomeEnterModel>( | ||
| 84 | - // create: (_) => HomeEnterModel(), | ||
| 85 | - // child: ChangeNotifierProvider<RemarkManagerModel>( | ||
| 86 | - // create: (_) => RemarkManagerModel(), | ||
| 87 | - // child: SafeArea(child: HomeEnterPage()), | ||
| 88 | - // ))) | ||
| 89 | - ..add(SafeArea( | ||
| 90 | - child: MessagePage(), | ||
| 91 | - )) | ||
| 92 | -// ..add(ChangeNotifierProvider<EnterModel>( | ||
| 93 | -// create: (_) => EnterModel(), | ||
| 94 | -// child: SafeArea(child: EnterPage(detailEntity:NotebookDetail.def(context),rid: "-1",)), | ||
| 95 | -// )) | ||
| 96 | - ..add(ChangeNotifierProvider<NoteBookModel>( | ||
| 97 | - create: (_) => NoteBookModel(), | ||
| 98 | - child: SafeArea(child: NoteBookPage()), | ||
| 99 | - )) | ||
| 100 | - ..add(ChangeNotifierProvider<TableManagerModel>( | ||
| 101 | - create: (_) => TableManagerModel(), | ||
| 102 | - child: TableManagerPage(), | ||
| 103 | - )) | ||
| 104 | - ..add(ChangeNotifierProvider<MyModel>( | ||
| 105 | - create: (_) => MyModel(), | ||
| 106 | - child: MyPage(), | ||
| 107 | - )); | ||
| 108 | - WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 109 | - initPlatformState(); | ||
| 110 | - | ||
| 111 | - List<PullMarketingByUidSunModel> data = | ||
| 112 | - Provider.of<UserModel>(context, listen: false) | ||
| 113 | - .pullMarketingByUidSunModel; | ||
| 114 | - if (data != null) { | ||
| 115 | - if (data.length > 0) { | ||
| 116 | - Future.delayed(Duration(milliseconds: 300), () { | ||
| 117 | - DialogUtil.cupertinoAlertDialog(context, | ||
| 118 | - title: "全店任务", | ||
| 119 | - content: "管理员发布了新的任务,请立即查看并完成任务", | ||
| 120 | - lTitle: "稍后提醒", | ||
| 121 | - rTitle: "立即查看", lCallback: () { | ||
| 122 | - print("稍后提醒"); | ||
| 123 | - // 30分钟后重新弹窗 | ||
| 124 | - _startTimerSeller(); | ||
| 125 | - }, rCallback: () { | ||
| 126 | - _endTimerSeller(); | ||
| 127 | - if (data.length == 1) { | ||
| 128 | - //进入营销详情 | ||
| 129 | - NavigatorUtil.goSellerMyMarketingRecordsDetailPage( | ||
| 130 | - context, data[0].mid, | ||
| 131 | - fromNotify: true); | ||
| 132 | - } else { | ||
| 133 | - //进入我的客情首页 | ||
| 134 | - NavigatorUtil.goMyCustomerPage(context); | ||
| 135 | - } | ||
| 136 | - }); | ||
| 137 | - }); | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | - if (widget.initialIndex == 0) return; | ||
| 141 | - _getIntent(); | ||
| 142 | - Future.delayed(Duration(milliseconds: 30000), () { | ||
| 143 | - ContactModel.getInstance().uploadLocalContact(context); | ||
| 144 | - if (needUpdate) { | ||
| 145 | - UpdateModelMy updateModel = new UpdateModelMy(); | ||
| 146 | - updateModel.checkUpdate(context, (version) { | ||
| 147 | - updateModel.showUpdateDialog(context, version); | ||
| 148 | - }, showToast: false); | ||
| 149 | - } | ||
| 150 | - }); | ||
| 151 | - timer = Timer.periodic(Duration(minutes: 3), (_) { | ||
| 152 | - _getAllUnMessages(); | ||
| 153 | - }); | ||
| 154 | - _getUnMsgNum(); | ||
| 155 | - }); | ||
| 156 | } | 69 | } |
| 157 | 70 | ||
| 71 | +// @override | ||
| 72 | +// void initState() { | ||
| 73 | +// // TODO: implement initState | ||
| 74 | +// super.initState(); | ||
| 75 | +// LogUtil.v("home_initState"); | ||
| 76 | + | ||
| 77 | +// AzhonAppUpdate.listener( | ||
| 78 | +// // () { | ||
| 79 | +// // needUpdate = false; | ||
| 80 | +// // // print(map['type']); | ||
| 81 | +// // } | ||
| 82 | +// ); | ||
| 83 | +// WidgetsBinding.instance.addObserver(this); | ||
| 84 | + | ||
| 85 | +// _currIndex = widget.initialIndex; | ||
| 86 | +// _pageController = PageController(initialPage: _currIndex); | ||
| 87 | +// pages | ||
| 88 | +// // ..add(ChangeNotifierProvider<HomeEnterModel>( | ||
| 89 | +// // create: (_) => HomeEnterModel(), | ||
| 90 | +// // child: ChangeNotifierProvider<RemarkManagerModel>( | ||
| 91 | +// // create: (_) => RemarkManagerModel(), | ||
| 92 | +// // child: SafeArea(child: HomeEnterPage()), | ||
| 93 | +// // ))) | ||
| 94 | +// ..add(SafeArea( | ||
| 95 | +// child: MessagePage(), | ||
| 96 | +// )) | ||
| 97 | +// // ..add(ChangeNotifierProvider<EnterModel>( | ||
| 98 | +// // create: (_) => EnterModel(), | ||
| 99 | +// // child: SafeArea(child: EnterPage(detailEntity:NotebookDetail.def(context),rid: "-1",)), | ||
| 100 | +// // )) | ||
| 101 | +// ..add(ChangeNotifierProvider<NoteBookModel>( | ||
| 102 | +// create: (_) => NoteBookModel(), | ||
| 103 | +// child: SafeArea(child: NoteBookPage()), | ||
| 104 | +// )) | ||
| 105 | +// ..add(ChangeNotifierProvider<TableManagerModel>( | ||
| 106 | +// create: (_) => TableManagerModel(), | ||
| 107 | +// child: TableManagerPage(), | ||
| 108 | +// )) | ||
| 109 | +// ..add(ChangeNotifierProvider<MyModel>( | ||
| 110 | +// create: (_) => MyModel(), | ||
| 111 | +// child: MyPage(), | ||
| 112 | +// )); | ||
| 113 | +// WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 114 | +// initPlatformState(); | ||
| 115 | + | ||
| 116 | +// List<PullMarketingByUidSunModel> data = | ||
| 117 | +// Provider.of<UserModel>(context, listen: false) | ||
| 118 | +// .pullMarketingByUidSunModel; | ||
| 119 | +// if (data != null) { | ||
| 120 | +// if (data.length > 0) { | ||
| 121 | +// Future.delayed(Duration(milliseconds: 300), () { | ||
| 122 | +// DialogUtil.cupertinoAlertDialog(context, | ||
| 123 | +// title: "全店任务", | ||
| 124 | +// content: "管理员发布了新的任务,请立即查看并完成任务", | ||
| 125 | +// lTitle: "稍后提醒", | ||
| 126 | +// rTitle: "立即查看", lCallback: () { | ||
| 127 | +// print("稍后提醒"); | ||
| 128 | +// // 30分钟后重新弹窗 | ||
| 129 | +// _startTimerSeller(); | ||
| 130 | +// }, rCallback: () { | ||
| 131 | +// _endTimerSeller(); | ||
| 132 | +// if (data.length == 1) { | ||
| 133 | +// //进入营销详情 | ||
| 134 | +// NavigatorUtil.goSellerMyMarketingRecordsDetailPage( | ||
| 135 | +// context, data[0].mid, | ||
| 136 | +// fromNotify: true); | ||
| 137 | +// } else { | ||
| 138 | +// //进入我的客情首页 | ||
| 139 | +// NavigatorUtil.goMyCustomerPage(context); | ||
| 140 | +// } | ||
| 141 | +// }); | ||
| 142 | +// }); | ||
| 143 | +// } | ||
| 144 | +// } | ||
| 145 | +// if (widget.initialIndex == 0) return; | ||
| 146 | +// _getIntent(); | ||
| 147 | +// Future.delayed(Duration(milliseconds: 30000), () { | ||
| 148 | +// ContactModel.getInstance().uploadLocalContact(context); | ||
| 149 | +// if (needUpdate) { | ||
| 150 | +// UpdateModelMy updateModel = new UpdateModelMy(); | ||
| 151 | +// updateModel.checkUpdate(context, (version) { | ||
| 152 | +// updateModel.showUpdateDialog(context, version); | ||
| 153 | +// }, showToast: false); | ||
| 154 | +// } | ||
| 155 | +// }); | ||
| 156 | +// timer = Timer.periodic(Duration(minutes: 3), (_) { | ||
| 157 | +// _getAllUnMessages(); | ||
| 158 | +// }); | ||
| 159 | +// _getUnMsgNum(); | ||
| 160 | +// }); | ||
| 161 | +// } | ||
| 162 | + | ||
| 158 | _endTimerSeller() { | 163 | _endTimerSeller() { |
| 159 | if (timerSeller != null) { | 164 | if (timerSeller != null) { |
| 160 | timerSeller.cancel(); | 165 | timerSeller.cancel(); |
| @@ -599,6 +604,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -599,6 +604,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 599 | 604 | ||
| 600 | @override | 605 | @override |
| 601 | Widget build(BuildContext context) { | 606 | Widget build(BuildContext context) { |
| 607 | + return Container(width: 300, height: 300, color: Colors.pink); | ||
| 602 | // TODO: implement build | 608 | // TODO: implement build |
| 603 | ScreenUtil.init(context, width: 750, height: 1334); | 609 | ScreenUtil.init(context, width: 750, height: 1334); |
| 604 | return new WillPopScope( | 610 | return new WillPopScope( |
| @@ -674,12 +680,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -674,12 +680,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 674 | ) | 680 | ) |
| 675 | ], | 681 | ], |
| 676 | ), | 682 | ), |
| 677 | - title: Text( | ||
| 678 | - "消息中心", | ||
| 679 | - style: TextStyle( | ||
| 680 | - color: _currIndex == 0 ? _activeColor : _defaultColor, | ||
| 681 | - fontSize: ScreenUtil().setSp(22)), | ||
| 682 | - ), | 683 | + label: |
| 684 | + // Text( | ||
| 685 | + "消息中心", | ||
| 686 | + // style: TextStyle( | ||
| 687 | + // color: _currIndex == 0 ? _activeColor : _defaultColor, | ||
| 688 | + // fontSize: ScreenUtil().setSp(22)), | ||
| 689 | + // ), | ||
| 683 | ), | 690 | ), |
| 684 | // BottomNavigationBarItem( | 691 | // BottomNavigationBarItem( |
| 685 | // icon: Image( | 692 | // icon: Image( |
| @@ -710,12 +717,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -710,12 +717,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 710 | width: ScreenUtil().setWidth(48), | 717 | width: ScreenUtil().setWidth(48), |
| 711 | height: ScreenUtil().setWidth(48), | 718 | height: ScreenUtil().setWidth(48), |
| 712 | ), | 719 | ), |
| 713 | - title: Text( | ||
| 714 | - "已预订", | ||
| 715 | - style: TextStyle( | ||
| 716 | - color: _currIndex == 1 ? _activeColor : _defaultColor, | ||
| 717 | - fontSize: ScreenUtil().setSp(22)), | ||
| 718 | - ), | 720 | + label: |
| 721 | + // Text( | ||
| 722 | + "已预订", | ||
| 723 | + // style: TextStyle( | ||
| 724 | + // color: _currIndex == 1 ? _activeColor : _defaultColor, | ||
| 725 | + // fontSize: ScreenUtil().setSp(22)), | ||
| 726 | + // ), | ||
| 719 | ), | 727 | ), |
| 720 | BottomNavigationBarItem( | 728 | BottomNavigationBarItem( |
| 721 | icon: Image( | 729 | icon: Image( |
| @@ -728,12 +736,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -728,12 +736,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 728 | width: ScreenUtil().setWidth(48), | 736 | width: ScreenUtil().setWidth(48), |
| 729 | height: ScreenUtil().setWidth(48), | 737 | height: ScreenUtil().setWidth(48), |
| 730 | ), | 738 | ), |
| 731 | - title: Text( | ||
| 732 | - "桌位", | ||
| 733 | - style: TextStyle( | ||
| 734 | - color: _currIndex == 2 ? _activeColor : _defaultColor, | ||
| 735 | - fontSize: ScreenUtil().setSp(22)), | ||
| 736 | - ), | 739 | + label: |
| 740 | + // Text( | ||
| 741 | + "桌位", | ||
| 742 | + // style: TextStyle( | ||
| 743 | + // color: _currIndex == 2 ? _activeColor : _defaultColor, | ||
| 744 | + // fontSize: ScreenUtil().setSp(22)), | ||
| 745 | + // ), | ||
| 737 | ), | 746 | ), |
| 738 | BottomNavigationBarItem( | 747 | BottomNavigationBarItem( |
| 739 | icon: Image( | 748 | icon: Image( |
| @@ -746,12 +755,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | @@ -746,12 +755,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { | ||
| 746 | width: ScreenUtil().setWidth(48), | 755 | width: ScreenUtil().setWidth(48), |
| 747 | height: ScreenUtil().setWidth(48), | 756 | height: ScreenUtil().setWidth(48), |
| 748 | ), | 757 | ), |
| 749 | - title: Text( | ||
| 750 | - "我的", | ||
| 751 | - style: TextStyle( | ||
| 752 | - color: _currIndex == 3 ? _activeColor : _defaultColor, | ||
| 753 | - fontSize: ScreenUtil().setSp(22)), | ||
| 754 | - ), | 758 | + label: |
| 759 | + // Text( | ||
| 760 | + "我的", | ||
| 761 | + // style: TextStyle( | ||
| 762 | + // color: _currIndex == 3 ? _activeColor : _defaultColor, | ||
| 763 | + // fontSize: ScreenUtil().setSp(22)), | ||
| 764 | + // ), | ||
| 755 | ), | 765 | ), |
| 756 | ], | 766 | ], |
| 757 | type: BottomNavigationBarType.fixed, | 767 | type: BottomNavigationBarType.fixed, |
| @@ -1554,7 +1554,7 @@ class _ButtonState extends State<CustomButton> { | @@ -1554,7 +1554,7 @@ class _ButtonState extends State<CustomButton> { | ||
| 1554 | 1554 | ||
| 1555 | inputFormatters: [ | 1555 | inputFormatters: [ |
| 1556 | LengthLimitingTextInputFormatter(3), | 1556 | LengthLimitingTextInputFormatter(3), |
| 1557 | - WhitelistingTextInputFormatter.digitsOnly | 1557 | + FilteringTextInputFormatter.digitsOnly |
| 1558 | ], | 1558 | ], |
| 1559 | //光标颜色 | 1559 | //光标颜色 |
| 1560 | cursorColor: widget.isSelect | 1560 | cursorColor: widget.isSelect |
| @@ -174,7 +174,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -174,7 +174,7 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 174 | }); | 174 | }); |
| 175 | } else { | 175 | } else { |
| 176 | _checkWechat(); | 176 | _checkWechat(); |
| 177 | - _getWxCode(); | 177 | + _getWxCode(); |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| 180 | 180 | ||
| @@ -413,510 +413,504 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | @@ -413,510 +413,504 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver { | ||
| 413 | final double prefixIconWidth = ScreenUtil().setWidth(24); | 413 | final double prefixIconWidth = ScreenUtil().setWidth(24); |
| 414 | 414 | ||
| 415 | return Scaffold( | 415 | return Scaffold( |
| 416 | - backgroundColor: MyColours.color_ffffff, | ||
| 417 | - body: Container( | ||
| 418 | - width: double.infinity, | ||
| 419 | - height: double.infinity, | ||
| 420 | - child: SingleChildScrollView( | ||
| 421 | - controller: _scrollController, | ||
| 422 | - child: Column( | ||
| 423 | - crossAxisAlignment: CrossAxisAlignment.center, | 416 | + backgroundColor: MyColours.color_ffffff, |
| 417 | + body: Container( | ||
| 418 | + width: double.infinity, | ||
| 419 | + height: double.infinity, | ||
| 420 | + child: SingleChildScrollView( | ||
| 421 | + controller: _scrollController, | ||
| 422 | + child: Column( | ||
| 423 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 424 | + children: <Widget>[ | ||
| 425 | + // VEmptyView(218 - App.statusBarHeight), | ||
| 426 | + VEmptyView(80 + App.statusBarHeight), | ||
| 427 | + Padding( | ||
| 428 | + padding: EdgeInsets.symmetric( | ||
| 429 | + horizontal: ScreenUtil().setWidth(40)), | ||
| 430 | + child: Row( | ||
| 431 | + mainAxisAlignment: MainAxisAlignment.start, | ||
| 432 | + children: [ | ||
| 433 | + Image.asset( | ||
| 434 | + "assets/logo.png", | ||
| 435 | + width: ScreenUtil().setWidth(40 * 2), | ||
| 436 | + height: ScreenUtil().setWidth(40 * 2), | ||
| 437 | + ) | ||
| 438 | + ], | ||
| 439 | + )), | ||
| 440 | + VEmptyView(120), | ||
| 441 | + Image.asset( | ||
| 442 | + Utils.getImgPath('login_bg'), | ||
| 443 | + ), | ||
| 444 | + // Container( | ||
| 445 | + // height: ScreenUtil().setHeight(84), | ||
| 446 | + // width: ScreenUtil().setWidth(611), | ||
| 447 | + // padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)), | ||
| 448 | + // alignment: Alignment.center, | ||
| 449 | + // decoration: BoxDecoration( | ||
| 450 | + // border: Border.all( | ||
| 451 | + // color: MyColours.color_bff6f7, | ||
| 452 | + // width: ScreenUtil().setWidth(2)), | ||
| 453 | + // borderRadius: | ||
| 454 | + // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 455 | + // child: Row( | ||
| 456 | + // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 457 | + // children: <Widget>[ | ||
| 458 | + // Image.asset( | ||
| 459 | + // "assets/icon_sellercode.png", | ||
| 460 | + // width: prefixIconWidth, | ||
| 461 | + // ), | ||
| 462 | + // HEmptyView(26), | ||
| 463 | + // Center( | ||
| 464 | + // child: Text( | ||
| 465 | + // "商户编号", | ||
| 466 | + // style: TextStyle( | ||
| 467 | + // color: MyColours.color_353535, | ||
| 468 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 469 | + // )), | ||
| 470 | + // Expanded( | ||
| 471 | + // child: Container( | ||
| 472 | + // height: ScreenUtil().setHeight(84), | ||
| 473 | + // padding: EdgeInsets.only( | ||
| 474 | + // left: ScreenUtil().setWidth(20), | ||
| 475 | + // right: ScreenUtil().setWidth(20), | ||
| 476 | + // top: ScreenUtil().setWidth(8)), | ||
| 477 | + // child: TextField( | ||
| 478 | + // controller: _sellerCodeController, | ||
| 479 | + // focusNode: _sellerCodeFocusNode, | ||
| 480 | + // // autofocus: _sellerCodeController.text.isEmpty, | ||
| 481 | + // style: TextStyle( | ||
| 482 | + // color: MyColours.color_353535, | ||
| 483 | + // fontSize: ScreenUtil().setSp(28), | ||
| 484 | + // textBaseline: TextBaseline.alphabetic), | ||
| 485 | + // // textAlignVertical: TextAlignVertical.center, | ||
| 486 | + // decoration: InputDecoration( | ||
| 487 | + // hintText: "请输入6位商户编码", | ||
| 488 | + // hintStyle: TextStyle( | ||
| 489 | + // color: MyColours.color_c1c1c1, | ||
| 490 | + // fontSize: ScreenUtil().setSp(28), | ||
| 491 | + // ), | ||
| 492 | + // border: OutlineInputBorder( | ||
| 493 | + // borderSide: BorderSide.none), | ||
| 494 | + // contentPadding: EdgeInsets.zero, | ||
| 495 | + // ), | ||
| 496 | + // onChanged: (_) { | ||
| 497 | + // setActivate(); | ||
| 498 | + // }, | ||
| 499 | + // keyboardType: TextInputType.number, | ||
| 500 | + // )), | ||
| 501 | + // ) | ||
| 502 | + // ], | ||
| 503 | + // )), | ||
| 504 | + | ||
| 505 | + // Container( | ||
| 506 | + // height: ScreenUtil().setHeight(84), | ||
| 507 | + // width: ScreenUtil().setWidth(611), | ||
| 508 | + // padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)), | ||
| 509 | + // margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)), | ||
| 510 | + // alignment: Alignment.center, | ||
| 511 | + // decoration: BoxDecoration( | ||
| 512 | + // border: Border.all( | ||
| 513 | + // color: MyColours.color_bff6f7, | ||
| 514 | + // width: ScreenUtil().setWidth(2)), | ||
| 515 | + // borderRadius: | ||
| 516 | + // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 517 | + // child: Row( | ||
| 518 | + // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 519 | + // children: <Widget>[ | ||
| 520 | + // Image.asset( | ||
| 521 | + // "assets/icon_account.png", | ||
| 522 | + // width: prefixIconWidth, | ||
| 523 | + // ), | ||
| 524 | + // HEmptyView(26), | ||
| 525 | + // Text( | ||
| 526 | + // "工 号", | ||
| 527 | + // style: TextStyle( | ||
| 528 | + // color: MyColours.color_353535, | ||
| 529 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 530 | + // ), | ||
| 531 | + // Expanded( | ||
| 532 | + // child: Container( | ||
| 533 | + // height: ScreenUtil().setHeight(84), | ||
| 534 | + // padding: EdgeInsets.only( | ||
| 535 | + // left: ScreenUtil().setWidth(20), | ||
| 536 | + // right: ScreenUtil().setWidth(20), | ||
| 537 | + // top: ScreenUtil().setWidth(8)), | ||
| 538 | + // child: TextField( | ||
| 539 | + // controller: _accountController, | ||
| 540 | + // focusNode: _accountFocusNode, | ||
| 541 | + // style: TextStyle( | ||
| 542 | + // color: MyColours.color_353535, | ||
| 543 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 544 | + // decoration: InputDecoration( | ||
| 545 | + // hintText: "请输入4位工号", | ||
| 546 | + // hintStyle: TextStyle( | ||
| 547 | + // color: MyColours.color_c1c1c1, | ||
| 548 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 549 | + // border: OutlineInputBorder( | ||
| 550 | + // borderSide: BorderSide.none), | ||
| 551 | + // contentPadding: EdgeInsets.zero, | ||
| 552 | + // ), | ||
| 553 | + // onChanged: (_) { | ||
| 554 | + // setActivate(); | ||
| 555 | + // }, | ||
| 556 | + // keyboardType: TextInputType.number, | ||
| 557 | + // ), | ||
| 558 | + // )) | ||
| 559 | + // ], | ||
| 560 | + // )), | ||
| 561 | + // Container( | ||
| 562 | + // height: ScreenUtil().setHeight(84), | ||
| 563 | + // width: ScreenUtil().setWidth(611), | ||
| 564 | + // padding: EdgeInsets.only( | ||
| 565 | + // left: ScreenUtil().setWidth(20), | ||
| 566 | + // right: ScreenUtil().setWidth(27)), | ||
| 567 | + // margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)), | ||
| 568 | + // alignment: Alignment.center, | ||
| 569 | + // decoration: BoxDecoration( | ||
| 570 | + // border: Border.all( | ||
| 571 | + // color: MyColours.color_bff6f7, | ||
| 572 | + // width: ScreenUtil().setWidth(2)), | ||
| 573 | + // borderRadius: | ||
| 574 | + // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 575 | + // child: Row( | ||
| 576 | + // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 577 | + // children: <Widget>[ | ||
| 578 | + // Image.asset( | ||
| 579 | + // "assets/icon_pwd.png", | ||
| 580 | + // width: prefixIconWidth, | ||
| 581 | + // ), | ||
| 582 | + // HEmptyView(26), | ||
| 583 | + // Text( | ||
| 584 | + // "密 码", | ||
| 585 | + // style: TextStyle( | ||
| 586 | + // color: MyColours.color_353535, | ||
| 587 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 588 | + // ), | ||
| 589 | + // Expanded( | ||
| 590 | + // child: Container( | ||
| 591 | + // height: ScreenUtil().setHeight(84), | ||
| 592 | + // padding: EdgeInsets.only( | ||
| 593 | + // left: ScreenUtil().setWidth(20), | ||
| 594 | + // right: ScreenUtil().setWidth(20), | ||
| 595 | + // top: ScreenUtil().setWidth(8)), | ||
| 596 | + // child: TextField( | ||
| 597 | + // controller: _pwdController, | ||
| 598 | + // focusNode: _pwdFocusNode, | ||
| 599 | + // // autofocus: _sellerCodeController.text.isNotEmpty && | ||
| 600 | + // // _accountController.text.isNotEmpty && | ||
| 601 | + // // _pwdController.text.isEmpty, | ||
| 602 | + // style: TextStyle( | ||
| 603 | + // color: MyColours.color_353535, | ||
| 604 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 605 | + // decoration: InputDecoration( | ||
| 606 | + // hintText: "请输入密码", | ||
| 607 | + // hintStyle: TextStyle( | ||
| 608 | + // color: MyColours.color_c1c1c1, | ||
| 609 | + // fontSize: ScreenUtil().setSp(28)), | ||
| 610 | + // border: OutlineInputBorder( | ||
| 611 | + // borderSide: BorderSide.none), | ||
| 612 | + // contentPadding: EdgeInsets.zero, | ||
| 613 | + // ), | ||
| 614 | + // onChanged: (_) { | ||
| 615 | + // setActivate(); | ||
| 616 | + // }, | ||
| 617 | + // obscureText: obscureText, | ||
| 618 | + // keyboardType: TextInputType.text, | ||
| 619 | + // )), | ||
| 620 | + // ), | ||
| 621 | + // GestureDetector( | ||
| 622 | + // child: Padding( | ||
| 623 | + // padding: EdgeInsets.all(ScreenUtil().setWidth(10)), | ||
| 624 | + // child: Image.asset( | ||
| 625 | + // obscureText | ||
| 626 | + // ? "assets/icon_pwd_show.png" | ||
| 627 | + // : "assets/icon_pwd_hide.png", | ||
| 628 | + // width: ScreenUtil().setWidth(35), | ||
| 629 | + // height: ScreenUtil().setHeight(24), | ||
| 630 | + // ), | ||
| 631 | + // ), | ||
| 632 | + // onTap: () { | ||
| 633 | + // setState(() { | ||
| 634 | + // obscureText = !obscureText; | ||
| 635 | + // }); | ||
| 636 | + // }, | ||
| 637 | + // ) | ||
| 638 | + // ], | ||
| 639 | + // )), | ||
| 640 | + | ||
| 641 | + // Container( | ||
| 642 | + // width: ScreenUtil().setWidth(611), | ||
| 643 | + // margin: EdgeInsets.only(top: ScreenUtil().setHeight(16)), | ||
| 644 | + // alignment: Alignment.centerLeft, | ||
| 645 | + // child: Text( | ||
| 646 | + // errorText, | ||
| 647 | + // // 'hfhfhf', | ||
| 648 | + // style: TextStyle( | ||
| 649 | + // color: MyColours.color_d93535, | ||
| 650 | + // fontSize: ScreenUtil().setSp(16)), | ||
| 651 | + // ), | ||
| 652 | + // ), | ||
| 653 | + VEmptyView(60), | ||
| 654 | + // Consumer<UserModel>( | ||
| 655 | + // builder: | ||
| 656 | + // (BuildContext context, UserModel value, Widget child) { | ||
| 657 | + // return GestureDetector( | ||
| 658 | + // onTap: () { | ||
| 659 | + // if (!isActivate) return; | ||
| 660 | + // if (!_check) { | ||
| 661 | + // Utils.showToast('请先仔细阅读并同意协议'); | ||
| 662 | + // return; | ||
| 663 | + // } | ||
| 664 | + // if (App.sp.containsKey('unionid')) { | ||
| 665 | + // //微信登陆的时候,退出清空数据 | ||
| 666 | + // App.sp.remove('openid'); | ||
| 667 | + // App.sp.remove("unionid"); | ||
| 668 | + // } | ||
| 669 | + // Map<String, String> params = { | ||
| 670 | + // "seller_code": "${_sellerCodeController.text}", | ||
| 671 | + // "alias": "ssahdahgdafgahjkhakjgh", | ||
| 672 | + // "account": "${_accountController.text}", | ||
| 673 | + // "password": "${_pwdController.text}" | ||
| 674 | + // }; | ||
| 675 | + // value.login(context, params).then((value) { | ||
| 676 | + // setState(() { | ||
| 677 | + // errorText = value ?? ""; | ||
| 678 | + // }); | ||
| 679 | + // }); | ||
| 680 | + // }, | ||
| 681 | + // child: Container( | ||
| 682 | + // height: ScreenUtil().setWidth(84), | ||
| 683 | + // width: ScreenUtil().setWidth(611), | ||
| 684 | + // alignment: Alignment.center, | ||
| 685 | + // decoration: BoxDecoration( | ||
| 686 | + // color: isActivate | ||
| 687 | + // ? MyColours.color_2bb5b7 | ||
| 688 | + // : MyColours.color_2bb5b7, | ||
| 689 | + // boxShadow: [ | ||
| 690 | + // BoxShadow( | ||
| 691 | + // color: MyColours.color_26000000, | ||
| 692 | + // offset: Offset(0, ScreenUtil().setWidth(4)), | ||
| 693 | + // ) | ||
| 694 | + // ], | ||
| 695 | + // borderRadius: BorderRadius.all( | ||
| 696 | + // Radius.circular(ScreenUtil().setWidth(8)))), | ||
| 697 | + // child: Text( | ||
| 698 | + // "登录", | ||
| 699 | + // style: TextStyle( | ||
| 700 | + // color: MyColours.color_ffffff, | ||
| 701 | + // fontSize: ScreenUtil().setSp(34)), | ||
| 702 | + // ), | ||
| 703 | + // ), | ||
| 704 | + // ); | ||
| 705 | + // }, | ||
| 706 | + // ), | ||
| 707 | + | ||
| 708 | + Row( | ||
| 709 | + // mainAxisSize: MainAxisSize.min, | ||
| 710 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 424 | children: <Widget>[ | 711 | children: <Widget>[ |
| 425 | - // VEmptyView(218 - App.statusBarHeight), | ||
| 426 | - VEmptyView(80 + App.statusBarHeight), | ||
| 427 | - Padding( | ||
| 428 | - padding: EdgeInsets.symmetric( | ||
| 429 | - horizontal: ScreenUtil().setWidth(40)), | ||
| 430 | - child: Row( | ||
| 431 | - mainAxisAlignment: MainAxisAlignment.start, | ||
| 432 | - children: [ | ||
| 433 | - Image.asset( | ||
| 434 | - "assets/logo.png", | ||
| 435 | - width: ScreenUtil().setWidth(40 * 2), | ||
| 436 | - height: ScreenUtil().setWidth(40 * 2), | ||
| 437 | - ) | ||
| 438 | - ], | 712 | + InkWell( |
| 713 | + onTap: () { | ||
| 714 | + setState(() { | ||
| 715 | + _check = !_check; | ||
| 716 | + }); | ||
| 717 | + }, | ||
| 718 | + child: Container( | ||
| 719 | + alignment: Alignment.topCenter, | ||
| 720 | + // color: Colors.red, | ||
| 721 | + height: ScreenUtil().setWidth(110), | ||
| 722 | + padding: EdgeInsets.only( | ||
| 723 | + right: ScreenUtil().setWidth(30), | ||
| 724 | + left: ScreenUtil().setWidth(102), | ||
| 725 | + bottom: ScreenUtil().setWidth(10)), | ||
| 726 | + child: Image.asset( | ||
| 727 | + _check | ||
| 728 | + ? "assets/mine_radio_sel.png" | ||
| 729 | + : "assets/mine_radio_nor.png", | ||
| 730 | + width: ScreenUtil().setWidth(26), | ||
| 731 | + height: ScreenUtil().setWidth(26)), | ||
| 439 | )), | 732 | )), |
| 440 | - VEmptyView(120), | ||
| 441 | - Image.asset( | ||
| 442 | - Utils.getImgPath('login_bg'), | 733 | + // HEmptyView(30), |
| 734 | + Padding( | ||
| 735 | + padding: EdgeInsets.only(top: ScreenUtil().setWidth(2)), | ||
| 736 | + child: Text( | ||
| 737 | + '已阅读并同意', | ||
| 738 | + style: TextStyle( | ||
| 739 | + fontSize: ScreenUtil().setSp(24), | ||
| 740 | + color: MyColours.color_999999), | ||
| 741 | + ), | ||
| 443 | ), | 742 | ), |
| 444 | - // Container( | ||
| 445 | - // height: ScreenUtil().setHeight(84), | ||
| 446 | - // width: ScreenUtil().setWidth(611), | ||
| 447 | - // padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)), | ||
| 448 | - // alignment: Alignment.center, | ||
| 449 | - // decoration: BoxDecoration( | ||
| 450 | - // border: Border.all( | ||
| 451 | - // color: MyColours.color_bff6f7, | ||
| 452 | - // width: ScreenUtil().setWidth(2)), | ||
| 453 | - // borderRadius: | ||
| 454 | - // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 455 | - // child: Row( | ||
| 456 | - // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 457 | - // children: <Widget>[ | ||
| 458 | - // Image.asset( | ||
| 459 | - // "assets/icon_sellercode.png", | ||
| 460 | - // width: prefixIconWidth, | ||
| 461 | - // ), | ||
| 462 | - // HEmptyView(26), | ||
| 463 | - // Center( | ||
| 464 | - // child: Text( | ||
| 465 | - // "商户编号", | ||
| 466 | - // style: TextStyle( | ||
| 467 | - // color: MyColours.color_353535, | ||
| 468 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 469 | - // )), | ||
| 470 | - // Expanded( | ||
| 471 | - // child: Container( | ||
| 472 | - // height: ScreenUtil().setHeight(84), | ||
| 473 | - // padding: EdgeInsets.only( | ||
| 474 | - // left: ScreenUtil().setWidth(20), | ||
| 475 | - // right: ScreenUtil().setWidth(20), | ||
| 476 | - // top: ScreenUtil().setWidth(8)), | ||
| 477 | - // child: TextField( | ||
| 478 | - // controller: _sellerCodeController, | ||
| 479 | - // focusNode: _sellerCodeFocusNode, | ||
| 480 | - // // autofocus: _sellerCodeController.text.isEmpty, | ||
| 481 | - // style: TextStyle( | ||
| 482 | - // color: MyColours.color_353535, | ||
| 483 | - // fontSize: ScreenUtil().setSp(28), | ||
| 484 | - // textBaseline: TextBaseline.alphabetic), | ||
| 485 | - // // textAlignVertical: TextAlignVertical.center, | ||
| 486 | - // decoration: InputDecoration( | ||
| 487 | - // hintText: "请输入6位商户编码", | ||
| 488 | - // hintStyle: TextStyle( | ||
| 489 | - // color: MyColours.color_c1c1c1, | ||
| 490 | - // fontSize: ScreenUtil().setSp(28), | ||
| 491 | - // ), | ||
| 492 | - // border: OutlineInputBorder( | ||
| 493 | - // borderSide: BorderSide.none), | ||
| 494 | - // contentPadding: EdgeInsets.zero, | ||
| 495 | - // ), | ||
| 496 | - // onChanged: (_) { | ||
| 497 | - // setActivate(); | ||
| 498 | - // }, | ||
| 499 | - // keyboardType: TextInputType.number, | ||
| 500 | - // )), | ||
| 501 | - // ) | ||
| 502 | - // ], | ||
| 503 | - // )), | ||
| 504 | - | ||
| 505 | - // Container( | ||
| 506 | - // height: ScreenUtil().setHeight(84), | ||
| 507 | - // width: ScreenUtil().setWidth(611), | ||
| 508 | - // padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)), | ||
| 509 | - // margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)), | ||
| 510 | - // alignment: Alignment.center, | ||
| 511 | - // decoration: BoxDecoration( | ||
| 512 | - // border: Border.all( | ||
| 513 | - // color: MyColours.color_bff6f7, | ||
| 514 | - // width: ScreenUtil().setWidth(2)), | ||
| 515 | - // borderRadius: | ||
| 516 | - // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 517 | - // child: Row( | ||
| 518 | - // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 519 | - // children: <Widget>[ | ||
| 520 | - // Image.asset( | ||
| 521 | - // "assets/icon_account.png", | ||
| 522 | - // width: prefixIconWidth, | ||
| 523 | - // ), | ||
| 524 | - // HEmptyView(26), | ||
| 525 | - // Text( | ||
| 526 | - // "工 号", | ||
| 527 | - // style: TextStyle( | ||
| 528 | - // color: MyColours.color_353535, | ||
| 529 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 530 | - // ), | ||
| 531 | - // Expanded( | ||
| 532 | - // child: Container( | ||
| 533 | - // height: ScreenUtil().setHeight(84), | ||
| 534 | - // padding: EdgeInsets.only( | ||
| 535 | - // left: ScreenUtil().setWidth(20), | ||
| 536 | - // right: ScreenUtil().setWidth(20), | ||
| 537 | - // top: ScreenUtil().setWidth(8)), | ||
| 538 | - // child: TextField( | ||
| 539 | - // controller: _accountController, | ||
| 540 | - // focusNode: _accountFocusNode, | ||
| 541 | - // style: TextStyle( | ||
| 542 | - // color: MyColours.color_353535, | ||
| 543 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 544 | - // decoration: InputDecoration( | ||
| 545 | - // hintText: "请输入4位工号", | ||
| 546 | - // hintStyle: TextStyle( | ||
| 547 | - // color: MyColours.color_c1c1c1, | ||
| 548 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 549 | - // border: OutlineInputBorder( | ||
| 550 | - // borderSide: BorderSide.none), | ||
| 551 | - // contentPadding: EdgeInsets.zero, | ||
| 552 | - // ), | ||
| 553 | - // onChanged: (_) { | ||
| 554 | - // setActivate(); | ||
| 555 | - // }, | ||
| 556 | - // keyboardType: TextInputType.number, | ||
| 557 | - // ), | ||
| 558 | - // )) | ||
| 559 | - // ], | ||
| 560 | - // )), | ||
| 561 | - // Container( | ||
| 562 | - // height: ScreenUtil().setHeight(84), | ||
| 563 | - // width: ScreenUtil().setWidth(611), | ||
| 564 | - // padding: EdgeInsets.only( | ||
| 565 | - // left: ScreenUtil().setWidth(20), | ||
| 566 | - // right: ScreenUtil().setWidth(27)), | ||
| 567 | - // margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)), | ||
| 568 | - // alignment: Alignment.center, | ||
| 569 | - // decoration: BoxDecoration( | ||
| 570 | - // border: Border.all( | ||
| 571 | - // color: MyColours.color_bff6f7, | ||
| 572 | - // width: ScreenUtil().setWidth(2)), | ||
| 573 | - // borderRadius: | ||
| 574 | - // BorderRadius.circular(ScreenUtil().setWidth(8))), | ||
| 575 | - // child: Row( | ||
| 576 | - // crossAxisAlignment: CrossAxisAlignment.center, | ||
| 577 | - // children: <Widget>[ | ||
| 578 | - // Image.asset( | ||
| 579 | - // "assets/icon_pwd.png", | ||
| 580 | - // width: prefixIconWidth, | ||
| 581 | - // ), | ||
| 582 | - // HEmptyView(26), | ||
| 583 | - // Text( | ||
| 584 | - // "密 码", | ||
| 585 | - // style: TextStyle( | ||
| 586 | - // color: MyColours.color_353535, | ||
| 587 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 588 | - // ), | ||
| 589 | - // Expanded( | ||
| 590 | - // child: Container( | ||
| 591 | - // height: ScreenUtil().setHeight(84), | ||
| 592 | - // padding: EdgeInsets.only( | ||
| 593 | - // left: ScreenUtil().setWidth(20), | ||
| 594 | - // right: ScreenUtil().setWidth(20), | ||
| 595 | - // top: ScreenUtil().setWidth(8)), | ||
| 596 | - // child: TextField( | ||
| 597 | - // controller: _pwdController, | ||
| 598 | - // focusNode: _pwdFocusNode, | ||
| 599 | - // // autofocus: _sellerCodeController.text.isNotEmpty && | ||
| 600 | - // // _accountController.text.isNotEmpty && | ||
| 601 | - // // _pwdController.text.isEmpty, | ||
| 602 | - // style: TextStyle( | ||
| 603 | - // color: MyColours.color_353535, | ||
| 604 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 605 | - // decoration: InputDecoration( | ||
| 606 | - // hintText: "请输入密码", | ||
| 607 | - // hintStyle: TextStyle( | ||
| 608 | - // color: MyColours.color_c1c1c1, | ||
| 609 | - // fontSize: ScreenUtil().setSp(28)), | ||
| 610 | - // border: OutlineInputBorder( | ||
| 611 | - // borderSide: BorderSide.none), | ||
| 612 | - // contentPadding: EdgeInsets.zero, | ||
| 613 | - // ), | ||
| 614 | - // onChanged: (_) { | ||
| 615 | - // setActivate(); | ||
| 616 | - // }, | ||
| 617 | - // obscureText: obscureText, | ||
| 618 | - // keyboardType: TextInputType.text, | ||
| 619 | - // )), | ||
| 620 | - // ), | ||
| 621 | - // GestureDetector( | ||
| 622 | - // child: Padding( | ||
| 623 | - // padding: EdgeInsets.all(ScreenUtil().setWidth(10)), | ||
| 624 | - // child: Image.asset( | ||
| 625 | - // obscureText | ||
| 626 | - // ? "assets/icon_pwd_show.png" | ||
| 627 | - // : "assets/icon_pwd_hide.png", | ||
| 628 | - // width: ScreenUtil().setWidth(35), | ||
| 629 | - // height: ScreenUtil().setHeight(24), | ||
| 630 | - // ), | ||
| 631 | - // ), | ||
| 632 | - // onTap: () { | ||
| 633 | - // setState(() { | ||
| 634 | - // obscureText = !obscureText; | ||
| 635 | - // }); | ||
| 636 | - // }, | ||
| 637 | - // ) | ||
| 638 | - // ], | ||
| 639 | - // )), | ||
| 640 | - | ||
| 641 | - // Container( | ||
| 642 | - // width: ScreenUtil().setWidth(611), | ||
| 643 | - // margin: EdgeInsets.only(top: ScreenUtil().setHeight(16)), | ||
| 644 | - // alignment: Alignment.centerLeft, | ||
| 645 | - // child: Text( | ||
| 646 | - // errorText, | ||
| 647 | - // // 'hfhfhf', | ||
| 648 | - // style: TextStyle( | ||
| 649 | - // color: MyColours.color_d93535, | ||
| 650 | - // fontSize: ScreenUtil().setSp(16)), | ||
| 651 | - // ), | ||
| 652 | - // ), | ||
| 653 | - VEmptyView(60), | ||
| 654 | - // Consumer<UserModel>( | ||
| 655 | - // builder: | ||
| 656 | - // (BuildContext context, UserModel value, Widget child) { | ||
| 657 | - // return GestureDetector( | ||
| 658 | - // onTap: () { | ||
| 659 | - // if (!isActivate) return; | ||
| 660 | - // if (!_check) { | ||
| 661 | - // Utils.showToast('请先仔细阅读并同意协议'); | ||
| 662 | - // return; | ||
| 663 | - // } | ||
| 664 | - // if (App.sp.containsKey('unionid')) { | ||
| 665 | - // //微信登陆的时候,退出清空数据 | ||
| 666 | - // App.sp.remove('openid'); | ||
| 667 | - // App.sp.remove("unionid"); | ||
| 668 | - // } | ||
| 669 | - // Map<String, String> params = { | ||
| 670 | - // "seller_code": "${_sellerCodeController.text}", | ||
| 671 | - // "alias": "ssahdahgdafgahjkhakjgh", | ||
| 672 | - // "account": "${_accountController.text}", | ||
| 673 | - // "password": "${_pwdController.text}" | ||
| 674 | - // }; | ||
| 675 | - // value.login(context, params).then((value) { | ||
| 676 | - // setState(() { | ||
| 677 | - // errorText = value ?? ""; | ||
| 678 | - // }); | ||
| 679 | - // }); | ||
| 680 | - // }, | ||
| 681 | - // child: Container( | ||
| 682 | - // height: ScreenUtil().setWidth(84), | ||
| 683 | - // width: ScreenUtil().setWidth(611), | ||
| 684 | - // alignment: Alignment.center, | ||
| 685 | - // decoration: BoxDecoration( | ||
| 686 | - // color: isActivate | ||
| 687 | - // ? MyColours.color_2bb5b7 | ||
| 688 | - // : MyColours.color_2bb5b7, | ||
| 689 | - // boxShadow: [ | ||
| 690 | - // BoxShadow( | ||
| 691 | - // color: MyColours.color_26000000, | ||
| 692 | - // offset: Offset(0, ScreenUtil().setWidth(4)), | ||
| 693 | - // ) | ||
| 694 | - // ], | ||
| 695 | - // borderRadius: BorderRadius.all( | ||
| 696 | - // Radius.circular(ScreenUtil().setWidth(8)))), | ||
| 697 | - // child: Text( | ||
| 698 | - // "登录", | ||
| 699 | - // style: TextStyle( | ||
| 700 | - // color: MyColours.color_ffffff, | ||
| 701 | - // fontSize: ScreenUtil().setSp(34)), | ||
| 702 | - // ), | ||
| 703 | - // ), | ||
| 704 | - // ); | ||
| 705 | - // }, | ||
| 706 | - // ), | ||
| 707 | - | ||
| 708 | - Row( | ||
| 709 | - // mainAxisSize: MainAxisSize.min, | ||
| 710 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 711 | - children: <Widget>[ | ||
| 712 | - InkWell( | ||
| 713 | - onTap: () { | ||
| 714 | - setState(() { | ||
| 715 | - _check = !_check; | ||
| 716 | - }); | ||
| 717 | - }, | ||
| 718 | - child: Container( | ||
| 719 | - alignment: Alignment.topCenter, | ||
| 720 | - // color: Colors.red, | ||
| 721 | - height: ScreenUtil().setWidth(110), | ||
| 722 | - padding: EdgeInsets.only( | ||
| 723 | - right: ScreenUtil().setWidth(30), | ||
| 724 | - left: ScreenUtil().setWidth(102), | ||
| 725 | - bottom: ScreenUtil().setWidth(10)), | ||
| 726 | - child: Image.asset( | ||
| 727 | - _check | ||
| 728 | - ? "assets/mine_radio_sel.png" | ||
| 729 | - : "assets/mine_radio_nor.png", | ||
| 730 | - width: ScreenUtil().setWidth(26), | ||
| 731 | - height: ScreenUtil().setWidth(26)), | ||
| 732 | - )), | ||
| 733 | - // HEmptyView(30), | ||
| 734 | - Padding( | 743 | + InkWell( |
| 744 | + onTap: () { | ||
| 745 | + NavigatorUtil.goWebPage(context, '软件服务协议', "xy"); | ||
| 746 | + }, | ||
| 747 | + child: Padding( | ||
| 735 | padding: | 748 | padding: |
| 736 | EdgeInsets.only(top: ScreenUtil().setWidth(2)), | 749 | EdgeInsets.only(top: ScreenUtil().setWidth(2)), |
| 737 | child: Text( | 750 | child: Text( |
| 738 | - '已阅读并同意', | 751 | + '《软件服务协议》', |
| 739 | style: TextStyle( | 752 | style: TextStyle( |
| 740 | fontSize: ScreenUtil().setSp(24), | 753 | fontSize: ScreenUtil().setSp(24), |
| 741 | - color: MyColours.color_999999), | ||
| 742 | - ), | ||
| 743 | - ), | ||
| 744 | - InkWell( | ||
| 745 | - onTap: () { | ||
| 746 | - NavigatorUtil.goWebPage(context, '软件服务协议', "xy"); | ||
| 747 | - }, | ||
| 748 | - child: Padding( | ||
| 749 | - padding: EdgeInsets.only( | ||
| 750 | - top: ScreenUtil().setWidth(2)), | ||
| 751 | - child: Text( | ||
| 752 | - '《软件服务协议》', | ||
| 753 | - style: TextStyle( | ||
| 754 | - fontSize: ScreenUtil().setSp(24), | ||
| 755 | - color: MyColours.color_333333), | ||
| 756 | - )), | ||
| 757 | - ), | ||
| 758 | - Padding( | ||
| 759 | - padding: | ||
| 760 | - EdgeInsets.only(top: ScreenUtil().setWidth(2)), | ||
| 761 | - child: Text('及', | ||
| 762 | - style: TextStyle( | ||
| 763 | - fontSize: ScreenUtil().setSp(24), | ||
| 764 | - color: MyColours.color_999999))), | ||
| 765 | - InkWell( | ||
| 766 | - onTap: () { | ||
| 767 | - NavigatorUtil.goWebPage(context, '隐私政策', "zc"); | ||
| 768 | - }, | ||
| 769 | - child: Padding( | ||
| 770 | - padding: EdgeInsets.only( | ||
| 771 | - top: ScreenUtil().setWidth(2)), | ||
| 772 | - child: Text('《隐私政策》', | ||
| 773 | - style: TextStyle( | ||
| 774 | - fontSize: ScreenUtil().setSp(24), | ||
| 775 | - color: MyColours.color_333333))), | ||
| 776 | - ) | ||
| 777 | - ], | 754 | + color: MyColours.color_333333), |
| 755 | + )), | ||
| 778 | ), | 756 | ), |
| 757 | + Padding( | ||
| 758 | + padding: EdgeInsets.only(top: ScreenUtil().setWidth(2)), | ||
| 759 | + child: Text('及', | ||
| 760 | + style: TextStyle( | ||
| 761 | + fontSize: ScreenUtil().setSp(24), | ||
| 762 | + color: MyColours.color_999999))), | ||
| 763 | + InkWell( | ||
| 764 | + onTap: () { | ||
| 765 | + NavigatorUtil.goWebPage(context, '隐私政策', "zc"); | ||
| 766 | + }, | ||
| 767 | + child: Padding( | ||
| 768 | + padding: | ||
| 769 | + EdgeInsets.only(top: ScreenUtil().setWidth(2)), | ||
| 770 | + child: Text('《隐私政策》', | ||
| 771 | + style: TextStyle( | ||
| 772 | + fontSize: ScreenUtil().setSp(24), | ||
| 773 | + color: MyColours.color_333333))), | ||
| 774 | + ) | ||
| 775 | + ], | ||
| 776 | + ), | ||
| 779 | 777 | ||
| 780 | - //微信登录 | ||
| 781 | - Offstage( | ||
| 782 | - offstage: !App.isInstallWx, | ||
| 783 | - child: InkWell( | ||
| 784 | - child: Container( | ||
| 785 | - width: double.infinity, | ||
| 786 | - height: ScreenUtil().setWidth(90), | ||
| 787 | - margin: EdgeInsets.only( | ||
| 788 | - bottom: ScreenUtil().setWidth(30), | ||
| 789 | - right: ScreenUtil().setWidth(80), | ||
| 790 | - left: ScreenUtil().setWidth(80)), | ||
| 791 | - decoration: BoxDecoration( | ||
| 792 | - color: MyColours.color_55AA67, | ||
| 793 | - borderRadius: BorderRadius.circular( | ||
| 794 | - ScreenUtil().setWidth(8))), | ||
| 795 | - child: Row( | ||
| 796 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 797 | - children: [ | ||
| 798 | - Image.asset( | ||
| 799 | - Utils.getImgPath('icon_wechat_login'), | ||
| 800 | - width: ScreenUtil().setWidth(46)), | ||
| 801 | - HEmptyView(20), | ||
| 802 | - Text('微信登录', | ||
| 803 | - style: TextStyle( | ||
| 804 | - color: MyColours.color_ffffff, | ||
| 805 | - fontSize: ScreenUtil().setSp(28), | ||
| 806 | - fontWeight: FontWeight.bold)), | ||
| 807 | - ], | ||
| 808 | - )), | ||
| 809 | - onTap: () { | ||
| 810 | - if (!_check) { | ||
| 811 | - DialogUtil.openAlertDialogLogin(context, 500, | ||
| 812 | - onTap: () { | ||
| 813 | - Navigator.pop(context); | ||
| 814 | - _wxLogin(); | ||
| 815 | - }); | ||
| 816 | - return; | ||
| 817 | - } | 778 | + //微信登录 |
| 779 | + Offstage( | ||
| 780 | + offstage: !App.isInstallWx, | ||
| 781 | + child: InkWell( | ||
| 782 | + child: Container( | ||
| 783 | + width: double.infinity, | ||
| 784 | + height: ScreenUtil().setWidth(90), | ||
| 785 | + margin: EdgeInsets.only( | ||
| 786 | + bottom: ScreenUtil().setWidth(30), | ||
| 787 | + right: ScreenUtil().setWidth(80), | ||
| 788 | + left: ScreenUtil().setWidth(80)), | ||
| 789 | + decoration: BoxDecoration( | ||
| 790 | + color: MyColours.color_55AA67, | ||
| 791 | + borderRadius: BorderRadius.circular( | ||
| 792 | + ScreenUtil().setWidth(8))), | ||
| 793 | + child: Row( | ||
| 794 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 795 | + children: [ | ||
| 796 | + Image.asset(Utils.getImgPath('icon_wechat_login'), | ||
| 797 | + width: ScreenUtil().setWidth(46)), | ||
| 798 | + HEmptyView(20), | ||
| 799 | + Text('微信登录', | ||
| 800 | + style: TextStyle( | ||
| 801 | + color: MyColours.color_ffffff, | ||
| 802 | + fontSize: ScreenUtil().setSp(28), | ||
| 803 | + fontWeight: FontWeight.bold)), | ||
| 804 | + ], | ||
| 805 | + )), | ||
| 806 | + onTap: () { | ||
| 807 | + if (!_check) { | ||
| 808 | + DialogUtil.openAlertDialogLogin(context, 500, | ||
| 809 | + onTap: () { | ||
| 810 | + Navigator.pop(context); | ||
| 818 | _wxLogin(); | 811 | _wxLogin(); |
| 819 | - }, | ||
| 820 | - )), | ||
| 821 | - //账号登录 | ||
| 822 | - Consumer<UserModel>(builder: | ||
| 823 | - (BuildContext context, UserModel value, Widget child) { | ||
| 824 | - return InkWell( | ||
| 825 | - child: Container( | ||
| 826 | - width: double.infinity, | ||
| 827 | - height: ScreenUtil().setWidth(90), | ||
| 828 | - margin: EdgeInsets.only( | ||
| 829 | - bottom: ScreenUtil().setWidth(30), | ||
| 830 | - right: ScreenUtil().setWidth(80), | ||
| 831 | - left: ScreenUtil().setWidth(80)), | ||
| 832 | - decoration: BoxDecoration( | ||
| 833 | - color: MyColours.color_41444B, | ||
| 834 | - borderRadius: BorderRadius.circular( | ||
| 835 | - ScreenUtil().setWidth(8))), | ||
| 836 | - child: Row( | ||
| 837 | - mainAxisAlignment: MainAxisAlignment.center, | ||
| 838 | - children: [ | ||
| 839 | - Text('一键订账号登录', | ||
| 840 | - style: TextStyle( | ||
| 841 | - color: MyColours.color_ffffff, | ||
| 842 | - fontSize: ScreenUtil().setSp(28), | ||
| 843 | - fontWeight: FontWeight.bold)), | ||
| 844 | - ], | ||
| 845 | - )), | ||
| 846 | - onTap: () { | ||
| 847 | - if (!_check) { | ||
| 848 | - DialogUtil.openAlertDialogLogin(context, 500, | ||
| 849 | - onTap: () { | ||
| 850 | - Navigator.pop(context); | ||
| 851 | - NavigatorUtil.goAccountLoginPage(context); | ||
| 852 | - }); | ||
| 853 | - return; | ||
| 854 | - } | 812 | + }); |
| 813 | + return; | ||
| 814 | + } | ||
| 815 | + _wxLogin(); | ||
| 816 | + }, | ||
| 817 | + )), | ||
| 818 | + //账号登录 | ||
| 819 | + Consumer<UserModel>(builder: | ||
| 820 | + (BuildContext context, UserModel value, Widget child) { | ||
| 821 | + return InkWell( | ||
| 822 | + child: Container( | ||
| 823 | + width: double.infinity, | ||
| 824 | + height: ScreenUtil().setWidth(90), | ||
| 825 | + margin: EdgeInsets.only( | ||
| 826 | + bottom: ScreenUtil().setWidth(30), | ||
| 827 | + right: ScreenUtil().setWidth(80), | ||
| 828 | + left: ScreenUtil().setWidth(80)), | ||
| 829 | + decoration: BoxDecoration( | ||
| 830 | + color: MyColours.color_41444B, | ||
| 831 | + borderRadius: BorderRadius.circular( | ||
| 832 | + ScreenUtil().setWidth(8))), | ||
| 833 | + child: Row( | ||
| 834 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 835 | + children: [ | ||
| 836 | + Text('一键订账号登录', | ||
| 837 | + style: TextStyle( | ||
| 838 | + color: MyColours.color_ffffff, | ||
| 839 | + fontSize: ScreenUtil().setSp(28), | ||
| 840 | + fontWeight: FontWeight.bold)), | ||
| 841 | + ], | ||
| 842 | + )), | ||
| 843 | + onTap: () { | ||
| 844 | + if (!_check) { | ||
| 845 | + DialogUtil.openAlertDialogLogin(context, 500, | ||
| 846 | + onTap: () { | ||
| 847 | + Navigator.pop(context); | ||
| 855 | NavigatorUtil.goAccountLoginPage(context); | 848 | NavigatorUtil.goAccountLoginPage(context); |
| 856 | }); | 849 | }); |
| 857 | - }), | ||
| 858 | - // ios登录 | ||
| 859 | - Platform.isAndroid | ||
| 860 | - ? Text('') | ||
| 861 | - : Consumer<UserModel>(builder: (BuildContext context, | ||
| 862 | - UserModel value, Widget child) { | ||
| 863 | - return InkWell( | ||
| 864 | - child: Container( | ||
| 865 | - width: double.infinity, | ||
| 866 | - height: ScreenUtil().setWidth(90), | ||
| 867 | - margin: EdgeInsets.only( | ||
| 868 | - bottom: ScreenUtil().setWidth(30), | ||
| 869 | - right: ScreenUtil().setWidth(80), | ||
| 870 | - left: ScreenUtil().setWidth(80)), | ||
| 871 | - decoration: BoxDecoration( | ||
| 872 | - color: MyColours.color_ffffff, | ||
| 873 | - border: Border.all( | ||
| 874 | - color: MyColours.color_E4E4E4, | ||
| 875 | - width: ScreenUtil().setWidth(2)), | ||
| 876 | - borderRadius: BorderRadius.circular( | ||
| 877 | - ScreenUtil().setWidth(8))), | ||
| 878 | - child: Row( | ||
| 879 | - mainAxisAlignment: | ||
| 880 | - MainAxisAlignment.center, | ||
| 881 | - children: [ | ||
| 882 | - Image.asset( | ||
| 883 | - Utils.getImgPath( | ||
| 884 | - 'icon_apple_login'), | ||
| 885 | - width: ScreenUtil().setWidth(46)), | ||
| 886 | - HEmptyView(20), | ||
| 887 | - Text('通过 Apple 登录', | ||
| 888 | - style: TextStyle( | ||
| 889 | - color: MyColours.color_41444B, | ||
| 890 | - fontSize: | ||
| 891 | - ScreenUtil().setSp(28), | ||
| 892 | - fontWeight: FontWeight.bold)), | ||
| 893 | - ], | ||
| 894 | - )), | ||
| 895 | - onTap: () { | ||
| 896 | - if (!_check) { | ||
| 897 | - DialogUtil.openAlertDialogLogin( | ||
| 898 | - context, 500, onTap: () { | ||
| 899 | - Navigator.pop(context); | ||
| 900 | - _iosLogin(value); | ||
| 901 | - }); | ||
| 902 | - return; | ||
| 903 | - } | 850 | + return; |
| 851 | + } | ||
| 852 | + NavigatorUtil.goAccountLoginPage(context); | ||
| 853 | + }); | ||
| 854 | + }), | ||
| 855 | + // ios登录 | ||
| 856 | + Platform.isAndroid | ||
| 857 | + ? Text('') | ||
| 858 | + : Consumer<UserModel>(builder: | ||
| 859 | + (BuildContext context, UserModel value, Widget child) { | ||
| 860 | + return InkWell( | ||
| 861 | + child: Container( | ||
| 862 | + width: double.infinity, | ||
| 863 | + height: ScreenUtil().setWidth(90), | ||
| 864 | + margin: EdgeInsets.only( | ||
| 865 | + bottom: ScreenUtil().setWidth(30), | ||
| 866 | + right: ScreenUtil().setWidth(80), | ||
| 867 | + left: ScreenUtil().setWidth(80)), | ||
| 868 | + decoration: BoxDecoration( | ||
| 869 | + color: MyColours.color_ffffff, | ||
| 870 | + border: Border.all( | ||
| 871 | + color: MyColours.color_E4E4E4, | ||
| 872 | + width: ScreenUtil().setWidth(2)), | ||
| 873 | + borderRadius: BorderRadius.circular( | ||
| 874 | + ScreenUtil().setWidth(8))), | ||
| 875 | + child: Row( | ||
| 876 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 877 | + children: [ | ||
| 878 | + Image.asset( | ||
| 879 | + Utils.getImgPath('icon_apple_login'), | ||
| 880 | + width: ScreenUtil().setWidth(46)), | ||
| 881 | + HEmptyView(20), | ||
| 882 | + Text('通过 Apple 登录', | ||
| 883 | + style: TextStyle( | ||
| 884 | + color: MyColours.color_41444B, | ||
| 885 | + fontSize: ScreenUtil().setSp(28), | ||
| 886 | + fontWeight: FontWeight.bold)), | ||
| 887 | + ], | ||
| 888 | + )), | ||
| 889 | + onTap: () { | ||
| 890 | + if (!_check) { | ||
| 891 | + DialogUtil.openAlertDialogLogin(context, 500, | ||
| 892 | + onTap: () { | ||
| 893 | + Navigator.pop(context); | ||
| 904 | _iosLogin(value); | 894 | _iosLogin(value); |
| 905 | }); | 895 | }); |
| 906 | - }), | ||
| 907 | - InkWell( | ||
| 908 | - onTap: () { | ||
| 909 | - Utils.goPhone("400-000-9690"); | ||
| 910 | - }, | ||
| 911 | - child: Text('联系客服', | ||
| 912 | - style: TextStyle( | ||
| 913 | - color: MyColours.color_333333, | ||
| 914 | - fontWeight: FontWeight.bold, | ||
| 915 | - fontSize: ScreenUtil().setSp(26), | ||
| 916 | - decoration: TextDecoration.underline))), | ||
| 917 | - ], | ||
| 918 | - ), | ||
| 919 | - ), | ||
| 920 | - )); | 896 | + return; |
| 897 | + } | ||
| 898 | + _iosLogin(value); | ||
| 899 | + }); | ||
| 900 | + }), | ||
| 901 | + InkWell( | ||
| 902 | + onTap: () { | ||
| 903 | + Utils.goPhone("400-000-9690"); | ||
| 904 | + }, | ||
| 905 | + child: Text('联系客服', | ||
| 906 | + style: TextStyle( | ||
| 907 | + color: MyColours.color_333333, | ||
| 908 | + fontWeight: FontWeight.bold, | ||
| 909 | + fontSize: ScreenUtil().setSp(26), | ||
| 910 | + decoration: TextDecoration.underline))), | ||
| 911 | + ], | ||
| 912 | + ), | ||
| 913 | + ), | ||
| 914 | + )); | ||
| 921 | } | 915 | } |
| 922 | } | 916 | } |
| 1 | -import 'dart:async'; | ||
| 2 | -import 'dart:convert'; | ||
| 3 | -import 'dart:io'; | ||
| 4 | 1 | ||
| 2 | +// class WebPage extends StatefulWidget { | ||
| 3 | +// final String title; | ||
| 4 | +// final String url; | ||
| 5 | +// final bool need; | ||
| 6 | + | ||
| 7 | +// const WebPage({Key key, this.title, this.url, this.need = false}) | ||
| 8 | +// : super(key: key); | ||
| 9 | +// @override | ||
| 10 | +// _WebPageState createState() => _WebPageState(); | ||
| 11 | +// } | ||
| 12 | + | ||
| 13 | +// class _WebPageState extends State<WebPage> { | ||
| 14 | +// final Completer<WebViewController> _controller = | ||
| 15 | +// Completer<WebViewController>(); | ||
| 16 | + | ||
| 17 | +// @override | ||
| 18 | +// void initState() { | ||
| 19 | +// super.initState(); | ||
| 20 | +// // Enable hybrid composition. | ||
| 21 | +// if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); | ||
| 22 | +// } | ||
| 23 | + | ||
| 24 | +// @override | ||
| 25 | +// Widget build(BuildContext context) { | ||
| 26 | +// return Text('''引言 | ||
| 27 | +// 欢迎您使用由纳极(北京)科技有限公司(本文简称纳极)提供的“一键订”!我们非常重视用户的隐私和个人信息保护。您在使用我们的产品与/或服务时,我们可能会收集和使用您的相关信息。我们希望通过本《隐私政策》向您说明我们在您使用我们的产品与/或服务时如何收集、使用、保存、共享和转让这些信息,以及我们为您提供的访问、更新、控制和保护这些信息的方式。 | ||
| 28 | +// 本隐私政策将帮助您了解以下内容: | ||
| 29 | +// 一、我们如何收集和使用您的个人信息 | ||
| 30 | +// 二、我们如何共享、转让、公开披露您的个人信息 | ||
| 31 | +// 三、我们如何保护和保存您的个人信息 | ||
| 32 | +// 四、您如何管理个人信息 | ||
| 33 | +// 五、未成年人的个人信息保护 | ||
| 34 | +// 六、通知和修订 | ||
| 35 | +// 七、如何联系我们 | ||
| 36 | +// 本隐私政策与您所使用的“一键订”服务以及该服务所包括的各种业务功能(以下统称“我们的产品与/或服务”)息息相关,希望您在使用我们的产品与/或服务前仔细阅读并确认您已经充分理解本隐私政策所写明的内容,并让您可以按照本隐私政策的指引做出您认为适当的选择。本隐私政策中涉及的相关术语,我们尽量以简明扼要的表述,以便您更好地理解。 | ||
| 37 | +// 一、我们如何收集和使用您的个人信息 | ||
| 38 | +// 个人信息是指以电子或者其他方式记录的能够单独或者与其他信息结合识别特定自然人身份或者反映特定自然人活动情况的各种信息。个人敏感信息是指一旦泄露、非法提供或滥用可能危害人身和财产安全,极易导致个人名誉、身心健康受到损害或歧视性待遇等的个人信息(我们将在本政策中对涉及到的个人敏感信息以粗体进行显著标识)。 | ||
| 39 | +// 我们会遵循正当、合法、必要的原则,出于本政策所述的以下目的,收集和使用您在使用产品与/或服务过程中主动提供或因使用产品与/或服务而产生的个人信息,以及从第三方获取您的相关个人信息。如果我们要将您的个人信息用于本政策未载明的其它用途,或将基于特定目的收集而来的信息用于其他目的,我们将以合理的方式向您告知,并在使用前再次征得您的同意。 | ||
| 40 | +// (一)您须授权我们收集和使用您个人信息的情形 | ||
| 41 | +// 我们的产品与/或服务包括一些核心功能,这些功能包含了实现预订管理所必须的功能。我们可能会收集、保存和使用下列与您有关的信息才能实现上述这些功能。如果您不提供相关信息,您将无法享受我们提供的产品与/或服务。这些功能包括: | ||
| 42 | +// (1)账户注册、登录与验证 | ||
| 43 | +// 当您注册“一键订”账户时,您至少需要向我们提供您准备使用的您本人的手机号码,我们将通过发送短信验证码的方式来验证您的身份是否有效。您可以修改和补充您的姓名、照片、联系电话,这些信息均属于您的“账户信息”。您补充的账户信息将有助于我们为您的客户提供更优的预订体验。 | ||
| 44 | +// (2)店铺服务信息设置 | ||
| 45 | +// 为了让您的客户快速地找到您的店铺,我们会收集您店铺的名称、所在位置相关信息(您授权的GPS位置信息,我们仅收集您当时所处的地理位置,但不会将您各时段的位置信息进行结合以判断您的行踪轨迹)来判断您所处的地点。 | ||
| 46 | +// (3)预订信息录入 | ||
| 47 | +// 为了方便您快速录入客户的姓名、联系电话,在您同意开启通讯录权限后您在录入预订订单时不需再手动输入您通讯录中联系人的信息,用于订单快速生成。 | ||
| 48 | +// (4)预订通知管理 | ||
| 49 | +// 当您准备通知您的客户预订结果时,“一键订”需要调用您的微信给客户发送预订安排。您需要在通知内至少填写您的联系电话; | ||
| 50 | +// 您还可以填写您的姓名、职务和微信二维码以方便客户更好的跟您建立联系,但是不填写这些信息不影响您的预订通知。 | ||
| 51 | +// 当您设置您的通知信息时,“一键订”需要调用基于图片/视频上传的扩展功能:我们会使用您所上传的图片,作为您的形象照片和微信二维码展示,方便客户添加您的微信。 | ||
| 52 | +// (5)订单结账通知功能 | ||
| 53 | +// 当您传送订单水单给客户时,“一键订”需要调用基于摄像头(相机)的扩展功能:您可以使用这项扩展功能完成拍照上传水单传送给客户。 | ||
| 54 | +// (6)基于剪切板的扩展功能:当您复制个人信息、短信验证码,分享或接收被分享信息时,您的剪切板功能可能会被调用。剪切板信息仅会在您的设备上进行处理,我们不会存储您的剪切板信息用于任何其他途径。 | ||
| 55 | +// 上述功能可能需要您在您的设备中向我们开启您的地理位置(位置信息)、相机(摄像头)、相册(图片库)、通讯录,以实现这些功能所涉及的信息的收集和使用。您可以在“一键订”APP或设备系统中逐项查看您上述权限的开启状态,并可以决定将这些权限随时的开启或关闭。请您注意,您开启这些权限即代表您授权我们可以收集和使用这些个人信息来实现上述的功能,您关闭权限即代表您取消了这些授权,则我们将不再继续收集和使用您的这些个人信息,也无法为您提供上述与这些授权所对应的功能。您关闭权限的决定不会影响此前基于您的授权所进行的个人信息的处理。除此以外,我们在相关业务功能中可能还需要您开启设备的其他访问权限,详细权限和使用目的如下: | ||
| 56 | +// (1)android.permission.ACCESS_COARSE_LOCATION(访问位置权限):用于应用创建店铺供用户选择地图位置、定位 | ||
| 57 | +// (2)android.permission.ACCESS_FINE_LOCATION(访问位置权限):用于应用创建店铺供用户选择地图位置、定位 | ||
| 58 | +// (3)android.permission.READ_CONTACTS/android.permission.WRITE_CONTACTS(访问联系人权限):获取用户通讯录以便快速录入用户联系电话,方便发送短信 | ||
| 59 | +// (4)com.huawei.android.launcher.permission.CHANGE_BADGE(设置桌面图标角标权限):应于消息推送设置桌面角标,推送客户预订、提前点餐、买单需求、取消预订等需要推送通知给商家的消息数 | ||
| 60 | +// (二)您充分知晓,以下情形中,我们收集、使用个人信息无需征得您的授权同意: | ||
| 61 | +// 1、与国家安全、国防安全有关的; | ||
| 62 | +// 2、与公共安全、公共卫生、重大公共利益有关的; | ||
| 63 | +// 3、与犯罪侦查、起诉、审判和判决执行等有关的; | ||
| 64 | +// 4、出于维护个人信息主体或其他个人的生命、财产等重大合法权益但又很难得到本人同意的; | ||
| 65 | +// 5、所收集的个人信息是个人信息主体或监护人自行向社会公众公开的; | ||
| 66 | +// 6、从合法公开披露的信息中收集的您的个人信息的,如合法的新闻报道、政府信息公开等渠道; | ||
| 67 | +// 7、根据您的要求签订合同所必需的; | ||
| 68 | +// 8、用于维护所提供的产品与/或服务的安全稳定运行所必需的,例如发现、处置产品与/或服务的故障; | ||
| 69 | +// 9、为合法的新闻报道所必需的; | ||
| 70 | +// 10、学术研究机构基于公共利益开展统计或学术研究所必要,且对外提供学术研究或描述的结果时,对结果中所包含的个人信息进行去标识化处理的; | ||
| 71 | +// 11、法律法规规定的其他情形。 | ||
| 72 | +// (三)我们从第三方获得您个人信息的情形 | ||
| 73 | +// 我们可能从第三方获取您授权共享的账户信息(头像、昵称及授权页面提示的其他信息),并在您同意本隐私政策后将您的第三方账户与您的纳极账户绑定,使您可以通过第三方账户直接登录并使用我们的产品与/或服务。我们会将依据与第三方的约定、对个人信息来源的合法性进行确认后,在符合相关法律和法规规定的前提下,使用您的这些个人信息。您也可以使用本机号码来快捷登录,我们会将您的网络信息提供给运营商完成注册或登录。 | ||
| 74 | +// (四)“一键订”APP涉及嵌入第三方代码、插件传输个人信息的情形逐项列举: | ||
| 75 | +// 高德地图sdk:用于应用创建店铺供用户选择地图位置、定位 | ||
| 76 | +// 获取通讯录:获取用户通讯录以便快速录入用户联系电话,方便发送短信 | ||
| 77 | +// 华为推送sdk:应于消息推送,推送客户预订、提前点餐、买单需求、取消预订等需要推送通知给商家的消息 | ||
| 78 | +// 腾讯Bugly:用于收集应用使用中报出的错误信息、日志 | ||
| 79 | +// 微信sdk:用于商家经理微信登录“一键订”app 以及微信分享预订通知、点餐清单等操作 | ||
| 80 | +// 七牛云sdk:用于上传、获取商家图片、视频等资源 | ||
| 81 | +// (五)您个人信息使用的规则 | ||
| 82 | +// 1、我们会根据本隐私政策的约定并为实现我们的产品与/或服务功能对所收集的个人信息进行使用。 | ||
| 83 | +// 2、在收集您的个人信息后,我们将通过技术手段对数据进行去标识化处理,去标识化处理的信息将无法识别主体。请您了解并同意,在此情况下我们有权使用已经去标识化的信息;并在不透露您个人信息的前提下,我们有权对用户数据库进行分析并予以商业化的利用。 | ||
| 84 | +// 3、请您了解并同意,您在使用我们的产品与/或服务时所提供的所有个人信息,除非您删除或通过系统设置拒绝我们收集,否则将在您使用我们的产品与/或服务期间持续授权我们使用。 | ||
| 85 | +// 4、我们会对我们的产品与/或服务使用情况进行统计,并可能会与公众或第三方共享这些统计信息,以展示我们的产品与/或服务的整体使用趋势。但这些统计信息不包含您的任何身份识别信息。 | ||
| 86 | +// 5、当我们展示您的个人信息时,我们会采用包括内容替换、匿名处理方式对您的信息进行脱敏,以保护您的信息安全。 | ||
| 87 | +// 6、当我们要将您的个人信息用于本隐私政策未载明的其它用途时,或基于特定目的收集而来的信息用于其他目的时,会实现征求您的明示同意。请您理解,我们向您提供的产品与/或服务将不断更新变化。如果您选择使用本隐私政策中尚未列明的其他产品与/或服务时,我们会在收集您的个人信息前通过协议、页面提示等方式向您详细说明信息收集的目的、方式、范围并征求您的同意。若您不同意提供前述信息,您可能无法使用该项产品与/或服务,但不影响您使用现有产品与/或服务。 | ||
| 88 | +// 二、我们如何共享、转让、公开披露您的个人信息 | ||
| 89 | +// (一)共享 | ||
| 90 | +// 1、我们不会与纳极以外的任何公司、组织和个人共享您的个人信息,但以下情况除外: | ||
| 91 | +// (1)事先获得您明确的同意或授权; | ||
| 92 | +// (2)根据适用的法律法规、法律程序的要求、强制性的行政或司法要求所必须的情况下进行提供; | ||
| 93 | +// (3)在法律法规允许的范围内,为维护纳极、纳极的关联方或合作伙伴、您或其他纳极用户或社会公众利益、财产或安全免遭损害而有必要提供; | ||
| 94 | +// (4) 只有共享您的个人信息,才能实现我们的产品与/或服务的核心功能或提供您需要的服务; | ||
| 95 | +// (5)应您需求为您处理您与他人的纠纷或争议; | ||
| 96 | +// (6)符合与您签署的相关协议(包括在线签署的电子协议以及相应的平台规则)或其他的法律文件约定所提供; | ||
| 97 | +// (7)基于学术研究而使用; | ||
| 98 | +// (8)基于符合法律法规的社会公共利益而使用。 | ||
| 99 | +// 2、对我们与之共享个人信息的公司、组织和个人,我们会与其签署严格的保密协定,要求他们按照我们的说明、本隐私政策以及其他任何相关的保密和安全措施来处理个人信息。为了保障数据安全可控,我们在云端提供安全可靠的数据使用和存储环境,确保用户数据的安全性。 | ||
| 100 | +// 3、为了遵守法律、执行或适用我们的使用条件和其他协议,或者为了保护纳极、您或其他纳极客户的权利及其财产或安全,比如为防止欺诈等违法活动和减少信用风险,而与其他公司和组织交换信息。不过,这并不包括违反本隐私政策中所作的承诺而为获利目的出售、出租、共享或以其它方式披露的个人信息。 | ||
| 101 | +// (二)转让 | ||
| 102 | +// 我们不会将您的个人信息转让给任何公司、组织和个人,但以下情况除外: | ||
| 103 | +// 1、事先获得您明确的同意或授权; | ||
| 104 | +// 2、根据适用的法律法规、法律程序的要求、强制性的行政或司法要求所必须的情况进行提供; | ||
| 105 | +// 3、符合与您签署的相关协议(包括在线签署的电子协议以及相应的平台规则)或其他的法律文件约定所提供; | ||
| 106 | +// 4、在涉及合并、收购、资产转让或类似的交易时,如涉及到个人信息转让,我们会要求新的持有您个人信息的公司、组织继续受本隐私政策的约束,否则,我们将要求该公司、组织重新向您征求授权同意。 | ||
| 107 | +// (三)公开披露 | ||
| 108 | +// 我们仅会在以下情况下,且采取符合业界标准的安全防护措施的前提下,才会公开披露您的个人信息: | ||
| 109 | +// 1、根据您的需求,在您明确同意的披露方式下披露您所指定的个人信息; | ||
| 110 | +// 2、根据法律、法规的要求、强制性的行政执法或司法要求所必须提供您个人信息的情况下,我们可能会依据所要求的个人信息类型和披露方式公开披露您的个人信息。在符合法律法规的前提下,当我们收到上述披露信息的请求时,我们会要求必须出具与之相应的法律文件,如传票或调查函。我们坚信,对于要求我们提供的信息,应该在法律允许的范围内尽可能保持透明。我们对所有的请求都进行了慎重的审查,以确保其具备合法依据,且仅限于执法部门因特定调查目的且有合法权利获取的数据。在法律法规许可的前提下,我们披露的文件均在加密密钥的保护之下。 | ||
| 111 | +// 三、我们如何保护和保存您的个人信息 | ||
| 112 | +// (一)我们保护您个人信息的技术与措施 | ||
| 113 | +// 我们非常重视个人信息安全,并采取一切合理可行的措施,保护您的个人信息: | ||
| 114 | +// 1、数据安全技术措施 | ||
| 115 | +// 我们会采用符合业界标准的安全防护措施,包括建立合理的制度规范、安全技术来防止您的个人信息遭到未经授权的访问使用、修改,避免数据的损坏或丢失。 | ||
| 116 | +// 纳极的网络服务采取了传输层安全协议等加密技术,通过https等方式提供浏览服务,确保用户数据在传输过程中的安全。 | ||
| 117 | +// 纳极采取加密技术对用户个人信息进行加密保存,并通过隔离技术进行隔离。 | ||
| 118 | +// 在个人信息使用时,例如个人信息展示、个人信息关联计算,我们会采用包括内容替换、SHA256在内多种数据脱敏技术增强个人信息在使用中安全性。 | ||
| 119 | +// 纳极采用严格的数据访问权限控制和多重身份认证技术保护个人信息,避免数据被违规使用。 | ||
| 120 | +// 纳极采用代码安全自动检查、数据访问日志分析技术进行个人信息安全审计。 | ||
| 121 | +// 2、纳极为保护个人信息采取的其他安全措施 | ||
| 122 | +// 纳极通过建立数据分类分级制度、数据安全管理规范、数据安全开发规范来管理规范个人信息的存储和使用。 | ||
| 123 | +// 纳极通过信息接触者保密协议、监控和审计机制来对数据进行全面安全控制。 | ||
| 124 | +// 加强安全意识。我们还会举办安全和隐私保护培训课程,加强员工对于保护个人信息重要性的认识。 | ||
| 125 | +// 3、我们仅允许有必要知晓这些信息的纳极及纳极关联方的员工、合作伙伴访问个人信息,并为此设置了严格的访问权限控制和监控机制。我们同时要求可能接触到您个人信息的所有人员履行相应的保密义务。如果未能履行这些义务,可能会被追究法律责任或被中止与纳极的合作关系。 | ||
| 126 | +// 4、我们会采取一切合理可行的措施,确保未收集无关的个人信息。 | ||
| 127 | +// 5、如果您对我们的个人信息保护有任何疑问,可通过本隐私政策中约定的联系方式联系我们。如您发现自己的个人信息泄密,尤其是您的账户及密码发生泄露,请您立即通过本隐私政策【七、如何联系我们】中约定的联系方式联络我们,以便我们采取相应措施。 | ||
| 128 | +// (二)您个人信息的保存 | ||
| 129 | +// 1、您的个人信息将存储于中华人民共和国境内。 | ||
| 130 | +// 2、在您使用我们的产品与/或服务期间,您的个人信息将在为了实现本政策所述目的之期限内保存,同时将结合法律有强制的留存要求期限的规定确定,如《中华人民共和国电子商务法》要求商品和服务信息、交易信息保存时间自交易完成之日起不少于三年。在超出保存期间后,我们会根据适用法律的要求删除您的个人信息,或进行匿名化处理。 | ||
| 131 | +// 3、请您注意,当您或我们协助您删除相关信息后,因为适用的法律和安全技术限制,我们可能无法立即从备份系统中删除相应的信息,我们将安全地存储您的个人信息并限制对其的任何进一步的处理,直到备份可以删除或实现匿名化。 | ||
| 132 | +// 4、如果我们终止服务或运营,我们会至少提前三十日向您通知,并在终止服务或运营后对您的个人信息进行删除或匿名化处理。 | ||
| 133 | +// 四、您如何管理您的个人信息 | ||
| 134 | +// 纳极非常重视您对个人信息的关注,并尽全力保护您对于您个人信息访问、更正、删除以及撤回同意的权利,以使您拥有充分的能力保障您的隐私和安全。您的权利包括: | ||
| 135 | +// 1、访问和更正您的个人信息 | ||
| 136 | +// 除法律法规规定外,您有权随时访问和更正您的个人信息,具体包括: | ||
| 137 | +// (1)您的账户信息:您可以在“一键订”APP “我的”页面的“编辑”菜单中查阅您提交给纳极的所有个人信息,你也可通过上述途径更新除个人信息。 | ||
| 138 | +// (2)您的店铺配置信息:您可以在“一键订”APP “我的”页面进行相关预订操作的设置。 | ||
| 139 | +// 2、删除您的个人信息 | ||
| 140 | +// 您在我们的产品与/或服务页面中可以直接清除或删除的信息,包括姓名、联系电话、微信二维码信息。 | ||
| 141 | +// 在以下情形中,您可以向我们提出删除个人信息的请求: | ||
| 142 | +// (1)如果我们处理个人信息的行为违反法律法规; | ||
| 143 | +// (2)如果我们收集、使用您的个人信息,却未征得您的同意; | ||
| 144 | +// (3)如果我们处理个人信息的行为违反了与您的约定; | ||
| 145 | +// (4)如果您不再使用我们的产品或服务; | ||
| 146 | +// (5)如果我们终止服务及运营。若我们决定响应您的删除请求,我们还将同时通知从我们获得您的个人信息的实体,要求其及时删除,除非法律法规另有规定,或这些实体获得您的独立授权。若我们响应您的删除请求,我们不能保证立即从备份系统中删除相应的信息,但会在备份系统更新时删除这些信息。 | ||
| 147 | +// 3、改变您授权同意的范围或撤回您的授权 | ||
| 148 | +// 您可以通过删除信息、关闭设备功能、在“一键订”软件中进行隐私设置等方式改变您授权我们继续收集个人信息的范围或撤回您的授权。 | ||
| 149 | +// 请您理解,每个业务功能需要一些基本的个人信息才能得以完成,当您撤回同意或授权后,我们无法继续为您提供撤回同意或授权所对应的服务,也不再处理您相应的个人信息。但您撤回同意或授权的决定,不会影响此前基于您的授权而开展的个人信息处理。 | ||
| 150 | +// 4、获取您的个人信息副本 | ||
| 151 | +// 您有权获取您的个人信息副本。如您需要获取我们收集的您的个人信息副本,您随时联系我们。在符合相关法律规定且技术可行的前提下,我们将根据您的要求向您提供您的个人信息副本。 | ||
| 152 | +// 6、响应您的请求 | ||
| 153 | +// 如果您无法通过上述方式访问、更正或删除您的个人信息,或您需要访问、更正或删除您在使用我们产品与/或服务时所产生的其他个人信息或者获取个人信息副本,或您认为“一键订”存在任何违反法律法规或与您关于个人信息的收集或使用的约定,您均可以通过本隐私政策中的指定方式与我们联系。为了保障安全,我们可能需要您提供书面请求,或提供您的身份证明文件,我们将在收到您反馈并验证您的身份后的15天内答复您的请求。对于您合理的请求,我们原则上不收取费用,但对多次重复、超出合理限度的请求,我们将视情收取一定成本费用。对于那些无端重复、需要过多技术手段(例如,需要开发新系统或从根本上改变现行惯例)、给他人合法权益带来风险或者非常不切实际(例如,涉及备份磁带上存放的信息)的请求,我们可能会予以拒绝。 | ||
| 154 | +// 在以下情形中,按照法律法规要求,我们将无法响应您的请求: | ||
| 155 | +// (1)与个人信息控制者履行法律法规规定的义务相关的; | ||
| 156 | +// (2)与国家安全、国防安全有关的; | ||
| 157 | +// (3)与公共安全、公共卫生、重大公共利益有关的; | ||
| 158 | +// (4)与犯罪侦查、起诉和审判和执行判决等有关的; | ||
| 159 | +// (5)有充分证据表明您存在主观恶意或滥用权利的; | ||
| 160 | +// (6)出于维护个人信息主体或其他个人的生命、财产等重大合法权益但又很难得到本人同意的; | ||
| 161 | +// (7)响应您的请求将导致您或其他个人、组织的合法权益受到严重损害的; | ||
| 162 | +// (8)涉及商业秘密的。 | ||
| 163 | +// 五、未成年人的个人信息保护 | ||
| 164 | +// 1、“一键订”非常重视对未成年人个人信息的保护。若您是18周岁以下的未成年人,在使用我们的产品与/或服务前,应事先取得您监护人的同意。“一键订”根据国家相关法律法规的规定保护未成年人的个人信息。 | ||
| 165 | +// 2、我们不会主动直接向未成年人收集其个人信息。对于经监护人同意而收集未成年人个人信息的情况,我们只会在受到法律允许、监护人同意或者保护未成年人所必要的情况下使用、共享、转让或披露此信息。 | ||
| 166 | +// 3、如果有事实证明未成年人在未取得监护人同意的情况下注册使用了我们的产品与/或服务,我们会与相关监护人协商,并设法尽快删除相关个人信息。 | ||
| 167 | +// 4、对于可能涉及的不满14周岁的儿童个人信息,我们进一步采取以下措施予以保障: | ||
| 168 | +// (1)对于收集到的儿童个人信息,我们除遵守本隐私政策关于用户个人信息的约定外,还会秉持正当必要、知情同意、目的明确、安全保障、依法利用的原则,严格遵循《儿童个人信息网络保护规定》等法律法规的要求进行存储、使用、披露,且不会超过实现收集、使用目的所必须的期限,到期后我们会对儿童个人信息进行删除或匿名化处理。 | ||
| 169 | +// (2)当您作为监护人为被监护的儿童选择使用“一键订”相关服务时,我们可能需要向您收集被监护的儿童个人信息,用于向您履行相关服务之必要。在具体服务中需要向您收集儿童个人信息的,我们会事先取得您的授权同意,并告知您收集的目的和用途。如果您不提供前述信息,您将无法享受我们提供的相关服务。您作为监护人应当正确履行监护职责,保护儿童个人信息安全。若儿童本人需要注册或使用我们的产品与/或服务,您应正确引导并予以监护。 | ||
| 170 | +// (3)儿童或其监护人有权随时访问和更正儿童个人信息,还可以向我们提出更正和删除的请求。如您对儿童个人信息相关事宜有任何意见、建议或投诉、举报,请联系我们。我们会随时为您提供帮助。 | ||
| 171 | +// 六、通知和修订 | ||
| 172 | +// 1、为给您提供更好的服务以及随着纳极业务的发展,本隐私政策也会随之更新。但未经您明确同意,我们不会削减您依据本隐私政策所应享有的权利。我们会通过在纳极网站、一键订移动端上发出更新版本并在生效前通过网站公告或以其他适当方式提醒您相关内容的更新,也请您访问纳极以便及时了解最新的隐私政策。 | ||
| 173 | +// 2、对于重大变更,我们还会提供更为显著的通知(我们会通过包括但不限于邮件、短信或在浏览页面做特别提示等方式,说明隐私政策的具体变更内容)。 | ||
| 174 | +// 本隐私政策所指的重大变更包括但不限于: | ||
| 175 | +// (1)我们的服务模式发生重大变化。如处理个人信息的目的、处理的个人信息类型、个人信息的使用方式等; | ||
| 176 | +// (2)我们在所有权结构、组织架构等方面发生重大变化。如业务调整、破产并购等引起的所有者变更等; | ||
| 177 | +// (3)个人信息共享、转让或公开披露的主要对象发生变化; | ||
| 178 | +// (4)您参与个人信息处理方面的权利及其行使方式发生重大变化; | ||
| 179 | +// (5)我们负责处理个人信息安全的责任部门、联络方式及投诉渠道发生变化时; | ||
| 180 | +// (6)个人信息安全影响评估报告表明存在高风险时。 | ||
| 181 | +// 3、为了您能及时接收到通知,建议您在联系方式更新时及时通知我们。如您在本政策更新生效后继续使用我们的服务,即代表您已充分阅读、理解并接受更新后的政策并愿意受更新后的政策约束。我们鼓励您在每次使用我们服务时都查阅本政策。 | ||
| 182 | +// 七、如何联系我们 | ||
| 183 | +// 1、如您对本隐私政策或您个人信息的相关事宜或者投诉、举报、有任何问题、意见或建议,请通过以下方式与我们联系。 | ||
| 184 | +// 联系电话:400-000-9690 | ||
| 185 | +// 2、一般情况下,我们将在15天内回复。如果您对我们的回复不满意,特别是我们的个人信息处理行为损害了您的合法权益,您还可以向网信、电信、公安及工商等监管部门进行投诉或举报。 | ||
| 186 | +// 注:本隐私政策版本更新日期为2021年【8】月【6】日,将于2021年【8】月【7】日正式生效。 | ||
| 187 | +// '''); | ||
| 188 | +// return Scaffold( | ||
| 189 | +// // We're using a Builder here so we have a context that is below the Scaffold | ||
| 190 | +// // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 191 | +// appBar: SystemAppBar( | ||
| 192 | +// widget.title, | ||
| 193 | +// onTap: () { | ||
| 194 | +// if (widget.need) { | ||
| 195 | +// Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 196 | +// } | ||
| 197 | +// Navigator.of(context).pop(); | ||
| 198 | +// }, | ||
| 199 | +// ), | ||
| 200 | +// body: WillPopScope( | ||
| 201 | +// onWillPop: () async { | ||
| 202 | +// if (widget.need) { | ||
| 203 | +// Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 204 | +// } | ||
| 205 | +// return true; | ||
| 206 | +// }, | ||
| 207 | +// child: Column(children: [ | ||
| 208 | +// Builder(builder: (BuildContext context) { | ||
| 209 | +// return Expanded( | ||
| 210 | +// child: WebView( | ||
| 211 | +// initialUrl: "http://colorcun.com/privacy1.html", | ||
| 212 | +// javascriptMode: JavascriptMode.unrestricted, | ||
| 213 | +// onWebViewCreated: (WebViewController webViewController) { | ||
| 214 | +// _controller.complete(webViewController); | ||
| 215 | +// }, | ||
| 216 | +// // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 217 | +// // ignore: prefer_collection_literals | ||
| 218 | +// javascriptChannels: <JavascriptChannel>[ | ||
| 219 | +// _toasterJavascriptChannel(context), | ||
| 220 | +// ].toSet(), | ||
| 221 | +// navigationDelegate: (NavigationRequest request) { | ||
| 222 | +// if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 223 | +// print('blocking navigation to $request}'); | ||
| 224 | +// return NavigationDecision.prevent; | ||
| 225 | +// } | ||
| 226 | +// print('allowing navigation to $request'); | ||
| 227 | +// return NavigationDecision.navigate; | ||
| 228 | +// }, | ||
| 229 | +// onPageStarted: (String url) { | ||
| 230 | +// print('Page started loading: $url'); | ||
| 231 | +// }, | ||
| 232 | +// onPageFinished: (String url) { | ||
| 233 | +// print('Page finished loading: $url'); | ||
| 234 | +// }, | ||
| 235 | +// gestureNavigationEnabled: true, | ||
| 236 | +// )); | ||
| 237 | +// }), | ||
| 238 | +// ]))); | ||
| 239 | +// } | ||
| 240 | + | ||
| 241 | +// JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 242 | +// return JavascriptChannel( | ||
| 243 | +// name: 'Toaster', | ||
| 244 | +// onMessageReceived: (JavascriptMessage message) { | ||
| 245 | +// Scaffold.of(context).showSnackBar( | ||
| 246 | +// SnackBar(content: Text(message.message)), | ||
| 247 | +// ); | ||
| 248 | +// }); | ||
| 249 | +// } | ||
| 250 | +// } | ||
| 5 | import 'package:flutter/material.dart'; | 251 | import 'package:flutter/material.dart'; |
| 6 | -import 'package:one_key/res/colors.dart'; | ||
| 7 | -import 'package:one_key/utils/event_bus.dart'; | ||
| 8 | -import 'package:one_key/utils/utils.dart'; | ||
| 9 | -import 'package:one_key/widgets/app_bar.dart'; | ||
| 10 | -import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 11 | -import 'package:webview_flutter/webview_flutter.dart'; | ||
| 12 | 252 | ||
| 13 | class WebPage extends StatefulWidget { | 253 | class WebPage extends StatefulWidget { |
| 14 | final String title; | 254 | final String title; |
| @@ -22,14 +262,104 @@ class WebPage extends StatefulWidget { | @@ -22,14 +262,104 @@ class WebPage extends StatefulWidget { | ||
| 22 | } | 262 | } |
| 23 | 263 | ||
| 24 | class _WebPageState extends State<WebPage> { | 264 | class _WebPageState extends State<WebPage> { |
| 25 | - final Completer<WebViewController> _controller = | ||
| 26 | - Completer<WebViewController>(); | 265 | + final GlobalKey webViewKey = GlobalKey(); |
| 266 | + | ||
| 267 | + InAppWebViewController webViewController; | ||
| 268 | + InAppWebViewGroupOptions options = InAppWebViewGroupOptions( | ||
| 269 | + crossPlatform: InAppWebViewOptions( | ||
| 270 | + useShouldOverrideUrlLoading: true, | ||
| 271 | + useOnDownloadStart: true, | ||
| 272 | + mediaPlaybackRequiresUserGesture: false, | ||
| 273 | + ), | ||
| 274 | + android: AndroidInAppWebViewOptions( | ||
| 275 | + useHybridComposition: true, | ||
| 276 | + ), | ||
| 277 | + ios: IOSInAppWebViewOptions( | ||
| 278 | + allowsInlineMediaPlayback: true, | ||
| 279 | + )); | ||
| 280 | + | ||
| 281 | + PullToRefreshController pullToRefreshController; | ||
| 282 | + ContextMenu contextMenu; | ||
| 283 | + String url = ""; | ||
| 284 | + double progress = 0; | ||
| 285 | + final urlController = TextEditingController(); | ||
| 286 | + // Future<void> openFile(filePath) async { | ||
| 287 | + // final _result = await OpenFile.open(filePath); | ||
| 288 | + // print(_result.message); | ||
| 289 | + | ||
| 290 | + // // setState(() { | ||
| 291 | + // // _openResult = "type=${_result.type} message=${_result.message}"; | ||
| 292 | + // // }); | ||
| 293 | + // } | ||
| 27 | 294 | ||
| 28 | @override | 295 | @override |
| 29 | void initState() { | 296 | void initState() { |
| 30 | super.initState(); | 297 | super.initState(); |
| 298 | + | ||
| 31 | // Enable hybrid composition. | 299 | // Enable hybrid composition. |
| 32 | - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); | 300 | + _init(); |
| 301 | + } | ||
| 302 | + | ||
| 303 | + // Future<bool> _checkPermission() async { | ||
| 304 | + // DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | ||
| 305 | + // AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | ||
| 306 | + // if (Platform.isAndroid && androidInfo.version.sdkInt <= 28) { | ||
| 307 | + // final status = await Permission.storage.status; | ||
| 308 | + // if (status != PermissionStatus.granted) { | ||
| 309 | + // final result = await Permission.storage.request(); | ||
| 310 | + // if (result == PermissionStatus.granted) { | ||
| 311 | + // return true; | ||
| 312 | + // } | ||
| 313 | + // } else { | ||
| 314 | + // return true; | ||
| 315 | + // } | ||
| 316 | + // } else { | ||
| 317 | + // return true; | ||
| 318 | + // } | ||
| 319 | + // return false; | ||
| 320 | + // } | ||
| 321 | + | ||
| 322 | + // Future<bool> checkPermissionStorage() async { | ||
| 323 | + // var status = await Permission.storage.status; | ||
| 324 | + // if (!status.isGranted) { | ||
| 325 | + // status = await Permission.storage.request(); | ||
| 326 | + // if (status.isGranted) { | ||
| 327 | + // return true; | ||
| 328 | + // } | ||
| 329 | + // } else { | ||
| 330 | + // return true; | ||
| 331 | + // } | ||
| 332 | + // return false; | ||
| 333 | + // } | ||
| 334 | + | ||
| 335 | + _init() async { | ||
| 336 | + // WidgetsFlutterBinding.ensureInitialized(); | ||
| 337 | + // await FlutterDownloader.initialize(debug: true); | ||
| 338 | + if (Platform.isAndroid) { | ||
| 339 | + await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); | ||
| 340 | + | ||
| 341 | + var swAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 342 | + AndroidWebViewFeature.SERVICE_WORKER_BASIC_USAGE); | ||
| 343 | + var swInterceptAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 344 | + AndroidWebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); | ||
| 345 | + | ||
| 346 | + if (swAvailable && swInterceptAvailable) { | ||
| 347 | + AndroidServiceWorkerController serviceWorkerController = | ||
| 348 | + AndroidServiceWorkerController.instance(); | ||
| 349 | + | ||
| 350 | + serviceWorkerController.serviceWorkerClient = | ||
| 351 | + AndroidServiceWorkerClient( | ||
| 352 | + shouldInterceptRequest: (request) async { | ||
| 353 | + print(request); | ||
| 354 | + return null; | ||
| 355 | + }, | ||
| 356 | + ); | ||
| 357 | + } | ||
| 358 | + } | ||
| 359 | + // await FlutterDownloader.initialize( | ||
| 360 | + // debug: true // optional: set false to disable printing logs to console | ||
| 361 | + // ); | ||
| 362 | + // await Permission.storage.request(); | ||
| 33 | } | 363 | } |
| 34 | 364 | ||
| 35 | @override | 365 | @override |
| @@ -53,52 +383,201 @@ class _WebPageState extends State<WebPage> { | @@ -53,52 +383,201 @@ class _WebPageState extends State<WebPage> { | ||
| 53 | } | 383 | } |
| 54 | return true; | 384 | return true; |
| 55 | }, | 385 | }, |
| 56 | - child: Column(children: [ | ||
| 57 | - Builder(builder: (BuildContext context) { | ||
| 58 | - return Expanded( | ||
| 59 | - child: WebView( | ||
| 60 | - initialUrl: "http://colorcun.com/privacy1.html", | ||
| 61 | - javascriptMode: JavascriptMode.unrestricted, | ||
| 62 | - onWebViewCreated: (WebViewController webViewController) { | ||
| 63 | - _controller.complete(webViewController); | 386 | + child: Column( |
| 387 | + children: [ | ||
| 388 | + Expanded( | ||
| 389 | + child: InAppWebView( | ||
| 390 | + key: webViewKey, | ||
| 391 | + // contextMenu: contextMenu, | ||
| 392 | + initialUrlRequest: URLRequest( | ||
| 393 | + url: Uri.parse("http://colorcun.com/privacy1.html")), | ||
| 394 | + // initialFile: "assets/index.html", | ||
| 395 | + initialUserScripts: UnmodifiableListView<UserScript>([]), | ||
| 396 | + initialOptions: options, | ||
| 397 | + pullToRefreshController: pullToRefreshController, | ||
| 398 | + onWebViewCreated: (controller) { | ||
| 399 | + webViewController = controller; | ||
| 64 | }, | 400 | }, |
| 65 | - // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 66 | - // ignore: prefer_collection_literals | ||
| 67 | - javascriptChannels: <JavascriptChannel>[ | ||
| 68 | - _toasterJavascriptChannel(context), | ||
| 69 | - ].toSet(), | ||
| 70 | - navigationDelegate: (NavigationRequest request) { | ||
| 71 | - if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 72 | - print('blocking navigation to $request}'); | ||
| 73 | - return NavigationDecision.prevent; | 401 | + onLoadStart: (controller, url) { |
| 402 | + // setState(() { | ||
| 403 | + // this.url = url.toString(); | ||
| 404 | + // urlController.text = this.url; | ||
| 405 | + // }); | ||
| 406 | + }, | ||
| 407 | + androidOnPermissionRequest: | ||
| 408 | + (controller, origin, resources) async { | ||
| 409 | + // return PermissionRequestResponse( | ||
| 410 | + // resources: resources, | ||
| 411 | + // action: PermissionRequestResponseAction.GRANT); | ||
| 412 | + }, | ||
| 413 | + shouldOverrideUrlLoading: | ||
| 414 | + (controller, navigationAction) async { | ||
| 415 | + var uri = navigationAction.request.url; | ||
| 416 | + | ||
| 417 | + if (![ | ||
| 418 | + "http", | ||
| 419 | + "https", | ||
| 420 | + "file", | ||
| 421 | + "chrome", | ||
| 422 | + "data", | ||
| 423 | + "javascript", | ||
| 424 | + "about" | ||
| 425 | + ].contains(uri.scheme)) { | ||
| 426 | + if (await canLaunch(url)) { | ||
| 427 | + // Launch the App | ||
| 428 | + await launch( | ||
| 429 | + url, | ||
| 430 | + ); | ||
| 431 | + // and cancel the request | ||
| 432 | + return NavigationActionPolicy.CANCEL; | ||
| 433 | + } | ||
| 74 | } | 434 | } |
| 75 | - print('allowing navigation to $request'); | ||
| 76 | - return NavigationDecision.navigate; | 435 | + |
| 436 | + return NavigationActionPolicy.ALLOW; | ||
| 77 | }, | 437 | }, |
| 78 | - onPageStarted: (String url) { | ||
| 79 | - print('Page started loading: $url'); | 438 | + onLoadStop: (controller, url) async { |
| 439 | + // pullToRefreshController.endRefreshing(); | ||
| 440 | + // setState(() { | ||
| 441 | + // this.url = url.toString(); | ||
| 442 | + // urlController.text = this.url; | ||
| 443 | + // }); | ||
| 80 | }, | 444 | }, |
| 81 | - onPageFinished: (String url) { | ||
| 82 | - print('Page finished loading: $url'); | 445 | + onLoadError: (controller, url, code, message) { |
| 446 | + pullToRefreshController.endRefreshing(); | ||
| 83 | }, | 447 | }, |
| 84 | - gestureNavigationEnabled: true, | ||
| 85 | - )); | ||
| 86 | - }), | ||
| 87 | - ]))); | ||
| 88 | - } | 448 | + onProgressChanged: (controller, progress) { |
| 449 | + // if (progress == 100) { | ||
| 450 | + pullToRefreshController.endRefreshing(); | ||
| 451 | + // } | ||
| 452 | + // setState(() { | ||
| 453 | + // this.progress = progress / 100; | ||
| 454 | + // urlController.text = this.url; | ||
| 455 | + // }); | ||
| 456 | + }, | ||
| 457 | + onUpdateVisitedHistory: (controller, url, androidIsReload) { | ||
| 458 | + // setState(() { | ||
| 459 | + // this.url = url.toString(); | ||
| 460 | + // urlController.text = this.url; | ||
| 461 | + // }); | ||
| 462 | + }, | ||
| 463 | + onConsoleMessage: (controller, consoleMessage) { | ||
| 464 | + print(consoleMessage); | ||
| 465 | + }, | ||
| 466 | + onDownloadStart: (controller, url) async { | ||
| 467 | + // print("onDownloadStart $url"); | ||
| 468 | + // Utils.showToast('开始下载...'); | ||
| 469 | + // // final taskId = await FlutterDownloader.enqueue( | ||
| 470 | + // // url: url.toString(), | ||
| 471 | + // // savedDir: (await getExternalStorageDirectory()).path, | ||
| 472 | + // // showNotification: | ||
| 473 | + // // true, // show download progress in status bar (for Android) | ||
| 474 | + // // openFileFromNotification: | ||
| 475 | + // // true, // click on notification to open downloaded file (for Android) | ||
| 476 | + // // ); | ||
| 477 | + // final dir = await getExternalStorageDirectory(); | ||
| 478 | + // String savePath = dir.path + "/one_key"; | ||
| 89 | 479 | ||
| 90 | - JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 91 | - return JavascriptChannel( | ||
| 92 | - name: 'Toaster', | ||
| 93 | - onMessageReceived: (JavascriptMessage message) { | ||
| 94 | - Scaffold.of(context).showSnackBar( | ||
| 95 | - SnackBar(content: Text(message.message)), | ||
| 96 | - ); | ||
| 97 | - }); | 480 | + // Directory directory = new Directory(savePath); |
| 481 | + // if (directory.existsSync()) { | ||
| 482 | + // //删除历史apk | ||
| 483 | + // final List<FileSystemEntity> files = directory.listSync(); | ||
| 484 | + // for (FileSystemEntity file in files) { | ||
| 485 | + // file.deleteSync(); | ||
| 486 | + // } | ||
| 487 | + // } | ||
| 488 | + // DioUtil().download(url.toString(), savePath, | ||
| 489 | + // onProgress: (received, total) { | ||
| 490 | + // // if (_progress != 100) { | ||
| 491 | + // // int progress = ((received / total) * 100).round(); | ||
| 492 | + // // _progress = progress; | ||
| 493 | + // // _setState(() {}); | ||
| 494 | + // // } | ||
| 495 | + // if (received == total) { | ||
| 496 | + // print('object'); | ||
| 497 | + // Utils.showToast('文件已保存在${savePath}'); | ||
| 498 | + // // openFile(savePath); | ||
| 499 | + // //下载完成 | ||
| 500 | + // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 501 | + // } | ||
| 502 | + // }); | ||
| 503 | + // // }, | ||
| 504 | + // // DioUtil().download(url.toString(), | ||
| 505 | + // // (await getExternalStorageDirectory()).path, | ||
| 506 | + // // onProgress: (received, total) { | ||
| 507 | + // // // if (_progress != 100) { | ||
| 508 | + // // // int progress = ((received / total) * 100).round(); | ||
| 509 | + // // // _progress = progress; | ||
| 510 | + // // // _setState(() {}); | ||
| 511 | + // // // } | ||
| 512 | + // // if (received == total) { | ||
| 513 | + // // //下载完成 | ||
| 514 | + // // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 515 | + // // } | ||
| 516 | + // // }); | ||
| 517 | + }, | ||
| 518 | + )) | ||
| 519 | + ], | ||
| 520 | + ) | ||
| 521 | + // Builder(builder: (BuildContext context) { | ||
| 522 | + // return WebView( | ||
| 523 | + // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 524 | + // javascriptMode: JavascriptMode.unrestricted, | ||
| 525 | + // onWebViewCreated: (WebViewController webViewController) { | ||
| 526 | + // _controller.complete(webViewController); | ||
| 527 | + // }, | ||
| 528 | + // // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 529 | + // // ignore: prefer_collection_literals | ||
| 530 | + // javascriptChannels: <JavascriptChannel>[ | ||
| 531 | + // _toasterJavascriptChannel(context), | ||
| 532 | + // ].toSet(), | ||
| 533 | + // navigationDelegate: (NavigationRequest request) { | ||
| 534 | + // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 535 | + // print('blocking navigation to $request}'); | ||
| 536 | + // return NavigationDecision.prevent; | ||
| 537 | + // } | ||
| 538 | + // print('allowing navigation to $request'); | ||
| 539 | + // return NavigationDecision.navigate; | ||
| 540 | + // }, | ||
| 541 | + // onPageStarted: (String url) { | ||
| 542 | + // print('Page started loading: $url'); | ||
| 543 | + // }, | ||
| 544 | + // onPageFinished: (String url) async { | ||
| 545 | + // print('Page finished loading: $url'); | ||
| 546 | + // // showDownloadProgress(context); | ||
| 547 | + // final dir = await getExternalStorageDirectory(); | ||
| 548 | + // String savePath = dir.path + "/one_key"; | ||
| 549 | + // DioUtil().download(url, savePath, | ||
| 550 | + // onProgress: (received, total) { | ||
| 551 | + // // if (_progress != 100) { | ||
| 552 | + // // int progress = ((received / total) * 100).round(); | ||
| 553 | + // // _progress = progress; | ||
| 554 | + // // _setState(() {}); | ||
| 555 | + // // } | ||
| 556 | + // if (received == total) { | ||
| 557 | + // print('object'); | ||
| 558 | + // //下载完成 | ||
| 559 | + // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 560 | + // } | ||
| 561 | + // }); | ||
| 562 | + // }, | ||
| 563 | + // gestureNavigationEnabled: true, | ||
| 564 | + // ); | ||
| 565 | + // }), | ||
| 566 | + )); | ||
| 98 | } | 567 | } |
| 568 | + | ||
| 569 | + // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 570 | + // return JavascriptChannel( | ||
| 571 | + // name: 'Toaster', | ||
| 572 | + // onMessageReceived: (JavascriptMessage message) { | ||
| 573 | + // Scaffold.of(context).showSnackBar( | ||
| 574 | + // SnackBar(content: Text(message.message)), | ||
| 575 | + // ); | ||
| 576 | + // }); | ||
| 577 | + // } | ||
| 99 | } | 578 | } |
| 100 | 579 | ||
| 101 | -// class WebPage extends StatefulWidget { | 580 | +// class WebPage extends StatelessWidget { |
| 102 | // final String title; | 581 | // final String title; |
| 103 | // final String url; | 582 | // final String url; |
| 104 | // final bool need; | 583 | // final bool need; |
| @@ -106,382 +585,55 @@ class _WebPageState extends State<WebPage> { | @@ -106,382 +585,55 @@ class _WebPageState extends State<WebPage> { | ||
| 106 | // const WebPage({Key key, this.title, this.url, this.need = false}) | 585 | // const WebPage({Key key, this.title, this.url, this.need = false}) |
| 107 | // : super(key: key); | 586 | // : super(key: key); |
| 108 | // @override | 587 | // @override |
| 109 | -// _WebPageState createState() => _WebPageState(); | ||
| 110 | -// } | ||
| 111 | - | ||
| 112 | -// class _WebPageState extends State<WebPage> { | ||
| 113 | -// final GlobalKey webViewKey = GlobalKey(); | ||
| 114 | - | ||
| 115 | -// InAppWebViewController webViewController; | ||
| 116 | -// InAppWebViewGroupOptions options = InAppWebViewGroupOptions( | ||
| 117 | -// crossPlatform: InAppWebViewOptions( | ||
| 118 | -// useShouldOverrideUrlLoading: true, | ||
| 119 | -// useOnDownloadStart: true, | ||
| 120 | -// mediaPlaybackRequiresUserGesture: false, | ||
| 121 | -// ), | ||
| 122 | -// android: AndroidInAppWebViewOptions( | ||
| 123 | -// useHybridComposition: true, | ||
| 124 | -// ), | ||
| 125 | -// ios: IOSInAppWebViewOptions( | ||
| 126 | -// allowsInlineMediaPlayback: true, | ||
| 127 | -// )); | ||
| 128 | - | ||
| 129 | -// PullToRefreshController pullToRefreshController; | ||
| 130 | -// ContextMenu contextMenu; | ||
| 131 | -// String url = ""; | ||
| 132 | -// double progress = 0; | ||
| 133 | -// final urlController = TextEditingController(); | ||
| 134 | -// // Future<void> openFile(filePath) async { | ||
| 135 | -// // final _result = await OpenFile.open(filePath); | ||
| 136 | -// // print(_result.message); | ||
| 137 | - | ||
| 138 | -// // // setState(() { | ||
| 139 | -// // // _openResult = "type=${_result.type} message=${_result.message}"; | ||
| 140 | -// // // }); | ||
| 141 | -// // } | ||
| 142 | - | ||
| 143 | -// @override | ||
| 144 | -// void initState() { | ||
| 145 | -// super.initState(); | ||
| 146 | - | ||
| 147 | -// // Enable hybrid composition. | ||
| 148 | -// _init(); | ||
| 149 | -// } | ||
| 150 | - | ||
| 151 | -// // Future<bool> _checkPermission() async { | ||
| 152 | -// // DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); | ||
| 153 | -// // AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; | ||
| 154 | -// // if (Platform.isAndroid && androidInfo.version.sdkInt <= 28) { | ||
| 155 | -// // final status = await Permission.storage.status; | ||
| 156 | -// // if (status != PermissionStatus.granted) { | ||
| 157 | -// // final result = await Permission.storage.request(); | ||
| 158 | -// // if (result == PermissionStatus.granted) { | ||
| 159 | -// // return true; | ||
| 160 | -// // } | ||
| 161 | -// // } else { | ||
| 162 | -// // return true; | ||
| 163 | -// // } | ||
| 164 | -// // } else { | ||
| 165 | -// // return true; | ||
| 166 | -// // } | ||
| 167 | -// // return false; | ||
| 168 | -// // } | ||
| 169 | - | ||
| 170 | -// // Future<bool> checkPermissionStorage() async { | ||
| 171 | -// // var status = await Permission.storage.status; | ||
| 172 | -// // if (!status.isGranted) { | ||
| 173 | -// // status = await Permission.storage.request(); | ||
| 174 | -// // if (status.isGranted) { | ||
| 175 | -// // return true; | ||
| 176 | -// // } | ||
| 177 | -// // } else { | ||
| 178 | -// // return true; | ||
| 179 | -// // } | ||
| 180 | -// // return false; | ||
| 181 | -// // } | ||
| 182 | - | ||
| 183 | -// _init() async { | ||
| 184 | -// // WidgetsFlutterBinding.ensureInitialized(); | ||
| 185 | -// // await FlutterDownloader.initialize(debug: true); | ||
| 186 | -// if (Platform.isAndroid) { | ||
| 187 | -// await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); | ||
| 188 | - | ||
| 189 | -// var swAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 190 | -// AndroidWebViewFeature.SERVICE_WORKER_BASIC_USAGE); | ||
| 191 | -// var swInterceptAvailable = await AndroidWebViewFeature.isFeatureSupported( | ||
| 192 | -// AndroidWebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); | ||
| 193 | - | ||
| 194 | -// if (swAvailable && swInterceptAvailable) { | ||
| 195 | -// AndroidServiceWorkerController serviceWorkerController = | ||
| 196 | -// AndroidServiceWorkerController.instance(); | ||
| 197 | - | ||
| 198 | -// serviceWorkerController.serviceWorkerClient = | ||
| 199 | -// AndroidServiceWorkerClient( | ||
| 200 | -// shouldInterceptRequest: (request) async { | ||
| 201 | -// print(request); | ||
| 202 | -// return null; | ||
| 203 | -// }, | ||
| 204 | -// ); | ||
| 205 | -// } | ||
| 206 | -// } | ||
| 207 | -// // await FlutterDownloader.initialize( | ||
| 208 | -// // debug: true // optional: set false to disable printing logs to console | ||
| 209 | -// // ); | ||
| 210 | -// // await Permission.storage.request(); | ||
| 211 | -// } | ||
| 212 | - | ||
| 213 | -// @override | ||
| 214 | // Widget build(BuildContext context) { | 588 | // Widget build(BuildContext context) { |
| 589 | +// final Completer<WebViewController> _controller = | ||
| 590 | +// Completer<WebViewController>(); | ||
| 215 | // return Scaffold( | 591 | // return Scaffold( |
| 216 | -// // We're using a Builder here so we have a context that is below the Scaffold | ||
| 217 | -// // to allow calling Scaffold.of(context) so we can show a snackbar. | ||
| 218 | -// appBar: SystemAppBar( | ||
| 219 | -// widget.title, | ||
| 220 | -// onTap: () { | ||
| 221 | -// if (widget.need) { | 592 | +// appBar: SystemAppBar(title, onTap: () { |
| 593 | +// if (need) { | ||
| 594 | +// Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 595 | +// } | ||
| 596 | +// Navigator.of(context).pop(); | ||
| 597 | +// }), | ||
| 598 | +// body: WillPopScope( | ||
| 599 | +// onWillPop: () async { | ||
| 600 | +// if (need) { | ||
| 222 | // Utils.changeStatusColor(color: MyColours.color_199095); | 601 | // Utils.changeStatusColor(color: MyColours.color_199095); |
| 223 | // } | 602 | // } |
| 224 | -// Navigator.of(context).pop(); | 603 | +// return true; |
| 225 | // }, | 604 | // }, |
| 226 | -// ), | ||
| 227 | -// body: WillPopScope( | ||
| 228 | -// onWillPop: () async { | ||
| 229 | -// if (widget.need) { | ||
| 230 | -// Utils.changeStatusColor(color: MyColours.color_199095); | 605 | +// child: WebView( |
| 606 | +// initialUrl: "http://colorcun.com/privacy1.html", | ||
| 607 | +// javascriptMode: JavascriptMode.unrestricted, | ||
| 608 | +// onWebViewCreated: (WebViewController webViewController) { | ||
| 609 | +// // Loading.showLoading(context); | ||
| 610 | +// _controller.complete(webViewController); | ||
| 611 | +// }, | ||
| 612 | +// javascriptChannels: <JavascriptChannel>[ | ||
| 613 | +// _toasterJavascriptChannel(context), | ||
| 614 | +// ].toSet(), | ||
| 615 | +// navigationDelegate: (NavigationRequest request) { | ||
| 616 | +// if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 617 | +// return NavigationDecision.prevent; | ||
| 231 | // } | 618 | // } |
| 232 | -// return true; | 619 | +// return NavigationDecision.navigate; |
| 233 | // }, | 620 | // }, |
| 234 | -// child: Column( | ||
| 235 | -// children: [ | ||
| 236 | -// Expanded( | ||
| 237 | -// child: InAppWebView( | ||
| 238 | -// key: webViewKey, | ||
| 239 | -// // contextMenu: contextMenu, | ||
| 240 | -// initialUrlRequest: URLRequest( | ||
| 241 | -// url: Uri.parse("http://colorcun.com/privacy1.html")), | ||
| 242 | -// // initialFile: "assets/index.html", | ||
| 243 | -// initialUserScripts: UnmodifiableListView<UserScript>([]), | ||
| 244 | -// initialOptions: options, | ||
| 245 | -// pullToRefreshController: pullToRefreshController, | ||
| 246 | -// onWebViewCreated: (controller) { | ||
| 247 | -// webViewController = controller; | ||
| 248 | -// }, | ||
| 249 | -// onLoadStart: (controller, url) { | ||
| 250 | -// // setState(() { | ||
| 251 | -// // this.url = url.toString(); | ||
| 252 | -// // urlController.text = this.url; | ||
| 253 | -// // }); | ||
| 254 | -// }, | ||
| 255 | -// androidOnPermissionRequest: | ||
| 256 | -// (controller, origin, resources) async { | ||
| 257 | -// // return PermissionRequestResponse( | ||
| 258 | -// // resources: resources, | ||
| 259 | -// // action: PermissionRequestResponseAction.GRANT); | ||
| 260 | -// }, | ||
| 261 | -// shouldOverrideUrlLoading: | ||
| 262 | -// (controller, navigationAction) async { | ||
| 263 | -// var uri = navigationAction.request.url; | ||
| 264 | - | ||
| 265 | -// if (![ | ||
| 266 | -// "http", | ||
| 267 | -// "https", | ||
| 268 | -// "file", | ||
| 269 | -// "chrome", | ||
| 270 | -// "data", | ||
| 271 | -// "javascript", | ||
| 272 | -// "about" | ||
| 273 | -// ].contains(uri.scheme)) { | ||
| 274 | -// if (await canLaunch(url)) { | ||
| 275 | -// // Launch the App | ||
| 276 | -// await launch( | ||
| 277 | -// url, | ||
| 278 | -// ); | ||
| 279 | -// // and cancel the request | ||
| 280 | -// return NavigationActionPolicy.CANCEL; | ||
| 281 | -// } | ||
| 282 | -// } | ||
| 283 | - | ||
| 284 | -// return NavigationActionPolicy.ALLOW; | ||
| 285 | -// }, | ||
| 286 | -// onLoadStop: (controller, url) async { | ||
| 287 | -// // pullToRefreshController.endRefreshing(); | ||
| 288 | -// // setState(() { | ||
| 289 | -// // this.url = url.toString(); | ||
| 290 | -// // urlController.text = this.url; | ||
| 291 | -// // }); | ||
| 292 | -// }, | ||
| 293 | -// onLoadError: (controller, url, code, message) { | ||
| 294 | -// pullToRefreshController.endRefreshing(); | ||
| 295 | -// }, | ||
| 296 | -// onProgressChanged: (controller, progress) { | ||
| 297 | -// // if (progress == 100) { | ||
| 298 | -// pullToRefreshController.endRefreshing(); | ||
| 299 | -// // } | ||
| 300 | -// // setState(() { | ||
| 301 | -// // this.progress = progress / 100; | ||
| 302 | -// // urlController.text = this.url; | ||
| 303 | -// // }); | ||
| 304 | -// }, | ||
| 305 | -// onUpdateVisitedHistory: (controller, url, androidIsReload) { | ||
| 306 | -// // setState(() { | ||
| 307 | -// // this.url = url.toString(); | ||
| 308 | -// // urlController.text = this.url; | ||
| 309 | -// // }); | ||
| 310 | -// }, | ||
| 311 | -// onConsoleMessage: (controller, consoleMessage) { | ||
| 312 | -// print(consoleMessage); | ||
| 313 | -// }, | ||
| 314 | -// onDownloadStart: (controller, url) async { | ||
| 315 | -// // print("onDownloadStart $url"); | ||
| 316 | -// // Utils.showToast('开始下载...'); | ||
| 317 | -// // // final taskId = await FlutterDownloader.enqueue( | ||
| 318 | -// // // url: url.toString(), | ||
| 319 | -// // // savedDir: (await getExternalStorageDirectory()).path, | ||
| 320 | -// // // showNotification: | ||
| 321 | -// // // true, // show download progress in status bar (for Android) | ||
| 322 | -// // // openFileFromNotification: | ||
| 323 | -// // // true, // click on notification to open downloaded file (for Android) | ||
| 324 | -// // // ); | ||
| 325 | -// // final dir = await getExternalStorageDirectory(); | ||
| 326 | -// // String savePath = dir.path + "/one_key"; | ||
| 327 | - | ||
| 328 | -// // Directory directory = new Directory(savePath); | ||
| 329 | -// // if (directory.existsSync()) { | ||
| 330 | -// // //删除历史apk | ||
| 331 | -// // final List<FileSystemEntity> files = directory.listSync(); | ||
| 332 | -// // for (FileSystemEntity file in files) { | ||
| 333 | -// // file.deleteSync(); | ||
| 334 | -// // } | ||
| 335 | -// // } | ||
| 336 | -// // DioUtil().download(url.toString(), savePath, | ||
| 337 | -// // onProgress: (received, total) { | ||
| 338 | -// // // if (_progress != 100) { | ||
| 339 | -// // // int progress = ((received / total) * 100).round(); | ||
| 340 | -// // // _progress = progress; | ||
| 341 | -// // // _setState(() {}); | ||
| 342 | -// // // } | ||
| 343 | -// // if (received == total) { | ||
| 344 | -// // print('object'); | ||
| 345 | -// // Utils.showToast('文件已保存在${savePath}'); | ||
| 346 | -// // // openFile(savePath); | ||
| 347 | -// // //下载完成 | ||
| 348 | -// // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 349 | -// // } | ||
| 350 | -// // }); | ||
| 351 | -// // // }, | ||
| 352 | -// // // DioUtil().download(url.toString(), | ||
| 353 | -// // // (await getExternalStorageDirectory()).path, | ||
| 354 | -// // // onProgress: (received, total) { | ||
| 355 | -// // // // if (_progress != 100) { | ||
| 356 | -// // // // int progress = ((received / total) * 100).round(); | ||
| 357 | -// // // // _progress = progress; | ||
| 358 | -// // // // _setState(() {}); | ||
| 359 | -// // // // } | ||
| 360 | -// // // if (received == total) { | ||
| 361 | -// // // //下载完成 | ||
| 362 | -// // // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 363 | -// // // } | ||
| 364 | -// // // }); | ||
| 365 | -// }, | ||
| 366 | -// )) | ||
| 367 | -// ], | ||
| 368 | -// ) | ||
| 369 | -// // Builder(builder: (BuildContext context) { | ||
| 370 | -// // return WebView( | ||
| 371 | -// // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 372 | -// // javascriptMode: JavascriptMode.unrestricted, | ||
| 373 | -// // onWebViewCreated: (WebViewController webViewController) { | ||
| 374 | -// // _controller.complete(webViewController); | ||
| 375 | -// // }, | ||
| 376 | -// // // TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
| 377 | -// // // ignore: prefer_collection_literals | ||
| 378 | -// // javascriptChannels: <JavascriptChannel>[ | ||
| 379 | -// // _toasterJavascriptChannel(context), | ||
| 380 | -// // ].toSet(), | ||
| 381 | -// // navigationDelegate: (NavigationRequest request) { | ||
| 382 | -// // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 383 | -// // print('blocking navigation to $request}'); | ||
| 384 | -// // return NavigationDecision.prevent; | ||
| 385 | -// // } | ||
| 386 | -// // print('allowing navigation to $request'); | ||
| 387 | -// // return NavigationDecision.navigate; | ||
| 388 | -// // }, | ||
| 389 | -// // onPageStarted: (String url) { | ||
| 390 | -// // print('Page started loading: $url'); | ||
| 391 | -// // }, | ||
| 392 | -// // onPageFinished: (String url) async { | ||
| 393 | -// // print('Page finished loading: $url'); | ||
| 394 | -// // // showDownloadProgress(context); | ||
| 395 | -// // final dir = await getExternalStorageDirectory(); | ||
| 396 | -// // String savePath = dir.path + "/one_key"; | ||
| 397 | -// // DioUtil().download(url, savePath, | ||
| 398 | -// // onProgress: (received, total) { | ||
| 399 | -// // // if (_progress != 100) { | ||
| 400 | -// // // int progress = ((received / total) * 100).round(); | ||
| 401 | -// // // _progress = progress; | ||
| 402 | -// // // _setState(() {}); | ||
| 403 | -// // // } | ||
| 404 | -// // if (received == total) { | ||
| 405 | -// // print('object'); | ||
| 406 | -// // //下载完成 | ||
| 407 | -// // // InstallPlugin.installApk(savePath, "com.naji.one_key"); | ||
| 408 | -// // } | ||
| 409 | -// // }); | ||
| 410 | -// // }, | ||
| 411 | -// // gestureNavigationEnabled: true, | ||
| 412 | -// // ); | ||
| 413 | -// // }), | ||
| 414 | -// )); | 621 | +// onPageStarted: (String url) {}, |
| 622 | +// onPageFinished: (String url) { | ||
| 623 | +// // Loading.hideLoading(context); | ||
| 624 | +// }, | ||
| 625 | +// gestureNavigationEnabled: true, | ||
| 626 | +// )), | ||
| 627 | +// ); | ||
| 415 | // } | 628 | // } |
| 416 | 629 | ||
| 417 | -// // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 418 | -// // return JavascriptChannel( | ||
| 419 | -// // name: 'Toaster', | ||
| 420 | -// // onMessageReceived: (JavascriptMessage message) { | ||
| 421 | -// // Scaffold.of(context).showSnackBar( | ||
| 422 | -// // SnackBar(content: Text(message.message)), | ||
| 423 | -// // ); | ||
| 424 | -// // }); | ||
| 425 | -// // } | 630 | +// JavascriptChannel _toasterJavascriptChannel(BuildContext context) { |
| 631 | +// return JavascriptChannel( | ||
| 632 | +// name: 'Toaster', | ||
| 633 | +// onMessageReceived: (JavascriptMessage message) { | ||
| 634 | +// Scaffold.of(context).showSnackBar( | ||
| 635 | +// SnackBar(content: Text(message.message)), | ||
| 636 | +// ); | ||
| 637 | +// }); | ||
| 638 | +// } | ||
| 426 | // } | 639 | // } |
| 427 | - | ||
| 428 | -// // class WebPage extends StatelessWidget { | ||
| 429 | -// // final String title; | ||
| 430 | -// // final String url; | ||
| 431 | -// // final bool need; | ||
| 432 | - | ||
| 433 | -// // const WebPage({Key key, this.title, this.url, this.need = false}) | ||
| 434 | -// // : super(key: key); | ||
| 435 | -// // @override | ||
| 436 | -// // Widget build(BuildContext context) { | ||
| 437 | -// // final Completer<WebViewController> _controller = | ||
| 438 | -// // Completer<WebViewController>(); | ||
| 439 | -// // return Scaffold( | ||
| 440 | -// // appBar: SystemAppBar(title, onTap: () { | ||
| 441 | -// // if (need) { | ||
| 442 | -// // Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 443 | -// // } | ||
| 444 | -// // Navigator.of(context).pop(); | ||
| 445 | -// // }), | ||
| 446 | -// // body: WillPopScope( | ||
| 447 | -// // onWillPop: () async { | ||
| 448 | -// // if (need) { | ||
| 449 | -// // Utils.changeStatusColor(color: MyColours.color_199095); | ||
| 450 | -// // } | ||
| 451 | -// // return true; | ||
| 452 | -// // }, | ||
| 453 | -// // child: WebView( | ||
| 454 | -// // initialUrl: "http://colorcun.com/privacy1.html", | ||
| 455 | -// // javascriptMode: JavascriptMode.unrestricted, | ||
| 456 | -// // onWebViewCreated: (WebViewController webViewController) { | ||
| 457 | -// // // Loading.showLoading(context); | ||
| 458 | -// // _controller.complete(webViewController); | ||
| 459 | -// // }, | ||
| 460 | -// // javascriptChannels: <JavascriptChannel>[ | ||
| 461 | -// // _toasterJavascriptChannel(context), | ||
| 462 | -// // ].toSet(), | ||
| 463 | -// // navigationDelegate: (NavigationRequest request) { | ||
| 464 | -// // if (request.url.startsWith('https://www.youtube.com/')) { | ||
| 465 | -// // return NavigationDecision.prevent; | ||
| 466 | -// // } | ||
| 467 | -// // return NavigationDecision.navigate; | ||
| 468 | -// // }, | ||
| 469 | -// // onPageStarted: (String url) {}, | ||
| 470 | -// // onPageFinished: (String url) { | ||
| 471 | -// // // Loading.hideLoading(context); | ||
| 472 | -// // }, | ||
| 473 | -// // gestureNavigationEnabled: true, | ||
| 474 | -// // )), | ||
| 475 | -// // ); | ||
| 476 | -// // } | ||
| 477 | - | ||
| 478 | -// // JavascriptChannel _toasterJavascriptChannel(BuildContext context) { | ||
| 479 | -// // return JavascriptChannel( | ||
| 480 | -// // name: 'Toaster', | ||
| 481 | -// // onMessageReceived: (JavascriptMessage message) { | ||
| 482 | -// // Scaffold.of(context).showSnackBar( | ||
| 483 | -// // SnackBar(content: Text(message.message)), | ||
| 484 | -// // ); | ||
| 485 | -// // }); | ||
| 486 | -// // } | ||
| 487 | -// // } |
| @@ -41,7 +41,7 @@ class MyCustomerListPage extends StatefulWidget { | @@ -41,7 +41,7 @@ class MyCustomerListPage extends StatefulWidget { | ||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | class _MyCustomerListPageState extends State<MyCustomerListPage> | 43 | class _MyCustomerListPageState extends State<MyCustomerListPage> |
| 44 | - with TickerProviderStateMixin, SingleTickerProviderStateMixin { | 44 | + with TickerProviderStateMixin{ |
| 45 | List _tabBarTitle; | 45 | List _tabBarTitle; |
| 46 | TabController tabController; | 46 | TabController tabController; |
| 47 | 47 |
| @@ -38,7 +38,7 @@ class MyShowCustomerListPage extends StatefulWidget { | @@ -38,7 +38,7 @@ class MyShowCustomerListPage extends StatefulWidget { | ||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | class _MyShowCustomerListPageState extends State<MyShowCustomerListPage> | 40 | class _MyShowCustomerListPageState extends State<MyShowCustomerListPage> |
| 41 | - with TickerProviderStateMixin, SingleTickerProviderStateMixin { | 41 | + with TickerProviderStateMixin { |
| 42 | List _tabBarTitle; | 42 | List _tabBarTitle; |
| 43 | TabController tabController; | 43 | TabController tabController; |
| 44 | 44 |
| @@ -43,7 +43,7 @@ class CustomerListPage extends StatefulWidget { | @@ -43,7 +43,7 @@ class CustomerListPage extends StatefulWidget { | ||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | class _CustomerListPageState extends State<CustomerListPage> | 45 | class _CustomerListPageState extends State<CustomerListPage> |
| 46 | - with TickerProviderStateMixin, SingleTickerProviderStateMixin { | 46 | + with TickerProviderStateMixin{ |
| 47 | List _tabBarTitle; | 47 | List _tabBarTitle; |
| 48 | TabController tabController; | 48 | TabController tabController; |
| 49 | 49 |
| @@ -38,7 +38,7 @@ class ShowCustomerListPage extends StatefulWidget { | @@ -38,7 +38,7 @@ class ShowCustomerListPage extends StatefulWidget { | ||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | class _ShowCustomerListPageState extends State<ShowCustomerListPage> | 40 | class _ShowCustomerListPageState extends State<ShowCustomerListPage> |
| 41 | - with TickerProviderStateMixin, SingleTickerProviderStateMixin { | 41 | + with TickerProviderStateMixin { |
| 42 | List _tabBarTitle; | 42 | List _tabBarTitle; |
| 43 | TabController tabController; | 43 | TabController tabController; |
| 44 | 44 | ||
| @@ -73,7 +73,6 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage> | @@ -73,7 +73,6 @@ class _ShowCustomerListPageState extends State<ShowCustomerListPage> | ||
| 73 | "gid": widget.gid, | 73 | "gid": widget.gid, |
| 74 | }; | 74 | }; |
| 75 | await customerProvider.getSellerGuestByGid(context, params); | 75 | await customerProvider.getSellerGuestByGid(context, params); |
| 76 | - | ||
| 77 | } | 76 | } |
| 78 | 77 | ||
| 79 | /// 搜索框 | 78 | /// 搜索框 |
| 1 | +import 'package:audioplayers/audioplayers.dart'; | ||
| 1 | import 'package:common_utils/common_utils.dart'; | 2 | import 'package:common_utils/common_utils.dart'; |
| 2 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 3 | import 'package:one_key/constant/constant.dart'; | 4 | import 'package:one_key/constant/constant.dart'; |
| @@ -7,12 +8,12 @@ import 'package:one_key/net/dio_util.dart'; | @@ -7,12 +8,12 @@ import 'package:one_key/net/dio_util.dart'; | ||
| 7 | import 'package:one_key/net/http_url.dart'; | 8 | import 'package:one_key/net/http_url.dart'; |
| 8 | 9 | ||
| 9 | import 'package:one_key/utils/dialog_util.dart'; | 10 | import 'package:one_key/utils/dialog_util.dart'; |
| 10 | -import 'package:audioplayers/audio_cache.dart'; | 11 | +// import 'package:audioplayers/audio_cache.dart'; |
| 11 | // import 'package:audioplayers/audioplayers.dart'; | 12 | // import 'package:audioplayers/audioplayers.dart'; |
| 12 | import 'package:one_key/utils/utils.dart'; | 13 | import 'package:one_key/utils/utils.dart'; |
| 13 | 14 | ||
| 14 | class MessageDialogModel extends ChangeNotifier { | 15 | class MessageDialogModel extends ChangeNotifier { |
| 15 | - final _player = AudioCache(); | 16 | + final _player = AudioPlayer(); |
| 16 | 17 | ||
| 17 | bool showMessageDialog = false; | 18 | bool showMessageDialog = false; |
| 18 | 19 | ||
| @@ -20,9 +21,9 @@ class MessageDialogModel extends ChangeNotifier { | @@ -20,9 +21,9 @@ class MessageDialogModel extends ChangeNotifier { | ||
| 20 | List<Message> unMessagesOnline = []; //未读在线预定 | 21 | List<Message> unMessagesOnline = []; //未读在线预定 |
| 21 | List<Message> unMessagesOrder = []; //未读提前点餐 | 22 | List<Message> unMessagesOrder = []; //未读提前点餐 |
| 22 | 23 | ||
| 23 | - void init() { | ||
| 24 | - _player.load("tts_online.mp3"); | ||
| 25 | - } | 24 | + // void init() { |
| 25 | + // _player.load("tts_online.mp3"); | ||
| 26 | + // } | ||
| 26 | 27 | ||
| 27 | /// 播放 | 28 | /// 播放 |
| 28 | void play(String message_type) { | 29 | void play(String message_type) { |
| @@ -104,10 +104,10 @@ class StoreBaseIndoProvider with ChangeNotifier { | @@ -104,10 +104,10 @@ class StoreBaseIndoProvider with ChangeNotifier { | ||
| 104 | } catch (e) { | 104 | } catch (e) { |
| 105 | Loading.hideLoading(context); | 105 | Loading.hideLoading(context); |
| 106 | return new Future.error(new DioError( | 106 | return new Future.error(new DioError( |
| 107 | - // requestOptions: response.requestOptions, | 107 | + requestOptions: response.requestOptions, |
| 108 | response: response, | 108 | response: response, |
| 109 | error: "data parsing exception...", | 109 | error: "data parsing exception...", |
| 110 | - type: DioErrorType.RESPONSE, | 110 | + type: DioErrorType.response, |
| 111 | )); | 111 | )); |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 1 | -## 1.0.7 | ||
| 2 | - | ||
| 3 | -* Minor documentation update to indicate known issue on iOS 13.4 and 13.5. | ||
| 4 | - * See: https://github.com/flutter/flutter/issues/53490 | ||
| 5 | - | ||
| 6 | -## 1.0.6 | ||
| 7 | - | ||
| 8 | -* Invoke the WebView.onWebResourceError on iOS when the webview content process crashes. | ||
| 9 | - | ||
| 10 | -## 1.0.5 | ||
| 11 | - | ||
| 12 | -* Fix example in the readme. | ||
| 13 | - | ||
| 14 | -## 1.0.4 | ||
| 15 | - | ||
| 16 | -* Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`. | ||
| 17 | - | ||
| 18 | -## 1.0.3 | ||
| 19 | - | ||
| 20 | -* Update android compileSdkVersion to 29. | ||
| 21 | - | ||
| 22 | -## 1.0.2 | ||
| 23 | - | ||
| 24 | -* Android Code Inspection and Clean up. | ||
| 25 | - | ||
| 26 | -## 1.0.1 | ||
| 27 | - | ||
| 28 | -* Add documentation for `WebViewPlatformCreatedCallback`. | ||
| 29 | - | ||
| 30 | -## 1.0.0 - Out of developer preview 🎉. | ||
| 31 | - | ||
| 32 | -* Bumped the minimal Flutter SDK to 1.22 where platform views are out of developer preview, and | ||
| 33 | -performing better on iOS. Flutter 1.22 no longer requires adding the | ||
| 34 | -`io.flutter.embedded_views_preview` flag to `Info.plist`. | ||
| 35 | - | ||
| 36 | -* Added support for Hybrid Composition on Android (see opt-in instructions in [README](https://github.com/flutter/plugins/blob/master/packages/webview_flutter/README.md#android)) | ||
| 37 | - * Lowered the required Android API to 19 (was previously 20): [#23728](https://github.com/flutter/flutter/issues/23728). | ||
| 38 | - * Fixed the following issues: | ||
| 39 | - * 🎹 Keyboard: [#41089](https://github.com/flutter/flutter/issues/41089), [#36478](https://github.com/flutter/flutter/issues/36478), [#51254](https://github.com/flutter/flutter/issues/51254), [#50716](https://github.com/flutter/flutter/issues/50716), [#55724](https://github.com/flutter/flutter/issues/55724), [#56513](https://github.com/flutter/flutter/issues/56513), [#56515](https://github.com/flutter/flutter/issues/56515), [#61085](https://github.com/flutter/flutter/issues/61085), [#62205](https://github.com/flutter/flutter/issues/62205), [#62547](https://github.com/flutter/flutter/issues/62547), [#58943](https://github.com/flutter/flutter/issues/58943), [#56361](https://github.com/flutter/flutter/issues/56361), [#56361](https://github.com/flutter/flutter/issues/42902), [#40716](https://github.com/flutter/flutter/issues/40716), [#37989](https://github.com/flutter/flutter/issues/37989), [#27924](https://github.com/flutter/flutter/issues/27924). | ||
| 40 | - * ♿️ Accessibility: [#50716](https://github.com/flutter/flutter/issues/50716). | ||
| 41 | - * ⚡️ Performance: [#61280](https://github.com/flutter/flutter/issues/61280), [#31243](https://github.com/flutter/flutter/issues/31243), [#52211](https://github.com/flutter/flutter/issues/52211). | ||
| 42 | - * 📹 Video: [#5191](https://github.com/flutter/flutter/issues/5191). | ||
| 43 | - | ||
| 44 | -## 0.3.24 | ||
| 45 | - | ||
| 46 | -* Keep handling deprecated Android v1 classes for backward compatibility. | ||
| 47 | - | ||
| 48 | -## 0.3.23 | ||
| 49 | - | ||
| 50 | -* Handle WebView multi-window support. | ||
| 51 | - | ||
| 52 | -## 0.3.22+2 | ||
| 53 | - | ||
| 54 | -* Update package:e2e reference to use the local version in the flutter/plugins | ||
| 55 | - repository. | ||
| 56 | - | ||
| 57 | -## 0.3.22+1 | ||
| 58 | - | ||
| 59 | -* Update the `setAndGetScrollPosition` to use hard coded values and add a `pumpAndSettle` call. | ||
| 60 | - | ||
| 61 | -## 0.3.22 | ||
| 62 | - | ||
| 63 | -* Add support for passing a failing url. | ||
| 64 | - | ||
| 65 | -## 0.3.21 | ||
| 66 | - | ||
| 67 | -* Enable programmatic scrolling using Android's WebView.scrollTo & iOS WKWebView.scrollView.contentOffset. | ||
| 68 | - | ||
| 69 | -## 0.3.20+2 | ||
| 70 | - | ||
| 71 | -* Fix CocoaPods podspec lint warnings. | ||
| 72 | - | ||
| 73 | -## 0.3.20+1 | ||
| 74 | - | ||
| 75 | -* OCMock module import -> #import, unit tests compile generated as library. | ||
| 76 | -* Fix select drop down crash on old Android tablets (https://github.com/flutter/flutter/issues/54164). | ||
| 77 | - | ||
| 78 | -## 0.3.20 | ||
| 79 | - | ||
| 80 | -* Added support for receiving web resource loading errors. See `WebView.onWebResourceError`. | ||
| 81 | - | ||
| 82 | -## 0.3.19+10 | ||
| 83 | - | ||
| 84 | -* Replace deprecated `getFlutterEngine` call on Android. | ||
| 85 | - | ||
| 86 | -## 0.3.19+9 | ||
| 87 | - | ||
| 88 | -* Remove example app's iOS workspace settings. | ||
| 89 | - | ||
| 90 | -## 0.3.19+8 | ||
| 91 | - | ||
| 92 | -* Make the pedantic dev_dependency explicit. | ||
| 93 | - | ||
| 94 | -## 0.3.19+7 | ||
| 95 | - | ||
| 96 | -* Remove the Flutter SDK constraint upper bound. | ||
| 97 | - | ||
| 98 | -## 0.3.19+6 | ||
| 99 | - | ||
| 100 | -* Enable opening links that target the "_blank" window (links open in same window). | ||
| 101 | - | ||
| 102 | -## 0.3.19+5 | ||
| 103 | - | ||
| 104 | -* On iOS, always keep contentInsets of the WebView to be 0. | ||
| 105 | -* Fix XCTest case to follow XCTest naming convention. | ||
| 106 | - | ||
| 107 | -## 0.3.19+4 | ||
| 108 | - | ||
| 109 | -* On iOS, fix the scroll view content inset is automatically adjusted. After the fix, the content position of the WebView is customizable by Flutter. | ||
| 110 | -* Fix an iOS 13 bug where the scroll indicator shows at random location. | ||
| 111 | - | ||
| 112 | -## 0.3.19+3 | ||
| 113 | - | ||
| 114 | -* Setup XCTests. | ||
| 115 | - | ||
| 116 | -## 0.3.19+2 | ||
| 117 | - | ||
| 118 | -* Migrate from deprecated BinaryMessages to ServicesBinding.instance.defaultBinaryMessenger. | ||
| 119 | - | ||
| 120 | -## 0.3.19+1 | ||
| 121 | - | ||
| 122 | -* Raise min Flutter SDK requirement to the latest stable. v2 embedding apps no | ||
| 123 | - longer need to special case their Flutter SDK requirement like they have | ||
| 124 | - since v0.3.15+3. | ||
| 125 | - | ||
| 126 | -## 0.3.19 | ||
| 127 | - | ||
| 128 | -* Add setting for iOS to allow gesture based navigation. | ||
| 129 | - | ||
| 130 | -## 0.3.18+1 | ||
| 131 | - | ||
| 132 | -* Be explicit that keyboard is not ready for production in README.md. | ||
| 133 | - | ||
| 134 | -## 0.3.18 | ||
| 135 | - | ||
| 136 | -* Add support for onPageStarted event. | ||
| 137 | -* Remove the deprecated `author:` field from pubspec.yaml | ||
| 138 | -* Migrate to the new pubspec platforms manifest. | ||
| 139 | -* Require Flutter SDK 1.10.0 or greater. | ||
| 140 | - | ||
| 141 | -## 0.3.17 | ||
| 142 | - | ||
| 143 | -* Fix pedantic lint errors. Added missing documentation and awaited some futures | ||
| 144 | - in tests and the example app. | ||
| 145 | - | ||
| 146 | -## 0.3.16 | ||
| 147 | - | ||
| 148 | -* Add support for async NavigationDelegates. Synchronous NavigationDelegates | ||
| 149 | - should still continue to function without any change in behavior. | ||
| 150 | - | ||
| 151 | -## 0.3.15+3 | ||
| 152 | - | ||
| 153 | -* Re-land support for the v2 Android embedding. This correctly sets the minimum | ||
| 154 | - SDK to the latest stable and avoid any compile errors. *WARNING:* the V2 | ||
| 155 | - embedding itself still requires the current Flutter master channel | ||
| 156 | - (flutter/flutter@1d4d63a) for text input to work properly on all Android | ||
| 157 | - versions. | ||
| 158 | - | ||
| 159 | -## 0.3.15+2 | ||
| 160 | - | ||
| 161 | -* Remove AndroidX warnings. | ||
| 162 | - | ||
| 163 | -## 0.3.15+1 | ||
| 164 | - | ||
| 165 | -* Revert the prior embedding support add since it requires an API that hasn't | ||
| 166 | - rolled to stable. | ||
| 167 | - | ||
| 168 | -## 0.3.15 | ||
| 169 | - | ||
| 170 | -* Add support for the v2 Android embedding. This shouldn't affect existing | ||
| 171 | - functionality. Plugin authors who use the V2 embedding can now register the | ||
| 172 | - plugin and expect that it correctly responds to app lifecycle changes. | ||
| 173 | - | ||
| 174 | -## 0.3.14+2 | ||
| 175 | - | ||
| 176 | -* Define clang module for iOS. | ||
| 177 | - | ||
| 178 | -## 0.3.14+1 | ||
| 179 | - | ||
| 180 | -* Allow underscores anywhere for Javascript Channel name. | ||
| 181 | - | ||
| 182 | -## 0.3.14 | ||
| 183 | - | ||
| 184 | -* Added a getTitle getter to WebViewController. | ||
| 185 | - | ||
| 186 | -## 0.3.13 | ||
| 187 | - | ||
| 188 | -* Add an optional `userAgent` property to set a custom User Agent. | ||
| 189 | - | ||
| 190 | -## 0.3.12+1 | ||
| 191 | - | ||
| 192 | -* Temporarily revert getTitle (doing this as a patch bump shortly after publishing). | ||
| 193 | - | ||
| 194 | -## 0.3.12 | ||
| 195 | - | ||
| 196 | -* Added a getTitle getter to WebViewController. | ||
| 197 | - | ||
| 198 | -## 0.3.11+6 | ||
| 199 | - | ||
| 200 | -* Calling destroy on Android webview when flutter webview is getting disposed. | ||
| 201 | - | ||
| 202 | -## 0.3.11+5 | ||
| 203 | - | ||
| 204 | -* Reduce compiler warnings regarding iOS9 compatibility by moving a single | ||
| 205 | - method back into a `@available` block. | ||
| 206 | - | ||
| 207 | -## 0.3.11+4 | ||
| 208 | - | ||
| 209 | -* Removed noisy log messages on iOS. | ||
| 210 | - | ||
| 211 | -## 0.3.11+3 | ||
| 212 | - | ||
| 213 | -* Apply the display listeners workaround that was shipped in 0.3.11+1 on | ||
| 214 | - all Android versions prior to P. | ||
| 215 | - | ||
| 216 | -## 0.3.11+2 | ||
| 217 | - | ||
| 218 | -* Add fix for input connection being dropped after a screen resize on certain | ||
| 219 | - Android devices. | ||
| 220 | - | ||
| 221 | -## 0.3.11+1 | ||
| 222 | - | ||
| 223 | -* Work around a bug in old Android WebView versions that was causing a crash | ||
| 224 | - when resizing the webview on old devices. | ||
| 225 | - | ||
| 226 | -## 0.3.11 | ||
| 227 | - | ||
| 228 | -* Add an initialAutoMediaPlaybackPolicy setting for controlling how auto media | ||
| 229 | - playback is restricted. | ||
| 230 | - | ||
| 231 | -## 0.3.10+5 | ||
| 232 | - | ||
| 233 | -* Add dependency on `androidx.annotation:annotation:1.0.0`. | ||
| 234 | - | ||
| 235 | -## 0.3.10+4 | ||
| 236 | - | ||
| 237 | -* Add keyboard text to README. | ||
| 238 | - | ||
| 239 | -## 0.3.10+3 | ||
| 240 | - | ||
| 241 | -* Don't log an unknown setting key error for 'debuggingEnabled' on iOS. | ||
| 242 | - | ||
| 243 | -## 0.3.10+2 | ||
| 244 | - | ||
| 245 | -* Fix InputConnection being lost when combined with route transitions. | ||
| 246 | - | ||
| 247 | -## 0.3.10+1 | ||
| 248 | - | ||
| 249 | -* Add support for simultaenous Flutter `TextInput` and WebView text fields. | ||
| 250 | - | ||
| 251 | -## 0.3.10 | ||
| 252 | - | ||
| 253 | -* Add partial WebView keyboard support for Android versions prior to N. Support | ||
| 254 | - for UIs that also have Flutter `TextInput` fields is still pending. This basic | ||
| 255 | - support currently only works with Flutter `master`. The keyboard will still | ||
| 256 | - appear when it previously did not when run with older versions of Flutter. But | ||
| 257 | - if the WebView is resized while showing the keyboard the text field will need | ||
| 258 | - to be focused multiple times for any input to be registered. | ||
| 259 | - | ||
| 260 | -## 0.3.9+2 | ||
| 261 | - | ||
| 262 | -* Update Dart code to conform to current Dart formatter. | ||
| 263 | - | ||
| 264 | -## 0.3.9+1 | ||
| 265 | - | ||
| 266 | -* Add missing template type parameter to `invokeMethod` calls. | ||
| 267 | -* Bump minimum Flutter version to 1.5.0. | ||
| 268 | -* Replace invokeMethod with invokeMapMethod wherever necessary. | ||
| 269 | - | ||
| 270 | -## 0.3.9 | ||
| 271 | - | ||
| 272 | -* Allow external packages to provide webview implementations for new platforms. | ||
| 273 | - | ||
| 274 | -## 0.3.8+1 | ||
| 275 | - | ||
| 276 | -* Suppress deprecation warning for BinaryMessages. See: https://github.com/flutter/flutter/issues/33446 | ||
| 277 | - | ||
| 278 | -## 0.3.8 | ||
| 279 | - | ||
| 280 | -* Add `debuggingEnabled` property. | ||
| 281 | - | ||
| 282 | -## 0.3.7+1 | ||
| 283 | - | ||
| 284 | -* Fix an issue where JavaScriptChannel messages weren't sent from the platform thread on Android. | ||
| 285 | - | ||
| 286 | -## 0.3.7 | ||
| 287 | - | ||
| 288 | -* Fix loadUrlWithHeaders flaky test. | ||
| 289 | - | ||
| 290 | -## 0.3.6+1 | ||
| 291 | - | ||
| 292 | -* Remove un-used method params in webview\_flutter | ||
| 293 | - | ||
| 294 | -## 0.3.6 | ||
| 295 | - | ||
| 296 | -* Add an optional `headers` field to the controller. | ||
| 297 | - | ||
| 298 | -## 0.3.5+5 | ||
| 299 | - | ||
| 300 | -* Fixed error in documentation of `javascriptChannels`. | ||
| 301 | - | ||
| 302 | -## 0.3.5+4 | ||
| 303 | - | ||
| 304 | -* Fix bugs in the example app by updating it to use a `StatefulWidget`. | ||
| 305 | - | ||
| 306 | -## 0.3.5+3 | ||
| 307 | - | ||
| 308 | -* Make sure to post javascript channel messages from the platform thread. | ||
| 309 | - | ||
| 310 | -## 0.3.5+2 | ||
| 311 | - | ||
| 312 | -* Fix crash from `NavigationDelegate` on later versions of Android. | ||
| 313 | - | ||
| 314 | -## 0.3.5+1 | ||
| 315 | - | ||
| 316 | -* Fix a bug where updates to onPageFinished were ignored. | ||
| 317 | - | ||
| 318 | -## 0.3.5 | ||
| 319 | - | ||
| 320 | -* Added an onPageFinished callback. | ||
| 321 | - | ||
| 322 | -## 0.3.4 | ||
| 323 | - | ||
| 324 | -* Support specifying navigation delegates that can prevent navigations from being executed. | ||
| 325 | - | ||
| 326 | -## 0.3.3+2 | ||
| 327 | - | ||
| 328 | -* Exclude LongPress handler from semantics tree since it does nothing. | ||
| 329 | - | ||
| 330 | -## 0.3.3+1 | ||
| 331 | - | ||
| 332 | -* Fixed a memory leak on Android - the WebView was not properly disposed. | ||
| 333 | - | ||
| 334 | -## 0.3.3 | ||
| 335 | - | ||
| 336 | -* Add clearCache method to WebView controller. | ||
| 337 | - | ||
| 338 | -## 0.3.2+1 | ||
| 339 | - | ||
| 340 | -* Log a more detailed warning at build time about the previous AndroidX | ||
| 341 | - migration. | ||
| 342 | - | ||
| 343 | -## 0.3.2 | ||
| 344 | - | ||
| 345 | -* Added CookieManager to interface with WebView cookies. Currently has the ability to clear cookies. | ||
| 346 | - | ||
| 347 | -## 0.3.1 | ||
| 348 | - | ||
| 349 | -* Added JavaScript channels to facilitate message passing from JavaScript code running inside | ||
| 350 | - the WebView to the Flutter app's Dart code. | ||
| 351 | - | ||
| 352 | -## 0.3.0 | ||
| 353 | - | ||
| 354 | -* **Breaking change**. Migrate from the deprecated original Android Support | ||
| 355 | - Library to AndroidX. This shouldn't result in any functional changes, but it | ||
| 356 | - requires any Android apps using this plugin to [also | ||
| 357 | - migrate](https://developer.android.com/jetpack/androidx/migrate) if they're | ||
| 358 | - using the original support library. | ||
| 359 | - | ||
| 360 | -## 0.2.0 | ||
| 361 | - | ||
| 362 | -* Added a evaluateJavascript method to WebView controller. | ||
| 363 | -* (BREAKING CHANGE) Renamed the `JavaScriptMode` enum to `JavascriptMode`, and the WebView `javasScriptMode` parameter to `javascriptMode`. | ||
| 364 | - | ||
| 365 | -## 0.1.2 | ||
| 366 | - | ||
| 367 | -* Added a reload method to the WebView controller. | ||
| 368 | - | ||
| 369 | -## 0.1.1 | ||
| 370 | - | ||
| 371 | -* Added a `currentUrl` accessor for the WebView controller to look up what URL | ||
| 372 | - is being displayed. | ||
| 373 | - | ||
| 374 | -## 0.1.0+1 | ||
| 375 | - | ||
| 376 | -* Fix null crash when initialUrl is unset on iOS. | ||
| 377 | - | ||
| 378 | -## 0.1.0 | ||
| 379 | - | ||
| 380 | -* Add goBack, goForward, canGoBack, and canGoForward methods to the WebView controller. | ||
| 381 | - | ||
| 382 | -## 0.0.1+1 | ||
| 383 | - | ||
| 384 | -* Fix case for "FLTWebViewFlutterPlugin" (iOS was failing to buld on case-sensitive file systems). | ||
| 385 | - | ||
| 386 | -## 0.0.1 | ||
| 387 | - | ||
| 388 | -* Initial release. |
| 1 | -Copyright 2018 The Chromium Authors. All rights reserved. | ||
| 2 | - | ||
| 3 | -Redistribution and use in source and binary forms, with or without modification, | ||
| 4 | -are permitted provided that the following conditions are met: | ||
| 5 | - | ||
| 6 | - * Redistributions of source code must retain the above copyright | ||
| 7 | - notice, this list of conditions and the following disclaimer. | ||
| 8 | - * Redistributions in binary form must reproduce the above | ||
| 9 | - copyright notice, this list of conditions and the following | ||
| 10 | - disclaimer in the documentation and/or other materials provided | ||
| 11 | - with the distribution. | ||
| 12 | - * Neither the name of Google Inc. nor the names of its | ||
| 13 | - contributors may be used to endorse or promote products derived | ||
| 14 | - from this software without specific prior written permission. | ||
| 15 | - | ||
| 16 | -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
| 17 | -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 18 | -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 19 | -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
| 20 | -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 21 | -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 22 | -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| 23 | -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 24 | -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 25 | -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 1 | -# WebView for Flutter | ||
| 2 | - | ||
| 3 | -[](https://pub.dartlang.org/packages/webview_flutter) | ||
| 4 | - | ||
| 5 | -A Flutter plugin that provides a WebView widget. | ||
| 6 | - | ||
| 7 | -On iOS the WebView widget is backed by a [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview); | ||
| 8 | -On Android the WebView widget is backed by a [WebView](https://developer.android.com/reference/android/webkit/WebView). | ||
| 9 | - | ||
| 10 | -## Usage | ||
| 11 | -Add `webview_flutter` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). | ||
| 12 | - | ||
| 13 | -You can now include a WebView widget in your widget tree. See the | ||
| 14 | -[WebView](https://pub.dev/documentation/webview_flutter/latest/webview_flutter/WebView-class.html) | ||
| 15 | -widget's Dartdoc for more details on how to use the widget. | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | -## Android Platform Views | ||
| 20 | -The WebView is relying on | ||
| 21 | -[Platform Views](https://flutter.dev/docs/development/platform-integration/platform-views) to embed | ||
| 22 | -the Android’s webview within the Flutter app. By default a Virtual Display based platform view | ||
| 23 | -backend is used, this implementation has multiple | ||
| 24 | -[keyboard](https://github.com/flutter/flutter/issues?q=is%3Aopen+label%3Avd-only+label%3A%22p%3A+webview-keyboard%22). | ||
| 25 | -When keyboard input is required we recommend using the Hybrid Composition based platform views | ||
| 26 | -implementation. Note that on Android versions prior to Android 10 Hybrid Composition has some | ||
| 27 | -[performance drawbacks](https://flutter.dev/docs/development/platform-integration/platform-views#performance). | ||
| 28 | - | ||
| 29 | -### Using Hybrid Composition | ||
| 30 | - | ||
| 31 | -To enable hybrid composition, set `WebView.platform = SurfaceAndroidWebView();` in `initState()`. | ||
| 32 | -For example: | ||
| 33 | - | ||
| 34 | -```dart | ||
| 35 | -import 'dart:io'; | ||
| 36 | - | ||
| 37 | -import 'package:webview_flutter/webview_flutter.dart'; | ||
| 38 | - | ||
| 39 | -class WebViewExample extends StatefulWidget { | ||
| 40 | - @override | ||
| 41 | - WebViewExampleState createState() => WebViewExampleState(); | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -class WebViewExampleState extends State<WebViewExample> { | ||
| 45 | - @override | ||
| 46 | - void initState() { | ||
| 47 | - super.initState(); | ||
| 48 | - // Enable hybrid composition. | ||
| 49 | - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - @override | ||
| 53 | - Widget build(BuildContext context) { | ||
| 54 | - return WebView( | ||
| 55 | - initialUrl: 'https://flutter.dev', | ||
| 56 | - ); | ||
| 57 | - } | ||
| 58 | -} | ||
| 59 | -``` | ||
| 60 | - | ||
| 61 | -`SurfaceAndroidWebView()` requires [API level 19](https://developer.android.com/studio/releases/platforms?hl=th#4.4). The plugin itself doesn't enforce the API level, so if you want to make the app available on devices running this API level or above, add the following to `<your-app>/android/app/build.gradle`: | ||
| 62 | - | ||
| 63 | -```gradle | ||
| 64 | -android { | ||
| 65 | - defaultConfig { | ||
| 66 | - // Required by the Flutter WebView plugin. | ||
| 67 | - minSdkVersion 19 | ||
| 68 | - } | ||
| 69 | - } | ||
| 70 | -``` |
| 1 | -group 'io.flutter.plugins.webviewflutter' | ||
| 2 | -version '1.0-SNAPSHOT' | ||
| 3 | - | ||
| 4 | -buildscript { | ||
| 5 | - repositories { | ||
| 6 | - google() | ||
| 7 | - jcenter() | ||
| 8 | - } | ||
| 9 | - | ||
| 10 | - dependencies { | ||
| 11 | - classpath 'com.android.tools.build:gradle:3.3.0' | ||
| 12 | - } | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -rootProject.allprojects { | ||
| 16 | - repositories { | ||
| 17 | - google() | ||
| 18 | - jcenter() | ||
| 19 | - } | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -apply plugin: 'com.android.library' | ||
| 23 | - | ||
| 24 | -android { | ||
| 25 | - compileSdkVersion 29 | ||
| 26 | - | ||
| 27 | - defaultConfig { | ||
| 28 | - minSdkVersion 16 | ||
| 29 | - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| 30 | - } | ||
| 31 | - lintOptions { | ||
| 32 | - disable 'InvalidPackage' | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - dependencies { | ||
| 36 | - implementation 'androidx.annotation:annotation:1.0.0' | ||
| 37 | - implementation 'androidx.webkit:webkit:1.0.0' | ||
| 38 | - } | ||
| 39 | -} |
| 1 | -rootProject.name = 'webview_flutter' |
| 1 | -package io.flutter.plugins.webviewflutter; | ||
| 2 | - | ||
| 3 | -import static android.hardware.display.DisplayManager.DisplayListener; | ||
| 4 | - | ||
| 5 | -import android.annotation.TargetApi; | ||
| 6 | -import android.hardware.display.DisplayManager; | ||
| 7 | -import android.os.Build; | ||
| 8 | -import android.util.Log; | ||
| 9 | -import java.lang.reflect.Field; | ||
| 10 | -import java.util.ArrayList; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * Works around an Android WebView bug by filtering some DisplayListener invocations. | ||
| 14 | - * | ||
| 15 | - * <p>Older Android WebView versions had assumed that when {@link DisplayListener#onDisplayChanged} | ||
| 16 | - * is invoked, the display ID it is provided is of a valid display. However it turns out that when a | ||
| 17 | - * display is removed Android may call onDisplayChanged with the ID of the removed display, in this | ||
| 18 | - * case the Android WebView code tries to fetch and use the display with this ID and crashes with an | ||
| 19 | - * NPE. | ||
| 20 | - * | ||
| 21 | - * <p>This issue was fixed in the Android WebView code in | ||
| 22 | - * https://chromium-review.googlesource.com/517913 which is available starting WebView version | ||
| 23 | - * 58.0.3029.125 however older webviews in the wild still have this issue. | ||
| 24 | - * | ||
| 25 | - * <p>Since Flutter removes virtual displays whenever a platform view is resized the webview crash | ||
| 26 | - * is more likely to happen than other apps. And users were reporting this issue see: | ||
| 27 | - * https://github.com/flutter/flutter/issues/30420 | ||
| 28 | - * | ||
| 29 | - * <p>This class works around the webview bug by unregistering the WebView's DisplayListener, and | ||
| 30 | - * instead registering its own DisplayListener which delegates the callbacks to the WebView's | ||
| 31 | - * listener unless it's a onDisplayChanged for an invalid display. | ||
| 32 | - * | ||
| 33 | - * <p>I did not find a clean way to get a handle of the WebView's DisplayListener so I'm using | ||
| 34 | - * reflection to fetch all registered listeners before and after initializing a webview. In the | ||
| 35 | - * first initialization of a webview within the process the difference between the lists is the | ||
| 36 | - * webview's display listener. | ||
| 37 | - */ | ||
| 38 | -@TargetApi(Build.VERSION_CODES.KITKAT) | ||
| 39 | -class DisplayListenerProxy { | ||
| 40 | - private static final String TAG = "DisplayListenerProxy"; | ||
| 41 | - | ||
| 42 | - private ArrayList<DisplayListener> listenersBeforeWebView; | ||
| 43 | - | ||
| 44 | - /** Should be called prior to the webview's initialization. */ | ||
| 45 | - void onPreWebViewInitialization(DisplayManager displayManager) { | ||
| 46 | - listenersBeforeWebView = yoinkDisplayListeners(displayManager); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - /** Should be called after the webview's initialization. */ | ||
| 50 | - void onPostWebViewInitialization(final DisplayManager displayManager) { | ||
| 51 | - final ArrayList<DisplayListener> webViewListeners = yoinkDisplayListeners(displayManager); | ||
| 52 | - // We recorded the list of listeners prior to initializing webview, any new listeners we see | ||
| 53 | - // after initializing the webview are listeners added by the webview. | ||
| 54 | - webViewListeners.removeAll(listenersBeforeWebView); | ||
| 55 | - | ||
| 56 | - if (webViewListeners.isEmpty()) { | ||
| 57 | - // The Android WebView registers a single display listener per process (even if there | ||
| 58 | - // are multiple WebView instances) so this list is expected to be non-empty only the | ||
| 59 | - // first time a webview is initialized. | ||
| 60 | - // Note that in an add2app scenario if the application had instantiated a non Flutter | ||
| 61 | - // WebView prior to instantiating the Flutter WebView we are not able to get a reference | ||
| 62 | - // to the WebView's display listener and can't work around the bug. | ||
| 63 | - // | ||
| 64 | - // This means that webview resizes in add2app Flutter apps with a non Flutter WebView | ||
| 65 | - // running on a system with a webview prior to 58.0.3029.125 may crash (the Android's | ||
| 66 | - // behavior seems to be racy so it doesn't always happen). | ||
| 67 | - return; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - for (DisplayListener webViewListener : webViewListeners) { | ||
| 71 | - // Note that while DisplayManager.unregisterDisplayListener throws when given an | ||
| 72 | - // unregistered listener, this isn't an issue as the WebView code never calls | ||
| 73 | - // unregisterDisplayListener. | ||
| 74 | - displayManager.unregisterDisplayListener(webViewListener); | ||
| 75 | - | ||
| 76 | - // We never explicitly unregister this listener as the webview's listener is never | ||
| 77 | - // unregistered (it's released when the process is terminated). | ||
| 78 | - displayManager.registerDisplayListener( | ||
| 79 | - new DisplayListener() { | ||
| 80 | - @Override | ||
| 81 | - public void onDisplayAdded(int displayId) { | ||
| 82 | - for (DisplayListener webViewListener : webViewListeners) { | ||
| 83 | - webViewListener.onDisplayAdded(displayId); | ||
| 84 | - } | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | - public void onDisplayRemoved(int displayId) { | ||
| 89 | - for (DisplayListener webViewListener : webViewListeners) { | ||
| 90 | - webViewListener.onDisplayRemoved(displayId); | ||
| 91 | - } | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - @Override | ||
| 95 | - public void onDisplayChanged(int displayId) { | ||
| 96 | - if (displayManager.getDisplay(displayId) == null) { | ||
| 97 | - return; | ||
| 98 | - } | ||
| 99 | - for (DisplayListener webViewListener : webViewListeners) { | ||
| 100 | - webViewListener.onDisplayChanged(displayId); | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | - }, | ||
| 104 | - null); | ||
| 105 | - } | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @SuppressWarnings({"unchecked", "PrivateApi"}) | ||
| 109 | - private static ArrayList<DisplayListener> yoinkDisplayListeners(DisplayManager displayManager) { | ||
| 110 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
| 111 | - // We cannot use reflection on Android P, but it shouldn't matter as it shipped | ||
| 112 | - // with WebView 66.0.3359.158 and the WebView version the bug this code is working around was | ||
| 113 | - // fixed in 61.0.3116.0. | ||
| 114 | - return new ArrayList<>(); | ||
| 115 | - } | ||
| 116 | - try { | ||
| 117 | - Field displayManagerGlobalField = DisplayManager.class.getDeclaredField("mGlobal"); | ||
| 118 | - displayManagerGlobalField.setAccessible(true); | ||
| 119 | - Object displayManagerGlobal = displayManagerGlobalField.get(displayManager); | ||
| 120 | - Field displayListenersField = | ||
| 121 | - displayManagerGlobal.getClass().getDeclaredField("mDisplayListeners"); | ||
| 122 | - displayListenersField.setAccessible(true); | ||
| 123 | - ArrayList<Object> delegates = | ||
| 124 | - (ArrayList<Object>) displayListenersField.get(displayManagerGlobal); | ||
| 125 | - | ||
| 126 | - Field listenerField = null; | ||
| 127 | - ArrayList<DisplayManager.DisplayListener> listeners = new ArrayList<>(); | ||
| 128 | - for (Object delegate : delegates) { | ||
| 129 | - if (listenerField == null) { | ||
| 130 | - listenerField = delegate.getClass().getField("mListener"); | ||
| 131 | - listenerField.setAccessible(true); | ||
| 132 | - } | ||
| 133 | - DisplayManager.DisplayListener listener = | ||
| 134 | - (DisplayManager.DisplayListener) listenerField.get(delegate); | ||
| 135 | - listeners.add(listener); | ||
| 136 | - } | ||
| 137 | - return listeners; | ||
| 138 | - } catch (NoSuchFieldException | IllegalAccessException e) { | ||
| 139 | - Log.w(TAG, "Could not extract WebView's display listeners. " + e); | ||
| 140 | - return new ArrayList<>(); | ||
| 141 | - } | ||
| 142 | - } | ||
| 143 | -} |
| 1 | -// Copyright 2019 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import android.os.Build; | ||
| 8 | -import android.os.Build.VERSION_CODES; | ||
| 9 | -import android.webkit.CookieManager; | ||
| 10 | -import android.webkit.ValueCallback; | ||
| 11 | -import io.flutter.plugin.common.BinaryMessenger; | ||
| 12 | -import io.flutter.plugin.common.MethodCall; | ||
| 13 | -import io.flutter.plugin.common.MethodChannel; | ||
| 14 | -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
| 15 | -import io.flutter.plugin.common.MethodChannel.Result; | ||
| 16 | - | ||
| 17 | -class FlutterCookieManager implements MethodCallHandler { | ||
| 18 | - private final MethodChannel methodChannel; | ||
| 19 | - | ||
| 20 | - FlutterCookieManager(BinaryMessenger messenger) { | ||
| 21 | - methodChannel = new MethodChannel(messenger, "plugins.flutter.io/cookie_manager"); | ||
| 22 | - methodChannel.setMethodCallHandler(this); | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - @Override | ||
| 26 | - public void onMethodCall(MethodCall methodCall, Result result) { | ||
| 27 | - switch (methodCall.method) { | ||
| 28 | - case "clearCookies": | ||
| 29 | - clearCookies(result); | ||
| 30 | - break; | ||
| 31 | - default: | ||
| 32 | - result.notImplemented(); | ||
| 33 | - } | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - void dispose() { | ||
| 37 | - methodChannel.setMethodCallHandler(null); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - private static void clearCookies(final Result result) { | ||
| 41 | - CookieManager cookieManager = CookieManager.getInstance(); | ||
| 42 | - final boolean hasCookies = cookieManager.hasCookies(); | ||
| 43 | - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { | ||
| 44 | - cookieManager.removeAllCookies( | ||
| 45 | - new ValueCallback<Boolean>() { | ||
| 46 | - @Override | ||
| 47 | - public void onReceiveValue(Boolean value) { | ||
| 48 | - result.success(hasCookies); | ||
| 49 | - } | ||
| 50 | - }); | ||
| 51 | - } else { | ||
| 52 | - cookieManager.removeAllCookie(); | ||
| 53 | - result.success(hasCookies); | ||
| 54 | - } | ||
| 55 | - } | ||
| 56 | -} |
| 1 | -// Copyright 2018 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -//package io.flutter.plugins.webviewflutter; | ||
| 6 | -// | ||
| 7 | -//import android.annotation.TargetApi; | ||
| 8 | -//import android.content.Context; | ||
| 9 | -//import android.hardware.display.DisplayManager; | ||
| 10 | -//import android.os.Build; | ||
| 11 | -//import android.os.Handler; | ||
| 12 | -//import android.os.Message; | ||
| 13 | -//import android.view.View; | ||
| 14 | -//import android.webkit.WebChromeClient; | ||
| 15 | -//import android.webkit.WebResourceRequest; | ||
| 16 | -//import android.webkit.WebStorage; | ||
| 17 | -//import android.webkit.WebView; | ||
| 18 | -//import android.webkit.WebViewClient; | ||
| 19 | -//import androidx.annotation.NonNull; | ||
| 20 | -//import io.flutter.plugin.common.BinaryMessenger; | ||
| 21 | -//import io.flutter.plugin.common.MethodCall; | ||
| 22 | -//import io.flutter.plugin.common.MethodChannel; | ||
| 23 | -//import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
| 24 | -//import io.flutter.plugin.common.MethodChannel.Result; | ||
| 25 | -//import io.flutter.plugin.platform.PlatformView; | ||
| 26 | -//import java.util.Collections; | ||
| 27 | -//import java.util.List; | ||
| 28 | -//import java.util.Map; | ||
| 29 | -//import android.content.Intent; | ||
| 30 | -//package io.flutter.plugins.webviewflutter; | ||
| 31 | -package io.flutter.plugins.webviewflutter; | ||
| 32 | -import android.annotation.TargetApi; | ||
| 33 | -import android.app.Activity; | ||
| 34 | -import android.content.Context; | ||
| 35 | -import android.content.Intent; | ||
| 36 | -import android.hardware.display.DisplayManager; | ||
| 37 | -import android.net.Uri; | ||
| 38 | -import android.os.Build; | ||
| 39 | -import android.os.Handler; | ||
| 40 | -import android.os.Message; | ||
| 41 | -import android.view.View; | ||
| 42 | -import android.webkit.ValueCallback; | ||
| 43 | -import android.webkit.WebChromeClient; | ||
| 44 | -import android.webkit.WebResourceRequest; | ||
| 45 | -import android.webkit.WebStorage; | ||
| 46 | -import android.webkit.WebView; | ||
| 47 | -import android.webkit.WebViewClient; | ||
| 48 | - | ||
| 49 | -import androidx.annotation.NonNull; | ||
| 50 | -import androidx.annotation.RequiresApi; | ||
| 51 | - | ||
| 52 | -import io.flutter.plugin.common.BinaryMessenger; | ||
| 53 | -import io.flutter.plugin.common.MethodCall; | ||
| 54 | -import io.flutter.plugin.common.MethodChannel; | ||
| 55 | -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
| 56 | -import io.flutter.plugin.common.MethodChannel.Result; | ||
| 57 | -import io.flutter.plugin.platform.PlatformView; | ||
| 58 | - | ||
| 59 | -import java.util.Collections; | ||
| 60 | -import java.util.List; | ||
| 61 | -import java.util.Map; | ||
| 62 | - | ||
| 63 | -import android.content.Intent; | ||
| 64 | -//package io.flutter.plugins.webviewflutter; | ||
| 65 | - | ||
| 66 | - | ||
| 67 | -public class FlutterWebView implements PlatformView, MethodCallHandler { | ||
| 68 | - private static final String JS_CHANNEL_NAMES_FIELD = "javascriptChannelNames"; | ||
| 69 | - private final InputAwareWebView webView; | ||
| 70 | - private final MethodChannel methodChannel; | ||
| 71 | - private final FlutterWebViewClient flutterWebViewClient; | ||
| 72 | - private final Handler platformThreadHandler; | ||
| 73 | - | ||
| 74 | - // Verifies that a url opened by `Window.open` has a secure url. | ||
| 75 | - private class FlutterWebChromeClient extends WebChromeClient { | ||
| 76 | - @Override | ||
| 77 | - public boolean onCreateWindow( | ||
| 78 | - final WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) { | ||
| 79 | - final WebViewClient webViewClient = | ||
| 80 | - new WebViewClient() { | ||
| 81 | - @TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
| 82 | - @Override | ||
| 83 | - public boolean shouldOverrideUrlLoading( | ||
| 84 | - @NonNull WebView view, @NonNull WebResourceRequest request) { | ||
| 85 | - final String url = request.getUrl().toString(); | ||
| 86 | - if (!flutterWebViewClient.shouldOverrideUrlLoading( | ||
| 87 | - FlutterWebView.this.webView, request)) { | ||
| 88 | - webView.loadUrl(url); | ||
| 89 | - } | ||
| 90 | - return true; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - @Override | ||
| 94 | - public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
| 95 | - if (!flutterWebViewClient.shouldOverrideUrlLoading( | ||
| 96 | - FlutterWebView.this.webView, url)) { | ||
| 97 | - webView.loadUrl(url); | ||
| 98 | - } | ||
| 99 | - return true; | ||
| 100 | - } | ||
| 101 | - }; | ||
| 102 | - | ||
| 103 | - final WebView newWebView = new WebView(view.getContext()); | ||
| 104 | - newWebView.setWebViewClient(webViewClient); | ||
| 105 | - | ||
| 106 | - final WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; | ||
| 107 | - transport.setWebView(newWebView); | ||
| 108 | - resultMsg.sendToTarget(); | ||
| 109 | - | ||
| 110 | - return true; | ||
| 111 | - } | ||
| 112 | - // For Android < 3.0 | ||
| 113 | - public void openFileChooser(ValueCallback<Uri> valueCallback) { | ||
| 114 | - Log.v(TAG, "openFileChooser Android < 3.0"); | ||
| 115 | - uploadMessage = valueCallback; | ||
| 116 | - openImageChooserActivity(); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - // For Android >= 3.0 | ||
| 120 | - public void openFileChooser(ValueCallback valueCallback, String acceptType) { | ||
| 121 | - Log.v(TAG, "openFileChooser Android >= 3.0"); | ||
| 122 | - uploadMessage = valueCallback; | ||
| 123 | - openImageChooserActivity(); | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - //For Android >= 4.1 | ||
| 127 | - public void openFileChooser(ValueCallback<Uri> valueCallback, String acceptType, String capture) { | ||
| 128 | - Log.v(TAG, "openFileChooser Android >= 4.1"); | ||
| 129 | - uploadMessage = valueCallback; | ||
| 130 | - openImageChooserActivity(); | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - // For Android >= 5.0 | ||
| 134 | - @Override | ||
| 135 | - public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { | ||
| 136 | - Log.v(TAG, "openFileChooser Android >= 5.0"); | ||
| 137 | - uploadMessageAboveL = filePathCallback; | ||
| 138 | - openImageChooserActivity(); | ||
| 139 | - return true; | ||
| 140 | - } | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - private void openImageChooserActivity() { | ||
| 144 | - Log.v(TAG, "openImageChooserActivity"); | ||
| 145 | - Intent intent1 = new Intent(Intent.ACTION_PICK, null); | ||
| 146 | - intent1.setDataAndType( | ||
| 147 | - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); | ||
| 148 | - Intent chooser = new Intent(Intent.ACTION_CHOOSER); | ||
| 149 | - chooser.putExtra(Intent.EXTRA_TITLE, "选择图片"); | ||
| 150 | - chooser.putExtra(Intent.EXTRA_INTENT,intent1); | ||
| 151 | - | ||
| 152 | - if (WebViewFlutterPlugin.activity != null){ | ||
| 153 | - WebViewFlutterPlugin.activity.startActivityForResult(chooser, FILE_CHOOSER_RESULT_CODE); | ||
| 154 | - } else { | ||
| 155 | - Log.v(TAG, "activity is null"); | ||
| 156 | - } | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - public boolean activityResult(int requestCode, int resultCode, Intent data) { | ||
| 160 | - if (requestCode == FILE_CHOOSER_RESULT_CODE) { | ||
| 161 | - if (null == uploadMessage && null == uploadMessageAboveL) { | ||
| 162 | - return false; | ||
| 163 | - } | ||
| 164 | - Uri result = data == null || resultCode != RESULT_OK ? null : data.getData(); | ||
| 165 | - if (uploadMessageAboveL != null) { | ||
| 166 | - onActivityResultAboveL(requestCode, resultCode, data); | ||
| 167 | - } else if (uploadMessage != null && result != null) { | ||
| 168 | - uploadMessage.onReceiveValue(result); | ||
| 169 | - uploadMessage = null; | ||
| 170 | - } | ||
| 171 | - } | ||
| 172 | - return false; | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - @TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
| 176 | - private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) { | ||
| 177 | - if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null) | ||
| 178 | - { | ||
| 179 | - return; | ||
| 180 | - } | ||
| 181 | - Uri[] results = null; | ||
| 182 | - if (resultCode == Activity.RESULT_OK) { | ||
| 183 | - if (intent != null) { | ||
| 184 | - String dataString = intent.getDataString(); | ||
| 185 | - ClipData clipData = intent.getClipData(); | ||
| 186 | - if (clipData != null) { | ||
| 187 | - results = new Uri[clipData.getItemCount()]; | ||
| 188 | - for (int i = 0; i < clipData.getItemCount(); i++) { | ||
| 189 | - ClipData.Item item = clipData.getItemAt(i); | ||
| 190 | - results[i] = item.getUri(); | ||
| 191 | - } | ||
| 192 | - } | ||
| 193 | - if (dataString != null) | ||
| 194 | - { | ||
| 195 | - results = new Uri[]{Uri.parse(dataString)}; | ||
| 196 | - } | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - uploadMessageAboveL.onReceiveValue(results); | ||
| 200 | - uploadMessageAboveL = null; | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) | ||
| 205 | - @SuppressWarnings("unchecked") | ||
| 206 | - FlutterWebView( | ||
| 207 | - final Context context, | ||
| 208 | - BinaryMessenger messenger, | ||
| 209 | - int id, | ||
| 210 | - Map<String, Object> params, | ||
| 211 | - View containerView) { | ||
| 212 | - | ||
| 213 | - DisplayListenerProxy displayListenerProxy = new DisplayListenerProxy(); | ||
| 214 | - DisplayManager displayManager = | ||
| 215 | - (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE); | ||
| 216 | - displayListenerProxy.onPreWebViewInitialization(displayManager); | ||
| 217 | - webView = new InputAwareWebView(context, containerView); | ||
| 218 | - displayListenerProxy.onPostWebViewInitialization(displayManager); | ||
| 219 | - | ||
| 220 | - platformThreadHandler = new Handler(context.getMainLooper()); | ||
| 221 | - // Allow local storage. | ||
| 222 | - webView.getSettings().setDomStorageEnabled(true); | ||
| 223 | - webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); | ||
| 224 | - | ||
| 225 | - // Multi windows is set with FlutterWebChromeClient by default to handle internal bug: b/159892679. | ||
| 226 | - webView.getSettings().setSupportMultipleWindows(true); | ||
| 227 | - webView.setWebChromeClient(new FlutterWebChromeClient()); | ||
| 228 | - | ||
| 229 | - methodChannel = new MethodChannel(messenger, "plugins.flutter.io/webview_" + id); | ||
| 230 | - methodChannel.setMethodCallHandler(this); | ||
| 231 | - | ||
| 232 | - flutterWebViewClient = new FlutterWebViewClient(methodChannel); | ||
| 233 | - Map<String, Object> settings = (Map<String, Object>) params.get("settings"); | ||
| 234 | - if (settings != null) applySettings(settings); | ||
| 235 | - | ||
| 236 | - if (params.containsKey(JS_CHANNEL_NAMES_FIELD)) { | ||
| 237 | - List<String> names = (List<String>) params.get(JS_CHANNEL_NAMES_FIELD); | ||
| 238 | - if (names != null) registerJavaScriptChannelNames(names); | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - Integer autoMediaPlaybackPolicy = (Integer) params.get("autoMediaPlaybackPolicy"); | ||
| 242 | - if (autoMediaPlaybackPolicy != null) updateAutoMediaPlaybackPolicy(autoMediaPlaybackPolicy); | ||
| 243 | - if (params.containsKey("userAgent")) { | ||
| 244 | - String userAgent = (String) params.get("userAgent"); | ||
| 245 | - updateUserAgent(userAgent); | ||
| 246 | - } | ||
| 247 | - if (params.containsKey("initialUrl")) { | ||
| 248 | - String url = (String) params.get("initialUrl"); | ||
| 249 | - webView.loadUrl(url); | ||
| 250 | - } | ||
| 251 | - } | ||
| 252 | - | ||
| 253 | - @Override | ||
| 254 | - public View getView() { | ||
| 255 | - return webView; | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - // @Override | ||
| 259 | - // This is overriding a method that hasn't rolled into stable Flutter yet. Including the | ||
| 260 | - // annotation would cause compile time failures in versions of Flutter too old to include the new | ||
| 261 | - // method. However leaving it raw like this means that the method will be ignored in old versions | ||
| 262 | - // of Flutter but used as an override anyway wherever it's actually defined. | ||
| 263 | - // TODO(mklim): Add the @Override annotation once flutter/engine#9727 rolls to stable. | ||
| 264 | - public void onInputConnectionUnlocked() { | ||
| 265 | - webView.unlockInputConnection(); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - // @Override | ||
| 269 | - // This is overriding a method that hasn't rolled into stable Flutter yet. Including the | ||
| 270 | - // annotation would cause compile time failures in versions of Flutter too old to include the new | ||
| 271 | - // method. However leaving it raw like this means that the method will be ignored in old versions | ||
| 272 | - // of Flutter but used as an override anyway wherever it's actually defined. | ||
| 273 | - // TODO(mklim): Add the @Override annotation once flutter/engine#9727 rolls to stable. | ||
| 274 | - public void onInputConnectionLocked() { | ||
| 275 | - webView.lockInputConnection(); | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | - // @Override | ||
| 279 | - // This is overriding a method that hasn't rolled into stable Flutter yet. Including the | ||
| 280 | - // annotation would cause compile time failures in versions of Flutter too old to include the new | ||
| 281 | - // method. However leaving it raw like this means that the method will be ignored in old versions | ||
| 282 | - // of Flutter but used as an override anyway wherever it's actually defined. | ||
| 283 | - // TODO(mklim): Add the @Override annotation once stable passes v1.10.9. | ||
| 284 | - public void onFlutterViewAttached(View flutterView) { | ||
| 285 | - webView.setContainerView(flutterView); | ||
| 286 | - } | ||
| 287 | - | ||
| 288 | - // @Override | ||
| 289 | - // This is overriding a method that hasn't rolled into stable Flutter yet. Including the | ||
| 290 | - // annotation would cause compile time failures in versions of Flutter too old to include the new | ||
| 291 | - // method. However leaving it raw like this means that the method will be ignored in old versions | ||
| 292 | - // of Flutter but used as an override anyway wherever it's actually defined. | ||
| 293 | - // TODO(mklim): Add the @Override annotation once stable passes v1.10.9. | ||
| 294 | - public void onFlutterViewDetached() { | ||
| 295 | - webView.setContainerView(null); | ||
| 296 | - } | ||
| 297 | - | ||
| 298 | - @Override | ||
| 299 | - public void onMethodCall(MethodCall methodCall, Result result) { | ||
| 300 | - switch (methodCall.method) { | ||
| 301 | - case "loadUrl": | ||
| 302 | - loadUrl(methodCall, result); | ||
| 303 | - break; | ||
| 304 | - case "updateSettings": | ||
| 305 | - updateSettings(methodCall, result); | ||
| 306 | - break; | ||
| 307 | - case "canGoBack": | ||
| 308 | - canGoBack(result); | ||
| 309 | - break; | ||
| 310 | - case "canGoForward": | ||
| 311 | - canGoForward(result); | ||
| 312 | - break; | ||
| 313 | - case "goBack": | ||
| 314 | - goBack(result); | ||
| 315 | - break; | ||
| 316 | - case "goForward": | ||
| 317 | - goForward(result); | ||
| 318 | - break; | ||
| 319 | - case "reload": | ||
| 320 | - reload(result); | ||
| 321 | - break; | ||
| 322 | - case "currentUrl": | ||
| 323 | - currentUrl(result); | ||
| 324 | - break; | ||
| 325 | - case "evaluateJavascript": | ||
| 326 | - evaluateJavaScript(methodCall, result); | ||
| 327 | - break; | ||
| 328 | - case "addJavascriptChannels": | ||
| 329 | - addJavaScriptChannels(methodCall, result); | ||
| 330 | - break; | ||
| 331 | - case "removeJavascriptChannels": | ||
| 332 | - removeJavaScriptChannels(methodCall, result); | ||
| 333 | - break; | ||
| 334 | - case "clearCache": | ||
| 335 | - clearCache(result); | ||
| 336 | - break; | ||
| 337 | - case "getTitle": | ||
| 338 | - getTitle(result); | ||
| 339 | - break; | ||
| 340 | - case "scrollTo": | ||
| 341 | - scrollTo(methodCall, result); | ||
| 342 | - break; | ||
| 343 | - case "scrollBy": | ||
| 344 | - scrollBy(methodCall, result); | ||
| 345 | - break; | ||
| 346 | - case "getScrollX": | ||
| 347 | - getScrollX(result); | ||
| 348 | - break; | ||
| 349 | - case "getScrollY": | ||
| 350 | - getScrollY(result); | ||
| 351 | - break; | ||
| 352 | - default: | ||
| 353 | - result.notImplemented(); | ||
| 354 | - } | ||
| 355 | - } | ||
| 356 | - | ||
| 357 | - @SuppressWarnings("unchecked") | ||
| 358 | - private void loadUrl(MethodCall methodCall, Result result) { | ||
| 359 | - Map<String, Object> request = (Map<String, Object>) methodCall.arguments; | ||
| 360 | - String url = (String) request.get("url"); | ||
| 361 | - Map<String, String> headers = (Map<String, String>) request.get("headers"); | ||
| 362 | - if (headers == null) { | ||
| 363 | - headers = Collections.emptyMap(); | ||
| 364 | - } | ||
| 365 | - webView.loadUrl(url, headers); | ||
| 366 | - result.success(null); | ||
| 367 | - } | ||
| 368 | - | ||
| 369 | - private void canGoBack(Result result) { | ||
| 370 | - result.success(webView.canGoBack()); | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - private void canGoForward(Result result) { | ||
| 374 | - result.success(webView.canGoForward()); | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - private void goBack(Result result) { | ||
| 378 | - if (webView.canGoBack()) { | ||
| 379 | - webView.goBack(); | ||
| 380 | - } | ||
| 381 | - result.success(null); | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - private void goForward(Result result) { | ||
| 385 | - if (webView.canGoForward()) { | ||
| 386 | - webView.goForward(); | ||
| 387 | - } | ||
| 388 | - result.success(null); | ||
| 389 | - } | ||
| 390 | - | ||
| 391 | - private void reload(Result result) { | ||
| 392 | - webView.reload(); | ||
| 393 | - result.success(null); | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - private void currentUrl(Result result) { | ||
| 397 | - result.success(webView.getUrl()); | ||
| 398 | - } | ||
| 399 | - | ||
| 400 | - @SuppressWarnings("unchecked") | ||
| 401 | - private void updateSettings(MethodCall methodCall, Result result) { | ||
| 402 | - applySettings((Map<String, Object>) methodCall.arguments); | ||
| 403 | - result.success(null); | ||
| 404 | - } | ||
| 405 | - | ||
| 406 | - @TargetApi(Build.VERSION_CODES.KITKAT) | ||
| 407 | - private void evaluateJavaScript(MethodCall methodCall, final Result result) { | ||
| 408 | - String jsString = (String) methodCall.arguments; | ||
| 409 | - if (jsString == null) { | ||
| 410 | - throw new UnsupportedOperationException("JavaScript string cannot be null"); | ||
| 411 | - } | ||
| 412 | - webView.evaluateJavascript( | ||
| 413 | - jsString, | ||
| 414 | - new android.webkit.ValueCallback<String>() { | ||
| 415 | - @Override | ||
| 416 | - public void onReceiveValue(String value) { | ||
| 417 | - result.success(value); | ||
| 418 | - } | ||
| 419 | - }); | ||
| 420 | - } | ||
| 421 | - | ||
| 422 | - @SuppressWarnings("unchecked") | ||
| 423 | - private void addJavaScriptChannels(MethodCall methodCall, Result result) { | ||
| 424 | - List<String> channelNames = (List<String>) methodCall.arguments; | ||
| 425 | - registerJavaScriptChannelNames(channelNames); | ||
| 426 | - result.success(null); | ||
| 427 | - } | ||
| 428 | - | ||
| 429 | - @SuppressWarnings("unchecked") | ||
| 430 | - private void removeJavaScriptChannels(MethodCall methodCall, Result result) { | ||
| 431 | - List<String> channelNames = (List<String>) methodCall.arguments; | ||
| 432 | - for (String channelName : channelNames) { | ||
| 433 | - webView.removeJavascriptInterface(channelName); | ||
| 434 | - } | ||
| 435 | - result.success(null); | ||
| 436 | - } | ||
| 437 | - | ||
| 438 | - private void clearCache(Result result) { | ||
| 439 | - webView.clearCache(true); | ||
| 440 | - WebStorage.getInstance().deleteAllData(); | ||
| 441 | - result.success(null); | ||
| 442 | - } | ||
| 443 | - | ||
| 444 | - private void getTitle(Result result) { | ||
| 445 | - result.success(webView.getTitle()); | ||
| 446 | - } | ||
| 447 | - | ||
| 448 | - private void scrollTo(MethodCall methodCall, Result result) { | ||
| 449 | - Map<String, Object> request = methodCall.arguments(); | ||
| 450 | - int x = (int) request.get("x"); | ||
| 451 | - int y = (int) request.get("y"); | ||
| 452 | - | ||
| 453 | - webView.scrollTo(x, y); | ||
| 454 | - | ||
| 455 | - result.success(null); | ||
| 456 | - } | ||
| 457 | - | ||
| 458 | - private void scrollBy(MethodCall methodCall, Result result) { | ||
| 459 | - Map<String, Object> request = methodCall.arguments(); | ||
| 460 | - int x = (int) request.get("x"); | ||
| 461 | - int y = (int) request.get("y"); | ||
| 462 | - | ||
| 463 | - webView.scrollBy(x, y); | ||
| 464 | - result.success(null); | ||
| 465 | - } | ||
| 466 | - | ||
| 467 | - private void getScrollX(Result result) { | ||
| 468 | - result.success(webView.getScrollX()); | ||
| 469 | - } | ||
| 470 | - | ||
| 471 | - private void getScrollY(Result result) { | ||
| 472 | - result.success(webView.getScrollY()); | ||
| 473 | - } | ||
| 474 | - | ||
| 475 | - private void applySettings(Map<String, Object> settings) { | ||
| 476 | - for (String key : settings.keySet()) { | ||
| 477 | - switch (key) { | ||
| 478 | - case "jsMode": | ||
| 479 | - Integer mode = (Integer) settings.get(key); | ||
| 480 | - if (mode != null) updateJsMode(mode); | ||
| 481 | - break; | ||
| 482 | - case "hasNavigationDelegate": | ||
| 483 | - final boolean hasNavigationDelegate = (boolean) settings.get(key); | ||
| 484 | - | ||
| 485 | - final WebViewClient webViewClient = | ||
| 486 | - flutterWebViewClient.createWebViewClient(hasNavigationDelegate); | ||
| 487 | - | ||
| 488 | - webView.setWebViewClient(webViewClient); | ||
| 489 | - break; | ||
| 490 | - case "debuggingEnabled": | ||
| 491 | - final boolean debuggingEnabled = (boolean) settings.get(key); | ||
| 492 | - | ||
| 493 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||
| 494 | - webView.setWebContentsDebuggingEnabled(debuggingEnabled); | ||
| 495 | - } | ||
| 496 | - break; | ||
| 497 | - case "gestureNavigationEnabled": | ||
| 498 | - break; | ||
| 499 | - case "userAgent": | ||
| 500 | - updateUserAgent((String) settings.get(key)); | ||
| 501 | - break; | ||
| 502 | - default: | ||
| 503 | - throw new IllegalArgumentException("Unknown WebView setting: " + key); | ||
| 504 | - } | ||
| 505 | - } | ||
| 506 | - } | ||
| 507 | - | ||
| 508 | - private void updateJsMode(int mode) { | ||
| 509 | - switch (mode) { | ||
| 510 | - case 0: // disabled | ||
| 511 | - webView.getSettings().setJavaScriptEnabled(false); | ||
| 512 | - break; | ||
| 513 | - case 1: // unrestricted | ||
| 514 | - webView.getSettings().setJavaScriptEnabled(true); | ||
| 515 | - break; | ||
| 516 | - default: | ||
| 517 | - throw new IllegalArgumentException("Trying to set unknown JavaScript mode: " + mode); | ||
| 518 | - } | ||
| 519 | - } | ||
| 520 | - | ||
| 521 | - private void updateAutoMediaPlaybackPolicy(int mode) { | ||
| 522 | - // This is the index of the AutoMediaPlaybackPolicy enum, index 1 is always_allow, for all | ||
| 523 | - // other values we require a user gesture. | ||
| 524 | - boolean requireUserGesture = mode != 1; | ||
| 525 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | ||
| 526 | - webView.getSettings().setMediaPlaybackRequiresUserGesture(requireUserGesture); | ||
| 527 | - } | ||
| 528 | - } | ||
| 529 | - | ||
| 530 | - private void registerJavaScriptChannelNames(List<String> channelNames) { | ||
| 531 | - for (String channelName : channelNames) { | ||
| 532 | - webView.addJavascriptInterface( | ||
| 533 | - new JavaScriptChannel(methodChannel, channelName, platformThreadHandler), channelName); | ||
| 534 | - } | ||
| 535 | - } | ||
| 536 | - | ||
| 537 | - private void updateUserAgent(String userAgent) { | ||
| 538 | - webView.getSettings().setUserAgentString(userAgent); | ||
| 539 | - } | ||
| 540 | - | ||
| 541 | - @Override | ||
| 542 | - public void dispose() { | ||
| 543 | - methodChannel.setMethodCallHandler(null); | ||
| 544 | - webView.dispose(); | ||
| 545 | - webView.destroy(); | ||
| 546 | - } | ||
| 547 | -} |
| 1 | -// Copyright 2019 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import android.annotation.SuppressLint; | ||
| 8 | -import android.annotation.TargetApi; | ||
| 9 | -import android.graphics.Bitmap; | ||
| 10 | -import android.os.Build; | ||
| 11 | -import android.util.Log; | ||
| 12 | -import android.view.KeyEvent; | ||
| 13 | -import android.webkit.WebResourceError; | ||
| 14 | -import android.webkit.WebResourceRequest; | ||
| 15 | -import android.webkit.WebView; | ||
| 16 | -import android.webkit.WebViewClient; | ||
| 17 | -import androidx.annotation.RequiresApi; | ||
| 18 | -import androidx.webkit.WebResourceErrorCompat; | ||
| 19 | -import androidx.webkit.WebViewClientCompat; | ||
| 20 | -import io.flutter.plugin.common.MethodChannel; | ||
| 21 | -import java.util.HashMap; | ||
| 22 | -import java.util.Locale; | ||
| 23 | -import java.util.Map; | ||
| 24 | - | ||
| 25 | -// We need to use WebViewClientCompat to get | ||
| 26 | -// shouldOverrideUrlLoading(WebView view, WebResourceRequest request) | ||
| 27 | -// invoked by the webview on older Android devices, without it pages that use iframes will | ||
| 28 | -// be broken when a navigationDelegate is set on Android version earlier than N. | ||
| 29 | -class FlutterWebViewClient { | ||
| 30 | - private static final String TAG = "FlutterWebViewClient"; | ||
| 31 | - private final MethodChannel methodChannel; | ||
| 32 | - private boolean hasNavigationDelegate; | ||
| 33 | - | ||
| 34 | - FlutterWebViewClient(MethodChannel methodChannel) { | ||
| 35 | - this.methodChannel = methodChannel; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - private static String errorCodeToString(int errorCode) { | ||
| 39 | - switch (errorCode) { | ||
| 40 | - case WebViewClient.ERROR_AUTHENTICATION: | ||
| 41 | - return "authentication"; | ||
| 42 | - case WebViewClient.ERROR_BAD_URL: | ||
| 43 | - return "badUrl"; | ||
| 44 | - case WebViewClient.ERROR_CONNECT: | ||
| 45 | - return "connect"; | ||
| 46 | - case WebViewClient.ERROR_FAILED_SSL_HANDSHAKE: | ||
| 47 | - return "failedSslHandshake"; | ||
| 48 | - case WebViewClient.ERROR_FILE: | ||
| 49 | - return "file"; | ||
| 50 | - case WebViewClient.ERROR_FILE_NOT_FOUND: | ||
| 51 | - return "fileNotFound"; | ||
| 52 | - case WebViewClient.ERROR_HOST_LOOKUP: | ||
| 53 | - return "hostLookup"; | ||
| 54 | - case WebViewClient.ERROR_IO: | ||
| 55 | - return "io"; | ||
| 56 | - case WebViewClient.ERROR_PROXY_AUTHENTICATION: | ||
| 57 | - return "proxyAuthentication"; | ||
| 58 | - case WebViewClient.ERROR_REDIRECT_LOOP: | ||
| 59 | - return "redirectLoop"; | ||
| 60 | - case WebViewClient.ERROR_TIMEOUT: | ||
| 61 | - return "timeout"; | ||
| 62 | - case WebViewClient.ERROR_TOO_MANY_REQUESTS: | ||
| 63 | - return "tooManyRequests"; | ||
| 64 | - case WebViewClient.ERROR_UNKNOWN: | ||
| 65 | - return "unknown"; | ||
| 66 | - case WebViewClient.ERROR_UNSAFE_RESOURCE: | ||
| 67 | - return "unsafeResource"; | ||
| 68 | - case WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME: | ||
| 69 | - return "unsupportedAuthScheme"; | ||
| 70 | - case WebViewClient.ERROR_UNSUPPORTED_SCHEME: | ||
| 71 | - return "unsupportedScheme"; | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - final String message = | ||
| 75 | - String.format(Locale.getDefault(), "Could not find a string for errorCode: %d", errorCode); | ||
| 76 | - throw new IllegalArgumentException(message); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - @TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
| 80 | - boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { | ||
| 81 | - if (!hasNavigationDelegate) { | ||
| 82 | - return false; | ||
| 83 | - } | ||
| 84 | - notifyOnNavigationRequest( | ||
| 85 | - request.getUrl().toString(), request.getRequestHeaders(), view, request.isForMainFrame()); | ||
| 86 | - // We must make a synchronous decision here whether to allow the navigation or not, | ||
| 87 | - // if the Dart code has set a navigation delegate we want that delegate to decide whether | ||
| 88 | - // to navigate or not, and as we cannot get a response from the Dart delegate synchronously we | ||
| 89 | - // return true here to block the navigation, if the Dart delegate decides to allow the | ||
| 90 | - // navigation the plugin will later make an addition loadUrl call for this url. | ||
| 91 | - // | ||
| 92 | - // Since we cannot call loadUrl for a subframe, we currently only allow the delegate to stop | ||
| 93 | - // navigations that target the main frame, if the request is not for the main frame | ||
| 94 | - // we just return false to allow the navigation. | ||
| 95 | - // | ||
| 96 | - // For more details see: https://github.com/flutter/flutter/issues/25329#issuecomment-464863209 | ||
| 97 | - return request.isForMainFrame(); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
| 101 | - if (!hasNavigationDelegate) { | ||
| 102 | - return false; | ||
| 103 | - } | ||
| 104 | - // This version of shouldOverrideUrlLoading is only invoked by the webview on devices with | ||
| 105 | - // webview versions earlier than 67(it is also invoked when hasNavigationDelegate is false). | ||
| 106 | - // On these devices we cannot tell whether the navigation is targeted to the main frame or not. | ||
| 107 | - // We proceed assuming that the navigation is targeted to the main frame. If the page had any | ||
| 108 | - // frames they will be loaded in the main frame instead. | ||
| 109 | - Log.w( | ||
| 110 | - TAG, | ||
| 111 | - "Using a navigationDelegate with an old webview implementation, pages with frames or iframes will not work"); | ||
| 112 | - notifyOnNavigationRequest(url, null, view, true); | ||
| 113 | - return true; | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | - private void onPageStarted(WebView view, String url) { | ||
| 117 | - Map<String, Object> args = new HashMap<>(); | ||
| 118 | - args.put("url", url); | ||
| 119 | - methodChannel.invokeMethod("onPageStarted", args); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - private void onPageFinished(WebView view, String url) { | ||
| 123 | - Map<String, Object> args = new HashMap<>(); | ||
| 124 | - args.put("url", url); | ||
| 125 | - methodChannel.invokeMethod("onPageFinished", args); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - private void onWebResourceError( | ||
| 129 | - final int errorCode, final String description, final String failingUrl) { | ||
| 130 | - final Map<String, Object> args = new HashMap<>(); | ||
| 131 | - args.put("errorCode", errorCode); | ||
| 132 | - args.put("description", description); | ||
| 133 | - args.put("errorType", FlutterWebViewClient.errorCodeToString(errorCode)); | ||
| 134 | - args.put("failingUrl", failingUrl); | ||
| 135 | - methodChannel.invokeMethod("onWebResourceError", args); | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - private void notifyOnNavigationRequest( | ||
| 139 | - String url, Map<String, String> headers, WebView webview, boolean isMainFrame) { | ||
| 140 | - HashMap<String, Object> args = new HashMap<>(); | ||
| 141 | - args.put("url", url); | ||
| 142 | - args.put("isForMainFrame", isMainFrame); | ||
| 143 | - if (isMainFrame) { | ||
| 144 | - methodChannel.invokeMethod( | ||
| 145 | - "navigationRequest", args, new OnNavigationRequestResult(url, headers, webview)); | ||
| 146 | - } else { | ||
| 147 | - methodChannel.invokeMethod("navigationRequest", args); | ||
| 148 | - } | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - // This method attempts to avoid using WebViewClientCompat due to bug | ||
| 152 | - // https://bugs.chromium.org/p/chromium/issues/detail?id=925887. Also, see | ||
| 153 | - // https://github.com/flutter/flutter/issues/29446. | ||
| 154 | - WebViewClient createWebViewClient(boolean hasNavigationDelegate) { | ||
| 155 | - this.hasNavigationDelegate = hasNavigationDelegate; | ||
| 156 | - | ||
| 157 | - if (!hasNavigationDelegate || android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
| 158 | - return internalCreateWebViewClient(); | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - return internalCreateWebViewClientCompat(); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - private WebViewClient internalCreateWebViewClient() { | ||
| 165 | - return new WebViewClient() { | ||
| 166 | - @TargetApi(Build.VERSION_CODES.N) | ||
| 167 | - @Override | ||
| 168 | - public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { | ||
| 169 | - return FlutterWebViewClient.this.shouldOverrideUrlLoading(view, request); | ||
| 170 | - } | ||
| 171 | - | ||
| 172 | - @Override | ||
| 173 | - public void onPageStarted(WebView view, String url, Bitmap favicon) { | ||
| 174 | - FlutterWebViewClient.this.onPageStarted(view, url); | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - @Override | ||
| 178 | - public void onPageFinished(WebView view, String url) { | ||
| 179 | - FlutterWebViewClient.this.onPageFinished(view, url); | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - @TargetApi(Build.VERSION_CODES.M) | ||
| 183 | - @Override | ||
| 184 | - public void onReceivedError( | ||
| 185 | - WebView view, WebResourceRequest request, WebResourceError error) { | ||
| 186 | - FlutterWebViewClient.this.onWebResourceError( | ||
| 187 | - error.getErrorCode(), error.getDescription().toString(), request.getUrl().toString()); | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - @Override | ||
| 191 | - public void onReceivedError( | ||
| 192 | - WebView view, int errorCode, String description, String failingUrl) { | ||
| 193 | - FlutterWebViewClient.this.onWebResourceError(errorCode, description, failingUrl); | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - @Override | ||
| 197 | - public void onUnhandledKeyEvent(WebView view, KeyEvent event) { | ||
| 198 | - // Deliberately empty. Occasionally the webview will mark events as having failed to be | ||
| 199 | - // handled even though they were handled. We don't want to propagate those as they're not | ||
| 200 | - // truly lost. | ||
| 201 | - } | ||
| 202 | - }; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - private WebViewClientCompat internalCreateWebViewClientCompat() { | ||
| 206 | - return new WebViewClientCompat() { | ||
| 207 | - @Override | ||
| 208 | - public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { | ||
| 209 | - return FlutterWebViewClient.this.shouldOverrideUrlLoading(view, request); | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - @Override | ||
| 213 | - public boolean shouldOverrideUrlLoading(WebView view, String url) { | ||
| 214 | - return FlutterWebViewClient.this.shouldOverrideUrlLoading(view, url); | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - @Override | ||
| 218 | - public void onPageStarted(WebView view, String url, Bitmap favicon) { | ||
| 219 | - FlutterWebViewClient.this.onPageStarted(view, url); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - @Override | ||
| 223 | - public void onPageFinished(WebView view, String url) { | ||
| 224 | - FlutterWebViewClient.this.onPageFinished(view, url); | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - // This method is only called when the WebViewFeature.RECEIVE_WEB_RESOURCE_ERROR feature is | ||
| 228 | - // enabled. The deprecated method is called when a device doesn't support this. | ||
| 229 | - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) | ||
| 230 | - @SuppressLint("RequiresFeature") | ||
| 231 | - @Override | ||
| 232 | - public void onReceivedError( | ||
| 233 | - WebView view, WebResourceRequest request, WebResourceErrorCompat error) { | ||
| 234 | - FlutterWebViewClient.this.onWebResourceError( | ||
| 235 | - error.getErrorCode(), error.getDescription().toString(), request.getUrl().toString()); | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - @Override | ||
| 239 | - public void onReceivedError( | ||
| 240 | - WebView view, int errorCode, String description, String failingUrl) { | ||
| 241 | - FlutterWebViewClient.this.onWebResourceError(errorCode, description, failingUrl); | ||
| 242 | - } | ||
| 243 | - | ||
| 244 | - @Override | ||
| 245 | - public void onUnhandledKeyEvent(WebView view, KeyEvent event) { | ||
| 246 | - // Deliberately empty. Occasionally the webview will mark events as having failed to be | ||
| 247 | - // handled even though they were handled. We don't want to propagate those as they're not | ||
| 248 | - // truly lost. | ||
| 249 | - } | ||
| 250 | - }; | ||
| 251 | - } | ||
| 252 | - | ||
| 253 | - private static class OnNavigationRequestResult implements MethodChannel.Result { | ||
| 254 | - private final String url; | ||
| 255 | - private final Map<String, String> headers; | ||
| 256 | - private final WebView webView; | ||
| 257 | - | ||
| 258 | - private OnNavigationRequestResult(String url, Map<String, String> headers, WebView webView) { | ||
| 259 | - this.url = url; | ||
| 260 | - this.headers = headers; | ||
| 261 | - this.webView = webView; | ||
| 262 | - } | ||
| 263 | - | ||
| 264 | - @Override | ||
| 265 | - public void success(Object shouldLoad) { | ||
| 266 | - Boolean typedShouldLoad = (Boolean) shouldLoad; | ||
| 267 | - if (typedShouldLoad) { | ||
| 268 | - loadUrl(); | ||
| 269 | - } | ||
| 270 | - } | ||
| 271 | - | ||
| 272 | - @Override | ||
| 273 | - public void error(String errorCode, String s1, Object o) { | ||
| 274 | - throw new IllegalStateException("navigationRequest calls must succeed"); | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | - @Override | ||
| 278 | - public void notImplemented() { | ||
| 279 | - throw new IllegalStateException( | ||
| 280 | - "navigationRequest must be implemented by the webview method channel"); | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - private void loadUrl() { | ||
| 284 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
| 285 | - webView.loadUrl(url, headers); | ||
| 286 | - } else { | ||
| 287 | - webView.loadUrl(url); | ||
| 288 | - } | ||
| 289 | - } | ||
| 290 | - } | ||
| 291 | -} |
| 1 | -// Copyright 2019 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import static android.content.Context.INPUT_METHOD_SERVICE; | ||
| 8 | - | ||
| 9 | -import android.content.Context; | ||
| 10 | -import android.graphics.Rect; | ||
| 11 | -import android.os.Build; | ||
| 12 | -import android.util.Log; | ||
| 13 | -import android.view.View; | ||
| 14 | -import android.view.inputmethod.InputMethodManager; | ||
| 15 | -import android.webkit.WebView; | ||
| 16 | -import android.widget.ListPopupWindow; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * A WebView subclass that mirrors the same implementation hacks that the system WebView does in | ||
| 20 | - * order to correctly create an InputConnection. | ||
| 21 | - * | ||
| 22 | - * <p>These hacks are only needed in Android versions below N and exist to create an InputConnection | ||
| 23 | - * on the WebView's dedicated input, or IME, thread. The majority of this proxying logic is in | ||
| 24 | - * {@link #checkInputConnectionProxy}. | ||
| 25 | - * | ||
| 26 | - * <p>See also {@link ThreadedInputConnectionProxyAdapterView}. | ||
| 27 | - */ | ||
| 28 | -final class InputAwareWebView extends WebView { | ||
| 29 | - private static final String TAG = "InputAwareWebView"; | ||
| 30 | - private View threadedInputConnectionProxyView; | ||
| 31 | - private ThreadedInputConnectionProxyAdapterView proxyAdapterView; | ||
| 32 | - private View containerView; | ||
| 33 | - | ||
| 34 | - InputAwareWebView(Context context, View containerView) { | ||
| 35 | - super(context); | ||
| 36 | - this.containerView = containerView; | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - void setContainerView(View containerView) { | ||
| 40 | - this.containerView = containerView; | ||
| 41 | - | ||
| 42 | - if (proxyAdapterView == null) { | ||
| 43 | - return; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - Log.w(TAG, "The containerView has changed while the proxyAdapterView exists."); | ||
| 47 | - if (containerView != null) { | ||
| 48 | - setInputConnectionTarget(proxyAdapterView); | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | - * Set our proxy adapter view to use its cached input connection instead of creating new ones. | ||
| 54 | - * | ||
| 55 | - * <p>This is used to avoid losing our input connection when the virtual display is resized. | ||
| 56 | - */ | ||
| 57 | - void lockInputConnection() { | ||
| 58 | - if (proxyAdapterView == null) { | ||
| 59 | - return; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - proxyAdapterView.setLocked(true); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** Sets the proxy adapter view back to its default behavior. */ | ||
| 66 | - void unlockInputConnection() { | ||
| 67 | - if (proxyAdapterView == null) { | ||
| 68 | - return; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - proxyAdapterView.setLocked(false); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - /** Restore the original InputConnection, if needed. */ | ||
| 75 | - void dispose() { | ||
| 76 | - resetInputConnection(); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * Creates an InputConnection from the IME thread when needed. | ||
| 81 | - * | ||
| 82 | - * <p>We only need to create a {@link ThreadedInputConnectionProxyAdapterView} and create an | ||
| 83 | - * InputConnectionProxy on the IME thread when WebView is doing the same thing. So we rely on the | ||
| 84 | - * system calling this method for WebView's proxy view in order to know when we need to create our | ||
| 85 | - * own. | ||
| 86 | - * | ||
| 87 | - * <p>This method would normally be called for any View that used the InputMethodManager. We rely | ||
| 88 | - * on flutter/engine filtering the calls we receive down to the ones in our hierarchy and the | ||
| 89 | - * system WebView in order to know whether or not the system WebView expects an InputConnection on | ||
| 90 | - * the IME thread. | ||
| 91 | - */ | ||
| 92 | - @Override | ||
| 93 | - public boolean checkInputConnectionProxy(final View view) { | ||
| 94 | - // Check to see if the view param is WebView's ThreadedInputConnectionProxyView. | ||
| 95 | - View previousProxy = threadedInputConnectionProxyView; | ||
| 96 | - threadedInputConnectionProxyView = view; | ||
| 97 | - if (previousProxy == view) { | ||
| 98 | - // This isn't a new ThreadedInputConnectionProxyView. Ignore it. | ||
| 99 | - return super.checkInputConnectionProxy(view); | ||
| 100 | - } | ||
| 101 | - if (containerView == null) { | ||
| 102 | - Log.e( | ||
| 103 | - TAG, | ||
| 104 | - "Can't create a proxy view because there's no container view. Text input may not work."); | ||
| 105 | - return super.checkInputConnectionProxy(view); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - // We've never seen this before, so we make the assumption that this is WebView's | ||
| 109 | - // ThreadedInputConnectionProxyView. We are making the assumption that the only view that could | ||
| 110 | - // possibly be interacting with the IMM here is WebView's ThreadedInputConnectionProxyView. | ||
| 111 | - proxyAdapterView = | ||
| 112 | - new ThreadedInputConnectionProxyAdapterView( | ||
| 113 | - /*containerView=*/ containerView, | ||
| 114 | - /*targetView=*/ view, | ||
| 115 | - /*imeHandler=*/ view.getHandler()); | ||
| 116 | - setInputConnectionTarget(/*targetView=*/ proxyAdapterView); | ||
| 117 | - return super.checkInputConnectionProxy(view); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - /** | ||
| 121 | - * Ensure that input creation happens back on {@link #containerView}'s thread once this view no | ||
| 122 | - * longer has focus. | ||
| 123 | - * | ||
| 124 | - * <p>The logic in {@link #checkInputConnectionProxy} forces input creation to happen on Webview's | ||
| 125 | - * thread for all connections. We undo it here so users will be able to go back to typing in | ||
| 126 | - * Flutter UIs as expected. | ||
| 127 | - */ | ||
| 128 | - @Override | ||
| 129 | - public void clearFocus() { | ||
| 130 | - super.clearFocus(); | ||
| 131 | - resetInputConnection(); | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - /** | ||
| 135 | - * Ensure that input creation happens back on {@link #containerView}. | ||
| 136 | - * | ||
| 137 | - * <p>The logic in {@link #checkInputConnectionProxy} forces input creation to happen on Webview's | ||
| 138 | - * thread for all connections. We undo it here so users will be able to go back to typing in | ||
| 139 | - * Flutter UIs as expected. | ||
| 140 | - */ | ||
| 141 | - private void resetInputConnection() { | ||
| 142 | - if (proxyAdapterView == null) { | ||
| 143 | - // No need to reset the InputConnection to the default thread if we've never changed it. | ||
| 144 | - return; | ||
| 145 | - } | ||
| 146 | - if (containerView == null) { | ||
| 147 | - Log.e(TAG, "Can't reset the input connection to the container view because there is none."); | ||
| 148 | - return; | ||
| 149 | - } | ||
| 150 | - setInputConnectionTarget(/*targetView=*/ containerView); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - /** | ||
| 154 | - * This is the crucial trick that gets the InputConnection creation to happen on the correct | ||
| 155 | - * thread pre Android N. | ||
| 156 | - * https://cs.chromium.org/chromium/src/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java?l=169&rcl=f0698ee3e4483fad5b0c34159276f71cfaf81f3a | ||
| 157 | - * | ||
| 158 | - * <p>{@code targetView} should have a {@link View#getHandler} method with the thread that future | ||
| 159 | - * InputConnections should be created on. | ||
| 160 | - */ | ||
| 161 | - private void setInputConnectionTarget(final View targetView) { | ||
| 162 | - if (containerView == null) { | ||
| 163 | - Log.e( | ||
| 164 | - TAG, | ||
| 165 | - "Can't set the input connection target because there is no containerView to use as a handler."); | ||
| 166 | - return; | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - targetView.requestFocus(); | ||
| 170 | - containerView.post( | ||
| 171 | - new Runnable() { | ||
| 172 | - @Override | ||
| 173 | - public void run() { | ||
| 174 | - InputMethodManager imm = | ||
| 175 | - (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE); | ||
| 176 | - // This is a hack to make InputMethodManager believe that the target view now has focus. | ||
| 177 | - // As a result, InputMethodManager will think that targetView is focused, and will call | ||
| 178 | - // getHandler() of the view when creating input connection. | ||
| 179 | - | ||
| 180 | - // Step 1: Set targetView as InputMethodManager#mNextServedView. This does not affect | ||
| 181 | - // the real window focus. | ||
| 182 | - targetView.onWindowFocusChanged(true); | ||
| 183 | - | ||
| 184 | - // Step 2: Have InputMethodManager focus in on targetView. As a result, IMM will call | ||
| 185 | - // onCreateInputConnection() on targetView on the same thread as | ||
| 186 | - // targetView.getHandler(). It will also call subsequent InputConnection methods on this | ||
| 187 | - // thread. This is the IME thread in cases where targetView is our proxyAdapterView. | ||
| 188 | - imm.isActive(containerView); | ||
| 189 | - } | ||
| 190 | - }); | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - @Override | ||
| 194 | - protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { | ||
| 195 | - // This works around a crash when old (<67.0.3367.0) Chromium versions are used. | ||
| 196 | - | ||
| 197 | - // Prior to Chromium 67.0.3367 the following sequence happens when a select drop down is shown | ||
| 198 | - // on tablets: | ||
| 199 | - // | ||
| 200 | - // - WebView is calling ListPopupWindow#show | ||
| 201 | - // - buildDropDown is invoked, which sets mDropDownList to a DropDownListView. | ||
| 202 | - // - showAsDropDown is invoked - resulting in mDropDownList being added to the window and is | ||
| 203 | - // also synchronously performing the following sequence: | ||
| 204 | - // - WebView's focus change listener is loosing focus (as mDropDownList got it) | ||
| 205 | - // - WebView is hiding all popups (as it lost focus) | ||
| 206 | - // - WebView's SelectPopupDropDown#hide is invoked. | ||
| 207 | - // - DropDownPopupWindow#dismiss is invoked setting mDropDownList to null. | ||
| 208 | - // - mDropDownList#setSelection is invoked and is throwing a NullPointerException (as we just set mDropDownList to null). | ||
| 209 | - // | ||
| 210 | - // To workaround this, we drop the problematic focus lost call. | ||
| 211 | - // See more details on: https://github.com/flutter/flutter/issues/54164 | ||
| 212 | - // | ||
| 213 | - // We don't do this after Android P as it shipped with a new enough WebView version, and it's | ||
| 214 | - // better to not do this on all future Android versions in case DropDownListView's code changes. | ||
| 215 | - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P | ||
| 216 | - && isCalledFromListPopupWindowShow() | ||
| 217 | - && !focused) { | ||
| 218 | - return; | ||
| 219 | - } | ||
| 220 | - super.onFocusChanged(focused, direction, previouslyFocusedRect); | ||
| 221 | - } | ||
| 222 | - | ||
| 223 | - private boolean isCalledFromListPopupWindowShow() { | ||
| 224 | - StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | ||
| 225 | - for (StackTraceElement stackTraceElement : stackTraceElements) { | ||
| 226 | - if (stackTraceElement.getClassName().equals(ListPopupWindow.class.getCanonicalName()) | ||
| 227 | - && stackTraceElement.getMethodName().equals("show")) { | ||
| 228 | - return true; | ||
| 229 | - } | ||
| 230 | - } | ||
| 231 | - return false; | ||
| 232 | - } | ||
| 233 | -} |
| 1 | -// Copyright 2019 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import android.os.Handler; | ||
| 8 | -import android.os.Looper; | ||
| 9 | -import android.webkit.JavascriptInterface; | ||
| 10 | -import io.flutter.plugin.common.MethodChannel; | ||
| 11 | -import java.util.HashMap; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * Added as a JavaScript interface to the WebView for any JavaScript channel that the Dart code sets | ||
| 15 | - * up. | ||
| 16 | - * | ||
| 17 | - * <p>Exposes a single method named `postMessage` to JavaScript, which sends a message over a method | ||
| 18 | - * channel to the Dart code. | ||
| 19 | - */ | ||
| 20 | -class JavaScriptChannel { | ||
| 21 | - private final MethodChannel methodChannel; | ||
| 22 | - private final String javaScriptChannelName; | ||
| 23 | - private final Handler platformThreadHandler; | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * @param methodChannel the Flutter WebView method channel to which JS messages are sent | ||
| 27 | - * @param javaScriptChannelName the name of the JavaScript channel, this is sent over the method | ||
| 28 | - * channel with each message to let the Dart code know which JavaScript channel the message | ||
| 29 | - * was sent through | ||
| 30 | - */ | ||
| 31 | - JavaScriptChannel( | ||
| 32 | - MethodChannel methodChannel, String javaScriptChannelName, Handler platformThreadHandler) { | ||
| 33 | - this.methodChannel = methodChannel; | ||
| 34 | - this.javaScriptChannelName = javaScriptChannelName; | ||
| 35 | - this.platformThreadHandler = platformThreadHandler; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - // Suppressing unused warning as this is invoked from JavaScript. | ||
| 39 | - @SuppressWarnings("unused") | ||
| 40 | - @JavascriptInterface | ||
| 41 | - public void postMessage(final String message) { | ||
| 42 | - Runnable postMessageRunnable = | ||
| 43 | - new Runnable() { | ||
| 44 | - @Override | ||
| 45 | - public void run() { | ||
| 46 | - HashMap<String, String> arguments = new HashMap<>(); | ||
| 47 | - arguments.put("channel", javaScriptChannelName); | ||
| 48 | - arguments.put("message", message); | ||
| 49 | - methodChannel.invokeMethod("javascriptChannelMessage", arguments); | ||
| 50 | - } | ||
| 51 | - }; | ||
| 52 | - if (platformThreadHandler.getLooper() == Looper.myLooper()) { | ||
| 53 | - postMessageRunnable.run(); | ||
| 54 | - } else { | ||
| 55 | - platformThreadHandler.post(postMessageRunnable); | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | -} |
| 1 | -// Copyright 2019 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import android.os.Handler; | ||
| 8 | -import android.os.IBinder; | ||
| 9 | -import android.view.View; | ||
| 10 | -import android.view.inputmethod.EditorInfo; | ||
| 11 | -import android.view.inputmethod.InputConnection; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * A fake View only exposed to InputMethodManager. | ||
| 15 | - * | ||
| 16 | - * <p>This follows a similar flow to Chromium's WebView (see | ||
| 17 | - * https://cs.chromium.org/chromium/src/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionProxyView.java). | ||
| 18 | - * WebView itself bounces its InputConnection around several different threads. We follow its logic | ||
| 19 | - * here to get the same working connection. | ||
| 20 | - * | ||
| 21 | - * <p>This exists solely to forward input creation to WebView's ThreadedInputConnectionProxyView on | ||
| 22 | - * the IME thread. The way that this is created in {@link | ||
| 23 | - * InputAwareWebView#checkInputConnectionProxy} guarantees that we have a handle to | ||
| 24 | - * ThreadedInputConnectionProxyView and {@link #onCreateInputConnection} is always called on the IME | ||
| 25 | - * thread. We delegate to ThreadedInputConnectionProxyView there to get WebView's input connection. | ||
| 26 | - */ | ||
| 27 | -final class ThreadedInputConnectionProxyAdapterView extends View { | ||
| 28 | - final Handler imeHandler; | ||
| 29 | - final IBinder windowToken; | ||
| 30 | - final View containerView; | ||
| 31 | - final View rootView; | ||
| 32 | - final View targetView; | ||
| 33 | - | ||
| 34 | - private boolean triggerDelayed = true; | ||
| 35 | - private boolean isLocked = false; | ||
| 36 | - private InputConnection cachedConnection; | ||
| 37 | - | ||
| 38 | - ThreadedInputConnectionProxyAdapterView(View containerView, View targetView, Handler imeHandler) { | ||
| 39 | - super(containerView.getContext()); | ||
| 40 | - this.imeHandler = imeHandler; | ||
| 41 | - this.containerView = containerView; | ||
| 42 | - this.targetView = targetView; | ||
| 43 | - windowToken = containerView.getWindowToken(); | ||
| 44 | - rootView = containerView.getRootView(); | ||
| 45 | - setFocusable(true); | ||
| 46 | - setFocusableInTouchMode(true); | ||
| 47 | - setVisibility(VISIBLE); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - /** Returns whether or not this is currently asynchronously acquiring an input connection. */ | ||
| 51 | - boolean isTriggerDelayed() { | ||
| 52 | - return triggerDelayed; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - /** Sets whether or not this should use its previously cached input connection. */ | ||
| 56 | - void setLocked(boolean locked) { | ||
| 57 | - isLocked = locked; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * This is expected to be called on the IME thread. See the setup required for this in {@link | ||
| 62 | - * InputAwareWebView#checkInputConnectionProxy(View)}. | ||
| 63 | - * | ||
| 64 | - * <p>Delegates to ThreadedInputConnectionProxyView to get WebView's input connection. | ||
| 65 | - */ | ||
| 66 | - @Override | ||
| 67 | - public InputConnection onCreateInputConnection(final EditorInfo outAttrs) { | ||
| 68 | - triggerDelayed = false; | ||
| 69 | - InputConnection inputConnection = | ||
| 70 | - (isLocked) ? cachedConnection : targetView.onCreateInputConnection(outAttrs); | ||
| 71 | - triggerDelayed = true; | ||
| 72 | - cachedConnection = inputConnection; | ||
| 73 | - return inputConnection; | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @Override | ||
| 77 | - public boolean checkInputConnectionProxy(View view) { | ||
| 78 | - return true; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - @Override | ||
| 82 | - public boolean hasWindowFocus() { | ||
| 83 | - // None of our views here correctly report they have window focus because of how we're embedding | ||
| 84 | - // the platform view inside of a virtual display. | ||
| 85 | - return true; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - @Override | ||
| 89 | - public View getRootView() { | ||
| 90 | - return rootView; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - @Override | ||
| 94 | - public boolean onCheckIsTextEditor() { | ||
| 95 | - return true; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - @Override | ||
| 99 | - public boolean isFocused() { | ||
| 100 | - return true; | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - @Override | ||
| 104 | - public IBinder getWindowToken() { | ||
| 105 | - return windowToken; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @Override | ||
| 109 | - public Handler getHandler() { | ||
| 110 | - return imeHandler; | ||
| 111 | - } | ||
| 112 | -} |
| 1 | -// Copyright 2018 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import android.content.Context; | ||
| 8 | -import android.view.View; | ||
| 9 | -import io.flutter.plugin.common.BinaryMessenger; | ||
| 10 | -import io.flutter.plugin.common.StandardMessageCodec; | ||
| 11 | -import io.flutter.plugin.platform.PlatformView; | ||
| 12 | -import io.flutter.plugin.platform.PlatformViewFactory; | ||
| 13 | -import java.util.Map; | ||
| 14 | - | ||
| 15 | -public final class WebViewFactory extends PlatformViewFactory { | ||
| 16 | - private final BinaryMessenger messenger; | ||
| 17 | - private final View containerView; | ||
| 18 | - private FlutterWebView flutterWebView; | ||
| 19 | - WebViewFactory(BinaryMessenger messenger, View containerView) { | ||
| 20 | - super(StandardMessageCodec.INSTANCE); | ||
| 21 | - this.messenger = messenger; | ||
| 22 | - this.containerView = containerView; | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - @SuppressWarnings("unchecked") | ||
| 26 | - @Override | ||
| 27 | - public PlatformView create(Context context, int id, Object args) { | ||
| 28 | - Map<String, Object> params = (Map<String, Object>) args; | ||
| 29 | - return new FlutterWebView(context, messenger, id, params, containerView); | ||
| 30 | - } | ||
| 31 | - public FlutterWebView getFlutterWebView(){ | ||
| 32 | - return flutterWebView; | ||
| 33 | - } | ||
| 34 | -} |
| 1 | -// Copyright 2018 The Chromium Authors. All rights reserved. | ||
| 2 | -// Use of this source code is governed by a BSD-style license that can be | ||
| 3 | -// found in the LICENSE file. | ||
| 4 | - | ||
| 5 | -package io.flutter.plugins.webviewflutter; | ||
| 6 | - | ||
| 7 | -import io.flutter.embedding.engine.plugins.FlutterPlugin; | ||
| 8 | -import io.flutter.plugin.common.BinaryMessenger; | ||
| 9 | -import io.flutter.embedding.engine.plugins.activity.ActivityAware; | ||
| 10 | -import io.flutter.plugin.common.PluginRegistry; | ||
| 11 | -import io.flutter.plugin.common.PluginRegistry.Registrar; | ||
| 12 | -import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener; | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | -/** | ||
| 17 | - * Java platform implementation of the webview_flutter plugin. | ||
| 18 | - * | ||
| 19 | - * <p>Register this in an add to app scenario to gracefully handle activity and context changes. | ||
| 20 | - * | ||
| 21 | - * <p>Call {@link #registerWith(Registrar)} to use the stable {@code io.flutter.plugin.common} | ||
| 22 | - * package instead. | ||
| 23 | - */ | ||
| 24 | -public class WebViewFlutterPlugin implements FlutterPlugin, PluginRegistry.ActivityResultListener, ActivityAware { | ||
| 25 | - private static final String TAG = "WebViewFlutterPlugin"; | ||
| 26 | - | ||
| 27 | - private FlutterCookieManager flutterCookieManager; | ||
| 28 | - public static Activity activity; | ||
| 29 | - private WebViewFactory factory; | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * Add an instance of this to {@link io.flutter.embedding.engine.plugins.PluginRegistry} to | ||
| 33 | - * register it. | ||
| 34 | - * | ||
| 35 | - * <p>THIS PLUGIN CODE PATH DEPENDS ON A NEWER VERSION OF FLUTTER THAN THE ONE DEFINED IN THE | ||
| 36 | - * PUBSPEC.YAML. Text input will fail on some Android devices unless this is used with at least | ||
| 37 | - * flutter/flutter@1d4d63ace1f801a022ea9ec737bf8c15395588b9. Use the V1 embedding with {@link | ||
| 38 | - * #registerWith(Registrar)} to use this plugin with older Flutter versions. | ||
| 39 | - * | ||
| 40 | - * <p>Registration should eventually be handled automatically by v2 of the | ||
| 41 | - * GeneratedPluginRegistrant. https://github.com/flutter/flutter/issues/42694 | ||
| 42 | - */ | ||
| 43 | - public WebViewFlutterPlugin() { | ||
| 44 | - // Log.v(TAG,"WebViewFlutterPlugin"); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * Registers a plugin implementation that uses the stable {@code io.flutter.plugin.common} | ||
| 49 | - * package. | ||
| 50 | - * | ||
| 51 | - * <p>Calling this automatically initializes the plugin. However plugins initialized this way | ||
| 52 | - * won't react to changes in activity or context, unlike {@link CameraPlugin}. | ||
| 53 | - */ | ||
| 54 | - @SuppressWarnings("deprecation") | ||
| 55 | - public static void registerWith(Registrar registrar) { | ||
| 56 | - // Log.v(TAG,"registerWith"); | ||
| 57 | - registrar | ||
| 58 | - .platformViewRegistry() | ||
| 59 | - .registerViewFactory( | ||
| 60 | - "plugins.flutter.io/webview", | ||
| 61 | - new WebViewFactory(registrar.messenger(), registrar.view())); | ||
| 62 | - new FlutterCookieManager(registrar.messenger()); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @Override | ||
| 66 | - public void onAttachedToEngine(FlutterPluginBinding binding) { | ||
| 67 | - // Log.v(TAG,"onAttachedToEngine"); | ||
| 68 | - BinaryMessenger messenger = binding.getBinaryMessenger(); | ||
| 69 | - factory = new WebViewFactory(messenger, null); | ||
| 70 | - binding | ||
| 71 | - .getFlutterEngine() | ||
| 72 | - .getPlatformViewsController() | ||
| 73 | - .getRegistry() | ||
| 74 | - .registerViewFactory( | ||
| 75 | - "plugins.flutter.io/webview", factory); | ||
| 76 | - flutterCookieManager = new FlutterCookieManager(messenger); | ||
| 77 | - | ||
| 78 | - Context appContext = binding.getApplicationContext(); | ||
| 79 | - if (appContext instanceof FlutterApplication) { | ||
| 80 | - Activity currentActivity = ((FlutterApplication) appContext).getCurrentActivity(); | ||
| 81 | - if (currentActivity != null) { | ||
| 82 | - activity = currentActivity; | ||
| 83 | - } | ||
| 84 | - } | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | - public void onDetachedFromEngine(FlutterPluginBinding binding) { | ||
| 89 | - // Log.v(TAG,"onDetachedFromEngine"); | ||
| 90 | - if (flutterCookieManager == null) { | ||
| 91 | - return; | ||
| 92 | - } | ||
| 93 | - activity = null; | ||
| 94 | - flutterCookieManager.dispose(); | ||
| 95 | - flutterCookieManager = null; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - @Override | ||
| 99 | - public boolean onActivityResult(int requestCode, int resultCode, Intent data) { | ||
| 100 | - // Log.v(TAG,"onActivityResult"); | ||
| 101 | - if (factory != null && factory.getFlutterWebView() != null){ | ||
| 102 | - return factory.getFlutterWebView().activityResult(requestCode, resultCode, data); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - return false; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - @Override | ||
| 109 | - public void onAttachedToActivity(ActivityPluginBinding binding) { | ||
| 110 | - // Log.v(TAG,"onAttachedToActivity"); | ||
| 111 | - activity = binding.getActivity(); | ||
| 112 | - binding.addActivityResultListener(this); | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - @Override | ||
| 116 | - public void onDetachedFromActivityForConfigChanges() { | ||
| 117 | - // Log.v(TAG,"onDetachedFromActivityForConfigChanges"); | ||
| 118 | - } | ||
| 119 | - | ||
| 120 | - @Override | ||
| 121 | - public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) { | ||
| 122 | - // Log.v(TAG,"onReattachedToActivityForConfigChanges"); | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - @Override | ||
| 126 | - public void onDetachedFromActivity() { | ||
| 127 | - // Log.v(TAG,"onDetachedFromActivity"); | ||
| 128 | - } | ||
| 129 | -} |
| 1 | -# This file tracks properties of this Flutter project. | ||
| 2 | -# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
| 3 | -# | ||
| 4 | -# This file should be version controlled and should not be manually edited. | ||
| 5 | - | ||
| 6 | -version: | ||
| 7 | - revision: 1e5cb2d87f8542f9fbbd0f22d528823274be0acb | ||
| 8 | - channel: master |
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/fileChanges/last-build.bin
deleted
100644 → 0
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/fileContent/fileContent.lock
deleted
100644 → 0
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/fileHashes/fileHashes.bin
deleted
100644 → 0
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/fileHashes/fileHashes.lock
deleted
100644 → 0
No preview for this file type
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/javaCompile/javaCompile.lock
deleted
100644 → 0
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/taskHistory/taskHistory.bin
deleted
100644 → 0
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/4.10.2/taskHistory/taskHistory.lock
deleted
100644 → 0
No preview for this file type
No preview for this file type
library/webview_flutter-1.0.7/example/android/.gradle/buildOutputCleanup/outputFiles.bin
deleted
100644 → 0
No preview for this file type
| 1 | -def localProperties = new Properties() | ||
| 2 | -def localPropertiesFile = rootProject.file('local.properties') | ||
| 3 | -if (localPropertiesFile.exists()) { | ||
| 4 | - localPropertiesFile.withReader('UTF-8') { reader -> | ||
| 5 | - localProperties.load(reader) | ||
| 6 | - } | ||
| 7 | -} | ||
| 8 | - | ||
| 9 | -def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
| 10 | -if (flutterRoot == null) { | ||
| 11 | - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
| 15 | -if (flutterVersionCode == null) { | ||
| 16 | - flutterVersionCode = '1' | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | -def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
| 20 | -if (flutterVersionName == null) { | ||
| 21 | - flutterVersionName = '1.0' | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -apply plugin: 'com.android.application' | ||
| 25 | -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
| 26 | - | ||
| 27 | -android { | ||
| 28 | - compileSdkVersion 29 | ||
| 29 | - | ||
| 30 | - lintOptions { | ||
| 31 | - disable 'InvalidPackage' | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - defaultConfig { | ||
| 35 | - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
| 36 | - applicationId "io.flutter.plugins.webviewflutterexample" | ||
| 37 | - minSdkVersion 16 | ||
| 38 | - targetSdkVersion 28 | ||
| 39 | - versionCode flutterVersionCode.toInteger() | ||
| 40 | - versionName flutterVersionName | ||
| 41 | - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - buildTypes { | ||
| 45 | - release { | ||
| 46 | - // TODO: Add your own signing config for the release build. | ||
| 47 | - // Signing with the debug keys for now, so `flutter run --release` works. | ||
| 48 | - signingConfig signingConfigs.debug | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | -} | ||
| 52 | - | ||
| 53 | -flutter { | ||
| 54 | - source '../..' | ||
| 55 | -} | ||
| 56 | - | ||
| 57 | -dependencies { | ||
| 58 | - testImplementation 'junit:junit:4.12' | ||
| 59 | - androidTestImplementation 'androidx.test:runner:1.2.0' | ||
| 60 | - androidTestImplementation 'androidx.test:rules:1.2.0' | ||
| 61 | - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
| 62 | -} |
| 1 | -package io.flutter.plugins.webviewflutterexample; | ||
| 2 | - | ||
| 3 | -import androidx.test.rule.ActivityTestRule; | ||
| 4 | -import dev.flutter.plugins.integration_test.FlutterTestRunner; | ||
| 5 | -import org.junit.Rule; | ||
| 6 | -import org.junit.runner.RunWith; | ||
| 7 | - | ||
| 8 | -@RunWith(FlutterTestRunner.class) | ||
| 9 | -@SuppressWarnings("deprecation") | ||
| 10 | -public class EmbeddingV1ActivityTest { | ||
| 11 | - @Rule | ||
| 12 | - public ActivityTestRule<EmbeddingV1Activity> rule = | ||
| 13 | - new ActivityTestRule<>(EmbeddingV1Activity.class); | ||
| 14 | -} |
| 1 | -package io.flutter.plugins.webviewflutterexample; | ||
| 2 | - | ||
| 3 | -import androidx.test.rule.ActivityTestRule; | ||
| 4 | -import dev.flutter.plugins.integration_test.FlutterTestRunner; | ||
| 5 | -import io.flutter.embedding.android.FlutterActivity; | ||
| 6 | -import org.junit.Rule; | ||
| 7 | -import org.junit.runner.RunWith; | ||
| 8 | - | ||
| 9 | -@RunWith(FlutterTestRunner.class) | ||
| 10 | -public class MainActivityTest { | ||
| 11 | - @Rule | ||
| 12 | - public ActivityTestRule<FlutterActivity> rule = new ActivityTestRule<>(FlutterActivity.class); | ||
| 13 | -} |
-
Please register or login to post a comment