Merge pull request #179 from ente-io/link_sharing_changes

Link sharing changes
This commit is contained in:
Neeraj Gupta 2022-02-04 11:27:18 +05:30 committed by GitHub
commit 0a5f01461b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 63 additions and 75 deletions

View file

@ -36,7 +36,7 @@ analyzer:
directives_ordering: error directives_ordering: error
always_use_package_imports: error always_use_package_imports: error
prefer_final_fields: error prefer_final_fields: error
unused_import: warning unused_import: error
prefer_is_empty: warning prefer_is_empty: warning
use_rethrow_when_possible: info use_rethrow_when_possible: info

View file

@ -7,6 +7,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:flutter_sodium/flutter_sodium.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/core/event_bus.dart'; import 'package:photos/core/event_bus.dart';
import 'package:photos/db/collections_db.dart'; import 'package:photos/db/collections_db.dart';
import 'package:photos/db/files_db.dart'; import 'package:photos/db/files_db.dart';
@ -30,8 +31,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:super_logging/super_logging.dart'; import 'package:super_logging/super_logging.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'constants.dart';
class Configuration { class Configuration {
Configuration._privateConstructor(); Configuration._privateConstructor();

View file

@ -1,6 +1,6 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/core/constants.dart'; import 'package:photos/core/constants.dart';

View file

@ -3,7 +3,6 @@ import 'dart:typed_data';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:flutter_sodium/flutter_sodium.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
@ -73,8 +72,7 @@ class UserService {
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
if (e.response != null && e.response.statusCode == 403) { if (e.response != null && e.response.statusCode == 403) {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "this email is already in use");
AppLocalizations.of(context).email_already_claimed);
} else { } else {
showGenericErrorDialog(context); showGenericErrorDialog(context);
} }
@ -222,20 +220,17 @@ class UserService {
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
if (e.response != null && e.response.statusCode == 410) { if (e.response != null && e.response.statusCode == 410) {
await showErrorDialog(context, AppLocalizations.of(context).oops, await showErrorDialog(
AppLocalizations.of(context).log_in_code_expired); context, "oops", "your verification code has expired");
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
showErrorDialog( showErrorDialog(context, "incorrect code",
context, "authentication failed, please try again");
AppLocalizations.of(context).incorrect_code_title,
AppLocalizations.of(context).incorrect_code_msg);
} }
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "verification failed, please try again");
"verification failed, please try again");
} }
} }
@ -267,24 +262,19 @@ class UserService {
Bus.instance.fire(UserDetailsChangedEvent()); Bus.instance.fire(UserDetailsChangedEvent());
return; return;
} }
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "verification failed, please try again");
"verification failed, please try again");
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
if (e.response != null && e.response.statusCode == 403) { if (e.response != null && e.response.statusCode == 403) {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "this email is already in use");
AppLocalizations.of(context).email_already_claimed);
} else { } else {
showErrorDialog( showErrorDialog(context, "incorrect code",
context, "authentication failed, please try again");
AppLocalizations.of(context).incorrect_code_title,
AppLocalizations.of(context).incorrect_code_msg);
} }
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "verification failed, please try again");
"verification failed, please try again");
} }
} }
@ -406,8 +396,8 @@ class UserService {
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"authentication failed, please try again"); context, "oops", "authentication failed, please try again");
} }
} }
@ -447,13 +437,13 @@ class UserService {
(route) => route.isFirst, (route) => route.isFirst,
); );
} else { } else {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"something went wrong, please try again"); context, "oops", "something went wrong, please try again");
} }
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"something went wrong, please try again"); context, "oops", "something went wrong, please try again");
} finally { } finally {
await dialog.hide(); await dialog.hide();
} }
@ -513,13 +503,13 @@ class UserService {
(route) => route.isFirst, (route) => route.isFirst,
); );
} else { } else {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"something went wrong, please try again"); context, "oops", "something went wrong, please try again");
} }
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"something went wrong, please try again"); context, "oops", "something went wrong, please try again");
} finally { } finally {
await dialog.hide(); await dialog.hide();
} }

View file

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photos/services/user_service.dart'; import 'package:photos/services/user_service.dart';
import 'package:photos/utils/dialog_util.dart'; import 'package:photos/utils/dialog_util.dart';

