Add logging to shortcut pin request handler
This commit is contained in:
parent
e08e9a370c
commit
633cc0214d
@ -2,6 +2,7 @@ package de.mm20.launcher2.activity
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import de.mm20.launcher2.searchable.SearchableRepository
|
import de.mm20.launcher2.searchable.SearchableRepository
|
||||||
import de.mm20.launcher2.search.data.AppShortcut
|
import de.mm20.launcher2.search.data.AppShortcut
|
||||||
import de.mm20.launcher2.services.favorites.FavoritesService
|
import de.mm20.launcher2.services.favorites.FavoritesService
|
||||||
@ -16,6 +17,8 @@ class AddItemActivity : Activity() {
|
|||||||
val shortcut = AppShortcut.fromPinRequestIntent(this, intent)
|
val shortcut = AppShortcut.fromPinRequestIntent(this, intent)
|
||||||
if (shortcut != null) {
|
if (shortcut != null) {
|
||||||
favoritesService.pinItem(shortcut)
|
favoritesService.pinItem(shortcut)
|
||||||
|
} else {
|
||||||
|
Log.w("MM20", "Shortcut could not be added")
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import android.content.pm.ShortcutInfo
|
|||||||
import android.graphics.drawable.AdaptiveIconDrawable
|
import android.graphics.drawable.AdaptiveIconDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
|
import android.util.Log
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import de.mm20.launcher2.appshortcuts.R
|
import de.mm20.launcher2.appshortcuts.R
|
||||||
@ -143,8 +144,19 @@ data class LauncherShortcut(
|
|||||||
val launcherApps =
|
val launcherApps =
|
||||||
context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val pinRequest = launcherApps.getPinItemRequest(data)
|
val pinRequest = launcherApps.getPinItemRequest(data)
|
||||||
val shortcutInfo = pinRequest?.shortcutInfo ?: return null
|
if (pinRequest == null) {
|
||||||
if (!pinRequest.accept()) return null
|
Log.w("MM20", "Pin request could not be retrieved from intent")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val shortcutInfo = pinRequest.shortcutInfo
|
||||||
|
if (shortcutInfo == null) {
|
||||||
|
Log.w("MM20", "Pin request is missing shortcut info")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (!pinRequest.accept()) {
|
||||||
|
Log.w("MM20", "Pin request could not be accepted")
|
||||||
|
return null
|
||||||
|
}
|
||||||
return LauncherShortcut(
|
return LauncherShortcut(
|
||||||
context,
|
context,
|
||||||
shortcutInfo,
|
shortcutInfo,
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import android.content.Intent
|
|||||||
import android.content.Intent.ShortcutIconResource
|
import android.content.Intent.ShortcutIconResource
|
||||||
import android.graphics.drawable.AdaptiveIconDrawable
|
import android.graphics.drawable.AdaptiveIconDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import de.mm20.launcher2.icons.*
|
import de.mm20.launcher2.icons.*
|
||||||
import de.mm20.launcher2.ktx.getDrawableOrNull
|
import de.mm20.launcher2.ktx.getDrawableOrNull
|
||||||
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||||
@ -85,6 +86,7 @@ data class LegacyShortcut(
|
|||||||
data.extras?.getParcelable(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)
|
data.extras?.getParcelable(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)
|
||||||
|
|
||||||
if (intent == null || name == null) {
|
if (intent == null || name == null) {
|
||||||
|
Log.w("MM20", "Pin request intent is missing required extras: intent=$intent, name=$name")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user