2022-10-04 13:12:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Yubico.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-03-25 14:23:14 +03:00
|
|
|
import 'dart:convert';
|
2022-06-05 17:33:17 +03:00
|
|
|
import 'dart:io';
|
2021-11-24 13:38:30 +03:00
|
|
|
|
2021-11-19 17:05:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-07 14:59:44 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2021-11-24 13:38:30 +03:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
2024-03-08 11:30:47 +03:00
|
|
|
import 'package:material_symbols_icons/symbols.dart';
|
2021-11-25 13:56:25 +03:00
|
|
|
|
2022-10-24 15:18:31 +03:00
|
|
|
import 'android/state.dart';
|
|
|
|
import 'app/app_url_launcher.dart';
|
2022-03-25 14:23:14 +03:00
|
|
|
import 'app/logging.dart';
|
2022-03-25 17:43:32 +03:00
|
|
|
import 'app/message.dart';
|
2022-08-04 09:23:07 +03:00
|
|
|
import 'app/state.dart';
|
2023-11-14 18:44:14 +03:00
|
|
|
import 'app/views/keys.dart';
|
2021-11-25 13:56:25 +03:00
|
|
|
import 'core/state.dart';
|
2022-01-27 14:34:29 +03:00
|
|
|
import 'desktop/state.dart';
|
2022-08-04 09:23:07 +03:00
|
|
|
import 'version.dart';
|
2022-09-01 15:00:33 +03:00
|
|
|
import 'widgets/choice_filter_chip.dart';
|
2022-10-24 15:18:31 +03:00
|
|
|
import 'widgets/responsive_dialog.dart';
|
2021-11-24 13:38:30 +03:00
|
|
|
|
2022-02-21 11:38:09 +03:00
|
|
|
final _log = Logger('about');
|
2021-11-19 17:05:57 +03:00
|
|
|
|
2021-11-24 13:38:30 +03:00
|
|
|
class AboutPage extends ConsumerWidget {
|
2022-05-12 10:56:55 +03:00
|
|
|
const AboutPage({super.key});
|
2021-11-19 17:05:57 +03:00
|
|
|
|
|
|
|
@override
|
2021-11-24 13:38:30 +03:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-02-28 13:34:29 +03:00
|
|
|
final l10n = AppLocalizations.of(context)!;
|
2022-03-15 20:04:26 +03:00
|
|
|
return ResponsiveDialog(
|
2023-03-02 14:45:55 +03:00
|
|
|
title: Text(l10n.s_about),
|
2022-09-08 13:17:44 +03:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 32),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Image.asset('assets/graphics/app-icon.png', scale: 1 / 0.75),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 24.0),
|
|
|
|
child: Text(
|
2023-02-28 17:02:12 +03:00
|
|
|
l10n.app_name,
|
2022-09-08 13:17:44 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
2022-06-02 15:53:29 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
const Text(version),
|
|
|
|
const Text(''),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
TextButton(
|
|
|
|
child: Text(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: tosButton,
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_terms_of_use,
|
2022-09-08 13:17:44 +03:00
|
|
|
style:
|
|
|
|
const TextStyle(decoration: TextDecoration.underline),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
2022-10-24 15:18:31 +03:00
|
|
|
launchTermsUrl();
|
2022-09-08 13:17:44 +03:00
|
|
|
},
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
TextButton(
|
|
|
|
child: Text(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: privacyButton,
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_privacy_policy,
|
2022-09-08 13:17:44 +03:00
|
|
|
style:
|
|
|
|
const TextStyle(decoration: TextDecoration.underline),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
2022-10-24 15:18:31 +03:00
|
|
|
launchPrivacyUrl();
|
2022-09-08 13:17:44 +03:00
|
|
|
},
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
child: Text(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: licensesButton,
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_open_src_licenses,
|
2022-09-08 13:17:44 +03:00
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
2022-06-03 17:45:02 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).push(MaterialPageRoute<void>(
|
|
|
|
builder: (BuildContext context) => const LicensePage(
|
|
|
|
applicationVersion: version,
|
|
|
|
),
|
|
|
|
settings: const RouteSettings(name: 'licenses'),
|
|
|
|
));
|
|
|
|
},
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 24.0, bottom: 8.0),
|
|
|
|
child: Divider(),
|
2022-06-02 15:53:29 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
child: Text(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: helpButton,
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_help_and_feedback,
|
2022-09-08 13:17:44 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
TextButton(
|
2024-04-11 15:24:50 +03:00
|
|
|
onPressed: launchDocumentationUrl,
|
2022-09-08 13:17:44 +03:00
|
|
|
child: Text(
|
2024-04-11 15:24:50 +03:00
|
|
|
key: userGuideButton,
|
|
|
|
l10n.s_user_guide,
|
2022-09-08 13:17:44 +03:00
|
|
|
style:
|
|
|
|
const TextStyle(decoration: TextDecoration.underline),
|
|
|
|
),
|
2022-06-05 17:33:17 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
TextButton(
|
2024-04-11 15:24:50 +03:00
|
|
|
onPressed: launchHelpUrl,
|
2022-09-08 13:17:44 +03:00
|
|
|
child: Text(
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_i_need_help,
|
2022-09-08 13:17:44 +03:00
|
|
|
style:
|
|
|
|
const TextStyle(decoration: TextDecoration.underline),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 24.0, bottom: 8.0),
|
|
|
|
child: Divider(),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
|
child: Text(
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_troubleshooting,
|
2022-09-08 13:17:44 +03:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const LoggingPanel(),
|
|
|
|
|
|
|
|
// Diagnostics (desktop only)
|
|
|
|
if (isDesktop) ...[
|
|
|
|
const SizedBox(height: 12.0),
|
|
|
|
ActionChip(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: diagnosticsChip,
|
2024-03-08 11:30:47 +03:00
|
|
|
avatar: const Icon(Symbols.bug_report),
|
2023-03-02 14:45:55 +03:00
|
|
|
label: Text(l10n.s_run_diagnostics),
|
2022-09-08 13:17:44 +03:00
|
|
|
onPressed: () async {
|
|
|
|
_log.info('Running diagnostics...');
|
2022-12-20 16:14:14 +03:00
|
|
|
final response = await ref
|
|
|
|
.read(rpcProvider)
|
|
|
|
.requireValue
|
|
|
|
.command('diagnose', []);
|
2022-09-08 13:17:44 +03:00
|
|
|
final data = response['diagnostics'] as List;
|
|
|
|
data.insert(0, {
|
|
|
|
'app_version': version,
|
|
|
|
'dart': Platform.version,
|
2023-02-24 16:24:33 +03:00
|
|
|
'os': Platform.operatingSystem,
|
|
|
|
'os_version': Platform.operatingSystemVersion,
|
2022-09-08 13:17:44 +03:00
|
|
|
});
|
2023-10-04 12:08:02 +03:00
|
|
|
data.insert(data.length - 1, ref.read(featureFlagProvider));
|
2022-09-08 13:17:44 +03:00
|
|
|
final text = const JsonEncoder.withIndent(' ').convert(data);
|
2022-09-21 16:29:34 +03:00
|
|
|
await ref.read(clipboardProvider).setText(text);
|
2022-09-08 13:17:44 +03:00
|
|
|
await ref.read(withContextProvider)(
|
|
|
|
(context) async {
|
2023-02-28 17:02:12 +03:00
|
|
|
showMessage(context, l10n.l_diagnostics_copied);
|
2022-09-08 13:17:44 +03:00
|
|
|
},
|
2022-06-05 17:33:17 +03:00
|
|
|
);
|
|
|
|
},
|
2022-06-03 17:45:02 +03:00
|
|
|
),
|
2022-09-08 13:17:44 +03:00
|
|
|
],
|
|
|
|
|
|
|
|
// Enable screenshots (Android only)
|
|
|
|
if (isAndroid) ...[
|
|
|
|
const SizedBox(height: 12.0),
|
|
|
|
FilterChip(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: screenshotChip,
|
2023-03-02 14:45:55 +03:00
|
|
|
label: Text(l10n.s_allow_screenshots),
|
2022-09-08 13:17:44 +03:00
|
|
|
selected: ref.watch(androidAllowScreenshotsProvider),
|
|
|
|
onSelected: (value) async {
|
|
|
|
ref
|
|
|
|
.read(androidAllowScreenshotsProvider.notifier)
|
|
|
|
.setAllowScreenshots(value);
|
2022-06-05 17:33:17 +03:00
|
|
|
},
|
2022-06-05 13:26:40 +03:00
|
|
|
),
|
2022-06-02 15:53:29 +03:00
|
|
|
],
|
2022-09-08 13:17:44 +03:00
|
|
|
],
|
|
|
|
),
|
2021-11-19 17:05:57 +03:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-03-25 14:23:14 +03:00
|
|
|
|
|
|
|
class LoggingPanel extends ConsumerWidget {
|
2022-05-12 10:56:55 +03:00
|
|
|
const LoggingPanel({super.key});
|
2022-03-25 14:23:14 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-02-28 13:34:29 +03:00
|
|
|
final l10n = AppLocalizations.of(context)!;
|
2022-09-01 15:00:33 +03:00
|
|
|
final logLevel = ref.watch(logLevelProvider);
|
|
|
|
return Wrap(
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
spacing: 4.0,
|
|
|
|
runSpacing: 8.0,
|
2022-03-25 14:23:14 +03:00
|
|
|
children: [
|
2022-09-01 15:00:33 +03:00
|
|
|
ChoiceFilterChip<Level>(
|
|
|
|
avatar: Icon(
|
2024-03-08 11:30:47 +03:00
|
|
|
Symbols.insights,
|
2022-09-01 15:00:33 +03:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-06-02 15:53:29 +03:00
|
|
|
),
|
2022-09-01 15:00:33 +03:00
|
|
|
value: logLevel,
|
|
|
|
items: Levels.LEVELS,
|
|
|
|
selected: logLevel != Level.INFO,
|
2023-03-02 14:45:55 +03:00
|
|
|
labelBuilder: (value) => Text(l10n.s_log_level(
|
2023-03-01 12:30:32 +03:00
|
|
|
value.name[0] + value.name.substring(1).toLowerCase())),
|
2022-09-01 15:00:33 +03:00
|
|
|
itemBuilder: (value) =>
|
|
|
|
Text('${value.name[0]}${value.name.substring(1).toLowerCase()}'),
|
2022-03-25 14:23:14 +03:00
|
|
|
onChanged: (level) {
|
2022-09-01 15:00:33 +03:00
|
|
|
ref.read(logLevelProvider.notifier).setLogLevel(level);
|
2022-05-03 12:24:25 +03:00
|
|
|
_log.debug('Log level set to $level');
|
2022-03-25 14:23:14 +03:00
|
|
|
},
|
|
|
|
),
|
2022-09-01 15:00:33 +03:00
|
|
|
ActionChip(
|
2023-11-14 18:44:14 +03:00
|
|
|
key: logChip,
|
2024-03-08 16:14:02 +03:00
|
|
|
avatar: const Icon(Symbols.content_copy),
|
2023-03-02 14:45:55 +03:00
|
|
|
label: Text(l10n.s_copy_log),
|
2022-03-25 14:23:14 +03:00
|
|
|
onPressed: () async {
|
2022-05-17 10:10:23 +03:00
|
|
|
_log.info('Copying log to clipboard ($version)...');
|
2022-05-11 16:47:35 +03:00
|
|
|
final logs = await ref.read(logLevelProvider.notifier).getLogs();
|
2022-09-21 16:29:34 +03:00
|
|
|
var clipboard = ref.read(clipboardProvider);
|
|
|
|
await clipboard.setText(logs.join('\n'));
|
|
|
|
if (!clipboard.platformGivesFeedback()) {
|
|
|
|
await ref.read(withContextProvider)(
|
2022-12-20 16:14:14 +03:00
|
|
|
(context) async {
|
2023-02-28 17:02:12 +03:00
|
|
|
showMessage(context, l10n.l_log_copied);
|
2022-09-21 16:29:34 +03:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2022-03-25 14:23:14 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|