mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Show intro dialog for photo enhancement
This commit is contained in:
parent
fb2bb30e0f
commit
9ecdb53e69
7 changed files with 98 additions and 3 deletions
|
@ -6,6 +6,8 @@ const twoFactorAuthUrl =
|
|||
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/two-factor-authentication";
|
||||
const homeFolderNotFoundUrl =
|
||||
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/home-folder-not-found";
|
||||
const enhanceUrl =
|
||||
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/enhance";
|
||||
const enhanceZeroDceUrl =
|
||||
"https://gitlab.com/nkming2/nc-photos/-/wikis/help/enhance/zero-dce";
|
||||
const enhanceDeepLabPortraitBlurUrl =
|
||||
|
|
|
@ -1182,6 +1182,8 @@
|
|||
"@enhanceTooltip": {
|
||||
"description": "Enhance a photo"
|
||||
},
|
||||
"enhanceIntroDialogTitle": "Enhance your photos",
|
||||
"enhanceIntroDialogDescription": "Your photos are processed locally on your device. By default, they are downscaled to 2048x1536. You can adjust the output resolution in Settings",
|
||||
"enhanceLowLightTitle": "Low-light enhancement",
|
||||
"@enhanceLowLightTitle": {
|
||||
"description": "Enhance a photo taken in low-light environment"
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
"backgroundServiceStopping",
|
||||
"metadataTaskPauseLowBatteryNotification",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -200,6 +202,8 @@
|
|||
"backgroundServiceStopping",
|
||||
"metadataTaskPauseLowBatteryNotification",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -366,6 +370,8 @@
|
|||
"backgroundServiceStopping",
|
||||
"metadataTaskPauseLowBatteryNotification",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -383,6 +389,8 @@
|
|||
"backgroundServiceStopping",
|
||||
"metadataTaskPauseLowBatteryNotification",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -395,6 +403,8 @@
|
|||
"settingsEnhanceMaxResolutionTitle",
|
||||
"settingsEnhanceMaxResolutionDescription",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -411,6 +421,8 @@
|
|||
"helpButtonLabel",
|
||||
"removeFromAlbumTooltip",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -444,6 +456,8 @@
|
|||
"backgroundServiceStopping",
|
||||
"metadataTaskPauseLowBatteryNotification",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -456,6 +470,8 @@
|
|||
"settingsEnhanceMaxResolutionTitle",
|
||||
"settingsEnhanceMaxResolutionDescription",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -468,6 +484,8 @@
|
|||
"settingsEnhanceMaxResolutionTitle",
|
||||
"settingsEnhanceMaxResolutionDescription",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -480,6 +498,8 @@
|
|||
"settingsEnhanceMaxResolutionTitle",
|
||||
"settingsEnhanceMaxResolutionDescription",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
@ -492,6 +512,8 @@
|
|||
"settingsEnhanceMaxResolutionTitle",
|
||||
"settingsEnhanceMaxResolutionDescription",
|
||||
"enhanceTooltip",
|
||||
"enhanceIntroDialogTitle",
|
||||
"enhanceIntroDialogDescription",
|
||||
"enhanceLowLightTitle",
|
||||
"collectionEnhancedPhotosLabel",
|
||||
"deletePermanentlyLocalConfirmationDialogContent",
|
||||
|
|
|
@ -186,6 +186,13 @@ class Pref {
|
|||
value,
|
||||
(key, value) => provider.setInt(key, value));
|
||||
|
||||
bool? hasShownEnhanceInfo() => provider.getBool(PrefKey.hasShownEnhanceInfo);
|
||||
bool hasShownEnhanceInfoOr([bool def = false]) => hasShownEnhanceInfo() ?? def;
|
||||
Future<bool> setHasShownEnhanceInfo(bool value) => _set<bool>(
|
||||
PrefKey.hasShownEnhanceInfo,
|
||||
value,
|
||||
(key, value) => provider.setBool(key, value));
|
||||
|
||||
Future<bool> _set<T>(PrefKey key, T value,
|
||||
Future<bool> Function(PrefKey key, T value) setFn) async {
|
||||
if (await setFn(key, value)) {
|
||||
|
@ -477,6 +484,7 @@ enum PrefKey {
|
|||
hasShownSharedAlbumInfo,
|
||||
enhanceMaxWidth,
|
||||
enhanceMaxHeight,
|
||||
hasShownEnhanceInfo,
|
||||
|
||||
// account pref
|
||||
isEnableFaceRecognitionApp,
|
||||
|
@ -535,6 +543,8 @@ extension on PrefKey {
|
|||
return "enhanceMaxWidth";
|
||||
case PrefKey.enhanceMaxHeight:
|
||||
return "enhanceMaxHeight";
|
||||
case PrefKey.hasShownEnhanceInfo:
|
||||
return "hasShownEnhanceInfo";
|
||||
|
||||
// account pref
|
||||
case PrefKey.isEnableFaceRecognitionApp:
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'package:nc_photos/object_extension.dart';
|
|||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/pref.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/settings.dart';
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
|
@ -26,6 +27,10 @@ class EnhanceHandler {
|
|||
file_util.isSupportedImageFormat(file) && file.contentType != "image/gif";
|
||||
|
||||
Future<void> call(BuildContext context) async {
|
||||
if (!Pref().hasShownEnhanceInfoOr()) {
|
||||
await _showInfo(context);
|
||||
}
|
||||
|
||||
if (!await _ensurePermission()) {
|
||||
return;
|
||||
}
|
||||
|
@ -90,6 +95,37 @@ class EnhanceHandler {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _showInfo(BuildContext context) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(L10n.global().enhanceIntroDialogTitle),
|
||||
content: Text(L10n.global().enhanceIntroDialogDescription),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
launch(enhanceUrl);
|
||||
},
|
||||
child: Text(L10n.global().learnMoreButtonLabel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(EnhancementSettings.routeName);
|
||||
},
|
||||
child: Text(L10n.global().configButtonLabel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(MaterialLocalizations.of(context).closeButtonLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
Pref().setHasShownEnhanceInfo(true);
|
||||
}
|
||||
|
||||
Future<bool> _ensurePermission() async {
|
||||
if (platform_k.isAndroid) {
|
||||
if (AndroidInfo().sdkInt < AndroidVersion.R &&
|
||||
|
|
|
@ -172,6 +172,7 @@ class _MyAppState extends State<MyApp>
|
|||
route ??= _handleFavoriteBrowserRoute(settings);
|
||||
route ??= _handleEnhancedPhotoBrowserRoute(settings);
|
||||
route ??= _handleLocalFileViewerRoute(settings);
|
||||
route ??= _handleEnhancementSettingsRoute(settings);
|
||||
return route;
|
||||
}
|
||||
|
||||
|
@ -536,6 +537,18 @@ class _MyAppState extends State<MyApp>
|
|||
return null;
|
||||
}
|
||||
|
||||
Route<dynamic>? _handleEnhancementSettingsRoute(RouteSettings settings) {
|
||||
try {
|
||||
if (settings.name == EnhancementSettings.routeName) {
|
||||
return EnhancementSettings.buildRoute();
|
||||
}
|
||||
} catch (e) {
|
||||
_log.severe(
|
||||
"[_handleEnhancementSettingsRoute] Failed while handling route", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
final _navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ class _SettingsState extends State<Settings> {
|
|||
color: AppTheme.getUnfocusedIconColor(context),
|
||||
),
|
||||
label: L10n.global().settingsPhotoEnhancementTitle,
|
||||
builder: () => _EnhancementSettings(),
|
||||
builder: () => const EnhancementSettings(),
|
||||
),
|
||||
_buildSubSettings(
|
||||
context,
|
||||
|
@ -966,12 +966,22 @@ class _AlbumSettingsState extends State<_AlbumSettings> {
|
|||
static final _log = Logger("widget.settings._AlbumSettingsState");
|
||||
}
|
||||
|
||||
class _EnhancementSettings extends StatefulWidget {
|
||||
class EnhancementSettings extends StatefulWidget {
|
||||
static const routeName = "/enhancement-settings";
|
||||
|
||||
static Route buildRoute() => MaterialPageRoute(
|
||||
builder: (_) => const EnhancementSettings(),
|
||||
);
|
||||
|
||||
const EnhancementSettings({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
createState() => _EnhancementSettingsState();
|
||||
}
|
||||
|
||||
class _EnhancementSettingsState extends State<_EnhancementSettings> {
|
||||
class _EnhancementSettingsState extends State<EnhancementSettings> {
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
|
|
Loading…
Reference in a new issue