Custom controls changes

- Try to get toggleable option works.
- [Bug fix] Hidden buttons
This commit is contained in:
khanhduytran0 2020-12-02 05:23:49 +07:00
parent 7b2eaeac94
commit 1b04a74f5c
2 changed files with 10 additions and 9 deletions

View File

@ -174,9 +174,8 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
public boolean onTouch(View view, MotionEvent event) {
if (!mModifiable) {
mCanTriggerLongClick = false;
// if (!mProperties.isToggle) {
if (mProperties.keycode >= 0) {
if (mProperties.keycode >= 0) {
if (!mProperties.isToggle) {
boolean isDown;
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN: // 0
@ -192,13 +191,12 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
return false;
}
MainActivity.sendKeyPress(mProperties.keycode, mMods, isDown);
return true;
} else if (mGestureDetector.onTouchEvent(event)) {
mChecked = !mChecked;
MainActivity.sendKeyPress(mProperties.keycode, mMods, mChecked);
}
/* } else if (mGestureDetector.onTouchEvent(event)) {
mChecked = !mChecked;
MainActivity.sendKeyPress(mProperties.keycode, mMods, mChecked);
} */
return true;
}
} else {
if (mGestureDetector.onTouchEvent(event)) {
mCanTriggerLongClick = true;

View File

@ -69,6 +69,9 @@ public class ControlLayout extends FrameLayout
private void addControlView(ControlData controlButton) {
final ControlButton view = new ControlButton(this, controlButton);
view.setModifiable(mModifiable);
if (!mModifiable) {
view.setAlpha(view.getProperties().hidden ? 0f : 1.0f);
}
addView(view);
setModified(true);