Merge pull request 'Autohide messages from blocked contacts' (#117) from bugfix into trunk

Reviewed-on: cwtch.im/cwtch-ui#117
Reviewed-by: erinn <erinn@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2021-07-14 13:48:02 -07:00
commit 464edf9aed
10 changed files with 83 additions and 16 deletions

View File

@ -1,6 +1,8 @@
{
"@@locale": "de",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -1,6 +1,8 @@
{
"@@locale": "en",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -1,6 +1,8 @@
{
"@@locale": "es",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -1,7 +1,9 @@
{
"@@locale": "fr",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"placeholderEnterMessage": "Type a message...",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "saisissez un message",
"plainProfileDescription": "Nous vous recommandons de protéger vos profils Cwtch par un mot de passe. Si vous ne définissez pas de mot de passe sur ce profil, toute personne ayant accès à cet appareil peut être en mesure d'accéder aux informations relatives à ce profil, y compris les contacts, les messages et les clés de chiffrement sensibles.",
"encryptedProfileDescription": "Le chiffrement d'un profil à l'aide d'un mot de passe le protège des autres personnes susceptibles d'utiliser également cet appareil. Les profils chiffrés ne peuvent pas être déchiffrés , affichés ou accessibles tant que le mot de passe correct n'a pas été saisi pour les déverrouiller.",
"addContactConfirm": "Ajouter le contact %1",

View File

@ -1,6 +1,8 @@
{
"@@locale": "it",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -1,6 +1,8 @@
{
"@@locale": "pl",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -1,6 +1,8 @@
{
"@@locale": "pt",
"@@last_modified": "2021-07-14T21:46:10+02:00",
"@@last_modified": "2021-07-14T22:29:25+02:00",
"showMessageButton": "Show Message",
"blockedMessageMessage": "This message is from a profile you have blocked.",
"placeholderEnterMessage": "Type a message...",
"plainProfileDescription": "We recommend that you protect your Cwtch profiles with a password. If you do not set a password on this profile then anyone who has access to this device may be able to access information about this profile, including contacts, messages and sensitive cryptographic keys.",
"encryptedProfileDescription": "Encrypting a profile with a password protects it from other people who may also use this device. Encrypted profiles cannot be decrypted, displayed or accessed until the correct password is entered to unlock them.",

View File

@ -25,6 +25,7 @@ class InviteMessage extends Message {
String inviteTarget;
String inviteNick;
String invite = this.content;
if (this.content.length == TorV3ContactHandleLength) {
inviteTarget = this.content;
@ -40,7 +41,7 @@ class InviteMessage extends Message {
return MessageRow(MalformedBubble());
}
}
return MessageRow(InvitationBubble(overlay, inviteTarget, inviteNick), key: Provider.of<ContactInfoState>(bcontext).getMessageKey(idx));
return MessageRow(InvitationBubble(overlay, inviteTarget, inviteNick, invite), key: Provider.of<ContactInfoState>(bcontext).getMessageKey(idx));
});
}
@ -51,7 +52,7 @@ class InviteMessage extends Message {
builder: (bcontext, child) {
String inviteTarget;
String inviteNick;
String invite = this.content;
if (this.content.length == TorV3ContactHandleLength) {
inviteTarget = this.content;
var targetContact = Provider.of<ProfileInfoState>(context).contactList.getContact(inviteTarget);
@ -66,7 +67,7 @@ class InviteMessage extends Message {
return MalformedBubble();
}
}
return InvitationBubble(overlay, inviteTarget, inviteNick);
return InvitationBubble(overlay, inviteTarget, inviteNick, invite);
});
}

View File

@ -19,8 +19,9 @@ class InvitationBubble extends StatefulWidget {
final int overlay;
final String inviteTarget;
final String inviteNick;
final String invite;
InvitationBubble(this.overlay, this.inviteTarget, this.inviteNick);
InvitationBubble(this.overlay, this.inviteTarget, this.inviteNick, this.invite);
@override
InvitationBubbleState createState() => InvitationBubbleState();
@ -136,7 +137,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
void _btnAccept() {
setState(() {
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, widget.inviteTarget);
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, widget.invite);
isAccepted = true;
});
}

View File

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/message.dart';
import 'package:cwtch/views/contactsview.dart';
import 'package:flutter/material.dart';
@ -21,11 +22,13 @@ class MessageRow extends StatefulWidget {
class MessageRowState extends State<MessageRow> {
bool showMenu = false;
bool showBlockedMessage = false;
@override
Widget build(BuildContext context) {
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
var isContact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle) != null;
var isBlocked = isContact ? Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle)!.isBlocked : false;
var actualMessage = Flexible(flex: 3, fit: FlexFit.loose, child: widget.child);
var senderDisplayStr = "";
if (!fromMe) {
@ -53,7 +56,55 @@ class MessageRowState extends State<MessageRow> {
widgetRow = <Widget>[
wdgSpacer,
wdgIcons,
Flexible(flex: 3, fit: FlexFit.loose, child: widget.child),
actualMessage,
];
} else if (isBlocked && !showBlockedMessage) {
Color blockedMessageBackground = Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor();
Widget wdgPortrait = Padding(padding: EdgeInsets.all(4.0), child: Icon(CwtchIcons.account_blocked));
widgetRow = <Widget>[
wdgPortrait,
Container(
padding: EdgeInsets.all(2.0),
decoration: BoxDecoration(
color: blockedMessageBackground,
border: Border.all(color: blockedMessageBackground, width: 2),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15.0),
topRight: Radius.circular(15.0),
bottomLeft: Radius.circular(15.0),
bottomRight: Radius.circular(15.0),
)),
child: Padding(
padding: EdgeInsets.all(9.0),
child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
SelectableText(
AppLocalizations.of(context)!.blockedMessageMessage,
//key: Key(myKey),
style: TextStyle(
color: Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
),
textAlign: TextAlign.center,
textWidthBasis: TextWidthBasis.longestLine,
),
Padding(
padding: EdgeInsets.all(1.0),
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(blockedMessageBackground),
overlayColor: MaterialStateProperty.all(blockedMessageBackground),
),
child: Text(
AppLocalizations.of(context)!.showMessageButton + '\u202F',
style: TextStyle(decoration: TextDecoration.underline),
),
onPressed: () {
setState(() {
this.showBlockedMessage = true;
});
})),
]))),
wdgIcons,
wdgSpacer,
];
} else {
var contact = Provider.of<ContactInfoState>(context);
@ -72,7 +123,7 @@ class MessageRowState extends State<MessageRow> {
widgetRow = <Widget>[
wdgPortrait,
Flexible(flex: 3, fit: FlexFit.loose, child: widget.child),
actualMessage,
wdgIcons,
wdgSpacer,
];