Migrate to non transitive R class

This commit is contained in:
Naveen 2023-09-01 20:53:00 +05:30
parent 5721ccf615
commit 59b3e60832
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
38 changed files with 136 additions and 124 deletions

View file

@ -64,7 +64,11 @@ class AlbumsActivity : SimpleMusicActivity() {
val startIndex = albumTracks.indexOf(it as Track) val startIndex = albumTracks.indexOf(it as Track)
prepareAndPlay(albumTracks, startIndex) prepareAndPlay(albumTracks, startIndex)
} else { } else {
PermissionRequiredDialog(this, R.string.allow_notifications_music_player, { openNotificationSettings() }) PermissionRequiredDialog(
this,
com.simplemobiletools.commons.R.string.allow_notifications_music_player,
{ openNotificationSettings() }
)
} }
} }
} }

View file

@ -12,7 +12,6 @@ import com.simplemobiletools.commons.helpers.DARK_GREY
import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MySeekBar import com.simplemobiletools.commons.views.MySeekBar
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.databinding.ActivityEqualizerBinding import com.simplemobiletools.musicplayer.databinding.ActivityEqualizerBinding
import com.simplemobiletools.musicplayer.databinding.EqualizerBandBinding import com.simplemobiletools.musicplayer.databinding.EqualizerBandBinding
import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.config
@ -122,7 +121,7 @@ class EqualizerActivity : SimpleActivity() {
} }
private fun draggingStarted(equalizer: Equalizer) { private fun draggingStarted(equalizer: Equalizer) {
binding.equalizerPreset.text = getString(R.string.custom) binding.equalizerPreset.text = getString(com.simplemobiletools.commons.R.string.custom)
config.equalizerPreset = EQUALIZER_PRESET_CUSTOM config.equalizerPreset = EQUALIZER_PRESET_CUSTOM
for (band in 0 until equalizer.numberOfBands) { for (band in 0 until equalizer.numberOfBands) {
bands[band.toShort()] = bandSeekBars[band].progress bands[band.toShort()] = bandSeekBars[band].progress
@ -143,7 +142,7 @@ class EqualizerActivity : SimpleActivity() {
RadioItem(it, equalizer.getPresetName(it.toShort())) RadioItem(it, equalizer.getPresetName(it.toShort()))
} }
items.add(RadioItem(EQUALIZER_PRESET_CUSTOM, getString(R.string.custom))) items.add(RadioItem(EQUALIZER_PRESET_CUSTOM, getString(com.simplemobiletools.commons.R.string.custom)))
RadioGroupDialog(this, items, config.equalizerPreset) { presetId -> RadioGroupDialog(this, items, config.equalizerPreset) { presetId ->
try { try {
config.equalizerPreset = presetId as Int config.equalizerPreset = presetId as Int
@ -158,7 +157,7 @@ class EqualizerActivity : SimpleActivity() {
private fun presetChanged(presetId: Int, equalizer: Equalizer) { private fun presetChanged(presetId: Int, equalizer: Equalizer) {
if (presetId == EQUALIZER_PRESET_CUSTOM) { if (presetId == EQUALIZER_PRESET_CUSTOM) {
binding.equalizerPreset.text = getString(R.string.custom) binding.equalizerPreset.text = getString(com.simplemobiletools.commons.R.string.custom)
for (band in 0 until equalizer.numberOfBands) { for (band in 0 until equalizer.numberOfBands) {
val minValue = equalizer.bandLevelRange[0] val minValue = equalizer.bandLevelRange[0]
@ -177,7 +176,7 @@ class EqualizerActivity : SimpleActivity() {
val presetName = equalizer.getPresetName(presetId.toShort()) val presetName = equalizer.getPresetName(presetId.toShort())
if (presetName.isEmpty()) { if (presetName.isEmpty()) {
config.equalizerPreset = EQUALIZER_PRESET_CUSTOM config.equalizerPreset = EQUALIZER_PRESET_CUSTOM
binding.equalizerPreset.text = getString(R.string.custom) binding.equalizerPreset.text = getString(com.simplemobiletools.commons.R.string.custom)
} else { } else {
binding.equalizerPreset.text = presetName binding.equalizerPreset.text = presetName
} }

View file

@ -62,7 +62,7 @@ class MainActivity : SimpleMusicActivity() {
if (it) { if (it) {
initActivity() initActivity()
} else { } else {
toast(R.string.no_storage_permissions) toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
finish() finish()
} }
} }
@ -239,7 +239,7 @@ class MainActivity : SimpleMusicActivity() {
private fun setupTabs() { private fun setupTabs() {
binding.mainTabsHolder.removeAllTabs() binding.mainTabsHolder.removeAllTabs()
getVisibleTabs().forEach { value -> getVisibleTabs().forEach { value ->
binding.mainTabsHolder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { binding.mainTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply {
val tabItemBinding = BottomTablayoutItemBinding.bind(customView!!) val tabItemBinding = BottomTablayoutItemBinding.bind(customView!!)
tabItemBinding.tabItemIcon.setImageDrawable(getTabIcon(value)) tabItemBinding.tabItemIcon.setImageDrawable(getTabIcon(value))
tabItemBinding.tabItemLabel.text = getTabLabel(value) tabItemBinding.tabItemLabel.text = getTabLabel(value)
@ -282,7 +282,7 @@ class MainActivity : SimpleMusicActivity() {
val drawableId = when (position) { val drawableId = when (position) {
TAB_PLAYLISTS -> R.drawable.ic_playlist_vector TAB_PLAYLISTS -> R.drawable.ic_playlist_vector
TAB_FOLDERS -> R.drawable.ic_folders_vector TAB_FOLDERS -> R.drawable.ic_folders_vector
TAB_ARTISTS -> R.drawable.ic_person_vector TAB_ARTISTS -> com.simplemobiletools.commons.R.drawable.ic_person_vector
TAB_ALBUMS -> R.drawable.ic_album_vector TAB_ALBUMS -> R.drawable.ic_album_vector
TAB_GENRES -> R.drawable.ic_genre_vector TAB_GENRES -> R.drawable.ic_genre_vector
else -> R.drawable.ic_music_note_vector else -> R.drawable.ic_music_note_vector
@ -352,7 +352,7 @@ class MainActivity : SimpleMusicActivity() {
uri.scheme == "content" -> { uri.scheme == "content" -> {
val tempFile = getTempFile("imports", uri.path!!.getFilenameFromPath()) val tempFile = getTempFile("imports", uri.path!!.getFilenameFromPath())
if (tempFile == null) { if (tempFile == null) {
toast(R.string.unknown_error_occurred) toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
return return
} }
@ -367,7 +367,7 @@ class MainActivity : SimpleMusicActivity() {
} }
} }
else -> toast(R.string.invalid_file_format) else -> toast(com.simplemobiletools.commons.R.string.invalid_file_format)
} }
} }
@ -381,7 +381,7 @@ class MainActivity : SimpleMusicActivity() {
try { try {
startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT) startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
toast(R.string.system_service_disabled, Toast.LENGTH_LONG) toast(com.simplemobiletools.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} }
@ -415,9 +415,9 @@ class MainActivity : SimpleMusicActivity() {
runOnUiThread { runOnUiThread {
toast( toast(
when (result) { when (result) {
ImportResult.IMPORT_OK -> R.string.importing_successful ImportResult.IMPORT_OK -> com.simplemobiletools.commons.R.string.importing_successful
ImportResult.IMPORT_PARTIAL -> R.string.importing_some_entries_failed ImportResult.IMPORT_PARTIAL -> com.simplemobiletools.commons.R.string.importing_some_entries_failed
else -> R.string.importing_failed else -> com.simplemobiletools.commons.R.string.importing_failed
} }
) )
@ -428,8 +428,8 @@ class MainActivity : SimpleMusicActivity() {
} }
private fun showSleepTimer() { private fun showSleepTimer() {
val minutes = getString(R.string.minutes_raw) val minutes = getString(com.simplemobiletools.commons.R.string.minutes_raw)
val hour = resources.getQuantityString(R.plurals.hours, 1, 1) val hour = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, 1, 1)
val items = arrayListOf( val items = arrayListOf(
RadioItem(5 * 60, "5 $minutes"), RadioItem(5 * 60, "5 $minutes"),
@ -441,12 +441,12 @@ class MainActivity : SimpleMusicActivity() {
if (items.none { it.id == config.lastSleepTimerSeconds }) { if (items.none { it.id == config.lastSleepTimerSeconds }) {
val lastSleepTimerMinutes = config.lastSleepTimerSeconds / 60 val lastSleepTimerMinutes = config.lastSleepTimerSeconds / 60
val text = resources.getQuantityString(R.plurals.minutes, lastSleepTimerMinutes, lastSleepTimerMinutes) val text = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.minutes, lastSleepTimerMinutes, lastSleepTimerMinutes)
items.add(RadioItem(config.lastSleepTimerSeconds, text)) items.add(RadioItem(config.lastSleepTimerSeconds, text))
} }
items.sortBy { it.id } items.sortBy { it.id }
items.add(RadioItem(-1, getString(R.string.custom))) items.add(RadioItem(-1, getString(com.simplemobiletools.commons.R.string.custom)))
RadioGroupDialog(this, items, config.lastSleepTimerSeconds) { RadioGroupDialog(this, items, config.lastSleepTimerSeconds) {
if (it as Int == -1) { if (it as Int == -1) {
@ -527,14 +527,14 @@ class MainActivity : SimpleMusicActivity() {
val faqItems = arrayListOf( val faqItems = arrayListOf(
FAQItem(R.string.faq_1_title, R.string.faq_1_text), FAQItem(R.string.faq_1_title, R.string.faq_1_text),
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons), FAQItem(com.simplemobiletools.commons.R.string.faq_1_title_commons, com.simplemobiletools.commons.R.string.faq_1_text_commons),
FAQItem(R.string.faq_4_title_commons, R.string.faq_4_text_commons), FAQItem(com.simplemobiletools.commons.R.string.faq_4_title_commons, com.simplemobiletools.commons.R.string.faq_4_text_commons),
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons) FAQItem(com.simplemobiletools.commons.R.string.faq_9_title_commons, com.simplemobiletools.commons.R.string.faq_9_text_commons)
) )
if (!resources.getBoolean(R.bool.hide_google_relations)) { if (!resources.getBoolean(R.bool.hide_google_relations)) {
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons)) faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons))
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons)) faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons))
} }
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true) startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)

View file

@ -107,9 +107,9 @@ class SettingsActivity : SimpleControllerActivity() {
settingsShowFilename.text = getReplaceTitleText() settingsShowFilename.text = getReplaceTitleText()
settingsShowFilenameHolder.setOnClickListener { settingsShowFilenameHolder.setOnClickListener {
val items = arrayListOf( val items = arrayListOf(
RadioItem(SHOW_FILENAME_NEVER, getString(R.string.never)), RadioItem(SHOW_FILENAME_NEVER, getString(com.simplemobiletools.commons.R.string.never)),
RadioItem(SHOW_FILENAME_IF_UNAVAILABLE, getString(R.string.title_is_not_available)), RadioItem(SHOW_FILENAME_IF_UNAVAILABLE, getString(R.string.title_is_not_available)),
RadioItem(SHOW_FILENAME_ALWAYS, getString(R.string.always)) RadioItem(SHOW_FILENAME_ALWAYS, getString(com.simplemobiletools.commons.R.string.always))
) )
RadioGroupDialog(this@SettingsActivity, items, config.showFilename) { RadioGroupDialog(this@SettingsActivity, items, config.showFilename) {
@ -122,9 +122,9 @@ class SettingsActivity : SimpleControllerActivity() {
private fun getReplaceTitleText() = getString( private fun getReplaceTitleText() = getString(
when (config.showFilename) { when (config.showFilename) {
SHOW_FILENAME_NEVER -> R.string.never SHOW_FILENAME_NEVER -> com.simplemobiletools.commons.R.string.never
SHOW_FILENAME_IF_UNAVAILABLE -> R.string.title_is_not_available SHOW_FILENAME_IF_UNAVAILABLE -> R.string.title_is_not_available
else -> R.string.always else -> com.simplemobiletools.commons.R.string.always
} }
) )

View file

@ -10,7 +10,6 @@ import androidx.media3.session.MediaController
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.extensions.*
import com.simplemobiletools.musicplayer.helpers.EXTRA_NEXT_MEDIA_ID import com.simplemobiletools.musicplayer.helpers.EXTRA_NEXT_MEDIA_ID
import com.simplemobiletools.musicplayer.helpers.SimpleMediaController import com.simplemobiletools.musicplayer.helpers.SimpleMediaController
@ -117,7 +116,7 @@ abstract class SimpleControllerActivity : SimpleActivity(), Player.Listener {
EventBus.getDefault().post(Events.RefreshFragments()) EventBus.getDefault().post(Events.RefreshFragments())
callback() callback()
} else { } else {
toast(R.string.unknown_error_occurred) toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
} }
} }
} else { } else {

View file

@ -7,7 +7,6 @@ import androidx.media3.common.Player
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.openNotificationSettings import com.simplemobiletools.commons.extensions.openNotificationSettings
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.isReallyPlaying import com.simplemobiletools.musicplayer.extensions.isReallyPlaying
import com.simplemobiletools.musicplayer.extensions.togglePlayback import com.simplemobiletools.musicplayer.extensions.togglePlayback
import com.simplemobiletools.musicplayer.views.CurrentTrackBar import com.simplemobiletools.musicplayer.views.CurrentTrackBar
@ -34,7 +33,7 @@ abstract class SimpleMusicActivity : SimpleControllerActivity(), Player.Listener
startActivity(this) startActivity(this)
} }
} else { } else {
PermissionRequiredDialog(this, R.string.allow_notifications_music_player, { openNotificationSettings() }) PermissionRequiredDialog(this, com.simplemobiletools.commons.R.string.allow_notifications_music_player, { openNotificationSettings() })
} }
} }
} }

View file

@ -145,7 +145,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
if (track != null) { if (track != null) {
prepareAndPlay(listOf(track), startActivity = false) prepareAndPlay(listOf(track), startActivity = false)
} else { } else {
toast(R.string.unknown_error_occurred) toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
finish() finish()
} }
} }
@ -188,7 +188,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
binding.nextTrackLabel.text = "${getString(R.string.next_track)} ${track.title}$artist" binding.nextTrackLabel.text = "${getString(R.string.next_track)} ${track.title}$artist"
getTrackCoverArt(track) { coverArt -> getTrackCoverArt(track) { coverArt ->
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_small).toInt() val cornerRadius = resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small).toInt()
val wantedSize = resources.getDimension(R.dimen.song_image_size).toInt() val wantedSize = resources.getDimension(R.dimen.song_image_size).toInt()
// change cover image manually only once loaded successfully to avoid blinking at fails and placeholders // change cover image manually only once loaded successfully to avoid blinking at fails and placeholders
@ -252,7 +252,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
if (velocityY > 0 && velocityY > velocityX && e2.y - e1.y > SWIPE_DOWN_THRESHOLD) { if (velocityY > 0 && velocityY > velocityX && e2.y - e1.y > SWIPE_DOWN_THRESHOLD) {
finish() finish()
binding.activityTrackTopShadow.animate().alpha(0f).start() binding.activityTrackTopShadow.animate().alpha(0f).start()
overridePendingTransition(0, R.anim.slide_down) overridePendingTransition(0, com.simplemobiletools.commons.R.anim.slide_down)
} }
} }
return super.onFling(e1, e2, velocityX, velocityY) return super.onFling(e1, e2, velocityX, velocityY)

View file

@ -292,7 +292,7 @@ class TracksActivity : SimpleMusicActivity() {
if (path.isAudioFast()) { if (path.isAudioFast()) {
addTrackFromPath(path, true) addTrackFromPath(path, true)
} else { } else {
toast(R.string.invalid_file_format) toast(com.simplemobiletools.commons.R.string.invalid_file_format)
} }
} }
} }
@ -306,7 +306,7 @@ class TracksActivity : SimpleMusicActivity() {
addTrackFromPath(path, false) addTrackFromPath(path, false)
} }
} else { } else {
toast(R.string.unknown_error_occurred) toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
} }
} else { } else {
var track = audioHelper.getTrack(mediaStoreId) var track = audioHelper.getTrack(mediaStoreId)
@ -377,7 +377,7 @@ class TracksActivity : SimpleMusicActivity() {
val startIndex = tracks.indexOf(track) val startIndex = tracks.indexOf(track)
prepareAndPlay(tracks, startIndex) prepareAndPlay(tracks, startIndex)
} else { } else {
PermissionRequiredDialog(this, R.string.allow_notifications_music_player, { openNotificationSettings() }) PermissionRequiredDialog(this, com.simplemobiletools.commons.R.string.allow_notifications_music_player, { openNotificationSettings() })
} }
} }
} }
@ -393,7 +393,7 @@ class TracksActivity : SimpleMusicActivity() {
try { try {
startActivityForResult(this, PICK_EXPORT_FILE_INTENT) startActivityForResult(this, PICK_EXPORT_FILE_INTENT)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
toast(R.string.system_service_disabled, Toast.LENGTH_LONG) toast(com.simplemobiletools.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
} catch (e: Exception) { } catch (e: Exception) {
showErrorToast(e) showErrorToast(e)
} }
@ -415,16 +415,16 @@ class TracksActivity : SimpleMusicActivity() {
private fun exportPlaylistTo(outputStream: OutputStream?) { private fun exportPlaylistTo(outputStream: OutputStream?) {
val tracks = getTracksAdapter()?.items val tracks = getTracksAdapter()?.items
if (tracks.isNullOrEmpty()) { if (tracks.isNullOrEmpty()) {
toast(R.string.no_entries_for_exporting) toast(com.simplemobiletools.commons.R.string.no_entries_for_exporting)
return return
} }
M3uExporter(this).exportPlaylist(outputStream, tracks) { result -> M3uExporter(this).exportPlaylist(outputStream, tracks) { result ->
toast( toast(
when (result) { when (result) {
ExportResult.EXPORT_OK -> R.string.exporting_successful ExportResult.EXPORT_OK -> com.simplemobiletools.commons.R.string.exporting_successful
ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed ExportResult.EXPORT_PARTIAL -> com.simplemobiletools.commons.R.string.exporting_some_entries_failed
else -> R.string.exporting_failed else -> com.simplemobiletools.commons.R.string.exporting_failed
} }
) )
} }

View file

@ -53,8 +53,8 @@ class WidgetConfigureActivity : SimpleActivity() {
songInfoTitle.text = currSong.title songInfoTitle.text = currSong.title
songInfoArtist.text = currSong.artist songInfoArtist.text = currSong.artist
} else { } else {
songInfoTitle.text = getString(R.string.artist) songInfoTitle.text = getString(com.simplemobiletools.commons.R.string.artist)
songInfoArtist.text = getString(R.string.song_title) songInfoArtist.text = getString(com.simplemobiletools.commons.R.string.song_title)
} }
} }
@ -87,8 +87,8 @@ class WidgetConfigureActivity : SimpleActivity() {
} }
mTextColor = config.widgetTextColor mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) {
mTextColor = resources.getColor(R.color.you_primary_color, theme) mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
} }
updateTextColor() updateTextColor()

