parent
18acfda99b
commit
f6126dd20e
@ -1,6 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.view
|
package com.topjohnwu.magisk.view
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ShortcutInfo
|
import android.content.pm.ShortcutInfo
|
||||||
@ -8,6 +7,8 @@ import android.content.pm.ShortcutManager
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
|
import androidx.core.content.pm.ShortcutInfoCompat
|
||||||
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import androidx.core.graphics.drawable.IconCompat
|
import androidx.core.graphics.drawable.IconCompat
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.core.Const
|
import com.topjohnwu.magisk.core.Const
|
||||||
@ -24,16 +25,14 @@ object Shortcuts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(26)
|
|
||||||
fun addHomeIcon(context: Context) {
|
fun addHomeIcon(context: Context) {
|
||||||
val manager = context.getSystemService<ShortcutManager>() ?: return
|
|
||||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName) ?: return
|
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName) ?: return
|
||||||
val info = ShortcutInfo.Builder(context, Const.Nav.HOME)
|
val info = ShortcutInfoCompat.Builder(context, Const.Nav.HOME)
|
||||||
.setShortLabel(context.getString(R.string.magisk))
|
.setShortLabel(context.getString(R.string.magisk))
|
||||||
.setIntent(intent)
|
.setIntent(intent)
|
||||||
.setIcon(context.getIcon(R.drawable.ic_launcher))
|
.setIcon(context.getIconCompat(R.drawable.ic_launcher))
|
||||||
.build()
|
.build()
|
||||||
manager.requestPinShortcut(info, null)
|
ShortcutManagerCompat.requestPinShortcut(context, info, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.getIconCompat(id: Int): IconCompat {
|
private fun Context.getIconCompat(id: Int): IconCompat {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||||
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="a.Q"
|
android:name="a.Q"
|
||||||
|
Loading…
Reference in New Issue
Block a user