mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-05-02 16:20:30 +00:00
permissions fix
This commit is contained in:
parent
7293722ddc
commit
4dbf351b46
11 changed files with 154 additions and 43 deletions
Binary file not shown.
|
|
@ -128,8 +128,8 @@ public class FirstActivity extends AppCompatActivity {
|
|||
in.close();
|
||||
} catch (Exception e) {
|
||||
acceptLiceneseChkBox.setEnabled(false);
|
||||
Toast.makeText(activity, "no internet connection", Toast.LENGTH_LONG).show();
|
||||
Log.d("VECTRAS", e.toString());
|
||||
MainActivity.UIAlert("no internet connection", e.toString(), activity);
|
||||
Log.d("TERMS", e.toString());
|
||||
}
|
||||
|
||||
//since we are in background thread, to post results we have to go back to ui thread. do the following for that
|
||||
|
|
|
|||
|
|
@ -2,7 +2,12 @@ package com.epicstudios.vectras.Fragment;
|
|||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
|
|
@ -13,6 +18,8 @@ import android.view.MenuItem;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.BaseInputConnection;
|
||||
import android.widget.LinearLayout;
|
||||
|
|
@ -20,6 +27,8 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.epicstudios.vectras.MainActivity;
|
||||
import com.epicstudios.vectras.R;
|
||||
import com.epicstudios.vectras.Config;
|
||||
import com.epicstudios.vectras.VectrasSDLActivity;
|
||||
|
|
@ -27,6 +36,9 @@ import com.epicstudios.vectras.widgets.JoystickView;
|
|||
import com.epicstudios.vectras.utils.KeyboardUtils;
|
||||
import com.epicstudios.vectras.utils.UIUtils;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
|
@ -39,6 +51,8 @@ public class ControlsFragment extends Fragment {
|
|||
private Timer _timer = new Timer();
|
||||
private TimerTask t;
|
||||
|
||||
public static final int MAX_LINES = 1;
|
||||
public static final String TWO_SPACES = " ";
|
||||
public static LinearLayout escBtn, enterBtn, shiftBtn, delBtn, gamepadLayout, desktopLayout, BtnUp, BtnDown,
|
||||
BtnRight, BtnLeft, BtnF, BtnShift, Btn0, BtnSpace, BtnSettings, kbdBtn, BtnMode, BtnHide;
|
||||
|
||||
|
|
@ -48,6 +62,12 @@ public class ControlsFragment extends Fragment {
|
|||
|
||||
public static LinearLayout rightClick, leftClick;
|
||||
|
||||
ProcessBuilder processBuilder;
|
||||
String Holder = "";
|
||||
String[] DATA = {"/system/bin/cat", "/proc/cpuinfo"};
|
||||
InputStream inputStream;
|
||||
Process process ;
|
||||
byte[] byteArry ;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
@ -116,6 +136,51 @@ public class ControlsFragment extends Fragment {
|
|||
_timer.scheduleAtFixedRate(t, (int) (0), (int) (1000));
|
||||
|
||||
//txtMem.setVisibility(View.GONE);
|
||||
//txtCpu.setVisibility(View.GONE);
|
||||
byteArry = new byte[1024];
|
||||
|
||||
try{
|
||||
processBuilder = new ProcessBuilder(DATA);
|
||||
|
||||
process = processBuilder.start();
|
||||
|
||||
inputStream = process.getInputStream();
|
||||
|
||||
while(inputStream.read(byteArry) != -1){
|
||||
|
||||
Holder = Holder + new String(byteArry);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
|
||||
} catch(IOException ex){
|
||||
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
String cpuTxt = "Cpu Info:\n" + Holder;
|
||||
|
||||
txtCpu.setText(cpuTxt);
|
||||
txtCpu.post(() -> {
|
||||
// Past the maximum number of lines we want to display.
|
||||
if (txtCpu.getLineCount() > MAX_LINES) {
|
||||
int lastCharShown = txtCpu.getLayout().getLineVisibleEnd(MAX_LINES - 1);
|
||||
|
||||
txtCpu.setMaxLines(MAX_LINES);
|
||||
|
||||
String moreString = "Show More";
|
||||
String suffix = TWO_SPACES + moreString;
|
||||
|
||||
// 3 is a "magic number" but it's just basically the length of the ellipsis we're going to insert
|
||||
String actionDisplayText = cpuTxt.substring(0, lastCharShown - suffix.length() - 3) + "..." + suffix;
|
||||
|
||||
SpannableString truncatedSpannableString = new SpannableString(actionDisplayText);
|
||||
int startIndex = actionDisplayText.indexOf(moreString);
|
||||
truncatedSpannableString.setSpan(new ForegroundColorSpan(Color.GRAY), startIndex, startIndex + moreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
txtCpu.setText(truncatedSpannableString);
|
||||
}
|
||||
});
|
||||
|
||||
txtCpu.setVisibility(View.GONE);
|
||||
|
||||
if (gamepadLayout.getVisibility() != View.VISIBLE) {
|
||||
|
|
@ -236,10 +301,26 @@ public class ControlsFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (gamepadLayout.getVisibility() != View.VISIBLE) {
|
||||
gamepadLayout.setVisibility(View.VISIBLE);
|
||||
Animation animation2;
|
||||
animation2 = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_to_left);
|
||||
animation2.setDuration(300);
|
||||
desktopLayout.startAnimation(animation2);
|
||||
desktopLayout.setVisibility(View.GONE);
|
||||
Animation animation;
|
||||
animation = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_from_left);
|
||||
animation.setDuration(300);
|
||||
gamepadLayout.startAnimation(animation);
|
||||
gamepadLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Animation animation;
|
||||
animation = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_to_left);
|
||||
animation.setDuration(300);
|
||||
gamepadLayout.startAnimation(animation);
|
||||
gamepadLayout.setVisibility(View.GONE);
|
||||
Animation animation2;
|
||||
animation2 = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_from_left);
|
||||
animation2.setDuration(300);
|
||||
desktopLayout.startAnimation(animation2);
|
||||
desktopLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
@ -249,10 +330,20 @@ public class ControlsFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (gamepadLayout.getVisibility() == View.GONE && desktopLayout.getVisibility() == View.GONE) {
|
||||
Animation animation;
|
||||
animation = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_from_left);
|
||||
animation.setDuration(300);
|
||||
desktopLayout.startAnimation(animation);
|
||||
gamepadLayout.startAnimation(animation);
|
||||
gamepadLayout.setVisibility(View.VISIBLE);
|
||||
desktopLayout.setVisibility(View.GONE);
|
||||
TxtHide.setText("Hide");
|
||||
} else {
|
||||
Animation animation;
|
||||
animation = AnimationUtils.loadAnimation(VectrasSDLActivity.activity, R.anim.slide_to_left);
|
||||
animation.setDuration(300);
|
||||
desktopLayout.startAnimation(animation);
|
||||
gamepadLayout.startAnimation(animation);
|
||||
gamepadLayout.setVisibility(View.GONE);
|
||||
desktopLayout.setVisibility(View.GONE);
|
||||
TxtHide.setText("Show");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ package com.epicstudios.vectras;
|
|||
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
|
|
@ -16,6 +20,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
|
|
@ -32,6 +37,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -512,7 +518,28 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
paramsList.add("-k");
|
||||
paramsList.add("en-us");
|
||||
|
||||
paramsList.add("-monitor");
|
||||
paramsList.add("none");
|
||||
|
||||
paramsList.add("-serial");
|
||||
paramsList.add("none");
|
||||
|
||||
paramsList.add("-parallel");
|
||||
paramsList.add("none");
|
||||
|
||||
|
||||
/*
|
||||
paramsList.add("-drive"); //empty
|
||||
String paramIso = "index=2";
|
||||
paramIso += ",if=";
|
||||
paramIso += "ide";
|
||||
|
||||
paramIso += ",media=cdrom";
|
||||
paramIso += ",file=" + Config.basefiledir+"iso/cdrom.iso";
|
||||
|
||||
paramsList.add(paramIso);
|
||||
|
||||
paramsList.add("-drive");
|
||||
String driveParams = "index=3";
|
||||
driveParams += ",media=disk";
|
||||
|
|
@ -610,6 +637,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
totalRam = findViewById(R.id.totalRam);
|
||||
usedRam = findViewById(R.id.usedRam);
|
||||
freeRam = findViewById(R.id.freeRam);
|
||||
|
||||
ipTxt.setVisibility(View.GONE);
|
||||
t = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -628,6 +657,13 @@ public class MainActivity extends AppCompatActivity {
|
|||
totalRam.setText("Total Memory: " + totalMemory + " MB");
|
||||
usedRam.setText("Used Memory: " + usedMemory + " MB");
|
||||
freeRam.setText("Free Memory: " + freeMemory + " MB ("+RamInfo.vectrasMemory()+")");
|
||||
ProgressBar progressBar = findViewById(R.id.progressBar);
|
||||
progressBar.setMax((int) totalMemory);
|
||||
if (SDK_INT >= Build.VERSION_CODES.N) {
|
||||
progressBar.setProgress((int) freeMemory, true);
|
||||
} else {
|
||||
progressBar.setProgress((int) freeMemory);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -645,10 +681,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
AdView mAdView = findViewById(R.id.adView);
|
||||
AdRequest adRequest = new AdRequest.Builder().build();
|
||||
mAdView.loadAd(adRequest);
|
||||
UIAlert(getString(R.string.app_version), "This is only the first beta version of Vectras. Please note that the application is still in the experimental stage so that it is available in the best condition. Do not be lazy and support the application with your opinion.", activity);
|
||||
|
||||
|
||||
|
||||
//UIAlert(getString(R.string.app_version), "This is only the first beta version of Vectras. Please note that the application is still in the experimental stage so that it is available in the best condition. Do not be lazy and support the application with your opinion.", activity);
|
||||
//File extra = new File(Config.basefiledir+"config_extra.txt");
|
||||
//String extraParams = FileUtils.readFromFile(MainActivity.activity, extra);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,29 +10,26 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="left"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
<TextView
|
||||
android:id="@+id/dvcTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ramTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Free Memory:" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cpuTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cpu Usage:" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dvcTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device Model:" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
@ -154,8 +151,8 @@
|
|||
|
||||
<com.epicstudios.vectras.widgets.JoystickView
|
||||
android:id="@+id/joyStick"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="bottom|left"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:alpha="0.5"
|
||||
|
|
@ -417,7 +414,7 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/F1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_height="59dp"
|
||||
android:background="@drawable/controls_button"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical|center|center_horizontal"
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@
|
|||
android:layout_margin="10dp"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:progressBackgroundTint="@color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:progressTint="@color/blue" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ipTxt"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
android:text="@string/app_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/verTxt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_version" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Vectras VM</string>
|
||||
<string name="app_version">1.0.0 alpha test</string>
|
||||
<string name="app_version">1.1b</string>
|
||||
<string name="str_home">Home</string>
|
||||
<string name="str_logger">Logger</string>
|
||||
<string name="fab_info">Start Emulation</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue