use of android.content.pm.ShortcutManager in project xabber-android by redsolution.
the class ShortcutBuilder method createPinnedShortcut.
public static Intent createPinnedShortcut(Context context, AbstractContact contact) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ShortcutManager manager = context.getSystemService(ShortcutManager.class);
if (manager != null && manager.isRequestPinShortcutSupported()) {
ShortcutInfo shortcutInfo = createShortcutInfo(context, contact);
Intent callbackIntent = manager.createShortcutResultIntent(shortcutInfo);
PendingIntent successCallback = PendingIntent.getBroadcast(context, 0, callbackIntent, 0);
manager.requestPinShortcut(shortcutInfo, successCallback.getIntentSender());
return null;
}
}
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, ChatActivity.createClearTopIntent(context, contact.getAccount(), contact.getUser()));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, contact.getName());
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, getAvatar(contact));
return intent;
}
use of android.content.pm.ShortcutManager in project Conversations by siacs.
the class ShortcutService method report.
@TargetApi(25)
public void report(Contact contact) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
shortcutManager.reportShortcutUsed(getShortcutId(contact));
}
}
use of android.content.pm.ShortcutManager in project SpotiQ by ZinoKader.
the class ShortcutUtil method removeAllShortcuts.
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
public static void removeAllShortcuts(Context context) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
shortcutManager.disableShortcuts(Arrays.asList(ApplicationConstants.SEARCH_SHORTCUT_ID));
shortcutManager.removeAllDynamicShortcuts();
}
use of android.content.pm.ShortcutManager in project Pix-Art-Messenger by kriztan.
the class ShortcutService method report.
@TargetApi(25)
public void report(Contact contact) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
shortcutManager.reportShortcutUsed(getShortcutId(contact));
}
}
use of android.content.pm.ShortcutManager in project Pix-Art-Messenger by kriztan.
the class ShortcutService method refreshImpl.
@TargetApi(25)
private void refreshImpl(boolean forceUpdate) {
List<FrequentContact> frequentContacts = xmppConnectionService.databaseBackend.getFrequentContacts(30);
HashMap<String, Account> accounts = new HashMap<>();
for (Account account : xmppConnectionService.getAccounts()) {
accounts.put(account.getUuid(), account);
}
List<Contact> contacts = new ArrayList<>();
for (FrequentContact frequentContact : frequentContacts) {
Account account = accounts.get(frequentContact.account);
if (account != null) {
contacts.add(account.getRoster().getContact(frequentContact.contact));
}
}
ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
boolean needsUpdate = forceUpdate || contactsChanged(contacts, shortcutManager.getDynamicShortcuts());
if (!needsUpdate) {
Log.d(Config.LOGTAG, "skipping shortcut update");
return;
}
List<ShortcutInfo> newDynamicShortCuts = new ArrayList<>();
for (Contact contact : contacts) {
ShortcutInfo shortcut = new ShortcutInfo.Builder(xmppConnectionService, getShortcutId(contact)).setShortLabel(contact.getDisplayName()).setIntent(getShortcutIntent(contact)).setIcon(Icon.createWithBitmap(xmppConnectionService.getAvatarService().getRoundedShortcut(contact))).build();
newDynamicShortCuts.add(shortcut);
}
if (shortcutManager.setDynamicShortcuts(newDynamicShortCuts)) {
Log.d(Config.LOGTAG, "updated dynamic shortcuts");
} else {
Log.d(Config.LOGTAG, "unable to update dynamic shortcuts");
}
}
Aggregations