|
|
|
@ -260,21 +260,24 @@ class _SettingsState extends State<Settings> {
|
|
|
|
if (mounted) setState(() => profile = p);
|
|
|
|
if (mounted) setState(() => profile = p);
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
crossSigningCachedFuture ??=
|
|
|
|
if (client.encryption != null) {
|
|
|
|
client.encryption.crossSigning.isCached().then((c) {
|
|
|
|
crossSigningCachedFuture ??=
|
|
|
|
if (mounted) setState(() => crossSigningCached = c);
|
|
|
|
client.encryption.crossSigning.isCached().then((c) {
|
|
|
|
return c;
|
|
|
|
if (mounted) setState(() => crossSigningCached = c);
|
|
|
|
});
|
|
|
|
return c;
|
|
|
|
megolmBackupCachedFuture ??=
|
|
|
|
});
|
|
|
|
client.encryption.keyManager.isCached().then((c) {
|
|
|
|
megolmBackupCachedFuture ??=
|
|
|
|
if (mounted) setState(() => megolmBackupCached = c);
|
|
|
|
client.encryption.keyManager.isCached().then((c) {
|
|
|
|
return c;
|
|
|
|
if (mounted) setState(() => megolmBackupCached = c);
|
|
|
|
});
|
|
|
|
return c;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
body: NestedScrollView(
|
|
|
|
body: NestedScrollView(
|
|
|
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
|
|
|
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) =>
|
|
|
|
<Widget>[
|
|
|
|
<Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
SliverAppBar(
|
|
|
|
|
|
|
|
leading: BackButton(),
|
|
|
|
expandedHeight: 300.0,
|
|
|
|
expandedHeight: 300.0,
|
|
|
|
floating: true,
|
|
|
|
floating: true,
|
|
|
|
pinned: true,
|
|
|
|
pinned: true,
|
|
|
|
@ -434,126 +437,128 @@ class _SettingsState extends State<Settings> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () => _deleteAccountAction(context),
|
|
|
|
onTap: () => _deleteAccountAction(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Divider(thickness: 1),
|
|
|
|
if (client.encryption != null) ...{
|
|
|
|
ListTile(
|
|
|
|
Divider(thickness: 1),
|
|
|
|
title: Text(
|
|
|
|
ListTile(
|
|
|
|
L10n.of(context).encryption,
|
|
|
|
title: Text(
|
|
|
|
style: TextStyle(
|
|
|
|
L10n.of(context).encryption,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
ListTile(
|
|
|
|
trailing: Icon(Icons.compare_arrows_outlined),
|
|
|
|
trailing: Icon(Icons.compare_arrows_outlined),
|
|
|
|
title: Text(client.encryption.crossSigning.enabled
|
|
|
|
title: Text(client.encryption.crossSigning.enabled
|
|
|
|
? L10n.of(context).crossSigningEnabled
|
|
|
|
? L10n.of(context).crossSigningEnabled
|
|
|
|
: L10n.of(context).crossSigningDisabled),
|
|
|
|
: L10n.of(context).crossSigningDisabled),
|
|
|
|
subtitle: client.encryption.crossSigning.enabled
|
|
|
|
subtitle: client.encryption.crossSigning.enabled
|
|
|
|
? Text(client.isUnknownSession
|
|
|
|
? Text(client.isUnknownSession
|
|
|
|
? L10n.of(context).unknownSessionVerify
|
|
|
|
? L10n.of(context).unknownSessionVerify
|
|
|
|
: L10n.of(context).sessionVerified +
|
|
|
|
: L10n.of(context).sessionVerified +
|
|
|
|
', ' +
|
|
|
|
', ' +
|
|
|
|
(crossSigningCached == null
|
|
|
|
(crossSigningCached == null
|
|
|
|
? '⌛'
|
|
|
|
? '⌛'
|
|
|
|
: (crossSigningCached
|
|
|
|
: (crossSigningCached
|
|
|
|
? L10n.of(context).keysCached
|
|
|
|
? L10n.of(context).keysCached
|
|
|
|
: L10n.of(context).keysMissing)))
|
|
|
|
: L10n.of(context).keysMissing)))
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
if (!client.encryption.crossSigning.enabled) {
|
|
|
|
if (!client.encryption.crossSigning.enabled) {
|
|
|
|
return BootstrapDialog().show(context);
|
|
|
|
return BootstrapDialog().show(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (client.isUnknownSession) {
|
|
|
|
if (client.isUnknownSession) {
|
|
|
|
final input = await showTextInputDialog(
|
|
|
|
final input = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context).askSSSSVerify,
|
|
|
|
title: L10n.of(context).askSSSSVerify,
|
|
|
|
textFields: [
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
DialogTextField(
|
|
|
|
hintText: L10n.of(context).passphraseOrKey,
|
|
|
|
hintText: L10n.of(context).passphraseOrKey,
|
|
|
|
obscureText: true,
|
|
|
|
obscureText: true,
|
|
|
|
minLines: 1,
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (input != null) {
|
|
|
|
if (input != null) {
|
|
|
|
final valid = await showFutureLoadingDialog(
|
|
|
|
final valid = await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
future: () async {
|
|
|
|
future: () async {
|
|
|
|
// make sure the loading spinner shows before we test the keys
|
|
|
|
// make sure the loading spinner shows before we test the keys
|
|
|
|
await Future.delayed(Duration(milliseconds: 100));
|
|
|
|
await Future.delayed(Duration(milliseconds: 100));
|
|
|
|
var valid = false;
|
|
|
|
var valid = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await client.encryption.crossSigning
|
|
|
|
|
|
|
|
.selfSign(recoveryKey: input.single);
|
|
|
|
|
|
|
|
valid = true;
|
|
|
|
|
|
|
|
} catch (_) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await client.encryption.crossSigning
|
|
|
|
await client.encryption.crossSigning
|
|
|
|
.selfSign(passphrase: input.single);
|
|
|
|
.selfSign(recoveryKey: input.single);
|
|
|
|
valid = true;
|
|
|
|
valid = true;
|
|
|
|
} catch (_) {
|
|
|
|
} catch (_) {
|
|
|
|
valid = false;
|
|
|
|
try {
|
|
|
|
|
|
|
|
await client.encryption.crossSigning
|
|
|
|
|
|
|
|
.selfSign(passphrase: input.single);
|
|
|
|
|
|
|
|
valid = true;
|
|
|
|
|
|
|
|
} catch (_) {
|
|
|
|
|
|
|
|
valid = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return valid;
|
|
|
|
return valid;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (valid.result == true) {
|
|
|
|
if (valid.result == true) {
|
|
|
|
await showOkAlertDialog(
|
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).verifiedSession,
|
|
|
|
message: L10n.of(context).verifiedSession,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
crossSigningCachedFuture = null;
|
|
|
|
crossSigningCachedFuture = null;
|
|
|
|
crossSigningCached = null;
|
|
|
|
crossSigningCached = null;
|
|
|
|
megolmBackupCachedFuture = null;
|
|
|
|
megolmBackupCachedFuture = null;
|
|
|
|
megolmBackupCached = null;
|
|
|
|
megolmBackupCached = null;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
await showOkAlertDialog(
|
|
|
|
await showOkAlertDialog(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
message: L10n.of(context).incorrectPassphraseOrKey,
|
|
|
|
message: L10n.of(context).incorrectPassphraseOrKey,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(await client.encryption.crossSigning.isCached())) {
|
|
|
|
if (!(await client.encryption.crossSigning.isCached())) {
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
|
|
trailing: Icon(Icons.wb_cloudy_outlined),
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
return BootstrapDialog().show(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(await client.encryption.keyManager.isCached())) {
|
|
|
|
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
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),
|
|
|
|
ListTile(
|
|
|
|
),
|
|
|
|
trailing: Icon(Icons.wb_cloudy_outlined),
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
return BootstrapDialog().show(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(await client.encryption.keyManager.isCached())) {
|
|
|
|
|
|
|
|
await requestSSSSCache(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
},
|
|
|
|
Divider(thickness: 1),
|
|
|
|
Divider(thickness: 1),
|
|
|
|
ListTile(
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
title: Text(
|
|
|
|
|