From eb5705df3617d058e94af87d7d55c14c3dcee06e Mon Sep 17 00:00:00 2001 From: Vishnu Mohandas Date: Tue, 25 May 2021 17:46:42 +0530 Subject: [PATCH] Revert "Switch to older version of WebView" This reverts commit cdd814cdbdb9eb83983d89dd176132e208be63f7. --- android/app/build.gradle | 2 +- lib/ui/settings/support_section_widget.dart | 53 +++++++++++---------- lib/ui/web_page.dart | 17 ++----- pubspec.lock | 21 +++++--- pubspec.yaml | 4 +- 5 files changed, 49 insertions(+), 48 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 8d00e8530..0cbd4ccc3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -44,7 +44,7 @@ android { defaultConfig { applicationId "io.ente.photos" - minSdkVersion 19 + minSdkVersion 18 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/ui/settings/support_section_widget.dart b/lib/ui/settings/support_section_widget.dart index 33b0be8f6..51ec6dc1b 100644 --- a/lib/ui/settings/support_section_widget.dart +++ b/lib/ui/settings/support_section_widget.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:archive/archive_io.dart'; -// import 'package:crisp/crisp.dart'; +import 'package:crisp/crisp.dart'; import 'package:flutter/material.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart'; import 'package:path_provider/path_provider.dart'; @@ -58,20 +58,20 @@ class SupportSectionWidget extends StatelessWidget { }, child: SettingsTextItem(text: "email", icon: Icons.navigate_next), ), - // Divider(height: 4), - // GestureDetector( - // behavior: HitTestBehavior.translucent, - // onTap: () async { - // Navigator.of(context).push( - // MaterialPageRoute( - // builder: (BuildContext context) { - // return CrispChatPage(); - // }, - // ), - // ); - // }, - // child: SettingsTextItem(text: "chat", icon: Icons.navigate_next), - // ), + Divider(height: 4), + GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () async { + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) { + return CrispChatPage(); + }, + ), + ); + }, + child: SettingsTextItem(text: "chat", icon: Icons.navigate_next), + ), Divider(height: 4), GestureDetector( behavior: HitTestBehavior.translucent, @@ -115,18 +115,18 @@ class CrispChatPage extends StatefulWidget { class _CrispChatPageState extends State { static const websiteID = "86d56ea2-68a2-43f9-8acb-95e06dee42e8"; - // CrispMain _crisp; + CrispMain _crisp; @override void initState() { - // _crisp = CrispMain( - // websiteId: websiteID, - // ); - // _crisp.register( - // user: CrispUser( - // email: Configuration.instance.getEmail(), - // ), - // ); + _crisp = CrispMain( + websiteId: websiteID, + ); + _crisp.register( + user: CrispUser( + email: Configuration.instance.getEmail(), + ), + ); super.initState(); } @@ -136,7 +136,10 @@ class _CrispChatPageState extends State { appBar: AppBar( title: Text("support chat"), ), - body: Center(child: Text("unavailable")), + body: CrispView( + crispMain: _crisp, + loadingWidget: loadWidget, + ), ); } } diff --git a/lib/ui/web_page.dart b/lib/ui/web_page.dart index 3e3ee39a5..5549c74a0 100644 --- a/lib/ui/web_page.dart +++ b/lib/ui/web_page.dart @@ -1,8 +1,6 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:photos/ui/loading_widget.dart'; -import 'package:webview_flutter/webview_flutter.dart'; class WebPage extends StatefulWidget { final String title; @@ -17,12 +15,6 @@ class WebPage extends StatefulWidget { class _WebPageState extends State { bool _hasLoadedPage = false; - @override - void initState() { - super.initState(); - if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -30,10 +22,9 @@ class _WebPageState extends State { title: Text(widget.title), actions: [_hasLoadedPage ? Container() : loadWidget], ), - body: WebView( - initialUrl: widget.url, - javascriptMode: JavascriptMode.unrestricted, - onPageFinished: (url) { + body: InAppWebView( + initialUrlRequest: URLRequest(url: Uri.parse(widget.url)), + onLoadStop: (c, url) { setState(() { _hasLoadedPage = true; }); diff --git a/pubspec.lock b/pubspec.lock index ad2a45ec2..d4fa4744e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -134,6 +134,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.4.0" + crisp: + dependency: "direct main" + description: + name: crisp + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" crypto: dependency: transitive description: @@ -237,6 +244,13 @@ packages: relative: true source: path version: "0.7.0" + flutter_inappwebview: + dependency: "direct main" + description: + name: flutter_inappwebview + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.2" flutter_keyboard_visibility: dependency: transitive description: @@ -931,13 +945,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0" - webview_flutter: - dependency: "direct main" - description: - name: webview_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.7" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ed55af09e..7ff0e6a0d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,7 @@ dependencies: computer: ^1.0.2 flutter_secure_storage: ^4.2.0 uni_links: ^0.5.1 - # crisp: ^0.1.3 + crisp: ^0.1.3 flutter_sodium: ^0.2.0 pedantic: ^1.9.2 page_transition: "^1.1.7+2" @@ -66,7 +66,7 @@ dependencies: path: thirdparty/in_app_purchase expansion_card: ^0.1.0 flutter_password_strength: ^0.1.6 - webview_flutter: ^2.0.7 + flutter_inappwebview: ^5.3.2 background_fetch: ^0.7.2 # flutter_inapp_purchase: ^3.0.1 google_nav_bar: ^5.0.5