if (shortcutInfo.getShortLabel() != null) { pojo.setName(shortcutInfo.getShortLabel().toString()); } else if (shortcutInfo.getLongLabel() != null) { pojo.setName(shortcutInfo.getLongLabel().toString());
@Override public CharSequence getLabel() { return mInfo.getShortLabel(); }
public CharSequence getShortLabel() { return mShortcutInfo.getShortLabel(); }
public CharSequence getShortLabel() { return mShortcutInfo.getShortLabel(); }
public CharSequence getShortLabel() { return mShortcutInfo.getShortLabel(); }
@Override public void onBindViewHolder(ViewHolder holder, int position) { if (!SDKUtil.AT_LEAST_N_MR1) { return; } final ShortcutInfo shortcutInfo = mShortcuts.get(position); holder.titleTextView.setText(shortcutInfo.getShortLabel()); holder.iconImageView.setImageDrawable(ShortcutUtil.loadDrawable(holder.itemView.getContext(), shortcutInfo)); holder.itemView.setOnClickListener(view -> ShortcutUtil.launchShortcut(view, shortcutInfo)); }
private void addShortcutToActionPopup(final LauncherApps launcherApps, final ShortcutInfo shortcutInfo) { if (Build.VERSION.SDK_INT>=25) { if (shortcutInfo != null && shortcutInfo.getActivity() != null) { //Log.d(TAG, shortcutInfo.getShortLabel() + " " + shortcutInfo.getActivity().getClassName()); if (shortcutInfo.isEnabled()) { String label = ""; if (shortcutInfo.getShortLabel() != null) label += shortcutInfo.getShortLabel(); if (shortcutInfo.getLongLabel() != null && !label.contentEquals(shortcutInfo.getLongLabel())) label = shortcutInfo.getLongLabel() + ""; Drawable icon = launcherApps.getShortcutIconDrawable(shortcutInfo, DisplayMetrics.DENSITY_DEFAULT); addActionMenuItem(label.trim(), icon, new Runnable() { @Override public void run() { if (Build.VERSION.SDK_INT >= 25) { try { launcherApps.startShortcut(shortcutInfo, null, null); } catch (Exception e) { Log.e(TAG, "Couldn't Launch shortcut", e); } } dismissActionPopup(); } }); } } } }
@TargetApi(Build.VERSION_CODES.O) private void acceptShortcut(LauncherApps launcherApps, LauncherApps.PinItemRequest request) { ShortcutReceiver shrecv = GlobState.getShortcutReceiver(this); if (shrecv == null) { return; } ShortcutInfo si = request.getShortcutInfo(); if (si == null) { return; } Drawable iconDrawable = launcherApps.getShortcutIconDrawable(si, 0); Bitmap icon = null; if (iconDrawable != null) { icon = IconsHandler.drawableToBitmap(iconDrawable); } String label = null; if (si.getShortLabel() != null) { label = si.getShortLabel().toString(); CharSequence longlabel = si.getLongLabel(); if (longlabel != null) { if (longlabel.toString().startsWith(label)) { label = longlabel.toString(); } else { label += " " + longlabel; } } } shrecv.addOreoLink(this, si.getId(), si.getPackage(), label, icon); request.accept(); }
try { String shortcutsText = shortcutInfoList.get(j).getShortLabel().toString();
.setShortLabel(prevShortcut.getShortLabel()) .setLongLabel(prevShortcut.getLongLabel()) .setIntent(shortcutIntent)