View file

@ -5,7 +5,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_password_strength/flutter_password_strength.dart'; import 'package:flutter_password_strength/flutter_password_strength.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/models/billing_plan.dart'; import 'package:photos/models/billing_plan.dart';
@ -67,7 +66,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
child: Material( child: Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Text( child: Text(
AppLocalizations.of(context).sign_up, "sign up",
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
letterSpacing: 0.6, letterSpacing: 0.6,
@ -209,7 +208,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
height: 64, height: 64,
padding: const EdgeInsets.fromLTRB(80, 0, 80, 0), padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
child: button( child: button(
AppLocalizations.of(context).sign_up, "sign up",
onPressed: _isFormValid() onPressed: _isFormValid()
? () { ? () {
if (!isValidEmail(_email)) { if (!isValidEmail(_email)) {

View file

@ -5,7 +5,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:move_to_background/move_to_background.dart'; import 'package:move_to_background/move_to_background.dart';
import 'package:photo_manager/photo_manager.dart'; import 'package:photo_manager/photo_manager.dart';
@ -121,20 +120,19 @@ class _HomeWidgetState extends State<HomeWidget> {
_triggerLogoutEvent = _triggerLogoutEvent =
Bus.instance.on<TriggerLogoutEvent>().listen((event) async { Bus.instance.on<TriggerLogoutEvent>().listen((event) async {
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
title: Text(AppLocalizations.of(context).auth_session_expired), title: Text("session expired"),
content: Text(AppLocalizations.of(context).auth_login_again), content: Text("please login again"),
actions: [ actions: [
TextButton( TextButton(
child: Text( child: Text(
AppLocalizations.of(context).ok, "ok",
style: TextStyle( style: TextStyle(
color: Theme.of(context).buttonColor, color: Theme.of(context).buttonColor,
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context, rootNavigator: true).pop('dialog'); Navigator.of(context, rootNavigator: true).pop('dialog');
final dialog = createProgressDialog( final dialog = createProgressDialog(context, "logging out...");
context, AppLocalizations.of(context).auth_logging_out);
await dialog.show(); await dialog.show();
await Configuration.instance.logout(); await Configuration.instance.logout();
await dialog.hide(); await dialog.hide();
@ -410,7 +408,7 @@ class _HomeWidgetState extends State<HomeWidget> {
height: 64, height: 64,
padding: const EdgeInsets.fromLTRB(60, 0, 60, 0), padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
child: button( child: button(
AppLocalizations.of(context).start_backup, "start backup",
fontSize: 16, fontSize: 16,
lineHeight: 1.5, lineHeight: 1.5,
padding: EdgeInsets.only(bottom: 4), padding: EdgeInsets.only(bottom: 4),
@ -423,7 +421,7 @@ class _HomeWidgetState extends State<HomeWidget> {
context, context,
BackupFolderSelectionPage( BackupFolderSelectionPage(
shouldSelectAll: true, shouldSelectAll: true,
buttonText: AppLocalizations.of(context).start_backup, buttonText: "start backup",
), ),
); );
} }

View file

@ -1,7 +1,6 @@
import 'package:dots_indicator/dots_indicator.dart'; import 'package:dots_indicator/dots_indicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/ui/email_entry_page.dart'; import 'package:photos/ui/email_entry_page.dart';
import 'package:photos/ui/login_page.dart'; import 'package:photos/ui/login_page.dart';
@ -110,7 +109,7 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
child: Material( child: Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Text( child: Text(
AppLocalizations.of(context).log_in, "log in",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 16,
@ -153,7 +152,7 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
child: Material( child: Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Text( child: Text(
AppLocalizations.of(context).sign_up, "sign up",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 18, fontSize: 18,

View file

@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/services/user_service.dart'; import 'package:photos/services/user_service.dart';
import 'package:photos/ui/common_elements.dart'; import 'package:photos/ui/common_elements.dart';
@ -36,7 +35,7 @@ class _LoginPageState extends State<LoginPage> {
child: Material( child: Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: Text( child: Text(
AppLocalizations.of(context).log_in, "log in",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
letterSpacing: 0.6, letterSpacing: 0.6,
@ -139,7 +138,7 @@ class _LoginPageState extends State<LoginPage> {
height: 64, height: 64,
padding: const EdgeInsets.fromLTRB(80, 0, 80, 0), padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
child: button( child: button(
AppLocalizations.of(context).log_in, "log in",
onPressed: _email != null && _email.isNotEmpty onPressed: _email != null && _email.isNotEmpty
? () { ? () {
if (!isValidEmail(_email)) { if (!isValidEmail(_email)) {

View file

@ -1,7 +1,4 @@
import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:photos/services/user_service.dart'; import 'package:photos/services/user_service.dart';
import 'package:photos/ui/common_elements.dart'; import 'package:photos/ui/common_elements.dart';

View file

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart'; import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart'; import 'package:photos/core/event_bus.dart';
@ -94,7 +93,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
width: double.infinity, width: double.infinity,
height: 64, height: 64,
child: button( child: button(
AppLocalizations.of(context).log_in, "log in",
fontSize: 18, fontSize: 18,
onPressed: _passwordController.text.isNotEmpty onPressed: _passwordController.text.isNotEmpty
? () async { ? () async {

View file

@ -2,7 +2,6 @@ import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:fluttercontactpicker/fluttercontactpicker.dart'; import 'package:fluttercontactpicker/fluttercontactpicker.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
@ -53,7 +52,7 @@ class _SharingDialogState extends State<SharingDialog> {
children.add(_getEmailField()); children.add(_getEmailField());
} }
children.add(Padding( children.add(Padding(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(8),
)); ));
if (!_showEntryField) { if (!_showEntryField) {
children.add(SizedBox( children.add(SizedBox(
@ -87,9 +86,9 @@ class _SharingDialogState extends State<SharingDialog> {
if (!FeatureFlagService.instance.disableUrlSharing()) { if (!FeatureFlagService.instance.disableUrlSharing()) {
bool hasUrl = widget.collection.publicURLs?.isNotEmpty ?? false; bool hasUrl = widget.collection.publicURLs?.isNotEmpty ?? false;
children.addAll([ children.addAll([
Padding(padding: EdgeInsets.all(12)), Padding(padding: EdgeInsets.all(16)),
Divider(height: 1), Divider(height: 1),
Padding(padding: EdgeInsets.all(8)), Padding(padding: EdgeInsets.all(12)),
SizedBox( SizedBox(
height: 36, height: 36,
child: Row( child: Row(
@ -228,15 +227,26 @@ class _SharingDialogState extends State<SharingDialog> {
}, },
child: Container( child: Container(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
child: Center( child: Row(
child: Text( crossAxisAlignment: CrossAxisAlignment.end,
url, children: [
style: TextStyle( Flexible(
fontSize: 16, child: Text(
fontFeatures: const [FontFeature.tabularFigures()], url,
color: Colors.white.withOpacity(0.7), style: TextStyle(
fontSize: 16,
fontFeatures: const [FontFeature.tabularFigures()],
color: Colors.white.withOpacity(0.68),
overflow: TextOverflow.ellipsis,
),
),
), ),
), Padding(padding: EdgeInsets.all(2)),
Icon(
Icons.copy,
size: 18,
),
],
), ),
color: Colors.white.withOpacity(0.02), color: Colors.white.withOpacity(0.02),
), ),
@ -279,12 +289,11 @@ class _SharingDialogState extends State<SharingDialog> {
"please enter a valid email address."); "please enter a valid email address.");
return; return;
} else if (email == Configuration.instance.getEmail()) { } else if (email == Configuration.instance.getEmail()) {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(context, "oops", "you cannot share with yourself");
"you cannot share with yourself");
return; return;
} else if (widget.collection.sharees.any((user) => user.email == email)) { } else if (widget.collection.sharees.any((user) => user.email == email)) {
showErrorDialog(context, AppLocalizations.of(context).oops, showErrorDialog(
"you're already sharing this with " + email); context, "oops", "you're already sharing this with " + email);
return; return;
} }
if (publicKey == null) { if (publicKey == null) {

View file

@ -11,7 +11,7 @@ description: ente photos application
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.4.16+276 version: 0.4.17+277
environment: environment:
sdk: ">=2.10.0 <3.0.0" sdk: ">=2.10.0 <3.0.0"