feat: add notification volume setting (#4310)
This commit is contained in:
parent
15b052e5a2
commit
8c388a76f8
8 changed files with 55 additions and 1 deletions
|
|
@ -194,6 +194,8 @@ abstract class AppConfig {
|
|||
"https://pangea-chat-client-assets.s3.us-east-1.amazonaws.com";
|
||||
|
||||
static String errorSubscriptionId = "pangea_subscription_error";
|
||||
|
||||
static double volume = 1.0;
|
||||
// Pangea#
|
||||
|
||||
static void loadFromJson(Map<String, dynamic> json) {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ abstract class SettingKeys {
|
|||
static const String showPresences = 'chat.fluffy.show_presences';
|
||||
static const String displayNavigationRail =
|
||||
'chat.fluffy.display_navigation_rail';
|
||||
// #Pangea
|
||||
static const String volume = 'pangea.volume';
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
enum AppSettings<T> {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/settings_notifications/push_rule_extensions.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
|
|
@ -192,6 +193,20 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
}
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
final ValueNotifier<double> volumeNotifier =
|
||||
ValueNotifier<double>(AppConfig.volume);
|
||||
|
||||
void updateVolume(double value) {
|
||||
volumeNotifier.value = value;
|
||||
AppConfig.volume = value;
|
||||
Matrix.of(context).store.setDouble(
|
||||
SettingKeys.volume,
|
||||
value,
|
||||
);
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsNotificationsView(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,28 @@ class SettingsNotificationsView extends StatelessWidget {
|
|||
return SelectionArea(
|
||||
child: Column(
|
||||
children: [
|
||||
// #Pangea
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.volume_up),
|
||||
Expanded(
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: controller.volumeNotifier,
|
||||
builder: (context, volume, _) {
|
||||
return Slider(
|
||||
value: volume,
|
||||
max: 1.0,
|
||||
onChanged: controller.updateVolume,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Pangea#
|
||||
if (pushRules != null)
|
||||
for (final category in pushCategories) ...[
|
||||
ListTile(
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class LevelUpUtil {
|
|||
) async {
|
||||
// Remove delay since GetAnalyticsController._onLevelUp is already async
|
||||
final player = AudioPlayer();
|
||||
player.setVolume(AppConfig.volume);
|
||||
|
||||
// Wait for any existing snackbars to dismiss
|
||||
await _waitForSnackbars(context);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
|
||||
class ClickPlayer {
|
||||
late AudioPlayer _player;
|
||||
|
||||
ClickPlayer() {
|
||||
_player = AudioPlayer();
|
||||
_player.setPlayerMode(PlayerMode.lowLatency);
|
||||
_player.setVolume(0.5);
|
||||
_player.setVolume(min(0.5, AppConfig.volume));
|
||||
}
|
||||
|
||||
Future<void> play() async {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
);
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
_audioPlayer.volume = AppConfig.volume;
|
||||
// Pangea#
|
||||
_audioPlayer.play();
|
||||
|
||||
html.Notification(
|
||||
|
|
|
|||
|
|
@ -528,6 +528,10 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
AppConfig.displayNavigationRail =
|
||||
store.getBool(SettingKeys.displayNavigationRail) ??
|
||||
AppConfig.displayNavigationRail;
|
||||
|
||||
// #Pangea
|
||||
AppConfig.volume = store.getDouble(SettingKeys.volume) ?? AppConfig.volume;
|
||||
// Pangea#
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue