feat: Pick share keys with
This commit is contained in:
parent
5f439a6b58
commit
9f9f52fa02
7 changed files with 67 additions and 7 deletions
|
|
@ -34,4 +34,5 @@ abstract class SettingKeys {
|
||||||
'chat.fluffy.display_chat_details_column';
|
'chat.fluffy.display_chat_details_column';
|
||||||
static const String noEncryptionWarningShown =
|
static const String noEncryptionWarningShown =
|
||||||
'chat.fluffy.no_encryption_warning_shown';
|
'chat.fluffy.no_encryption_warning_shown';
|
||||||
|
static const String shareKeysWith = 'chat.fluffy.share_keys_with';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
|
@ -108,6 +109,16 @@ class SettingsSecurityController extends State<SettingsSecurity> {
|
||||||
|
|
||||||
Future<void> dehydrateAction() => Matrix.of(context).dehydrateAction(context);
|
Future<void> dehydrateAction() => Matrix.of(context).dehydrateAction(context);
|
||||||
|
|
||||||
|
void changeShareKeysWith(ShareKeysWith? shareKeysWith) async {
|
||||||
|
if (shareKeysWith == null) return;
|
||||||
|
Matrix.of(context).store.setString(
|
||||||
|
SettingKeys.shareKeysWith,
|
||||||
|
shareKeysWith.name,
|
||||||
|
);
|
||||||
|
Matrix.of(context).client.shareKeysWith = shareKeysWith;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SettingsSecurityView(this);
|
Widget build(BuildContext context) => SettingsSecurityView(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
|
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
|
||||||
|
import 'package:matrix/matrix.dart';
|
||||||
import 'settings_security.dart';
|
import 'settings_security.dart';
|
||||||
|
|
||||||
class SettingsSecurityView extends StatelessWidget {
|
class SettingsSecurityView extends StatelessWidget {
|
||||||
|
|
@ -88,6 +89,43 @@ class SettingsSecurityView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
Divider(color: theme.dividerColor),
|
Divider(color: theme.dividerColor),
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Share keys with',
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.secondary,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Which devices should be trusted so that they can read along your messages in encrypted chats?',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Material(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(AppConfig.borderRadius / 2),
|
||||||
|
color: theme.colorScheme.onInverseSurface,
|
||||||
|
child: DropdownButton<ShareKeysWith>(
|
||||||
|
isExpanded: true,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(AppConfig.borderRadius / 2),
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
value: Matrix.of(context).client.shareKeysWith,
|
||||||
|
items: ShareKeysWith.values
|
||||||
|
.map(
|
||||||
|
(share) => DropdownMenuItem(
|
||||||
|
value: share,
|
||||||
|
child: Text(share.name),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
onChanged: controller.changeShareKeysWith,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(color: theme.dividerColor),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
L10n.of(context).account,
|
L10n.of(context).account,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||||
|
|
@ -43,7 +45,8 @@ abstract class ClientManager {
|
||||||
clientNames.add(PlatformInfos.clientName);
|
clientNames.add(PlatformInfos.clientName);
|
||||||
await store.setStringList(clientNamespace, clientNames.toList());
|
await store.setStringList(clientNamespace, clientNames.toList());
|
||||||
}
|
}
|
||||||
final clients = clientNames.map(createClient).toList();
|
final clients =
|
||||||
|
clientNames.map((name) => createClient(name, store)).toList();
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
await Future.wait(
|
await Future.wait(
|
||||||
clients.map(
|
clients.map(
|
||||||
|
|
@ -97,7 +100,9 @@ abstract class ClientManager {
|
||||||
? const NativeImplementationsDummy()
|
? const NativeImplementationsDummy()
|
||||||
: NativeImplementationsIsolate(compute);
|
: NativeImplementationsIsolate(compute);
|
||||||
|
|
||||||
static Client createClient(String clientName) {
|
static Client createClient(String clientName, SharedPreferences store) {
|
||||||
|
final shareKeysWith = store.getString(SettingKeys.shareKeysWith) ?? 'all';
|
||||||
|
|
||||||
return Client(
|
return Client(
|
||||||
clientName,
|
clientName,
|
||||||
httpClient:
|
httpClient:
|
||||||
|
|
@ -122,6 +127,9 @@ abstract class ClientManager {
|
||||||
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
customImageResizer: PlatformInfos.isMobile ? customImageResizer : null,
|
||||||
defaultNetworkRequestTimeout: const Duration(minutes: 30),
|
defaultNetworkRequestTimeout: const Duration(minutes: 30),
|
||||||
enableDehydratedDevices: true,
|
enableDehydratedDevices: true,
|
||||||
|
shareKeysWith: ShareKeysWith.values
|
||||||
|
.singleWhereOrNull((share) => share.name == shareKeysWith) ??
|
||||||
|
ShareKeysWith.all,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
}
|
}
|
||||||
final candidate = _loginClientCandidate ??= ClientManager.createClient(
|
final candidate = _loginClientCandidate ??= ClientManager.createClient(
|
||||||
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}',
|
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
store,
|
||||||
)..onLoginStateChanged
|
)..onLoginStateChanged
|
||||||
.stream
|
.stream
|
||||||
.where((l) => l == LoginState.loggedIn)
|
.where((l) => l == LoginState.loggedIn)
|
||||||
|
|
|
||||||
|
|
@ -1125,10 +1125,9 @@ packages:
|
||||||
matrix:
|
matrix:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: matrix
|
path: "../matrix-dart-sdk"
|
||||||
sha256: "519e1d18623f741de5aa984a9d04cf3f660149d1e167fa06e17ddec8cec5f52d"
|
relative: true
|
||||||
url: "https://pub.dev"
|
source: path
|
||||||
source: hosted
|
|
||||||
version: "0.37.0"
|
version: "0.37.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
|
|
|
||||||
|
|
@ -153,3 +153,5 @@ msix_config:
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
win32: 5.5.3
|
win32: 5.5.3
|
||||||
|
matrix:
|
||||||
|
path: ../matrix-dart-sdk/
|
||||||
Loading…
Add table
Add a link
Reference in a new issue