summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-08-30 23:43:10 +0200
committerGitHub <noreply@github.com>2023-08-30 23:43:10 +0200
commitc5357b17e6f19a506f181ad006b486b68d0b1921 (patch)
tree7e1def3da84c4b01a46b5d465c9b7481ff9d98d3
parentMerge pull request #11405 from t895/emulation-loading (diff)
parentandroid: Support dynamic app shortcuts (diff)
downloadyuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.gz
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.bz2
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.lz
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.xz
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.tar.zst
yuzu-c5357b17e6f19a506f181ad006b486b68d0b1921.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt21
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 @@
package org.yuzu.yuzu_emu.adapters
+import android.content.Intent
+import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.text.TextUtils
import android.view.LayoutInflater
@@ -11,6 +13,9 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.content.pm.ShortcutInfoCompat
+import androidx.core.content.pm.ShortcutManagerCompat
+import androidx.core.graphics.drawable.IconCompat
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
@@ -22,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView
import org.yuzu.yuzu_emu.HomeNavigationDirections
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.YuzuApplication
+import org.yuzu.yuzu_emu.activities.EmulationActivity
import org.yuzu.yuzu_emu.adapters.GameAdapter.GameViewHolder
import org.yuzu.yuzu_emu.databinding.CardGameBinding
import org.yuzu.yuzu_emu.model.Game
@@ -77,6 +83,21 @@ class GameAdapter(private val activity: AppCompatActivity) :
)
.apply()
+ val openIntent = Intent(YuzuApplication.appContext, EmulationActivity::class.java).apply {
+ action = Intent.ACTION_VIEW
+ data = Uri.parse(holder.game.path)
+ }
+ val shortcut = ShortcutInfoCompat.Builder(YuzuApplication.appContext, holder.game.path)
+ .setShortLabel(holder.game.title)
+ .setIcon(
+ IconCompat.createWithBitmap(
+ (holder.binding.imageGameScreen.drawable as BitmapDrawable).bitmap
+ )
+ )
+ .setIntent(openIntent)
+ .build()
+ ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
+
val action = HomeNavigationDirections.actionGlobalEmulationActivity(holder.game)
view.findNavController().navigate(action)
}