mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-05-03 00:30:28 +00:00
v2.7
This commit is contained in:
parent
38cfb38b3f
commit
28eea7d2c3
41 changed files with 2323 additions and 371 deletions
|
|
@ -169,7 +169,7 @@ public class Config {
|
|||
public static MouseMode mouseMode = MouseMode.Trackpad;
|
||||
|
||||
//specify hd interface, alternative we don't need it right now
|
||||
public static boolean enable_hd_if = false;
|
||||
public static boolean enable_hd_if = true;
|
||||
public static String hd_if_type = "ide";
|
||||
|
||||
//Change to true in prod if you want to be notified by default for new versions
|
||||
|
|
|
|||
|
|
@ -63,8 +63,10 @@ import com.vectras.vm.MainActivity;
|
|||
import com.vectras.vm.R;
|
||||
import com.vectras.vm.adapter.LogsAdapter;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
import com.vectras.vm.widgets.JoystickView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -811,10 +813,15 @@ public class MainSDLActivity extends SDLActivity {
|
|||
if (event.getAction() == KeyEvent.ACTION_MULTIPLE && event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) {
|
||||
sendText(event.getCharacters().toString());
|
||||
return true;
|
||||
} else /*if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
this.onBackPressed();
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
FrameLayout l = findViewById(R.id.mainControl);
|
||||
if (l.getVisibility() == View.VISIBLE) {
|
||||
l.setVisibility(View.GONE);
|
||||
} else {
|
||||
l.setVisibility(View.VISIBLE);
|
||||
}
|
||||
return true;
|
||||
}*/ if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
} if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
// We emulate right click with volume down
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
@ -823,11 +830,11 @@ public class MainSDLActivity extends SDLActivity {
|
|||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
// We emulate middle click with volume up
|
||||
// We emulate left click with volume up
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
middleClick(e, 0);
|
||||
leftClick(e, 0);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -866,6 +873,8 @@ public class MainSDLActivity extends SDLActivity {
|
|||
private TimerTask t;
|
||||
public boolean ctrlClicked = false;
|
||||
public boolean altClicked = false;
|
||||
public static LinearLayout desktop;
|
||||
public static LinearLayout gamepad;
|
||||
|
||||
// Setup
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
|
|
@ -903,6 +912,20 @@ public class MainSDLActivity extends SDLActivity {
|
|||
decorView.setSystemUiVisibility(uiOptions);
|
||||
|
||||
onFitToScreen();
|
||||
desktop = findViewById(R.id.desktop);
|
||||
gamepad = findViewById(R.id.gamepad);
|
||||
|
||||
if (Objects.equals(MainSettingsManager.getControlMode(activity), "D")) {
|
||||
desktop.setVisibility(View.VISIBLE);
|
||||
gamepad.setVisibility(View.GONE);
|
||||
} else if (Objects.equals(MainSettingsManager.getControlMode(activity), "G")) {
|
||||
desktop.setVisibility(View.GONE);
|
||||
gamepad.setVisibility(View.VISIBLE);
|
||||
} else if (Objects.equals(MainSettingsManager.getControlMode(activity), "H")) {
|
||||
desktop.setVisibility(View.GONE);
|
||||
gamepad.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
ImageButton shutdownBtn = findViewById(R.id.shutdownBtn);
|
||||
ImageButton settingBtn = findViewById(R.id.btnSettings);
|
||||
|
|
@ -919,6 +942,215 @@ public class MainSDLActivity extends SDLActivity {
|
|||
ImageButton delBtn = findViewById(R.id.delBtn);
|
||||
ImageButton qmpBtn = findViewById(R.id.btnQmp);
|
||||
ImageButton btnLogs = findViewById(R.id.btnLogs);
|
||||
Button eBtn = findViewById(R.id.eBtn);
|
||||
Button rBtn = findViewById(R.id.rBtn);
|
||||
Button qBtn = findViewById(R.id.qBtn);
|
||||
Button xBtn = findViewById(R.id.xBtn);
|
||||
ImageButton ctrlGameBtn = findViewById(R.id.ctrlGameBtn);
|
||||
Button spaceBtn = findViewById(R.id.spaceBtn);
|
||||
Button tabGameBtn = findViewById(R.id.tabGameBtn);
|
||||
Button tabBtn = findViewById(R.id.tabBtn);
|
||||
ImageButton upGameBtn = findViewById(R.id.upGameBtn);
|
||||
ImageButton downGameBtn = findViewById(R.id.downGameBtn);
|
||||
ImageButton leftGameBtn = findViewById(R.id.leftGameBtn);
|
||||
ImageButton rightGameBtn = findViewById(R.id.rightGameBtn);
|
||||
ImageButton enterGameBtn = findViewById(R.id.enterGameBtn);
|
||||
upGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_UP);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_UP);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
leftGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
downGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
rightGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
int loop =10;
|
||||
JoystickView joystick = (JoystickView) findViewById(R.id.joyStick);
|
||||
joystick.setOnMoveListener(new JoystickView.OnMoveListener() {
|
||||
@Override
|
||||
public void onMove(int angle, int strength) {
|
||||
// do whatever you want
|
||||
if (angle > 0) {
|
||||
if (angle < 30) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
} else if (angle > 30) {
|
||||
if (angle < 60) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_UP_RIGHT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_UP_RIGHT);
|
||||
} else if (angle > 60) {
|
||||
if (angle < 120) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_UP);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_UP);
|
||||
} else if (angle > 120) {
|
||||
if (angle < 150) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_UP_LEFT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_UP_LEFT);
|
||||
} else if (angle > 150) {
|
||||
if (angle < 210) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
} else if (angle > 210) {
|
||||
if (angle < 240) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_DOWN_LEFT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_DOWN_LEFT);
|
||||
} else if (angle > 240) {
|
||||
if (angle < 300) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
} else if (angle > 300) {
|
||||
if (angle < 330) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_DOWN_RIGHT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_DOWN_RIGHT);
|
||||
} else if (angle > 330) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, loop);
|
||||
tabBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_TAB);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_TAB);
|
||||
}
|
||||
});
|
||||
tabGameBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_TAB);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_TAB);
|
||||
}
|
||||
});
|
||||
eBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_E);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_E);
|
||||
}
|
||||
});
|
||||
rBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_R);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_R);
|
||||
}
|
||||
});
|
||||
qBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_Q);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_Q);
|
||||
}
|
||||
});
|
||||
xBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_X);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_X);
|
||||
}
|
||||
});
|
||||
ctrlGameBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_CTRL_LEFT);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_CTRL_LEFT);
|
||||
}
|
||||
});
|
||||
spaceBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_SPACE);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_SPACE);
|
||||
}
|
||||
});
|
||||
btnLogs.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -969,9 +1201,14 @@ public class MainSDLActivity extends SDLActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_UP);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_UP);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -982,9 +1219,14 @@ public class MainSDLActivity extends SDLActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_LEFT);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -995,9 +1237,14 @@ public class MainSDLActivity extends SDLActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_DOWN);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1008,9 +1255,14 @@ public class MainSDLActivity extends SDLActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DPAD_RIGHT);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(500).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1070,7 +1322,7 @@ public class MainSDLActivity extends SDLActivity {
|
|||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DEL);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_DEL);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_DEL);
|
||||
}
|
||||
});
|
||||
qmpBtn.setVisibility(View.GONE);
|
||||
|
|
@ -1079,6 +1331,47 @@ public class MainSDLActivity extends SDLActivity {
|
|||
} else {
|
||||
qmpBtn.setImageDrawable(getResources().getDrawable(R.drawable.round_computer_24));
|
||||
}
|
||||
Button rightClickBtn = findViewById(R.id.rightClickBtn);
|
||||
Button middleClickBtn = findViewById(R.id.middleBtn);
|
||||
Button leftClickBtn = findViewById(R.id.leftClickBtn);
|
||||
ImageButton winBtn = findViewById(R.id.winBtn);
|
||||
|
||||
rightClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
rightClick(e, 0);
|
||||
}
|
||||
});
|
||||
middleClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
middleClick(e, 0);
|
||||
}
|
||||
});
|
||||
leftClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
leftClick(e, 0);
|
||||
}
|
||||
});
|
||||
winBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_CTRL_LEFT);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyDown(KeyEvent.KEYCODE_ESCAPE);
|
||||
delayKey(100);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_CTRL_LEFT);
|
||||
SDLActivity.onNativeKeyUp(KeyEvent.KEYCODE_ESCAPE);
|
||||
}
|
||||
});
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||
R.layout.container_function, functionsArray);
|
||||
|
|
@ -1116,20 +1409,6 @@ public class MainSDLActivity extends SDLActivity {
|
|||
}
|
||||
});*/
|
||||
|
||||
ImageButton hideBtn = findViewById(R.id.visibilityButton);
|
||||
hideBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FrameLayout l = findViewById(R.id.mainControl);
|
||||
if (l.getVisibility() == View.VISIBLE) {
|
||||
l.setVisibility(View.GONE);
|
||||
hideBtn.setImageResource(R.drawable.round_visibility_24);
|
||||
} else {
|
||||
l.setVisibility(View.VISIBLE);
|
||||
hideBtn.setImageResource(R.drawable.round_visibility_off_24);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1971,6 +2250,24 @@ public class MainSDLActivity extends SDLActivity {
|
|||
|
||||
}
|
||||
|
||||
public boolean leftClick(final MotionEvent e, final int i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Log.d("SDL", "Mouse Left Click");
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_LEFT, MotionEvent.ACTION_DOWN, 1, -1, -1);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
// Log.v("SDLSurface", "Interrupted: " + ex);
|
||||
}
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_LEFT, MotionEvent.ACTION_UP, 1, -1, -1);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public boolean middleClick(final MotionEvent e, final int i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.vectras.qemu;
|
||||
|
||||
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
|
|
@ -162,7 +164,11 @@ public class MainService extends Service {
|
|||
mNotification.tickerText = text;
|
||||
mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||
|
||||
service.startForeground(notifID, mNotification);
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
service.startForeground(notifID, mNotification, FOREGROUND_SERVICE_TYPE_LOCATION);
|
||||
} else {
|
||||
service.startForeground(notifID, mNotification);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import android.os.SystemClock;
|
|||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -64,12 +65,15 @@ import com.vectras.vm.R;
|
|||
import com.vectras.qemu.utils.Machine;
|
||||
import com.vectras.qemu.utils.QmpClient;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
import com.vectras.vm.widgets.JoystickView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -94,6 +98,8 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
public boolean altClicked = false;
|
||||
private ImageButton qmpBtn;
|
||||
public static MainVNCActivity activity;
|
||||
public static LinearLayout desktop;
|
||||
public static LinearLayout gamepad;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle b) {
|
||||
|
|
@ -120,6 +126,20 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
|
||||
onFitToScreen();
|
||||
|
||||
desktop = findViewById(R.id.desktop);
|
||||
gamepad = findViewById(R.id.gamepad);
|
||||
|
||||
if (Objects.equals(MainSettingsManager.getControlMode(activity), "D")) {
|
||||
desktop.setVisibility(View.VISIBLE);
|
||||
gamepad.setVisibility(View.GONE);
|
||||
} else if (Objects.equals(MainSettingsManager.getControlMode(activity), "G")) {
|
||||
desktop.setVisibility(View.GONE);
|
||||
gamepad.setVisibility(View.VISIBLE);
|
||||
} else if (Objects.equals(MainSettingsManager.getControlMode(activity), "H")) {
|
||||
desktop.setVisibility(View.GONE);
|
||||
gamepad.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImageButton shutdownBtn = findViewById(R.id.shutdownBtn);
|
||||
ImageButton settingBtn = findViewById(R.id.btnSettings);
|
||||
ImageButton keyboardBtn = findViewById(R.id.kbdBtn);
|
||||
|
|
@ -134,7 +154,148 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
ImageButton altBtn = findViewById(R.id.altBtn);
|
||||
ImageButton delBtn = findViewById(R.id.delBtn);
|
||||
ImageButton btnLogs = findViewById(R.id.btnLogs);
|
||||
Button eBtn = findViewById(R.id.eBtn);
|
||||
Button rBtn = findViewById(R.id.rBtn);
|
||||
Button qBtn = findViewById(R.id.qBtn);
|
||||
Button xBtn = findViewById(R.id.xBtn);
|
||||
ImageButton ctrlGameBtn = findViewById(R.id.ctrlGameBtn);
|
||||
Button spaceBtn = findViewById(R.id.spaceBtn);
|
||||
Button tabGameBtn = findViewById(R.id.tabGameBtn);
|
||||
Button tabBtn = findViewById(R.id.tabBtn);
|
||||
ImageButton upGameBtn = findViewById(R.id.upGameBtn);
|
||||
ImageButton downGameBtn = findViewById(R.id.downGameBtn);
|
||||
ImageButton leftGameBtn = findViewById(R.id.leftGameBtn);
|
||||
ImageButton rightGameBtn = findViewById(R.id.rightGameBtn);
|
||||
ImageButton enterGameBtn = findViewById(R.id.enterGameBtn);
|
||||
qmpBtn = findViewById(R.id.btnQmp);
|
||||
upGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_UP, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_UP, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
leftGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_LEFT, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_LEFT, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
downGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_DOWN, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_DOWN, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
rightGameBtn.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_RIGHT, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_RIGHT, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
JoystickView joystick = (JoystickView) findViewById(R.id.joyStick);
|
||||
joystick.setVisibility(View.GONE);
|
||||
tabBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_TAB);
|
||||
}
|
||||
});
|
||||
tabGameBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_TAB);
|
||||
}
|
||||
});
|
||||
enterGameBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_ENTER);
|
||||
}
|
||||
});
|
||||
eBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_E);
|
||||
}
|
||||
});
|
||||
rBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_R);
|
||||
}
|
||||
});
|
||||
qBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_Q);
|
||||
}
|
||||
});
|
||||
xBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_X);
|
||||
}
|
||||
});
|
||||
ctrlGameBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_CTRL_LEFT);
|
||||
}
|
||||
});
|
||||
spaceBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
keyDownUp(KeyEvent.KEYCODE_SPACE);
|
||||
}
|
||||
});
|
||||
btnLogs.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -185,9 +346,14 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_UP, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_UP, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -198,9 +364,14 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_LEFT, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_LEFT, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -211,9 +382,14 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_DOWN, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_DOWN, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -224,9 +400,14 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_RIGHT, false);
|
||||
v.animate().scaleXBy(-0.2f).setDuration(200).start();
|
||||
v.animate().scaleYBy(-0.2f).setDuration(200).start();
|
||||
return true;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
sendKey(KeyEvent.KEYCODE_DPAD_RIGHT, true);
|
||||
v.animate().cancel();
|
||||
v.animate().scaleX(1f).setDuration(200).start();
|
||||
v.animate().scaleY(1f).setDuration(200).start();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -297,6 +478,44 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
} else {
|
||||
qmpBtn.setImageDrawable(getResources().getDrawable(R.drawable.round_computer_24));
|
||||
}
|
||||
Button rightClickBtn = findViewById(R.id.rightClickBtn);
|
||||
Button middleClickBtn = findViewById(R.id.middleBtn);
|
||||
Button leftClickBtn = findViewById(R.id.leftClickBtn);
|
||||
ImageButton winBtn = findViewById(R.id.winBtn);
|
||||
|
||||
rightClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
rightClick(e, 0);
|
||||
}
|
||||
});
|
||||
middleClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
middleClick(e, 0);
|
||||
}
|
||||
});
|
||||
leftClickBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MotionEvent e = MotionEvent.obtain(1000, 1000, MotionEvent.ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0,
|
||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||
leftClick(e, 0);
|
||||
}
|
||||
});
|
||||
winBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendKey(KeyEvent.KEYCODE_CTRL_LEFT, false);
|
||||
sendKey(KeyEvent.KEYCODE_ESCAPE, false);
|
||||
sendKey(KeyEvent.KEYCODE_CTRL_LEFT, false);
|
||||
sendKey(KeyEvent.KEYCODE_ESCAPE, false);
|
||||
}
|
||||
});
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||
R.layout.container_function, functionsArray);
|
||||
|
|
@ -333,23 +552,61 @@ public class MainVNCActivity extends VncCanvasActivity {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
ImageButton hideBtn = findViewById(R.id.visibilityButton);
|
||||
hideBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FrameLayout l = findViewById(R.id.mainControl);
|
||||
if (l.getVisibility() == View.VISIBLE) {
|
||||
l.setVisibility(View.GONE);
|
||||
hideBtn.setImageResource(R.drawable.round_visibility_24);
|
||||
} else {
|
||||
l.setVisibility(View.VISIBLE);
|
||||
hideBtn.setImageResource(R.drawable.round_visibility_off_24);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean rightClick(final MotionEvent e, final int i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Log.d("SDL", "Mouse Right Click");
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_RIGHT, MotionEvent.ACTION_DOWN, 1, -1, -1);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
// Log.v("SDLSurface", "Interrupted: " + ex);
|
||||
}
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_RIGHT, MotionEvent.ACTION_UP, 1, -1, -1);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public boolean leftClick(final MotionEvent e, final int i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Log.d("SDL", "Mouse Left Click");
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_LEFT, MotionEvent.ACTION_DOWN, 1, -1, -1);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
// Log.v("SDLSurface", "Interrupted: " + ex);
|
||||
}
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_LEFT, MotionEvent.ACTION_UP, 1, -1, -1);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public boolean middleClick(final MotionEvent e, final int i) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Log.d("SDL", "Mouse Middle Click");
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_MIDDLE, MotionEvent.ACTION_DOWN, 1, -1, -1);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
// Log.v("SDLSurface", "Interrupted: " + ex);
|
||||
}
|
||||
MainActivity.vmexecutor.onVectrasMouse(Config.SDL_MOUSE_MIDDLE, MotionEvent.ACTION_UP, 1, -1, -1);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
return true;
|
||||
|
||||
}
|
||||
private void keyDownUp(int keyEventCode) {
|
||||
dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
|
||||
dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class StartVM {
|
|||
|
||||
// disks
|
||||
public String hda_img_path;
|
||||
public String hdb_img_path;
|
||||
public String hdb_img_path = null;
|
||||
public String hdc_img_path;
|
||||
public String hdd_img_path;
|
||||
public String shared_folder_path = null;
|
||||
|
|
@ -98,7 +98,7 @@ public class StartVM {
|
|||
private String initrd;
|
||||
|
||||
//graphics
|
||||
public String vga_type = "std";
|
||||
public String vga_type = "Default";
|
||||
|
||||
//audio
|
||||
public String sound_card;
|
||||
|
|
@ -182,10 +182,20 @@ public class StartVM {
|
|||
else
|
||||
this.mouse = "ps2";
|
||||
|
||||
if (new File(AppConfig.maindirpath + "/drive.iso").exists())
|
||||
if (new File(AppConfig.datadirpath(MainActivity.activity) + "/drive.iso").exists())
|
||||
cd_iso_path = AppConfig.maindirpath + "/drive.iso";
|
||||
else
|
||||
cd_iso_path = null;
|
||||
|
||||
if (new File(AppConfig.datadirpath(MainActivity.activity) + "/hdd1.qcow2").exists())
|
||||
hdc_img_path = AppConfig.maindirpath + "/hdd1.qcow2";
|
||||
else
|
||||
hdc_img_path = null;
|
||||
|
||||
if (new File(AppConfig.datadirpath(MainActivity.activity) + "/hdd2.qcow2").exists())
|
||||
hdd_img_path = AppConfig.maindirpath + "/hdd2.qcow2";
|
||||
else
|
||||
hdd_img_path = null;
|
||||
}
|
||||
|
||||
public static void onVMResolutionChanged(int width, int height) {
|
||||
|
|
@ -438,7 +448,7 @@ public class StartVM {
|
|||
if (this.cpuNum > 1 &&
|
||||
(enablekvm == 1 || enable_mttcg == 1 || !Config.enableSMPOnlyOnKVM)) {
|
||||
paramsList.add("-smp");
|
||||
paramsList.add("sockets=" + "1" + ",cores=" + this.cpuNum + ",threads=" + this.cpuNum + "");
|
||||
paramsList.add("sockets=" + "1" + ",cores=" + this.cpuNum + ",threads=2");
|
||||
}
|
||||
|
||||
if (machine_type != null && !machine_type.equals("Default")) {
|
||||
|
|
@ -644,6 +654,7 @@ public class StartVM {
|
|||
driveParams += ",if=";
|
||||
driveParams += Config.hd_if_type;
|
||||
}
|
||||
|
||||
driveParams += ",format=raw";
|
||||
driveParams += ",file=fat:";
|
||||
driveParams += "rw:"; //Always Read/Write
|
||||
|
|
|
|||
|
|
@ -40,17 +40,15 @@ public class AppConfig {
|
|||
}
|
||||
|
||||
// App config
|
||||
public static final String datadirpath() {
|
||||
File f = new File(SplashActivity.activity.getExternalFilesDir("data") + "/Vectras");
|
||||
if (f.exists())
|
||||
return SplashActivity.activity.getExternalFilesDir("data") + "/Vectras";
|
||||
else
|
||||
return FileUtils.getExternalFilesDirectory(SplashActivity.activity).getPath();
|
||||
public static final String datadirpath(Activity activity) {
|
||||
File f = new File(activity.getExternalFilesDir("data") + "/Vectras");
|
||||
return activity.getExternalFilesDir("data") + "/Vectras";
|
||||
//return FileUtils.getExternalFilesDirectory(activity).getPath();
|
||||
}
|
||||
|
||||
;
|
||||
public static final String sharedFolder = datadirpath() + "/SharedFolder/";
|
||||
public static final String basefiledir = datadirpath() + "/.qemu/";
|
||||
public static final String maindirpath = datadirpath() + "/";
|
||||
public static final String sharedFolder = FileUtils.getExternalFilesDirectory(MainActivity.activity).getPath() + "/SharedFolder/";
|
||||
public static final String basefiledir = datadirpath(SplashActivity.activity) + "/.qemu/";
|
||||
public static final String maindirpath = datadirpath(SplashActivity.activity) + "/";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -441,10 +441,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
loadingPb.setVisibility(View.GONE);
|
||||
custom.setVisibility(View.VISIBLE);
|
||||
addRomBtn.setEnabled(isFilled(title) && isFilled(icon) && isFilled(drive));
|
||||
MainActivity.UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
MainActivity.UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
@ -487,8 +487,13 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
*/
|
||||
}
|
||||
} catch (IOException e) {
|
||||
UIUtils.toastLong(activity, e.toString());
|
||||
throw new RuntimeException(e);
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UIUtils.toastLong(activity, e.toString());
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
|
|
|
|||
363
app/src/main/java/com/vectras/vm/DataExplorerActivity.java
Normal file
363
app/src/main/java/com/vectras/vm/DataExplorerActivity.java
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
package com.vectras.vm;
|
||||
|
||||
import static android.content.Intent.ACTION_OPEN_DOCUMENT;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.text.InputType;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.vectras.qemu.Config;
|
||||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DataExplorerActivity extends AppCompatActivity {
|
||||
|
||||
public AppCompatActivity activity;
|
||||
private List<String> item = null;
|
||||
|
||||
private List<String> path = null;
|
||||
public String currentDirPath;
|
||||
|
||||
public ListView lv;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
menu.add(0, 0, 0, "import files").setShortcut('3', 'c').setIcon(R.drawable.input_circle).setShowAsAction(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case 0:
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
startActivityForResult(intent, 0);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
|
||||
@Override
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
activity = this;
|
||||
|
||||
setContentView(R.layout.activity_data_explorer);
|
||||
|
||||
loadingPb = findViewById(R.id.loadingPb);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
if (getActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
lv = findViewById(R.id.listview1);
|
||||
|
||||
getDir(AppConfig.maindirpath);
|
||||
|
||||
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
File file = new File(path.get(position));
|
||||
|
||||
|
||||
if (file.isDirectory()) {
|
||||
|
||||
if (file.canRead())
|
||||
|
||||
getDir(path.get(position));
|
||||
|
||||
else {
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
|
||||
.setIcon(R.drawable.round_folder_24)
|
||||
|
||||
.setTitle("[" + file.getName() + "] folder can't be read!")
|
||||
|
||||
.setPositiveButton("OK",
|
||||
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}).show();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
|
||||
.setTitle(file.getName())
|
||||
|
||||
.setPositiveButton("DELETE",
|
||||
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
file.delete();
|
||||
getDir(AppConfig.maindirpath);
|
||||
|
||||
}
|
||||
|
||||
}).setNegativeButton("OPEN",
|
||||
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
open_file(file.getPath());
|
||||
|
||||
}
|
||||
|
||||
}).setNeutralButton("COPY PATH",
|
||||
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ClipboardManager clipboardManager = (ClipboardManager)
|
||||
activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("nonsense_data",
|
||||
file.getPath());
|
||||
clipboardManager.setPrimaryClip(clipData);
|
||||
UIUtils.toastShort(activity, "Copied to clipboard successfully!");
|
||||
}
|
||||
|
||||
}).show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getPath(Uri uri) {
|
||||
return FileUtils.getPath(activity, uri);
|
||||
}
|
||||
|
||||
private void getDir(String dirPath) {
|
||||
|
||||
item = new ArrayList<String>();
|
||||
|
||||
path = new ArrayList<String>();
|
||||
|
||||
currentDirPath = dirPath;
|
||||
|
||||
File f = new File(dirPath);
|
||||
|
||||
File[] files = f.listFiles();
|
||||
|
||||
|
||||
item.add("../");
|
||||
|
||||
path.add(f.getParent());
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
|
||||
File file = files[i];
|
||||
|
||||
path.add(file.getPath());
|
||||
|
||||
if (file.isDirectory())
|
||||
|
||||
item.add(file.getName() + "/");
|
||||
|
||||
else
|
||||
|
||||
item.add(file.getName());
|
||||
|
||||
}
|
||||
|
||||
|
||||
ArrayAdapter<String> fileList =
|
||||
|
||||
new ArrayAdapter<String>(activity, R.layout.row, item);
|
||||
|
||||
lv.setAdapter(fileList);
|
||||
|
||||
}
|
||||
|
||||
public void open_file(String location) {
|
||||
// Create a new AlertDialog.Builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
// Set the dialog's title and message
|
||||
builder.setTitle(new File(location).getName())
|
||||
.setMessage("Edit");
|
||||
|
||||
// Create an EditText for the user to input data
|
||||
final EditText input = new EditText(this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
|
||||
// Add the EditText to the dialog
|
||||
builder.setView(input);
|
||||
|
||||
input.setText(FileUtils.readFromFile(activity, new File(location)));
|
||||
|
||||
// Set a positive button and handle the button click event
|
||||
builder.setPositiveButton("SAVE", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = String.valueOf(input.getText());
|
||||
FileUtils.writeToFile(text, new File(location), activity);
|
||||
}
|
||||
});
|
||||
|
||||
// Set a positive button and handle the button click event
|
||||
builder.setNeutralButton("COPY CONTENT", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = String.valueOf(input.getText());
|
||||
ClipboardManager clipboardManager = (ClipboardManager)
|
||||
activity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("nonsense_data",
|
||||
input.getText());
|
||||
clipboardManager.setPrimaryClip(clipData);
|
||||
UIUtils.toastShort(activity, "Copied to clipboard successfully!");
|
||||
}
|
||||
});
|
||||
|
||||
// Optionally, set a negative button
|
||||
builder.setNegativeButton("DISCARD", null);
|
||||
|
||||
// Create and show the dialog
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public ProgressBar loadingPb;
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0 && resultCode == RESULT_OK) {
|
||||
Uri content_describer = data.getData();
|
||||
File selectedFilePath = new File(getPath(content_describer));
|
||||
loadingPb.setVisibility(View.VISIBLE);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileInputStream File = null;
|
||||
try {
|
||||
File = (FileInputStream) getContentResolver().openInputStream(content_describer);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(new File(currentDirPath + "/" + selectedFilePath.getName()));
|
||||
try {
|
||||
// Transfer bytes from in to out
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = File.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingPb.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
File.close();
|
||||
getDir(currentDirPath);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingPb.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
MainActivity.UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -13,8 +13,13 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
|
||||
import com.vectras.qemu.MainSDLActivity;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.qemu.MainVNCActivity;
|
||||
import com.vectras.vm.R;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ControlersOptionsFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
|
|
@ -27,6 +32,13 @@ public class ControlersOptionsFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
MainSettingsManager.setControlMode(getActivity(), "G");
|
||||
if (MainSettingsManager.getVmUi(getActivity()).equals("SDL")) {
|
||||
MainSDLActivity.desktop.setVisibility(View.GONE);
|
||||
MainSDLActivity.gamepad.setVisibility(View.VISIBLE);
|
||||
} else if (MainSettingsManager.getVmUi(getActivity()).equals("VNC")) {
|
||||
MainVNCActivity.desktop.setVisibility(View.GONE);
|
||||
MainVNCActivity.gamepad.setVisibility(View.VISIBLE);
|
||||
}
|
||||
alertDialog.cancel();
|
||||
}
|
||||
});
|
||||
|
|
@ -34,6 +46,13 @@ public class ControlersOptionsFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
MainSettingsManager.setControlMode(getActivity(), "D");
|
||||
if (MainSettingsManager.getVmUi(getActivity()).equals("SDL")) {
|
||||
MainSDLActivity.desktop.setVisibility(View.VISIBLE);
|
||||
MainSDLActivity.gamepad.setVisibility(View.GONE);
|
||||
} else if (MainSettingsManager.getVmUi(getActivity()).equals("VNC")) {
|
||||
MainVNCActivity.desktop.setVisibility(View.VISIBLE);
|
||||
MainVNCActivity.gamepad.setVisibility(View.GONE);
|
||||
}
|
||||
alertDialog.cancel();
|
||||
}
|
||||
});
|
||||
|
|
@ -41,6 +60,13 @@ public class ControlersOptionsFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
MainSettingsManager.setControlMode(getActivity(), "H");
|
||||
if (MainSettingsManager.getVmUi(getActivity()).equals("SDL")) {
|
||||
MainSDLActivity.desktop.setVisibility(View.GONE);
|
||||
MainSDLActivity.gamepad.setVisibility(View.GONE);
|
||||
} else if (MainSettingsManager.getVmUi(getActivity()).equals("VNC")) {
|
||||
MainVNCActivity.desktop.setVisibility(View.GONE);
|
||||
MainVNCActivity.gamepad.setVisibility(View.GONE);
|
||||
}
|
||||
alertDialog.cancel();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ public class HomeFragment extends Fragment {
|
|||
romsMainData.itemArch = "unknown";
|
||||
}
|
||||
romsMainData.itemPath = json_data.getString("imgPath");
|
||||
try {
|
||||
romsMainData.itemDrv1 = json_data.getString("imgDrv1");
|
||||
} catch (JSONException ignored) {
|
||||
romsMainData.itemDrv1 = "";
|
||||
}
|
||||
romsMainData.itemExtra = json_data.getString("imgExtra");
|
||||
try {
|
||||
if (json_data.getString("imgArch").equals(MainSettingsManager.getArch(MainActivity.activity)))
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
|
@ -123,6 +124,7 @@ import java.util.logging.Logger;
|
|||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static String curRomName;
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
public static final String TAG = "Main Activity";
|
||||
// Static
|
||||
|
|
@ -183,6 +185,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
//mAuth = FirebaseAuth.getInstance();
|
||||
}
|
||||
|
||||
//ANDROID 14 FIX BY SENZ
|
||||
private void requestPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(this, POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
|
@ -199,16 +202,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, POST_NOTIFICATIONS);
|
||||
}
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{ACCESS_FINE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, ACCESS_FINE_LOCATION);
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{ACCESS_COARSE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, ACCESS_COARSE_LOCATION);
|
||||
if (ContextCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{ACCESS_FINE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, ACCESS_FINE_LOCATION);
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(this, ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{ACCESS_COARSE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,34 +223,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void requestPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this, R.style.MainDialogTheme);
|
||||
alertDialog.setTitle(R.string.permission_title);
|
||||
alertDialog.setMessage(R.string.permission_notification_text);
|
||||
alertDialog.setPositiveButton("OK!", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, 11003);
|
||||
}
|
||||
});
|
||||
alertDialog.create().show();
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.POST_NOTIFICATIONS);
|
||||
}
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
}
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 11003);
|
||||
} else {
|
||||
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
}
|
||||
|
||||
public void updateApp(final boolean showDialog) {
|
||||
new AppUpdater(this, new AppUpdater.OnUpdateListener() {
|
||||
@Override
|
||||
|
|
@ -427,6 +402,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
navEmail.setText(email);
|
||||
TextView viewProfile = (TextView) headerView.findViewById(R.id.viewProfile);
|
||||
TextView appNameTxt = (TextView) headerView.findViewById(R.id.appNameTxt);
|
||||
|
||||
/*ObjectAnimator rgbAnim=ObjectAnimator.ofObject(navUsername,"textColor",new ArgbEvaluator(), Color.RED,Color.GREEN,Color.BLUE);
|
||||
rgbAnim.setDuration(500);
|
||||
rgbAnim.setRepeatMode(ValueAnimator.REVERSE);
|
||||
|
|
@ -510,12 +486,149 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
startActivityForResult(intent, 1004);
|
||||
}
|
||||
} else if (id == R.id.navigation_item_hdd1) {
|
||||
if (new File(AppConfig.maindirpath + "/hdd1.qcow2").exists()) {
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
ad.setTitle("REPLACE HDD1");
|
||||
ad.setMessage("there is hdd1 imported you want to replace it?");
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, "REPLACE", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
startActivityForResult(intent, 1006);
|
||||
return;
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, "REMOVE", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
File isoFile = new File(AppConfig.maindirpath + "/hdd1.qcow2");
|
||||
try {
|
||||
isoFile.delete();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEUTRAL, "SHARE", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
|
||||
File fileWithinMyDir = new File(AppConfig.maindirpath + "/hdd1.qcow2");
|
||||
|
||||
if (fileWithinMyDir.exists()) {
|
||||
intentShareFile.setType("*/*");
|
||||
intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + AppConfig.maindirpath + "/hdd1.qcow2"));
|
||||
|
||||
intentShareFile.putExtra(Intent.EXTRA_SUBJECT,
|
||||
"Sharing File...");
|
||||
intentShareFile.putExtra(Intent.EXTRA_TEXT, "Sharing File...");
|
||||
|
||||
startActivity(Intent.createChooser(intentShareFile, "Share File"));
|
||||
}
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
} else {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
startActivityForResult(intent, 1005);
|
||||
}
|
||||
} else if (id == R.id.navigation_item_hdd2) {
|
||||
if (new File(AppConfig.maindirpath + "/hdd2.qcow2").exists()) {
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
ad.setTitle("REPLACE HDD2");
|
||||
ad.setMessage("there is hdd2 imported you want to replace it?");
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, "REPLACE", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
startActivityForResult(intent, 1006);
|
||||
return;
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, "REMOVE", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
File isoFile = new File(AppConfig.maindirpath + "/hdd2.qcow2");
|
||||
try {
|
||||
isoFile.delete();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEUTRAL, "SHARE", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intentShareFile = new Intent(Intent.ACTION_SEND);
|
||||
File fileWithinMyDir = new File(AppConfig.maindirpath + "/hdd2.qcow2");
|
||||
|
||||
if (fileWithinMyDir.exists()) {
|
||||
intentShareFile.setType("*/*");
|
||||
intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + AppConfig.maindirpath + "/hdd2.qcow2"));
|
||||
|
||||
intentShareFile.putExtra(Intent.EXTRA_SUBJECT,
|
||||
"Sharing File...");
|
||||
intentShareFile.putExtra(Intent.EXTRA_TEXT, "Sharing File...");
|
||||
|
||||
startActivity(Intent.createChooser(intentShareFile, "Share File"));
|
||||
}
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
} else {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
startActivityForResult(intent, 1006);
|
||||
}
|
||||
} else if (id == R.id.navigation_item_view_logs) {
|
||||
FileUtils.viewVectrasLog(activity);
|
||||
} else if (id == R.id.navigation_item_settings) {
|
||||
startActivity(new Intent(activity, MainSettingsManager.class));
|
||||
} else if (id == R.id.navigation_item_store) {
|
||||
startActivity(new Intent(activity, StoreActivity.class));
|
||||
} else if (id == R.id.navigation_data_explorer) {
|
||||
startActivity(new Intent(activity, DataExplorerActivity.class));
|
||||
} else if (id == R.id.navigation_item_donate) {
|
||||
String tw = "https://www.buymeacoffee.com/vectrasvm/";
|
||||
Intent w = new Intent(Intent.ACTION_VIEW);
|
||||
w.setData(Uri.parse(tw));
|
||||
startActivity(w);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -678,9 +791,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!mCurrentUser.isEmailVerified()) {
|
||||
if (!mCurrentUser.isEmailVerified() &&
|
||||
!mAuth.getCurrentUser().isAnonymous()) {
|
||||
startActivity(new Intent(activity, VerifyEmailActivity.class));
|
||||
activity.finish();
|
||||
}
|
||||
try {
|
||||
HomeFragment.loadDataVbi();
|
||||
|
|
@ -1197,15 +1310,172 @@ public class MainActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else
|
||||
UIAlert("NOT VAILED FILE", "please select iso file", activity);
|
||||
} else if (requestCode == 1005 && resultCode == RESULT_OK) {
|
||||
Uri content_describer = ReturnedIntent.getData();
|
||||
File selectedFilePath = new File(getPath(content_describer));
|
||||
ProgressBar loading = findViewById(R.id.loading);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileInputStream File = null;
|
||||
try {
|
||||
File = (FileInputStream) getContentResolver().openInputStream(content_describer);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(new File(AppConfig.maindirpath + "/hdd1.qcow2"));
|
||||
try {
|
||||
// Transfer bytes from in to out
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = File.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
File.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else if (requestCode == 1006 && resultCode == RESULT_OK) {
|
||||
Uri content_describer = ReturnedIntent.getData();
|
||||
File selectedFilePath = new File(getPath(content_describer));
|
||||
ProgressBar loading = findViewById(R.id.loading);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileInputStream File = null;
|
||||
try {
|
||||
File = (FileInputStream) getContentResolver().openInputStream(content_describer);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(new File(AppConfig.maindirpath + "/hdd2.qcow2"));
|
||||
try {
|
||||
// Transfer bytes from in to out
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = File.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
File.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else if (requestCode == 122 && resultCode == RESULT_OK) {
|
||||
Uri content_describer = ReturnedIntent.getData();
|
||||
File selectedFilePath = new File(getPath(content_describer));
|
||||
ProgressBar loading = findViewById(R.id.loading);
|
||||
TextInputEditText drv1 = AdapterMainRoms.d.findViewById(R.id.drive1);
|
||||
Button saveB = AdapterMainRoms.d.findViewById(R.id.saveRomBtn);
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
saveB.setVisibility(View.GONE);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileInputStream File = null;
|
||||
try {
|
||||
File = (FileInputStream) getContentResolver().openInputStream(content_describer);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
File romDir = new File(AppConfig.maindirpath + curRomName + "/");
|
||||
if (!romDir.exists()) {
|
||||
romDir.mkdirs();
|
||||
}
|
||||
OutputStream out = new FileOutputStream(new File(AppConfig.maindirpath + curRomName + "/" + "drv1-" + selectedFilePath.getName()));
|
||||
try {
|
||||
// Transfer bytes from in to out
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = File.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} finally {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
saveB.setVisibility(View.VISIBLE);
|
||||
drv1.setText(AppConfig.maindirpath + curRomName + "/" + "drv1-" + selectedFilePath.getName());
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
File.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loading.setVisibility(View.GONE);
|
||||
saveB.setVisibility(View.VISIBLE);
|
||||
UIAlert("error", e.toString(), activity);
|
||||
}
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
package com.vectras.vm.MainRoms;
|
||||
|
||||
import static android.content.Intent.ACTION_OPEN_DOCUMENT;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
|
@ -66,6 +72,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
public List<DataMainRoms> data = Collections.emptyList();
|
||||
int currentPos = 0;
|
||||
private int mSelectedItem = -1;
|
||||
public static Dialog d;
|
||||
|
||||
// create constructor to innitilize context and data sent from MainActivity
|
||||
public AdapterMainRoms(Context context, List<DataMainRoms> data) {
|
||||
|
|
@ -97,20 +104,59 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
myHolder.ivIcon.setImageBitmap(bmImg);
|
||||
myHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
Dialog d;
|
||||
d = new Dialog(MainActivity.activity);
|
||||
d.setTitle(current.itemName);
|
||||
d.setContentView(R.layout.rom_options_dialog);
|
||||
d.setCancelable(true);
|
||||
TextView qemu = d.findViewById(R.id.qemu);
|
||||
qemu.setText(current.itemExtra);
|
||||
TextInputEditText drv1 = d.findViewById(R.id.drive1);
|
||||
drv1.setText(current.itemDrv1);
|
||||
drv1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
MainActivity.curRomName = current.itemName;
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
MainActivity.activity.startActivityForResult(intent, 122);
|
||||
}
|
||||
});
|
||||
TextInputLayout drv1fld = d.findViewById(R.id.drive1Field);
|
||||
drv1fld.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
MainActivity.curRomName = current.itemName;
|
||||
|
||||
// Optionally, specify a URI for the file that should appear in the
|
||||
// system file picker when it loads.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
MainActivity.activity.startActivityForResult(intent, 122);
|
||||
}
|
||||
});
|
||||
Button saveRomBtn = d.findViewById(R.id.saveRomBtn);
|
||||
saveRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final File jsonFile = new File(AppConfig.maindirpath + "roms-data" + ".json");
|
||||
current.itemDrv1 = drv1.getText().toString();
|
||||
current.itemExtra = qemu.getText().toString();
|
||||
try {
|
||||
JSONObject jObj = HomeFragment.jArray.getJSONObject(position);
|
||||
jObj.put("imgDrv1", drv1.getText().toString());
|
||||
jObj.put("imgExtra", qemu.getText().toString());
|
||||
HomeFragment.jArray.put(position, jObj);
|
||||
} catch (JSONException e) {
|
||||
|
|
@ -125,6 +171,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
UIUtils.toastLong(MainActivity.activity, e.toString());
|
||||
} finally {
|
||||
d.dismiss();
|
||||
HomeFragment.loadDataVbi();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -178,9 +225,10 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
ZipEntrySource[] addedEntries = new ZipEntrySource[]{
|
||||
new FileSource("/" + new File(current.itemPath).getName(), new File(current.itemPath)),
|
||||
new FileSource("/" + new File(current.itemIcon).getName(), new File(current.itemIcon)),
|
||||
new FileSource("/" + new File(current.itemDrv1).getName(), new File(current.itemDrv1)),
|
||||
new FileSource("/" + new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json").getName(), new File(MainActivity.activity.getExternalFilesDir("data") + "/rom-data.json"))
|
||||
};
|
||||
ZipUtil.pack(addedEntries, new File(AppConfig.datadirpath() + "/cvbi/" + current.itemName + ".cvbi"));
|
||||
ZipUtil.pack(addedEntries, new File(AppConfig.datadirpath(MainActivity.activity) + "/cvbi/" + current.itemName + ".cvbi"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runnable runnable = new Runnable() {
|
||||
|
|
@ -196,7 +244,7 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
@Override
|
||||
public void run() {
|
||||
progressDialog.cancel(); // cancelling Dialog.}
|
||||
MainActivity.UIAlert("DONE!", AppConfig.datadirpath() + "/cvbi/" + current.itemName + ".cvbi", MainActivity.activity);
|
||||
MainActivity.UIAlert("DONE!", AppConfig.datadirpath(MainActivity.activity) + "/cvbi/" + current.itemName + ".cvbi", MainActivity.activity);
|
||||
}
|
||||
};
|
||||
MainActivity.activity.runOnUiThread(runnable);
|
||||
|
|
@ -244,12 +292,19 @@ public class AdapterMainRoms extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
ad.setButton(Dialog.BUTTON_NEGATIVE, "REMOVE " + current.itemName, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
File file = new File(current.itemPath);
|
||||
File file2 = new File(current.itemDrv1);
|
||||
try {
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
UIUtils.toastLong(MainActivity.activity, e.toString());
|
||||
} finally {
|
||||
}
|
||||
try {
|
||||
file2.delete();
|
||||
} catch (Exception e) {
|
||||
UIUtils.toastLong(MainActivity.activity, e.toString());
|
||||
} finally {
|
||||
}
|
||||
HomeFragment.mMainAdapter = new AdapterMainRoms(MainActivity.activity, HomeFragment.data);
|
||||
HomeFragment.data.remove(position);
|
||||
HomeFragment.mRVMainRoms.setAdapter(HomeFragment.mMainAdapter);
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ public class DataMainRoms {
|
|||
public String itemName;
|
||||
public String itemArch;
|
||||
public String itemPath;
|
||||
public String itemDrv1;
|
||||
public String itemExtra;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
|
@ -254,7 +255,7 @@ public class RomsManagerActivity extends AppCompatActivity {
|
|||
data = new ArrayList<>();
|
||||
|
||||
try {
|
||||
JSONArray jArray = new JSONArray(FileUtils.readFromFile(activity, new File(AppConfig.maindirpath + "roms.json")));
|
||||
JSONArray jArray = new JSONArray(FileUtils.readFromFile(activity, new File(getExternalFilesDir("data") + "roms.json")));
|
||||
|
||||
// Extract data from json and store into ArrayList as class objects
|
||||
for (int i = 0; i < jArray.length(); i++) {
|
||||
|
|
@ -281,7 +282,7 @@ public class RomsManagerActivity extends AppCompatActivity {
|
|||
// Setup and Handover data to recyclerview
|
||||
|
||||
} catch (JSONException e) {
|
||||
UIUtils.toastLong(activity, e.toString());
|
||||
UIUtils.UIAlert(activity, "ERROR", e.toString());
|
||||
}
|
||||
mRVRoms = (RecyclerView) activity.findViewById(R.id.romsRv);
|
||||
mAdapter = new AdapterRoms(activity, data);
|
||||
|
|
@ -344,7 +345,7 @@ public class RomsManagerActivity extends AppCompatActivity {
|
|||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
mProgressDialog.dismiss();
|
||||
final File jsonFile = new File(AppConfig.maindirpath + "roms-data" + ".json");
|
||||
final File jsonFile = new File(AppConfig.maindirpath + "roms-data.json");
|
||||
|
||||
if (jsonFile.exists()) {
|
||||
try {
|
||||
|
|
@ -424,11 +425,12 @@ public class RomsManagerActivity extends AppCompatActivity {
|
|||
});
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, "DOWNLAOD " + selectedPath.replace(".IMG", ".vbi"), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String gt = selectedLink;
|
||||
Intent g = new Intent(Intent.ACTION_VIEW);
|
||||
g.setData(Uri.parse(gt));
|
||||
RomsManagerActivity.activity.startActivity(g);
|
||||
RomsManagerActivity.activity.finish();
|
||||
if (selectedLink != null) {
|
||||
String gt = selectedLink;
|
||||
Intent g = new Intent(Intent.ACTION_VIEW);
|
||||
g.setData(Uri.parse(gt));
|
||||
startActivity(g);
|
||||
}
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
|
|
|
|||
|
|
@ -178,9 +178,9 @@ public class SplashActivity extends AppCompatActivity implements Runnable {
|
|||
|
||||
int lenghtOfFile = conexion.getContentLength();
|
||||
Log.d(TAG, "Lenght of file: " + lenghtOfFile);
|
||||
String fileName = URLUtil.guessFileName(url.getFile(),null,null);
|
||||
String fileName = "roms.json";
|
||||
InputStream input = new BufferedInputStream(url.openStream());
|
||||
OutputStream output = new FileOutputStream(AppConfig.maindirpath+fileName);
|
||||
OutputStream output = new FileOutputStream(getExternalFilesDir("data")+fileName);
|
||||
|
||||
byte data[] = new byte[1024];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.vectras.vm.ui.login;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
|
|
@ -38,6 +40,7 @@ import com.google.firebase.auth.FirebaseAuth;
|
|||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.UserProfileChangeRequest;
|
||||
import com.vectras.vm.AppConfig;
|
||||
import com.vectras.vm.MainActivity;
|
||||
import com.vectras.vm.R;
|
||||
import com.vectras.vm.RomsManagerActivity;
|
||||
import com.vectras.vm.SplashActivity;
|
||||
|
|
@ -98,6 +101,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||
}
|
||||
}).start();
|
||||
|
||||
TextView resetButton = findViewById(R.id.resetPassword);
|
||||
|
||||
MaterialButton signinButton = findViewById(R.id.signinBtn);
|
||||
|
||||
|
|
@ -105,6 +109,8 @@ public class LoginActivity extends AppCompatActivity {
|
|||
|
||||
MaterialButton signwithGoogleButton = findViewById(R.id.signwithGoogleBtn);
|
||||
|
||||
MaterialButton guestButton = findViewById(R.id.guestBtn);
|
||||
|
||||
TextInputEditText usernameEditText = findViewById(R.id.username);
|
||||
|
||||
TextInputEditText passwordEditText = findViewById(R.id.password);
|
||||
|
|
@ -137,8 +143,10 @@ public class LoginActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (usernameEditText.getText().toString().trim().length() > 0) {
|
||||
resetButton.setVisibility(View.VISIBLE);
|
||||
signinButton.setEnabled(true);
|
||||
} else {
|
||||
resetButton.setVisibility(View.GONE);
|
||||
signinButton.setEnabled(false);
|
||||
}
|
||||
if (passwordEditText.getText().toString().trim().length() > 0) {
|
||||
|
|
@ -176,6 +184,35 @@ public class LoginActivity extends AppCompatActivity {
|
|||
updateUI(null);
|
||||
}
|
||||
}));
|
||||
|
||||
resetButton.setOnClickListener(v -> mAuth.sendPasswordResetEmail(usernameEditText.getText().toString())
|
||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Toast.makeText(LoginActivity.this, "Reset Password Email Sent!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
mStatusTextView.setText(task.getException().toString());
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
guestButton.setOnClickListener(v -> mAuth.signInAnonymously()
|
||||
.addOnCompleteListener(LoginActivity.this, (OnCompleteListener<AuthResult>) task -> {
|
||||
if (task.isSuccessful()) {
|
||||
// Sign in success, update UI with the signed-in user's information
|
||||
FirebaseUser user = mAuth.getCurrentUser();
|
||||
updateUI(user);
|
||||
} else {
|
||||
|
||||
mStatusTextView.setText(task.getException().toString());
|
||||
// If sign in fails, display a message to the user.
|
||||
Toast.makeText(LoginActivity.this, "Authentication failed.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
updateUI(null);
|
||||
}
|
||||
}));
|
||||
signupButton.setOnClickListener(v -> startActivity(new Intent(this, SignupActivity.class)));
|
||||
signwithGoogleButton.setOnClickListener(v -> startActivity(new Intent(this, GoogleSignInActivity.class)));
|
||||
|
||||
|
|
@ -213,13 +250,25 @@ public class LoginActivity extends AppCompatActivity {
|
|||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
finish();
|
||||
startActivity(new Intent(LoginActivity.this, SplashActivity.class));
|
||||
SharedPreferences prefs = getSharedPreferences("settings_prefs", Context.MODE_PRIVATE);
|
||||
|
||||
boolean isAccessed = prefs.getBoolean("isFirstLaunch", false);
|
||||
if (FirebaseAuth.getInstance().getCurrentUser().isAnonymous()) {
|
||||
if (isAccessed)
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
else
|
||||
startActivity(new Intent(LoginActivity.this, RomsManagerActivity.class));
|
||||
} else {
|
||||
startActivity(new Intent(LoginActivity.this, SplashActivity.class));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (user != null && user.isEmailVerified())
|
||||
startActivity(new Intent(LoginActivity.this, RomsManagerActivity.class));
|
||||
if (user != null && user.isEmailVerified()) {
|
||||
startActivity(new Intent(LoginActivity.this, SplashActivity.class));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,4 +34,10 @@ public class VerifyEmailActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (FirebaseAuth.getInstance().getCurrentUser().isEmailVerified()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ public class UIUtils {
|
|||
|
||||
UIUtils.toastShortTop(activity, "Press Volume Down for Right Click");
|
||||
|
||||
UIUtils.toastShortTop(activity, "Press Volume Up for Left Click");
|
||||
|
||||
UIUtils.toastShortTop(activity, "Press Back Button for Hide/Show Controls UI");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue