use of com.saggitt.omega.OmegaLauncher 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.saggitt.omega.OmegaLauncher in project Neo-Launcher by NeoApplications.
the class CustomBottomSheet method populateAndShow.
@Override
public void populateAndShow(ItemInfo itemInfo) {
super.populateAndShow(itemInfo);
mItemInfo = itemInfo;
mInfoProvider = CustomInfoProvider.Companion.forItem(getContext(), mItemInfo);
TextView title = findViewById(R.id.title);
title.setText(itemInfo.title);
((PrefsFragment) mFragmentManager.findFragmentById(R.id.sheet_prefs)).loadForApp(itemInfo, this::setForceOpen, this::unsetForceOpen, this::reopen);
boolean allowTitleEdit = true;
if (itemInfo instanceof ItemInfoWithIcon || mInfoProvider.supportsIcon()) {
ImageView icon = findViewById(R.id.icon);
if (itemInfo instanceof WorkspaceItemInfo && ((WorkspaceItemInfo) itemInfo).customIcon != null) {
icon.setImageBitmap(((WorkspaceItemInfo) itemInfo).customIcon);
} else if (itemInfo instanceof ItemInfoWithIcon) {
icon.setImageBitmap(((ItemInfoWithIcon) itemInfo).iconBitmap);
} else if (itemInfo instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) itemInfo;
icon.setImageDrawable(folderInfo.getIcon(mLauncher));
// Drawer folder
if (folderInfo.container == ItemInfo.NO_ID) {
// TODO: Allow editing title for drawer folder & sync with group backend
allowTitleEdit = false;
}
}
if (mInfoProvider != null) {
OmegaLauncher launcher = OmegaLauncher.getLauncher(getContext());
icon.setOnClickListener(v -> {
ItemInfo editItem;
if (mItemInfo instanceof FolderInfo && ((FolderInfo) mItemInfo).isCoverMode()) {
editItem = ((FolderInfo) mItemInfo).getCoverInfo();
} else {
editItem = mItemInfo;
}
CustomInfoProvider editProvider = CustomInfoProvider.Companion.forItem(getContext(), editItem);
if (editProvider != null) {
launcher.startEditIcon(editItem, editProvider);
}
});
}
}
if (mInfoProvider != null && allowTitleEdit) {
mPreviousTitle = mInfoProvider.getCustomTitle(mItemInfo);
if (mPreviousTitle == null)
mPreviousTitle = "";
mEditTitle = findViewById(R.id.edit_title);
mEditTitle.setHint(mInfoProvider.getDefaultTitle(mItemInfo));
mEditTitle.setText(mPreviousTitle);
mEditTitle.setVisibility(VISIBLE);
title.setVisibility(View.GONE);
}
}
use of com.saggitt.omega.OmegaLauncher in project Neo-Launcher by NeoApplications.
the class Launcher method onNewIntent.
@Override
protected void onNewIntent(Intent intent) {
TraceHelper.beginSection("NEW_INTENT");
super.onNewIntent(intent);
boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
// Check this condition before handling isActionMain, as this will get reset.
boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL) && AbstractFloatingView.getTopOpenView(this) == null;
boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
boolean internalStateHandled = InternalStateHandler.handleNewIntent(this, intent, isStarted());
boolean handled = false;
if (isActionMain) {
if (!internalStateHandled) {
// In all these cases, only animate if we're already on home
AbstractFloatingView.closeAllOpenViews(this, isStarted());
if (!isInState(NORMAL)) {
// Only change state, if not already the same. This prevents cancelling any
// animations running as part of resume
mStateManager.goToState(NORMAL);
}
// Reset the apps view
if (!alreadyOnHome) {
mAppsView.reset(isStarted());
handled = true;
}
if (shouldMoveToDefaultScreen && !mWorkspace.isHandlingTouch()) {
mWorkspace.post(mWorkspace::moveToDefaultScreen);
handled = true;
}
if (!handled && this instanceof OmegaLauncher) {
((OmegaLauncher) this).getGestureController().onPressHome();
}
}
// Handle HOME_INTENT
UserEventDispatcher ued = getUserEventDispatcher();
Target target = newContainerTarget(mStateManager.getState().containerType);
target.pageIndex = mWorkspace.getCurrentPage();
ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE));
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken());
}
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onHomeIntent(internalStateHandled);
}
}
TraceHelper.endSection("NEW_INTENT");
}
Aggregations