Commit 9c36f84b authored by Mygod's avatar Mygod

Update shortcut APIs

parent 143afb05
...@@ -24,6 +24,8 @@ import android.app.Activity ...@@ -24,6 +24,8 @@ import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.pm.ShortcutManager import android.content.pm.ShortcutManager
import android.os.{Build, Bundle} import android.os.{Build, Bundle}
import android.support.v4.content.pm.{ShortcutInfoCompat, ShortcutManagerCompat}
import android.support.v4.graphics.drawable.IconCompat
import com.github.shadowsocks.utils.{State, Utils} import com.github.shadowsocks.utils.{State, Utils}
/** /**
...@@ -34,11 +36,12 @@ class QuickToggleShortcut extends Activity with ServiceBoundContext { ...@@ -34,11 +36,12 @@ class QuickToggleShortcut extends Activity with ServiceBoundContext {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
getIntent.getAction match { getIntent.getAction match {
case Intent.ACTION_CREATE_SHORTCUT => case Intent.ACTION_CREATE_SHORTCUT =>
setResult(Activity.RESULT_OK, new Intent() setResult(Activity.RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this,
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, classOf[QuickToggleShortcut])) new ShortcutInfoCompat.Builder(this, "toggle")
.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.quick_toggle)) .setIntent(new Intent(this, classOf[QuickToggleShortcut]).setAction(Intent.ACTION_MAIN))
.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, .setIcon(IconCompat.createWithResource(this, R.drawable.ic_qu_shadowsocks_launcher))
Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher))) .setShortLabel(getString(R.string.quick_toggle))
.build()))
finish() finish()
case _ => case _ =>
attachService() attachService()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment