mirror of
https://github.com/Michatec/Radio.git
synced 2026-11-16 21:36:53 +01:00
feat(binding): implement view binding across multiple fragments and dialogs
This commit is contained in:
1 parent
79e79b3811
commit
41d46de4b8
15 files changed
+373
-426
No files matched your search
@@ -23,6 +23,7 @@ android {
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
viewBinding = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -6,9 +6,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.ProgressBar
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
@@ -17,10 +15,9 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import com.michatec.radio.collection.CollectionViewModel
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.databinding.DialogFindStationBinding
|
||||
import com.michatec.radio.helpers.CollectionHelper
|
||||
import com.michatec.radio.helpers.NetworkHelper
|
||||
import com.michatec.radio.search.DirectInputCheck
|
||||
@@ -38,13 +35,9 @@ class AddStationFragment : Fragment(),
|
||||
RadioBrowserSearch.RadioBrowserSearchListener,
|
||||
DirectInputCheck.DirectInputCheckListener {
|
||||
|
||||
private var _binding: DialogFindStationBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
private lateinit var collectionViewModel: CollectionViewModel
|
||||
private lateinit var stationSearchBoxView: SearchView
|
||||
private lateinit var searchRequestProgressIndicator: ProgressBar
|
||||
private lateinit var noSearchResultsTextView: MaterialTextView
|
||||
private lateinit var stationSearchResultList: RecyclerView
|
||||
private lateinit var positiveButton: Button
|
||||
private lateinit var negativeButton: Button
|
||||
private lateinit var searchResultAdapter: SearchResultAdapter
|
||||
private lateinit var radioBrowserSearch: RadioBrowserSearch
|
||||
private lateinit var directInputCheck: DirectInputCheck
|
||||
@@ -56,32 +49,25 @@ class AddStationFragment : Fragment(),
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
// We reuse the dialog layout as it's already optimized for TV in layout-television
|
||||
val view = inflater.inflate(R.layout.dialog_find_station, container, false)
|
||||
_binding = DialogFindStationBinding.inflate(inflater, container, false)
|
||||
|
||||
collectionViewModel = ViewModelProvider(requireActivity())[CollectionViewModel::class.java]
|
||||
radioBrowserSearch = RadioBrowserSearch(this)
|
||||
directInputCheck = DirectInputCheck(this)
|
||||
|
||||
stationSearchBoxView = view.findViewById(R.id.station_search_box_view)
|
||||
searchRequestProgressIndicator = view.findViewById(R.id.search_request_progress_indicator)
|
||||
stationSearchResultList = view.findViewById(R.id.station_search_result_list)
|
||||
noSearchResultsTextView = view.findViewById(R.id.no_results_text_view)
|
||||
positiveButton = view.findViewById(R.id.dialog_positive_button)
|
||||
negativeButton = view.findViewById(R.id.dialog_negative_button)
|
||||
|
||||
setupRecyclerView()
|
||||
setupSearchView()
|
||||
|
||||
positiveButton.setOnClickListener {
|
||||
binding.dialogPositiveButton?.setOnClickListener {
|
||||
addStationAndExit()
|
||||
}
|
||||
|
||||
negativeButton.setOnClickListener {
|
||||
binding.dialogNegativeButton?.setOnClickListener {
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
|
||||
stationSearchBoxView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
binding.stationSearchBoxView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextChange(query: String): Boolean {
|
||||
handleSearch(query)
|
||||
return true
|
||||
@@ -92,7 +78,12 @@ class AddStationFragment : Fragment(),
|
||||
}
|
||||
})
|
||||
|
||||
return view
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -105,14 +96,14 @@ class AddStationFragment : Fragment(),
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
searchResultAdapter = SearchResultAdapter(this, listOf())
|
||||
stationSearchResultList.adapter = searchResultAdapter
|
||||
stationSearchResultList.layoutManager = LinearLayoutManager(context)
|
||||
stationSearchResultList.itemAnimator = DefaultItemAnimator()
|
||||
binding.stationSearchResultList.adapter = searchResultAdapter
|
||||
binding.stationSearchResultList.layoutManager = LinearLayoutManager(context)
|
||||
binding.stationSearchResultList.itemAnimator = DefaultItemAnimator()
|
||||
}
|
||||
|
||||
private fun setupSearchView() {
|
||||
// TV specific: ensure keyboard opens when search view gets focus
|
||||
stationSearchBoxView.setOnQueryTextFocusChangeListener { v, hasFocus ->
|
||||
binding.stationSearchBoxView.setOnQueryTextFocusChangeListener { v, hasFocus ->
|
||||
if (hasFocus) {
|
||||
// Find the internal EditText of the SearchView
|
||||
val searchEditText = v.findViewById<EditText>(androidx.appcompat.R.id.search_src_text)
|
||||
@@ -125,7 +116,7 @@ class AddStationFragment : Fragment(),
|
||||
}
|
||||
|
||||
// Make the SearchView always expanded and ready for input
|
||||
stationSearchBoxView.isIconified = false
|
||||
binding.stationSearchBoxView.isIconified = false
|
||||
}
|
||||
|
||||
private fun handleSearch(query: String) {
|
||||
@@ -165,11 +156,11 @@ class AddStationFragment : Fragment(),
|
||||
}
|
||||
|
||||
override fun activateAddButton() {
|
||||
positiveButton.isEnabled = true
|
||||
binding.dialogPositiveButton?.isEnabled = true
|
||||
}
|
||||
|
||||
override fun deactivateAddButton() {
|
||||
positiveButton.isEnabled = false
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onRadioBrowserSearchResults(results: Array<RadioBrowserResult>) {
|
||||
@@ -191,19 +182,19 @@ class AddStationFragment : Fragment(),
|
||||
}
|
||||
|
||||
private fun resetLayout(clear: Boolean) {
|
||||
positiveButton.isEnabled = false
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
if (clear) searchResultAdapter.resetSelection(true)
|
||||
}
|
||||
|
||||
private fun showProgressIndicator() {
|
||||
searchRequestProgressIndicator.isVisible = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.searchRequestProgressIndicator.isVisible = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
}
|
||||
|
||||
private fun showNoResultsError() {
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isVisible = true
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isVisible = true
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.michatec.radio
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
@@ -19,18 +18,15 @@ import androidx.core.graphics.toColorInt
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.michatec.radio.databinding.ElementColorCircleBinding
|
||||
import com.michatec.radio.databinding.FragmentCustomThemeBinding
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
import com.michatec.radio.helpers.ThemeHelper
|
||||
|
||||
class CustomThemeFragment : Fragment() {
|
||||
|
||||
private lateinit var colorPreview: View
|
||||
private lateinit var hexCode: TextInputEditText
|
||||
private lateinit var seekRed: SeekBar
|
||||
private lateinit var seekGreen: SeekBar
|
||||
private lateinit var seekBlue: SeekBar
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private var _binding: FragmentCustomThemeBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private var currentColor: Int = Color.BLACK
|
||||
private var isUpdatingFromHex = false
|
||||
@@ -49,8 +45,14 @@ class CustomThemeFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_custom_theme, container, false)
|
||||
): View {
|
||||
_binding = FragmentCustomThemeBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -58,13 +60,6 @@ class CustomThemeFragment : Fragment() {
|
||||
|
||||
(activity as? AppCompatActivity)?.supportActionBar?.title = getString(R.string.pref_custom_theme_title)
|
||||
|
||||
colorPreview = view.findViewById(R.id.color_preview)
|
||||
hexCode = view.findViewById(R.id.hex_code)
|
||||
seekRed = view.findViewById(R.id.seek_red)
|
||||
seekGreen = view.findViewById(R.id.seek_green)
|
||||
seekBlue = view.findViewById(R.id.seek_blue)
|
||||
recyclerView = view.findViewById(R.id.color_recycler_view)
|
||||
|
||||
currentColor = PreferencesHelper.loadCustomThemeColor(requireContext())
|
||||
|
||||
applyColor(currentColor)
|
||||
@@ -72,29 +67,29 @@ class CustomThemeFragment : Fragment() {
|
||||
val seekBarListener = object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
val r = seekRed.progress
|
||||
val g = seekGreen.progress
|
||||
val b = seekBlue.progress
|
||||
val r = binding.seekRed.progress
|
||||
val g = binding.seekGreen.progress
|
||||
val b = binding.seekBlue.progress
|
||||
currentColor = Color.rgb(r, g, b)
|
||||
updatePreview(currentColor)
|
||||
PreferencesHelper.saveCustomTheme(currentColor, -1)
|
||||
(recyclerView.adapter as? ColorAdapter)?.resetSelection()
|
||||
(binding.colorRecyclerView.adapter as? ColorAdapter)?.resetSelection()
|
||||
}
|
||||
}
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
|
||||
}
|
||||
|
||||
seekRed.setOnSeekBarChangeListener(seekBarListener)
|
||||
seekGreen.setOnSeekBarChangeListener(seekBarListener)
|
||||
seekBlue.setOnSeekBarChangeListener(seekBarListener)
|
||||
binding.seekRed.setOnSeekBarChangeListener(seekBarListener)
|
||||
binding.seekGreen.setOnSeekBarChangeListener(seekBarListener)
|
||||
binding.seekBlue.setOnSeekBarChangeListener(seekBarListener)
|
||||
|
||||
// Clipboard logic (Non-TV)
|
||||
if (!isAndroidTV) {
|
||||
hexCode.setOnClickListener {
|
||||
copyToClipboard(hexCode.text.toString())
|
||||
binding.hexCode.setOnClickListener {
|
||||
copyToClipboard(binding.hexCode.text.toString())
|
||||
}
|
||||
hexCode.addTextChangedListener(object : TextWatcher {
|
||||
binding.hexCode.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (!isUpdatingFromHex) {
|
||||
@@ -104,7 +99,7 @@ class CustomThemeFragment : Fragment() {
|
||||
isUpdatingFromHex = true
|
||||
applyColor(color)
|
||||
PreferencesHelper.saveCustomTheme(currentColor, -1)
|
||||
(recyclerView.adapter as? ColorAdapter)?.resetSelection()
|
||||
(binding.colorRecyclerView.adapter as? ColorAdapter)?.resetSelection()
|
||||
isUpdatingFromHex = false
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
@@ -112,44 +107,44 @@ class CustomThemeFragment : Fragment() {
|
||||
override fun afterTextChanged(s: Editable?) {}
|
||||
})
|
||||
} else {
|
||||
hexCode.isFocusable = false
|
||||
hexCode.isFocusableInTouchMode = false
|
||||
binding.hexCode.isFocusable = false
|
||||
binding.hexCode.isFocusableInTouchMode = false
|
||||
}
|
||||
|
||||
setupRecyclerView()
|
||||
}
|
||||
|
||||
private fun copyToClipboard(text: String) {
|
||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText(getString(R.string.hex_code), text)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
Toast.makeText(requireContext(), R.string.toastmessage_copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun updateSeekBars(color: Int) {
|
||||
seekRed.progress = Color.red(color)
|
||||
seekGreen.progress = Color.green(color)
|
||||
seekBlue.progress = Color.blue(color)
|
||||
binding.seekRed.progress = Color.red(color)
|
||||
binding.seekGreen.progress = Color.green(color)
|
||||
binding.seekBlue.progress = Color.blue(color)
|
||||
}
|
||||
|
||||
private fun updatePreview(color: Int) {
|
||||
colorPreview.setBackgroundColor(color)
|
||||
binding.colorPreview.setBackgroundColor(color)
|
||||
if (!isUpdatingFromHex) {
|
||||
isUpdatingFromHex = true
|
||||
hexCode.setText(String.format("#%08X", 0xFFFFFF and color))
|
||||
binding.hexCode.setText(String.format("#%08X", 0xFFFFFF and color))
|
||||
isUpdatingFromHex = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
recyclerView.layoutManager = GridLayoutManager(requireContext(), 5)
|
||||
binding.colorRecyclerView.layoutManager = GridLayoutManager(requireContext(), 5)
|
||||
val colors = ThemeHelper.getPredefinedColors(requireContext())
|
||||
val adapter = ColorAdapter(colors) { color, index ->
|
||||
currentColor = color
|
||||
applyColor(color)
|
||||
PreferencesHelper.saveCustomTheme(currentColor, index)
|
||||
}
|
||||
recyclerView.adapter = adapter
|
||||
binding.colorRecyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun copyToClipboard(text: String) {
|
||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = android.content.ClipData.newPlainText(getString(R.string.hex_code), text)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
Toast.makeText(requireContext(), R.string.toastmessage_copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private inner class ColorAdapter(
|
||||
@@ -169,12 +164,11 @@ class CustomThemeFragment : Fragment() {
|
||||
if (oldPos != -1) notifyItemChanged(oldPos)
|
||||
}
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val circle: View = view.findViewById(R.id.color_circle)
|
||||
inner class ViewHolder(val binding: ElementColorCircleBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
view.isFocusable = true
|
||||
view.isFocusableInTouchMode = isAndroidTV
|
||||
view.setOnClickListener {
|
||||
binding.root.isFocusable = true
|
||||
binding.root.isFocusableInTouchMode = isAndroidTV
|
||||
binding.root.setOnClickListener {
|
||||
val pos = bindingAdapterPosition
|
||||
if (pos != RecyclerView.NO_POSITION) {
|
||||
val oldPos = selectedPosition
|
||||
@@ -188,14 +182,18 @@ class CustomThemeFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.element_color_circle, parent, false)
|
||||
return ViewHolder(view)
|
||||
return ViewHolder(
|
||||
ElementColorCircleBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val color = colors[position]
|
||||
val drawable = holder.circle.background as GradientDrawable
|
||||
val drawable = holder.binding.colorCircle.background as GradientDrawable
|
||||
drawable.setColor(color)
|
||||
|
||||
// Set selection state
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.view.View
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
@@ -27,6 +26,7 @@ import androidx.navigation.ui.NavigationUI
|
||||
import androidx.navigation.ui.navigateUp
|
||||
import android.content.*
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.michatec.radio.databinding.ActivityMainBinding
|
||||
import com.michatec.radio.helpers.AppThemeHelper
|
||||
import com.michatec.radio.helpers.FileHelper
|
||||
import com.michatec.radio.helpers.LanguageHelper
|
||||
@@ -41,8 +41,8 @@ import java.util.Locale
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
/* Main class variables */
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||
private lateinit var mainRoot: View
|
||||
|
||||
// Check if the device running the app is an Android TV instance
|
||||
private val isAndroidTV: Boolean by lazy {
|
||||
@@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() {
|
||||
) { isGranted ->
|
||||
if (!isGranted) {
|
||||
val snackbar = Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
binding.mainRoot,
|
||||
R.string.snackbar_failed_permission_notification,
|
||||
Snackbar.LENGTH_LONG
|
||||
)
|
||||
@@ -68,7 +68,9 @@ class MainActivity : AppCompatActivity() {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
snackbar.anchorView = findViewById(R.id.bottom_sheet)
|
||||
findViewById<View>(R.id.bottom_sheet)?.let {
|
||||
snackbar.anchorView = it
|
||||
}
|
||||
snackbar.show()
|
||||
}
|
||||
}
|
||||
@@ -94,25 +96,25 @@ class MainActivity : AppCompatActivity() {
|
||||
setTheme(R.style.AppTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
// Free Android
|
||||
FreeDroidWarn.showWarningOnUpgrade(this, BuildConfig.VERSION_CODE)
|
||||
|
||||
// set up views
|
||||
setContentView(R.layout.activity_main)
|
||||
mainRoot = findViewById(R.id.main_root)
|
||||
applyCustomTheme()
|
||||
|
||||
// create .nomedia file - if not yet existing
|
||||
FileHelper.createNomediaFile(getExternalFilesDir(null))
|
||||
|
||||
// set up action bar
|
||||
setSupportActionBar(findViewById(R.id.main_toolbar))
|
||||
val toolbar: Toolbar = findViewById(R.id.main_toolbar)
|
||||
setSupportActionBar(binding.mainToolbar)
|
||||
val navHostFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.main_host_container) as NavHostFragment
|
||||
val navController = navHostFragment.navController
|
||||
appBarConfiguration = AppBarConfiguration(navController.graph)
|
||||
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration)
|
||||
NavigationUI.setupWithNavController(binding.mainToolbar, navController, appBarConfiguration)
|
||||
supportActionBar?.hide()
|
||||
|
||||
// TV-specific loading logic: Hide the overlay once the app is ready
|
||||
@@ -122,7 +124,7 @@ class MainActivity : AppCompatActivity() {
|
||||
hideLoadingOverlay()
|
||||
}, 1200)
|
||||
} else {
|
||||
findViewById<View>(R.id.loading_layout)?.visibility = View.GONE
|
||||
binding.loadingLayout.visibility = View.GONE
|
||||
}
|
||||
|
||||
// register listener for changes in shared preferences
|
||||
@@ -151,7 +153,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
/* Hides the loading/splash overlay */
|
||||
private fun hideLoadingOverlay() {
|
||||
findViewById<View>(R.id.loading_layout)?.let { overlay ->
|
||||
binding.loadingLayout.let { overlay ->
|
||||
if (overlay.isVisible) {
|
||||
overlay.animate().alpha(0f).setDuration(500)
|
||||
.withEndAction { overlay.visibility = View.GONE }
|
||||
@@ -177,12 +179,12 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
mainRoot.setBackgroundColor(color)
|
||||
binding.mainRoot.setBackgroundColor(color)
|
||||
} else {
|
||||
// Reset to default theme background color
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(android.R.attr.colorBackground, typedValue, true)
|
||||
mainRoot.setBackgroundColor(typedValue.data)
|
||||
binding.mainRoot.setBackgroundColor(typedValue.data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +208,7 @@ class MainActivity : AppCompatActivity() {
|
||||
/* Overrides onSupportNavigateUp from AppCompatActivity */
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
val navHostFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.main_host_container) as NavHostFragment
|
||||
supportFragmentManager.findFragmentById(binding.mainHostContainer.id) as NavHostFragment
|
||||
val navController = navHostFragment.navController
|
||||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||
}
|
||||
@@ -246,11 +248,13 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Keys.ACTION_REMOTE_SERVER_ERROR) {
|
||||
val snackbar = Snackbar.make(
|
||||
findViewById(R.id.main_root),
|
||||
binding.mainRoot,
|
||||
R.string.error_webserver,
|
||||
Snackbar.LENGTH_LONG
|
||||
)
|
||||
snackbar.anchorView = findViewById(R.id.bottom_sheet)
|
||||
this@MainActivity.findViewById<View>(R.id.bottom_sheet)?.let {
|
||||
snackbar.anchorView = it
|
||||
}
|
||||
snackbar.show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.michatec.radio.dialogs.AddStationDialog
|
||||
import com.michatec.radio.dialogs.FindStationDialog
|
||||
import com.michatec.radio.dialogs.YesNoDialog
|
||||
import com.michatec.radio.extensions.*
|
||||
import com.michatec.radio.databinding.FragmentPlayerBinding
|
||||
import com.michatec.radio.helpers.*
|
||||
import com.michatec.radio.ui.LayoutHolder
|
||||
import com.michatec.radio.ui.PlayerState
|
||||
@@ -85,6 +86,8 @@ class PlayerFragment : Fragment(),
|
||||
private val TAG: String = PlayerFragment::class.java.simpleName
|
||||
|
||||
/* Main class variables */
|
||||
private var _binding: FragmentPlayerBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
private lateinit var collectionViewModel: CollectionViewModel
|
||||
private lateinit var layout: LayoutHolder
|
||||
private lateinit var collectionAdapter: CollectionAdapter
|
||||
@@ -183,26 +186,31 @@ class PlayerFragment : Fragment(),
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
// find views and set them up
|
||||
val rootView: View = inflater.inflate(R.layout.fragment_player, container, false)
|
||||
layout = LayoutHolder(rootView)
|
||||
_binding = FragmentPlayerBinding.inflate(inflater, container, false)
|
||||
layout = LayoutHolder(binding)
|
||||
isSearchActive = false
|
||||
|
||||
shaderEffectView = rootView.findViewById(R.id.player_shader_effect)
|
||||
shaderEffectView = binding.playerSheet?.playerShaderEffect ?: binding.playerShaderEffect
|
||||
initializeViews()
|
||||
|
||||
// hide action bar
|
||||
(activity as AppCompatActivity).supportActionBar?.hide()
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(layout.rootView) { v, insets ->
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.updatePadding(bottom = systemBars.bottom)
|
||||
v.updatePadding(top = systemBars.top, bottom = systemBars.bottom)
|
||||
insets
|
||||
}
|
||||
// associate the ItemTouchHelper with the RecyclerView
|
||||
itemTouchHelper = ItemTouchHelper(ItemTouchHelperCallback())
|
||||
itemTouchHelper?.attachToRecyclerView(layout.recyclerView)
|
||||
itemTouchHelper?.attachToRecyclerView(binding.stationList)
|
||||
|
||||
return rootView
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,12 +9,8 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.Group
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
@@ -23,19 +19,31 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.michatec.radio.Keys
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.core.Collection
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.helpers.*
|
||||
import kotlinx.coroutines.*
|
||||
import com.michatec.radio.databinding.CardAddNewStationBinding
|
||||
import com.michatec.radio.databinding.CardStationBinding
|
||||
import com.michatec.radio.helpers.CollectionHelper
|
||||
import com.michatec.radio.helpers.FileHelper
|
||||
import com.michatec.radio.helpers.ImageHelper
|
||||
import com.michatec.radio.helpers.NetworkHelper
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
import com.michatec.radio.helpers.ShortcutHelper
|
||||
import com.michatec.radio.helpers.UiHelper
|
||||
import com.michatec.radio.helpers.UpdateHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import java.util.*
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.Collections
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
/*
|
||||
@@ -94,16 +102,22 @@ class CollectionAdapter(
|
||||
|
||||
return when (viewType) {
|
||||
Keys.VIEW_TYPE_ADD_NEW -> {
|
||||
// get view, put view into holder and return
|
||||
val v = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.card_add_new_station, parent, false)
|
||||
AddNewViewHolder(v)
|
||||
AddNewViewHolder(
|
||||
CardAddNewStationBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
// get view, put view into holder and return
|
||||
val v = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.card_station, parent, false)
|
||||
StationViewHolder(v)
|
||||
StationViewHolder(
|
||||
CardStationBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,22 +205,21 @@ class CollectionAdapter(
|
||||
when (holder) {
|
||||
// CASE ADD NEW CARD
|
||||
is AddNewViewHolder -> {
|
||||
// get reference to StationViewHolder
|
||||
val addNewViewHolder: AddNewViewHolder = holder
|
||||
addNewViewHolder.addNewStationView.setOnClickListener {
|
||||
val binding = holder.binding
|
||||
binding.cardAddNewStation.setOnClickListener {
|
||||
// show the add station dialog
|
||||
collectionAdapterListener.onAddNewButtonTapped()
|
||||
}
|
||||
addNewViewHolder.settingsButtonView.setOnClickListener {
|
||||
binding.cardSettings.setOnClickListener {
|
||||
it.findNavController().navigate(R.id.settings_destination)
|
||||
}
|
||||
addNewViewHolder.visualizerButtonView.setOnClickListener {
|
||||
binding.cardVisualizer.setOnClickListener {
|
||||
it.findNavController().navigate(R.id.visualizer_destination)
|
||||
}
|
||||
addNewViewHolder.playerSearchButtonView.setOnClickListener {
|
||||
binding.playerSearchButton.setOnClickListener {
|
||||
collectionAdapterListener.onSearchButtonTapped()
|
||||
}
|
||||
addNewViewHolder.playerSearchButtonView.isVisible = collection.stations.isNotEmpty()
|
||||
binding.playerSearchButton.isVisible = collection.stations.isNotEmpty()
|
||||
}
|
||||
// CASE STATION CARD
|
||||
is StationViewHolder -> {
|
||||
@@ -225,11 +238,11 @@ class CollectionAdapter(
|
||||
setDownloadProgress(stationViewHolder, station)
|
||||
|
||||
if (reorderStationUuid == station.uuid) {
|
||||
stationViewHolder.reorderCheckbox.isVisible = true
|
||||
stationViewHolder.reorderCheckbox.isChecked = true
|
||||
stationViewHolder.binding.reorderCheckbox.isVisible = true
|
||||
stationViewHolder.binding.reorderCheckbox.isChecked = true
|
||||
} else {
|
||||
stationViewHolder.reorderCheckbox.isGone = true
|
||||
stationViewHolder.reorderCheckbox.isChecked = false
|
||||
stationViewHolder.binding.reorderCheckbox.isGone = true
|
||||
stationViewHolder.binding.reorderCheckbox.isChecked = false
|
||||
}
|
||||
|
||||
updateVisibility(stationViewHolder, station)
|
||||
@@ -251,17 +264,17 @@ class CollectionAdapter(
|
||||
|
||||
/* Sets the station name view */
|
||||
private fun setStationName(stationViewHolder: StationViewHolder, station: Station) {
|
||||
stationViewHolder.stationNameView.text = station.name
|
||||
stationViewHolder.binding.stationName.text = station.name
|
||||
}
|
||||
|
||||
|
||||
/* Sets the playback progress view */
|
||||
private fun setPlaybackProgress(stationViewHolder: StationViewHolder, station: Station) {
|
||||
if (station.bufferingProgress > 0) {
|
||||
stationViewHolder.bufferingProgress.progress = station.bufferingProgress
|
||||
stationViewHolder.bufferingProgress.isVisible = true
|
||||
stationViewHolder.binding.bufferingProgress.progress = station.bufferingProgress
|
||||
stationViewHolder.binding.bufferingProgress.isVisible = true
|
||||
} else {
|
||||
stationViewHolder.bufferingProgress.isGone = true
|
||||
stationViewHolder.binding.bufferingProgress.isGone = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,25 +282,26 @@ class CollectionAdapter(
|
||||
/* Sets the download progress view */
|
||||
private fun setDownloadProgress(stationViewHolder: StationViewHolder, station: Station) {
|
||||
if (station.downloadProgress > 0) {
|
||||
stationViewHolder.downloadProgress.progress = station.downloadProgress
|
||||
stationViewHolder.downloadProgress.isVisible = true
|
||||
stationViewHolder.binding.downloadProgress.progress = station.downloadProgress
|
||||
stationViewHolder.binding.downloadProgress.isVisible = true
|
||||
} else {
|
||||
stationViewHolder.downloadProgress.isGone = true
|
||||
stationViewHolder.binding.downloadProgress.isGone = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Sets the edit views */
|
||||
private fun setEditViews(stationViewHolder: StationViewHolder, station: Station) {
|
||||
stationViewHolder.stationNameEditView.setText(station.name, TextView.BufferType.EDITABLE)
|
||||
stationViewHolder.stationUriEditView.setText(
|
||||
val binding = stationViewHolder.binding
|
||||
binding.editStationName.setText(station.name, TextView.BufferType.EDITABLE)
|
||||
binding.editStreamUri.setText(
|
||||
station.getStreamUri(),
|
||||
TextView.BufferType.EDITABLE
|
||||
)
|
||||
|
||||
// Remove existing TextWatcher to prevent leaks and redundant updates
|
||||
stationViewHolder.textWatcher?.let {
|
||||
stationViewHolder.stationUriEditView.removeTextChangedListener(it)
|
||||
binding.editStreamUri.removeTextChangedListener(it)
|
||||
}
|
||||
|
||||
val newTextWatcher = object : TextWatcher {
|
||||
@@ -299,35 +313,35 @@ class CollectionAdapter(
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||
}
|
||||
stationViewHolder.textWatcher = newTextWatcher
|
||||
stationViewHolder.stationUriEditView.addTextChangedListener(newTextWatcher)
|
||||
binding.editStreamUri.addTextChangedListener(newTextWatcher)
|
||||
|
||||
stationViewHolder.cancelButton.setOnClickListener {
|
||||
binding.cancelButton.setOnClickListener {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
UiHelper.hideSoftKeyboard(context, stationViewHolder.stationNameEditView)
|
||||
UiHelper.hideSoftKeyboard(context, binding.editStationName)
|
||||
}
|
||||
stationViewHolder.saveButton.setOnClickListener {
|
||||
binding.saveButton.setOnClickListener {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
saveStation(
|
||||
station,
|
||||
stationViewHolder.stationNameEditView.text.toString(),
|
||||
stationViewHolder.stationUriEditView.text.toString()
|
||||
binding.editStationName.text.toString(),
|
||||
binding.editStreamUri.text.toString()
|
||||
)
|
||||
UiHelper.hideSoftKeyboard(context, stationViewHolder.stationNameEditView)
|
||||
UiHelper.hideSoftKeyboard(context, binding.editStationName)
|
||||
}
|
||||
stationViewHolder.placeOnHomeScreenButton.setOnClickListener {
|
||||
binding.placeOnHomeScreenButton.setOnClickListener {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
ShortcutHelper.placeShortcut(context, station)
|
||||
toggleEditViews(position, station.uuid)
|
||||
UiHelper.hideSoftKeyboard(context, stationViewHolder.stationNameEditView)
|
||||
UiHelper.hideSoftKeyboard(context, binding.editStationName)
|
||||
}
|
||||
stationViewHolder.stationImageChangeView.setOnClickListener {
|
||||
binding.changeImageView.setOnClickListener {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
collectionAdapterListener.onChangeImageButtonTapped(station.uuid)
|
||||
stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
UiHelper.hideSoftKeyboard(context, stationViewHolder.stationNameEditView)
|
||||
UiHelper.hideSoftKeyboard(context, binding.editStationName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,47 +391,49 @@ class CollectionAdapter(
|
||||
|
||||
/* Updates the visibility of a station's views based on its expanded state */
|
||||
private fun updateVisibility(stationViewHolder: StationViewHolder, station: Station) {
|
||||
val binding = stationViewHolder.binding
|
||||
val isExpanded = expandedStationUuid == station.uuid
|
||||
if (isExpanded) {
|
||||
stationViewHolder.stationNameView.isVisible = false
|
||||
stationViewHolder.playButtonView.isGone = true
|
||||
stationViewHolder.stationStarredView.isGone = true
|
||||
stationViewHolder.editViews.isVisible = true
|
||||
binding.stationName.isVisible = false
|
||||
binding.playbackButton.isGone = true
|
||||
binding.starredIcon.isGone = true
|
||||
binding.defaultEditViews.isVisible = true
|
||||
if (editStationStreamsEnabled) {
|
||||
stationViewHolder.stationUriEditView.isVisible = true
|
||||
stationViewHolder.stationUriEditView.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
binding.editStreamUri.isVisible = true
|
||||
binding.editStreamUri.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
} else {
|
||||
stationViewHolder.stationUriEditView.isGone = true
|
||||
stationViewHolder.stationNameEditView.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
binding.editStreamUri.isGone = true
|
||||
binding.editStationName.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
}
|
||||
// Allow internal focus
|
||||
stationViewHolder.stationCardView.descendantFocusability = ViewGroup.FOCUS_AFTER_DESCENDANTS
|
||||
binding.stationCard.descendantFocusability = ViewGroup.FOCUS_AFTER_DESCENDANTS
|
||||
} else {
|
||||
stationViewHolder.stationNameView.isVisible = true
|
||||
stationViewHolder.stationStarredView.isVisible = station.starred
|
||||
stationViewHolder.editViews.isGone = true
|
||||
stationViewHolder.stationUriEditView.isGone = true
|
||||
binding.stationName.isVisible = true
|
||||
binding.starredIcon.isVisible = station.starred
|
||||
binding.defaultEditViews.isGone = true
|
||||
binding.editStreamUri.isGone = true
|
||||
// Block internal focus
|
||||
stationViewHolder.stationCardView.descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
binding.stationCard.descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Toggles the starred icon */
|
||||
private fun setStarredIcon(stationViewHolder: StationViewHolder, station: Station) {
|
||||
val binding = stationViewHolder.binding
|
||||
val isExpanded = expandedStationUuid == station.uuid
|
||||
when (station.starred) {
|
||||
true -> {
|
||||
if (station.imageColor != -1) {
|
||||
stationViewHolder.stationStarredView.setColorFilter(station.imageColor)
|
||||
binding.starredIcon.setColorFilter(station.imageColor)
|
||||
} else {
|
||||
stationViewHolder.stationStarredView.clearColorFilter()
|
||||
binding.starredIcon.clearColorFilter()
|
||||
}
|
||||
stationViewHolder.stationStarredView.isVisible = !isExpanded
|
||||
binding.starredIcon.isVisible = !isExpanded
|
||||
}
|
||||
false -> {
|
||||
stationViewHolder.stationStarredView.clearColorFilter()
|
||||
stationViewHolder.stationStarredView.isGone = true
|
||||
binding.starredIcon.clearColorFilter()
|
||||
binding.starredIcon.isGone = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,46 +441,48 @@ class CollectionAdapter(
|
||||
|
||||
/* Sets the station image view */
|
||||
private fun setStationImage(stationViewHolder: StationViewHolder, station: Station) {
|
||||
val binding = stationViewHolder.binding
|
||||
if (station.imageColor != -1) {
|
||||
stationViewHolder.stationImageView.setBackgroundColor(station.imageColor)
|
||||
binding.stationIcon.setBackgroundColor(station.imageColor)
|
||||
}
|
||||
stationViewHolder.stationImageView.setImageBitmap(
|
||||
binding.stationIcon.setImageBitmap(
|
||||
ImageHelper.getStationImage(
|
||||
context,
|
||||
station.smallImage
|
||||
)
|
||||
)
|
||||
stationViewHolder.stationImageView.contentDescription =
|
||||
binding.stationIcon.contentDescription =
|
||||
"${context.getString(R.string.descr_player_station_image)}: ${station.name}"
|
||||
}
|
||||
|
||||
|
||||
/* Sets up a station's play and edit buttons */
|
||||
private fun setStationButtons(stationViewHolder: StationViewHolder, station: Station) {
|
||||
val binding = stationViewHolder.binding
|
||||
when (station.isPlaying) {
|
||||
true -> stationViewHolder.playButtonView.visibility = View.VISIBLE
|
||||
false -> stationViewHolder.playButtonView.visibility = View.INVISIBLE
|
||||
true -> binding.playbackButton.visibility = View.VISIBLE
|
||||
false -> binding.playbackButton.visibility = View.INVISIBLE
|
||||
}
|
||||
stationViewHolder.stationCardView.setOnClickListener {
|
||||
binding.stationCard.setOnClickListener {
|
||||
if (reorderStationUuid.isNotEmpty()) return@setOnClickListener
|
||||
if (expandedStationPosition == stationViewHolder.bindingAdapterPosition) return@setOnClickListener
|
||||
collectionAdapterListener.onPlayButtonTapped(station.uuid)
|
||||
}
|
||||
stationViewHolder.playButtonView.setOnClickListener {
|
||||
binding.playbackButton.setOnClickListener {
|
||||
collectionAdapterListener.onPlayButtonTapped(station.uuid)
|
||||
}
|
||||
stationViewHolder.stationNameView.setOnClickListener {
|
||||
binding.stationName.setOnClickListener {
|
||||
collectionAdapterListener.onPlayButtonTapped(station.uuid)
|
||||
}
|
||||
stationViewHolder.stationStarredView.setOnClickListener {
|
||||
binding.starredIcon.setOnClickListener {
|
||||
collectionAdapterListener.onPlayButtonTapped(station.uuid)
|
||||
}
|
||||
stationViewHolder.stationImageView.setOnClickListener {
|
||||
binding.stationIcon.setOnClickListener {
|
||||
collectionAdapterListener.onPlayButtonTapped(station.uuid)
|
||||
}
|
||||
|
||||
// TV improvement: Allow reordering with DPAD
|
||||
stationViewHolder.stationCardView.setOnKeyListener { _, keyCode, event ->
|
||||
binding.stationCard.setOnKeyListener { _, keyCode, event ->
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
// Reorder mode handling
|
||||
if (reorderStationUuid == station.uuid) {
|
||||
@@ -517,7 +535,7 @@ class CollectionAdapter(
|
||||
false
|
||||
}
|
||||
|
||||
stationViewHolder.playButtonView.setOnLongClickListener {
|
||||
binding.playbackButton.setOnLongClickListener {
|
||||
if (editStationsEnabled) {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
@@ -526,7 +544,7 @@ class CollectionAdapter(
|
||||
return@setOnLongClickListener false
|
||||
}
|
||||
}
|
||||
stationViewHolder.stationNameView.setOnLongClickListener {
|
||||
binding.stationName.setOnLongClickListener {
|
||||
if (editStationsEnabled) {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
@@ -535,7 +553,7 @@ class CollectionAdapter(
|
||||
return@setOnLongClickListener false
|
||||
}
|
||||
}
|
||||
stationViewHolder.stationStarredView.setOnLongClickListener {
|
||||
binding.starredIcon.setOnLongClickListener {
|
||||
if (editStationsEnabled) {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
@@ -544,7 +562,7 @@ class CollectionAdapter(
|
||||
return@setOnLongClickListener false
|
||||
}
|
||||
}
|
||||
stationViewHolder.stationImageView.setOnLongClickListener {
|
||||
binding.stationIcon.setOnLongClickListener {
|
||||
if (editStationsEnabled) {
|
||||
val position: Int = stationViewHolder.bindingAdapterPosition
|
||||
toggleEditViews(position, station.uuid)
|
||||
@@ -562,15 +580,16 @@ class CollectionAdapter(
|
||||
s: Editable?,
|
||||
streamUri: String
|
||||
) {
|
||||
val binding = stationViewHolder.binding
|
||||
if (editStationStreamsEnabled) {
|
||||
val input: String = s.toString()
|
||||
if (input == streamUri) {
|
||||
// enable save button
|
||||
stationViewHolder.saveButton.isEnabled = true
|
||||
binding.saveButton.isEnabled = true
|
||||
stationViewHolder.validationJob?.cancel()
|
||||
} else {
|
||||
// 1. disable save button
|
||||
stationViewHolder.saveButton.isEnabled = false
|
||||
binding.saveButton.isEnabled = false
|
||||
// 2. check for valid station uri - and re-enable button
|
||||
if (input.length > 10 && input.startsWith("http")) {
|
||||
// cancel previous validation job
|
||||
@@ -592,7 +611,7 @@ class CollectionAdapter(
|
||||
) {
|
||||
// re-enable save button
|
||||
withContext(Main) {
|
||||
stationViewHolder.saveButton.isEnabled = true
|
||||
binding.saveButton.isEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -790,17 +809,8 @@ class CollectionAdapter(
|
||||
/*
|
||||
* Inner class: ViewHolder for the Add New Station action
|
||||
*/
|
||||
private class AddNewViewHolder(listItemAddNewLayout: View) :
|
||||
RecyclerView.ViewHolder(listItemAddNewLayout) {
|
||||
val addNewStationView: ExtendedFloatingActionButton =
|
||||
listItemAddNewLayout.findViewById(R.id.card_add_new_station)
|
||||
val settingsButtonView: ExtendedFloatingActionButton =
|
||||
listItemAddNewLayout.findViewById(R.id.card_settings)
|
||||
val visualizerButtonView: ExtendedFloatingActionButton =
|
||||
listItemAddNewLayout.findViewById(R.id.card_visualizer)
|
||||
val playerSearchButtonView: ExtendedFloatingActionButton =
|
||||
listItemAddNewLayout.findViewById(R.id.player_search_button)
|
||||
}
|
||||
private class AddNewViewHolder(val binding: CardAddNewStationBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
/*
|
||||
* End of inner class
|
||||
*/
|
||||
@@ -809,29 +819,8 @@ class CollectionAdapter(
|
||||
/*
|
||||
* Inner class: ViewHolder for a station
|
||||
*/
|
||||
private class StationViewHolder(stationCardLayout: View) :
|
||||
RecyclerView.ViewHolder(stationCardLayout) {
|
||||
val stationCardView: MaterialCardView = stationCardLayout.findViewById(R.id.station_card)
|
||||
val stationImageView: ImageView = stationCardLayout.findViewById(R.id.station_icon)
|
||||
val stationNameView: TextView = stationCardLayout.findViewById(R.id.station_name)
|
||||
val stationStarredView: ImageView = stationCardLayout.findViewById(R.id.starred_icon)
|
||||
val reorderCheckbox: CheckBox = stationCardLayout.findViewById(R.id.reorder_checkbox)
|
||||
val bufferingProgress: ProgressBar = stationCardLayout.findViewById(R.id.buffering_progress)
|
||||
val downloadProgress: ProgressBar = stationCardLayout.findViewById(R.id.download_progress)
|
||||
|
||||
val playButtonView: ImageView = stationCardLayout.findViewById(R.id.playback_button)
|
||||
val editViews: Group = stationCardLayout.findViewById(R.id.default_edit_views)
|
||||
val stationImageChangeView: ImageView =
|
||||
stationCardLayout.findViewById(R.id.change_image_view)
|
||||
val stationNameEditView: TextInputEditText =
|
||||
stationCardLayout.findViewById(R.id.edit_station_name)
|
||||
val stationUriEditView: TextInputEditText =
|
||||
stationCardLayout.findViewById(R.id.edit_stream_uri)
|
||||
val placeOnHomeScreenButton: MaterialButton =
|
||||
stationCardLayout.findViewById(R.id.place_on_home_screen_button)
|
||||
val cancelButton: MaterialButton = stationCardLayout.findViewById(R.id.cancel_button)
|
||||
val saveButton: MaterialButton = stationCardLayout.findViewById(R.id.save_button)
|
||||
|
||||
private class StationViewHolder(val binding: CardStationBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
var textWatcher: TextWatcher? = null
|
||||
var validationJob: Job? = null
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.michatec.radio.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isGone
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.databinding.DialogAddStationBinding
|
||||
import com.michatec.radio.search.SearchResultAdapter
|
||||
|
||||
|
||||
@@ -31,10 +30,8 @@ class AddStationDialog (
|
||||
|
||||
|
||||
/* Main class variables */
|
||||
private lateinit var binding: DialogAddStationBinding
|
||||
private lateinit var dialog: AlertDialog
|
||||
private lateinit var stationSearchResultList: RecyclerView
|
||||
private var customPositiveButton: Button? = null
|
||||
private var customNegativeButton: Button? = null
|
||||
private lateinit var searchResultAdapter: SearchResultAdapter
|
||||
private var station: Station = Station()
|
||||
|
||||
@@ -55,18 +52,12 @@ class AddStationDialog (
|
||||
// set title
|
||||
builder.setTitle(R.string.dialog_add_station_title)
|
||||
|
||||
// get views
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.dialog_add_station, null)
|
||||
stationSearchResultList = view.findViewById(R.id.station_list)
|
||||
// get binding
|
||||
binding = DialogAddStationBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
// set up list of search results
|
||||
setupRecyclerView(context)
|
||||
|
||||
// find custom buttons (for TV layout)
|
||||
customPositiveButton = view.findViewById(R.id.dialog_positive_button)
|
||||
customNegativeButton = view.findViewById(R.id.dialog_negative_button)
|
||||
|
||||
// add okay ("Add") button
|
||||
builder.setPositiveButton(R.string.dialog_find_station_button_add) { _, _ ->
|
||||
// listen for click on add button
|
||||
@@ -83,29 +74,29 @@ class AddStationDialog (
|
||||
}
|
||||
|
||||
// set up custom buttons if they exist (TV layout)
|
||||
customPositiveButton?.setOnClickListener {
|
||||
binding.dialogPositiveButton?.setOnClickListener {
|
||||
listener.onAddStationDialog(station)
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
dialog.dismiss()
|
||||
}
|
||||
customNegativeButton?.setOnClickListener {
|
||||
binding.dialogNegativeButton?.setOnClickListener {
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
// set dialog view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// create and display dialog
|
||||
dialog = builder.create()
|
||||
dialog.show()
|
||||
|
||||
// handle button visibility and state
|
||||
if (customPositiveButton != null) {
|
||||
if (binding.dialogPositiveButton != null) {
|
||||
// hide default buttons if custom ones are used
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isGone = true
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).isGone = true
|
||||
customPositiveButton?.isEnabled = false
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
} else {
|
||||
// initially disable default "Add" button
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
@@ -116,28 +107,28 @@ class AddStationDialog (
|
||||
/* Sets up list of results (RecyclerView) */
|
||||
private fun setupRecyclerView(context: Context) {
|
||||
searchResultAdapter = SearchResultAdapter(this, stationList)
|
||||
stationSearchResultList.adapter = searchResultAdapter
|
||||
binding.stationList.adapter = searchResultAdapter
|
||||
val layoutManager: LinearLayoutManager = object: LinearLayoutManager(context) {
|
||||
override fun supportsPredictiveItemAnimations(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
stationSearchResultList.layoutManager = layoutManager
|
||||
stationSearchResultList.itemAnimator = DefaultItemAnimator()
|
||||
binding.stationList.layoutManager = layoutManager
|
||||
binding.stationList.itemAnimator = DefaultItemAnimator()
|
||||
}
|
||||
|
||||
|
||||
/* Implement activateAddButton to enable the "Add" button */
|
||||
override fun activateAddButton() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = true
|
||||
customPositiveButton?.isEnabled = true
|
||||
binding.dialogPositiveButton?.isEnabled = true
|
||||
}
|
||||
|
||||
|
||||
/* Implement deactivateAddButton to disable the "Add" button */
|
||||
override fun deactivateAddButton() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
customPositiveButton?.isEnabled = false
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import android.content.Context
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.databinding.DialogGenericWithDetailsBinding
|
||||
|
||||
|
||||
/*
|
||||
@@ -30,41 +30,37 @@ class ErrorDialog {
|
||||
// set title
|
||||
builder.setTitle(context.getString(errorTitle))
|
||||
|
||||
// get views
|
||||
val inflater: LayoutInflater = LayoutInflater.from(context)
|
||||
val view: View = inflater.inflate(R.layout.dialog_generic_with_details, null)
|
||||
val errorMessageView: TextView = view.findViewById(R.id.dialog_message)
|
||||
val errorDetailsLinkView: TextView = view.findViewById(R.id.dialog_details_link)
|
||||
val errorDetailsView: TextView = view.findViewById(R.id.dialog_details)
|
||||
// get binding
|
||||
val binding = DialogGenericWithDetailsBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
// set dialog view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// set detail view
|
||||
val detailsNotEmpty = errorDetails.isNotEmpty()
|
||||
// show/hide details link depending on whether details are empty or not
|
||||
errorDetailsLinkView.isVisible = detailsNotEmpty
|
||||
binding.dialogDetailsLink.isVisible = detailsNotEmpty
|
||||
|
||||
if (detailsNotEmpty) {
|
||||
// allow scrolling on details view
|
||||
errorDetailsView.movementMethod = ScrollingMovementMethod()
|
||||
binding.dialogDetails.movementMethod = ScrollingMovementMethod()
|
||||
|
||||
// show and hide details on click
|
||||
errorDetailsLinkView.setOnClickListener {
|
||||
when (errorDetailsView.visibility) {
|
||||
View.GONE -> errorDetailsView.isVisible = true
|
||||
View.VISIBLE -> errorDetailsView.isGone = true
|
||||
binding.dialogDetailsLink.setOnClickListener {
|
||||
when (binding.dialogDetails.visibility) {
|
||||
View.GONE -> binding.dialogDetails.isVisible = true
|
||||
View.VISIBLE -> binding.dialogDetails.isGone = true
|
||||
View.INVISIBLE -> {
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
// set details text view
|
||||
errorDetailsView.text = errorDetails
|
||||
binding.dialogDetails.text = errorDetails
|
||||
}
|
||||
|
||||
// set text views
|
||||
errorMessageView.text = context.getString(errorMessage)
|
||||
binding.dialogMessage.text = context.getString(errorMessage)
|
||||
|
||||
// add okay button
|
||||
builder.setPositiveButton(R.string.dialog_generic_button_okay) { _, _ ->
|
||||
|
||||
@@ -6,20 +6,17 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.ProgressBar
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import com.michatec.radio.Keys
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.databinding.DialogFindStationBinding
|
||||
import com.michatec.radio.search.DirectInputCheck
|
||||
import com.michatec.radio.search.RadioBrowserResult
|
||||
import com.michatec.radio.search.RadioBrowserSearch
|
||||
@@ -44,13 +41,8 @@ class FindStationDialog (
|
||||
|
||||
|
||||
/* Main class variables */
|
||||
private lateinit var binding: DialogFindStationBinding
|
||||
private lateinit var dialog: AlertDialog
|
||||
private lateinit var stationSearchBoxView: SearchView
|
||||
private lateinit var searchRequestProgressIndicator: ProgressBar
|
||||
private lateinit var noSearchResultsTextView: MaterialTextView
|
||||
private lateinit var stationSearchResultList: RecyclerView
|
||||
private var customPositiveButton: Button? = null
|
||||
private var customNegativeButton: Button? = null
|
||||
private lateinit var searchResultAdapter: SearchResultAdapter
|
||||
private lateinit var radioBrowserSearch: RadioBrowserSearch
|
||||
private lateinit var directInputCheck: DirectInputCheck
|
||||
@@ -65,7 +57,7 @@ class FindStationDialog (
|
||||
// hide keyboard
|
||||
val imm: InputMethodManager =
|
||||
context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(stationSearchBoxView.windowToken, 0)
|
||||
imm.hideSoftInputFromWindow(binding.stationSearchBoxView.windowToken, 0)
|
||||
// make add button clickable
|
||||
activateAddButton()
|
||||
}
|
||||
@@ -106,22 +98,13 @@ class FindStationDialog (
|
||||
// set title
|
||||
builder.setTitle(R.string.dialog_find_station_title)
|
||||
|
||||
// get views
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.dialog_find_station, null)
|
||||
stationSearchBoxView = view.findViewById(R.id.station_search_box_view)
|
||||
searchRequestProgressIndicator = view.findViewById(R.id.search_request_progress_indicator)
|
||||
stationSearchResultList = view.findViewById(R.id.station_search_result_list)
|
||||
noSearchResultsTextView = view.findViewById(R.id.no_results_text_view)
|
||||
noSearchResultsTextView.isGone = true
|
||||
// get binding
|
||||
binding = DialogFindStationBinding.inflate(LayoutInflater.from(context))
|
||||
binding.noResultsTextView.isGone = true
|
||||
|
||||
// set up list of search results
|
||||
setupRecyclerView(context)
|
||||
|
||||
// find custom buttons (for TV layout)
|
||||
customPositiveButton = view.findViewById(R.id.dialog_positive_button)
|
||||
customNegativeButton = view.findViewById(R.id.dialog_negative_button)
|
||||
|
||||
// add okay ("Add") button
|
||||
builder.setPositiveButton(R.string.dialog_find_station_button_add) { _, _ ->
|
||||
// listen for click on add button
|
||||
@@ -141,19 +124,19 @@ class FindStationDialog (
|
||||
}
|
||||
|
||||
// set up custom buttons if they exist (TV layout)
|
||||
customPositiveButton?.setOnClickListener {
|
||||
binding.dialogPositiveButton?.setOnClickListener {
|
||||
listener.onFindStationDialog(station)
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
dialog.dismiss()
|
||||
}
|
||||
customNegativeButton?.setOnClickListener {
|
||||
binding.dialogNegativeButton?.setOnClickListener {
|
||||
radioBrowserSearch.stopSearchRequest()
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
// listen for input
|
||||
stationSearchBoxView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
binding.stationSearchBoxView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextChange(query: String): Boolean {
|
||||
handleSearchBoxLiveInput(context, query)
|
||||
searchResultAdapter.stopPrePlayback()
|
||||
@@ -168,18 +151,18 @@ class FindStationDialog (
|
||||
})
|
||||
|
||||
// set dialog view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// create and display dialog
|
||||
dialog = builder.create()
|
||||
dialog.show()
|
||||
|
||||
// handle button visibility and state
|
||||
if (customPositiveButton != null) {
|
||||
if (binding.dialogPositiveButton != null) {
|
||||
// hide default buttons if custom ones are used
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isGone = true
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).isGone = true
|
||||
customPositiveButton?.isEnabled = false
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
} else {
|
||||
// initially disable default "Add" button
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
@@ -192,14 +175,14 @@ class FindStationDialog (
|
||||
/* Sets up list of results (RecyclerView) */
|
||||
private fun setupRecyclerView(context: Context) {
|
||||
searchResultAdapter = SearchResultAdapter(this, listOf())
|
||||
stationSearchResultList.adapter = searchResultAdapter
|
||||
binding.stationSearchResultList.adapter = searchResultAdapter
|
||||
val layoutManager: LinearLayoutManager = object : LinearLayoutManager(context) {
|
||||
override fun supportsPredictiveItemAnimations(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
stationSearchResultList.layoutManager = layoutManager
|
||||
stationSearchResultList.itemAnimator = DefaultItemAnimator()
|
||||
binding.stationSearchResultList.layoutManager = layoutManager
|
||||
binding.stationSearchResultList.itemAnimator = DefaultItemAnimator()
|
||||
}
|
||||
|
||||
|
||||
@@ -250,25 +233,25 @@ class FindStationDialog (
|
||||
/* Makes the "Add" button clickable */
|
||||
override fun activateAddButton() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = true
|
||||
customPositiveButton?.isEnabled = true
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.dialogPositiveButton?.isEnabled = true
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
}
|
||||
|
||||
override fun deactivateAddButton() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
customPositiveButton?.isEnabled = false
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
}
|
||||
|
||||
|
||||
/* Resets the dialog layout to default state */
|
||||
private fun resetLayout(clearAdapter: Boolean = false) {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
customPositiveButton?.isEnabled = false
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
searchResultAdapter.resetSelection(clearAdapter)
|
||||
}
|
||||
|
||||
@@ -276,18 +259,18 @@ class FindStationDialog (
|
||||
/* Display the "No Results" error - hide other unneeded views */
|
||||
private fun showNoResultsError() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
customPositiveButton?.isEnabled = false
|
||||
searchRequestProgressIndicator.isGone = true
|
||||
noSearchResultsTextView.isVisible = true
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
binding.searchRequestProgressIndicator.isGone = true
|
||||
binding.noResultsTextView.isVisible = true
|
||||
}
|
||||
|
||||
|
||||
/* Display the "No Results" error - hide other unneeded views */
|
||||
private fun showProgressIndicator() {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false
|
||||
customPositiveButton?.isEnabled = false
|
||||
searchRequestProgressIndicator.isVisible = true
|
||||
noSearchResultsTextView.isGone = true
|
||||
binding.dialogPositiveButton?.isEnabled = false
|
||||
binding.searchRequestProgressIndicator.isVisible = true
|
||||
binding.noResultsTextView.isGone = true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,10 @@ package com.michatec.radio.dialogs
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.databinding.DialogLanguageSelectionBinding
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
|
||||
|
||||
@@ -58,11 +58,7 @@ class LanguageSelectionDialog(private var languageSelectionDialogListener: Langu
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
|
||||
// inflate custom layout
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.dialog_language_selection, null)
|
||||
|
||||
// find radio group
|
||||
val radioGroup = view.findViewById<RadioGroup>(R.id.language_radio_group)
|
||||
val binding = DialogLanguageSelectionBinding.inflate(LayoutInflater.from(context))
|
||||
val currentLanguage = PreferencesHelper.loadSelectedLanguage()
|
||||
|
||||
// add radio buttons for each supported language
|
||||
@@ -74,12 +70,12 @@ class LanguageSelectionDialog(private var languageSelectionDialogListener: Langu
|
||||
textSize = if (isTelevision(context)) 20f else 16f
|
||||
setPadding(dpToPx(context, 8), dpToPx(context, 16), dpToPx(context, 16), dpToPx(context, 16))
|
||||
}
|
||||
radioGroup.addView(radioButton)
|
||||
binding.languageRadioGroup.addView(radioButton)
|
||||
}
|
||||
|
||||
// set current selection
|
||||
for (i in 0 until radioGroup.childCount) {
|
||||
val radioButton = radioGroup.getChildAt(i) as RadioButton
|
||||
for (i in 0 until binding.languageRadioGroup.childCount) {
|
||||
val radioButton = binding.languageRadioGroup.getChildAt(i) as RadioButton
|
||||
if (radioButton.tag == currentLanguage) {
|
||||
radioButton.isChecked = true
|
||||
break
|
||||
@@ -87,14 +83,14 @@ class LanguageSelectionDialog(private var languageSelectionDialogListener: Langu
|
||||
}
|
||||
|
||||
// if no language is selected, check the first one (system)
|
||||
if (radioGroup.checkedRadioButtonId == -1) {
|
||||
val firstButton = radioGroup.getChildAt(0) as RadioButton
|
||||
if (binding.languageRadioGroup.checkedRadioButtonId == -1) {
|
||||
val firstButton = binding.languageRadioGroup.getChildAt(0) as RadioButton
|
||||
firstButton.isChecked = true
|
||||
}
|
||||
|
||||
// set up radio group listener
|
||||
radioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val selectedButton = radioGroup.findViewById<RadioButton>(checkedId)
|
||||
binding.languageRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val selectedButton = binding.languageRadioGroup.findViewById<RadioButton>(checkedId)
|
||||
val selectedLanguageCode = selectedButton?.tag as? String ?: "system"
|
||||
|
||||
// save language selection to preferences
|
||||
@@ -108,7 +104,7 @@ class LanguageSelectionDialog(private var languageSelectionDialogListener: Langu
|
||||
}
|
||||
|
||||
// set custom view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// handle outside-click as cancel
|
||||
builder.setOnCancelListener {
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.michatec.radio.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RadioButton
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat.getString
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.databinding.DialogPresetSelectionBinding
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
|
||||
|
||||
@@ -31,30 +31,21 @@ class PresetSelectionDialog(private var presetSelectionDialogListener: PresetSel
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
|
||||
// inflate custom layout
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.dialog_preset_selection, null)
|
||||
|
||||
// find radio buttons
|
||||
val radioGroup = view.findViewById<android.widget.RadioGroup>(R.id.preset_radio_group)
|
||||
val radioNone = view.findViewById<RadioButton>(R.id.radio_preset_none)
|
||||
val radioRock = view.findViewById<RadioButton>(R.id.radio_preset_rock)
|
||||
val radioPop = view.findViewById<RadioButton>(R.id.radio_preset_pop)
|
||||
val radioJazz = view.findViewById<RadioButton>(R.id.radio_preset_jazz)
|
||||
val radioFlat = view.findViewById<RadioButton>(R.id.radio_preset_flat)
|
||||
val binding = DialogPresetSelectionBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
// set current selection
|
||||
val currentPreset = PreferencesHelper.loadSelectedPreset()
|
||||
when (currentPreset) {
|
||||
"" -> radioNone.isChecked = true
|
||||
getString(context, R.string.pref_preset_rock) -> radioRock.isChecked = true
|
||||
getString(context, R.string.pref_preset_pop) -> radioPop.isChecked = true
|
||||
getString(context, R.string.pref_preset_jazz) -> radioJazz.isChecked = true
|
||||
getString(context, R.string.pref_preset_flat) -> radioFlat.isChecked = true
|
||||
else -> radioNone.isChecked = true
|
||||
"" -> binding.radioPresetNone.isChecked = true
|
||||
getString(context, R.string.pref_preset_rock) -> binding.radioPresetRock.isChecked = true
|
||||
getString(context, R.string.pref_preset_pop) -> binding.radioPresetPop.isChecked = true
|
||||
getString(context, R.string.pref_preset_jazz) -> binding.radioPresetJazz.isChecked = true
|
||||
getString(context, R.string.pref_preset_flat) -> binding.radioPresetFlat.isChecked = true
|
||||
else -> binding.radioPresetNone.isChecked = true
|
||||
}
|
||||
|
||||
// set up radio group listener
|
||||
radioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding.presetRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val selectedPreset = when (checkedId) {
|
||||
R.id.radio_preset_none -> ""
|
||||
R.id.radio_preset_rock -> getString(context, R.string.pref_preset_rock)
|
||||
@@ -72,7 +63,7 @@ class PresetSelectionDialog(private var presetSelectionDialogListener: PresetSel
|
||||
}
|
||||
|
||||
// set custom view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// handle outside-click as cancel
|
||||
builder.setOnCancelListener {
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.michatec.radio.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RadioButton
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.michatec.radio.Keys
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.databinding.DialogThemeSelectionBinding
|
||||
import com.michatec.radio.helpers.AppThemeHelper
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
|
||||
@@ -33,31 +33,24 @@ class ThemeSelectionDialog(private var themeSelectionDialogListener: ThemeSelect
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
|
||||
// inflate custom layout
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val view = inflater.inflate(R.layout.dialog_theme_selection, null)
|
||||
|
||||
// find radio buttons
|
||||
val radioGroup = view.findViewById<android.widget.RadioGroup>(R.id.theme_radio_group)
|
||||
val radioFollowSystem = view.findViewById<RadioButton>(R.id.radio_theme_follow_system)
|
||||
val radioLight = view.findViewById<RadioButton>(R.id.radio_theme_light)
|
||||
val radioDark = view.findViewById<RadioButton>(R.id.radio_theme_dark)
|
||||
val binding = DialogThemeSelectionBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
// set current selection
|
||||
val currentTheme = AppThemeHelper.getCurrentTheme(context)
|
||||
when (currentTheme) {
|
||||
context.getString(R.string.pref_theme_selection_mode_device_default) -> {
|
||||
radioFollowSystem.isChecked = true
|
||||
binding.radioThemeFollowSystem.isChecked = true
|
||||
}
|
||||
context.getString(R.string.pref_theme_selection_mode_light) -> {
|
||||
radioLight.isChecked = true
|
||||
binding.radioThemeLight.isChecked = true
|
||||
}
|
||||
context.getString(R.string.pref_theme_selection_mode_dark) -> {
|
||||
radioDark.isChecked = true
|
||||
binding.radioThemeDark.isChecked = true
|
||||
}
|
||||
}
|
||||
|
||||
// set up radio group listener
|
||||
radioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding.themeRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val selectedTheme = when (checkedId) {
|
||||
R.id.radio_theme_follow_system -> Keys.STATE_THEME_FOLLOW_SYSTEM
|
||||
R.id.radio_theme_light -> Keys.STATE_THEME_LIGHT_MODE
|
||||
@@ -75,7 +68,7 @@ class ThemeSelectionDialog(private var themeSelectionDialogListener: ThemeSelect
|
||||
}
|
||||
|
||||
// set custom view
|
||||
builder.setView(view)
|
||||
builder.setView(binding.root)
|
||||
|
||||
// handle outside-click as cancel
|
||||
builder.setOnCancelListener {
|
||||
|
||||
@@ -20,9 +20,9 @@ import androidx.media3.exoplayer.audio.AudioSink
|
||||
import androidx.media3.exoplayer.audio.DefaultAudioSink
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
import com.michatec.radio.R
|
||||
import com.michatec.radio.core.Station
|
||||
import com.michatec.radio.databinding.ElementSearchResultBinding
|
||||
import com.michatec.radio.helpers.NativeAudioProcessor
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
|
||||
@@ -51,9 +51,13 @@ class SearchResultAdapter(
|
||||
|
||||
/* Overrides onCreateViewHolder from RecyclerView.Adapter */
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val v = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.element_search_result, parent, false)
|
||||
return SearchResultViewHolder(v)
|
||||
return SearchResultViewHolder(
|
||||
ElementSearchResultBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -67,43 +71,45 @@ class SearchResultAdapter(
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
// get reference to ViewHolder
|
||||
val searchResultViewHolder: SearchResultViewHolder = holder as SearchResultViewHolder
|
||||
val binding = searchResultViewHolder.binding
|
||||
val searchResult: Station = searchResults[position]
|
||||
|
||||
// update text
|
||||
searchResultViewHolder.nameView.text = searchResult.name
|
||||
searchResultViewHolder.streamView.text = searchResult.getStreamUri()
|
||||
binding.stationName.text = searchResult.name
|
||||
binding.stationUrl.text = searchResult.getStreamUri()
|
||||
|
||||
if (searchResult.codec.isNotEmpty()) {
|
||||
if (searchResult.bitrate == 0) {
|
||||
// show only the codec when the bitrate is at "0" from radio-browser.info API
|
||||
searchResultViewHolder.bitrateView.text = searchResult.codec
|
||||
binding.stationBitrate.text = searchResult.codec
|
||||
} else {
|
||||
// show the bitrate and codec if the result is available in the radio-browser.info API
|
||||
searchResultViewHolder.bitrateView.text = buildString {
|
||||
binding.stationBitrate.text = buildString {
|
||||
append(searchResult.codec)
|
||||
append(" | ")
|
||||
append(searchResult.bitrate)
|
||||
append("kbps")}
|
||||
}
|
||||
binding.stationBitrate.visibility = View.VISIBLE
|
||||
} else {
|
||||
// do not show for M3U and PLS playlists as they do not include codec or bitrate
|
||||
searchResultViewHolder.bitrateView.visibility = View.GONE
|
||||
binding.stationBitrate.visibility = View.GONE
|
||||
}
|
||||
|
||||
// mark selected if necessary
|
||||
val isSelected = selectedPosition == holder.bindingAdapterPosition
|
||||
searchResultViewHolder.searchResultLayout.isSelected = isSelected
|
||||
binding.root.isSelected = isSelected
|
||||
|
||||
// toggle text scrolling (marquee) if necessary
|
||||
searchResultViewHolder.nameView.isSelected = isSelected
|
||||
searchResultViewHolder.streamView.isSelected = isSelected
|
||||
binding.stationName.isSelected = isSelected
|
||||
binding.stationUrl.isSelected = isSelected
|
||||
|
||||
// reduce the shadow left and right because of scrolling (Marquee)
|
||||
searchResultViewHolder.nameView.setFadingEdgeLength(10)
|
||||
searchResultViewHolder.streamView.setFadingEdgeLength(10)
|
||||
binding.stationName.setFadingEdgeLength(10)
|
||||
binding.stationUrl.setFadingEdgeLength(10)
|
||||
|
||||
// attach touch listener
|
||||
searchResultViewHolder.searchResultLayout.setOnClickListener {
|
||||
binding.root.setOnClickListener {
|
||||
// move marked position
|
||||
val previousSelectedPosition = selectedPosition
|
||||
selectedPosition = holder.bindingAdapterPosition
|
||||
@@ -120,7 +126,7 @@ class SearchResultAdapter(
|
||||
// get the selected station from searchResults
|
||||
val selectedStation = searchResults[holder.bindingAdapterPosition]
|
||||
// perform pre-playback here
|
||||
performPrePlayback(searchResultViewHolder.searchResultLayout.context, selectedStation.getStreamUri())
|
||||
performPrePlayback(binding.root.context, selectedStation.getStreamUri())
|
||||
// hand over station
|
||||
listener.onSearchResultTapped(searchResult)
|
||||
}
|
||||
@@ -284,11 +290,7 @@ class SearchResultAdapter(
|
||||
/*
|
||||
* Inner class: ViewHolder for a radio station search result
|
||||
*/
|
||||
private class SearchResultViewHolder(var searchResultLayout: View) :
|
||||
RecyclerView.ViewHolder(searchResultLayout) {
|
||||
val nameView: MaterialTextView = searchResultLayout.findViewById(R.id.station_name)
|
||||
val streamView: MaterialTextView = searchResultLayout.findViewById(R.id.station_url)
|
||||
val bitrateView: MaterialTextView = searchResultLayout.findViewById(R.id.station_bitrate)
|
||||
}
|
||||
private class SearchResultViewHolder(val binding: ElementSearchResultBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
}
|
||||
@@ -36,49 +36,51 @@ import com.michatec.radio.helpers.DateTimeHelper
|
||||
import com.michatec.radio.helpers.ImageHelper
|
||||
import com.michatec.radio.helpers.PreferencesHelper
|
||||
import com.michatec.radio.helpers.ThemeHelper
|
||||
import com.michatec.radio.helpers.UiHelper
|
||||
import com.michatec.radio.databinding.FragmentPlayerBinding
|
||||
import com.michatec.radio.helpers.*
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
/*
|
||||
* LayoutHolder class
|
||||
*/
|
||||
data class LayoutHolder(var rootView: View) {
|
||||
class LayoutHolder(binding: FragmentPlayerBinding) {
|
||||
|
||||
/* Main class variables */
|
||||
var recyclerView: RecyclerView = rootView.findViewById(R.id.station_list)
|
||||
private val rootView: View = binding.root
|
||||
var recyclerView: RecyclerView = binding.stationList
|
||||
val layoutManager: LinearLayoutManager
|
||||
var bottomSheet: ConstraintLayout? = rootView.findViewById(R.id.bottom_sheet)
|
||||
var bottomSheet: ConstraintLayout? = binding.playerSheet?.bottomSheet
|
||||
|
||||
//private var sheetMetadataViews: Group
|
||||
private var sleepTimerRunningViews: Group? = rootView.findViewById(R.id.sleep_timer_running_views)
|
||||
private var downloadProgressIndicator: ProgressBar? = rootView.findViewById(R.id.download_progress_indicator)
|
||||
private var stationImageView: ImageView? = rootView.findViewById(R.id.station_icon)
|
||||
private var shaderEffectView: ShaderEffectView? = rootView.findViewById(R.id.player_shader_effect)
|
||||
private var stationNameView: TextView? = rootView.findViewById(R.id.player_station_name)
|
||||
private var metadataView: TextView? = rootView.findViewById(R.id.player_station_metadata)
|
||||
var playButtonView: ImageButton = rootView.findViewById(R.id.player_play_button)
|
||||
var playerPrevButtonView: ImageButton? = rootView.findViewById(R.id.player_prev_button)
|
||||
var playerNextButtonView: ImageButton? = rootView.findViewById(R.id.player_next_button)
|
||||
private var bufferingIndicator: ProgressBar = rootView.findViewById(R.id.player_buffering_indicator)
|
||||
private var searchLayout: View? = rootView.findViewById(R.id.search_layout)
|
||||
var searchInputEditText: TextInputEditText? = rootView.findViewById(R.id.search_input_edit_text)
|
||||
var searchFilterFavoritesSwitch: MaterialSwitch? = rootView.findViewById(R.id.search_filter_favorites_switch)
|
||||
private var searchNoResultsView: View? = rootView.findViewById(R.id.search_no_results_view)
|
||||
private var sheetStreamingLinkHeadline: TextView? = rootView.findViewById(R.id.sheet_streaming_link_headline)
|
||||
private var sheetStreamingLinkView: TextView? = rootView.findViewById(R.id.sheet_streaming_link)
|
||||
private var sheetMetadataHistoryHeadline: TextView? = rootView.findViewById(R.id.sheet_metadata_headline)
|
||||
private var sheetMetadataHistoryView: TextView? = rootView.findViewById(R.id.sheet_metadata_history)
|
||||
private var sheetNextMetadataView: ImageButton? = rootView.findViewById(R.id.sheet_next_metadata_button)
|
||||
private var sheetPreviousMetadataView: ImageButton? = rootView.findViewById(R.id.sheet_previous_metadata_button)
|
||||
private var sheetCopyMetadataButtonView: ImageButton? = rootView.findViewById(R.id.copy_station_metadata_button)
|
||||
private var mediaRouteButton: MediaRouteButton? = rootView.findViewById(R.id.media_route_button)
|
||||
private var sheetShareLinkButtonView: ImageView? = rootView.findViewById(R.id.sheet_share_link_button)
|
||||
private var sheetBitrateView: TextView? = rootView.findViewById(R.id.sheet_bitrate_view)
|
||||
var sheetSleepTimerStartButtonView: ImageButton? = rootView.findViewById(R.id.sleep_timer_start_button)
|
||||
var sheetSleepTimerCancelButtonView: ImageButton? = rootView.findViewById(R.id.sleep_timer_cancel_button)
|
||||
private var sheetSleepTimerRemainingTimeView: TextView = rootView.findViewById(R.id.sleep_timer_remaining_time)
|
||||
private var onboardingLayout: ConstraintLayout = rootView.findViewById(R.id.onboarding_layout)
|
||||
private var sleepTimerRunningViews: Group? = binding.playerSheet?.sleepTimerRunningViews
|
||||
private var downloadProgressIndicator: ProgressBar? = binding.downloadProgressIndicator
|
||||
private var stationImageView: ImageView? = binding.playerSheet?.stationIcon ?: binding.stationIcon
|
||||
private var shaderEffectView: ShaderEffectView? = binding.playerSheet?.playerShaderEffect ?: binding.playerShaderEffect
|
||||
private var stationNameView: TextView? = binding.playerSheet?.playerStationName ?: binding.playerStationName
|
||||
private var metadataView: TextView? = binding.playerSheet?.playerStationMetadata ?: binding.playerStationMetadata
|
||||
var playButtonView: ImageButton = binding.playerSheet?.playerPlayButton ?: binding.playerPlayButton!!
|
||||
var playerPrevButtonView: ImageButton? = binding.playerPrevButton
|
||||
var playerNextButtonView: ImageButton? = binding.playerNextButton
|
||||
private var bufferingIndicator: ProgressBar = binding.playerSheet?.playerBufferingIndicator ?: binding.playerBufferingIndicator!!
|
||||
private var searchLayout: View? = binding.searchLayout
|
||||
var searchInputEditText: TextInputEditText? = binding.searchInputEditText
|
||||
var searchFilterFavoritesSwitch: MaterialSwitch? = binding.searchFilterFavoritesSwitch
|
||||
private var searchNoResultsView: View? = binding.searchNoResultsView
|
||||
private var sheetStreamingLinkHeadline: TextView? = binding.playerSheet?.sheetStreamingLinkHeadline
|
||||
private var sheetStreamingLinkView: TextView? = binding.playerSheet?.sheetStreamingLink
|
||||
private var sheetMetadataHistoryHeadline: TextView? = binding.playerSheet?.sheetMetadataHeadline
|
||||
private var sheetMetadataHistoryView: TextView? = binding.playerSheet?.sheetMetadataHistory
|
||||
private var sheetNextMetadataView: ImageButton? = binding.playerSheet?.sheetNextMetadataButton
|
||||
private var sheetPreviousMetadataView: ImageButton? = binding.playerSheet?.sheetPreviousMetadataButton
|
||||
private var sheetCopyMetadataButtonView: ImageButton? = binding.playerSheet?.copyStationMetadataButton ?: binding.copyStationMetadataButton
|
||||
private var mediaRouteButton: MediaRouteButton? = binding.playerSheet?.mediaRouteButton
|
||||
private var sheetShareLinkButtonView: ImageView? = binding.playerSheet?.sheetShareLinkButton
|
||||
private var sheetBitrateView: TextView? = binding.playerSheet?.sheetBitrateView
|
||||
var sheetSleepTimerStartButtonView: ImageButton? = binding.playerSheet?.sleepTimerStartButton ?: binding.sleepTimerStartButton
|
||||
var sheetSleepTimerCancelButtonView: ImageButton? = binding.playerSheet?.sleepTimerCancelButton ?: binding.sleepTimerCancelButton
|
||||
private var sheetSleepTimerRemainingTimeView: TextView? = binding.playerSheet?.sleepTimerRemainingTime ?: binding.sleepTimerRemainingTime
|
||||
private var onboardingLayout: ConstraintLayout = binding.root.findViewById(R.id.onboarding_layout)
|
||||
private var bottomSheetBehavior: BottomSheetBehavior<ConstraintLayout>? = bottomSheet?.let { BottomSheetBehavior.from(it) }
|
||||
private var metadataHistory: MutableList<String>
|
||||
private var metadataHistoryPosition: Int
|
||||
@@ -303,14 +305,14 @@ data class LayoutHolder(var rootView: View) {
|
||||
when (timeRemaining) {
|
||||
0L -> {
|
||||
sleepTimerRunningViews?.isGone = true
|
||||
sheetSleepTimerRemainingTimeView.isVisible = false
|
||||
sheetSleepTimerRemainingTimeView?.isVisible = false
|
||||
}
|
||||
else -> {
|
||||
sleepTimerRunningViews?.isVisible = true
|
||||
sheetSleepTimerRemainingTimeView.isVisible = true
|
||||
sheetSleepTimerRemainingTimeView?.isVisible = true
|
||||
val sleepTimerTimeRemaining = DateTimeHelper.convertToHoursMinutesSeconds(timeRemaining)
|
||||
sheetSleepTimerRemainingTimeView.text = sleepTimerTimeRemaining
|
||||
sheetSleepTimerRemainingTimeView.contentDescription = "${context.getString(R.string.descr_expanded_player_sleep_timer_remaining_time)}: $sleepTimerTimeRemaining"
|
||||
sheetSleepTimerRemainingTimeView?.text = sleepTimerTimeRemaining
|
||||
sheetSleepTimerRemainingTimeView?.contentDescription = "${context.getString(R.string.descr_expanded_player_sleep_timer_remaining_time)}: $sleepTimerTimeRemaining"
|
||||
stationNameView?.isSelected = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,9 @@
|
||||
</LinearLayout>
|
||||
|
||||
<!-- PLAYER SHEET -->
|
||||
<include layout="@layout/bottom_sheet_playback_controls" />
|
||||
<include
|
||||
android:id="@+id/player_sheet"
|
||||
layout="@layout/bottom_sheet_playback_controls" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
|
||||
Reference in new issue
Block a user