mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Add calling and notification sounds (#119)
* Add calling and notification sounds * Fix notification visibility on any resolution * Add comments * Log howler error src * Revert removed files im stupid * Make sliders on settings use changeCommitted instead of onChange * Fix ringtone paths * Break alert words overflow * Fix tweet overflow pepega * Remove unused hook * Update volume sliders in real time * Fix resolution notifications * Fix initial value for vol sliders * Fix call duration timer bugs * Add alert when phone active and phone closes * keep notification * Stop ringing when accept
This commit is contained in:
1 parent
8ecb91e71f
commit
4eda44b9c2
28 files changed
+589
-142
No files matched your search
@@ -9,7 +9,7 @@ import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
import PlayIcon from '@material-ui/icons/PlayArrow';
|
||||
import StopIcon from '@material-ui/icons/Stop';
|
||||
import { Button, IconButton } from '@material-ui/core';
|
||||
import useSound from '../../../os/phone/hooks/useSound';
|
||||
import useSound from '../../../os/sound/hooks/useSound';
|
||||
|
||||
export const ExampleApp = () => {
|
||||
// calling the example hook, and we assign the value to a variable
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
ListItem,
|
||||
ListItemText,
|
||||
Divider,
|
||||
ListItemIcon,
|
||||
} from '@material-ui/core';
|
||||
import { ListItem, ListItemText, ListItemIcon } from '@material-ui/core';
|
||||
|
||||
interface IProps {
|
||||
options?: any;
|
||||
@@ -19,26 +14,12 @@ export const SettingItem = ({
|
||||
label,
|
||||
value,
|
||||
onClick,
|
||||
icon
|
||||
icon,
|
||||
}: IProps) => {
|
||||
if (!onClick)
|
||||
return (
|
||||
<>
|
||||
<ListItem button>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListItem onClick={() => onClick(options)} button>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</>
|
||||
<ListItem divider onClick={() => onClick?.(options)} button>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
import { AppContent } from '../../../ui/components/AppContent';
|
||||
@@ -23,12 +23,20 @@ import {
|
||||
VolumeUp,
|
||||
} from '@material-ui/icons';
|
||||
|
||||
import { ListSubheader } from '@material-ui/core';
|
||||
import {
|
||||
Box,
|
||||
ListItem,
|
||||
ListItemIcon,
|
||||
ListItemSecondaryAction,
|
||||
ListItemText,
|
||||
ListSubheader,
|
||||
Slider,
|
||||
} from '@material-ui/core';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { settingsState } from '../hooks/useSettings';
|
||||
|
||||
const SubHeaderComp = (props: { text: string }) => (
|
||||
<ListSubheader component='div' disableSticky>
|
||||
<ListSubheader color='primary' component='div' disableSticky>
|
||||
{props.text}
|
||||
</ListSubheader>
|
||||
);
|
||||
@@ -43,6 +51,33 @@ export const SettingsApp = () => {
|
||||
setSettings({ ...settings, [key]: value });
|
||||
};
|
||||
|
||||
const [sliders, setSliders] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
setSliders((curr) => {
|
||||
if (!curr.length) {
|
||||
return [
|
||||
settings.ringtoneVol,
|
||||
settings.notificationVol,
|
||||
settings.TWITTER_notificationVol,
|
||||
];
|
||||
}
|
||||
return curr;
|
||||
});
|
||||
}, [
|
||||
settings.notificationVol,
|
||||
settings.ringtoneVol,
|
||||
settings.TWITTER_notificationVol,
|
||||
]);
|
||||
|
||||
const handleSliderChange = (idx) => (_e: any, value: number | number[]) => {
|
||||
setSliders((curr) => {
|
||||
const newValues = [...curr];
|
||||
newValues[idx] = value;
|
||||
return newValues;
|
||||
});
|
||||
};
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const wallpapers = config.wallpapers.map(
|
||||
@@ -65,18 +100,22 @@ export const SettingsApp = () => {
|
||||
handleSettingChange('zoom', val)
|
||||
)
|
||||
);
|
||||
// Doesn't actually do anything for the time being
|
||||
const ringtones = config.ringtones.map(
|
||||
MapStringOptions(settings.ringtone, (val: string) =>
|
||||
handleSettingChange('ringtone', val)
|
||||
)
|
||||
);
|
||||
// * Probably gonna make this a slider component in the future
|
||||
// const ringtoneVols = config.ringtoneVols.map(
|
||||
// MapStringOptions(settings.ringtoneVol, (val: number) => setSettings('ringtoneVol', val))
|
||||
// )
|
||||
const notifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('notification', val)
|
||||
)
|
||||
);
|
||||
|
||||
// TODO: These new settings all work
|
||||
const twitterNotifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('TWITTER_notification', val)
|
||||
)
|
||||
);
|
||||
|
||||
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
||||
return (
|
||||
@@ -96,17 +135,58 @@ export const SettingsApp = () => {
|
||||
onClick={openMenu}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
{
|
||||
// * NOTE: This component is most likely temporary
|
||||
// * Probably want to make it a slider in the future. Ignore hardcoded for the meantime
|
||||
}
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
||||
secondary={settings.ringtoneVol}
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<Box p={2} width={150}>
|
||||
<Slider
|
||||
value={sliders[0] || settings.ringtoneVol}
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={handleSliderChange(0)}
|
||||
onChangeCommitted={() =>
|
||||
handleSettingChange('ringtoneVol', sliders[0])
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
,
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
||||
value='100%'
|
||||
options={['100%', '80%', '70%']}
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||
value={settings.notification}
|
||||
options={notifications}
|
||||
onClick={openMenu}
|
||||
icon={<VolumeUp />}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||
secondary={settings.notificationVol}
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<Box p={2} width={150}>
|
||||
<Slider
|
||||
value={sliders[1] || settings.notificationVol}
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={handleSliderChange(1)}
|
||||
onChangeCommitted={() =>
|
||||
handleSettingChange('notificationVol', sliders[1])
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
</List>
|
||||
<List disablePadding subheader={<SubHeaderComp text='Appearance' />}>
|
||||
<SettingItem
|
||||
@@ -138,6 +218,41 @@ export const SettingsApp = () => {
|
||||
icon={<ZoomIn />}
|
||||
/>
|
||||
</List>
|
||||
<List
|
||||
disablePadding
|
||||
subheader={<SubHeaderComp text={t('APPS_TWITTER')} />}
|
||||
>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||
value={settings.TWITTER_notification}
|
||||
options={twitterNotifications}
|
||||
onClick={openMenu}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||
secondary={settings.TWITTER_notificationVol}
|
||||
/>
|
||||
|
||||
<ListItemSecondaryAction>
|
||||
<Box p={2} width={150}>
|
||||
<Slider
|
||||
value={sliders[2] || settings.TWITTER_notificationVol}
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={handleSliderChange(2)}
|
||||
onChangeCommitted={() =>
|
||||
handleSettingChange('TWITTER_notificationVol', sliders[2])
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
</List>
|
||||
</AppContent>
|
||||
<ContextMenu />
|
||||
</AppWrapper>
|
||||
|
||||
@@ -22,13 +22,18 @@ export const settingsState = atom({
|
||||
effects_UNSTABLE: [localStorageEffect('settings')],
|
||||
});
|
||||
|
||||
interface IPhoneSettings {
|
||||
export interface IPhoneSettings {
|
||||
wallpaper: string;
|
||||
frame: string;
|
||||
theme: string;
|
||||
zoom: number;
|
||||
ringtone: string;
|
||||
ringtoneVol: number;
|
||||
notification: string;
|
||||
notificationVol: number;
|
||||
TWITTER_notification: string;
|
||||
TWITTER_notificationVol: number;
|
||||
TWITTER_notifyNewFeedTweet: boolean;
|
||||
}
|
||||
|
||||
export const useSettings = () => {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export const getRingtonePath = (name?: string) =>
|
||||
`./media/ringtones/${name || 'pixel'}.ogg`;
|
||||
|
||||
export const getNotificationPath = (name?: string) =>
|
||||
`./media/notifications/${name || 'online'}.ogg`;
|
||||
@@ -190,5 +190,5 @@ InjectDebugData(
|
||||
},
|
||||
},
|
||||
],
|
||||
2000
|
||||
3000
|
||||
);
|
||||
@@ -48,6 +48,7 @@ const useStyles = makeStyles(() => ({
|
||||
},
|
||||
message: {
|
||||
fontSize: '18px',
|
||||
wordBreak: 'break-all',
|
||||
},
|
||||
buttonContainer: {
|
||||
display: 'flex',
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { useRecoilState } from "recoil";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { useNotifications } from "../../../os/notifications/hooks/useNotifications";
|
||||
import { twitterState } from "./state";
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { useNotifications } from '../../../os/notifications/hooks/useNotifications';
|
||||
import { twitterState } from './state';
|
||||
|
||||
export const useTwitterNotifications = () => {
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
|
||||
const { addNotificationAlert } = useNotifications();
|
||||
|
||||
const { icon, notificationIcon } = useApp('TWITTER');
|
||||
const [unreadCount, setUnreadCount] = useRecoilState(twitterState.unreadTweetsCount);
|
||||
|
||||
const [unreadCount, setUnreadCount] = useRecoilState(
|
||||
twitterState.unreadTweetsCount
|
||||
);
|
||||
|
||||
const setNotification = useCallback(
|
||||
({ profile_name, message }) => {
|
||||
setUnreadCount((curr) => {
|
||||
@@ -19,6 +25,7 @@ export const useTwitterNotifications = () => {
|
||||
addNotificationAlert(
|
||||
{
|
||||
app: 'TWITTER',
|
||||
sound: true,
|
||||
title: t('APPS_TWITTER_NEW_BROADCAST', { profile_name }),
|
||||
onClick: () => history.push('/twitter'),
|
||||
content: message,
|
||||
@@ -39,5 +46,5 @@ export const useTwitterNotifications = () => {
|
||||
[setUnreadCount, addNotificationAlert, t, icon, notificationIcon, history]
|
||||
);
|
||||
|
||||
return { setNotification, setUnreadCount, unreadCount }
|
||||
return { setNotification, setUnreadCount, unreadCount };
|
||||
};
|
||||
Reference in new issue
Block a user