[Android] Fix snackbar display in Audio player + code cleanup
Nicolas Pomepuy
git at videolan.org
Thu Apr 9 09:16:11 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Apr 1 07:45:52 2020 +0200| [f38a34caaf5c7ce55a974b3245a4c5c58aa87567] | committer: Geoffrey Métais
Fix snackbar display in Audio player + code cleanup
> https://code.videolan.org/videolan/vlc-android/commit/f38a34caaf5c7ce55a974b3245a4c5c58aa87567
---
.../src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 26 +++++++---------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index dbd3cf976..7b7d03691 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -21,7 +21,9 @@
package org.videolan.vlc.gui.audio
import android.Manifest
-import android.content.*
+import android.content.Context
+import android.content.Intent
+import android.content.SharedPreferences
import android.os.Bundle
import android.os.Handler
import android.support.v4.media.session.PlaybackStateCompat
@@ -45,17 +47,13 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import com.google.android.material.bottomsheet.BottomSheetBehavior
-import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.onEach
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.*
-import org.videolan.tools.PREF_PLAYLIST_TIPS_SHOWN
-import org.videolan.tools.Settings
-import org.videolan.tools.dp
-import org.videolan.tools.putSingle
+import org.videolan.tools.*
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.R
import org.videolan.vlc.databinding.AudioPlayerBinding
@@ -353,11 +351,11 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
}
fun onNextClick(view: View) {
- if (!playlistModel.next()) Snackbar.make(binding.root, R.string.lastsong, Snackbar.LENGTH_SHORT).show()
+ if (!playlistModel.next()) UiTools.snacker(requireActivity().findViewById(android.R.id.content), R.string.lastsong)
}
fun onPreviousClick(view: View) {
- if (!playlistModel.previous()) Snackbar.make(binding.root, R.string.firstsong, Snackbar.LENGTH_SHORT).show()
+ if (!playlistModel.previous()) UiTools.snacker(requireActivity().findViewById(android.R.id.content), R.string.firstsong)
}
fun onRepeatClick(view: View) {
@@ -583,17 +581,9 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
override fun onTouchLongClick() {
val trackInfo = playlistModel.title ?: return
- val ctx = context ?: return
- val data = ClipData.newPlainText(ctx.getString(R.string.app_name), trackInfo)
- (ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
- .setPrimaryClip(data)
-
- Snackbar.make(
- binding.root,
- R.string.track_info_copied_to_clipboard,
- Snackbar.LENGTH_LONG
- ).show()
+ requireActivity().copy("VLC - song name", trackInfo)
+ UiTools.snacker(requireActivity().findViewById(android.R.id.content), R.string.track_info_copied_to_clipboard)
}
override fun onTouchDown() {}
More information about the Android
mailing list