mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Clipboard
This commit is contained in:
@ -36,7 +36,7 @@ interface SettingsFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SettingsForm = ({ dense = false }: SettingsFormProps): React.JSX.Element => {
|
const SettingsForm = ({ dense = false }: SettingsFormProps): React.JSX.Element => {
|
||||||
const { settings, setSettings, client } = useContext<UseAppStoreType>(AppContext);
|
const { settings, setSettings } = useContext<UseAppStoreType>(AppContext);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const fontSizes = [
|
const fontSizes = [
|
||||||
@ -241,7 +241,7 @@ const SettingsForm = ({ dense = false }: SettingsFormProps): React.JSX.Element =
|
|||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
{client === 'mobile' && (
|
{window.navigator.userAgent.includes('robosats') && (
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<TorIcon />
|
<TorIcon />
|
||||||
|
|||||||
@ -9,6 +9,7 @@ declare global {
|
|||||||
interface AndroidAppRobosats {
|
interface AndroidAppRobosats {
|
||||||
generateRoboname: (uuid: string, initialString: string) => void;
|
generateRoboname: (uuid: string, initialString: string) => void;
|
||||||
generateRobohash: (uuid: string, initialString: string) => void;
|
generateRobohash: (uuid: string, initialString: string) => void;
|
||||||
|
copyToClipboard: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AndroidRobosats {
|
class AndroidRobosats {
|
||||||
|
|||||||
@ -8,8 +8,10 @@ class SystemAndroidClient implements SystemClient {
|
|||||||
|
|
||||||
public loading = false;
|
public loading = false;
|
||||||
|
|
||||||
// TODO
|
// Clipboard
|
||||||
public copyToClipboard: (value: string) => void = () => {};
|
public copyToClipboard: (value: string) => void = (value) => {
|
||||||
|
window.AndroidAppRobosats?.copyToClipboard(value ?? '');
|
||||||
|
};
|
||||||
|
|
||||||
// Cookies
|
// Cookies
|
||||||
public getCookie: (key: string) => string = (key) => {
|
public getCookie: (key: string) => string = (key) => {
|
||||||
|
|||||||
@ -61,4 +61,22 @@ class WebAppInterface(private val context: Context, private val webView: WebView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
fun copyToClipboard(message: String) {
|
||||||
|
try {
|
||||||
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
|
||||||
|
val clip = android.content.ClipData.newPlainText("RoboSats Data", message)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
|
||||||
|
// Show a toast notification
|
||||||
|
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
// Log the action
|
||||||
|
Log.d(TAG, "Text copied to clipboard")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG, "Error copying to clipboard", e)
|
||||||
|
Toast.makeText(context, "Failed to copy to clipboard", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user