Bring auto re-locate to non-dynamic buttons.

Later will rename "dynamic" to use "custom dynamic"
This commit is contained in:
khanhduytran0 2020-11-23 14:48:47 +07:00
parent 487151c7fb
commit 7a5c6f592d
4 changed files with 22 additions and 24 deletions

View File

@ -119,10 +119,16 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
final CheckBox checkHidden = dialog.findViewById(R.id.controlsetting_checkbox_hidden);
checkHidden.setChecked(properties.hidden);
final CheckBox checkDynamicPos = dialog.findViewById(R.id.controlsetting_checkbox_dynamicpos);
checkDynamicPos.setChecked(properties.isDynamicBtn);
final LinearLayout layoutDynamicBtn = dialog.findViewById(R.id.controlsetting_dynamicbtnlayout);
final CheckBox checkDynamicPos = dialog.findViewById(R.id.controlsetting_checkbox_dynamicpos);
checkDynamicPos.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton btn, boolean checked) {
layoutDynamicBtn.setVisibility(checked ? View.VISIBLE : View.GONE);
}
});
checkDynamicPos.setChecked(properties.isDynamicBtn);
final EditText editDynamicX = dialog.findViewById(R.id.controlsetting_edit_dynamicpos_x);
final EditText editDynamicY = dialog.findViewById(R.id.controlsetting_edit_dynamicpos_y);
@ -133,14 +139,6 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
editDynamicY.setHint(Float.toString(properties.y));
editDynamicY.setText(properties.dynamicY);
checkDynamicPos.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton btn, boolean checked) {
layoutDynamicBtn.setVisibility(checked ? View.VISIBLE : View.GONE);
}
});
final CheckBox checkHoldAlt = dialog.findViewById(R.id.controlsetting_checkbox_keycombine_alt);
checkHoldAlt.setChecked(properties.holdAlt);

View File

@ -7,6 +7,7 @@ import android.widget.*;
import net.kdt.pojavlaunch.*;
import com.kdt.handleview.*;
import android.view.ViewGroup.*;
import org.lwjgl.glfw.*;
public class ControlButton extends Button implements OnLongClickListener, OnTouchListener
{
@ -100,6 +101,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
if (!mProperties.isDynamicBtn) {
mProperties.x = x;
mProperties.dynamicX = Float.toString(x / CallbackBridge.windowWidth) + " * ${screen_width}";
setModified(true);
}
}
@ -110,6 +112,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
if (!mProperties.isDynamicBtn) {
mProperties.y = y;
mProperties.dynamicY = Float.toString(y / CallbackBridge.windowHeight) + " * ${screen_height}";
setModified(true);
}
}

View File

@ -100,13 +100,7 @@ public class ControlData implements Cloneable
}
public ControlData(String name, int keycode, float x, float y, float width, float height) {
this.name = name;
this.keycode = keycode;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.isDynamicBtn = false;
this(name, keycode, null, null, width, height);
}
public ControlData(String name, int keycode, String dynamicX, String dynamicY) {
@ -168,8 +162,10 @@ public class ControlData implements Cloneable
specialButtonListener = data.specialButtonListener;
}
}
} if (!isDynamicBtn) {
return;
} if (dynamicX == null) {
dynamicX = Float.toString(x);
} if (dynamicY == null) {
dynamicY = Float.toString(y);
}
x = insertDynamicPos(dynamicX);

View File

@ -1,14 +1,13 @@
package net.kdt.pojavlaunch.customcontrols;
import android.widget.*;
import android.content.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import com.google.gson.*;
import net.kdt.pojavlaunch.*;
import android.support.v7.app.*;
import java.util.*;
import java.io.*;
import net.kdt.pojavlaunch.*;
import net.kdt.pojavlaunch.prefs.*;
import org.lwjgl.glfw.*;
public class ControlLayout extends FrameLayout
{
@ -49,6 +48,8 @@ public class ControlLayout extends FrameLayout
button.isHideable = button.keycode != ControlData.SPECIALBTN_TOGGLECTRL && button.keycode != ControlData.SPECIALBTN_VIRTUALMOUSE;
button.width = button.width / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE;
button.height = button.height / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE;
button.dynamicX = Float.toString(button.x / CallbackBridge.windowWidth) + " * ${screen_width}";
button.dynamicY = Float.toString(button.y / CallbackBridge.windowHeight) + " * ${screen_height}";
addControlView(button);
}