mattermost-mobile/app/screens/settings/config.ts
Christopher Poile 92bdb2847b
[MM-57486] [MM-58008] Calls: Mobile ringing for incoming calls (#7984)
* notification ringing, settings screen, native code patch, ringing mp3s

* i18n

* play preview on first press

* prevent playing from background (only affects Android) to match iOS beh

* stop ringing/vibration on entering background

* ring when coming back from background and new incoming call is present

* no push notification sound when it's a call; improve ringing

* move sounds to asset folder; copy on postinstall for android bundling

* make Ringtone type a string enum

* make Android ring async + await ring and stop; changes from PR comments

* missing fields after merge

* release lock on an exception

* cancel sample ringing when turning notifications off

* copy sound files for android build

* typo

* update snapshots

* testing if the problem is copying the mp3 files

* fix android mp3 assets when building for non-release

* add sounds to .gitignore

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2024-07-03 10:22:46 -04:00

140 lines
4.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {t} from '@i18n';
import {goToScreen} from '@screens/navigation';
import {typography} from '@utils/typography';
import type {AvailableScreens} from '@typings/screens/navigation';
import type {IntlShape} from 'react-intl';
export const getSaveButton = (buttonId: string, intl: IntlShape, color: string) => ({
color,
enabled: false,
id: buttonId,
showAsAction: 'always' as const,
testID: 'notification_settings.mentions.save.button',
text: intl.formatMessage({id: 'settings.save', defaultMessage: 'Save'}),
...typography('Body', 100, 'SemiBold'),
});
export const gotoSettingsScreen = (screen: AvailableScreens, title: string) => {
const passProps = {};
const options = {
topBar: {
backButton: {
popStackOnPress: false,
},
},
};
return goToScreen(screen, title, passProps, options);
};
type SettingConfigDetails = {
defaultMessage?: string;
i18nId?: string;
icon?: string;
testID?: string;
}
export const SettingOptionConfig: Record<string, SettingConfigDetails> = {
notification: {
defaultMessage: 'Notifications',
i18nId: t('general_settings.notifications'),
icon: 'bell-outline',
testID: 'general_settings.notifications',
},
display: {
defaultMessage: 'Display',
i18nId: t('general_settings.display'),
icon: 'layers-outline',
testID: 'general_settings.display',
},
advanced_settings: {
defaultMessage: 'Advanced Settings',
i18nId: t('general_settings.advanced_settings'),
icon: 'tune',
testID: 'general_settings.advanced',
},
about: {
defaultMessage: 'About {appTitle}',
i18nId: t('general_settings.about'),
icon: 'information-outline',
testID: 'general_settings.about',
},
help: {
defaultMessage: 'Help',
i18nId: t('general_settings.help'),
testID: 'general_settings.help',
},
report_problem: {
defaultMessage: 'Report a Problem',
i18nId: t('general_settings.report_problem'),
testID: 'general_settings.report_problem',
},
};
export const NotificationsOptionConfig: Record<string, SettingConfigDetails> = {
mentions: {
icon: 'at',
testID: 'notification_settings.mentions_replies',
},
push_notification: {
defaultMessage: 'Push Notifications',
i18nId: t('notification_settings.mobile'),
icon: 'cellphone',
testID: 'notification_settings.push_notification',
},
call_notification: {
defaultMessage: 'Call Notifications',
i18nId: t('notification_settings.calls'),
icon: 'phone-in-talk',
testID: 'notification_settings.call_notification',
},
email: {
defaultMessage: 'Email',
i18nId: t('notification_settings.email'),
icon: 'email-outline',
testID: 'notification_settings.email',
},
automatic_dm_replies: {
defaultMessage: 'Automatic replies',
i18nId: t('notification_settings.ooo_auto_responder'),
icon: 'reply-outline',
testID: 'notification_settings.automatic_dm_replies',
},
};
export const DisplayOptionConfig: Record<string, SettingConfigDetails> = {
clock: {
defaultMessage: 'Clock Display',
i18nId: t('mobile.display_settings.clockDisplay'),
icon: 'clock-outline',
testID: 'display_settings.clock',
},
crt: {
defaultMessage: 'Collapsed Reply Threads',
i18nId: t('mobile.display_settings.crt'),
icon: 'message-text-outline',
testID: 'display_settings.crt',
},
theme: {
defaultMessage: 'Theme',
i18nId: t('mobile.display_settings.theme'),
icon: 'palette-outline',
testID: 'display_settings.theme',
},
timezone: {
defaultMessage: 'Timezone',
i18nId: t('mobile.display_settings.timezone'),
icon: 'globe',
testID: 'display_settings.timezone',
},
};
export default {
...SettingOptionConfig,
...NotificationsOptionConfig,
...DisplayOptionConfig,
};