Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af3a3277 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Temorarily changing the long press action on the homescreen to show a...

Merge "Temorarily changing the long press action on the homescreen to show a popup menu" into ub-launcher3-master
parents 7149889d a5ace71d
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -16,12 +16,17 @@

package com.android.launcher3.uioverrides;

import android.content.Intent;
import android.view.View.AccessibilityDelegate;
import android.widget.PopupMenu;
import android.widget.Toast;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.R;
import com.android.launcher3.VerticalSwipeController;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.widget.WidgetsFullSheet;

public class UiFactory {

@@ -38,4 +43,29 @@ public class UiFactory {
                launcher.getAllAppsController(), launcher.getWorkspace(),
                new RecentsViewStateController(launcher)};
    }

    public static void onWorkspaceLongPress(Launcher launcher) {
        PopupMenu menu = new PopupMenu(launcher, launcher.getWorkspace().getPageIndicator());
        menu.getMenu().add(R.string.wallpaper_button_text).setOnMenuItemClickListener((i) -> {
            launcher.onClickWallpaperPicker(null);
            return true;
        });
        menu.getMenu().add(R.string.widget_button_text).setOnMenuItemClickListener((i) -> {
            if (launcher.getPackageManager().isSafeMode()) {
                Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
            } else {
                WidgetsFullSheet.show(launcher, true /* animated */);
            }
            return true;
        });
        if (launcher.hasSettings()) {
            menu.getMenu().add(R.string.settings_button_text).setOnMenuItemClickListener((i) -> {
                launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
                        .setPackage(launcher.getPackageName())
                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                return true;
            });
        }
        menu.show();
    }
}
+13 −6
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -122,6 +123,7 @@ import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.states.AllAppsState;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -2061,11 +2063,16 @@ public class Launcher extends BaseActivity
            intent.setPackage(pickerPackage);
        }

        final Bundle launchOptions;
        if (v != null) {
            intent.setSourceBounds(getViewBounds(v));
        try {
            startActivityForResult(intent, REQUEST_PICK_WALLPAPER,
            // If there is no target package, use the default intent chooser animation
                    hasTargetPackage ? getActivityLaunchOptions(v) : null);
            launchOptions = hasTargetPackage ? getActivityLaunchOptions(v) : null;
        } else {
            launchOptions = null;
        }
        try {
            startActivityForResult(intent, REQUEST_PICK_WALLPAPER, launchOptions);
        } catch (ActivityNotFoundException e) {
            setWaitingForResult(null);
            Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
@@ -2221,7 +2228,7 @@ public class Launcher extends BaseActivity
                    getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
                            Action.Direction.NONE, ContainerType.WORKSPACE,
                            mWorkspace.getCurrentPage());
                    getStateManager().goToState(OVERVIEW);
                    UiFactory.onWorkspaceLongPress(this);
                    mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                            HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
                    return true;
@@ -2258,7 +2265,7 @@ public class Launcher extends BaseActivity
                    getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
                            Action.Direction.NONE, ContainerType.WORKSPACE,
                            mWorkspace.getCurrentPage());
                    getStateManager().goToState(OVERVIEW);
                    UiFactory.onWorkspaceLongPress(this);
                }
                mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
                        HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.OVERVIEW;

import android.view.View.AccessibilityDelegate;

import com.android.launcher3.Launcher;
@@ -39,4 +41,8 @@ public class UiFactory {
                (OverviewPanel) launcher.getOverviewPanel(),
                launcher.getAllAppsController(), launcher.getWorkspace() };
    }

    public static void onWorkspaceLongPress(Launcher launcher) {
        launcher.getStateManager().goToState(OVERVIEW);
    }
}