notification policy work, translations, even for notifications
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
d1d3f23f82
commit
4c47198977
|
@ -29,6 +29,9 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
private var notificationID: MutableMap<String, Int> = mutableMapOf()
|
private var notificationID: MutableMap<String, Int> = mutableMapOf()
|
||||||
private var notificationIDnext: Int = 1
|
private var notificationIDnext: Int = 1
|
||||||
|
|
||||||
|
private var notificationSimple: String? = null
|
||||||
|
private var notificationConversationInfo: String? = null
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val method = inputData.getString(KEY_METHOD)
|
val method = inputData.getString(KEY_METHOD)
|
||||||
?: return Result.failure()
|
?: return Result.failure()
|
||||||
|
@ -67,14 +70,8 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
val data = JSONObject(evt.Data)
|
val data = JSONObject(evt.Data)
|
||||||
val handle = if (evt.EventType == "NewMessageFromPeer") data.getString("RemotePeer") else data.getString("GroupID");
|
val handle = if (evt.EventType == "NewMessageFromPeer") data.getString("RemotePeer") else data.getString("GroupID");
|
||||||
if (data["RemotePeer"] != data["ProfileOnion"]) {
|
if (data["RemotePeer"] != data["ProfileOnion"]) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val notification = data["notification"]
|
val notification = data["notification"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (notification == "SimpleEvent") {
|
if (notification == "SimpleEvent") {
|
||||||
val channelId =
|
val channelId =
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
@ -92,7 +89,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
|
|
||||||
val newNotification = NotificationCompat.Builder(applicationContext, channelId)
|
val newNotification = NotificationCompat.Builder(applicationContext, channelId)
|
||||||
.setContentTitle("Cwtch")
|
.setContentTitle("Cwtch")
|
||||||
.setContentText("New message")//todo: translate
|
.setContentText(notificationSimple ?: "New Message")
|
||||||
.setSmallIcon(R.mipmap.knott_transparent)
|
.setSmallIcon(R.mipmap.knott_transparent)
|
||||||
.setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
.setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
@ -121,7 +118,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
|
|
||||||
val newNotification = NotificationCompat.Builder(applicationContext, channelId)
|
val newNotification = NotificationCompat.Builder(applicationContext, channelId)
|
||||||
.setContentTitle(data.getString("Nick"))
|
.setContentTitle(data.getString("Nick"))
|
||||||
.setContentText("New message")//todo: translate
|
.setContentText((notificationConversationInfo ?: "New Message From %1").replace("%1", data.getString("Nick")))
|
||||||
.setLargeIcon(BitmapFactory.decodeStream(fh))
|
.setLargeIcon(BitmapFactory.decodeStream(fh))
|
||||||
.setSmallIcon(R.mipmap.knott_transparent)
|
.setSmallIcon(R.mipmap.knott_transparent)
|
||||||
.setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
.setContentIntent(PendingIntent.getActivity(applicationContext, 1, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
|
@ -397,6 +394,11 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
|
||||||
val v = (a.get("Val") as? String) ?: ""
|
val v = (a.get("Val") as? String) ?: ""
|
||||||
Cwtch.setServerAttribute(serverOnion, key, v)
|
Cwtch.setServerAttribute(serverOnion, key, v)
|
||||||
}
|
}
|
||||||
|
"L10nInit" -> {
|
||||||
|
notificationSimple = (a.get("notificationSimple") as? String) ?: "New Message"
|
||||||
|
notificationConversationInfo = (a.get("notificationConversationInfo") as? String)
|
||||||
|
?: "New Message From "
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Log.i("FlwtchWorker", "unknown command: " + method);
|
Log.i("FlwtchWorker", "unknown command: " + method);
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
|
|
|
@ -105,5 +105,9 @@ abstract class Cwtch {
|
||||||
// non-ffi
|
// non-ffi
|
||||||
String defaultDownloadPath();
|
String defaultDownloadPath();
|
||||||
|
|
||||||
|
bool isL10nInit();
|
||||||
|
|
||||||
|
void l10nInit(String notificationSimple, String notificationConversationInfo);
|
||||||
|
|
||||||
void dispose();
|
void dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import 'package:cwtch/models/remoteserver.dart';
|
||||||
import 'package:cwtch/models/servers.dart';
|
import 'package:cwtch/models/servers.dart';
|
||||||
import 'package:cwtch/notification_manager.dart';
|
import 'package:cwtch/notification_manager.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'package:cwtch/torstatus.dart';
|
import 'package:cwtch/torstatus.dart';
|
||||||
|
@ -28,6 +29,9 @@ class CwtchNotifier {
|
||||||
late AppState appState;
|
late AppState appState;
|
||||||
late ServerListState serverListState;
|
late ServerListState serverListState;
|
||||||
|
|
||||||
|
String? notificationSimple;
|
||||||
|
String? notificationConversationInfo;
|
||||||
|
|
||||||
CwtchNotifier(
|
CwtchNotifier(
|
||||||
ProfileListState pcn, Settings settingsCN, ErrorHandler errorCN, TorStatus torStatusCN, NotificationsManager notificationManagerP, AppState appStateCN, ServerListState serverListStateCN) {
|
ProfileListState pcn, Settings settingsCN, ErrorHandler errorCN, TorStatus torStatusCN, NotificationsManager notificationManagerP, AppState appStateCN, ServerListState serverListStateCN) {
|
||||||
profileCN = pcn;
|
profileCN = pcn;
|
||||||
|
@ -39,6 +43,11 @@ class CwtchNotifier {
|
||||||
serverListState = serverListStateCN;
|
serverListState = serverListStateCN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void l10nInit(String notificationSimple, String notificationConversationInfo) {
|
||||||
|
this.notificationSimple = notificationSimple;
|
||||||
|
this.notificationConversationInfo = notificationConversationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
void handleMessage(String type, dynamic data) {
|
void handleMessage(String type, dynamic data) {
|
||||||
//EnvironmentConfig.debugLog("NewEvent $type $data");
|
//EnvironmentConfig.debugLog("NewEvent $type $data");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -160,10 +169,10 @@ class CwtchNotifier {
|
||||||
var notification = data["notification"];
|
var notification = data["notification"];
|
||||||
|
|
||||||
if (notification == "SimpleEvent") {
|
if (notification == "SimpleEvent") {
|
||||||
notificationManager.notify(/*TODO l10n */ "New Message");
|
notificationManager.notify(notificationSimple ?? "New Message");
|
||||||
} else if (notification == "ContactInfo") {
|
} else if (notification == "ContactInfo") {
|
||||||
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
||||||
notificationManager.notify(/*TODO l10n */ "New Message from " + (contact?.nickname ?? senderHandle.toString()));
|
notificationManager.notify((notificationConversationInfo ?? "New Message from %1").replaceFirst("%1", (contact?.nickname ?? senderHandle.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.newMessage(
|
profileCN.getProfile(data["ProfileOnion"])?.newMessage(
|
||||||
|
@ -237,10 +246,10 @@ class CwtchNotifier {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.newMessage(identifier, idx, timestampSent, senderHandle, senderImage, isAuto, data["Data"], contenthash, selectedProfile, selectedConversation);
|
profileCN.getProfile(data["ProfileOnion"])?.newMessage(identifier, idx, timestampSent, senderHandle, senderImage, isAuto, data["Data"], contenthash, selectedProfile, selectedConversation);
|
||||||
|
|
||||||
if (notification == "SimpleEvent") {
|
if (notification == "SimpleEvent") {
|
||||||
notificationManager.notify(/*TODO l10n */ "New Message");
|
notificationManager.notify(notificationSimple ?? "New Message");
|
||||||
} else if (notification == "ContactInfo") {
|
} else if (notification == "ContactInfo") {
|
||||||
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
||||||
notificationManager.notify(/*TODO l10n */ "New Message from " + (contact?.nickname ?? senderHandle.toString()));
|
notificationManager.notify( (notificationConversationInfo ?? "New Message from %1").replaceFirst("%1", (contact?.nickname ?? senderHandle.toString())));
|
||||||
}
|
}
|
||||||
appState.notifyProfileUnread();
|
appState.notifyProfileUnread();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ class CwtchFfi implements Cwtch {
|
||||||
late CwtchNotifier cwtchNotifier;
|
late CwtchNotifier cwtchNotifier;
|
||||||
late Isolate cwtchIsolate;
|
late Isolate cwtchIsolate;
|
||||||
ReceivePort _receivePort = ReceivePort();
|
ReceivePort _receivePort = ReceivePort();
|
||||||
|
bool _isL10nInit = false;
|
||||||
|
|
||||||
static String getLibraryPath() {
|
static String getLibraryPath() {
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
|
@ -744,4 +745,15 @@ class CwtchFfi implements Cwtch {
|
||||||
malloc.free(utf8newpass);
|
malloc.free(utf8newpass);
|
||||||
malloc.free(utf8newpasssagain);
|
malloc.free(utf8newpasssagain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isL10nInit() {
|
||||||
|
return _isL10nInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void l10nInit(String notificationSimple, String notificationConversationInfo) {
|
||||||
|
cwtchNotifier.l10nInit(notificationSimple, notificationConversationInfo);
|
||||||
|
_isL10nInit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
late Future<dynamic> androidHomeDirectory;
|
late Future<dynamic> androidHomeDirectory;
|
||||||
String androidHomeDirectoryStr = "";
|
String androidHomeDirectoryStr = "";
|
||||||
late CwtchNotifier cwtchNotifier;
|
late CwtchNotifier cwtchNotifier;
|
||||||
|
bool _isL10nInit = false;
|
||||||
|
|
||||||
CwtchGomobile(CwtchNotifier _cwtchNotifier) {
|
CwtchGomobile(CwtchNotifier _cwtchNotifier) {
|
||||||
print("gomobile.dart: CwtchGomobile()");
|
print("gomobile.dart: CwtchGomobile()");
|
||||||
|
@ -295,4 +296,16 @@ class CwtchGomobile implements Cwtch {
|
||||||
void ChangePassword(String profile, String pass, String newpass, String newpassAgain) {
|
void ChangePassword(String profile, String pass, String newpass, String newpassAgain) {
|
||||||
cwtchPlatform.invokeMethod("ChangePassword", {"ProfileOnion": profile, "OldPass": pass, "NewPass": newpass, "NewPassAgain": newpassAgain});
|
cwtchPlatform.invokeMethod("ChangePassword", {"ProfileOnion": profile, "OldPass": pass, "NewPass": newpass, "NewPassAgain": newpassAgain});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isL10nInit() {
|
||||||
|
return _isL10nInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void l10nInit(String notificationSimple, String notificationConversationInfo) {
|
||||||
|
cwtchNotifier.l10nInit(notificationSimple, notificationConversationInfo);
|
||||||
|
cwtchPlatform.invokeMethod("L10nInit", {"notificationSimple": notificationSimple, "notificationConversationInfo": notificationConversationInfo});
|
||||||
|
_isL10nInit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "de",
|
"@@locale": "de",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "en",
|
"@@locale": "en",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"editProfile": "Edit Profile",
|
"editProfile": "Edit Profile",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "es",
|
"@@locale": "es",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "fr",
|
"@@locale": "fr",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"editProfile": "Modifier le profil",
|
"editProfile": "Modifier le profil",
|
||||||
"settingTheme": "Utilisez des thèmes clairs",
|
"settingTheme": "Utilisez des thèmes clairs",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "it",
|
"@@locale": "it",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "pl",
|
"@@locale": "pl",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "pt",
|
"@@locale": "pt",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
{
|
{
|
||||||
"@@locale": "ru",
|
"@@locale": "ru",
|
||||||
"@@last_modified": "2022-02-07T21:17:01+01:00",
|
"@@last_modified": "2022-02-08T20:13:50+01:00",
|
||||||
|
"newMessageNotificationConversationInfo": "New Message From %1",
|
||||||
|
"newMessageNotificationSimple": "New Message",
|
||||||
|
"notificationContentContactInfo": "Conversation Information",
|
||||||
|
"notificationContentSimpleEvent": "Plain Event",
|
||||||
|
"conversationNotificationPolicySettingDescription": "Control this conversation's notification behaviour",
|
||||||
|
"conversationNotificationPolicySettingLabel": "Conversation Notification Policy",
|
||||||
|
"settingsGroupExperiments": "Experiments",
|
||||||
|
"settingsGroupAppearance": "Appearance",
|
||||||
|
"settingGroupBehaviour": "Behaviour",
|
||||||
|
"notificationContentSettingDescription": "Controls the contents of conversation notifications",
|
||||||
|
"notificationPolicySettingDescription": "Controls the default application notification behaviour",
|
||||||
|
"notificationContentSettingLabel": "Notification Content",
|
||||||
|
"notificationPolicySettingLabel": "Notification Policy",
|
||||||
|
"conversationNotificationPolicyNever": "Never",
|
||||||
|
"conversationNotificationPolicyOptIn": "Opt In",
|
||||||
|
"conversationNotificationPolicyDefault": "Default",
|
||||||
|
"notificationPolicyDefaultAll": "Default All",
|
||||||
|
"notificationPolicyOptIn": "Opt In",
|
||||||
|
"notificationPolicyMute": "Mute",
|
||||||
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
"tooltipSelectACustomProfileImage": "Select a Custom Profile Image",
|
||||||
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
"torSettingsEnabledCacheDescription": "Cache the current downloaded Tor consensus to reuse next time Cwtch is opened. This will allow Tor to start faster. When disabled, Cwtch will purge cached data on start up.",
|
||||||
"torSettingsEnableCache": "Cache Tor Consensus",
|
"torSettingsEnableCache": "Cache Tor Consensus",
|
||||||
|
|
|
@ -37,7 +37,6 @@ Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
print("runApp()");
|
print("runApp()");
|
||||||
runApp(Flwtch());
|
runApp(Flwtch());
|
||||||
sleep(Duration(seconds: 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Flwtch extends StatefulWidget {
|
class Flwtch extends StatefulWidget {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:cwtch/widgets/messagerow.dart';
|
import 'package:cwtch/widgets/messagerow.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
|
||||||
import 'message.dart';
|
import 'message.dart';
|
||||||
import 'messagecache.dart';
|
import 'messagecache.dart';
|
||||||
|
@ -11,14 +13,14 @@ enum ConversationNotificationPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Nameable on ConversationNotificationPolicy {
|
extension Nameable on ConversationNotificationPolicy {
|
||||||
String get toName {
|
String toName(BuildContext context) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case ConversationNotificationPolicy.Default:
|
case ConversationNotificationPolicy.Default:
|
||||||
return "Default";
|
return AppLocalizations.of(context)!.conversationNotificationPolicyDefault;
|
||||||
case ConversationNotificationPolicy.OptIn:
|
case ConversationNotificationPolicy.OptIn:
|
||||||
return "Opt In";
|
return AppLocalizations.of(context)!.conversationNotificationPolicyOptIn;
|
||||||
case ConversationNotificationPolicy.Never:
|
case ConversationNotificationPolicy.Never:
|
||||||
return "Never";
|
return AppLocalizations.of(context)!.conversationNotificationPolicyNever;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,16 +296,16 @@ class Settings extends ChangeNotifier {
|
||||||
|
|
||||||
static String notificationPolicyToString(NotificationPolicy np, BuildContext context) {
|
static String notificationPolicyToString(NotificationPolicy np, BuildContext context) {
|
||||||
switch (np) {
|
switch (np) {
|
||||||
case NotificationPolicy.Mute: return "Mute";
|
case NotificationPolicy.Mute: return AppLocalizations.of(context)!.notificationPolicyMute;
|
||||||
case NotificationPolicy.OptIn: return "OptIn";
|
case NotificationPolicy.OptIn: return AppLocalizations.of(context)!.notificationPolicyOptIn;
|
||||||
case NotificationPolicy.DefaultAll: return "DefaultAll";
|
case NotificationPolicy.DefaultAll: return AppLocalizations.of(context)!.notificationPolicyDefaultAll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String notificationContentToString(NotificationContent nc, BuildContext context) {
|
static String notificationContentToString(NotificationContent nc, BuildContext context) {
|
||||||
switch (nc) {
|
switch (nc) {
|
||||||
case NotificationContent.SimpleEvent: return "SimpleEvent";
|
case NotificationContent.SimpleEvent: return AppLocalizations.of(context)!.notificationContentSimpleEvent;
|
||||||
case NotificationContent.ContactInfo: return "ContactInfo";
|
case NotificationContent.ContactInfo: return AppLocalizations.of(context)!.notificationContentContactInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
minHeight: viewportConstraints.maxHeight,
|
minHeight: viewportConstraints.maxHeight,
|
||||||
),
|
),
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text("Apperance", style: TextStyle(fontWeight: FontWeight.bold))]),
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text(AppLocalizations.of(context)!.settingsGroupAppearance, style: TextStyle(fontWeight: FontWeight.bold))]),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.settingLanguage, style: TextStyle(color: settings.current().mainTextColor)),
|
title: Text(AppLocalizations.of(context)!.settingLanguage, style: TextStyle(color: settings.current().mainTextColor)),
|
||||||
leading: Icon(CwtchIcons.change_language, color: settings.current().mainTextColor),
|
leading: Icon(CwtchIcons.change_language, color: settings.current().mainTextColor),
|
||||||
|
@ -168,9 +168,10 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text("Behaviour", style: TextStyle(fontWeight: FontWeight.bold))]),
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text(AppLocalizations.of(context)!.settingGroupBehaviour, style: TextStyle(fontWeight: FontWeight.bold))]),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(/*AppLocalizations.of(context)!.themeColorLabel*/ "Notification Policy"),
|
title: Text(AppLocalizations.of(context)!.notificationPolicySettingLabel),
|
||||||
|
subtitle: Text(AppLocalizations.of(context)!.notificationPolicySettingDescription),
|
||||||
trailing: DropdownButton(
|
trailing: DropdownButton(
|
||||||
value: settings.notificationPolicy,
|
value: settings.notificationPolicy,
|
||||||
onChanged: (NotificationPolicy? newValue) {
|
onChanged: (NotificationPolicy? newValue) {
|
||||||
|
@ -189,7 +190,8 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(/*AppLocalizations.of(context)!.themeColorLabel*/ "Notification Content"),
|
title: Text(AppLocalizations.of(context)!.notificationContentSettingLabel),
|
||||||
|
subtitle: Text(AppLocalizations.of(context)!.notificationContentSettingDescription),
|
||||||
trailing: DropdownButton(
|
trailing: DropdownButton(
|
||||||
value: settings.notificationContent,
|
value: settings.notificationContent,
|
||||||
onChanged: (NotificationContent? newValue) {
|
onChanged: (NotificationContent? newValue) {
|
||||||
|
@ -228,7 +230,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text("Experiments", style: TextStyle(fontWeight: FontWeight.bold))]),
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [Text(AppLocalizations.of(context)!.settingsGroupExperiments, style: TextStyle(fontWeight: FontWeight.bold))]),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.experimentsEnabled, style: TextStyle(color: settings.current().mainTextColor)),
|
title: Text(AppLocalizations.of(context)!.experimentsEnabled, style: TextStyle(color: settings.current().mainTextColor)),
|
||||||
subtitle: Text(AppLocalizations.of(context)!.descriptionExperiments),
|
subtitle: Text(AppLocalizations.of(context)!.descriptionExperiments),
|
||||||
|
|
|
@ -131,15 +131,15 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(/*AppLocalizations.of(context)!.savePeerHistory*/ "Conversation Notification Policy", style: TextStyle(color: settings.current().mainTextColor)),
|
title: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingLabel, style: TextStyle(color: settings.current().mainTextColor)),
|
||||||
subtitle: Text(/*AppLocalizations.of(context)!.savePeerHistoryDescription*/ "The system blah blah..."),
|
subtitle: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingDescription),
|
||||||
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
||||||
trailing: DropdownButton(
|
trailing: DropdownButton(
|
||||||
value: Provider.of<ContactInfoState>(context).notificationsPolicy,
|
value: Provider.of<ContactInfoState>(context).notificationsPolicy,
|
||||||
items: ConversationNotificationPolicy.values.map<DropdownMenuItem<ConversationNotificationPolicy>>((ConversationNotificationPolicy value) {
|
items: ConversationNotificationPolicy.values.map<DropdownMenuItem<ConversationNotificationPolicy>>((ConversationNotificationPolicy value) {
|
||||||
return DropdownMenuItem<ConversationNotificationPolicy>(
|
return DropdownMenuItem<ConversationNotificationPolicy>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value.toName),
|
child: Text(value.toName(context)),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (ConversationNotificationPolicy? newVal) {
|
onChanged: (ConversationNotificationPolicy? newVal) {
|
||||||
|
|
|
@ -202,15 +202,15 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
||||||
);
|
);
|
||||||
}).toList())),
|
}).toList())),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(/*AppLocalizations.of(context)!.savePeerHistory*/ "Conversation Notification Policy", style: TextStyle(color: settings.current().mainTextColor)),
|
title: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingLabel, style: TextStyle(color: settings.current().mainTextColor)),
|
||||||
subtitle: Text(/*AppLocalizations.of(context)!.savePeerHistoryDescription*/ "The system blah blah..."),
|
subtitle: Text(AppLocalizations.of(context)!.conversationNotificationPolicySettingDescription),
|
||||||
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),
|
||||||
trailing: DropdownButton(
|
trailing: DropdownButton(
|
||||||
value: Provider.of<ContactInfoState>(context).notificationsPolicy,
|
value: Provider.of<ContactInfoState>(context).notificationsPolicy,
|
||||||
items: ConversationNotificationPolicy.values.map<DropdownMenuItem<ConversationNotificationPolicy>>((ConversationNotificationPolicy value) {
|
items: ConversationNotificationPolicy.values.map<DropdownMenuItem<ConversationNotificationPolicy>>((ConversationNotificationPolicy value) {
|
||||||
return DropdownMenuItem<ConversationNotificationPolicy>(
|
return DropdownMenuItem<ConversationNotificationPolicy>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value.toName),
|
child: Text(value.toName(context)),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (ConversationNotificationPolicy? newVal) {
|
onChanged: (ConversationNotificationPolicy? newVal) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
import '../main.dart';
|
||||||
import '../settings.dart';
|
import '../settings.dart';
|
||||||
|
|
||||||
class SplashView extends StatefulWidget {
|
class SplashView extends StatefulWidget {
|
||||||
|
@ -14,6 +15,13 @@ class SplashView extends StatefulWidget {
|
||||||
class _SplashViewState extends State<SplashView> {
|
class _SplashViewState extends State<SplashView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var cwtch = Provider.of<FlwtchState>(context, listen: false).cwtch;
|
||||||
|
if (!cwtch.isL10nInit()) {
|
||||||
|
if (AppLocalizations.of(context) != null && AppLocalizations.of(context)!.newMessageNotificationSimple.isNotEmpty ) {
|
||||||
|
cwtch.l10nInit(AppLocalizations.of(context)!.newMessageNotificationSimple, AppLocalizations.of(context)!.newMessageNotificationConversationInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Consumer<AppState>(
|
return Consumer<AppState>(
|
||||||
builder: (context, appState, child) => Scaffold(
|
builder: (context, appState, child) => Scaffold(
|
||||||
key: Key("SplashView"),
|
key: Key("SplashView"),
|
||||||
|
|
Loading…
Reference in New Issue