Shortcut Demo: Address API changes
am: 1cf985bff6
Change-Id: I14a4e6405fd7698703dcb952496407a2c40c17d8
This commit is contained in:
@@ -165,7 +165,7 @@ public abstract class ShortcutAdapter extends BaseAdapter implements OnClickList
|
|||||||
if (showLine2()) {
|
if (showLine2()) {
|
||||||
line2.setText(
|
line2.setText(
|
||||||
si.getId() + (si.isDynamic() ? " [dynamic]" : "")
|
si.getId() + (si.isDynamic() ? " [dynamic]" : "")
|
||||||
+ (si.isManifestShortcut() ? " [manifest]" : "")
|
+ (si.isDeclaredInManifest() ? " [manifest]" : "")
|
||||||
+ (si.isPinned() ? " [pinned]" : "") + "\n"
|
+ (si.isPinned() ? " [pinned]" : "") + "\n"
|
||||||
+ "Long label: " + si.getLongLabel() + "\n"
|
+ "Long label: " + si.getLongLabel() + "\n"
|
||||||
+ "App: " + mAppLabelCache.getAppLabel(si.getPackage()));
|
+ "App: " + mAppLabelCache.getAppLabel(si.getPackage()));
|
||||||
|
|||||||
@@ -161,9 +161,9 @@ public class AppListFragment extends MyBaseListFragment {
|
|||||||
v.setVisibility(View.INVISIBLE);
|
v.setVisibility(View.INVISIBLE);
|
||||||
if (mLauncherApps.hasShortcutHostPermission()) {
|
if (mLauncherApps.hasShortcutHostPermission()) {
|
||||||
mQuery.setPackage(ai.getComponentName().getPackageName());
|
mQuery.setPackage(ai.getComponentName().getPackageName());
|
||||||
mQuery.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC
|
mQuery.setQueryFlags(ShortcutQuery.FLAG_MATCH_DYNAMIC
|
||||||
| ShortcutQuery.FLAG_GET_PINNED
|
| ShortcutQuery.FLAG_MATCH_PINNED
|
||||||
| ShortcutQuery.FLAG_GET_MANIFEST
|
| ShortcutQuery.FLAG_MATCH_MANIFEST
|
||||||
| ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY);
|
| ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY);
|
||||||
mQuery.setActivity(ai.getComponentName());
|
mQuery.setActivity(ai.getComponentName());
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import android.app.FragmentManager;
|
|||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.pm.LauncherApps;
|
import android.content.pm.LauncherApps;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.support.v13.app.FragmentStatePagerAdapter;
|
import android.support.v13.app.FragmentStatePagerAdapter;
|
||||||
import android.support.v4.view.PagerAdapter;
|
import android.support.v4.view.PagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
|
|||||||
@@ -125,9 +125,9 @@ public class ShortcutListFragment extends MyBaseListFragment {
|
|||||||
for (UserHandle user : getTargetUsers()) {
|
for (UserHandle user : getTargetUsers()) {
|
||||||
final Bundle b = getArguments();
|
final Bundle b = getArguments();
|
||||||
mQuery.setQueryFlags(
|
mQuery.setQueryFlags(
|
||||||
(b.getBoolean(ARG_INCLUDE_DYNAMIC) ? ShortcutQuery.FLAG_GET_DYNAMIC : 0) |
|
(b.getBoolean(ARG_INCLUDE_DYNAMIC) ? ShortcutQuery.FLAG_MATCH_DYNAMIC : 0) |
|
||||||
(b.getBoolean(ARG_INCLUDE_MANIFEST) ? ShortcutQuery.FLAG_GET_MANIFEST : 0) |
|
(b.getBoolean(ARG_INCLUDE_MANIFEST) ? ShortcutQuery.FLAG_MATCH_MANIFEST : 0) |
|
||||||
(b.getBoolean(ARG_INCLUDE_PINNED) ? ShortcutQuery.FLAG_GET_PINNED : 0));
|
(b.getBoolean(ARG_INCLUDE_PINNED) ? ShortcutQuery.FLAG_MATCH_PINNED : 0));
|
||||||
mQuery.setPackage(b.getString(ARG_TARGET_PACKAGE));
|
mQuery.setPackage(b.getString(ARG_TARGET_PACKAGE));
|
||||||
mQuery.setActivity(b.getParcelable(ARG_TARGET_ACTIVITY));
|
mQuery.setActivity(b.getParcelable(ARG_TARGET_ACTIVITY));
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class ShortcutPublisher extends Activity {
|
|||||||
private final Comparator<ShortcutInfo> mShortcutComparator =
|
private final Comparator<ShortcutInfo> mShortcutComparator =
|
||||||
(ShortcutInfo s1, ShortcutInfo s2) -> {
|
(ShortcutInfo s1, ShortcutInfo s2) -> {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
ret = (s1.isManifestShortcut() ? 0 : 1) - (s2.isManifestShortcut() ? 0 : 1);
|
ret = (s1.isDeclaredInManifest() ? 0 : 1) - (s2.isDeclaredInManifest() ? 0 : 1);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
ret = (s1.isDynamic() ? 0 : 1) - (s2.isDynamic() ? 0 : 1);
|
ret = (s1.isDynamic() ? 0 : 1) - (s2.isDynamic() ? 0 : 1);
|
||||||
@@ -197,21 +197,18 @@ public class ShortcutPublisher extends Activity {
|
|||||||
|
|
||||||
final ComponentName activity = new ComponentName(this, ShortcutPublisher.class);
|
final ComponentName activity = new ComponentName(this, ShortcutPublisher.class);
|
||||||
|
|
||||||
final ShortcutInfo si1 = addRandomIntents(this, new ShortcutInfo.Builder(this)
|
final ShortcutInfo si1 = addRandomIntents(this, new ShortcutInfo.Builder(this, "shortcut1"))
|
||||||
.setId("shortcut1"))
|
|
||||||
.setActivity(activity)
|
.setActivity(activity)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final ShortcutInfo si2 = new ShortcutInfo.Builder(this)
|
final ShortcutInfo si2 = new ShortcutInfo.Builder(this, SETUP_SHORTCUT_ID)
|
||||||
.setId(SETUP_SHORTCUT_ID)
|
|
||||||
.setActivity(activity)
|
.setActivity(activity)
|
||||||
.setShortLabel("Shortcut Demo Main")
|
.setShortLabel("Shortcut Demo Main")
|
||||||
.setIcon(icon2)
|
.setIcon(icon2)
|
||||||
.setIntent(intent2)
|
.setIntent(intent2)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final ShortcutInfo si3 = new ShortcutInfo.Builder(this)
|
final ShortcutInfo si3 = new ShortcutInfo.Builder(this, "shortcut3")
|
||||||
.setId("shortcut3")
|
|
||||||
.setActivity(activity)
|
.setActivity(activity)
|
||||||
.setShortLabel("Shortcut Demo Main with extras")
|
.setShortLabel("Shortcut Demo Main with extras")
|
||||||
.setIcon(icon3)
|
.setIcon(icon3)
|
||||||
@@ -237,8 +234,8 @@ public class ShortcutPublisher extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onAddPressed(View view) {
|
public void onAddPressed(View view) {
|
||||||
final ShortcutInfo si = addRandomIntents(this, new ShortcutInfo.Builder(this)
|
final ShortcutInfo si = addRandomIntents(this, new ShortcutInfo.Builder(this,
|
||||||
.setId("shortcut-" + formatTime(System.currentTimeMillis()) + "-"
|
"shortcut-" + formatTime(System.currentTimeMillis()) + "-"
|
||||||
+ sSequenceNumber.getAndIncrement()))
|
+ sSequenceNumber.getAndIncrement()))
|
||||||
.setActivity(new ComponentName(this, ShortcutPublisher.class))
|
.setActivity(new ComponentName(this, ShortcutPublisher.class))
|
||||||
.build();
|
.build();
|
||||||
@@ -251,8 +248,7 @@ public class ShortcutPublisher extends Activity {
|
|||||||
|
|
||||||
for (ShortcutInfo si : getAllShortcuts()) {
|
for (ShortcutInfo si : getAllShortcuts()) {
|
||||||
if (SETUP_SHORTCUT_ID.equals(si.getId())) continue;
|
if (SETUP_SHORTCUT_ID.equals(si.getId())) continue;
|
||||||
updateList.add(addRandomIntents(this, new ShortcutInfo.Builder(this)
|
updateList.add(addRandomIntents(this, new ShortcutInfo.Builder(this, si.getId()))
|
||||||
.setId(si.getId()))
|
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
callApi(this, () -> mShortcutManager.updateShortcuts(updateList));
|
callApi(this, () -> mShortcutManager.updateShortcuts(updateList));
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ public class ShortcutPublishingService extends IntentService {
|
|||||||
|
|
||||||
private void addShortcut() {
|
private void addShortcut() {
|
||||||
final ShortcutInfo si1 = ShortcutPublisher.addRandomIntents(
|
final ShortcutInfo si1 = ShortcutPublisher.addRandomIntents(
|
||||||
this, new ShortcutInfo.Builder(this)
|
this, new ShortcutInfo.Builder(this, ("shortcut-" + System.currentTimeMillis())))
|
||||||
.setId("shortcut-" + System.currentTimeMillis()))
|
|
||||||
.setActivity(new ComponentName(this, ShortcutPublisher.class))
|
.setActivity(new ComponentName(this, ShortcutPublisher.class))
|
||||||
.build();
|
.build();
|
||||||
ShortcutPublisher.callApi(this, () ->
|
ShortcutPublisher.callApi(this, () ->
|
||||||
|
|||||||
Reference in New Issue
Block a user