Skip to content

Commit

Permalink
feat: show message when clipboard is empty (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs authored Jun 1, 2024
1 parent 68ac8a1 commit 4bfc838
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ fun MainScreen(
val clipboard = LocalClipboardManager.current
val shareTitle = stringResource(R.string.share)
val openTitle = stringResource(R.string.open)
val copiedToClipboardMessage = stringResource(R.string.clipboard_message)
val clipboardEmptyMessage = stringResource(R.string.clipboard_empty_message)
var didPerformActionAfterClean by remember(uiState.result) { mutableStateOf(false) }
val view = LocalView.current

Expand Down Expand Up @@ -166,7 +168,7 @@ fun MainScreen(
fun copyToClipboard(result: Result.Success) {
clipboard.setText(AnnotatedString(result.cleanedText))
coroutineScope.launch {
snackbarHostState.showSnackbar(context.getString(R.string.clipboard_message))
snackbarHostState.showSnackbar(copiedToClipboardMessage)
}
}

Expand Down Expand Up @@ -206,9 +208,15 @@ fun MainScreen(
isUrlDecodeEnabled = uiState.isUrlDecodeEnabled,
isExtractUrlEnabled = uiState.isExtractUrlEnabled,
onImportFromClipboardClick = {
viewModel.setText(
clipboard.getText()?.toString(),
)
val text = clipboard.getText()?.toString()

if (text.isNullOrBlank()) {
coroutineScope.launch {
snackbarHostState.showSnackbar(clipboardEmptyMessage)
}
} else {
viewModel.setText(text)
}
},
onShareClick = ::openShareMenu,
onCopyToClipboardClick = ::copyToClipboard,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="open">Öffnen</string>
<string name="copy">Kopieren</string>
<string name="clipboard_message">Link in Zwischenablage kopiert</string>
<string name="clipboard_empty_message">Zwischenablage ist leer</string>
<string name="how_to_title">Anleitung</string>
<string name="how_to_text">Wähle die App \"URL Cleaner\" beim Teilen von Text aus. Klicke anschließend in dieser App auf \"Teilen\", um den Text an die Ziel-App zu schicken. Alternativ, klicke die Schaltflächte oben, um den Inhalt aus der Zwischenablage zu importieren.</string>
<string name="cleaned_url">Gesäuberte URL</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="open">Open</string>> <!-- TODO: translate -->
<string name="copy">Kopiuj</string>
<string name="clipboard_message">Link skopiowany do schowka</string>
<string name="clipboard_empty_message">Clipboard is empty</string> <!-- TODO: translate -->
<string name="how_to_title">Jak wykonać</string>
<string name="how_to_text">When sharing text, choose \"URL Cleaner\". Then click on \"Share\" in this app to send text to target app. Alternatively, click the button above to import contents from the clipboard.</string>
<string name="cleaned_url">URL Oczyszczony</string>
Expand All @@ -40,6 +41,6 @@
<string name="action_after_clean">Action after clean</string> <!-- TODO: translate -->
<string name="do_nothing">Do nothing</string> <!-- TODO: translate -->
<string name="open_share_menu">Open share menu</string> <!-- TODO: translate -->
<string name="open_url">Open URL</string>
<string name="open_url">Open URL</string> <!-- TODO: translate -->
<string name="copy_to_clipboard">Copy to clipboard</string> <!-- TODO: translate -->
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="open">Open</string>> <!-- TODO: translate -->
<string name="copy">Копировать</string>
<string name="clipboard_message">Ссылка скопирована в буфер обмена</string>
<string name="clipboard_empty_message">Clipboard is empty</string> <!-- TODO: translate -->
<string name="how_to_title">Инструкция</string>
<string name="how_to_text">When sharing text, choose \"URL Cleaner\". Then click on \"Share\" in this app to send text to target app. Alternatively, click the button above to import contents from the clipboard.</string>
<string name="cleaned_url">Очищенный URL-адрес</string>
Expand All @@ -40,6 +41,6 @@
<string name="action_after_clean">Action after clean</string> <!-- TODO: translate -->
<string name="do_nothing">Do nothing</string> <!-- TODO: translate -->
<string name="open_share_menu">Open share menu</string> <!-- TODO: translate -->
<string name="open_url">Open URL</string>
<string name="open_url">Open URL</string> <!-- TODO: translate -->
<string name="copy_to_clipboard">Copy to clipboard</string> <!-- TODO: translate -->
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string name="open">Mở</string>
<string name="copy">Sao chép</string>
<string name="clipboard_message">Đã chép liên kết vào clipboard</string>
<string name="clipboard_empty_message">Clipboard is empty</string> <!-- TODO: translate -->
<string name="how_to_title">Cách-để</string>
<string name="how_to_text">Khi chia sẻ văn bản, chọn \"URL Cleaner\". Sau đó nhấp vào \"Chia sẻ\" trong ứng dụng này để gửi văn bản đến ứng dụng mục tiêu. Ngoài ra, hãy nhấp vào nút bên trên để nhập nội dung từ clipboard.</string>
<string name="cleaned_url">URL đã làm sạch</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string name="open">Open</string>
<string name="copy">Copy</string>
<string name="clipboard_message">Link copied to clipboard</string>
<string name="clipboard_empty_message">Clipboard is empty</string>
<string name="how_to_title">How-to</string>
<string name="how_to_text">When sharing text, choose \"URL Cleaner\". Then click on \"Share\" in this app to send text to target app. Alternatively, click the button above to import contents from the clipboard.</string>
<string name="cleaned_url">Cleaned URL</string>
Expand Down

0 comments on commit 4bfc838

Please sign in to comment.