Search in sources :

Example 1 with OmegaLauncher

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);
    }
}
Also used : OmegaLauncher(com.saggitt.omega.OmegaLauncher) Bundle(android.os.Bundle) ComponentKey(com.android.launcher3.util.ComponentKey) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Intent(android.content.Intent) ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription)

Example 2 with OmegaLauncher

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);
    }
}
Also used : OmegaLauncher(com.saggitt.omega.OmegaLauncher) CustomInfoProvider(com.saggitt.omega.override.CustomInfoProvider) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ItemInfoWithIcon(com.android.launcher3.ItemInfoWithIcon) FolderInfo(com.android.launcher3.FolderInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Example 3 with OmegaLauncher

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");
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) OmegaLauncher(com.saggitt.omega.OmegaLauncher) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newTarget(com.android.launcher3.logging.LoggerUtils.newTarget) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) DragView(com.android.launcher3.dragndrop.DragView)

Aggregations

OmegaLauncher (com.saggitt.omega.OmegaLauncher)3 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 ClipData (android.content.ClipData)1 ClipDescription (android.content.ClipDescription)1 Intent (android.content.Intent)1 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)1 Bundle (android.os.Bundle)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FolderInfo (com.android.launcher3.FolderInfo)1 ItemInfo (com.android.launcher3.ItemInfo)1 ItemInfoWithIcon (com.android.launcher3.ItemInfoWithIcon)1 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 AllAppsContainerView (com.android.launcher3.allapps.AllAppsContainerView)1 DragView (com.android.launcher3.dragndrop.DragView)1 LoggerUtils.newContainerTarget (com.android.launcher3.logging.LoggerUtils.newContainerTarget)1 LoggerUtils.newTarget (com.android.launcher3.logging.LoggerUtils.newTarget)1 UserEventDispatcher (com.android.launcher3.logging.UserEventDispatcher)1 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)1