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 { settings, setSettings, client } = useContext<UseAppStoreType>(AppContext);
|
||||
const { settings, setSettings } = useContext<UseAppStoreType>(AppContext);
|
||||
const theme = useTheme();
|
||||
const { t } = useTranslation();
|
||||
const fontSizes = [
|
||||
@ -241,7 +241,7 @@ const SettingsForm = ({ dense = false }: SettingsFormProps): React.JSX.Element =
|
||||
</ToggleButtonGroup>
|
||||
</ListItem>
|
||||
|
||||
{client === 'mobile' && (
|
||||
{window.navigator.userAgent.includes('robosats') && (
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<TorIcon />
|
||||
|
||||
@ -9,6 +9,7 @@ declare global {
|
||||
interface AndroidAppRobosats {
|
||||
generateRoboname: (uuid: string, initialString: string) => void;
|
||||
generateRobohash: (uuid: string, initialString: string) => void;
|
||||
copyToClipboard: (value: string) => void;
|
||||
}
|
||||
|
||||
class AndroidRobosats {
|
||||
|
||||
@ -8,8 +8,10 @@ class SystemAndroidClient implements SystemClient {
|
||||
|
||||
public loading = false;
|
||||
|
||||
// TODO
|
||||
public copyToClipboard: (value: string) => void = () => {};
|
||||
// Clipboard
|
||||
public copyToClipboard: (value: string) => void = (value) => {
|
||||
window.AndroidAppRobosats?.copyToClipboard(value ?? '');
|
||||
};
|
||||
|
||||
// Cookies
|
||||
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