|
|
@ -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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|