diff --git a/lib/help_utils.dart b/lib/help_utils.dart index c39e267a..8629cf9a 100644 --- a/lib/help_utils.dart +++ b/lib/help_utils.dart @@ -1,4 +1,6 @@ const mainUrl = "https://gitlab.com/nkming2/nc-photos/-/wikis/home"; const peopleUrl = "https://gitlab.com/nkming2/nc-photos/-/wikis/help/people"; +const sharedAlbumLimitationsUrl = + "https://gitlab.com/nkming2/nc-photos/-/wikis/help/shared-album#limitations"; const twoFactorAuthUrl = "https://gitlab.com/nkming2/nc-photos/-/wikis/help/two-factor-authentication"; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index fdee6dee..5c93946d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1079,6 +1079,15 @@ "@addUserInputHint": { "description": "Input a user name to share this album with" }, + "sharedAlbumInfoDialogTitle": "Introducing shared album", + "@sharedAlbumInfoDialogTitle": { + "description": "This dialog is shown when user first open a shared album" + }, + "sharedAlbumInfoDialogContent": "Shared album allows multiple users on the same server to access the same album. Please read carefully the limitations before continuing", + "@sharedAlbumInfoDialogContent": { + "description": "This dialog is shown when user first open a shared album" + }, + "learnMoreButtonLabel": "LEARN MORE", "errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues", "@errorUnauthenticated": { diff --git a/lib/l10n/untranslated-messages.txt b/lib/l10n/untranslated-messages.txt index e6f1e8c1..1b655a09 100644 --- a/lib/l10n/untranslated-messages.txt +++ b/lib/l10n/untranslated-messages.txt @@ -50,6 +50,9 @@ "extraShareDescription", "defaultButtonLabel", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ], @@ -118,6 +121,9 @@ "extraShareDescription", "defaultButtonLabel", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ], @@ -241,12 +247,18 @@ "extraShareDescription", "defaultButtonLabel", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ], "es": [ "settingsMapProviderTitle", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ], @@ -350,6 +362,9 @@ "extraShareDescription", "defaultButtonLabel", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ], @@ -426,6 +441,9 @@ "extraShareDescription", "defaultButtonLabel", "addUserInputHint", + "sharedAlbumInfoDialogTitle", + "sharedAlbumInfoDialogContent", + "learnMoreButtonLabel", "errorAlbumDowngrade" ] } diff --git a/lib/pref.dart b/lib/pref.dart index abe63b6e..9fc15d7e 100644 --- a/lib/pref.dart +++ b/lib/pref.dart @@ -144,6 +144,12 @@ class Pref { Future setLabEnableSharedAlbum(bool value) => provider.setBool(PrefKey.labEnableSharedAlbum, value); + bool? hasShownSharedAlbumInfo() => + provider.getBool(PrefKey.hasShownSharedAlbumInfo); + bool hasShownSharedAlbumInfoOr(bool def) => hasShownSharedAlbumInfo() ?? def; + Future setHasShownSharedAlbumInfo(bool value) => + provider.setBool(PrefKey.hasShownSharedAlbumInfo, value); + final PrefProvider provider; static Pref? _inst; @@ -314,6 +320,7 @@ enum PrefKey { isSlideshowRepeat, isAlbumBrowserShowDate, gpsMapProvider, + hasShownSharedAlbumInfo, } extension on PrefKey { @@ -361,6 +368,8 @@ extension on PrefKey { return "isAlbumBrowserShowDate"; case PrefKey.gpsMapProvider: return "gpsMapProvider"; + case PrefKey.hasShownSharedAlbumInfo: + return "hasShownSharedAlbumInfo"; } } } diff --git a/lib/widget/album_browser.dart b/lib/widget/album_browser.dart index e26e1a59..d79dee3a 100644 --- a/lib/widget/album_browser.dart +++ b/lib/widget/album_browser.dart @@ -40,6 +40,7 @@ import 'package:nc_photos/widget/photo_list_helper.dart'; import 'package:nc_photos/widget/photo_list_item.dart'; import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/share_album_dialog.dart'; +import 'package:nc_photos/widget/shared_album_info_dialog.dart'; import 'package:nc_photos/widget/simple_input_dialog.dart'; import 'package:nc_photos/widget/viewer.dart'; @@ -182,6 +183,10 @@ class _AlbumBrowserState extends State final albumRepo = AlbumRepo(AlbumCachedDataSource(AppDb())); final album = await albumRepo.get(widget.account, widget.album.albumFile!); await _setAlbum(album); + + if (album.shares?.isNotEmpty == true) { + _showSharedAlbumInfoDialog(); + } } Widget _buildContent(BuildContext context) { @@ -329,6 +334,7 @@ class _AlbumBrowserState extends State } void _onSharePressed(BuildContext context) async { + await _showSharedAlbumInfoDialog(); await showDialog( context: context, builder: (_) => ShareAlbumDialog( @@ -778,6 +784,18 @@ class _AlbumBrowserState extends State widget.account, album, items); } + Future _showSharedAlbumInfoDialog() { + if (!Pref().hasShownSharedAlbumInfoOr(false)) { + return showDialog( + context: context, + builder: (_) => const SharedAlbumInfoDialog(), + barrierDismissible: false, + ); + } else { + return Future.value(); + } + } + bool get _canRemoveSelection { if (_album!.albumFile!.isOwned(widget.account.username) == true) { return true; diff --git a/lib/widget/shared_album_info_dialog.dart b/lib/widget/shared_album_info_dialog.dart new file mode 100644 index 00000000..b7c55bf0 --- /dev/null +++ b/lib/widget/shared_album_info_dialog.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:nc_photos/app_localizations.dart'; +import 'package:nc_photos/help_utils.dart' as help_utils; +import 'package:nc_photos/pref.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class SharedAlbumInfoDialog extends StatefulWidget { + const SharedAlbumInfoDialog({ + Key? key, + }) : super(key: key); + + @override + createState() => _SharedAlbumInfoDialogState(); +} + +class _SharedAlbumInfoDialogState extends State { + @override + dispose() { + super.dispose(); + Pref().setHasShownSharedAlbumInfo(true); + } + + @override + build(BuildContext context) { + return AlertDialog( + title: Text(L10n.global().sharedAlbumInfoDialogTitle), + content: Text(L10n.global().sharedAlbumInfoDialogContent), + actions: [ + TextButton( + onPressed: () => _onSkipPressed(context), + child: Text(L10n.global().skipButtonLabel), + ), + TextButton( + onPressed: _onLearnMorePressed, + child: Text(L10n.global().learnMoreButtonLabel), + ), + ], + ); + } + + void _onSkipPressed(BuildContext context) { + Navigator.of(context).pop(); + } + + void _onLearnMorePressed() { + launch(help_utils.sharedAlbumLimitationsUrl); + Navigator.of(context).pop(); + } +}