Skip to content

Commit

Permalink
Add option to change shift mode between hold and toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Aug 31, 2020
1 parent f55c0c8 commit 12d6096
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
6 changes: 1 addition & 5 deletions app/src/main/assets/about_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ Using libraries:
• LegacyLauncher: Open source Minecraft LaunchWrapper by Mojang.
• LWJGL %s.
• openal_soft: OpenAL port for Android devices by apportable.
• PojavDX (dx 1.16): tool to convert java bytecode to dex.
• Android HandleView of EditText for easy resize for custom controls.
• Java AWT Implementation includes:
- Boardwalk's makeshift.
- OpenJDK 7 codes implementation.
- Developer codes (copy text, open browser,...)
• OpenJDK Mobile 9.
* Notes:
- This app is under development and will not be stable.
- This app only use LWJGL2 and didn't have a JRE8 desugar so 1.13 or above versions will not supported.
Expand Down
32 changes: 20 additions & 12 deletions app/src/main/java/net/kdt/pojavlaunch/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import android.app.AlertDialog;

public class MainActivity extends AppCompatActivity implements OnTouchListener, OnClickListener, ToggleButton.OnCheckedChangeListener
public class MainActivity extends AppCompatActivity implements OnTouchListener, OnClickListener
{
public static final String initText = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ";

Expand Down Expand Up @@ -120,6 +120,8 @@ public void handleMessage(Message msg) {
private boolean lastEnabled = false;
private boolean lastGrab = false;
private boolean isExited = false;
private boolean isShiftModeClick = false;
private boolean isShiftDown = false;
private boolean isLogAllow = false;
private int navBarHeight = 40;

Expand Down Expand Up @@ -252,6 +254,12 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
case R.id.nav_debug: toggleDebug();
break;
case R.id.nav_customkey: dialogSendCustomKey();
break;
case R.id.nav_shiftmodechg:
isShiftModeClick = !isShiftModeClick;
// shiftButton.setOnTouchListener(isShiftModeClick ? null : MainActivity.this);
Toast.makeText(MainActivity.this, getString(R.string.toast_shiftmode) + " " + getString(isShiftModeClick ? R.string.toast_shiftmode_toggle : R.string.toast_shiftmode_hold), Toast.LENGTH_SHORT).show();
break;
}
//Toast.makeText(MainActivity.this, menuItem.getTitle() + ":" + menuItem.getItemId(), Toast.LENGTH_SHORT).show();

Expand Down Expand Up @@ -301,6 +309,7 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
this.textLogBehindGL.setTypeface(Typeface.MONOSPACE);

this.textLog.setTypeface(Typeface.MONOSPACE);
this.shiftButton.setOnClickListener(this);
this.toggleLog.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener(){

@Override
Expand Down Expand Up @@ -818,14 +827,12 @@ public void onClick(View view) {

zoomButton.setVisibility((zoomButton.getVisibility() == View.GONE && mVersionInfo.optifineLib != null) ? View.VISIBLE : View.GONE);
}
}
}

@Override
public void onCheckedChanged(CompoundButton btn, boolean checked) {
switch (btn.getId()) {
break;
case R.id.control_shift:
sendKeyPress(Keyboard.KEY_LSHIFT, checked);
if (isShiftModeClick) {
isShiftDown = !isShiftDown;
sendKeyPress(Keyboard.KEY_LSHIFT, isShiftDown);
}
break;
}
}
Expand Down Expand Up @@ -864,7 +871,10 @@ public boolean onTouch(View v, MotionEvent e) {
setRightOverride(isDown);
} break;
case R.id.control_debug: sendKeyPress(Keyboard.KEY_F3, isDown); break;
// case R.id.control_shift: sendKeyPress(Keyboard.KEY_LSHIFT, isDown); break;
case R.id.control_shift:
if (!isShiftModeClick)
sendKeyPress(Keyboard.KEY_LSHIFT, isDown);
break;
case R.id.control_inventory: sendKeyPress(Keyboard.KEY_E, isDown); break;
case R.id.control_talk: sendKeyPress(Keyboard.KEY_T, isDown); break;
case R.id.control_keyboard: showKeyboard(); break;
Expand Down Expand Up @@ -1445,9 +1455,7 @@ private Button findButton(int id) {
Button button = (Button) findViewById(id);
button.setWidth((int) Tools.dpToPx(this, Tools.pxToDp(this, button.getWidth()) * PojavPreferenceActivity.PREF_BUTTONSIZE));
button.setHeight((int) Tools.dpToPx(this, Tools.pxToDp(this, button.getHeight()) * PojavPreferenceActivity.PREF_BUTTONSIZE));
if (button instanceof ToggleButton) {
((ToggleButton) button).setOnCheckedChangeListener(this);
} else button.setOnTouchListener(this);
button.setOnTouchListener(this);
return button;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>

<ToggleButton
<Button
android:textSize="20.0sp"
android:id="@+id/control_shift"
android:background="@drawable/control_button"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/menu/menu_runopt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
<item
android:id="@+id/nav_customkey"
android:title="@string/control_customkey" />
<item
android:id="@+id/nav_shiftmodechg"
android:title="@string/control_shiftmodechg" />
</menu>
10 changes: 6 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<string name="toast_permission_denied">The read/write to storage permission is required!</string>
<string name="toast_login_error">Something went wrong after login. Please feedback to the developer.\nError: %s</string>
<string name="toast_optifine_success">Install successful</string>
<string name="toast_shiftmode">Shift (sneak) button mode changed to</string>
<string name="toast_shiftmode_hold">Hold mode</string>
<string name="toast_shiftmode_toggle">Click toggle mode</string>
<!--
<string name="toast_3">Exit</string>
-->
Expand Down Expand Up @@ -126,7 +129,6 @@
<string name="mcl_about">
%1$s BETA (Minecraft Java launcher for Android), version " + PathTools.usingVerName + "\n" +
" - by Khanh Duy Tran (based from \"Boardwalk\" app)\n" +
//"© 2019 Khanh Duy Tran\n" +
"Using libraries:\n" +
" • LWJGL " + org.lwjgl.Sys.getVersion() + "\n" +
//" • Boardwalk memory manager (not used now).\n" +
Expand Down Expand Up @@ -179,8 +181,8 @@
<string name="control_viewout">Log output</string>
<string name="control_adebug">PointerCapture Debug</string>
<string name="control_customkey">Send custom keycode</string>

<string name="control_more3"></string>
<string name="control_shiftmodechg">Change Shift (Sneak) mode</string>

<string name="control_more4"></string>

<string name="customctrl_keyname">Keycode</string>
Expand All @@ -199,5 +201,5 @@
<string name="main_switchuser">Switch user</string>
<string name="main_version_">Version:</string>
<string name="main_nocrash">No crash detected</string>
<string name="main_nolog">No log.</string>
<string name="main_nolog">No log.</string>
</resources>

0 comments on commit 12d6096

Please sign in to comment.