mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 16:47:14 -04:00
Roll back ControlInterface.canSnap
This commit is contained in:
parent
8e669caa2e
commit
a7809df1a5
@ -128,6 +128,7 @@ public class ControlDrawer extends ControlButton {
|
||||
setVisibility(isVisible ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(!getControlLayoutParent().getModifiable()){
|
||||
@ -163,9 +164,9 @@ public class ControlDrawer extends ControlButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cantSnap(ControlInterface button) {
|
||||
boolean result = !super.cantSnap(button);
|
||||
return !result || containsChild(button);
|
||||
public boolean canSnap(ControlInterface button) {
|
||||
boolean result = super.canSnap(button);
|
||||
return result && !containsChild(button);
|
||||
}
|
||||
|
||||
//Getters
|
||||
|
@ -184,17 +184,18 @@ public interface ControlInterface extends View.OnLongClickListener {
|
||||
* @param button The button to check
|
||||
* @return whether or not the button
|
||||
*/
|
||||
default boolean cantSnap(ControlInterface button){
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
default boolean canSnap(ControlInterface button){
|
||||
float MIN_DISTANCE = Tools.dpToPx(8);
|
||||
|
||||
if(button == this) return true;
|
||||
return net.kdt.pojavlaunch.utils.MathUtils.dist(
|
||||
if(button == this) return false;
|
||||
return !(net.kdt.pojavlaunch.utils.MathUtils.dist(
|
||||
button.getControlView().getX() + button.getControlView().getWidth() / 2f,
|
||||
button.getControlView().getY() + button.getControlView().getHeight() / 2f,
|
||||
getControlView().getX() + getControlView().getWidth() / 2f,
|
||||
getControlView().getY() + getControlView().getHeight() / 2f)
|
||||
> Math.max(button.getControlView().getWidth() / 2f + getControlView().getWidth() / 2f,
|
||||
button.getControlView().getHeight() / 2f + getControlView().getHeight() / 2f) + MIN_DISTANCE;
|
||||
button.getControlView().getHeight() / 2f + getControlView().getHeight() / 2f) + MIN_DISTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +218,7 @@ public interface ControlInterface extends View.OnLongClickListener {
|
||||
|
||||
for(ControlInterface button : ((ControlLayout) getControlView().getParent()).getButtonChildren()){
|
||||
//Step 1: Filter unwanted buttons
|
||||
if(cantSnap(button)) continue;
|
||||
if(!canSnap(button)) continue;
|
||||
|
||||
//Step 2: Get Coordinates
|
||||
float button_top = button.getControlView().getY();
|
||||
|
Loading…
x
Reference in New Issue
Block a user