Fix app shortcuts click crash
parent
0ce71b19a8
commit
9dc2da66e1
|
@ -77,7 +77,6 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
@ -91,6 +90,12 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
if (!hasPermissions()) {
|
||||
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
|
||||
}
|
||||
|
||||
showPromotionalDialog()
|
||||
}
|
||||
|
||||
private fun showPromotionalDialog() {
|
||||
|
||||
}
|
||||
|
||||
private fun setupNavigationController() {
|
||||
|
@ -104,9 +109,6 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
}
|
||||
navController.graph = navGraph
|
||||
NavigationUI.setupWithNavController(getBottomNavigationView(), navController)
|
||||
navController.addOnDestinationChangedListener { _, _, _ ->
|
||||
// appBarLayout.setExpanded(true, true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean =
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.os.Bundle
|
|||
import code.name.monkey.retromusic.appshortcuts.shortcuttype.LastAddedShortcutType
|
||||
import code.name.monkey.retromusic.appshortcuts.shortcuttype.ShuffleAllShortcutType
|
||||
import code.name.monkey.retromusic.appshortcuts.shortcuttype.TopTracksShortcutType
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.ShuffleAllPlaylist
|
||||
|
@ -31,16 +32,7 @@ class AppShortcutLauncherActivity : Activity() {
|
|||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
var shortcutType = SHORTCUT_TYPE_NONE
|
||||
|
||||
// Set shortcutType from the intent extras
|
||||
val extras = intent.extras
|
||||
if (extras != null) {
|
||||
shortcutType = extras.getInt(KEY_SHORTCUT_TYPE, SHORTCUT_TYPE_NONE)
|
||||
}
|
||||
|
||||
when (shortcutType) {
|
||||
when (extraNotNull(KEY_SHORTCUT_TYPE, SHORTCUT_TYPE_NONE).value) {
|
||||
SHORTCUT_TYPE_SHUFFLE_ALL -> {
|
||||
startServiceWithPlaylist(
|
||||
SHUFFLE_MODE_SHUFFLE, ShuffleAllPlaylist()
|
||||
|
@ -78,9 +70,9 @@ class AppShortcutLauncherActivity : Activity() {
|
|||
|
||||
companion object {
|
||||
const val KEY_SHORTCUT_TYPE = "code.name.monkey.retromusic.appshortcuts.ShortcutType"
|
||||
const val SHORTCUT_TYPE_SHUFFLE_ALL = 0
|
||||
const val SHORTCUT_TYPE_TOP_TRACKS = 1
|
||||
const val SHORTCUT_TYPE_LAST_ADDED = 2
|
||||
const val SHORTCUT_TYPE_NONE = 4
|
||||
const val SHORTCUT_TYPE_SHUFFLE_ALL = 0L
|
||||
const val SHORTCUT_TYPE_TOP_TRACKS = 1L
|
||||
const val SHORTCUT_TYPE_LAST_ADDED = 2L
|
||||
const val SHORTCUT_TYPE_NONE = 4L
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class DynamicShortcutManager(private val context: Context) {
|
|||
this.context.getSystemService(ShortcutManager::class.java)
|
||||
|
||||
private val defaultShortcuts: List<ShortcutInfo>
|
||||
get() = Arrays.asList(
|
||||
get() = listOf(
|
||||
ShuffleAllShortcutType(context).shortcutInfo,
|
||||
TopTracksShortcutType(context).shortcutInfo,
|
||||
LastAddedShortcutType(context).shortcutInfo
|
||||
|
@ -58,8 +58,12 @@ class DynamicShortcutManager(private val context: Context) {
|
|||
icon: Icon,
|
||||
intent: Intent
|
||||
): ShortcutInfo {
|
||||
return ShortcutInfo.Builder(context, id).setShortLabel(shortLabel)
|
||||
.setLongLabel(longLabel).setIcon(icon).setIntent(intent).build()
|
||||
return ShortcutInfo.Builder(context, id)
|
||||
.setShortLabel(shortLabel)
|
||||
.setLongLabel(longLabel)
|
||||
.setIcon(icon)
|
||||
.setIntent(intent)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun reportShortcutUsed(context: Context, shortcutId: String) {
|
||||
|
|
|
@ -33,11 +33,11 @@ abstract class BaseShortcutType(internal var context: Context) {
|
|||
* @param shortcutType Describes the type of shortcut to create (ShuffleAll, TopTracks, custom playlist, etc.)
|
||||
* @return
|
||||
*/
|
||||
internal fun getPlaySongsIntent(shortcutType: Int): Intent {
|
||||
internal fun getPlaySongsIntent(shortcutType: Long): Intent {
|
||||
val intent = Intent(context, AppShortcutLauncherActivity::class.java)
|
||||
intent.action = Intent.ACTION_VIEW
|
||||
val b = Bundle()
|
||||
b.putInt(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType)
|
||||
b.putLong(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType)
|
||||
intent.putExtras(b)
|
||||
return intent
|
||||
}
|
||||
|
|
|
@ -26,20 +26,16 @@ import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
|
|||
class ShuffleAllShortcutType(context: Context) : BaseShortcutType(context) {
|
||||
|
||||
override val shortcutInfo: ShortcutInfo
|
||||
get() = ShortcutInfo.Builder(
|
||||
context, id
|
||||
).setShortLabel(context.getString(R.string.app_shortcut_shuffle_all_short)).setLongLabel(
|
||||
context.getString(R.string.app_shortcut_shuffle_all_long)
|
||||
).setIcon(
|
||||
AppShortcutIconGenerator.generateThemedIcon(
|
||||
context, R.drawable.ic_app_shortcut_shuffle_all
|
||||
)
|
||||
).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL))
|
||||
get() = ShortcutInfo.Builder(context, id)
|
||||
.setShortLabel(context.getString(R.string.app_shortcut_shuffle_all_short))
|
||||
.setLongLabel(context.getString(R.string.app_shortcut_shuffle_all_long))
|
||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(context, R.drawable.ic_app_shortcut_shuffle_all))
|
||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL))
|
||||
.build()
|
||||
|
||||
companion object {
|
||||
|
||||
val id: String
|
||||
get() = BaseShortcutType.ID_PREFIX + "shuffle_all"
|
||||
get() = ID_PREFIX + "shuffle_all"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,8 +168,8 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
|||
}
|
||||
|
||||
override fun onPause() {
|
||||
recyclerViewDragDropManager?.cancelDrag()
|
||||
super.onPause()
|
||||
recyclerViewDragDropManager?.cancelDrag()
|
||||
progressViewUpdateHelper.stop()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import kotlin.math.abs
|
|||
object PlaylistIdGenerator {
|
||||
|
||||
operator fun invoke(name: String, @DrawableRes iconRes: Int): Long {
|
||||
return -abs(31L * name.hashCode() + iconRes * name.hashCode() * 31L * 31L)
|
||||
return abs(31L * name.hashCode() + iconRes * name.hashCode() * 31L * 31L)
|
||||
}
|
||||
|
||||
}
|
|
@ -72,8 +72,10 @@ import code.name.monkey.retromusic.appwidgets.AppWidgetText;
|
|||
import code.name.monkey.retromusic.glide.BlurTransformation;
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest;
|
||||
import code.name.monkey.retromusic.helper.ShuffleHelper;
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
|
||||
import code.name.monkey.retromusic.model.Playlist;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist;
|
||||
import code.name.monkey.retromusic.providers.HistoryStore;
|
||||
import code.name.monkey.retromusic.providers.MusicPlaybackQueueStore;
|
||||
import code.name.monkey.retromusic.providers.SongPlayCountStore;
|
||||
|
@ -1271,10 +1273,10 @@ public class MusicService extends Service
|
|||
}
|
||||
|
||||
private void playFromPlaylist(Intent intent) {
|
||||
Playlist playlist = intent.getParcelableExtra(INTENT_EXTRA_PLAYLIST);
|
||||
AbsSmartPlaylist playlist = intent.getParcelableExtra(INTENT_EXTRA_PLAYLIST);
|
||||
int shuffleMode = intent.getIntExtra(INTENT_EXTRA_SHUFFLE_MODE, getShuffleMode());
|
||||
if (playlist != null) {
|
||||
List<Song> playlistSongs = playlist.getSongs();
|
||||
List<Song> playlistSongs = playlist.songs();
|
||||
if (!playlistSongs.isEmpty()) {
|
||||
if (shuffleMode == SHUFFLE_MODE_SHUFFLE) {
|
||||
int startPosition = new Random().nextInt(playlistSongs.size());
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/roundSelector"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="14dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/previousButton"
|
||||
|
@ -124,6 +126,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/roundSelector"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="14dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/nextButton"
|
||||
|
|
|
@ -519,7 +519,6 @@
|
|||
|
||||
<string name="pref_snow_fall_title">Эффект снегопада</string>
|
||||
|
||||
<string name="action_album_artists_only">Только альбомы исполнителей</string>
|
||||
<string name="pref_summary_album_art_on_lockscreen">Использовать обложку альбома текущей песни в качестве обоев на экране блокировки.</string>
|
||||
<string name="pref_summary_audio_ducking">Снизить громкость воспроизведения когда приходит звуковое уведомление</string>
|
||||
<string name="pref_summary_blacklist">Содержимое черного списка скрыто из вашей библиотеки.</string>
|
||||
|
|
Loading…
Reference in New Issue