View file

@ -12,7 +12,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.activities.SimpleControllerActivity import com.simplemobiletools.musicplayer.activities.SimpleControllerActivity
import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.extensions.*
import com.simplemobiletools.musicplayer.helpers.TagHelper import com.simplemobiletools.musicplayer.helpers.TagHelper
@ -32,7 +31,7 @@ abstract class BaseMusicAdapter<Type>(
val tagHelper by lazy { TagHelper(ctx) } val tagHelper by lazy { TagHelper(ctx) }
val placeholder by lazy { resources.getSmallPlaceholder(textColor) } val placeholder by lazy { resources.getSmallPlaceholder(textColor) }
val placeholderBig by lazy { resources.getBiggerPlaceholder(textColor) } val placeholderBig by lazy { resources.getBiggerPlaceholder(textColor) }
open val cornerRadius by lazy { resources.getDimension(R.dimen.rounded_corner_radius_small).toInt() } open val cornerRadius by lazy { resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small).toInt() }
override fun getItemCount() = items.size override fun getItemCount() = items.size

View file

@ -11,7 +11,6 @@ import com.simplemobiletools.commons.extensions.humanizePath
import com.simplemobiletools.commons.extensions.setupViewBackground import com.simplemobiletools.commons.extensions.setupViewBackground
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.databinding.ItemExcludedFolderBinding import com.simplemobiletools.musicplayer.databinding.ItemExcludedFolderBinding
import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.config
@ -25,13 +24,13 @@ class ExcludedFoldersAdapter(
private val config = activity.config private val config = activity.config
override fun getActionMenuId() = R.menu.cab_remove_only override fun getActionMenuId() = com.simplemobiletools.commons.R.menu.cab_remove_only
override fun prepareActionMode(menu: Menu) {} override fun prepareActionMode(menu: Menu) {}
override fun actionItemPressed(id: Int) { override fun actionItemPressed(id: Int) {
when (id) { when (id) {
R.id.cab_remove -> removeSelection() com.simplemobiletools.commons.R.id.cab_remove -> removeSelection()
} }
} }
@ -95,7 +94,7 @@ class ExcludedFoldersAdapter(
setOnMenuItemClickListener { item -> setOnMenuItemClickListener { item ->
val eventTypeId = folder.hashCode() val eventTypeId = folder.hashCode()
when (item.itemId) { when (item.itemId) {
R.id.cab_remove -> { com.simplemobiletools.commons.R.id.cab_remove -> {
executeItemMenuOperation(eventTypeId) { executeItemMenuOperation(eventTypeId) {
removeSelection() removeSelection()
} }

View file

@ -107,7 +107,7 @@ class QueueAdapter(activity: SimpleActivity, items: ArrayList<Track>, var curren
} }
private fun deleteTracks() { private fun deleteTracks() {
ConfirmationDialog(ctx, "", R.string.delete_song_warning, R.string.ok, R.string.cancel) { ConfirmationDialog(ctx, "", R.string.delete_song_warning, com.simplemobiletools.commons.R.string.ok, com.simplemobiletools.commons.R.string.cancel) {
val positions = ArrayList<Int>() val positions = ArrayList<Int>()
val selectedTracks = getSelectedTracks() val selectedTracks = getSelectedTracks()
selectedTracks.forEach { track -> selectedTracks.forEach { track ->

View file

@ -28,7 +28,7 @@ class TracksHeaderAdapter(activity: SimpleActivity, items: ArrayList<ListItem>,
private val ITEM_HEADER = 0 private val ITEM_HEADER = 0
private val ITEM_TRACK = 1 private val ITEM_TRACK = 1
override val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_big).toInt() override val cornerRadius = resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big).toInt()
override fun getActionMenuId() = R.menu.cab_tracks_header override fun getActionMenuId() = R.menu.cab_tracks_header

View file

@ -29,7 +29,7 @@ class ChangeSortingDialog(val activity: Activity, val location: Int, val playlis
if (playlist != null) { if (playlist != null) {
sortingDialogUseForThisOnly.isChecked = config.hasCustomPlaylistSorting(playlist.id) sortingDialogUseForThisOnly.isChecked = config.hasCustomPlaylistSorting(playlist.id)
} else if (path != null) { } else if (path != null) {
sortingDialogUseForThisOnly.text = activity.getString(R.string.use_for_this_folder) sortingDialogUseForThisOnly.text = activity.getString(com.simplemobiletools.commons.R.string.use_for_this_folder)
sortingDialogUseForThisOnly.isChecked = config.hasCustomSorting(path) sortingDialogUseForThisOnly.isChecked = config.hasCustomSorting(path)
} }
} }
@ -54,10 +54,10 @@ class ChangeSortingDialog(val activity: Activity, val location: Int, val playlis
setupOrderRadio() setupOrderRadio()
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this, R.string.sort_by) activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by)
} }
} }
@ -65,45 +65,45 @@ class ChangeSortingDialog(val activity: Activity, val location: Int, val playlis
val radioItems = ArrayList<RadioItem>() val radioItems = ArrayList<RadioItem>()
when (location) { when (location) {
TAB_PLAYLISTS, TAB_FOLDERS -> { TAB_PLAYLISTS, TAB_FOLDERS -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(1, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT)) radioItems.add(RadioItem(1, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT))
} }
TAB_ARTISTS -> { TAB_ARTISTS -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(1, activity.getString(R.string.album_count), PLAYER_SORT_BY_ALBUM_COUNT)) radioItems.add(RadioItem(1, activity.getString(R.string.album_count), PLAYER_SORT_BY_ALBUM_COUNT))
radioItems.add(RadioItem(2, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT)) radioItems.add(RadioItem(2, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT))
} }
TAB_ALBUMS -> { TAB_ALBUMS -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(1, activity.getString(R.string.artist_name), PLAYER_SORT_BY_ARTIST_TITLE)) radioItems.add(RadioItem(1, activity.getString(R.string.artist_name), PLAYER_SORT_BY_ARTIST_TITLE))
radioItems.add(RadioItem(2, activity.getString(R.string.year), PLAYER_SORT_BY_YEAR)) radioItems.add(RadioItem(2, activity.getString(R.string.year), PLAYER_SORT_BY_YEAR))
radioItems.add(RadioItem(4, activity.getString(R.string.date_added), PLAYER_SORT_BY_DATE_ADDED)) radioItems.add(RadioItem(4, activity.getString(com.simplemobiletools.commons.R.string.date_added), PLAYER_SORT_BY_DATE_ADDED))
} }
TAB_TRACKS -> { TAB_TRACKS -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(1, activity.getString(R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) radioItems.add(RadioItem(1, activity.getString(com.simplemobiletools.commons.R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE))
radioItems.add(RadioItem(2, activity.getString(R.string.duration), PLAYER_SORT_BY_DURATION)) radioItems.add(RadioItem(2, activity.getString(com.simplemobiletools.commons.R.string.duration), PLAYER_SORT_BY_DURATION))
radioItems.add(RadioItem(3, activity.getString(R.string.track_number), PLAYER_SORT_BY_TRACK_ID)) radioItems.add(RadioItem(3, activity.getString(R.string.track_number), PLAYER_SORT_BY_TRACK_ID))
radioItems.add(RadioItem(4, activity.getString(R.string.date_added), PLAYER_SORT_BY_DATE_ADDED)) radioItems.add(RadioItem(4, activity.getString(com.simplemobiletools.commons.R.string.date_added), PLAYER_SORT_BY_DATE_ADDED))
} }
TAB_GENRES -> { TAB_GENRES -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(2, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT)) radioItems.add(RadioItem(2, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT))
} }
ACTIVITY_PLAYLIST_FOLDER -> { ACTIVITY_PLAYLIST_FOLDER -> {
radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE))
radioItems.add(RadioItem(1, activity.getString(R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) radioItems.add(RadioItem(1, activity.getString(com.simplemobiletools.commons.R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE))
radioItems.add(RadioItem(2, activity.getString(R.string.duration), PLAYER_SORT_BY_DURATION)) radioItems.add(RadioItem(2, activity.getString(com.simplemobiletools.commons.R.string.duration), PLAYER_SORT_BY_DURATION))
radioItems.add(RadioItem(3, activity.getString(R.string.track_number), PLAYER_SORT_BY_TRACK_ID)) radioItems.add(RadioItem(3, activity.getString(R.string.track_number), PLAYER_SORT_BY_TRACK_ID))
radioItems.add(RadioItem(4, activity.getString(R.string.date_added), PLAYER_SORT_BY_DATE_ADDED)) radioItems.add(RadioItem(4, activity.getString(com.simplemobiletools.commons.R.string.date_added), PLAYER_SORT_BY_DATE_ADDED))
if (playlist != null) { if (playlist != null) {
radioItems.add(RadioItem(4, activity.getString(R.string.custom), PLAYER_SORT_BY_CUSTOM)) radioItems.add(RadioItem(4, activity.getString(com.simplemobiletools.commons.R.string.custom), PLAYER_SORT_BY_CUSTOM))
} }
} }
} }

View file

@ -31,8 +31,8 @@ class EditDialog(val activity: BaseSimpleActivity, val track: Track, val callbac
} }
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this, R.string.rename_song) { alertDialog -> activity.setupDialogStuff(binding.root, this, R.string.rename_song) { alertDialog ->
alertDialog.showKeyboard(binding.title) alertDialog.showKeyboard(binding.title)
@ -105,7 +105,7 @@ class EditDialog(val activity: BaseSimpleActivity, val track: Track, val callbac
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
activity.toast(R.string.unknown_error_occurred) activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
} }
} }
} }

View file

@ -42,18 +42,18 @@ class ExportPlaylistDialog(
} }
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this, R.string.export_playlist) { alertDialog -> activity.setupDialogStuff(binding.root, this, R.string.export_playlist) { alertDialog ->
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = binding.exportPlaylistFilename.value val filename = binding.exportPlaylistFilename.value
when { when {
filename.isEmpty() -> activity.toast(R.string.empty_name) filename.isEmpty() -> activity.toast(com.simplemobiletools.commons.R.string.empty_name)
filename.isAValidFilename() -> { filename.isAValidFilename() -> {
val file = File(realPath, "$filename.m3u") val file = File(realPath, "$filename.m3u")
if (!hidePath && file.exists()) { if (!hidePath && file.exists()) {
activity.toast(R.string.name_taken) activity.toast(com.simplemobiletools.commons.R.string.name_taken)
return@setOnClickListener return@setOnClickListener
} }
@ -65,7 +65,7 @@ class ExportPlaylistDialog(
} }
} }
else -> activity.toast(R.string.invalid_name) else -> activity.toast(com.simplemobiletools.commons.R.string.invalid_name)
} }
} }
} }

View file

@ -7,7 +7,6 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.commons.helpers.isQPlus
import com.simplemobiletools.commons.views.MyAppCompatCheckbox import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.databinding.DialogManageVisibleTabsBinding import com.simplemobiletools.musicplayer.databinding.DialogManageVisibleTabsBinding
import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.helpers.* import com.simplemobiletools.musicplayer.helpers.*
@ -37,8 +36,8 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity, val callback: (r
} }
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this) activity.setupDialogStuff(binding.root, this)
} }

View file

@ -22,8 +22,8 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null,
binding.newPlaylistTitle.setText(playlist!!.title) binding.newPlaylistTitle.setText(playlist!!.title)
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
val dialogTitle = if (isNewPlaylist) R.string.create_new_playlist else R.string.rename_playlist val dialogTitle = if (isNewPlaylist) R.string.create_new_playlist else R.string.rename_playlist
activity.setupDialogStuff(binding.root, this, dialogTitle) { alertDialog -> activity.setupDialogStuff(binding.root, this, dialogTitle) { alertDialog ->
@ -38,7 +38,7 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null,
} }
if (title.isEmpty()) { if (title.isEmpty()) {
activity.toast(R.string.empty_name) activity.toast(com.simplemobiletools.commons.R.string.empty_name)
return@ensureBackgroundThread return@ensureBackgroundThread
} else if (isPlaylistTitleTaken) { } else if (isPlaylistTitleTaken) {
activity.toast(R.string.playlist_name_exists) activity.toast(R.string.playlist_name_exists)
@ -58,7 +58,7 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null,
alertDialog.dismiss() alertDialog.dismiss()
callback(eventTypeId) callback(eventTypeId)
} else { } else {
activity.toast(R.string.unknown_error_occurred) activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
} }
} }
} }

View file

@ -15,8 +15,8 @@ class RemovePlaylistDialog(val activity: Activity, val playlist: Playlist? = nul
init { init {
binding.removePlaylistDescription.text = getDescriptionText() binding.removePlaylistDescription.text = getDescriptionText()
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> callback(binding.removePlaylistCheckbox.isChecked) } .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> callback(binding.removePlaylistCheckbox.isChecked) }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this, R.string.remove_playlist) activity.setupDialogStuff(binding.root, this, R.string.remove_playlist)
} }

View file

@ -11,10 +11,10 @@ class SleepTimerCustomDialog(val activity: Activity, val callback: (seconds: Int
private val binding by activity.viewBinding(DialogCustomSleepTimerPickerBinding::inflate) private val binding by activity.viewBinding(DialogCustomSleepTimerPickerBinding::inflate)
init { init {
binding.minutesHint.hint = activity.getString(R.string.minutes_raw).replaceFirstChar { it.uppercaseChar() } binding.minutesHint.hint = activity.getString(com.simplemobiletools.commons.R.string.minutes_raw).replaceFirstChar { it.uppercaseChar() }
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(binding.root, this, R.string.sleep_timer) { alertDialog -> activity.setupDialogStuff(binding.root, this, R.string.sleep_timer) { alertDialog ->
dialog = alertDialog dialog = alertDialog

View file

@ -47,7 +47,7 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
binding.albumsPlaceholder.text = if (scanning) { binding.albumsPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.albumsPlaceholder.beVisibleIf(albums.isEmpty()) binding.albumsPlaceholder.beVisibleIf(albums.isEmpty())

View file

@ -46,7 +46,7 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
binding.artistsPlaceholder.text = if (scanning) { binding.artistsPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.artistsPlaceholder.beVisibleIf(artists.isEmpty()) binding.artistsPlaceholder.beVisibleIf(artists.isEmpty())

View file

@ -35,7 +35,7 @@ class FoldersFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
binding.foldersPlaceholder.text = if (scanning) { binding.foldersPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.foldersPlaceholder.beVisibleIf(folders.isEmpty()) binding.foldersPlaceholder.beVisibleIf(folders.isEmpty())
binding.foldersFastscroller.beGoneIf(binding.foldersPlaceholder.isVisible()) binding.foldersFastscroller.beGoneIf(binding.foldersPlaceholder.isVisible())

View file

@ -45,7 +45,7 @@ class GenresFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
binding.genresPlaceholder.text = if (scanning) { binding.genresPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.genresPlaceholder.beVisibleIf(genres.isEmpty()) binding.genresPlaceholder.beVisibleIf(genres.isEmpty())

View file

@ -34,8 +34,9 @@ class PlaybackSpeedFragment : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val config = requireContext().config val config = requireContext().config
val binding = FragmentPlaybackSpeedBinding.inflate(inflater, container, false) val binding = FragmentPlaybackSpeedBinding.inflate(inflater, container, false)
val background = ResourcesCompat.getDrawable(resources, R.drawable.bottom_sheet_bg, requireContext().theme) val background = ResourcesCompat.getDrawable(resources, com.simplemobiletools.commons.R.drawable.bottom_sheet_bg, requireContext().theme)
(background as LayerDrawable).findDrawableByLayerId(R.id.bottom_sheet_background).applyColorFilter(requireContext().getProperBackgroundColor()) (background as LayerDrawable).findDrawableByLayerId(com.simplemobiletools.commons.R.id.bottom_sheet_background)
.applyColorFilter(requireContext().getProperBackgroundColor())
binding.apply { binding.apply {
seekBar = playbackSpeedSeekbar seekBar = playbackSpeedSeekbar

View file

@ -52,7 +52,7 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
binding.playlistsPlaceholder.text = if (scanning) { binding.playlistsPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.playlistsPlaceholder.beVisibleIf(playlists.isEmpty()) binding.playlistsPlaceholder.beVisibleIf(playlists.isEmpty())
binding.playlistsPlaceholder2.beVisibleIf(playlists.isEmpty() && !scanning) binding.playlistsPlaceholder2.beVisibleIf(playlists.isEmpty() && !scanning)

View file

@ -5,7 +5,12 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
import com.simplemobiletools.commons.extensions.beGoneIf
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getParentPath
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.openNotificationSettings
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.activities.SimpleActivity import com.simplemobiletools.musicplayer.activities.SimpleActivity
@ -39,7 +44,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
binding.tracksPlaceholder.text = if (scanning) { binding.tracksPlaceholder.text = if (scanning) {
context.getString(R.string.loading_files) context.getString(R.string.loading_files)
} else { } else {
context.getString(R.string.no_items_found) context.getString(com.simplemobiletools.commons.R.string.no_items_found)
} }
binding.tracksPlaceholder.beVisibleIf(tracks.isEmpty()) binding.tracksPlaceholder.beVisibleIf(tracks.isEmpty())
val adapter = binding.tracksList.adapter val adapter = binding.tracksList.adapter
@ -52,7 +57,11 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
prepareAndPlay(tracks, startIndex) prepareAndPlay(tracks, startIndex)
} else { } else {
if (context is Activity) { if (context is Activity) {
PermissionRequiredDialog(activity, R.string.allow_notifications_music_player, { activity.openNotificationSettings() }) PermissionRequiredDialog(
activity,
com.simplemobiletools.commons.R.string.allow_notifications_music_player,
{ activity.openNotificationSettings() }
)
} }
} }
} }

View file

@ -4,7 +4,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.writeLn import com.simplemobiletools.commons.extensions.writeLn
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.models.Track import com.simplemobiletools.musicplayer.models.Track
import java.io.OutputStream import java.io.OutputStream
@ -26,7 +25,7 @@ class M3uExporter(val activity: BaseSimpleActivity) {
return return
} }
activity.toast(R.string.exporting) activity.toast(com.simplemobiletools.commons.R.string.exporting)
try { try {
outputStream.bufferedWriter().use { out -> outputStream.bufferedWriter().use { out ->

View file

@ -105,7 +105,7 @@ class MyWidgetProvider : AppWidgetProvider() {
} }
private fun updatePlayPauseButton(context: Context, views: RemoteViews, isPlaying: Boolean) { private fun updatePlayPauseButton(context: Context, views: RemoteViews, isPlaying: Boolean) {
val drawableId = if (isPlaying) R.drawable.ic_pause_vector else R.drawable.ic_play_vector val drawableId = if (isPlaying) com.simplemobiletools.commons.R.drawable.ic_pause_vector else com.simplemobiletools.commons.R.drawable.ic_play_vector
val widgetTextColor = context.config.widgetTextColor val widgetTextColor = context.config.widgetTextColor
val icon = context.resources.getColoredBitmap(drawableId, widgetTextColor) val icon = context.resources.getColoredBitmap(drawableId, widgetTextColor)
views.setImageViewBitmap(R.id.play_pause_btn, icon) views.setImageViewBitmap(R.id.play_pause_btn, icon)
@ -120,8 +120,14 @@ class MyWidgetProvider : AppWidgetProvider() {
applyColorFilter(R.id.widget_background, widgetBgColor) applyColorFilter(R.id.widget_background, widgetBgColor)
setTextColor(R.id.song_info_title, widgetTextColor) setTextColor(R.id.song_info_title, widgetTextColor)
setTextColor(R.id.song_info_artist, widgetTextColor) setTextColor(R.id.song_info_artist, widgetTextColor)
setImageViewBitmap(R.id.previous_btn, context.resources.getColoredBitmap(R.drawable.ic_previous_vector, widgetTextColor)) setImageViewBitmap(
setImageViewBitmap(R.id.next_btn, context.resources.getColoredBitmap(R.drawable.ic_next_vector, widgetTextColor)) R.id.previous_btn,
context.resources.getColoredBitmap(
com.simplemobiletools.commons.R.drawable.ic_previous_vector,
widgetTextColor
)
)
setImageViewBitmap(R.id.next_btn, context.resources.getColoredBitmap(com.simplemobiletools.commons.R.drawable.ic_next_vector, widgetTextColor))
} }
} }

View file

@ -23,7 +23,7 @@ class NotificationHelper(private val context: Context) {
fun createNoPermissionNotification(): Notification { fun createNoPermissionNotification(): Notification {
return NotificationCompat.Builder(context, NOTIFICATION_CHANNEL) return NotificationCompat.Builder(context, NOTIFICATION_CHANNEL)
.setContentTitle(context.getString(R.string.no_storage_permissions)) .setContentTitle(context.getString(com.simplemobiletools.commons.R.string.no_storage_permissions))
.setSmallIcon(R.drawable.ic_headset_small) .setSmallIcon(R.drawable.ic_headset_small)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_MAX) .setPriority(NotificationCompat.PRIORITY_MAX)
@ -34,7 +34,7 @@ class NotificationHelper(private val context: Context) {
} }
fun createMediaScannerNotification(contentText: String, progress: Int, max: Int): Notification { fun createMediaScannerNotification(contentText: String, progress: Int, max: Int): Notification {
val title = context.getString(R.string.scanning) val title = context.getString(com.simplemobiletools.commons.R.string.scanning)
return NotificationCompat.Builder(context, NOTIFICATION_CHANNEL) return NotificationCompat.Builder(context, NOTIFICATION_CHANNEL)
.setContentTitle(title) .setContentTitle(title)
.setSmallIcon(R.drawable.ic_headset_small) .setSmallIcon(R.drawable.ic_headset_small)

View file

@ -71,7 +71,7 @@ class SimpleMediaScanner(private val context: Application) {
} catch (ignored: Exception) { } catch (ignored: Exception) {
} finally { } finally {
if (showProgress && newTracks.isEmpty()) { if (showProgress && newTracks.isEmpty()) {
context.toast(R.string.no_items_found) context.toast(com.simplemobiletools.commons.R.string.no_items_found)
} }
newTracks.clear() newTracks.clear()

View file

@ -4,7 +4,6 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import androidx.media3.session.CommandButton import androidx.media3.session.CommandButton
import androidx.media3.session.SessionCommand import androidx.media3.session.SessionCommand
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.helpers.PATH import com.simplemobiletools.musicplayer.helpers.PATH
/** /**
@ -32,9 +31,9 @@ internal val customCommands = CustomCommands.values().map { it.sessionCommand }
internal fun Context.getCustomLayout(): List<CommandButton> { internal fun Context.getCustomLayout(): List<CommandButton> {
return listOf( return listOf(
CommandButton.Builder() CommandButton.Builder()
.setDisplayName(getString(R.string.close)) .setDisplayName(getString(com.simplemobiletools.commons.R.string.close))
.setSessionCommand(CustomCommands.CLOSE_PLAYER.sessionCommand) .setSessionCommand(CustomCommands.CLOSE_PLAYER.sessionCommand)
.setIconResId(R.drawable.ic_cross_vector) .setIconResId(com.simplemobiletools.commons.R.drawable.ic_cross_vector)
.build() .build()
) )
} }

View file

@ -10,7 +10,6 @@ import androidx.media3.common.util.UnstableApi
import androidx.media3.session.* import androidx.media3.session.*
import com.simplemobiletools.commons.extensions.hasPermission import com.simplemobiletools.commons.extensions.hasPermission
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.extensions.*
import com.simplemobiletools.musicplayer.helpers.NotificationHelper import com.simplemobiletools.musicplayer.helpers.NotificationHelper
import com.simplemobiletools.musicplayer.helpers.getPermissionToRequest import com.simplemobiletools.musicplayer.helpers.getPermissionToRequest
@ -92,7 +91,7 @@ class PlaybackService : MediaLibraryService(), MediaSessionService.Listener {
* background. * background.
*/ */
override fun onForegroundServiceStartNotAllowedException() { override fun onForegroundServiceStartNotAllowedException() {
showErrorToast(getString(R.string.unknown_error_occurred)) showErrorToast(getString(com.simplemobiletools.commons.R.string.unknown_error_occurred))
// todo: show a notification instead. // todo: show a notification instead.
} }

View file

@ -6,7 +6,6 @@ import androidx.media3.common.util.UnstableApi
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.helpers.EQUALIZER_PRESET_CUSTOM import com.simplemobiletools.musicplayer.helpers.EQUALIZER_PRESET_CUSTOM
import com.simplemobiletools.musicplayer.playback.player.SimpleMusicPlayer import com.simplemobiletools.musicplayer.playback.player.SimpleMusicPlayer
@ -39,7 +38,7 @@ object SimpleEqualizer {
} }
} }
} catch (ignored: Exception) { } catch (ignored: Exception) {
context.toast(R.string.unknown_error_occurred) context.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
} }
} }

View file

@ -155,7 +155,11 @@ internal class MediaItemProvider(private val context: Context) {
state = STATE_INITIALIZING state = STATE_INITIALIZING
ensureBackgroundThread { ensureBackgroundThread {
val root = buildMediaItem(title = context.getString(R.string.root), mediaId = SMP_ROOT_ID, mediaType = MediaMetadata.MEDIA_TYPE_FOLDER_MIXED) val root = buildMediaItem(
title = context.getString(com.simplemobiletools.commons.R.string.root),
mediaId = SMP_ROOT_ID,
mediaType = MediaMetadata.MEDIA_TYPE_FOLDER_MIXED
)
val rootChildren = RootCategories.buildRootChildren(context) val rootChildren = RootCategories.buildRootChildren(context)
addNodeAndChildren(item = root, children = rootChildren) addNodeAndChildren(item = root, children = rootChildren)
@ -233,7 +237,7 @@ internal class MediaItemProvider(private val context: Context) {
private enum class RootCategories(@StringRes val titleRes: Int, @DrawableRes val drawableRes: Int, val mediaId: String, val mediaType: @MediaType Int) { private enum class RootCategories(@StringRes val titleRes: Int, @DrawableRes val drawableRes: Int, val mediaId: String, val mediaType: @MediaType Int) {
PLAYLISTS(R.string.playlists, R.drawable.ic_playlist_vector, SMP_PLAYLISTS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS), PLAYLISTS(R.string.playlists, R.drawable.ic_playlist_vector, SMP_PLAYLISTS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS),
FOLDERS(R.string.folders, R.drawable.ic_folders_vector, SMP_FOLDERS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS), FOLDERS(R.string.folders, R.drawable.ic_folders_vector, SMP_FOLDERS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS),
ARTISTS(R.string.artists, R.drawable.ic_person_vector, SMP_ARTISTS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_ARTISTS), ARTISTS(R.string.artists, com.simplemobiletools.commons.R.drawable.ic_person_vector, SMP_ARTISTS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_ARTISTS),
ALBUMS(R.string.albums, R.drawable.ic_album_vector, SMP_ALBUMS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_ALBUMS), ALBUMS(R.string.albums, R.drawable.ic_album_vector, SMP_ALBUMS_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_ALBUMS),
TRACKS(R.string.tracks, R.drawable.ic_music_note_vector, SMP_TRACKS_ROOT_ID, MediaMetadata.MEDIA_TYPE_PLAYLIST), TRACKS(R.string.tracks, R.drawable.ic_music_note_vector, SMP_TRACKS_ROOT_ID, MediaMetadata.MEDIA_TYPE_PLAYLIST),
GENRES(R.string.genres, R.drawable.ic_genre_vector, SMP_GENRES_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_GENRES); GENRES(R.string.genres, R.drawable.ic_genre_vector, SMP_GENRES_ROOT_ID, MediaMetadata.MEDIA_TYPE_FOLDER_GENRES);

View file

@ -6,7 +6,6 @@ import androidx.media3.common.PlaybackException
import androidx.media3.common.Player import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi import androidx.media3.common.util.UnstableApi
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.extensions.getPlaybackSetting import com.simplemobiletools.musicplayer.extensions.getPlaybackSetting
import com.simplemobiletools.musicplayer.helpers.PlaybackSetting import com.simplemobiletools.musicplayer.helpers.PlaybackSetting
@ -15,7 +14,7 @@ import com.simplemobiletools.musicplayer.playback.PlaybackService
@UnstableApi @UnstableApi
internal fun PlaybackService.getPlayerListener() = object : Player.Listener { internal fun PlaybackService.getPlayerListener() = object : Player.Listener {
override fun onPlayerError(error: PlaybackException) = toast(R.string.unknown_error_occurred, Toast.LENGTH_LONG) override fun onPlayerError(error: PlaybackException) = toast(com.simplemobiletools.commons.R.string.unknown_error_occurred, Toast.LENGTH_LONG)
override fun onEvents(player: Player, events: Player.Events) { override fun onEvents(player: Player, events: Player.Events) {
if ( if (

View file

@ -48,7 +48,7 @@ class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLa
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
binding.currentTrackLabel.text = "${track.title}$artist" binding.currentTrackLabel.text = "${track.title}$artist"
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_small).toInt() val cornerRadius = resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small).toInt()
val currentTrackPlaceholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset, context.getProperTextColor()) val currentTrackPlaceholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset, context.getProperTextColor())
val options = RequestOptions() val options = RequestOptions()
.error(currentTrackPlaceholder) .error(currentTrackPlaceholder)

View file

@ -1,4 +1,3 @@
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx8192m org.gradle.jvmargs=-Xmx8192m
android.nonTransitiveRClass=false