Reset proxy button

This commit is contained in:
koalasat
2025-08-08 15:32:26 +02:00
parent e12714ef75
commit 1abc605c03
25 changed files with 116 additions and 25 deletions

View File

@ -383,6 +383,29 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
resolvePromise(uuid, key)
}
@JavascriptInterface
fun restart() {
try {
Log.d(TAG, "Restarting app...")
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
intent?.let {
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
context.startActivity(it)
context.finish()
} ?: run {
Log.e(TAG, "Could not get launch intent for app restart")
Toast.makeText(context, "Failed to restart app", Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {
Log.e(TAG, "Error restarting app", e)
Toast.makeText(context, "Failed to restart app", Toast.LENGTH_SHORT).show()
}
}
private fun onWsMessage(path: String?, message: String?) {
val encodedMessage = encodeForJavaScript(message)
safeEvaluateJavascript("javascript:window.AndroidRobosats.onWSMessage('$path', '$encodedMessage')")

View File

@ -28,6 +28,7 @@ import {
NotificationsActive,
} from '@mui/icons-material';
import { systemClient } from '../../services/System';
import Tor from '../Icons/Tor';
interface SettingsFormProps {
dense?: boolean;
@ -262,6 +263,31 @@ const SettingsForm = ({ dense = false }: SettingsFormProps): React.JSX.Element =
</ToggleButtonGroup>
</ListItem>
)}
{client == 'mobile' && (
<ListItem>
<ListItemIcon>
<Tor />
</ListItemIcon>
<ToggleButtonGroup
exclusive={true}
sx={{ width: '100%' }}
value={settings.useProxy}
onChange={(_e, useProxy) => {
setSettings({ ...settings, useProxy });
systemClient.setItem('settings_use_proxy', String(useProxy));
systemClient.restart();
}}
>
<ToggleButton value={true} color='primary' sx={{ flexGrow: 1 }}>
{t('Orbot')}
</ToggleButton>
<ToggleButton value={false} color='secondary' sx={{ flexGrow: 1 }}>
{t('Build-in')}
</ToggleButton>
</ToggleButtonGroup>
</ListItem>
)}
</List>
</Grid>
</Grid>

View File

@ -85,31 +85,29 @@ export const LockInvoicePrompt = ({
)}
<Grid item xs={12}>
<Tooltip disableHoverListener enterTouchDelay={0} title={t('Copied!')}>
<Box
sx={{
display: 'flex',
backgroundColor: settings.lightQRs ? '#fff' : theme.palette.background.paper,
alignItems: 'center',
justifyContent: 'center',
padding: '0.5em',
borderRadius: '0.3em',
border: '1px solid',
borderColor: theme.palette.mode === 'dark' ? '#434343' : '#c4c4c4',
'&:hover': {
borderColor: theme.palette.mode === 'dark' ? '#ffffff' : '#2f2f2f',
},
}}
>
<QRCode
bgColor={'rgba(255, 255, 255, 0)'}
fgColor={settings.lightQRs ? '#000000' : theme.palette.text.primary}
value={invoice?.toUpperCase() ?? 'Undefined: BOLT11 invoice not received'}
size={theme.typography.fontSize * 21.8}
onClick={handleClickQR}
/>
</Box>
</Tooltip>
<Box
sx={{
display: 'flex',
backgroundColor: settings.lightQRs ? '#fff' : theme.palette.background.paper,
alignItems: 'center',
justifyContent: 'center',
padding: '0.5em',
borderRadius: '0.3em',
border: '1px solid',
borderColor: theme.palette.mode === 'dark' ? '#434343' : '#c4c4c4',
'&:hover': {
borderColor: theme.palette.mode === 'dark' ? '#ffffff' : '#2f2f2f',
},
}}
>
<QRCode
bgColor={'rgba(255, 255, 255, 0)'}
fgColor={settings.lightQRs ? '#000000' : theme.palette.text.primary}
value={invoice?.toUpperCase() ?? 'Undefined: BOLT11 invoice not received'}
size={theme.typography.fontSize * 21.8}
onClick={handleClickQR}
/>
</Box>
</Grid>
<Grid item xs={12}>
<Tooltip disableHoverListener enterTouchDelay={0} title={t('Copied!')}>

View File

@ -28,6 +28,7 @@ interface AndroidAppRobosats {
headers: string,
body: string,
) => void;
restart: () => void;
}
class AndroidRobosats {

View File

@ -39,6 +39,10 @@ class SystemAndroidClient implements SystemClient {
const uuid: string = uuidv4();
window.AndroidAppRobosats?.deleteEncryptedStorage(uuid, key);
};
public restart: () => void = () => {
window.AndroidAppRobosats?.restart();
};
}
export default SystemAndroidClient;

View File

@ -39,6 +39,8 @@ class SystemDesktopClient implements SystemClient {
public deleteItem: (key: string) => void = (key) => {
window.sessionStorage.removeItem(key);
};
public restart: () => void = () => {};
}
export default SystemDesktopClient;

View File

@ -45,6 +45,8 @@ class SystemWebClient implements SystemClient {
public deleteItem: (key: string) => void = (key) => {
window.localStorage.removeItem(key);
};
public restart: () => void = () => {};
}
export default SystemWebClient;

View File

@ -9,6 +9,7 @@ export interface SystemClient {
getItem: (key: string) => Promise<string | undefined>;
setItem: (key: string, value: string) => void;
deleteItem: (key: string) => void;
restart: () => void;
}
function getSystemClient(): SystemClient {

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "La teva última ordre #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Fosc",
"Light": "Clar",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Cancel order",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Vaše poslední objednávka #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Tmavé",
"Light": "Světlé",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Zrušit objednávku",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Deine letzte Bestellung #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Dunkel",
"Light": "Hell",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Bestellung stornieren",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Your last order #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Dark",
"Light": "Light",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Cancel order",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Tu última orden #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Oscuro",
"Light": "Claro",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Cancelar orden",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Zure azken eskaera #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Iluna",
"Light": "Argia",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Eskaera bertan bera utzi",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Votre dernière commande #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Sombre",
"Light": "Clair",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Annuler l'ordre",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Il tuo ultimo ordine #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Scuro",
"Light": "Chiaro",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Annulla ordine",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "前回のオーダー #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "ダーク",
"Light": "ライト",
"Mainnet": "メインネット",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "テストネット",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "注文をキャンセル",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Twoje ostatnie zamówienie #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Ciemny",
"Light": "Jasny",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Anuluj zamówienie",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Sua última ordem #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Escuro",
"Light": "Claro",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Cancelar ordem",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Ваш последний ордер #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Темный",
"Light": "Светлый",
"Mainnet": "Основная сеть",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Тестовая сеть",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Отменить ордер",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Din senaste order #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Mörk",
"Light": "Ljusa",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Avbryt beställning",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "Agizo lako la mwisho #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "Giza",
"Light": "Mwanga",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "Ghairi agizo",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "คำสั่งซื้อสุดท้ายของคุณ #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "มืด",
"Light": "สว่าง",
"Mainnet": "Mainnet",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "Testnet",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "ยกเลิกคำสั่งซื้อ",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "你的上一笔订单#{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "黑色",
"Light": "浅色",
"Mainnet": "主网",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "测试网",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "取消订单",

View File

@ -509,11 +509,13 @@
"Your last order #{{orderID}}": "您的上一筆交易 #{{orderID}}",
"#50": "Phrases in components/SettingsForm/index.tsx",
"API": "API",
"Build-in": "Build-in",
"Dark": "深色",
"Light": "淺色",
"Mainnet": "主網",
"Off": "Off",
"On": "On",
"Orbot": "Orbot",
"Testnet": "測試網",
"#51": "Phrases in components/TradeBox/CancelButton.tsx",
"Cancel order": "取消訂單",