rm
This commit is contained in:
parent
0dbe29bdb3
commit
935d8ba8eb
6 changed files with 192 additions and 219 deletions
|
|
@ -5,7 +5,6 @@ import 'package:flex_color_scheme/flex_color_scheme.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:google_api_availability/google_api_availability.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
|
@ -24,8 +23,6 @@ import 'package:window_manager/window_manager.dart';
|
|||
|
||||
late Isar isar;
|
||||
|
||||
bool hasGPServices = false;
|
||||
|
||||
void main(List<String> args) async {
|
||||
if (Platform.isMacOS) {
|
||||
if (runWebViewTitleBarWidget(args)) {
|
||||
|
|
@ -42,13 +39,6 @@ void main(List<String> args) async {
|
|||
isar = await StorageProvider().initDB(null, inspector: kDebugMode);
|
||||
await StorageProvider().requestPermission();
|
||||
GoogleFonts.aBeeZee();
|
||||
if (Platform.isAndroid) {
|
||||
try {
|
||||
hasGPServices = (await GoogleApiAvailability.instance
|
||||
.checkGooglePlayServicesAvailability()) ==
|
||||
GooglePlayServicesAvailability.success;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
runApp(const ProviderScope(child: MyApp()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,167 +124,169 @@ class _MangaWebViewState extends ConsumerState<MangaWebView> {
|
|||
icon: const Icon(Icons.close)),
|
||||
),
|
||||
)
|
||||
: SafeArea(
|
||||
child: WillPopScope(
|
||||
onWillPop: () async {
|
||||
_webViewController?.goBack();
|
||||
return false;
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: AppBar().preferredSize.height,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
subtitle: Text(
|
||||
_url,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
: Material(
|
||||
child: SafeArea(
|
||||
child: WillPopScope(
|
||||
onWillPop: () async {
|
||||
_webViewController?.goBack();
|
||||
return false;
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: AppBar().preferredSize.height,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
subtitle: Text(
|
||||
_url,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
title: Text(
|
||||
_title,
|
||||
style: const TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.close)),
|
||||
),
|
||||
title: Text(
|
||||
_title,
|
||||
style: const TextStyle(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.close)),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back,
|
||||
color: _canGoback ? null : Colors.grey),
|
||||
onPressed: _canGoback
|
||||
? () {
|
||||
_webViewController?.goBack();
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back,
|
||||
color: _canGoback ? null : Colors.grey),
|
||||
onPressed: _canGoback
|
||||
? () {
|
||||
_webViewController?.goBack();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_forward,
|
||||
color: _canGoForward ? null : Colors.grey),
|
||||
onPressed: _canGoForward
|
||||
? () {
|
||||
_webViewController?.goForward();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
PopupMenuButton(
|
||||
popUpAnimationStyle: popupAnimationStyle,
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<int>(
|
||||
value: 0, child: Text(l10n!.refresh)),
|
||||
PopupMenuItem<int>(
|
||||
value: 1, child: Text(l10n.share)),
|
||||
PopupMenuItem<int>(
|
||||
value: 2,
|
||||
child: Text(l10n.open_in_browser)),
|
||||
PopupMenuItem<int>(
|
||||
value: 3, child: Text(l10n.clear_cookie)),
|
||||
];
|
||||
},
|
||||
onSelected: (value) async {
|
||||
if (value == 0) {
|
||||
_webViewController?.reload();
|
||||
} else if (value == 1) {
|
||||
Share.share(_url);
|
||||
} else if (value == 2) {
|
||||
await InAppBrowser.openWithSystemBrowser(
|
||||
url: Uri.parse(_url));
|
||||
} else if (value == 3) {
|
||||
CookieManager.instance().deleteAllCookies();
|
||||
MClient.deleteAllCookies(_url);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_forward,
|
||||
color: _canGoForward ? null : Colors.grey),
|
||||
onPressed: _canGoForward
|
||||
? () {
|
||||
_webViewController?.goForward();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
PopupMenuButton(
|
||||
popUpAnimationStyle: popupAnimationStyle,
|
||||
itemBuilder: (context) {
|
||||
return [
|
||||
PopupMenuItem<int>(
|
||||
value: 0, child: Text(l10n!.refresh)),
|
||||
PopupMenuItem<int>(
|
||||
value: 1, child: Text(l10n.share)),
|
||||
PopupMenuItem<int>(
|
||||
value: 2,
|
||||
child: Text(l10n.open_in_browser)),
|
||||
PopupMenuItem<int>(
|
||||
value: 3, child: Text(l10n.clear_cookie)),
|
||||
];
|
||||
},
|
||||
onSelected: (value) async {
|
||||
if (value == 0) {
|
||||
_webViewController?.reload();
|
||||
} else if (value == 1) {
|
||||
Share.share(_url);
|
||||
} else if (value == 2) {
|
||||
await InAppBrowser.openWithSystemBrowser(
|
||||
url: Uri.parse(_url));
|
||||
} else if (value == 3) {
|
||||
CookieManager.instance().deleteAllCookies();
|
||||
MClient.deleteAllCookies(_url);
|
||||
}
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_progress < 1.0
|
||||
? LinearProgressIndicator(value: _progress)
|
||||
: Container(),
|
||||
Expanded(
|
||||
child: InAppWebView(
|
||||
key: webViewKey,
|
||||
onWebViewCreated: (controller) async {
|
||||
_webViewController = controller;
|
||||
},
|
||||
onLoadStart: (controller, url) async {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
});
|
||||
},
|
||||
shouldOverrideUrlLoading:
|
||||
(controller, navigationAction) async {
|
||||
var uri = navigationAction.request.url!;
|
||||
|
||||
if (![
|
||||
"http",
|
||||
"https",
|
||||
"file",
|
||||
"chrome",
|
||||
"data",
|
||||
"javascript",
|
||||
"about"
|
||||
].contains(uri.scheme)) {
|
||||
if (await canLaunchUrl(uri)) {
|
||||
// Launch the App
|
||||
await launchUrl(
|
||||
uri,
|
||||
);
|
||||
// and cancel the request
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
_progress < 1.0
|
||||
? LinearProgressIndicator(value: _progress)
|
||||
: Container(),
|
||||
Expanded(
|
||||
child: InAppWebView(
|
||||
key: webViewKey,
|
||||
onWebViewCreated: (controller) async {
|
||||
_webViewController = controller;
|
||||
},
|
||||
onLoadStart: (controller, url) async {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
});
|
||||
},
|
||||
shouldOverrideUrlLoading:
|
||||
(controller, navigationAction) async {
|
||||
var uri = navigationAction.request.url!;
|
||||
|
||||
if (![
|
||||
"http",
|
||||
"https",
|
||||
"file",
|
||||
"chrome",
|
||||
"data",
|
||||
"javascript",
|
||||
"about"
|
||||
].contains(uri.scheme)) {
|
||||
if (await canLaunchUrl(uri)) {
|
||||
// Launch the App
|
||||
await launchUrl(
|
||||
uri,
|
||||
);
|
||||
// and cancel the request
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NavigationActionPolicy.ALLOW;
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
});
|
||||
}
|
||||
},
|
||||
onProgressChanged: (controller, progress) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_progress = progress / 100;
|
||||
});
|
||||
}
|
||||
},
|
||||
onUpdateVisitedHistory:
|
||||
(controller, url, isReload) async {
|
||||
final ua = await controller.evaluateJavascript(
|
||||
source: "navigator.userAgent") ??
|
||||
"";
|
||||
await MClient.setCookie(url.toString(), ua);
|
||||
final canGoback = await controller.canGoBack();
|
||||
final canGoForward = await controller.canGoForward();
|
||||
final title = await controller.getTitle();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
_title = title!;
|
||||
_canGoback = canGoback;
|
||||
_canGoForward = canGoForward;
|
||||
});
|
||||
}
|
||||
},
|
||||
initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
|
||||
|
||||
return NavigationActionPolicy.ALLOW;
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
});
|
||||
}
|
||||
},
|
||||
onProgressChanged: (controller, progress) async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_progress = progress / 100;
|
||||
});
|
||||
}
|
||||
},
|
||||
onUpdateVisitedHistory:
|
||||
(controller, url, isReload) async {
|
||||
final ua = await controller.evaluateJavascript(
|
||||
source: "navigator.userAgent") ??
|
||||
"";
|
||||
await MClient.setCookie(url.toString(), ua);
|
||||
final canGoback = await controller.canGoBack();
|
||||
final canGoForward = await controller.canGoForward();
|
||||
final title = await controller.getTitle();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_url = url.toString();
|
||||
_title = title!;
|
||||
_canGoback = canGoback;
|
||||
_canGoForward = canGoForward;
|
||||
});
|
||||
}
|
||||
},
|
||||
initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import 'dart:isolate';
|
|||
import 'package:async/async.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_api_availability/google_api_availability.dart';
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:mangayomi/services/http/m_client.dart';
|
||||
|
|
@ -573,16 +572,7 @@ final class DesktopDownloader extends BaseDownloader {
|
|||
|
||||
/// Recreates the [httpClient] used for Requests and isolate downloads/uploads
|
||||
static _recreateClient() async {
|
||||
bool hasGPServices = false;
|
||||
if (Platform.isAndroid) {
|
||||
hasGPServices = (await GoogleApiAvailability.instance
|
||||
.checkGooglePlayServicesAvailability()) ==
|
||||
GooglePlayServicesAvailability.success;
|
||||
}
|
||||
|
||||
if (Platform.isWindows ||
|
||||
Platform.isLinux ||
|
||||
(Platform.isAndroid && !hasGPServices)) {
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
final client = HttpClient();
|
||||
client.connectionTimeout = requestTimeout;
|
||||
client.findProxy = proxy.isNotEmpty
|
||||
|
|
@ -592,7 +582,7 @@ final class DesktopDownloader extends BaseDownloader {
|
|||
(X509Certificate cert, String host, int port) => true;
|
||||
httpClient = IOClient(client);
|
||||
} else {
|
||||
httpClient = MClient.httpClient(hasGPServices: hasGPServices);
|
||||
httpClient = MClient.httpClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,9 @@ import 'package:http/io_client.dart';
|
|||
import 'package:mangayomi/utils/log/log.dart';
|
||||
|
||||
class MClient {
|
||||
static final flutter_inappwebview.CookieManager _cookieManager =
|
||||
flutter_inappwebview.CookieManager.instance();
|
||||
|
||||
MClient();
|
||||
static Client httpClient({bool hasGPServices = false}) {
|
||||
static Client httpClient() {
|
||||
if (Platform.isAndroid) {
|
||||
if (!hasGPServices) {
|
||||
return IOClient(HttpClient());
|
||||
}
|
||||
final engine = CronetEngine.build(
|
||||
enablePublicKeyPinningBypassForLocalTrustAnchors: true,
|
||||
enableHttp2: true,
|
||||
|
|
@ -41,7 +35,7 @@ class MClient {
|
|||
static InterceptedClient init(
|
||||
{MSource? source, Map<String, dynamic>? reqcopyWith}) {
|
||||
return InterceptedClient.build(
|
||||
client: httpClient(hasGPServices: hasGPServices),
|
||||
client: httpClient(),
|
||||
interceptors: [MCookieManager(reqcopyWith), LoggerInterceptor()]);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +63,8 @@ class MClient {
|
|||
.toList() ??
|
||||
[];
|
||||
} else {
|
||||
cookies = (await _cookieManager.getCookies(url: Uri.parse(url)))
|
||||
cookies = (await flutter_inappwebview.CookieManager.instance()
|
||||
.getCookies(url: Uri.parse(url)))
|
||||
.map((e) => "${e.name}=${e.value}")
|
||||
.toList();
|
||||
}
|
||||
|
|
|
|||
57
pubspec.lock
57
pubspec.lock
|
|
@ -212,11 +212,12 @@ packages:
|
|||
cronet_http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cronet_http
|
||||
sha256: "013c515e2caf1381fcdc577b0c1a3625021b0df32880c20c06757fc616d375bb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
path: "pkgs/cronet_http"
|
||||
ref: a2e241ba1a8fdf22ce17e047ab6af8f46787faf8
|
||||
resolved-ref: a2e241ba1a8fdf22ce17e047ab6af8f46787faf8
|
||||
url: "https://github.com/dart-lang/http.git"
|
||||
source: git
|
||||
version: "1.3.1-wip"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -245,10 +246,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_http
|
||||
sha256: "0e3ed481280ad41d42d4881d4b6f89c083c17aa010205c9381ecb4c7ea7bdf1f"
|
||||
sha256: d04385be00db206c75be8ec1229729398bb7e48723ce33fde3a81ff219e2d7ca
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.5.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -590,30 +591,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.1.2"
|
||||
google_api_availability:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_api_availability
|
||||
sha256: "3e9548cfd991d983d11425a2436d5bd957d048c279cc9e145ffe3f36fd847385"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.0"
|
||||
google_api_availability_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_api_availability_android
|
||||
sha256: d95429ae78083585c312de2c6578085e7d53d100a94656d691bce0bb0ce435be
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
google_api_availability_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: google_api_availability_platform_interface
|
||||
sha256: "65b7da62fe5b582bb3d508628ad827d36d890710ea274766a992a56fa5420da6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -702,6 +679,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
http_profile:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_profile
|
||||
sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1644,6 +1629,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket
|
||||
sha256: "217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1734,4 +1727,4 @@ packages:
|
|||
version: "2.2.0"
|
||||
sdks:
|
||||
dart: ">=3.4.0 <4.0.0"
|
||||
flutter: ">=3.19.2"
|
||||
flutter: ">=3.22.0"
|
||||
|
|
|
|||
|
|
@ -67,10 +67,13 @@ dependencies:
|
|||
git:
|
||||
url: https://github.com/kodjodevf/flutter_qjs.git
|
||||
ref: main
|
||||
cronet_http: ^1.2.1
|
||||
cupertino_http: ^1.3.0
|
||||
cronet_http:
|
||||
git:
|
||||
url: https://github.com/dart-lang/http.git
|
||||
path: pkgs/cronet_http
|
||||
ref: a2e241ba1a8fdf22ce17e047ab6af8f46787faf8
|
||||
cupertino_http: ^1.5.0
|
||||
http: ^1.2.1
|
||||
google_api_availability: ^5.0.0
|
||||
flutter_code_editor: ^0.3.1
|
||||
flutter_highlight: ^0.7.0
|
||||
highlight: ^0.7.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue