2020-11-14 10:08:13 +01:00
|
|
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
2020-12-10 15:06:02 +01:00
|
|
|
import 'package:fluffychat/components/dialogs/bootstrap_dialog.dart';
|
2020-12-22 14:23:23 +01:00
|
|
|
import 'package:fluffychat/views/log_view.dart';
|
2020-11-24 14:27:07 +01:00
|
|
|
import 'package:fluffychat/views/settings_3pid.dart';
|
2020-11-25 20:39:54 +01:00
|
|
|
import 'package:fluffychat/views/settings_notifications.dart';
|
|
|
|
import 'package:fluffychat/views/settings_style.dart';
|
2020-11-14 08:54:26 +01:00
|
|
|
import 'package:flushbar/flushbar_helper.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-10-04 17:01:54 +02:00
|
|
|
import 'package:file_picker_cross/file_picker_cross.dart';
|
2020-12-19 13:06:31 +01:00
|
|
|
import 'package:fluffychat/utils/beautify_string_extension.dart';
|
2020-10-04 17:01:54 +02:00
|
|
|
|
2020-12-11 14:14:33 +01:00
|
|
|
import 'package:fluffychat/app_config.dart';
|
2020-10-04 17:01:54 +02:00
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2020-09-08 10:55:32 +02:00
|
|
|
import 'package:fluffychat/utils/sentry_controller.dart';
|
2020-02-19 16:23:13 +01:00
|
|
|
import 'package:fluffychat/views/settings_devices.dart';
|
2020-09-19 15:29:12 +02:00
|
|
|
import 'package:fluffychat/views/settings_ignore_list.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
import 'package:image_picker/image_picker.dart';
|
2020-01-04 09:40:38 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2020-01-01 19:10:13 +01:00
|
|
|
|
2020-02-23 08:49:58 +01:00
|
|
|
import '../components/adaptive_page_layout.dart';
|
2020-02-16 15:57:50 +01:00
|
|
|
import '../components/content_banner.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
import '../components/dialogs/simple_dialogs.dart';
|
2020-02-16 15:57:50 +01:00
|
|
|
import '../components/matrix.dart';
|
|
|
|
import '../utils/app_route.dart';
|
2020-12-11 14:14:33 +01:00
|
|
|
import '../app_config.dart';
|
2020-11-07 12:00:41 +01:00
|
|
|
import '../config/setting_keys.dart';
|
2020-10-03 13:11:07 +02:00
|
|
|
import 'chat_list.dart';
|
2020-05-12 09:02:33 +02:00
|
|
|
import 'settings_emotes.dart';
|
2020-02-16 15:57:50 +01:00
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
class SettingsView extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AdaptivePageLayout(
|
|
|
|
primaryPage: FocusPage.SECOND,
|
|
|
|
firstScaffold: ChatList(),
|
|
|
|
secondScaffold: Settings(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Settings extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_SettingsState createState() => _SettingsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingsState extends State<Settings> {
|
|
|
|
Future<dynamic> profileFuture;
|
|
|
|
dynamic profile;
|
2020-06-25 16:29:06 +02:00
|
|
|
Future<bool> crossSigningCachedFuture;
|
|
|
|
bool crossSigningCached;
|
|
|
|
Future<bool> megolmBackupCachedFuture;
|
|
|
|
bool megolmBackupCached;
|
2020-02-16 15:57:50 +01:00
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
void logoutAction(BuildContext context) async {
|
2020-11-14 10:08:13 +01:00
|
|
|
if (await showOkCancelAlertDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).areYouSure,
|
|
|
|
) ==
|
|
|
|
OkCancelResult.cancel) {
|
2020-02-16 09:56:17 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-05-13 15:58:59 +02:00
|
|
|
var matrix = Matrix.of(context);
|
2020-04-27 13:36:39 +02:00
|
|
|
await SimpleDialogs(context)
|
|
|
|
.tryRequestWithLoadingDialog(matrix.client.logout());
|
2020-01-01 19:10:13 +01:00
|
|
|
}
|
|
|
|
|
2020-09-21 17:50:01 +02:00
|
|
|
void _changePasswordAccountAction(BuildContext context) async {
|
2020-11-14 10:08:13 +01:00
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).changePassword,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
hintText: L10n.of(context).pleaseEnterYourPassword,
|
|
|
|
obscureText: true,
|
2020-12-10 15:06:02 +01:00
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
2020-11-14 10:08:13 +01:00
|
|
|
),
|
|
|
|
DialogTextField(
|
|
|
|
hintText: L10n.of(context).chooseAStrongPassword,
|
|
|
|
obscureText: true,
|
2020-12-10 15:06:02 +01:00
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
2020-11-14 10:08:13 +01:00
|
|
|
),
|
|
|
|
],
|
2020-09-21 17:50:01 +02:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input == null) return;
|
2020-09-21 17:50:01 +02:00
|
|
|
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
|
|
|
Matrix.of(context)
|
|
|
|
.client
|
2020-11-14 10:08:13 +01:00
|
|
|
.changePassword(input.last, oldPassword: input.first),
|
2020-09-21 17:50:01 +02:00
|
|
|
);
|
2020-11-14 08:54:26 +01:00
|
|
|
await FlushbarHelper.createSuccess(
|
|
|
|
message: L10n.of(context).passwordHasBeenChanged)
|
|
|
|
.show(context);
|
2020-09-21 17:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void _deleteAccountAction(BuildContext context) async {
|
2020-11-14 10:08:13 +01:00
|
|
|
if (await showOkCancelAlertDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).warning,
|
|
|
|
message: L10n.of(context).deactivateAccountWarning,
|
2020-09-21 17:50:01 +02:00
|
|
|
) ==
|
2020-11-14 10:08:13 +01:00
|
|
|
OkCancelResult.cancel) {
|
2020-09-21 17:50:01 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-11-14 10:08:13 +01:00
|
|
|
if (await showOkCancelAlertDialog(
|
|
|
|
context: context, title: L10n.of(context).areYouSure) ==
|
|
|
|
OkCancelResult.cancel) {
|
2020-09-21 17:50:01 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-11-14 10:08:13 +01:00
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).pleaseEnterYourPassword,
|
2020-12-10 15:06:02 +01:00
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
obscureText: true,
|
|
|
|
hintText: '******',
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
)
|
|
|
|
],
|
2020-09-21 17:50:01 +02:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input == null) return;
|
2020-09-21 17:50:01 +02:00
|
|
|
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-12-11 10:27:38 +01:00
|
|
|
Matrix.of(context).client.deactivateAccount(
|
|
|
|
auth: AuthenticationPassword(
|
|
|
|
password: input.single,
|
|
|
|
user: Matrix.of(context).client.userID,
|
|
|
|
identifier: AuthenticationUserIdentifier(
|
|
|
|
user: Matrix.of(context).client.userID),
|
|
|
|
),
|
|
|
|
),
|
2020-09-21 17:50:01 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-08 17:43:07 +02:00
|
|
|
void setJitsiInstanceAction(BuildContext context) async {
|
2020-11-23 14:27:10 +01:00
|
|
|
const prefix = 'https://';
|
2020-11-14 10:08:13 +01:00
|
|
|
var input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).editJitsiInstance,
|
|
|
|
textFields: [
|
2020-11-23 14:27:10 +01:00
|
|
|
DialogTextField(
|
2020-12-11 14:14:33 +01:00
|
|
|
initialText: AppConfig.jitsiInstance.replaceFirst(prefix, ''),
|
2020-11-23 14:27:10 +01:00
|
|
|
prefixText: prefix,
|
|
|
|
),
|
2020-11-14 10:08:13 +01:00
|
|
|
],
|
2020-04-08 17:43:07 +02:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input == null) return;
|
2020-11-23 14:27:10 +01:00
|
|
|
var jitsi = prefix + input.single;
|
2020-04-08 17:43:07 +02:00
|
|
|
if (!jitsi.endsWith('/')) {
|
|
|
|
jitsi += '/';
|
|
|
|
}
|
2020-05-13 15:58:59 +02:00
|
|
|
final matrix = Matrix.of(context);
|
2020-11-07 12:00:41 +01:00
|
|
|
await matrix.store.setItem(SettingKeys.jitsiInstance, jitsi);
|
2020-12-11 14:14:33 +01:00
|
|
|
AppConfig.jitsiInstance = jitsi;
|
2020-04-08 17:43:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-16 09:56:17 +01:00
|
|
|
void setDisplaynameAction(BuildContext context) async {
|
2020-11-14 10:08:13 +01:00
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).editDisplayname,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
initialText: profile?.displayname ??
|
|
|
|
Matrix.of(context).client.userID.localpart,
|
|
|
|
)
|
|
|
|
],
|
2020-02-16 09:56:17 +01:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input == null) return;
|
2020-05-13 15:58:59 +02:00
|
|
|
final matrix = Matrix.of(context);
|
2020-04-27 13:36:39 +02:00
|
|
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-11-14 10:08:13 +01:00
|
|
|
matrix.client.setDisplayname(matrix.client.userID, input.single),
|
2020-01-01 19:10:13 +01:00
|
|
|
);
|
2020-02-16 09:56:17 +01:00
|
|
|
if (success != false) {
|
2020-01-01 19:10:13 +01:00
|
|
|
setState(() {
|
|
|
|
profileFuture = null;
|
|
|
|
profile = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAvatarAction(BuildContext context) async {
|
2020-10-04 17:01:54 +02:00
|
|
|
MatrixFile file;
|
|
|
|
if (PlatformInfos.isMobile) {
|
|
|
|
final result = await ImagePicker().getImage(
|
|
|
|
source: ImageSource.gallery,
|
|
|
|
imageQuality: 50,
|
|
|
|
maxWidth: 1600,
|
|
|
|
maxHeight: 1600);
|
|
|
|
if (result == null) return;
|
|
|
|
file = MatrixFile(
|
|
|
|
bytes: await result.readAsBytes(),
|
|
|
|
name: result.path,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
final result =
|
|
|
|
await FilePickerCross.importFromStorage(type: FileTypeCross.image);
|
|
|
|
if (result == null) return;
|
|
|
|
file = MatrixFile(
|
|
|
|
bytes: result.toUint8List(),
|
|
|
|
name: result.fileName,
|
|
|
|
);
|
|
|
|
}
|
2020-05-13 15:58:59 +02:00
|
|
|
final matrix = Matrix.of(context);
|
2020-04-27 13:36:39 +02:00
|
|
|
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
2020-10-04 17:01:54 +02:00
|
|
|
matrix.client.setAvatar(file),
|
2020-01-01 19:10:13 +01:00
|
|
|
);
|
2020-01-04 09:40:38 +01:00
|
|
|
if (success != false) {
|
2020-01-01 19:10:13 +01:00
|
|
|
setState(() {
|
|
|
|
profileFuture = null;
|
|
|
|
profile = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 16:29:06 +02:00
|
|
|
Future<void> requestSSSSCache(BuildContext context) async {
|
|
|
|
final handle = Matrix.of(context).client.encryption.ssss.open();
|
2020-11-14 10:08:13 +01:00
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).askSSSSCache,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
2020-12-10 15:06:02 +01:00
|
|
|
hintText: L10n.of(context).passphraseOrKey,
|
|
|
|
obscureText: true,
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
)
|
2020-11-14 10:08:13 +01:00
|
|
|
],
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input != null) {
|
|
|
|
final valid = await SimpleDialogs(context)
|
|
|
|
.tryRequestWithLoadingDialog(Future.microtask(() async {
|
|
|
|
// make sure the loading spinner shows before we test the keys
|
|
|
|
await Future.delayed(Duration(milliseconds: 100));
|
|
|
|
var valid = false;
|
2020-06-25 16:29:06 +02:00
|
|
|
try {
|
2020-12-10 11:25:49 +01:00
|
|
|
await handle.unlock(recoveryKey: input.single);
|
2020-06-25 16:29:06 +02:00
|
|
|
valid = true;
|
2020-09-07 15:42:24 +02:00
|
|
|
} catch (e, s) {
|
2020-12-10 15:06:02 +01:00
|
|
|
SentryController.captureException(e, s);
|
2020-06-25 16:29:06 +02:00
|
|
|
}
|
2020-11-14 10:08:13 +01:00
|
|
|
return valid;
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (valid == true) {
|
2020-06-25 16:29:06 +02:00
|
|
|
await handle.maybeCacheAll();
|
2020-11-14 10:08:13 +01:00
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).cachedKeys,
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
crossSigningCachedFuture = null;
|
|
|
|
crossSigningCached = null;
|
|
|
|
megolmBackupCachedFuture = null;
|
|
|
|
megolmBackupCached = null;
|
|
|
|
});
|
|
|
|
} else {
|
2020-11-14 10:08:13 +01:00
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).incorrectPassphraseOrKey,
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-01 19:10:13 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-05-13 15:58:59 +02:00
|
|
|
final client = Matrix.of(context).client;
|
2020-06-25 16:29:06 +02:00
|
|
|
profileFuture ??= client.ownProfile.then((p) {
|
2020-01-08 14:19:15 +01:00
|
|
|
if (mounted) setState(() => profile = p);
|
2020-06-25 16:29:06 +02:00
|
|
|
return p;
|
|
|
|
});
|
|
|
|
crossSigningCachedFuture ??=
|
|
|
|
client.encryption.crossSigning.isCached().then((c) {
|
|
|
|
if (mounted) setState(() => crossSigningCached = c);
|
|
|
|
return c;
|
|
|
|
});
|
|
|
|
megolmBackupCachedFuture ??=
|
|
|
|
client.encryption.keyManager.isCached().then((c) {
|
|
|
|
if (mounted) setState(() => megolmBackupCached = c);
|
|
|
|
return c;
|
2020-01-08 14:19:15 +01:00
|
|
|
});
|
2020-01-01 19:10:13 +01:00
|
|
|
return Scaffold(
|
2020-02-16 10:42:59 +01:00
|
|
|
body: NestedScrollView(
|
|
|
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
|
|
|
|
<Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
expandedHeight: 300.0,
|
|
|
|
floating: true,
|
|
|
|
pinned: true,
|
|
|
|
backgroundColor: Theme.of(context).appBarTheme.color,
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
2020-02-16 20:11:39 +01:00
|
|
|
title: Text(
|
2020-05-07 07:52:40 +02:00
|
|
|
L10n.of(context).settings,
|
2020-02-16 20:11:39 +01:00
|
|
|
style: TextStyle(
|
2020-05-06 18:43:30 +02:00
|
|
|
color: Theme.of(context)
|
|
|
|
.appBarTheme
|
|
|
|
.textTheme
|
|
|
|
.headline6
|
|
|
|
.color),
|
2020-02-16 20:11:39 +01:00
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
background: ContentBanner(
|
2020-04-28 14:11:56 +02:00
|
|
|
profile?.avatarUrl,
|
2020-02-16 10:42:59 +01:00
|
|
|
height: 300,
|
2020-12-06 10:31:35 +01:00
|
|
|
defaultIcon: Icons.account_circle_outlined,
|
2020-02-16 10:42:59 +01:00
|
|
|
loading: profile == null,
|
|
|
|
onEdit: () => setAvatarAction(context),
|
2020-01-01 19:10:13 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
],
|
|
|
|
body: ListView(
|
|
|
|
children: <Widget>[
|
2020-02-23 08:49:58 +01:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
2020-11-25 20:39:54 +01:00
|
|
|
L10n.of(context).notifications,
|
2020-02-23 08:49:58 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-11-25 20:39:54 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.notifications_outlined),
|
2020-11-25 20:39:54 +01:00
|
|
|
title: Text(L10n.of(context).notifications),
|
|
|
|
onTap: () async => await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
SettingsNotificationsView(),
|
2020-04-03 20:24:25 +02:00
|
|
|
),
|
|
|
|
),
|
2020-11-25 20:39:54 +01:00
|
|
|
),
|
2020-05-09 13:36:41 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).chat,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
2020-11-25 20:39:54 +01:00
|
|
|
title: Text(L10n.of(context).changeTheme),
|
|
|
|
onTap: () async => await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
SettingsStyleView(),
|
|
|
|
),
|
2020-11-07 12:00:41 +01:00
|
|
|
),
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.style_outlined),
|
2020-11-07 12:00:41 +01:00
|
|
|
),
|
2020-11-25 20:39:54 +01:00
|
|
|
SwitchListTile(
|
|
|
|
title: Text(L10n.of(context).renderRichContent),
|
|
|
|
value: AppConfig.renderHtml,
|
|
|
|
onChanged: (bool newValue) async {
|
|
|
|
AppConfig.renderHtml = newValue;
|
|
|
|
await Matrix.of(context)
|
|
|
|
.store
|
|
|
|
.setItem(SettingKeys.renderHtml, newValue.toString());
|
|
|
|
setState(() => null);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SwitchListTile(
|
2020-11-07 12:00:41 +01:00
|
|
|
title: Text(L10n.of(context).hideRedactedEvents),
|
2020-11-25 20:39:54 +01:00
|
|
|
value: AppConfig.hideRedactedEvents,
|
|
|
|
onChanged: (bool newValue) async {
|
|
|
|
AppConfig.hideRedactedEvents = newValue;
|
|
|
|
await Matrix.of(context).store.setItem(
|
|
|
|
SettingKeys.hideRedactedEvents, newValue.toString());
|
|
|
|
setState(() => null);
|
|
|
|
},
|
2020-11-07 12:00:41 +01:00
|
|
|
),
|
2020-11-25 20:39:54 +01:00
|
|
|
SwitchListTile(
|
2020-11-07 12:00:41 +01:00
|
|
|
title: Text(L10n.of(context).hideUnknownEvents),
|
2020-11-25 20:39:54 +01:00
|
|
|
value: AppConfig.hideUnknownEvents,
|
|
|
|
onChanged: (bool newValue) async {
|
|
|
|
AppConfig.hideUnknownEvents = newValue;
|
|
|
|
await Matrix.of(context).store.setItem(
|
|
|
|
SettingKeys.hideUnknownEvents, newValue.toString());
|
|
|
|
setState(() => null);
|
|
|
|
},
|
2020-05-09 13:36:41 +02:00
|
|
|
),
|
2020-05-12 09:02:33 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).emoteSettings),
|
|
|
|
onTap: () async => await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
EmotesSettingsView(),
|
|
|
|
),
|
|
|
|
),
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.insert_emoticon_outlined),
|
2020-05-12 09:02:33 +02:00
|
|
|
),
|
2020-05-09 13:36:41 +02:00
|
|
|
Divider(thickness: 1),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
2020-05-07 07:52:40 +02:00
|
|
|
L10n.of(context).account,
|
2020-02-16 10:42:59 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2020-01-04 09:40:38 +01:00
|
|
|
),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.edit_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).editDisplayname),
|
2020-02-16 10:42:59 +01:00
|
|
|
subtitle: Text(profile?.displayname ?? client.userID.localpart),
|
|
|
|
onTap: () => setDisplaynameAction(context),
|
2020-02-15 09:20:08 +01:00
|
|
|
),
|
2020-04-08 17:43:07 +02:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.phone_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).editJitsiInstance),
|
2020-12-11 14:14:33 +01:00
|
|
|
subtitle: Text(AppConfig.jitsiInstance),
|
2020-04-08 17:43:07 +02:00
|
|
|
onTap: () => setJitsiInstanceAction(context),
|
|
|
|
),
|
2020-02-16 15:57:50 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.devices_other_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).devices),
|
2020-02-16 15:57:50 +01:00
|
|
|
onTap: () async => await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
2020-02-23 08:49:58 +01:00
|
|
|
DevicesSettingsView(),
|
2020-02-16 15:57:50 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-09-19 15:29:12 +02:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.block_outlined),
|
2020-09-19 15:29:12 +02:00
|
|
|
title: Text(L10n.of(context).ignoredUsers),
|
|
|
|
onTap: () async => await Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
SettingsIgnoreListView(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-09-08 10:55:32 +02:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.bug_report_outlined),
|
2020-09-08 10:55:32 +02:00
|
|
|
title: Text(L10n.of(context).sendBugReports),
|
|
|
|
onTap: () => SentryController.toggleSentryAction(context),
|
|
|
|
),
|
2020-09-21 17:50:01 +02:00
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
2020-12-19 13:06:31 +01:00
|
|
|
trailing: Icon(Icons.security_outlined),
|
2020-09-21 17:50:01 +02:00
|
|
|
title: Text(
|
2020-11-14 10:08:13 +01:00
|
|
|
L10n.of(context).changePassword,
|
2020-09-21 17:50:01 +02:00
|
|
|
),
|
|
|
|
onTap: () => _changePasswordAccountAction(context),
|
|
|
|
),
|
2020-11-24 14:27:07 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.email_outlined),
|
2020-11-24 14:27:07 +01:00
|
|
|
title: Text(L10n.of(context).passwordRecovery),
|
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
context,
|
|
|
|
Settings3PidView(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.exit_to_app_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).logout),
|
2020-02-16 10:42:59 +01:00
|
|
|
onTap: () => logoutAction(context),
|
|
|
|
),
|
2020-09-21 17:50:01 +02:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.delete_forever_outlined),
|
2020-09-21 17:50:01 +02:00
|
|
|
title: Text(
|
|
|
|
L10n.of(context).deleteAccount,
|
|
|
|
style: TextStyle(color: Colors.red),
|
|
|
|
),
|
|
|
|
onTap: () => _deleteAccountAction(context),
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
Divider(thickness: 1),
|
2020-06-25 16:29:06 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).encryption,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.compare_arrows_outlined),
|
2020-06-25 16:29:06 +02:00
|
|
|
title: Text(client.encryption.crossSigning.enabled
|
|
|
|
? L10n.of(context).crossSigningEnabled
|
|
|
|
: L10n.of(context).crossSigningDisabled),
|
|
|
|
subtitle: client.encryption.crossSigning.enabled
|
|
|
|
? Text(client.isUnknownSession
|
|
|
|
? L10n.of(context).unknownSessionVerify
|
|
|
|
: L10n.of(context).sessionVerified +
|
|
|
|
', ' +
|
|
|
|
(crossSigningCached == null
|
|
|
|
? '⌛'
|
|
|
|
: (crossSigningCached
|
|
|
|
? L10n.of(context).keysCached
|
|
|
|
: L10n.of(context).keysMissing)))
|
|
|
|
: null,
|
|
|
|
onTap: () async {
|
|
|
|
if (!client.encryption.crossSigning.enabled) {
|
2020-12-10 15:06:02 +01:00
|
|
|
return BootstrapDialog().show(context);
|
2020-06-25 16:29:06 +02:00
|
|
|
}
|
|
|
|
if (client.isUnknownSession) {
|
2020-11-14 10:08:13 +01:00
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).askSSSSVerify,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
2020-12-10 15:06:02 +01:00
|
|
|
hintText: L10n.of(context).passphraseOrKey,
|
|
|
|
obscureText: true,
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
)
|
2020-11-14 10:08:13 +01:00
|
|
|
],
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
2020-11-14 10:08:13 +01:00
|
|
|
if (input != null) {
|
|
|
|
final valid = await SimpleDialogs(context)
|
|
|
|
.tryRequestWithLoadingDialog(Future.microtask(() async {
|
|
|
|
// make sure the loading spinner shows before we test the keys
|
|
|
|
await Future.delayed(Duration(milliseconds: 100));
|
|
|
|
var valid = false;
|
2020-06-25 16:29:06 +02:00
|
|
|
try {
|
|
|
|
await client.encryption.crossSigning
|
2020-11-14 10:08:13 +01:00
|
|
|
.selfSign(recoveryKey: input.single);
|
2020-06-25 16:29:06 +02:00
|
|
|
valid = true;
|
|
|
|
} catch (_) {
|
2020-11-14 10:08:13 +01:00
|
|
|
try {
|
|
|
|
await client.encryption.crossSigning
|
|
|
|
.selfSign(passphrase: input.single);
|
|
|
|
valid = true;
|
|
|
|
} catch (_) {
|
|
|
|
valid = false;
|
|
|
|
}
|
2020-06-25 16:29:06 +02:00
|
|
|
}
|
2020-11-14 10:08:13 +01:00
|
|
|
return valid;
|
|
|
|
}));
|
|
|
|
|
|
|
|
if (valid == true) {
|
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).verifiedSession,
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
crossSigningCachedFuture = null;
|
|
|
|
crossSigningCached = null;
|
|
|
|
megolmBackupCachedFuture = null;
|
|
|
|
megolmBackupCached = null;
|
|
|
|
});
|
|
|
|
} else {
|
2020-11-14 10:08:13 +01:00
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).incorrectPassphraseOrKey,
|
2020-06-25 16:29:06 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(await client.encryption.crossSigning.isCached())) {
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.wb_cloudy_outlined),
|
2020-06-25 16:29:06 +02:00
|
|
|
title: Text(client.encryption.keyManager.enabled
|
|
|
|
? L10n.of(context).onlineKeyBackupEnabled
|
|
|
|
: L10n.of(context).onlineKeyBackupDisabled),
|
|
|
|
subtitle: client.encryption.keyManager.enabled
|
|
|
|
? Text(megolmBackupCached == null
|
|
|
|
? '⌛'
|
|
|
|
: (megolmBackupCached
|
|
|
|
? L10n.of(context).keysCached
|
|
|
|
: L10n.of(context).keysMissing))
|
|
|
|
: null,
|
|
|
|
onTap: () async {
|
|
|
|
if (!client.encryption.keyManager.enabled) {
|
2020-12-10 15:06:02 +01:00
|
|
|
return BootstrapDialog().show(context);
|
2020-06-25 16:29:06 +02:00
|
|
|
}
|
|
|
|
if (!(await client.encryption.keyManager.isCached())) {
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2020-12-19 13:06:31 +01:00
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).yourPublicKey),
|
|
|
|
onTap: () => showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).yourPublicKey,
|
|
|
|
message: client.fingerprintKey.beautified,
|
|
|
|
),
|
|
|
|
trailing: Icon(Icons.vpn_key_outlined),
|
|
|
|
),
|
2020-06-25 16:29:06 +02:00
|
|
|
Divider(thickness: 1),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
2020-05-07 07:52:40 +02:00
|
|
|
L10n.of(context).about,
|
2020-02-16 10:42:59 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2020-02-16 09:56:17 +01:00
|
|
|
),
|
2020-12-19 13:06:31 +01:00
|
|
|
onTap: () => Navigator.of(context).push(
|
2020-12-22 14:23:23 +01:00
|
|
|
AppRoute.defaultRoute(context, LogViewer()),
|
2020-12-19 13:06:31 +01:00
|
|
|
),
|
2020-02-16 09:56:17 +01:00
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.help_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).help),
|
2020-10-03 11:11:28 +02:00
|
|
|
onTap: () => launch(AppConfig.supportUrl),
|
|
|
|
),
|
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.privacy_tip_outlined),
|
2020-10-03 11:11:28 +02:00
|
|
|
title: Text(L10n.of(context).privacy),
|
|
|
|
onTap: () => launch(AppConfig.privacyUrl),
|
2020-02-16 10:42:59 +01:00
|
|
|
),
|
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.link_outlined),
|
2020-05-07 07:52:40 +02:00
|
|
|
title: Text(L10n.of(context).license),
|
2020-09-18 12:58:22 +02:00
|
|
|
onTap: () => showLicensePage(
|
|
|
|
context: context,
|
|
|
|
applicationIcon:
|
|
|
|
Image.asset('assets/logo.png', width: 100, height: 100),
|
|
|
|
applicationName: AppConfig.applicationName,
|
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
),
|
2020-10-02 11:24:19 +02:00
|
|
|
ListTile(
|
2020-12-06 10:31:35 +01:00
|
|
|
trailing: Icon(Icons.code_outlined),
|
2020-10-02 11:24:19 +02:00
|
|
|
title: Text(L10n.of(context).sourceCode),
|
2020-10-03 11:11:28 +02:00
|
|
|
onTap: () => launch(AppConfig.sourceCodeUrl),
|
2020-10-02 11:24:19 +02:00
|
|
|
),
|
2020-02-16 10:42:59 +01:00
|
|
|
],
|
|
|
|
),
|
2020-01-01 19:10:13 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|