Merge remote-tracking branch 'aosp/android12L-release' into 12.1-dev

This commit is contained in:
Suphon Thanakornpakapong
2022-05-08 18:41:13 +07:00
825 changed files with 38324 additions and 29270 deletions
@@ -37,9 +37,9 @@ import android.view.View.OnLongClickListener;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
@@ -59,7 +59,7 @@ import java.util.List;
/**
* Popup shown on long pressing an empty space in launcher
*/
public class OptionsPopupView extends ArrowPopup
public class OptionsPopupView extends ArrowPopup<Launcher>
implements OnClickListener, OnLongClickListener {
private final ArrayMap<View, OptionItem> mItemMap = new ArrayMap<>();
@@ -74,6 +74,10 @@ public class OptionsPopupView extends ArrowPopup
super(context, attrs, defStyleAttr);
}
public void setTargetRect(RectF targetRect) {
mTargetRect = targetRect;
}
@Override
public void onClick(View view) {
handleViewClick(view);
@@ -90,7 +94,7 @@ public class OptionsPopupView extends ArrowPopup
return false;
}
if (item.eventId.getId() > 0) {
mLauncher.getStatsLogManager().logger().log(item.eventId);
mActivityContext.getStatsLogManager().logger().log(item.eventId);
}
if (item.clickListener.onLongClick(view)) {
close(true);
@@ -171,21 +175,6 @@ public class OptionsPopupView extends ArrowPopup
return children;
}
@VisibleForTesting
public static ArrowPopup getOptionsPopup(Launcher launcher) {
return launcher.findViewById(R.id.popup_container);
}
public static void showDefaultOptions(Launcher launcher, float x, float y) {
float halfSize = launcher.getResources().getDimension(R.dimen.options_menu_thumb_size) / 2;
if (x < 0 || y < 0) {
x = launcher.getDragLayer().getWidth() / 2;
y = launcher.getDragLayer().getHeight() / 2;
}
RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize);
show(launcher, target, getOptions(launcher), false);
}
/**
* Returns the list of supported actions
*/
@@ -226,6 +215,11 @@ public class OptionsPopupView extends ArrowPopup
Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
return null;
} else {
AbstractFloatingView floatingView = AbstractFloatingView.getTopOpenViewWithType(
launcher, TYPE_WIDGETS_FULL_SHEET);
if (floatingView != null) {
return (WidgetsFullSheet) floatingView;
}
return WidgetsFullSheet.show(launcher, true /* animated */);
}
}
@@ -286,7 +280,7 @@ public class OptionsPopupView extends ArrowPopup
public final OnLongClickListener clickListener;
public OptionItem(Context context, int labelRes, int iconRes, EventEnum eventId,
OnLongClickListener clickListener) {
OnLongClickListener clickListener) {
this.labelRes = labelRes;
this.label = context.getText(labelRes);
this.icon = ContextCompat.getDrawable(context, iconRes);
@@ -295,7 +289,7 @@ public class OptionsPopupView extends ArrowPopup
}
public OptionItem(CharSequence label, Drawable icon, EventEnum eventId,
OnLongClickListener clickListener) {
OnLongClickListener clickListener) {
this.labelRes = 0;
this.label = label;
this.icon = icon;