Replace INSTALL_SHORTCUT with requestPinShortcut

pull/2561/head
Alex Baker 8 months ago
parent 77c86bbfb4
commit 348367e084

@ -1,15 +1,15 @@
package org.tasks.widget package org.tasks.widget
import android.app.Activity
import android.content.Intent
import android.content.Intent.ShortcutIconResource
import android.os.Bundle import android.os.Bundle
import android.os.Parcelable
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import com.todoroo.astrid.api.Filter import com.todoroo.astrid.api.Filter
import com.todoroo.astrid.helper.UUIDHelper
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import org.tasks.R import org.tasks.R
import org.tasks.Strings.isNullOrEmpty import org.tasks.Strings.isNullOrEmpty
@ -124,13 +124,15 @@ class ShortcutConfigActivity : ThemedInjectingAppCompatActivity(), ColorPaletteP
private fun save() { private fun save() {
val filterId = defaultFilterProvider.getFilterPreferenceValue(selectedFilter!!) val filterId = defaultFilterProvider.getFilterPreferenceValue(selectedFilter!!)
val shortcutIntent = TaskIntents.getTaskListByIdIntent(this, filterId) ShortcutManagerCompat.requestPinShortcut(
val icon: Parcelable = ShortcutIconResource.fromContext(this, ThemeColor.ICONS[themeIndex]) this,
val intent = Intent("com.android.launcher.action.INSTALL_SHORTCUT") ShortcutInfoCompat.Builder(this, UUIDHelper.newUUID())
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent) .setShortLabel(getShortcutName())
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getShortcutName()) .setIntent(TaskIntents.getTaskListByIdIntent(this, filterId))
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon) .setIcon(IconCompat.createWithResource(this, ThemeColor.ICONS[themeIndex]))
setResult(Activity.RESULT_OK, intent) .build(),
null,
)
finish() finish()
} }

@ -23,7 +23,7 @@ google-oauth2 = "1.19.0"
google-api-drive = "v3-rev20230822-2.0.0" google-api-drive = "v3-rev20230822-2.0.0"
google-api-tasks = "v1-rev20230401-2.0.0" google-api-tasks = "v1-rev20230401-2.0.0"
google-services = "4.4.0" google-services = "4.4.0"
gradle = "8.2.0-beta05" gradle = "8.2.0-beta06"
gson = "2.10.1" gson = "2.10.1"
hilt = "1.1.0-alpha01" hilt = "1.1.0-alpha01"
ical4android = "12fe73a" ical4android = "12fe73a"

Loading…
Cancel
Save