diff options
author | kaiyiz <kaiyiz@codeaurora.org> | 2013-07-29 14:19:27 +0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-08-17 02:35:26 -0700 |
commit | 913113208dd042c9dcf29c7003566c367539c77b (patch) | |
tree | ec06649c748f42943a72658f9baed4f561b23209 /src/com | |
parent | c9927e6569f2903249c4099eff12d169bdf9e696 (diff) | |
download | android_packages_apps_Trebuchet-913113208dd042c9dcf29c7003566c367539c77b.tar.gz android_packages_apps_Trebuchet-913113208dd042c9dcf29c7003566c367539c77b.tar.bz2 android_packages_apps_Trebuchet-913113208dd042c9dcf29c7003566c367539c77b.zip |
Launcher: It will pop shortcut added when the screen no room
Contacts show a sucesssful toast directly after send broadcast to
laucher evenwhen there is no room in launcher,
Laucher has no response to Contacts, and show the error toast
when there is no room.
When the shortcut put successful, Launcher broadcast an intent
with packagename, so Contacts show the sucessful toast only when
receive this intent.
CRs-Fixed: BZ707
Change-Id: I478d1dd25c494b3f0c2d1ac9711e5b56dcd8610f
Diffstat (limited to 'src/com')
-rwxr-xr-x[-rw-r--r--] | src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java index d8a69ba49..0b28ec07b 100644..100755 --- a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java +++ b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java @@ -1,5 +1,9 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2013 The Linux Foundation. All rights reserved. + * + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +21,7 @@ package com.cyanogenmod.trebuchet; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -44,6 +49,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver { private static final int INSTALL_SHORTCUT_IS_DUPLICATE = -1; private static final int INSTALL_SHORTCUT_NO_SPACE = -2; + private static final String ACTION_INSTALL_SHORTCUT_SUCCESSFUL = + "com.android.launcher.action.INSTALL_SHORTCUT_SUCCESSFUL"; + private static final String EXTRA_RESPONSE_PACKAGENAME = "response_packagename"; + private static final String EXTRA_SHORTCUT_PACKAGENAME = "shortcut_packagename"; + // A mime-type representing shortcut data public static final String SHORTCUT_MIMETYPE = "com.cyanogenmod.trebuchet/shortcut"; @@ -159,6 +169,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver { Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name), Toast.LENGTH_SHORT).show(); } + } else { + // When the shortcut put successful, broadcast an intent with package name + // So the application can use it to show a toast. + String packageName = intent.getStringExtra(EXTRA_SHORTCUT_PACKAGENAME); + Intent responseIntent = new Intent(ACTION_INSTALL_SHORTCUT_SUCCESSFUL); + responseIntent.putExtra(EXTRA_RESPONSE_PACKAGENAME, packageName); + context.sendBroadcast(responseIntent); } } |