From 59b3e608324881e26957c1c31a83e9f80dbc09bf Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 1 Sep 2023 20:53:00 +0530 Subject: [PATCH] Migrate to non transitive R class --- .../musicplayer/activities/AlbumsActivity.kt | 6 +++- .../activities/EqualizerActivity.kt | 9 +++-- .../musicplayer/activities/MainActivity.kt | 36 +++++++++---------- .../activities/SettingsActivity.kt | 8 ++--- .../activities/SimpleControllerActivity.kt | 3 +- .../activities/SimpleMusicActivity.kt | 3 +- .../musicplayer/activities/TrackActivity.kt | 6 ++-- .../musicplayer/activities/TracksActivity.kt | 16 ++++----- .../activities/WidgetConfigureActivity.kt | 8 ++--- .../musicplayer/adapters/BaseMusicAdapter.kt | 3 +- .../adapters/ExcludedFoldersAdapter.kt | 7 ++-- .../musicplayer/adapters/QueueAdapter.kt | 2 +- .../adapters/TracksHeaderAdapter.kt | 2 +- .../dialogs/ChangeSortingDialog.kt | 36 +++++++++---------- .../musicplayer/dialogs/EditDialog.kt | 6 ++-- .../dialogs/ExportPlaylistDialog.kt | 10 +++--- .../dialogs/ManageVisibleTabsDialog.kt | 5 ++- .../musicplayer/dialogs/NewPlaylistDialog.kt | 8 ++--- .../dialogs/RemovePlaylistDialog.kt | 4 +-- .../dialogs/SleepTimerCustomDialog.kt | 6 ++-- .../musicplayer/fragments/AlbumsFragment.kt | 2 +- .../musicplayer/fragments/ArtistsFragment.kt | 2 +- .../musicplayer/fragments/FoldersFragment.kt | 2 +- .../musicplayer/fragments/GenresFragment.kt | 2 +- .../fragments/PlaybackSpeedFragment.kt | 5 +-- .../fragments/PlaylistsFragment.kt | 2 +- .../musicplayer/fragments/TracksFragment.kt | 15 ++++++-- .../musicplayer/helpers/M3uExporter.kt | 3 +- .../musicplayer/helpers/MyWidgetProvider.kt | 12 +++++-- .../musicplayer/helpers/NotificationHelper.kt | 4 +-- .../musicplayer/helpers/SimpleMediaScanner.kt | 2 +- .../musicplayer/playback/CustomCommands.kt | 5 ++- .../musicplayer/playback/PlaybackService.kt | 3 +- .../musicplayer/playback/SimpleEqualizer.kt | 3 +- .../playback/library/MediaItemProvider.kt | 8 +++-- .../playback/player/PlayerListener.kt | 3 +- .../musicplayer/views/CurrentTrackBar.kt | 2 +- gradle.properties | 1 - 38 files changed, 136 insertions(+), 124 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/AlbumsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/AlbumsActivity.kt index a07fdcbd..8ef74e6e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/AlbumsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/AlbumsActivity.kt @@ -64,7 +64,11 @@ class AlbumsActivity : SimpleMusicActivity() { val startIndex = albumTracks.indexOf(it as Track) prepareAndPlay(albumTracks, startIndex) } else { - PermissionRequiredDialog(this, R.string.allow_notifications_music_player, { openNotificationSettings() }) + PermissionRequiredDialog( + this, + com.simplemobiletools.commons.R.string.allow_notifications_music_player, + { openNotificationSettings() } + ) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/EqualizerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/EqualizerActivity.kt index 98891ea2..fd416d14 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/EqualizerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/EqualizerActivity.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.commons.helpers.DARK_GREY import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.views.MySeekBar -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.databinding.ActivityEqualizerBinding import com.simplemobiletools.musicplayer.databinding.EqualizerBandBinding import com.simplemobiletools.musicplayer.extensions.config @@ -122,7 +121,7 @@ class EqualizerActivity : SimpleActivity() { } 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 for (band in 0 until equalizer.numberOfBands) { bands[band.toShort()] = bandSeekBars[band].progress @@ -143,7 +142,7 @@ class EqualizerActivity : SimpleActivity() { 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 -> try { config.equalizerPreset = presetId as Int @@ -158,7 +157,7 @@ class EqualizerActivity : SimpleActivity() { private fun presetChanged(presetId: Int, equalizer: Equalizer) { 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) { val minValue = equalizer.bandLevelRange[0] @@ -177,7 +176,7 @@ class EqualizerActivity : SimpleActivity() { val presetName = equalizer.getPresetName(presetId.toShort()) if (presetName.isEmpty()) { config.equalizerPreset = EQUALIZER_PRESET_CUSTOM - binding.equalizerPreset.text = getString(R.string.custom) + binding.equalizerPreset.text = getString(com.simplemobiletools.commons.R.string.custom) } else { binding.equalizerPreset.text = presetName } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt index 9b5d4e2d..74761b61 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt @@ -62,7 +62,7 @@ class MainActivity : SimpleMusicActivity() { if (it) { initActivity() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -239,7 +239,7 @@ class MainActivity : SimpleMusicActivity() { private fun setupTabs() { binding.mainTabsHolder.removeAllTabs() 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!!) tabItemBinding.tabItemIcon.setImageDrawable(getTabIcon(value)) tabItemBinding.tabItemLabel.text = getTabLabel(value) @@ -282,7 +282,7 @@ class MainActivity : SimpleMusicActivity() { val drawableId = when (position) { TAB_PLAYLISTS -> R.drawable.ic_playlist_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_GENRES -> R.drawable.ic_genre_vector else -> R.drawable.ic_music_note_vector @@ -352,7 +352,7 @@ class MainActivity : SimpleMusicActivity() { uri.scheme == "content" -> { val tempFile = getTempFile("imports", uri.path!!.getFilenameFromPath()) if (tempFile == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) 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 { startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT) } 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) { showErrorToast(e) } @@ -415,9 +415,9 @@ class MainActivity : SimpleMusicActivity() { runOnUiThread { toast( when (result) { - ImportResult.IMPORT_OK -> R.string.importing_successful - ImportResult.IMPORT_PARTIAL -> R.string.importing_some_entries_failed - else -> R.string.importing_failed + ImportResult.IMPORT_OK -> com.simplemobiletools.commons.R.string.importing_successful + ImportResult.IMPORT_PARTIAL -> com.simplemobiletools.commons.R.string.importing_some_entries_failed + else -> com.simplemobiletools.commons.R.string.importing_failed } ) @@ -428,8 +428,8 @@ class MainActivity : SimpleMusicActivity() { } private fun showSleepTimer() { - val minutes = getString(R.string.minutes_raw) - val hour = resources.getQuantityString(R.plurals.hours, 1, 1) + val minutes = getString(com.simplemobiletools.commons.R.string.minutes_raw) + val hour = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, 1, 1) val items = arrayListOf( RadioItem(5 * 60, "5 $minutes"), @@ -441,12 +441,12 @@ class MainActivity : SimpleMusicActivity() { if (items.none { it.id == config.lastSleepTimerSeconds }) { 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.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) { if (it as Int == -1) { @@ -527,14 +527,14 @@ class MainActivity : SimpleMusicActivity() { val faqItems = arrayListOf( 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(R.string.faq_4_title_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_1_title_commons, com.simplemobiletools.commons.R.string.faq_1_text_commons), + FAQItem(com.simplemobiletools.commons.R.string.faq_4_title_commons, com.simplemobiletools.commons.R.string.faq_4_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)) { - faqItems.add(FAQItem(R.string.faq_2_title_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_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_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) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SettingsActivity.kt index 18d7b07d..57e84fa5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SettingsActivity.kt @@ -107,9 +107,9 @@ class SettingsActivity : SimpleControllerActivity() { settingsShowFilename.text = getReplaceTitleText() settingsShowFilenameHolder.setOnClickListener { 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_ALWAYS, getString(R.string.always)) + RadioItem(SHOW_FILENAME_ALWAYS, getString(com.simplemobiletools.commons.R.string.always)) ) RadioGroupDialog(this@SettingsActivity, items, config.showFilename) { @@ -122,9 +122,9 @@ class SettingsActivity : SimpleControllerActivity() { private fun getReplaceTitleText() = getString( 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 - else -> R.string.always + else -> com.simplemobiletools.commons.R.string.always } ) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleControllerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleControllerActivity.kt index 58f20900..40afc9a5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleControllerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleControllerActivity.kt @@ -10,7 +10,6 @@ import androidx.media3.session.MediaController import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.isRPlus -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.helpers.EXTRA_NEXT_MEDIA_ID import com.simplemobiletools.musicplayer.helpers.SimpleMediaController @@ -117,7 +116,7 @@ abstract class SimpleControllerActivity : SimpleActivity(), Player.Listener { EventBus.getDefault().post(Events.RefreshFragments()) callback() } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleMusicActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleMusicActivity.kt index 74ba7e63..cca9773a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleMusicActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SimpleMusicActivity.kt @@ -7,7 +7,6 @@ import androidx.media3.common.Player import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.openNotificationSettings -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.isReallyPlaying import com.simplemobiletools.musicplayer.extensions.togglePlayback import com.simplemobiletools.musicplayer.views.CurrentTrackBar @@ -34,7 +33,7 @@ abstract class SimpleMusicActivity : SimpleControllerActivity(), Player.Listener startActivity(this) } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_music_player, { openNotificationSettings() }) + PermissionRequiredDialog(this, com.simplemobiletools.commons.R.string.allow_notifications_music_player, { openNotificationSettings() }) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt index df9bfd8a..c35dabaf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt @@ -145,7 +145,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener { if (track != null) { prepareAndPlay(listOf(track), startActivity = false) } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) finish() } } @@ -188,7 +188,7 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener { binding.nextTrackLabel.text = "${getString(R.string.next_track)} ${track.title}$artist" 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() // 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) { finish() 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) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TracksActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TracksActivity.kt index 8e72e516..24b14ec0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TracksActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TracksActivity.kt @@ -292,7 +292,7 @@ class TracksActivity : SimpleMusicActivity() { if (path.isAudioFast()) { addTrackFromPath(path, true) } 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) } } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } else { var track = audioHelper.getTrack(mediaStoreId) @@ -377,7 +377,7 @@ class TracksActivity : SimpleMusicActivity() { val startIndex = tracks.indexOf(track) prepareAndPlay(tracks, startIndex) } 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 { startActivityForResult(this, PICK_EXPORT_FILE_INTENT) } 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) { showErrorToast(e) } @@ -415,16 +415,16 @@ class TracksActivity : SimpleMusicActivity() { private fun exportPlaylistTo(outputStream: OutputStream?) { val tracks = getTracksAdapter()?.items if (tracks.isNullOrEmpty()) { - toast(R.string.no_entries_for_exporting) + toast(com.simplemobiletools.commons.R.string.no_entries_for_exporting) return } M3uExporter(this).exportPlaylist(outputStream, tracks) { result -> toast( when (result) { - ExportResult.EXPORT_OK -> R.string.exporting_successful - ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed - else -> R.string.exporting_failed + ExportResult.EXPORT_OK -> com.simplemobiletools.commons.R.string.exporting_successful + ExportResult.EXPORT_PARTIAL -> com.simplemobiletools.commons.R.string.exporting_some_entries_failed + else -> com.simplemobiletools.commons.R.string.exporting_failed } ) } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/WidgetConfigureActivity.kt index a814ce7f..921b6ac1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/WidgetConfigureActivity.kt @@ -53,8 +53,8 @@ class WidgetConfigureActivity : SimpleActivity() { songInfoTitle.text = currSong.title songInfoArtist.text = currSong.artist } else { - songInfoTitle.text = getString(R.string.artist) - songInfoArtist.text = getString(R.string.song_title) + songInfoTitle.text = getString(com.simplemobiletools.commons.R.string.artist) + songInfoArtist.text = getString(com.simplemobiletools.commons.R.string.song_title) } } @@ -87,8 +87,8 @@ class WidgetConfigureActivity : SimpleActivity() { } mTextColor = config.widgetTextColor - if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { - mTextColor = resources.getColor(R.color.you_primary_color, theme) + if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) { + mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme) } updateTextColor() diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/BaseMusicAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/BaseMusicAdapter.kt index d314c5ec..a95095fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/BaseMusicAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/BaseMusicAdapter.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.views.MyRecyclerView -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.activities.SimpleControllerActivity import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.helpers.TagHelper @@ -32,7 +31,7 @@ abstract class BaseMusicAdapter( val tagHelper by lazy { TagHelper(ctx) } val placeholder by lazy { resources.getSmallPlaceholder(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 diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/ExcludedFoldersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/ExcludedFoldersAdapter.kt index 23d13bc9..bff68b6f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/ExcludedFoldersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/ExcludedFoldersAdapter.kt @@ -11,7 +11,6 @@ import com.simplemobiletools.commons.extensions.humanizePath import com.simplemobiletools.commons.extensions.setupViewBackground import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.views.MyRecyclerView -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.databinding.ItemExcludedFolderBinding import com.simplemobiletools.musicplayer.extensions.config @@ -25,13 +24,13 @@ class ExcludedFoldersAdapter( 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 actionItemPressed(id: Int) { when (id) { - R.id.cab_remove -> removeSelection() + com.simplemobiletools.commons.R.id.cab_remove -> removeSelection() } } @@ -95,7 +94,7 @@ class ExcludedFoldersAdapter( setOnMenuItemClickListener { item -> val eventTypeId = folder.hashCode() when (item.itemId) { - R.id.cab_remove -> { + com.simplemobiletools.commons.R.id.cab_remove -> { executeItemMenuOperation(eventTypeId) { removeSelection() } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/QueueAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/QueueAdapter.kt index 6681c702..c391cac0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/QueueAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/QueueAdapter.kt @@ -107,7 +107,7 @@ class QueueAdapter(activity: SimpleActivity, items: ArrayList, var curren } 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() val selectedTracks = getSelectedTracks() selectedTracks.forEach { track -> diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/TracksHeaderAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/TracksHeaderAdapter.kt index ea363497..811a7994 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/TracksHeaderAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/TracksHeaderAdapter.kt @@ -28,7 +28,7 @@ class TracksHeaderAdapter(activity: SimpleActivity, items: ArrayList, private val ITEM_HEADER = 0 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 diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ChangeSortingDialog.kt index 57120721..58720aa3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ChangeSortingDialog.kt @@ -29,7 +29,7 @@ class ChangeSortingDialog(val activity: Activity, val location: Int, val playlis if (playlist != null) { sortingDialogUseForThisOnly.isChecked = config.hasCustomPlaylistSorting(playlist.id) } 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) } } @@ -54,10 +54,10 @@ class ChangeSortingDialog(val activity: Activity, val location: Int, val playlis setupOrderRadio() activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .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() when (location) { 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)) } 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(2, activity.getString(R.string.track_count), PLAYER_SORT_BY_TRACK_COUNT)) } 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(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 -> { - radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) - radioItems.add(RadioItem(1, activity.getString(R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) - radioItems.add(RadioItem(2, activity.getString(R.string.duration), PLAYER_SORT_BY_DURATION)) + radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE)) + radioItems.add(RadioItem(1, activity.getString(com.simplemobiletools.commons.R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) + 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(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 -> { - 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)) } ACTIVITY_PLAYLIST_FOLDER -> { - radioItems.add(RadioItem(0, activity.getString(R.string.title), PLAYER_SORT_BY_TITLE)) - radioItems.add(RadioItem(1, activity.getString(R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) - radioItems.add(RadioItem(2, activity.getString(R.string.duration), PLAYER_SORT_BY_DURATION)) + radioItems.add(RadioItem(0, activity.getString(com.simplemobiletools.commons.R.string.title), PLAYER_SORT_BY_TITLE)) + radioItems.add(RadioItem(1, activity.getString(com.simplemobiletools.commons.R.string.artist), PLAYER_SORT_BY_ARTIST_TITLE)) + 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(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) { - 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)) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/EditDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/EditDialog.kt index 2c7c48bf..c1ec2b98 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/EditDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/EditDialog.kt @@ -31,8 +31,8 @@ class EditDialog(val activity: BaseSimpleActivity, val track: Track, val callbac } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { activity.setupDialogStuff(binding.root, this, R.string.rename_song) { alertDialog -> alertDialog.showKeyboard(binding.title) @@ -105,7 +105,7 @@ class EditDialog(val activity: BaseSimpleActivity, val track: Track, val callbac } } } catch (e: Exception) { - activity.toast(R.string.unknown_error_occurred) + activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ExportPlaylistDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ExportPlaylistDialog.kt index ef0835eb..68485792 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ExportPlaylistDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ExportPlaylistDialog.kt @@ -42,18 +42,18 @@ class ExportPlaylistDialog( } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { activity.setupDialogStuff(binding.root, this, R.string.export_playlist) { alertDialog -> alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val filename = binding.exportPlaylistFilename.value when { - filename.isEmpty() -> activity.toast(R.string.empty_name) + filename.isEmpty() -> activity.toast(com.simplemobiletools.commons.R.string.empty_name) filename.isAValidFilename() -> { val file = File(realPath, "$filename.m3u") if (!hidePath && file.exists()) { - activity.toast(R.string.name_taken) + activity.toast(com.simplemobiletools.commons.R.string.name_taken) 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) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ManageVisibleTabsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ManageVisibleTabsDialog.kt index d25f6786..6a701b5c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ManageVisibleTabsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/ManageVisibleTabsDialog.kt @@ -7,7 +7,6 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.viewBinding import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.commons.views.MyAppCompatCheckbox -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.databinding.DialogManageVisibleTabsBinding import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.helpers.* @@ -37,8 +36,8 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity, val callback: (r } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { activity.setupDialogStuff(binding.root, this) } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/NewPlaylistDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/NewPlaylistDialog.kt index b2b51286..3e81ebfb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/NewPlaylistDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/NewPlaylistDialog.kt @@ -22,8 +22,8 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null, binding.newPlaylistTitle.setText(playlist!!.title) activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { val dialogTitle = if (isNewPlaylist) R.string.create_new_playlist else R.string.rename_playlist activity.setupDialogStuff(binding.root, this, dialogTitle) { alertDialog -> @@ -38,7 +38,7 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null, } if (title.isEmpty()) { - activity.toast(R.string.empty_name) + activity.toast(com.simplemobiletools.commons.R.string.empty_name) return@ensureBackgroundThread } else if (isPlaylistTitleTaken) { activity.toast(R.string.playlist_name_exists) @@ -58,7 +58,7 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null, alertDialog.dismiss() callback(eventTypeId) } else { - activity.toast(R.string.unknown_error_occurred) + activity.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/RemovePlaylistDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/RemovePlaylistDialog.kt index 062c0822..c1b4b0dd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/RemovePlaylistDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/RemovePlaylistDialog.kt @@ -15,8 +15,8 @@ class RemovePlaylistDialog(val activity: Activity, val playlist: Playlist? = nul init { binding.removePlaylistDescription.text = getDescriptionText() activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { _, _ -> callback(binding.removePlaylistCheckbox.isChecked) } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> callback(binding.removePlaylistCheckbox.isChecked) } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { activity.setupDialogStuff(binding.root, this, R.string.remove_playlist) } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/SleepTimerCustomDialog.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/SleepTimerCustomDialog.kt index e997914b..808ae21b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/SleepTimerCustomDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/dialogs/SleepTimerCustomDialog.kt @@ -11,10 +11,10 @@ class SleepTimerCustomDialog(val activity: Activity, val callback: (seconds: Int private val binding by activity.viewBinding(DialogCustomSleepTimerPickerBinding::inflate) 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() - .setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { activity.setupDialogStuff(binding.root, this, R.string.sleep_timer) { alertDialog -> dialog = alertDialog diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/AlbumsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/AlbumsFragment.kt index 4d509994..b60087bb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/AlbumsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/AlbumsFragment.kt @@ -47,7 +47,7 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager binding.albumsPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.albumsPlaceholder.beVisibleIf(albums.isEmpty()) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/ArtistsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/ArtistsFragment.kt index b1d0bc44..bd3df52e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/ArtistsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/ArtistsFragment.kt @@ -46,7 +46,7 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage binding.artistsPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.artistsPlaceholder.beVisibleIf(artists.isEmpty()) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/FoldersFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/FoldersFragment.kt index d3a7609a..1a008256 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/FoldersFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/FoldersFragment.kt @@ -35,7 +35,7 @@ class FoldersFragment(context: Context, attributeSet: AttributeSet) : MyViewPage binding.foldersPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.foldersPlaceholder.beVisibleIf(folders.isEmpty()) binding.foldersFastscroller.beGoneIf(binding.foldersPlaceholder.isVisible()) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/GenresFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/GenresFragment.kt index 782de2b8..8649b29c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/GenresFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/GenresFragment.kt @@ -45,7 +45,7 @@ class GenresFragment(context: Context, attributeSet: AttributeSet) : MyViewPager binding.genresPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.genresPlaceholder.beVisibleIf(genres.isEmpty()) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaybackSpeedFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaybackSpeedFragment.kt index 341b2ea7..a54fdab2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaybackSpeedFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaybackSpeedFragment.kt @@ -34,8 +34,9 @@ class PlaybackSpeedFragment : BottomSheetDialogFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val config = requireContext().config val binding = FragmentPlaybackSpeedBinding.inflate(inflater, container, false) - val background = ResourcesCompat.getDrawable(resources, R.drawable.bottom_sheet_bg, requireContext().theme) - (background as LayerDrawable).findDrawableByLayerId(R.id.bottom_sheet_background).applyColorFilter(requireContext().getProperBackgroundColor()) + val background = ResourcesCompat.getDrawable(resources, com.simplemobiletools.commons.R.drawable.bottom_sheet_bg, requireContext().theme) + (background as LayerDrawable).findDrawableByLayerId(com.simplemobiletools.commons.R.id.bottom_sheet_background) + .applyColorFilter(requireContext().getProperBackgroundColor()) binding.apply { seekBar = playbackSpeedSeekbar diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaylistsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaylistsFragment.kt index 1b36b46b..6d2e932e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaylistsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaylistsFragment.kt @@ -52,7 +52,7 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa binding.playlistsPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.playlistsPlaceholder.beVisibleIf(playlists.isEmpty()) binding.playlistsPlaceholder2.beVisibleIf(playlists.isEmpty() && !scanning) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/TracksFragment.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/TracksFragment.kt index a0793a55..b88ff276 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/TracksFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/TracksFragment.kt @@ -5,7 +5,12 @@ import android.content.Context import android.util.AttributeSet import com.simplemobiletools.commons.activities.BaseSimpleActivity 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.musicplayer.R import com.simplemobiletools.musicplayer.activities.SimpleActivity @@ -39,7 +44,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager binding.tracksPlaceholder.text = if (scanning) { context.getString(R.string.loading_files) } else { - context.getString(R.string.no_items_found) + context.getString(com.simplemobiletools.commons.R.string.no_items_found) } binding.tracksPlaceholder.beVisibleIf(tracks.isEmpty()) val adapter = binding.tracksList.adapter @@ -52,7 +57,11 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager prepareAndPlay(tracks, startIndex) } else { 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() } + ) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/M3uExporter.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/M3uExporter.kt index 961d03b4..a4c79124 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/M3uExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/M3uExporter.kt @@ -4,7 +4,6 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.writeLn -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.models.Track import java.io.OutputStream @@ -26,7 +25,7 @@ class M3uExporter(val activity: BaseSimpleActivity) { return } - activity.toast(R.string.exporting) + activity.toast(com.simplemobiletools.commons.R.string.exporting) try { outputStream.bufferedWriter().use { out -> diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/MyWidgetProvider.kt index b92639a5..bd14afa5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/MyWidgetProvider.kt @@ -105,7 +105,7 @@ class MyWidgetProvider : AppWidgetProvider() { } 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 icon = context.resources.getColoredBitmap(drawableId, widgetTextColor) views.setImageViewBitmap(R.id.play_pause_btn, icon) @@ -120,8 +120,14 @@ class MyWidgetProvider : AppWidgetProvider() { applyColorFilter(R.id.widget_background, widgetBgColor) setTextColor(R.id.song_info_title, widgetTextColor) setTextColor(R.id.song_info_artist, widgetTextColor) - setImageViewBitmap(R.id.previous_btn, context.resources.getColoredBitmap(R.drawable.ic_previous_vector, widgetTextColor)) - setImageViewBitmap(R.id.next_btn, context.resources.getColoredBitmap(R.drawable.ic_next_vector, widgetTextColor)) + setImageViewBitmap( + 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)) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/NotificationHelper.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/NotificationHelper.kt index 675533ed..7e2ed3a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/NotificationHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/NotificationHelper.kt @@ -23,7 +23,7 @@ class NotificationHelper(private val context: Context) { fun createNoPermissionNotification(): Notification { 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) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setPriority(NotificationCompat.PRIORITY_MAX) @@ -34,7 +34,7 @@ class NotificationHelper(private val context: Context) { } 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) .setContentTitle(title) .setSmallIcon(R.drawable.ic_headset_small) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/SimpleMediaScanner.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/SimpleMediaScanner.kt index fdaa783a..2c10426a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/SimpleMediaScanner.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/helpers/SimpleMediaScanner.kt @@ -71,7 +71,7 @@ class SimpleMediaScanner(private val context: Application) { } catch (ignored: Exception) { } finally { if (showProgress && newTracks.isEmpty()) { - context.toast(R.string.no_items_found) + context.toast(com.simplemobiletools.commons.R.string.no_items_found) } newTracks.clear() diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/CustomCommands.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/CustomCommands.kt index 4f96d2db..d87a95e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/CustomCommands.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/CustomCommands.kt @@ -4,7 +4,6 @@ import android.content.Context import android.os.Bundle import androidx.media3.session.CommandButton import androidx.media3.session.SessionCommand -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.helpers.PATH /** @@ -32,9 +31,9 @@ internal val customCommands = CustomCommands.values().map { it.sessionCommand } internal fun Context.getCustomLayout(): List { return listOf( CommandButton.Builder() - .setDisplayName(getString(R.string.close)) + .setDisplayName(getString(com.simplemobiletools.commons.R.string.close)) .setSessionCommand(CustomCommands.CLOSE_PLAYER.sessionCommand) - .setIconResId(R.drawable.ic_cross_vector) + .setIconResId(com.simplemobiletools.commons.R.drawable.ic_cross_vector) .build() ) } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/PlaybackService.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/PlaybackService.kt index b5320763..c78f2d93 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/PlaybackService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/PlaybackService.kt @@ -10,7 +10,6 @@ import androidx.media3.common.util.UnstableApi import androidx.media3.session.* import com.simplemobiletools.commons.extensions.hasPermission import com.simplemobiletools.commons.extensions.showErrorToast -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.* import com.simplemobiletools.musicplayer.helpers.NotificationHelper import com.simplemobiletools.musicplayer.helpers.getPermissionToRequest @@ -92,7 +91,7 @@ class PlaybackService : MediaLibraryService(), MediaSessionService.Listener { * background. */ 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. } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/SimpleEqualizer.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/SimpleEqualizer.kt index 6fc6e180..69f57443 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/SimpleEqualizer.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/SimpleEqualizer.kt @@ -6,7 +6,6 @@ import androidx.media3.common.util.UnstableApi import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.extensions.toast -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.helpers.EQUALIZER_PRESET_CUSTOM import com.simplemobiletools.musicplayer.playback.player.SimpleMusicPlayer @@ -39,7 +38,7 @@ object SimpleEqualizer { } } } catch (ignored: Exception) { - context.toast(R.string.unknown_error_occurred) + context.toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/library/MediaItemProvider.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/library/MediaItemProvider.kt index cbb6b632..0329f447 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/library/MediaItemProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/library/MediaItemProvider.kt @@ -155,7 +155,11 @@ internal class MediaItemProvider(private val context: Context) { state = STATE_INITIALIZING 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) 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) { 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), - 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), 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); diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/PlayerListener.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/PlayerListener.kt index 0a689e6f..3019e242 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/PlayerListener.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/playback/player/PlayerListener.kt @@ -6,7 +6,6 @@ import androidx.media3.common.PlaybackException import androidx.media3.common.Player import androidx.media3.common.util.UnstableApi import com.simplemobiletools.commons.extensions.toast -import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.getPlaybackSetting import com.simplemobiletools.musicplayer.helpers.PlaybackSetting @@ -15,7 +14,7 @@ import com.simplemobiletools.musicplayer.playback.PlaybackService @UnstableApi 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) { if ( diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/views/CurrentTrackBar.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/views/CurrentTrackBar.kt index 14d3e67e..7ba2fab6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/views/CurrentTrackBar.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/views/CurrentTrackBar.kt @@ -48,7 +48,7 @@ class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLa @SuppressLint("SetTextI18n") 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 options = RequestOptions() .error(currentTrackPlaceholder) diff --git a/gradle.properties b/gradle.properties index cfecf3f5..95e3e292 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx8192m -android.nonTransitiveRClass=false