|
|
|
|
@@ -4,6 +4,7 @@ import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
|
|
|
import 'package:freecell/utils/http_util.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
// import '../adjust/adjust_service.dart';
|
|
|
|
|
@@ -13,6 +14,15 @@ import '../utils/report.dart';
|
|
|
|
|
|
|
|
|
|
const String _webLoginTokenKey = 'assammzeeeass';
|
|
|
|
|
const int _maxWebViewProgressShowCount = 1;
|
|
|
|
|
const Set<String> _webSchemes = <String>{
|
|
|
|
|
'http',
|
|
|
|
|
'https',
|
|
|
|
|
'file',
|
|
|
|
|
'data',
|
|
|
|
|
'about',
|
|
|
|
|
'javascript',
|
|
|
|
|
'chrome',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// const String bridgeInjectScript =
|
|
|
|
|
// r'''lRpL+9TjSWvxRtAeNe3FCf8MtDcHDybBZ18LVDHp06Glxe6ITkTNRyyJqAPwbxuFOY6i0vsxF+6h8YzBBeq8A0I3Zye5I2Rk/TC3mCFBgZan0VNutDEJfdHIK/BdDKFWAbx6fxAZGvBMAOCC6HGajiiBwhP1KrMXfV0lL8+izrpCd9GA5CNEp7Z3RwIIGDWZA27vrxeN3fqFXHUx5AE2QvBNLO1A2kNAKfBql0d3CUcEAKUn/jd6KxOawZJfiQQVRHavfVMhIUIKwdLE0o1gMUaoD3j/IjiXJgsEqqvx+Pgh3BVbyyS3TAcpW0hywDnpYKmcCRFBtgdKpHjiZUyLee8wBUMh5w4RBnASZ5mskHGrGPn7Gu9xjmyASQndAW+VZuerDRs4Mo6dzRzeU8nKOD14N376joNgbXk6W4IcpEEmT7K/l5GqTsTFZyMfbrRwWOIIvc+29zAP+ugl8M6lt8Yhu37H/GDKU5OAh/eC159fTPNRvNVRLAUotkxUeYsf3k2j2GbNmd0Yd5eRGHCixQqGbcSuHnRdcmYe7UYv69TpE/c4tedsRB3KFUqGiEfHMpHFpMFuTsd0BvN1VvZ27h3mA478luSEITqHlqQ6vf0l5TZBkX+FFKlejqSVGLNFCfQ8cXiIEda4ReygZISfUJjLUrevTvfL7Zqmxhei2GXFgCf/k71ubFeqZbrWoRSakoJ+YgkBkuEE2PrxYrKIirB1qmSV9fmMtC/1QxaAjLvrkL+LKYZpyYX+yFkA43SK674L8hNAbqohqdbhgPd7lIz3SrPZ+4su1BTS4+yS2khB71uQn/BP3WrNFz5bcIsL''';
|
|
|
|
|
@@ -20,6 +30,7 @@ Future launchURL(
|
|
|
|
|
String url, {
|
|
|
|
|
LaunchMode mode = LaunchMode.externalApplication,
|
|
|
|
|
}) async {
|
|
|
|
|
debugPrint("op $url");
|
|
|
|
|
var uri = Uri.parse(url);
|
|
|
|
|
try {
|
|
|
|
|
await launchUrl(uri, mode: mode);
|
|
|
|
|
@@ -28,17 +39,17 @@ Future launchURL(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String _externalUrlForScheme(String url, String scheme) {
|
|
|
|
|
final prefix = '$scheme:';
|
|
|
|
|
if (!url.toLowerCase().startsWith(prefix)) return url;
|
|
|
|
|
String _externalUrlForScheme(String url, String scheme, String? authority) {
|
|
|
|
|
final prefix = '${scheme.toLowerCase()}://';
|
|
|
|
|
if (url.length < prefix.length ||
|
|
|
|
|
url.substring(0, prefix.length).toLowerCase() != prefix) {
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final stripped = Uri.decodeComponent(url.substring(prefix.length));
|
|
|
|
|
|
|
|
|
|
final stripped = url
|
|
|
|
|
.substring(prefix.length)
|
|
|
|
|
.replaceFirst(RegExp(r'^/+'), '');
|
|
|
|
|
final uri = Uri.tryParse(stripped);
|
|
|
|
|
if (uri != null &&
|
|
|
|
|
(uri.scheme == 'http' || uri.scheme == 'https') &&
|
|
|
|
|
uri.host.isNotEmpty) {
|
|
|
|
|
if (uri != null && uri.scheme.isNotEmpty) {
|
|
|
|
|
return stripped;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -634,10 +645,12 @@ class _LoadingScreenState extends State<LoadingScreen>
|
|
|
|
|
shouldOverrideUrlLoading:
|
|
|
|
|
(controller, navigationAction) async {
|
|
|
|
|
final requestUrl = navigationAction.request.url
|
|
|
|
|
?.toString();
|
|
|
|
|
?.rawValue;
|
|
|
|
|
|
|
|
|
|
if (requestUrl != null &&
|
|
|
|
|
requestUrl.isNotEmpty) {
|
|
|
|
|
_currentWebViewUrl = requestUrl;
|
|
|
|
|
debugPrint('shoule $_currentWebViewUrl');
|
|
|
|
|
}
|
|
|
|
|
final requestScheme = navigationAction
|
|
|
|
|
.request
|
|
|
|
|
@@ -645,6 +658,10 @@ class _LoadingScreenState extends State<LoadingScreen>
|
|
|
|
|
?.scheme
|
|
|
|
|
.trim()
|
|
|
|
|
.toLowerCase();
|
|
|
|
|
if (requestScheme != null &&
|
|
|
|
|
_webSchemes.contains(requestScheme)) {
|
|
|
|
|
return NavigationActionPolicy.ALLOW;
|
|
|
|
|
}
|
|
|
|
|
if (requestUrl != null &&
|
|
|
|
|
requestUrl.isNotEmpty &&
|
|
|
|
|
requestScheme != null &&
|
|
|
|
|
@@ -655,6 +672,7 @@ class _LoadingScreenState extends State<LoadingScreen>
|
|
|
|
|
_externalUrlForScheme(
|
|
|
|
|
requestUrl,
|
|
|
|
|
requestScheme,
|
|
|
|
|
navigationAction.request.url?.authority,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return NavigationActionPolicy.CANCEL;
|
|
|
|
|
|