2020-10-06 08:46:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Hemanth Savarla.
|
|
|
|
*
|
|
|
|
* Licensed under the GNU General Public License v3
|
|
|
|
*
|
|
|
|
* This is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
2019-04-20 05:29:45 +00:00
|
|
|
package code.name.monkey.retromusic.activities.tageditor
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
import android.annotation.SuppressLint
|
2018-12-06 08:52:57 +00:00
|
|
|
import android.net.Uri
|
|
|
|
import android.os.Bundle
|
2019-12-01 15:45:12 +00:00
|
|
|
import android.text.Editable
|
|
|
|
import android.text.TextWatcher
|
2021-09-08 18:30:20 +00:00
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.widget.ImageView
|
2020-02-22 12:10:12 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
2018-12-06 08:52:57 +00:00
|
|
|
import code.name.monkey.retromusic.R
|
2021-09-08 18:30:20 +00:00
|
|
|
import code.name.monkey.retromusic.databinding.ActivitySongTagEditorBinding
|
2019-07-30 21:46:50 +00:00
|
|
|
import code.name.monkey.retromusic.extensions.appHandleColor
|
2021-09-26 10:29:32 +00:00
|
|
|
import code.name.monkey.retromusic.extensions.setTint
|
2020-08-13 17:08:37 +00:00
|
|
|
import code.name.monkey.retromusic.repository.SongRepository
|
2018-12-06 08:52:57 +00:00
|
|
|
import org.jaudiotagger.tag.FieldKey
|
2020-08-13 17:08:37 +00:00
|
|
|
import org.koin.android.ext.android.inject
|
2020-10-12 17:22:53 +00:00
|
|
|
import java.util.*
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>(), TextWatcher {
|
|
|
|
|
|
|
|
override val bindingInflater: (LayoutInflater) -> ActivitySongTagEditorBinding =
|
|
|
|
ActivitySongTagEditorBinding::inflate
|
2018-12-06 08:52:57 +00:00
|
|
|
|
2019-12-01 15:45:12 +00:00
|
|
|
|
2020-08-13 17:08:37 +00:00
|
|
|
private val songRepository by inject<SongRepository>()
|
|
|
|
|
2019-12-01 15:45:12 +00:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setUpViews()
|
2021-09-08 18:30:20 +00:00
|
|
|
setNoImageMode()
|
|
|
|
binding.toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
|
|
setSupportActionBar(binding.toolbar)
|
2019-12-01 15:45:12 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2019-12-01 15:45:12 +00:00
|
|
|
private fun setUpViews() {
|
|
|
|
fillViewsWithFileTags()
|
2021-09-26 10:29:32 +00:00
|
|
|
binding.songTextContainer.setTint(false)
|
|
|
|
binding.composerContainer.setTint(false)
|
|
|
|
binding.albumTextContainer.setTint(false)
|
|
|
|
binding.artistContainer.setTint(false)
|
|
|
|
binding.albumArtistContainer.setTint(false)
|
|
|
|
binding.yearContainer.setTint(false)
|
|
|
|
binding.genreContainer.setTint(false)
|
|
|
|
binding.trackNumberContainer.setTint(false)
|
|
|
|
binding.lyricsContainer.setTint(false)
|
2021-09-08 18:30:20 +00:00
|
|
|
|
|
|
|
binding.songText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.albumText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.albumArtistText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.artistText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.genreText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.yearText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.trackNumberText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.lyricsText.appHandleColor().addTextChangedListener(this)
|
|
|
|
binding.songComposerText.appHandleColor().addTextChangedListener(this)
|
|
|
|
|
|
|
|
binding.lyricsText.setOnTouchListener { view, _ ->
|
|
|
|
view.parent.requestDisallowInterceptTouchEvent(true)
|
|
|
|
return@setOnTouchListener false
|
|
|
|
}
|
2019-12-01 15:45:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun fillViewsWithFileTags() {
|
2021-09-08 18:30:20 +00:00
|
|
|
binding.songText.setText(songTitle)
|
|
|
|
binding.albumArtistText.setText(albumArtist)
|
|
|
|
binding.albumText.setText(albumTitle)
|
|
|
|
binding.artistText.setText(artistName)
|
|
|
|
binding.genreText.setText(genreName)
|
|
|
|
binding.yearText.setText(songYear)
|
|
|
|
binding.trackNumberText.setText(trackNumber)
|
|
|
|
binding.lyricsText.setText(lyrics)
|
|
|
|
binding.songComposerText.setText(composer)
|
|
|
|
println(songTitle + songYear)
|
2019-12-01 15:45:12 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
override fun loadCurrentImage() {}
|
2019-12-01 15:45:12 +00:00
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
override fun searchImageOnWeb() {}
|
2019-12-01 15:45:12 +00:00
|
|
|
|
2021-09-08 18:30:20 +00:00
|
|
|
override fun deleteImage() {}
|
2019-12-01 15:45:12 +00:00
|
|
|
|
|
|
|
override fun save() {
|
|
|
|
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
2021-09-08 18:30:20 +00:00
|
|
|
fieldKeyValueMap[FieldKey.TITLE] = binding.songText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.ALBUM] = binding.albumText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.ARTIST] = binding.artistText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.GENRE] = binding.genreText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.YEAR] = binding.yearText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.TRACK] = binding.trackNumberText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.LYRICS] = binding.lyricsText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = binding.albumArtistText.text.toString()
|
|
|
|
fieldKeyValueMap[FieldKey.COMPOSER] = binding.songComposerText.text.toString()
|
2019-12-01 15:45:12 +00:00
|
|
|
writeValuesToFiles(fieldKeyValueMap, null)
|
|
|
|
}
|
|
|
|
|
2020-10-12 17:22:53 +00:00
|
|
|
override fun getSongPaths(): List<String> = listOf(songRepository.song(id).data)
|
2019-12-01 15:45:12 +00:00
|
|
|
|
|
|
|
override fun loadImageFromFile(selectedFile: Uri?) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun afterTextChanged(s: Editable) {
|
|
|
|
dataChanged()
|
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
|
|
|
}
|
2021-09-08 18:30:20 +00:00
|
|
|
|
|
|
|
override val editorImage: ImageView?
|
|
|
|
get() = null
|
2018-12-06 08:52:57 +00:00
|
|
|
}
|