Merge pull request 'Streamer Mode Date Redaction / Format Fixes / A Few More Font Fixes' (#732) from stable-blockers into trunk
continuous-integration/drone/push Build is pending Details

Reviewed-on: #732
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2023-09-25 18:19:53 +00:00
commit ae9301c8d0
28 changed files with 207 additions and 41 deletions

View File

@ -1,6 +1,12 @@
{
"@@locale": "cy",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "da",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "de",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "el",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "en",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "es",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "fr",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "it",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "ja",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "ko",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "lb",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "nl",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "no",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "pl",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "pt",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "pt_BR",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "ro",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "ru",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "sk",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "sv",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "sw",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "tr",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

View File

@ -1,6 +1,12 @@
{
"@@locale": "uk",
"@@last_modified": "2023-09-20T21:00:37+02:00",
"@@last_modified": "2023-09-25T19:25:43+02:00",
"now": "Now",
"xSecondsAgo": "$seconds seconds ago",
"xMinutesAgo": "$minutes minutes ago",
"xHoursAgo": "$hours hours ago",
"xDaysAgo": "$days days ago",
"profileOfflineAtStart": "Appear Online at Startup",
"profileAllowUnknownContacts": "Allow Unknown Contacts",
"profileBlockUnknownContacts": "Block Unknown Contacts",
"profileDisableProfile": "Disable Profile",

32
lib/models/redaction.dart Normal file
View File

@ -0,0 +1,32 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../settings.dart';
import 'package:intl/intl.dart';
String prettyDateString(BuildContext context, DateTime date) {
var settings = Provider.of<Settings>(context, listen: false);
if (settings.streamerMode) {
var now = DateTime.now();
if (date.millisecondsSinceEpoch == 0) {
return AppLocalizations.of(context)!.conversationNotificationPolicyNever;
}
if (now.difference(date).abs().inDays > 1) {
return AppLocalizations.of(context)!.xDaysAgo.replaceAll("\$days", now.difference(date).abs().inDays.toString());
}
if (now.difference(date).abs().inHours > 1) {
return AppLocalizations.of(context)!.xHoursAgo.replaceAll("\$hours", now.difference(date).abs().inHours.toString());
}
if (now.difference(date).abs().inMinutes > 1) {
return AppLocalizations.of(context)!.xMinutesAgo.replaceAll("\$minutes", now.difference(date).abs().inMinutes.toString());
}
// This updates too frequently and looks a little silly. Leaving here as documentation, just in case we want this for something else...
// if (now.difference(date).abs().inSeconds > 1) {
// return AppLocalizations.of(context)!.xSecondsAgo.replaceAll("\$seconds", now.difference(date).abs().inSeconds.toString());
// }
return AppLocalizations.of(context)!.now;
}
return DateFormat.yMd(Platform.localeName).add_jm().format(date);
}

View File

@ -50,14 +50,14 @@ class Formatter {
// regex to match **bold**
final _boldRegex = RegExp(
r'^(.*?)(\*\*([^*]*)\*\*)',
r'^(.*?)(\*\*([^*]+)\*\*)',
caseSensitive: false,
dotAll: true,
);
// regex to match *italic*
final _italicRegex = RegExp(
r'^(.*?)(\*([^*]*)\*)',
r'^(.*?)(\*([^*]+)\*)',
caseSensitive: false,
dotAll: true,
);

View File

@ -637,6 +637,10 @@ class _MessageViewState extends State<MessageView> {
enableIMEPersonalizedLearning: false,
minLines: 1,
maxLength: max(1, (isGroup ? GroupMessageLengthMax : P2PMessageLengthMax) - numberOfBytesMoreThanChar),
autocorrect: true,
buildCounter: (context, {currentLength = 0, isFocused = true, maxLength}) {
return Text("$currentLength/$maxLength", style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle));
},
maxLengthEnforcement: MaxLengthEnforcement.enforced,
maxLines: 3,
onFieldSubmitted: _sendMessage,

View File

@ -4,6 +4,8 @@ import 'package:cwtch/models/appstate.dart';
import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/contactlist.dart';
import 'package:cwtch/models/profile.dart';
import 'package:cwtch/models/redaction.dart';
import 'package:cwtch/themes/opaque.dart';
import 'package:cwtch/views/contactsview.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/widgets/profileimage.dart';
@ -126,6 +128,7 @@ class _ContactRowState extends State<ContactRow> {
child: TextButton.icon(
label: Text(
AppLocalizations.of(context)!.tooltipAcceptContactRequest,
style: Provider.of<Settings>(context).scaleFonts(defaultTextButtonStyle),
),
icon: Icon(
Icons.favorite,
@ -139,7 +142,7 @@ class _ContactRowState extends State<ContactRow> {
child: TextButton.icon(
label: Text(
AppLocalizations.of(context)!.tooltipRejectContactRequest,
style: TextStyle(decoration: TextDecoration.underline),
style: Provider.of<Settings>(context).scaleFonts(defaultTextButtonStyle),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.backgroundPaneColor),
@ -148,7 +151,7 @@ class _ContactRowState extends State<ContactRow> {
onPressed: _btnReject,
))
])
: (contact.isBlocked != null && contact.isBlocked
: (contact.isBlocked
? IconButton(
padding: EdgeInsets.zero,
splashRadius: Material.defaultSplashRadius / 2,
@ -156,7 +159,7 @@ class _ContactRowState extends State<ContactRow> {
icon: Icon(Icons.block, color: Provider.of<Settings>(context).theme.mainTextColor),
onPressed: () {},
)
: Text(dateToNiceString(widget.messageIndex == null ? contact.lastMessageTime : (this.cachedMessage?.getMetadata().timestamp ?? DateTime.now())))),
: Text(prettyDateString(context, widget.messageIndex == null ? contact.lastMessageTime : (this.cachedMessage?.getMetadata().timestamp ?? DateTime.now())))),
),
],
))),
@ -211,16 +214,4 @@ class _ContactRowState extends State<ContactRow> {
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier);
}
}
String dateToNiceString(DateTime date) {
if (date.millisecondsSinceEpoch == 0) {
return AppLocalizations.of(context)!.conversationNotificationPolicyNever;
}
// If the last message was over a day ago, just state the date
if (DateTime.now().difference(date).inDays > 0) {
return DateFormat.yMd(Platform.localeName).format(date.toLocal());
}
// Otherwise just state the time.
return DateFormat.Hm(Platform.localeName).format(date.toLocal());
}
}

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../models/redaction.dart';
import '../settings.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -20,7 +21,7 @@ class MessageBubbleDecoration extends StatefulWidget {
class _MessageBubbleDecoration extends State<MessageBubbleDecoration> {
@override
Widget build(BuildContext context) {
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(widget.messageDate.toLocal());
var prettyDate = prettyDateString(context, widget.messageDate.toLocal());
return Center(
widthFactor: 1.0,