Merge pull request #1238 from davotoula/display-toast-on-media-download-start
Display toast on media download start
This commit is contained in:
@@ -28,6 +28,7 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.LinearEasing
|
import androidx.compose.animation.core.LinearEasing
|
||||||
@@ -1189,9 +1190,17 @@ fun SaveButton(onSaveClick: (localContext: Context) -> Unit) {
|
|||||||
onSaveClick(localContext)
|
onSaveClick(localContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
scope.launch {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
localContext,
|
||||||
|
stringRes(localContext, R.string.video_download_has_started_toast),
|
||||||
|
Toast.LENGTH_SHORT,
|
||||||
|
).show()
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ||
|
||||||
writeStoragePermissionState.status.isGranted
|
writeStoragePermissionState.status.isGranted
|
||||||
|
|||||||
+20
@@ -24,6 +24,7 @@ import android.Manifest
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
@@ -54,6 +55,7 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
@@ -235,10 +237,20 @@ private fun DialogContent(
|
|||||||
if (myContent !is MediaUrlContent || !myContent.url.endsWith(".m3u8")) {
|
if (myContent !is MediaUrlContent || !myContent.url.endsWith(".m3u8")) {
|
||||||
val localContext = LocalContext.current
|
val localContext = LocalContext.current
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val writeStoragePermissionState =
|
val writeStoragePermissionState =
|
||||||
rememberPermissionState(Manifest.permission.WRITE_EXTERNAL_STORAGE) { isGranted ->
|
rememberPermissionState(Manifest.permission.WRITE_EXTERNAL_STORAGE) { isGranted ->
|
||||||
if (isGranted) {
|
if (isGranted) {
|
||||||
saveMediaToGallery(myContent, localContext, accountViewModel)
|
saveMediaToGallery(myContent, localContext, accountViewModel)
|
||||||
|
scope.launch {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
localContext,
|
||||||
|
stringRes(localContext, R.string.media_download_has_started_toast),
|
||||||
|
Toast.LENGTH_SHORT,
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +261,14 @@ private fun DialogContent(
|
|||||||
writeStoragePermissionState.status.isGranted
|
writeStoragePermissionState.status.isGranted
|
||||||
) {
|
) {
|
||||||
saveMediaToGallery(myContent, localContext, accountViewModel)
|
saveMediaToGallery(myContent, localContext, accountViewModel)
|
||||||
|
scope.launch {
|
||||||
|
Toast
|
||||||
|
.makeText(
|
||||||
|
localContext,
|
||||||
|
stringRes(localContext, R.string.media_download_has_started_toast),
|
||||||
|
Toast.LENGTH_SHORT,
|
||||||
|
).show()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
writeStoragePermissionState.launchPermissionRequest()
|
writeStoragePermissionState.launchPermissionRequest()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -676,10 +676,10 @@ fun ShareImageAction(
|
|||||||
text = { Text(stringRes(R.string.add_media_to_gallery)) },
|
text = { Text(stringRes(R.string.add_media_to_gallery)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
if (videoUri != null) {
|
if (videoUri != null) {
|
||||||
var n19 = Nip19Bech32.uriToRoute(postNostrUri)?.entity as? Nip19Bech32.NEvent
|
val n19 = Nip19Bech32.uriToRoute(postNostrUri)?.entity as? Nip19Bech32.NEvent
|
||||||
if (n19 != null) {
|
if (n19 != null) {
|
||||||
accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay[0], blurhash, dim, hash, mimeType) // TODO Whole list or first?
|
accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay[0], blurhash, dim, hash, mimeType) // TODO Whole list or first?
|
||||||
accountViewModel.toast(R.string.image_saved_to_the_gallery, R.string.image_saved_to_the_gallery)
|
accountViewModel.toast(R.string.media_added, R.string.media_added_to_profile_gallery)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -905,4 +905,10 @@
|
|||||||
<string name="torrent_no_apps">Pro otevření a stažení souboru nejsou nainstalovány žádné torrent aplikace.</string>
|
<string name="torrent_no_apps">Pro otevření a stažení souboru nejsou nainstalovány žádné torrent aplikace.</string>
|
||||||
<string name="select_list_to_filter">Vyberte seznam pro filtrování kanálu</string>
|
<string name="select_list_to_filter">Vyberte seznam pro filtrování kanálu</string>
|
||||||
<string name="temporary_account">Odhlásit se na zámek zařízení</string>
|
<string name="temporary_account">Odhlásit se na zámek zařízení</string>
|
||||||
|
|
||||||
|
<string name="video_download_has_started_toast">Stahování videa bylo zahájeno…</string>
|
||||||
|
<string name="media_download_has_started_toast">Stahování médií bylo zahájeno…</string>
|
||||||
|
<string name="media_added">Média přidána</string>
|
||||||
|
<string name="media_added_to_profile_gallery">Média přidána do vaší profilové galerie</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -910,4 +910,10 @@ anz der Bedingungen ist erforderlich</string>
|
|||||||
<string name="torrent_no_apps">Keine Torrent-Apps installiert, um die Datei zu öffnen und herunterzuladen.</string>
|
<string name="torrent_no_apps">Keine Torrent-Apps installiert, um die Datei zu öffnen und herunterzuladen.</string>
|
||||||
<string name="select_list_to_filter">Liste zum Filtern des Feeds auswählen</string>
|
<string name="select_list_to_filter">Liste zum Filtern des Feeds auswählen</string>
|
||||||
<string name="temporary_account">Beim Sperren des Geräts abmelden</string>
|
<string name="temporary_account">Beim Sperren des Geräts abmelden</string>
|
||||||
|
|
||||||
|
<string name="video_download_has_started_toast">Der Videodownload wurde gestartet…</string>
|
||||||
|
<string name="media_download_has_started_toast">Der Mediendownload wurde gestartet…</string>
|
||||||
|
<string name="media_added">Medien hinzugefügt</string>
|
||||||
|
<string name="media_added_to_profile_gallery">Medien wurden zu Ihrer Profilgalerie hinzugefügt</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -905,4 +905,10 @@
|
|||||||
<string name="torrent_no_apps">Nenhum aplicativo torrent instalado para abrir e baixar o arquivo.</string>
|
<string name="torrent_no_apps">Nenhum aplicativo torrent instalado para abrir e baixar o arquivo.</string>
|
||||||
<string name="select_list_to_filter">Selecione uma lista para filtrar o feed</string>
|
<string name="select_list_to_filter">Selecione uma lista para filtrar o feed</string>
|
||||||
<string name="temporary_account">Terminar sessão no bloqueio do dispositivo</string>
|
<string name="temporary_account">Terminar sessão no bloqueio do dispositivo</string>
|
||||||
|
|
||||||
|
<string name="video_download_has_started_toast">O download do vídeo foi iniciado…</string>
|
||||||
|
<string name="media_download_has_started_toast">O download da mídia foi iniciado…</string>
|
||||||
|
<string name="media_added">Mídia adicionada</string>
|
||||||
|
<string name="media_added_to_profile_gallery">Mídia adicionada à sua Galeria de Perfil</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -904,4 +904,10 @@
|
|||||||
<string name="torrent_no_apps">Inga torrent-appar installerade för att öppna och ladda ner filen.</string>
|
<string name="torrent_no_apps">Inga torrent-appar installerade för att öppna och ladda ner filen.</string>
|
||||||
<string name="select_list_to_filter">Välj en lista för att filtrera flödet</string>
|
<string name="select_list_to_filter">Välj en lista för att filtrera flödet</string>
|
||||||
<string name="temporary_account">Logga ut när enheten låses</string>
|
<string name="temporary_account">Logga ut när enheten låses</string>
|
||||||
|
|
||||||
|
<string name="video_download_has_started_toast">Nedladdning av video har startat…</string>
|
||||||
|
<string name="media_download_has_started_toast">Nedladdning av media har startat…</string>
|
||||||
|
<string name="media_added">Media tillagd</string>
|
||||||
|
<string name="media_added_to_profile_gallery">Media har lagts till i ditt profilgalleri</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -126,6 +126,8 @@
|
|||||||
<string name="ln_url_outdated">LN URL (outdated)</string>
|
<string name="ln_url_outdated">LN URL (outdated)</string>
|
||||||
<string name="save_to_gallery">Save to Gallery</string>
|
<string name="save_to_gallery">Save to Gallery</string>
|
||||||
<string name="image_saved_to_the_gallery">Image saved to the phone\'s photo gallery</string>
|
<string name="image_saved_to_the_gallery">Image saved to the phone\'s photo gallery</string>
|
||||||
|
<string name="video_download_has_started_toast">Video download has started…</string>
|
||||||
|
<string name="media_download_has_started_toast">Media download has started…</string>
|
||||||
<string name="failed_to_save_the_image">Failed to save the image</string>
|
<string name="failed_to_save_the_image">Failed to save the image</string>
|
||||||
<string name="video_saved_to_the_gallery">Video saved to the phone\'s video gallery</string>
|
<string name="video_saved_to_the_gallery">Video saved to the phone\'s video gallery</string>
|
||||||
<string name="failed_to_save_the_video">Failed to save the video</string>
|
<string name="failed_to_save_the_video">Failed to save the video</string>
|
||||||
@@ -709,6 +711,8 @@
|
|||||||
<string name="copy_url_to_clipboard">Copy URL to clipboard</string>
|
<string name="copy_url_to_clipboard">Copy URL to clipboard</string>
|
||||||
<string name="copy_the_note_id_to_the_clipboard">Copy Note ID to clipboard</string>
|
<string name="copy_the_note_id_to_the_clipboard">Copy Note ID to clipboard</string>
|
||||||
<string name="add_media_to_gallery">Add Media to Gallery</string>
|
<string name="add_media_to_gallery">Add Media to Gallery</string>
|
||||||
|
<string name="media_added">Media added</string>
|
||||||
|
<string name="media_added_to_profile_gallery">Media added to your Profile Gallery</string>
|
||||||
|
|
||||||
<string name="created_at">Created at</string>
|
<string name="created_at">Created at</string>
|
||||||
<string name="rules">Rules</string>
|
<string name="rules">Rules</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user