diff options
| author | 2023-08-30 17:43:10 -0400 | |
|---|---|---|
| committer | 2023-08-30 17:43:10 -0400 | |
| commit | c5357b17e6f19a506f181ad006b486b68d0b1921 (patch) | |
| tree | 7e1def3da84c4b01a46b5d465c9b7481ff9d98d3 | |
| parent | Merge pull request #11405 from t895/emulation-loading (diff) | |
| parent | android: Support dynamic app shortcuts (diff) | |
| download | yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.gz yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.xz yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.zip | |
Merge pull request #11416 from t895/shortcuts
android: Support dynamic app shortcuts
Diffstat (limited to '')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt index 13359ef36..0013e8512 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | package org.yuzu.yuzu_emu.adapters | 4 | package org.yuzu.yuzu_emu.adapters |
| 5 | 5 | ||
| 6 | import android.content.Intent | ||
| 7 | import android.graphics.drawable.BitmapDrawable | ||
| 6 | import android.net.Uri | 8 | import android.net.Uri |
| 7 | import android.text.TextUtils | 9 | import android.text.TextUtils |
| 8 | import android.view.LayoutInflater | 10 | import android.view.LayoutInflater |
| @@ -11,6 +13,9 @@ import android.view.ViewGroup | |||
| 11 | import android.widget.ImageView | 13 | import android.widget.ImageView |
| 12 | import android.widget.Toast | 14 | import android.widget.Toast |
| 13 | import androidx.appcompat.app.AppCompatActivity | 15 | import androidx.appcompat.app.AppCompatActivity |
| 16 | import androidx.core.content.pm.ShortcutInfoCompat | ||
| 17 | import androidx.core.content.pm.ShortcutManagerCompat | ||
| 18 | import androidx.core.graphics.drawable.IconCompat | ||
| 14 | import androidx.documentfile.provider.DocumentFile | 19 | import androidx.documentfile.provider.DocumentFile |
| 15 | import androidx.lifecycle.ViewModelProvider | 20 | import androidx.lifecycle.ViewModelProvider |
| 16 | import androidx.navigation.findNavController | 21 | import androidx.navigation.findNavController |
| @@ -22,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView | |||
| 22 | import org.yuzu.yuzu_emu.HomeNavigationDirections | 27 | import org.yuzu.yuzu_emu.HomeNavigationDirections |
| 23 | import org.yuzu.yuzu_emu.R | 28 | import org.yuzu.yuzu_emu.R |
| 24 | import org.yuzu.yuzu_emu.YuzuApplication | 29 | import org.yuzu.yuzu_emu.YuzuApplication |
| 30 | import org.yuzu.yuzu_emu.activities.EmulationActivity | ||
| 25 | import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder | 31 | import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder |
| 26 | import org.yuzu.yuzu_emu.databinding.CardGameBinding | 32 | import org.yuzu.yuzu_emu.databinding.CardGameBinding |
| 27 | import org.yuzu.yuzu_emu.model.Game | 33 | import org.yuzu.yuzu_emu.model.Game |
| @@ -77,6 +83,21 @@ class GameAdapter(private val activity: AppCompatActivity) : | |||
| 77 | ) | 83 | ) |
| 78 | .apply() | 84 | .apply() |
| 79 | 85 | ||
| 86 | val openIntent = Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply { | ||
| 87 | action = Intent.ACTION_VIEW | ||
| 88 | data = Uri.parse(holder.game.path) | ||
| 89 | } | ||
| 90 | val shortcut = ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path) | ||
| 91 | .setShortLabel(holder.game.title) | ||
| 92 | .setIcon( | ||
| 93 | IconCompat.createWithBitmap( | ||
| 94 | (holder.binding.imageGameScreen.drawable as BitmapDrawable).bitmap | ||
| 95 | ) | ||
| 96 | ) | ||
| 97 | .setIntent(openIntent) | ||
| 98 | .build() | ||
| 99 | ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut) | ||
| 100 | |||
| 80 | val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game) | 101 | val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game) |
| 81 | view.findNavController().navigate(action) | 102 | view.findNavController().navigate(action) |
| 82 | } | 103 | } |