use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.
the class LongClickReceiver method onReceive.
public void onReceive(final Context context, final Intent intent) {
final OmegaLauncher launcher = LongClickReceiver.bR.get();
if (launcher != null) {
final ComponentKey dl = AppSearchProvider.uriToComponent(intent.getData(), context);
final LauncherActivityInfo resolveActivity = LauncherAppsCompat.getInstance(context).resolveActivity(new Intent(Intent.ACTION_MAIN).setComponent(dl.componentName), dl.user);
if (resolveActivity == null) {
return;
}
final ItemDragListener onDragListener = new ItemDragListener(resolveActivity, intent.getSourceBounds());
onDragListener.init(launcher, false);
launcher.getDragLayer().setOnDragListener(onDragListener);
final ClipData clipData = new ClipData(new ClipDescription("", new String[] { onDragListener.getMimeType() }), new ClipData.Item(""));
final Bundle bundle = new Bundle();
bundle.putParcelable("clip_data", clipData);
this.setResult(-1, null, bundle);
}
}
use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.
the class AppLaunchActivity method startUri.
private void startUri(Uri uri) {
try {
ComponentKey dl = AppSearchProvider.uriToComponent(uri, this);
ItemInfo dVar = new AppItemInfoWithIcon(dl);
if (!getPackageManager().isSafeMode() || Utilities.isSystemApp(this, dVar.getIntent())) {
if (dl.user.equals(android.os.Process.myUserHandle())) {
startActivity(dVar.getIntent());
} else {
LauncherAppsCompat.getInstance(this).startActivityForProfile(dl.componentName, dl.user, getIntent().getSourceBounds(), null);
}
View view = new View(this);
view.setTag(dVar);
String predictionRank = uri.getQueryParameter("predictionRank");
new LogContainerProvider(this, TextUtils.isEmpty(predictionRank) ? -1 : Integer.parseInt(predictionRank)).addView(view);
return;
}
Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
}
}
use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.
the class AppSearchProvider method call.
public Bundle call(final String s, final String s2, final Bundle bundle) {
if (Looper.myLooper() == Looper.getMainLooper()) {
Log.d("AppSearchProvider", "Content provider accessed on main thread");
return null;
}
if ("loadIcon".equals(s))
try {
final Uri parse = Uri.parse(s2);
final ComponentKey dl = uriToComponent(parse, this.getContext());
final Callable<Bitmap> g = () -> {
final AppItemInfoWithIcon d = new AppItemInfoWithIcon(dl);
mApp.getIconCache().getTitleAndIcon(d, false);
return d.iconBitmap;
};
final Bundle bundle2 = new Bundle();
bundle2.putParcelable("suggest_icon_1", mLooper.submit(g).get());
return bundle2;
} catch (Exception ex) {
Log.e("AppSearchProvider", "Unable to load icon " + ex);
return null;
}
return super.call(s, s2, bundle);
}
use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.
the class AppSearchProvider method openFile.
public ParcelFileDescriptor openFile(final Uri uri, final String s) throws FileNotFoundException {
if (Looper.myLooper() == Looper.getMainLooper()) {
Log.e("AppSearchProvider", "Content provider accessed on main thread");
return null;
}
try {
final ComponentKey dl = uriToComponent(uri, getContext());
final String s2 = "image/png";
final Callable<Bitmap> g = () -> {
final AppItemInfoWithIcon d = new AppItemInfoWithIcon(dl);
mApp.getIconCache().getTitleAndIcon(d, false);
return d.iconBitmap;
};
return openPipeHelper(uri, s2, null, mLooper.submit(g), this.mPipeDataWriter);
} catch (Exception ex) {
throw new FileNotFoundException(ex.getMessage());
}
}
use of com.android.launcher3.util.ComponentKey in project Neo-Launcher by NeoApplications.
the class PredictionUiStateManager method fillInPredictedRank.
/**
* Fill in predicted_rank field based on app prediction.
* Only applicable when {@link ItemInfo#itemType} is one of the followings:
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
* {@link LauncherSettings.Favorites#ITEM_TYPE_DEEP_SHORTCUT}
*/
public static void fillInPredictedRank(@NonNull ItemInfo itemInfo, @NonNull LauncherLogProto.Target target) {
final PredictionUiStateManager manager = PredictionUiStateManager.INSTANCE.getNoCreate();
if (manager == null || itemInfo.getTargetComponent() == null || itemInfo.user == null || (itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_APPLICATION && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT && itemInfo.itemType != LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)) {
return;
}
final ComponentKey k = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
final List<ComponentKeyMapper> predictedApps = manager.getCurrentState().apps;
IntStream.range(0, predictedApps.size()).filter((i) -> k.equals(predictedApps.get(i).getComponentKey())).findFirst().ifPresent((rank) -> target.predictedRank = rank);
}
Aggregations