mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 23:28:52 -04:00
Better use of the SRP for the 2.2 input system
This commit is contained in:
parent
29a96330aa
commit
4ccfe06263
@ -902,25 +902,6 @@ public class BaseMainActivity extends LoggableActivity {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle on and off the soft keyboard, depending of the state
|
||||
* The condition is prone to errors if the keyboard is being hidden without the consent
|
||||
* of the current TouchCharInput
|
||||
*/
|
||||
public void switchKeyboardState(){
|
||||
//If an hard keyboard is present, never trigger the soft one
|
||||
if(touchCharInput.hasFocus()
|
||||
|| getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY){
|
||||
touchCharInput.clear();
|
||||
touchCharInput.disable();
|
||||
|
||||
}else{
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
touchCharInput.enable();
|
||||
touchCharInput.postDelayed(() -> imm.showSoftInput(touchCharInput, InputMethodManager.SHOW_IMPLICIT), 200);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRightOverride(boolean val) {
|
||||
this.rightOverride = val;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class MainActivity extends BaseMainActivity {
|
||||
for(int keycode : button.getProperties().keycodes){
|
||||
switch (keycode) {
|
||||
case ControlData.SPECIALBTN_KEYBOARD:
|
||||
switchKeyboardState();
|
||||
touchCharInput.switchKeyboardState();
|
||||
break;
|
||||
|
||||
case ControlData.SPECIALBTN_TOGGLECTRL:
|
||||
|
@ -1,8 +1,13 @@
|
||||
package net.kdt.pojavlaunch.customcontrols;
|
||||
|
||||
|
||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -87,6 +92,27 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
|
||||
super.setSelection(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle on and off the soft keyboard, depending of the state
|
||||
*
|
||||
* @return if the keyboard is set to be shown.
|
||||
*/
|
||||
public boolean switchKeyboardState(){
|
||||
//If an hard keyboard is present, never trigger the soft one
|
||||
if(hasFocus()
|
||||
|| getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY){
|
||||
clear();
|
||||
disable();
|
||||
return false;
|
||||
}else{
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
|
||||
enable();
|
||||
postDelayed(() -> imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT), 200);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the EditText from any leftover inputs
|
||||
* It does not affect the in-game input
|
||||
|
Loading…
x
Reference in New Issue
Block a user