diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index 4fbd74c9..c83491a5 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -84,6 +84,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : Log.i(TAG, "startCwtch success, starting coroutine AppbusEvent loop...") val downloadIDs = mutableMapOf() + val downloadFinishedIDs = mutableMapOf() var flags = PendingIntent.FLAG_UPDATE_CURRENT if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { flags = flags or PendingIntent.FLAG_IMMUTABLE @@ -167,32 +168,36 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val title = data.getString("NameSuggestion"); val progress = data.getString("Progress").toInt(); val progressMax = data.getString("FileSizeInChunks").toInt(); - if (!downloadIDs.containsKey(fileKey)) { - downloadIDs.put(fileKey, downloadIDs.count()); - } - var dlID = downloadIDs.get(fileKey); - if (dlID == null) { - dlID = 0; - } - if (progress >= 0) { - val channelId = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - createDownloadNotificationChannel(fileKey, fileKey) - } else { - // If earlier version channel ID is not used - // https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context) - "" - }; - val newNotification = NotificationCompat.Builder(applicationContext, channelId) - .setOngoing(true) - .setContentTitle("Downloading")//todo: translate - .setContentText(title) - .setSmallIcon(android.R.drawable.stat_sys_download) - .setProgress(progressMax, progress, false) - .setSound(null) - //.setSilent(true) - .build(); - notificationManager.notify(dlID, newNotification); + + // if we have seen a download finished update for this key then ignore it + if (!downloadFinishedIDs.containsKey(fileKey)) { + if (!downloadIDs.containsKey(fileKey)) { + downloadIDs.put(fileKey, downloadIDs.count()); + } + var dlID = downloadIDs.get(fileKey); + if (dlID == null) { + dlID = 0; + } + if (progress >= 0) { + val channelId = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + createDownloadNotificationChannel(fileKey, fileKey) + } else { + // If earlier version channel ID is not used + // https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context) + "" + }; + val newNotification = NotificationCompat.Builder(applicationContext, channelId) + .setOngoing(true) + .setContentTitle("Downloading")//todo: translate + .setContentText(title) + .setSmallIcon(android.R.drawable.stat_sys_download) + .setProgress(progressMax, progress, false) + .setSound(null) + //.setSilent(true) + .build(); + notificationManager.notify(dlID, newNotification); + } } } catch (e: Exception) { Log.d("FlwtchWorker->FileDownloadProgressUpdate", e.toString() + " :: " + e.getStackTrace()); @@ -216,6 +221,8 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : Files.delete(sourcePath); } } + // Suppress future notifications... + downloadFinishedIDs.put(fileKey, downloadIDs.count()); if (downloadIDs.containsKey(fileKey)) { notificationManager.cancel(downloadIDs.get(fileKey) ?: 0); } diff --git a/lib/models/messages/textmessage.dart b/lib/models/messages/textmessage.dart index c15555a6..bbbb7f23 100644 --- a/lib/models/messages/textmessage.dart +++ b/lib/models/messages/textmessage.dart @@ -26,7 +26,8 @@ class TextMessage extends Message { value: this.metadata, builder: (bcontext, child) { var formatMessages = Provider.of(bcontext).isExperimentEnabled(FormattingExperiment); - return compileMessageContentWidget(context, false, content, FocusNode(), formatMessages, false);; + return compileMessageContentWidget(context, false, content, FocusNode(), formatMessages, false); + ; }); } diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index aa10f2c9..7fdaff31 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -24,6 +24,7 @@ final TextStyle defaultMessageTextStyle = TextStyle(fontFamily: "Inter", fontWei final TextStyle defaultFormLabelTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: 20); final TextStyle defaultTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w500, fontSize: 12); final TextStyle defaultTextButtonStyle = defaultTextStyle.copyWith(fontWeight: FontWeight.bold); +final TextStyle defaultDropDownMenuItemTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: 16); final themes = { cwtch_theme: {mode_light: CwtchLight(), mode_dark: CwtchDark()}, @@ -205,8 +206,8 @@ ThemeData mkThemeData(Settings opaque) { textTheme: TextTheme( // NOTE: The following font scales were arrived at after consulting the material text scale // docs: https://m3.material.io/styles/typography/type-scale-tokens and some trial and error - displayMedium: TextStyle(fontFamily: "Inter", fontSize: opaque.fontScaling * 16.0, color: opaque.current().mainTextColor), displaySmall: TextStyle(fontFamily: "Inter", fontSize: opaque.fontScaling * 14.0, color: opaque.current().mainTextColor), + displayMedium: TextStyle(fontFamily: "Inter", fontSize: opaque.fontScaling * 16.0, color: opaque.current().mainTextColor), displayLarge: TextStyle(fontFamily: "Inter", fontSize: opaque.fontScaling * 18.0, color: opaque.current().mainTextColor), titleSmall: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: opaque.fontScaling * 16.0, color: opaque.current().mainTextColor), titleLarge: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: opaque.fontScaling * 18.0, color: opaque.current().mainTextColor), @@ -218,8 +219,8 @@ ThemeData mkThemeData(Settings opaque) { headlineMedium: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: opaque.fontScaling * 26.0, color: opaque.current().mainTextColor), headlineLarge: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: opaque.fontScaling * 28.0, color: opaque.current().mainTextColor), labelSmall: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w100, fontSize: opaque.fontScaling * 14.0, color: opaque.current().mainTextColor), - labelLarge: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w200, fontSize: opaque.fontScaling * 16.0, color: opaque.current().mainTextColor), - labelMedium: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w300, fontSize: opaque.fontScaling * 18.0, color: opaque.current().mainTextColor), + labelMedium: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w300, fontSize: opaque.fontScaling * 16.0, color: opaque.current().mainTextColor), + labelLarge: TextStyle(fontFamily: "Inter", fontWeight: FontWeight.w200, fontSize: opaque.fontScaling * 18.0, color: opaque.current().mainTextColor), ), switchTheme: SwitchThemeData( overlayColor: MaterialStateProperty.all(opaque.current().defaultButtonActiveColor), diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 36ec04c7..62d8cb5d 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -128,7 +128,8 @@ class _GlobalSettingsViewState extends State { items: AppLocalizations.supportedLocales.map>((Locale value) { return DropdownMenuItem( value: value.toString(), - child: Text(key: Key("dropdownLanguage" + value.languageCode), getLanguageFull(context, value.languageCode, value.countryCode)), + child: Text( + key: Key("dropdownLanguage" + value.languageCode), getLanguageFull(context, value.languageCode, value.countryCode), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), ); }).toList()))), SwitchListTile( @@ -165,7 +166,7 @@ class _GlobalSettingsViewState extends State { items: themes.keys.map>((String themeId) { return DropdownMenuItem( value: themeId, - child: Text(getThemeName(context, themeId)), //"ddi_$themeId", key: Key("ddi_$themeId")), + child: Text(getThemeName(context, themeId), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), //"ddi_$themeId", key: Key("ddi_$themeId")), ); }).toList())), leading: Icon(Icons.palette, color: settings.current().mainTextColor), @@ -185,7 +186,7 @@ class _GlobalSettingsViewState extends State { items: Settings.uiColumnModeOptions(false).map>((DualpaneMode value) { return DropdownMenuItem( value: value.toString(), - child: Text(Settings.uiColumnModeToString(value, context)), + child: Text(Settings.uiColumnModeToString(value, context), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), ); }).toList()))), ListTile( @@ -193,7 +194,6 @@ class _GlobalSettingsViewState extends State { AppLocalizations.of(context)!.settingUIColumnLandscape, textWidthBasis: TextWidthBasis.longestLine, softWrap: true, - style: TextStyle(color: settings.current().mainTextColor), ), leading: Icon(Icons.stay_primary_landscape, color: settings.current().mainTextColor), trailing: Container( @@ -210,10 +210,7 @@ class _GlobalSettingsViewState extends State { items: Settings.uiColumnModeOptions(true).map>((DualpaneMode value) { return DropdownMenuItem( value: value.toString(), - child: Text( - Settings.uiColumnModeToString(value, context), - overflow: TextOverflow.ellipsis, - ), + child: Text(Settings.uiColumnModeToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), ); }).toList())))), ListTile( @@ -305,10 +302,7 @@ class _GlobalSettingsViewState extends State { items: NotificationPolicy.values.map>((NotificationPolicy value) { return DropdownMenuItem( value: value, - child: Text( - Settings.notificationPolicyToString(value, context), - overflow: TextOverflow.ellipsis, - ), + child: Text(Settings.notificationPolicyToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), ); }).toList())), leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor), @@ -328,10 +322,7 @@ class _GlobalSettingsViewState extends State { items: NotificationContent.values.map>((NotificationContent value) { return DropdownMenuItem( value: value, - child: Text( - Settings.notificationContentToString(value, context), - overflow: TextOverflow.ellipsis, - ), + child: Text(Settings.notificationContentToString(value, context), overflow: TextOverflow.ellipsis, style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), ); }).toList())), leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor),