mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 13:30:15 -07:00
Settings Toasts, Long tap improvments, updated miniclient
This commit is contained in:
parent
108695fec5
commit
4979167651
4 changed files with 39 additions and 26 deletions
|
|
@ -105,7 +105,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
lp.addRule(RelativeLayout.ALIGN_PARENT_END);
|
lp.addRule(RelativeLayout.ALIGN_PARENT_END);
|
||||||
RelativeLayout.LayoutParams lp1 = (RelativeLayout.LayoutParams) findViewById(R.id.mb2).getLayoutParams();
|
RelativeLayout.LayoutParams lp1 = (RelativeLayout.LayoutParams) findViewById(R.id.mb2).getLayoutParams();
|
||||||
lp1.addRule(RelativeLayout.LEFT_OF,R.id.keyboard);
|
lp1.addRule(RelativeLayout.LEFT_OF,R.id.keyboard);
|
||||||
lp1.addRule(RelativeLayout.RIGHT_OF); // Clear right of prop
|
lp1.addRule(RelativeLayout.RIGHT_OF,0); // Clear right_of prop
|
||||||
RelativeLayout.LayoutParams lp2 = (RelativeLayout.LayoutParams) findViewById(R.id.main_toggle_mouse).getLayoutParams();
|
RelativeLayout.LayoutParams lp2 = (RelativeLayout.LayoutParams) findViewById(R.id.main_toggle_mouse).getLayoutParams();
|
||||||
lp2.addRule(RelativeLayout.LEFT_OF,R.id.keyboard);
|
lp2.addRule(RelativeLayout.LEFT_OF,R.id.keyboard);
|
||||||
RelativeLayout.LayoutParams lp3 = (RelativeLayout.LayoutParams) findViewById(R.id.installmod_scale_down).getLayoutParams();
|
RelativeLayout.LayoutParams lp3 = (RelativeLayout.LayoutParams) findViewById(R.id.installmod_scale_down).getLayoutParams();
|
||||||
|
|
@ -148,7 +148,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
|
|
||||||
if(action == 0){
|
if(action == KeyEvent.ACTION_DOWN){
|
||||||
// Reset checks because this is a new tap
|
// Reset checks because this is a new tap
|
||||||
longPressTriggered = false;
|
longPressTriggered = false;
|
||||||
totalMovement = 0;
|
totalMovement = 0;
|
||||||
|
|
@ -169,12 +169,13 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long press
|
// Long press
|
||||||
totalMovement += Math.abs(x - prevX) + Math.abs(y - prevX);
|
totalMovement += Math.abs(x - prevX) + Math.abs(y - prevY);
|
||||||
if(!longPressTriggered &&
|
if(!longPressTriggered &&
|
||||||
System.currentTimeMillis() - touchStart > 1500 &&
|
System.currentTimeMillis() - touchStart > 1500 &&
|
||||||
totalMovement < 8000
|
totalMovement < 5
|
||||||
){
|
){
|
||||||
longPressTriggered = true;
|
longPressTriggered = true;
|
||||||
|
Log.i("Longpress: ",""+totalMovement);
|
||||||
AWTInputBridge.sendKey((char)118,118);
|
AWTInputBridge.sendKey((char)118,118);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
vb.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
|
vb.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||||
|
|
@ -302,6 +303,19 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if(event.getAction() == KeyEvent.ACTION_DOWN){
|
if(event.getAction() == KeyEvent.ACTION_DOWN){
|
||||||
|
/*
|
||||||
|
|
||||||
|
About Key Events. Because the Android Spec doesn't require
|
||||||
|
soft keyboards to dispatch key events not all keyboard implementations
|
||||||
|
across Android will trigger these actions.
|
||||||
|
|
||||||
|
Currently we use the following function to translate keycodes for
|
||||||
|
special character, capital letters, and digits.
|
||||||
|
|
||||||
|
keycode 123 (F12) is used as a single digit capslock button which
|
||||||
|
when sent to the miniclient before a char will act accordingly.
|
||||||
|
|
||||||
|
*/
|
||||||
if(event.getKeyCode() == 67){
|
if(event.getKeyCode() == 67){
|
||||||
// Backspace
|
// Backspace
|
||||||
AWTInputBridge.sendKey((char)0x08,0x08);
|
AWTInputBridge.sendKey((char)0x08,0x08);
|
||||||
|
|
@ -370,7 +384,6 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
c = '\\';
|
c = '\\';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//System.out.println("I SEE A "+(char)event.getUnicodeChar());
|
|
||||||
if(c != (char)event.getUnicodeChar()){
|
if(c != (char)event.getUnicodeChar()){
|
||||||
System.out.println("REPLACED with "+(char)c);
|
System.out.println("REPLACED with "+(char)c);
|
||||||
AWTInputBridge.sendKey((char)123,123);
|
AWTInputBridge.sendKey((char)123,123);
|
||||||
|
|
@ -378,14 +391,12 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
||||||
AWTInputBridge.sendKey((char)c,c);
|
AWTInputBridge.sendKey((char)c,c);
|
||||||
|
|
||||||
} else if(Character.isDigit((char)event.getUnicodeChar())){
|
} else if(Character.isDigit((char)event.getUnicodeChar())){
|
||||||
System.out.println("I SEE A "+(char)event.getUnicodeChar());
|
|
||||||
AWTInputBridge.sendKey((char)event.getUnicodeChar(),(char)event.getUnicodeChar());
|
AWTInputBridge.sendKey((char)event.getUnicodeChar(),(char)event.getUnicodeChar());
|
||||||
} else if ((char)event.getUnicodeChar() == Character.toUpperCase((char)event.getUnicodeChar())){
|
} else if ((char)event.getUnicodeChar() == Character.toUpperCase((char)event.getUnicodeChar())){
|
||||||
// We send a '`' (keycode) 192 to avoid needing to worry about shift. The RS client takes this modifier
|
// We send F12 (keycode 123) to avoid needing to worry about shift. The RS client takes this modifier
|
||||||
// and does a toUpperCase(). Special character mapping will also need to be provided.
|
// and does a toUpperCase().
|
||||||
AWTInputBridge.sendKey((char)123,123);
|
AWTInputBridge.sendKey((char)123,123);
|
||||||
AWTInputBridge.sendKey((char)Character.toUpperCase(event.getUnicodeChar()),(char)Character.toUpperCase(event.getUnicodeChar()));
|
AWTInputBridge.sendKey((char)Character.toUpperCase(event.getUnicodeChar()),(char)Character.toUpperCase(event.getUnicodeChar()));
|
||||||
|
|
||||||
// Send shift key.. only problem is then you're stuck shifted.
|
// Send shift key.. only problem is then you're stuck shifted.
|
||||||
// AWTInputBridge.sendKey((char)0x10,(char)Character.toUpperCase(event.getUnicodeChar()),0,0x10);
|
// AWTInputBridge.sendKey((char)0x10,(char)Character.toUpperCase(event.getUnicodeChar()),0,0x10);
|
||||||
} else if((char)event.getUnicodeChar() == Character.toLowerCase((char)event.getUnicodeChar())){
|
} else if((char)event.getUnicodeChar() == Character.toLowerCase((char)event.getUnicodeChar())){
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,7 @@ public class SettingsMenu extends Activity {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case FILE_SELECT_CODE:
|
case FILE_SELECT_CODE:
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
// Get the Uri of the selected file
|
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
Log.d("TAG", "File Uri: " + uri.toString());
|
|
||||||
// Get the path
|
|
||||||
Log.d("TAG", "File Path: " + uri.getPath());
|
|
||||||
// Get the file instance
|
|
||||||
File config = new File(getFilesDir(), "config.json");
|
File config = new File(getFilesDir(), "config.json");
|
||||||
try {
|
try {
|
||||||
Log.d("TAG", "Starting copy: " + uri.getPath());
|
Log.d("TAG", "Starting copy: " + uri.getPath());
|
||||||
|
|
@ -70,7 +65,8 @@ public class SettingsMenu extends Activity {
|
||||||
}
|
}
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
System.out.println("Wrote new config to Local");
|
Toast.makeText(this, "Config loaded. Please restart the app.",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
Log.d("error", "Error with file " + e1);
|
Log.d("error", "Error with file " + e1);
|
||||||
}
|
}
|
||||||
|
|
@ -141,14 +137,14 @@ public class SettingsMenu extends Activity {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
righthanded.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
righthanded.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
// do something, the isChecked will be
|
||||||
// do something, the isChecked will be
|
// true if the switch is in the On position
|
||||||
// true if the switch is in the On position
|
System.out.println(isChecked);
|
||||||
System.out.println(isChecked);
|
editor.putString("righthanded",""+isChecked);
|
||||||
editor.putString("righthanded",""+isChecked);
|
editor.commit();
|
||||||
editor.commit();
|
Toast.makeText(this, "Relaunch required to update GUI.",
|
||||||
}
|
Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/loginText"
|
android:layout_below="@+id/loginText"
|
||||||
android:layout_marginTop="43dp"
|
android:layout_marginTop="16dp"
|
||||||
android:hint="Username"
|
android:hint="Username"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/loginText" />
|
app:layout_constraintTop_toBottomOf="@+id/loginText" />
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
|
@ -35,7 +37,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/username"
|
android:layout_below="@+id/username"
|
||||||
android:layout_marginTop="28dp"
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/username"
|
app:layout_constraintTop_toBottomOf="@+id/username"
|
||||||
|
|
@ -46,6 +50,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginTop="35dp"
|
android:layout_marginTop="35dp"
|
||||||
android:text="Right Handed Mode"
|
android:text="Right Handed Mode"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|
@ -53,9 +58,10 @@
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/loadconfig"
|
android:id="@+id/loadconfig"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="Load Config"
|
android:text="Load Config"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue