diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/AudioPlayer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/AudioPlayer.kt index d62a3fb..dae378f 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/AudioPlayer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/AudioPlayer.kt @@ -2,7 +2,6 @@ package sushi.hardcore.droidfs.file_viewers import com.google.android.exoplayer2.ExoPlayer import sushi.hardcore.droidfs.databinding.ActivityAudioPlayerBinding -import java.io.File class AudioPlayer: MediaPlayer(){ private lateinit var binding: ActivityAudioPlayerBinding @@ -11,7 +10,6 @@ class AudioPlayer: MediaPlayer(){ binding = ActivityAudioPlayerBinding.inflate(layoutInflater) setContentView(binding.root) super.viewFile() - refreshFileName() } override fun getFileType(): String { @@ -22,17 +20,7 @@ class AudioPlayer: MediaPlayer(){ binding.audioController.player = player } - override fun onPlaylistIndexChanged() { - refreshFileName() - } - - private fun refreshFileName() { - val filename = File(filePath).name - val pos = filename.lastIndexOf('.') - binding.musicTitle.text = if (pos != -1){ - filename.substring(0,pos) - } else { - filename - } + override fun onNewFileName(fileName: String) { + binding.musicTitle.text = fileName } } \ No newline at end of file diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/MediaPlayer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/MediaPlayer.kt index 403b89f..f37ffa1 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/MediaPlayer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/MediaPlayer.kt @@ -9,6 +9,7 @@ import com.google.android.exoplayer2.video.VideoSize import sushi.hardcore.droidfs.ConstValues import sushi.hardcore.droidfs.R import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder +import java.io.File abstract class MediaPlayer: FileViewerActivity() { private lateinit var player: ExoPlayer @@ -16,10 +17,11 @@ abstract class MediaPlayer: FileViewerActivity() { override fun viewFile() { supportActionBar?.hide() initializePlayer() + refreshFileName() } abstract fun bindPlayer(player: ExoPlayer) - protected open fun onPlaylistIndexChanged() {} + abstract fun onNewFileName(fileName: String) protected open fun onVideoSizeChanged(width: Int, height: Int) {} private fun createMediaSource(filePath: String): MediaSource { @@ -60,7 +62,7 @@ abstract class MediaPlayer: FileViewerActivity() { override fun onPositionDiscontinuity(reason: Int) { if (player.currentMediaItemIndex != currentPlaylistIndex) { playlistNext(player.currentMediaItemIndex == (currentPlaylistIndex+1) % mappedPlaylist.size) - onPlaylistIndexChanged() + refreshFileName() } } }) @@ -73,4 +75,8 @@ abstract class MediaPlayer: FileViewerActivity() { player.release() } } + + private fun refreshFileName() { + onNewFileName(File(filePath).name) + } } \ No newline at end of file diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/VideoPlayer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/VideoPlayer.kt index 023f80d..ca3de08 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/VideoPlayer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/VideoPlayer.kt @@ -21,7 +21,7 @@ class VideoPlayer: MediaPlayer() { binding.videoPlayer.player = player binding.videoPlayer.doubleTapOverlay = binding.doubleTapOverlay binding.videoPlayer.setControllerVisibilityListener { visibility -> - binding.rotateButton.visibility = visibility + binding.topBar.visibility = visibility } binding.rotateButton.setOnClickListener { requestedOrientation = @@ -33,6 +33,10 @@ class VideoPlayer: MediaPlayer() { } + override fun onNewFileName(fileName: String) { + binding.textFileName.text = fileName + } + override fun getFileType(): String { return "video" } diff --git a/app/src/main/res/layout/activity_image_viewer.xml b/app/src/main/res/layout/activity_image_viewer.xml index 026ed7e..57565e2 100644 --- a/app/src/main/res/layout/activity_image_viewer.xml +++ b/app/src/main/res/layout/activity_image_viewer.xml @@ -1,7 +1,5 @@ @@ -17,8 +15,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" - android:layout_margin="20dp" - android:orientation="horizontal"> + android:layout_marginHorizontal="20dp" + android:layout_marginTop="10dp"> diff --git a/app/src/main/res/layout/activity_video_player.xml b/app/src/main/res/layout/activity_video_player.xml index caa0bb5..97163d2 100644 --- a/app/src/main/res/layout/activity_video_player.xml +++ b/app/src/main/res/layout/activity_video_player.xml @@ -1,10 +1,8 @@ - - + - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 0e7c033..1913dcb 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -11,4 +11,5 @@ 30dp 10dp 16sp + 20sp \ No newline at end of file