use of android.content.pm.ShortcutManager in project plaid by nickbutcher.
the class ShortcutHelper method reportSearchUsed.
@TargetApi(Build.VERSION_CODES.N_MR1)
public static void reportSearchUsed(@NonNull Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1)
return;
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
shortcutManager.reportShortcutUsed(SEARCH_SHORTCUT_ID);
}
use of android.content.pm.ShortcutManager in project platform_frameworks_base by android.
the class RemoteInputView method sendRemoteInput.
private void sendRemoteInput() {
Bundle results = new Bundle();
results.putString(mRemoteInput.getResultKey(), mEditText.getText().toString());
Intent fillInIntent = new Intent().addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
RemoteInput.addResultsToIntent(mRemoteInputs, fillInIntent, results);
mEditText.setEnabled(false);
mSendButton.setVisibility(INVISIBLE);
mProgressBar.setVisibility(VISIBLE);
mEntry.remoteInputText = mEditText.getText();
mController.addSpinning(mEntry.key, mToken);
mController.removeRemoteInput(mEntry, mToken);
mEditText.mShowImeOnInputConnection = false;
mController.remoteInputSent(mEntry);
// Tell ShortcutManager that this package has been "activated". ShortcutManager
// will reset the throttling for this package.
// Strictly speaking, the intent receiver may be different from the notification publisher,
// but that's an edge case, and also because we can't always know which package will receive
// an intent, so we just reset for the publisher.
getContext().getSystemService(ShortcutManager.class).onApplicationActive(mEntry.notification.getPackageName(), mEntry.notification.getUser().getIdentifier());
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_SEND, mEntry.notification.getPackageName());
try {
mPendingIntent.send(mContext, 0, fillInIntent);
} catch (PendingIntent.CanceledException e) {
Log.i(TAG, "Unable to send remote input result", e);
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_FAIL, mEntry.notification.getPackageName());
}
}
use of android.content.pm.ShortcutManager in project android_frameworks_base by ResurrectionRemix.
the class RemoteInputView method sendRemoteInput.
private void sendRemoteInput() {
Bundle results = new Bundle();
results.putString(mRemoteInput.getResultKey(), mEditText.getText().toString());
Intent fillInIntent = new Intent().addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
RemoteInput.addResultsToIntent(mRemoteInputs, fillInIntent, results);
mEditText.setEnabled(false);
mSendButton.setVisibility(INVISIBLE);
mProgressBar.setVisibility(VISIBLE);
mEntry.remoteInputText = mEditText.getText();
mController.addSpinning(mEntry.key, mToken);
mController.removeRemoteInput(mEntry, mToken);
mEditText.mShowImeOnInputConnection = false;
mController.remoteInputSent(mEntry);
// Tell ShortcutManager that this package has been "activated". ShortcutManager
// will reset the throttling for this package.
// Strictly speaking, the intent receiver may be different from the notification publisher,
// but that's an edge case, and also because we can't always know which package will receive
// an intent, so we just reset for the publisher.
getContext().getSystemService(ShortcutManager.class).onApplicationActive(mEntry.notification.getPackageName(), mEntry.notification.getUser().getIdentifier());
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_SEND, mEntry.notification.getPackageName());
try {
mPendingIntent.send(mContext, 0, fillInIntent);
} catch (PendingIntent.CanceledException e) {
Log.i(TAG, "Unable to send remote input result", e);
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_REMOTE_INPUT_FAIL, mEntry.notification.getPackageName());
}
}
use of android.content.pm.ShortcutManager in project android_packages_apps_Settings by LineageOS.
the class CreateShortcut method createResultIntent.
protected Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo, CharSequence label) {
shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
ShortcutManager sm = getSystemService(ShortcutManager.class);
ActivityInfo activityInfo = resolveInfo.activityInfo;
Icon maskableIcon = activityInfo.icon != 0 ? Icon.createWithAdaptiveBitmap(createIcon(activityInfo.icon, R.layout.shortcut_badge_maskable, getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable))) : Icon.createWithResource(this, R.mipmap.ic_launcher);
String shortcutId = SHORTCUT_ID_PREFIX + shortcutIntent.getComponent().flattenToShortString();
ShortcutInfo info = new ShortcutInfo.Builder(this, shortcutId).setShortLabel(label).setIntent(shortcutIntent).setIcon(maskableIcon).build();
Intent intent = sm.createShortcutResultIntent(info);
if (intent == null) {
intent = new Intent();
}
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher));
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
if (activityInfo.icon != 0) {
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(activityInfo.icon, R.layout.shortcut_badge, getResources().getDimensionPixelSize(R.dimen.shortcut_size)));
}
return intent;
}
use of android.content.pm.ShortcutManager in project packages_apps_AicpExtras by AICP.
the class LauncherActivity method initShortcutManager.
private void initShortcutManager() {
final ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (Util.isPackageEnabled(Constants.AICP_OTA_PACKAGE, this.getPackageManager())) {
// Intent for launching AICP OTA
final Intent INTENT_OTA = new Intent().setComponent(new ComponentName(Constants.AICP_OTA_PACKAGE, Constants.AICP_OTA_ACTIVITY));
INTENT_OTA.setAction(Intent.ACTION_VIEW);
ShortcutInfo aicpotaShortcut = new ShortcutInfo.Builder(this, "aicpota").setShortLabel(getString(R.string.aicp_ota_title)).setLongLabel(getString(R.string.aicp_ota_title)).setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_shortcut_ota)).setIntent(INTENT_OTA).setRank(0).build();
shortcutManager.setDynamicShortcuts(Arrays.asList(aicpotaShortcut));
} else {
ShortcutInfo downloadsShortcut = new ShortcutInfo.Builder(this, "downloads").setShortLabel(getString(R.string.aicp_downloads_title)).setLongLabel(getString(R.string.aicp_downloads_title)).setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_shortcut_downloads)).setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(Util.getDownloadLinkForDevice(this)))).setRank(0).build();
shortcutManager.setDynamicShortcuts(Arrays.asList(downloadsShortcut));
}
}
Aggregations