mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-04-29 14:59:50 +00:00
Xangos
This commit is contained in:
parent
abdadcb5c4
commit
549e89584e
28 changed files with 508 additions and 546 deletions
|
|
@ -47,6 +47,7 @@ import com.google.android.gms.ads.MobileAds;
|
|||
import com.google.android.gms.ads.initialization.InitializationStatus;
|
||||
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
|
|
@ -54,6 +55,7 @@ import com.vectras.vm.Fragment.CreateImageDialogFragment;
|
|||
import com.vectras.vm.MainRoms.DataMainRoms;
|
||||
import com.vectras.vm.logger.VectrasStatus;
|
||||
import com.vectras.vm.utils.DeviceUtils;
|
||||
import com.vectras.vm.utils.DialogUtils;
|
||||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
|
||||
|
|
@ -79,12 +81,16 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.vectras.vm.utils.ZipUtils;
|
||||
import com.vectras.vterm.Terminal;
|
||||
import com.vectras.vm.utils.PermissionUtils;
|
||||
|
||||
|
|
@ -112,6 +118,14 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
private ImageView ivIcon;
|
||||
public static TextInputLayout driveLayout;
|
||||
|
||||
LinearProgressIndicator linearprogress;
|
||||
TextView textviewprogress;
|
||||
private Timer _timer = new Timer();
|
||||
private TimerTask timerTask;
|
||||
double zipFileSize = 0;
|
||||
double folderSize = 0;
|
||||
int decompressionProgress = 0;
|
||||
|
||||
private boolean isFilled(TextInputEditText TXT) {
|
||||
if (TXT.getText().toString().trim().length() > 0)
|
||||
return true;
|
||||
|
|
@ -134,7 +148,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
//if (!modify)
|
||||
menu.add(1, 1, 1, getString(R.string.create)).setShortcut('3', 'c').setIcon(R.drawable.check_24px).setShowAsAction(1);
|
||||
menu.add(1, 1, 1, getString(R.string.create)).setShortcut('3', 'c').setIcon(R.drawable.check_24px).setShowAsAction(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -156,41 +170,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
//
|
||||
// startActivityForResult(intent, 0);
|
||||
//if (mainlayout.getVisibility() == View.VISIBLE) {
|
||||
if (Objects.requireNonNull(title.getText()).toString().isEmpty()) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.need_set_name),true, false, activity);
|
||||
} else if ((!Objects.requireNonNull(drive.getText()).toString().isEmpty()) || (!Objects.requireNonNull(cdrom.getText()).toString().isEmpty())) {
|
||||
checkJsonFile();
|
||||
} else {
|
||||
if (VMManager.isHaveADisk(Objects.requireNonNull(qemu.getText()).toString())) {
|
||||
checkJsonFile();
|
||||
} else {
|
||||
if (qemu.getText().toString().isEmpty()) {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.problem_has_been_detected));
|
||||
alertDialog.setMessage(getResources().getString(R.string.qemu_params_is_empty));
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), (dialog, which) -> {
|
||||
checkJsonFile();
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
alertDialog.show();
|
||||
} else {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.problem_has_been_detected));
|
||||
alertDialog.setMessage(getResources().getString(R.string.you_have_not_added_any_storage_devices));
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), (dialog, which) -> {
|
||||
checkJsonFile();
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
startCreateVM();
|
||||
//}
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
|
|
@ -234,6 +214,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
TextInputLayout iconLayout = findViewById(R.id.iconField);
|
||||
TextInputLayout qemuLayout = findViewById(R.id.qemuField);
|
||||
TextView arch = findViewById(R.id.textArch);
|
||||
|
||||
linearprogress = findViewById(R.id.linearprogress);
|
||||
textviewprogress = findViewById(R.id.textviewprogress);
|
||||
|
||||
arch.setText(MainSettingsManager.getArch(this));
|
||||
icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
@ -314,45 +298,35 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
dialogFragment.customRom = true;
|
||||
dialogFragment.show(getSupportFragmentManager(), "CreateImageDialogFragment");
|
||||
} else {
|
||||
AlertDialog ad = new AlertDialog.Builder(CustomRomActivity.this, R.style.MainDialogTheme).create();
|
||||
ad.setTitle(getString(R.string.change_hard_drive));
|
||||
ad.setMessage(getString(R.string.do_you_want_to_change_create_or_remove));
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.change), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
DialogUtils.threeDialog(CustomRomActivity.this, getString(R.string.change_hard_drive), getString(R.string.do_you_want_to_change_create_or_remove), getString(R.string.change), getString(R.string.remove), getString(R.string.create), true, R.drawable.hard_drive_24px, true,
|
||||
() -> {
|
||||
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);
|
||||
}
|
||||
// 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, 1002);
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.remove), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
FileUtils.deleteDirectory(drive.getText().toString());
|
||||
drive.setText("");
|
||||
driveLayout.setEndIconDrawable(R.drawable.round_add_24);
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_NEUTRAL, getString(R.string.create), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (!createVMFolder()) {
|
||||
return;
|
||||
}
|
||||
CreateImageDialogFragment dialogFragment = new CreateImageDialogFragment();
|
||||
dialogFragment.customRom = true;
|
||||
dialogFragment.show(getSupportFragmentManager(), "CreateImageDialogFragment");
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
startActivityForResult(intent, 1002);
|
||||
},
|
||||
() -> {
|
||||
if (drive.getText().toString().contains(AppConfig.vmFolder + vmID)) {
|
||||
FileUtils.deleteDirectory(drive.getText().toString());
|
||||
}
|
||||
drive.setText("");
|
||||
driveLayout.setEndIconDrawable(R.drawable.round_add_24);
|
||||
},
|
||||
() -> {
|
||||
if (!createVMFolder()) {
|
||||
return;
|
||||
}
|
||||
CreateImageDialogFragment dialogFragment = new CreateImageDialogFragment();
|
||||
dialogFragment.customRom = true;
|
||||
dialogFragment.show(getSupportFragmentManager(), "CreateImageDialogFragment");
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -391,41 +365,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
addRomBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Objects.requireNonNull(title.getText()).toString().isEmpty()) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.need_set_name),true, false, activity);
|
||||
} else if ((!Objects.requireNonNull(drive.getText()).toString().isEmpty()) || (!Objects.requireNonNull(cdrom.getText()).toString().isEmpty())) {
|
||||
checkJsonFile();
|
||||
} else {
|
||||
if (VMManager.isHaveADisk(Objects.requireNonNull(qemu.getText()).toString())) {
|
||||
checkJsonFile();
|
||||
} else {
|
||||
if (qemu.getText().toString().isEmpty()) {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.problem_has_been_detected));
|
||||
alertDialog.setMessage(getResources().getString(R.string.qemu_params_is_empty));
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), (dialog, which) -> {
|
||||
checkJsonFile();
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
alertDialog.show();
|
||||
} else {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.problem_has_been_detected));
|
||||
alertDialog.setMessage(getResources().getString(R.string.you_have_not_added_any_storage_devices));
|
||||
alertDialog.setCancelable(true);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), (dialog, which) -> {
|
||||
checkJsonFile();
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), (dialog, which) -> {
|
||||
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
startCreateVM();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -506,34 +446,25 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
|
||||
startActivityForResult(intent, 1001);
|
||||
} else {
|
||||
AlertDialog ad = new AlertDialog.Builder(CustomRomActivity.this, R.style.MainDialogTheme).create();
|
||||
ad.setTitle(getString(R.string.change_thumbnail));
|
||||
ad.setMessage(getString(R.string.do_you_want_to_change_or_remove));
|
||||
ad.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.change), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("image/*");
|
||||
DialogUtils.twoDialog(CustomRomActivity.this, getString(R.string.change_thumbnail), getString(R.string.do_you_want_to_change_or_remove), getString(R.string.change), getString(R.string.remove), true, R.drawable.photo_24px, true,
|
||||
() -> {
|
||||
Intent intent = new Intent(ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("image/*");
|
||||
|
||||
// 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);
|
||||
}
|
||||
// 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, 1001);
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
ad.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.remove), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
thumbnailPath = "";
|
||||
ivAddThubnail.setImageResource(R.drawable.round_add_24);
|
||||
VMManager.setIconWithName(ivIcon, Objects.requireNonNull(title.getText()).toString());
|
||||
ad.dismiss();
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
startActivityForResult(intent, 1001);
|
||||
},
|
||||
() -> {
|
||||
thumbnailPath = "";
|
||||
ivAddThubnail.setImageResource(R.drawable.round_add_24);
|
||||
VMManager.setIconWithName(ivIcon, Objects.requireNonNull(title.getText()).toString());
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -542,7 +473,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
lineardisclaimer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
UIUtils.oneDialogWithCustomButtonPositive(getString(R.string.dont_miss_out), getString(R.string.disclaimer_when_using_rom), getString(R.string.i_agree), false, false, CustomRomActivity.this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.disclaimer_when_using_rom), getResources().getString(R.string.i_agree), true, R.drawable.verified_user_24px, true, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -564,8 +495,8 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
//Matcher matcher = pattern.matcher(current.itemExtra);
|
||||
|
||||
//if (matcher.find()) {
|
||||
//String cdromPath = matcher.group(1);
|
||||
//cdrom.setText(cdromPath);
|
||||
//String cdromPath = matcher.group(1);
|
||||
//cdrom.setText(cdromPath);
|
||||
//}
|
||||
|
||||
qemu.setText(current.itemExtra);
|
||||
|
|
@ -922,126 +853,34 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void startCreateVM() {
|
||||
//errorjsondialog();
|
||||
|
||||
File isoFile = new File(Objects.requireNonNull(cdrom.getText()).toString());
|
||||
if (isoFile.exists() && !Objects.requireNonNull(qemu.getText()).toString().contains(cdrom.getText().toString())) {
|
||||
isoFile.delete();
|
||||
}
|
||||
|
||||
if (modify) {
|
||||
|
||||
int position = getIntent().getIntExtra("POS", 0);
|
||||
final File jsonFile = new File(AppConfig.romsdatajson);
|
||||
current.itemDrv1 = Objects.requireNonNull(drive.getText()).toString();
|
||||
current.itemExtra = Objects.requireNonNull(qemu.getText()).toString();
|
||||
try {
|
||||
JSONObject jObj = MainActivity.jArray.getJSONObject(position);
|
||||
jObj.put("imgName", Objects.requireNonNull(title.getText()).toString());
|
||||
jObj.put("imgIcon", Objects.requireNonNull(icon.getText()).toString());
|
||||
jObj.put("imgPath", drive.getText().toString());
|
||||
jObj.put("imgExtra", qemu.getText().toString());
|
||||
|
||||
MainActivity.jArray.put(position, jObj);
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
Writer output = null;
|
||||
output = new BufferedWriter(new FileWriter(jsonFile));
|
||||
output.write(MainActivity.jArray.toString());
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
UIUtils.toastLong(CustomRomActivity.this, e.toString());
|
||||
} finally {
|
||||
MainActivity.loadDataVbi();
|
||||
finish();
|
||||
//activity.startActivity(new Intent(activity, SplashActivity.class));
|
||||
}
|
||||
if (Objects.requireNonNull(title.getText()).toString().isEmpty()) {
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getString(R.string.oops), getString(R.string.need_set_name), getString(R.string.ok), true, R.drawable.error_96px, true, null, null);
|
||||
} else {
|
||||
String CREDENTIAL_SHARED_PREF = "settings_prefs";
|
||||
SharedPreferences credentials = activity.getSharedPreferences(CREDENTIAL_SHARED_PREF, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = credentials.edit();
|
||||
editor.putBoolean("isFirstLaunch", Boolean.TRUE);
|
||||
editor.apply();
|
||||
whenProcessing(true);
|
||||
final File jsonFile = new File(AppConfig.romsdatajson);
|
||||
RomsJso obj = new RomsJso();
|
||||
if (jsonFile.exists()) {
|
||||
try {
|
||||
List<DataMainRoms> data = new ArrayList<>();
|
||||
JSONArray jArray = null;
|
||||
jArray = new JSONArray(FileUtils.readFromFile(CustomRomActivity.this, jsonFile));
|
||||
String _contentDialog = "";
|
||||
if (qemu.getText().toString().isEmpty()) {
|
||||
_contentDialog = getResources().getString(R.string.qemu_params_is_empty);
|
||||
}
|
||||
|
||||
try {
|
||||
// Extract data from json and store into ArrayList as class objects
|
||||
for (int i = 0; i < jArray.length(); i++) {
|
||||
JSONObject json_data = jArray.getJSONObject(i);
|
||||
DataMainRoms romsMainData = new DataMainRoms();
|
||||
romsMainData.itemName = json_data.getString("imgName");
|
||||
romsMainData.itemIcon = json_data.getString("imgIcon");
|
||||
romsMainData.itemPath = json_data.getString("imgPath");
|
||||
romsMainData.itemExtra = json_data.getString("imgExtra");
|
||||
data.add(romsMainData);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
Toast.makeText(CustomRomActivity.this, e.toString(), Toast.LENGTH_LONG).show();
|
||||
if ((Objects.requireNonNull(drive.getText()).toString().isEmpty()) && (Objects.requireNonNull(cdrom.getText()).toString().isEmpty())) {
|
||||
if (!VMManager.isHaveADisk(Objects.requireNonNull(qemu.getText()).toString())) {
|
||||
if (!_contentDialog.isEmpty()) {
|
||||
_contentDialog += "\n\n";
|
||||
}
|
||||
_contentDialog += getResources().getString(R.string.you_have_not_added_any_storage_devices);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = obj.makeJSONObject(Objects.requireNonNull(title.getText()).toString(), Objects.requireNonNull(icon.getText()).toString(), MainSettingsManager.getArch(activity), drive.getText().toString(), qemu.getText().toString());
|
||||
jArray.put(jsonObject);
|
||||
try {
|
||||
Writer output = null;
|
||||
output = new BufferedWriter(new FileWriter(jsonFile));
|
||||
//output.write(jArray.toString().replace("\\", "").replace("//", "/"));
|
||||
output.write(jArray.toString());
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
UIUtils.toastLong(activity, e.toString());
|
||||
whenProcessing(false);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
whenProcessing(false);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
JSONObject jsonObject = obj.makeJSONObject(Objects.requireNonNull(title.getText()).toString(), Objects.requireNonNull(icon.getText()).toString(), MainSettingsManager.getArch(activity), drive.getText().toString(), qemu.getText().toString());
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.put(jsonObject);
|
||||
try {
|
||||
Writer output = null;
|
||||
output = new BufferedWriter(new FileWriter(jsonFile));
|
||||
//output.write(jsonArray.toString().replace("\\", "").replace("//", "/"));
|
||||
output.write(jsonArray.toString());
|
||||
output.close();
|
||||
} catch (Exception e) {
|
||||
UIUtils.toastLong(activity, e.toString());
|
||||
}
|
||||
VectrasStatus.logInfo("Welcome to Vectras ♡");
|
||||
}
|
||||
if (getIntent().hasExtra("addromnow")) {
|
||||
RomsManagerActivity.isFinishNow = true;
|
||||
}
|
||||
|
||||
finish();
|
||||
//activity.startActivity(new Intent(activity, SplashActivity.class));
|
||||
}
|
||||
if (!previousName.isEmpty() && !title.getText().toString().equals(previousName)) {
|
||||
if (FileUtils.isFileExists(AppConfig.vmFolder + previousName + "/vmID.txt")) {
|
||||
FileUtils.copyAFile(AppConfig.vmFolder + previousName + "/vmID.txt", AppConfig.vmFolder + vmID + "/vmID.txt");
|
||||
if (_contentDialog.isEmpty()) {
|
||||
checkJsonFile();
|
||||
} else {
|
||||
FileUtils.writeToFile(AppConfig.vmFolder + title.getText().toString(), "/vmID.txt", VMManager.idGenerator());
|
||||
FileUtils.copyAFile(AppConfig.vmFolder + vmID + "/vmID.txt", AppConfig.vmFolder + previousName + "/vmID.txt");
|
||||
DialogUtils.twoDialog(CustomRomActivity.this, getString(R.string.problem_has_been_detected), _contentDialog, getString(R.string.continuetext), getString(R.string.cancel), true, R.drawable.warning_48px, true,
|
||||
() ->{
|
||||
checkJsonFile();
|
||||
finish();
|
||||
}, null, null);
|
||||
}
|
||||
} else {
|
||||
FileUtils.writeToFile(AppConfig.vmFolder + title.getText().toString(), "/vmID.txt", VMManager.idGenerator());
|
||||
}
|
||||
if ((!secondVMdirectory.isEmpty()) && FileUtils.isFileExists(AppConfig.vmFolder + vmID + "/vmID.txt")) {
|
||||
if (!(AppConfig.vmFolder + title.getText().toString()).equals(secondVMdirectory)) {
|
||||
FileUtils.copyAFile(AppConfig.vmFolder + vmID + "/vmID.txt", secondVMdirectory + "/vmID.txt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startCreateNewVM() {
|
||||
|
|
@ -1059,7 +898,7 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
modify = false;
|
||||
if(!MainActivity.isActivate) {
|
||||
if (!MainActivity.isActivate) {
|
||||
startActivity(new Intent(CustomRomActivity.this, SplashActivity.class));
|
||||
} else {
|
||||
Intent openURL = new Intent();
|
||||
|
|
@ -1113,9 +952,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
//Error code: CR_CVBI1
|
||||
if (!FileUtils.isFileExists(_filepath)) {
|
||||
if (getIntent().hasExtra("addromnow")) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI1), false, true, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI1), getResources().getString(R.string.ok), true, R.drawable.error_96px, true,
|
||||
this::finish, this::finish);
|
||||
} else {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI1), true, false, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI1), getResources().getString(R.string.ok), true, R.drawable.error_96px, true, null, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -1127,6 +967,33 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
whenProcessing(true);
|
||||
custom.setVisibility(View.GONE);
|
||||
ivIcon.setEnabled(false);
|
||||
|
||||
zipFileSize = FileUtils.getFileSize(_filepath);
|
||||
ZipUtils.reset();
|
||||
|
||||
timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
folderSize = FileUtils.getFolderSize(AppConfig.vmFolder + vmID);
|
||||
decompressionProgress = ZipUtils.getDecompressionProgress(folderSize, zipFileSize);
|
||||
if (decompressionProgress > 0) {
|
||||
if (decompressionProgress > 98) {
|
||||
linearprogress.setIndeterminate(true);
|
||||
} else {
|
||||
linearprogress.setProgressCompat(ZipUtils.getDecompressionProgress(folderSize, zipFileSize), true);
|
||||
}
|
||||
|
||||
textviewprogress.setText(getResources().getString(R.string.about) + " " + String.valueOf(ZipUtils.getRemainingDecompressionTime(folderSize, zipFileSize)) + " " + getResources().getString(R.string.seconds_left));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
_timer.schedule(timerTask, 0, 1000);
|
||||
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
FileInputStream zipFile = null;
|
||||
|
|
@ -1192,9 +1059,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
t.start();
|
||||
} else {
|
||||
if (getIntent().hasExtra("addromnow")) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.problem_has_been_detected), getResources().getString(R.string.format_not_supported_please_select_file_with_format_cvbi), false, true, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.problem_has_been_detected), getResources().getString(R.string.format_not_supported_please_select_file_with_format_cvbi), getResources().getString(R.string.ok), true, R.drawable.error_96px, true,
|
||||
this::finish, this::finish);
|
||||
} else {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.problem_has_been_detected), getResources().getString(R.string.format_not_supported_please_select_file_with_format_cvbi), true, false, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.problem_has_been_detected), getResources().getString(R.string.format_not_supported_please_select_file_with_format_cvbi), getResources().getString(R.string.ok), true, R.drawable.error_96px, true, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1210,24 +1078,14 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
if (VMManager.isADiskFile(selectedFilePath.getPath())) {
|
||||
startProcessingHardDriveFile(_content_describer, _addtodrive);
|
||||
} else {
|
||||
alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.problem_has_been_detected));
|
||||
alertDialog.setMessage(getResources().getString(R.string.file_format_is_not_supported));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startProcessingHardDriveFile(_content_describer, _addtodrive);
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(CustomRomActivity.this, getString(R.string.problem_has_been_detected), getString(R.string.file_format_is_not_supported), getResources().getString(R.string.continuetext), getResources().getString(R.string.cancel), true, R.drawable.hard_drive_24px, true,
|
||||
() -> {
|
||||
startProcessingHardDriveFile(_content_describer, _addtodrive);
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void startProcessingHardDriveFile (Uri _content_describer, boolean _addtodrive) {
|
||||
private void startProcessingHardDriveFile(Uri _content_describer, boolean _addtodrive) {
|
||||
File selectedFilePath = new File(getPath(_content_describer));
|
||||
if (MainSettingsManager.copyFile(activity)) {
|
||||
LinearLayout custom = findViewById(R.id.custom);
|
||||
|
|
@ -1298,9 +1156,9 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
private String cdromPatternCompile() {
|
||||
//Matches any string of characters that does not contain single quotes
|
||||
if (MainSettingsManager.getArch(activity).equals("ARM64")) {
|
||||
return "-device usb-storage,drive=cdrom -drive if=none,id=cdrom,format=raw,media=cdrom,file='([^']*)'";
|
||||
return "-device usb-storage,drive=cdrom -drive if=none,id=cdrom,format=raw,media=cdrom,file='([^']*)'";
|
||||
} else if (MainSettingsManager.getIfType(activity).isEmpty()) {
|
||||
return "-cdrom '([^']*)'";
|
||||
return "-cdrom '([^']*)'";
|
||||
} else {
|
||||
return "-drive index=1,media=cdrom,file='([^']*)'";
|
||||
}
|
||||
|
|
@ -1309,9 +1167,9 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
private String cdromPatternCompile2() {
|
||||
//Matches any string of characters, but will try to match the shortest string possible
|
||||
if (MainSettingsManager.getArch(activity).equals("ARM64")) {
|
||||
return "-device usb-storage,drive=cdrom -drive if=none,id=cdrom,format=raw,media=cdrom,file='(.*?)'";
|
||||
return "-device usb-storage,drive=cdrom -drive if=none,id=cdrom,format=raw,media=cdrom,file='(.*?)'";
|
||||
} else if (MainSettingsManager.getIfType(activity).isEmpty()) {
|
||||
return "-cdrom '(.*?)'";
|
||||
return "-cdrom '(.*?)'";
|
||||
} else {
|
||||
return "-drive index=1,media=cdrom,file='(.*?)'";
|
||||
}
|
||||
|
|
@ -1352,6 +1210,8 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
if (_isProcessing) {
|
||||
mainlayout.setVisibility(View.GONE);
|
||||
appbar.setVisibility(View.GONE);
|
||||
linearprogress.setIndeterminate(true);
|
||||
textviewprogress.setText(getResources().getString(R.string.processing_this_may_take_a_few_minutes));
|
||||
} else {
|
||||
mainlayout.setVisibility(View.VISIBLE);
|
||||
appbar.setVisibility(View.VISIBLE);
|
||||
|
|
@ -1361,9 +1221,9 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
private void thumbnailProcessing() {
|
||||
if (!thumbnailPath.isEmpty()) {
|
||||
ivAddThubnail.setImageResource(R.drawable.round_edit_24);
|
||||
File imgFile = new File(thumbnailPath);
|
||||
File imgFile = new File(thumbnailPath);
|
||||
|
||||
if(imgFile.exists()){
|
||||
if (imgFile.exists()) {
|
||||
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
|
||||
ivIcon.setImageBitmap(myBitmap);
|
||||
} else {
|
||||
|
|
@ -1387,9 +1247,10 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
if (!romDir.exists()) {
|
||||
if (!romDir.mkdirs()) {
|
||||
if (getIntent().hasExtra("addromnow")) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.unable_to_create_the_directory_to_create_the_vm), false, true, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.unable_to_create_the_directory_to_create_the_vm), getResources().getString(R.string.ok), true, R.drawable.error_96px, true,
|
||||
this::finish, this::finish);
|
||||
} else {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.unable_to_create_the_directory_to_create_the_vm), true, false, this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.unable_to_create_the_directory_to_create_the_vm), getResources().getString(R.string.ok), true, R.drawable.error_96px, true, null, null);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -1401,6 +1262,9 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void afterExtractCVBIFile(String _filename) {
|
||||
if (timerTask != null) {
|
||||
timerTask.cancel();
|
||||
}
|
||||
LinearLayout custom = findViewById(R.id.custom);
|
||||
whenProcessing(false);
|
||||
custom.setVisibility(View.VISIBLE);
|
||||
|
|
@ -1442,13 +1306,14 @@ public class CustomRomActivity extends AppCompatActivity {
|
|||
VMManager.setArch("X86_64", CustomRomActivity.this);
|
||||
}
|
||||
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI2), true, false, CustomRomActivity.this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI2), getResources().getString(R.string.ok), true, R.drawable.warning_48px, true, null, null);
|
||||
} else {
|
||||
//Error code: CR_CVBI3
|
||||
if (getIntent().hasExtra("addromnow")) {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI3), false, true, CustomRomActivity.this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI3), getResources().getString(R.string.ok), true, R.drawable.error_96px, true,
|
||||
this::finish, this::finish);
|
||||
} else {
|
||||
UIUtils.oneDialog(getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI3), true, false, CustomRomActivity.this);
|
||||
DialogUtils.oneDialog(CustomRomActivity.this, getResources().getString(R.string.oops), getResources().getString(R.string.error_CR_CVBI3), getResources().getString(R.string.ok), true, R.drawable.error_96px, true, null, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.google.gson.reflect.TypeToken;
|
|||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vm.utils.PackageUtils;
|
||||
import com.vectras.vm.utils.UIUtils;
|
||||
import com.vectras.vm.utils.ZipUtils;
|
||||
|
||||
import org.checkerframework.checker.guieffect.qual.UI;
|
||||
import org.zeroturnaround.zip.FileSource;
|
||||
|
|
@ -66,6 +67,7 @@ public class ExportRomActivity extends AppCompatActivity {
|
|||
private double folderSizeMB = 0;
|
||||
private LinearProgressIndicator progressBar;
|
||||
private TextView textviewsettingup;
|
||||
private int compressionProgress = 0;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -224,8 +226,12 @@ public class ExportRomActivity extends AppCompatActivity {
|
|||
|
||||
FileUtils.writeToFile(new File(String.valueOf(getApplicationContext().getExternalFilesDir("data"))).getPath(), "rom-data.json", new Gson().toJson(mapForGetData));
|
||||
|
||||
folderSize = FileUtils.getFolderSize(getRomPath);
|
||||
folderSizeMB = (folderSize / (1024 * 10.24)) / 2;
|
||||
//folderSize = FileUtils.getFolderSize(getRomPath);
|
||||
//folderSizeMB = (folderSize / (1024 * 10.24)) / 2;
|
||||
folderSize = FileUtils.getFileSize(diskfile);
|
||||
folderSize += FileUtils.getFileSize(cdromfile);
|
||||
folderSize += FileUtils.getFileSize(iconfile);
|
||||
ZipUtils.reset();
|
||||
|
||||
timerTask = new TimerTask() {
|
||||
@Override
|
||||
|
|
@ -234,22 +240,14 @@ public class ExportRomActivity extends AppCompatActivity {
|
|||
@Override
|
||||
public void run() {
|
||||
zipFileSize = FileUtils.getFileSize(FileUtils.getExternalFilesDirectory(getApplicationContext()).getPath() + "/cvbi/" + Objects.requireNonNull(mapForGetData.get("title")).toString() + ".cvbi");
|
||||
double zipFileSizeMB = zipFileSize / (1024 * 1024);
|
||||
double currentProgress = (100 / folderSizeMB) * zipFileSizeMB;
|
||||
if ((100 / folderSizeMB) * zipFileSizeMB < 0) {
|
||||
if ((int)currentProgress != (int)zipprogresslast) {
|
||||
zipprogress++ ;
|
||||
compressionProgress = ZipUtils.getCompressionProgress(folderSize, zipFileSize);
|
||||
if (compressionProgress > 0) {
|
||||
if (compressionProgress > 98) {
|
||||
progressBar.setIndeterminate(true);
|
||||
} else {
|
||||
progressBar.setProgressCompat(compressionProgress, true);
|
||||
}
|
||||
} else {
|
||||
zipprogress = currentProgress;
|
||||
}
|
||||
if (zipprogress > 99) {
|
||||
zipprogress = 99;
|
||||
}
|
||||
zipprogresslast = currentProgress;
|
||||
if (folderSize > 0 || zipFileSize > 0) {
|
||||
progressBar.setProgressCompat((int) zipprogress, true);
|
||||
textviewsettingup.setText(String.valueOf((int) zipprogress) + "% completed.");
|
||||
textviewsettingup.setText(getResources().getString(R.string.about) + " " + String.valueOf(ZipUtils.getRemainingCompressionTime(folderSize, zipFileSize)) + " " + getResources().getString(R.string.seconds_left));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import static com.vectras.vm.utils.LibraryChecker.isPackageInstalled2;
|
|||
import static com.vectras.vm.utils.UIUtils.UIAlert;
|
||||
|
||||
import com.vectras.vm.utils.CommandUtils;
|
||||
import com.vectras.vm.utils.DialogUtils;
|
||||
import com.vectras.vm.utils.PermissionUtils;
|
||||
|
||||
import android.androidVNC.androidVNC;
|
||||
|
|
@ -582,43 +583,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
public void onInitializationComplete(InitializationStatus initializationStatus) {
|
||||
}
|
||||
});
|
||||
if (Config.debug)
|
||||
UIAlert(activity, getString(R.string.debug_testing_build_5), getString(R.string.welcome_to_debug_build_of_vectras_vm_br) +
|
||||
getString(R.string.this_version_unstable_and_has_alot_of_bugs_br) +
|
||||
getString(R.string.don_t_forget_to_tell_us_on_github_issues_or_telegram_bot_br) +
|
||||
getString(R.string.a_href_https_t_me_vectras_protect_bot_telegram_report_bot_a_br) +
|
||||
getString(R.string.a_href_https_github_com_epicstudios856_vectras_vm_android_issues_github_issues_page_a_br));
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
if (!prefs.getBoolean("tgDialog", false)) {
|
||||
AlertDialog alertDialog;
|
||||
alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getString(R.string.join_us_on_telegram));
|
||||
alertDialog.setMessage(getString(R.string.join_us_on_telegram_where_we_publish_all_the_news_and_updates_and_receive_your_opinions_and_bugs));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.join), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String tg = "https://t.me/vectras_os";
|
||||
Intent f = new Intent(ACTION_VIEW);
|
||||
f.setData(Uri.parse(tg));
|
||||
startActivity(f);
|
||||
return;
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dont_show_again), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putBoolean("tgDialog", true);
|
||||
edit.apply();
|
||||
return;
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
DialogUtils.joinTelegram(activity);
|
||||
|
||||
totalRam = findViewById(R.id.totalRam);
|
||||
usedRam = findViewById(R.id.usedRam);
|
||||
|
|
@ -993,22 +959,22 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
public static void startVM(String vmName, String env, String itemExtra, String itemPath) {
|
||||
|
||||
timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
ActivityManager manager = (ActivityManager) activity.getSystemService(ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (!AudioStreamService.class.getName().equals(service.service.getClassName())) {
|
||||
if (SDK_INT >= Build.VERSION_CODES.O) {
|
||||
activity.startForegroundService(new Intent(activity, AudioStreamService.class));
|
||||
} else {
|
||||
activity.startService(new Intent(activity, AudioStreamService.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
timer.schedule(timerTask, 5000);
|
||||
// timerTask = new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// ActivityManager manager = (ActivityManager) activity.getSystemService(ACTIVITY_SERVICE);
|
||||
// for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
// if (!AudioStreamService.class.getName().equals(service.service.getClassName())) {
|
||||
// if (SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// activity.startForegroundService(new Intent(activity, AudioStreamService.class));
|
||||
// } else {
|
||||
// activity.startService(new Intent(activity, AudioStreamService.class));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// timer.schedule(timerTask, 5000);
|
||||
|
||||
File romDir = new File(Config.getCacheDir()+ "/" + Config.vmID);
|
||||
romDir.mkdirs();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import androidx.core.view.WindowInsetsCompat;
|
|||
import com.termux.app.TermuxService;
|
||||
import com.vectras.qemu.MainSettingsManager;
|
||||
import com.vectras.vm.utils.CommandUtils;
|
||||
import com.vectras.vm.utils.DialogUtils;
|
||||
import com.vectras.vm.utils.FileUtils;
|
||||
import com.vectras.vm.utils.ListUtils;
|
||||
import com.vectras.vm.utils.PackageUtils;
|
||||
|
|
@ -82,167 +83,95 @@ public class Minitools extends AppCompatActivity {
|
|||
|
||||
setupsoundfortermux.setOnClickListener(v -> {
|
||||
if (PackageUtils.isInstalled("com.termux", getApplicationContext())) {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.setup_sound));
|
||||
alertDialog.setMessage(getResources().getString(R.string.setup_sound_guide_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.start_setup), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("Setup", "curl -o setup.sh https://raw.githubusercontent.com/AnBui2004/termux/refs/heads/main/installpulseaudio.sh && chmod +rwx setup.sh && ./setup.sh && rm setup.sh");
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_VIEW);
|
||||
intent.setData(Uri.parse("android-app://com.termux"));
|
||||
startActivity(intent);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.copied), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getString(R.string.setup_sound), getResources().getString(R.string.setup_sound_guide_content), getString(R.string.start_setup), getString(R.string.cancel), true, R.drawable.volume_up_24px, true,
|
||||
() -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("Setup", "curl -o setup.sh https://raw.githubusercontent.com/AnBui2004/termux/refs/heads/main/installpulseaudio.sh && chmod +rwx setup.sh && ./setup.sh && rm setup.sh");
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_VIEW);
|
||||
intent.setData(Uri.parse("android-app://com.termux"));
|
||||
startActivity(intent);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.copied), Toast.LENGTH_LONG).show();
|
||||
}, null, null);
|
||||
} else {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.termux_is_not_installed));
|
||||
alertDialog.setMessage(getResources().getString(R.string.you_need_to_install_termux));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.install), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_VIEW);
|
||||
intent.setData(Uri.parse("https://github.com/termux/termux-app/releases"));
|
||||
startActivity(intent);
|
||||
return;
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getString(R.string.termux_is_not_installed), getResources().getString(R.string.you_need_to_install_termux), getString(R.string.install), getString(R.string.cancel), true, R.drawable.arrow_downward_24px, true,
|
||||
() -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ACTION_VIEW);
|
||||
intent.setData(Uri.parse("https://github.com/termux/termux-app/releases"));
|
||||
startActivity(intent);
|
||||
}, null, null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
cleanup.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.clean_up));
|
||||
alertDialog.setMessage(getResources().getString(R.string.clean_up_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.clean_up), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
VMManager.cleanUp();
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
restore.setVisibility(GONE);
|
||||
cleanup.setVisibility(GONE);
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getResources().getString(R.string.clean_up), getResources().getString(R.string.clean_up_content), getResources().getString(R.string.clean_up), getResources().getString(R.string.cancel), true, R.drawable.cleaning_services_24px, true,
|
||||
() -> {
|
||||
VMManager.cleanUp();
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
restore.setVisibility(GONE);
|
||||
cleanup.setVisibility(GONE);
|
||||
}, null, null);
|
||||
});
|
||||
|
||||
restore.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.restore));
|
||||
alertDialog.setMessage(getResources().getString(R.string.restore_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
VMManager.restoreVMs();
|
||||
UIUtils.oneDialog(getResources().getString(R.string.done), getResources().getString(R.string.restored) + " " + String.valueOf(VMManager.restoredVMs) + ".", true, false, Minitools.this);
|
||||
restore.setVisibility(GONE);
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getResources().getString(R.string.restore), getResources().getString(R.string.restore_content), getResources().getString(R.string.continuetext), getResources().getString(R.string.cancel), true, R.drawable.settings_backup_restore_24px, true,
|
||||
() -> {
|
||||
VMManager.restoreVMs();
|
||||
UIUtils.oneDialog(getResources().getString(R.string.done), getResources().getString(R.string.restored) + " " + String.valueOf(VMManager.restoredVMs) + ".", true, false, Minitools.this);
|
||||
restore.setVisibility(GONE);
|
||||
}, null, null);
|
||||
});
|
||||
|
||||
deleteallvm.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.delete_all_vm));
|
||||
alertDialog.setMessage(getResources().getString(R.string.delete_all_vm_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.delete_all), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
VMManager.killallqemuprocesses(getApplicationContext());
|
||||
FileUtils.deleteDirectory(AppConfig.vmFolder);
|
||||
FileUtils.deleteDirectory(AppConfig.recyclebin);
|
||||
FileUtils.deleteDirectory(AppConfig.romsdatajson);
|
||||
File vDir = new File(AppConfig.maindirpath);
|
||||
vDir.mkdirs();
|
||||
FileUtils.writeToFile(AppConfig.maindirpath, "roms-data.json", "[]");
|
||||
cleanup.setVisibility(GONE);
|
||||
restore.setVisibility(GONE);
|
||||
deleteallvm.setVisibility(GONE);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getResources().getString(R.string.delete_all_vm), getResources().getString(R.string.delete_all_vm_content), getResources().getString(R.string.delete_all), getResources().getString(R.string.cancel), true, R.drawable.delete_24px, true,
|
||||
() -> {
|
||||
VMManager.killallqemuprocesses(getApplicationContext());
|
||||
FileUtils.deleteDirectory(AppConfig.vmFolder);
|
||||
FileUtils.deleteDirectory(AppConfig.recyclebin);
|
||||
FileUtils.deleteDirectory(AppConfig.romsdatajson);
|
||||
File vDir = new File(AppConfig.maindirpath);
|
||||
vDir.mkdirs();
|
||||
FileUtils.writeToFile(AppConfig.maindirpath, "roms-data.json", "[]");
|
||||
cleanup.setVisibility(GONE);
|
||||
restore.setVisibility(GONE);
|
||||
deleteallvm.setVisibility(GONE);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}, null, null);
|
||||
});
|
||||
|
||||
deleteall.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.delete_all));
|
||||
alertDialog.setMessage(getResources().getString(R.string.delete_all_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.delete_all), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
VMManager.killallqemuprocesses(getApplicationContext());
|
||||
FileUtils.deleteDirectory(AppConfig.maindirpath);
|
||||
File vDir = new File(AppConfig.maindirpath);
|
||||
vDir.mkdirs();
|
||||
FileUtils.writeToFile(AppConfig.maindirpath, "roms-data.json", "[]");
|
||||
cleanup.setVisibility(GONE);
|
||||
restore.setVisibility(GONE);
|
||||
deleteallvm.setVisibility(GONE);
|
||||
deleteall.setVisibility(GONE);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getResources().getString(R.string.delete_all), getResources().getString(R.string.delete_all_content), getResources().getString(R.string.delete_all), getResources().getString(R.string.cancel), true, R.drawable.delete_forever_24px, true,
|
||||
() -> {
|
||||
VMManager.killallqemuprocesses(getApplicationContext());
|
||||
FileUtils.deleteDirectory(AppConfig.maindirpath);
|
||||
File vDir = new File(AppConfig.maindirpath);
|
||||
vDir.mkdirs();
|
||||
FileUtils.writeToFile(AppConfig.maindirpath, "roms-data.json", "[]");
|
||||
cleanup.setVisibility(GONE);
|
||||
restore.setVisibility(GONE);
|
||||
deleteallvm.setVisibility(GONE);
|
||||
deleteall.setVisibility(GONE);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.done), Toast.LENGTH_LONG).show();
|
||||
}, null, null);
|
||||
});
|
||||
|
||||
reinstallsystem.setOnClickListener(v -> {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(Minitools.this, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(getResources().getString(R.string.reinstall_system));
|
||||
alertDialog.setMessage(getResources().getString(R.string.reinstall_system_content));
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.continuetext), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MainActivity.isActivate = false;
|
||||
AppConfig.needreinstallsystem = true;
|
||||
VMManager.killallqemuprocesses(Minitools.this);
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/data");
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/distro");
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/usr");
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(Minitools.this, SetupQemuActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.twoDialog(Minitools.this, getResources().getString(R.string.reinstall_system), getResources().getString(R.string.reinstall_system_content), getResources().getString(R.string.continuetext), getResources().getString(R.string.cancel), true, R.drawable.system_update_24px, true,
|
||||
() -> {
|
||||
MainActivity.isActivate = false;
|
||||
AppConfig.needreinstallsystem = true;
|
||||
VMManager.killallqemuprocesses(Minitools.this);
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/data");
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/distro");
|
||||
FileUtils.deleteDirectory(getFilesDir().getAbsolutePath() + "/usr");
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(Minitools.this, SetupQemuActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}, null, null);
|
||||
});
|
||||
|
||||
spinnerselectmirror.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class SetupQemuActivity extends AppCompatActivity implements View.OnClick
|
|||
private HashMap<String, Object> mmap = new HashMap<>();
|
||||
private String bootstrapfilelink = "";
|
||||
private ArrayList<HashMap<String, String>> listmapForSelectMirrors = new ArrayList<>();
|
||||
private String selectedMirrorCommand = "";
|
||||
private String selectedMirrorCommand = "echo ";
|
||||
private String selectedMirrorLocation = "";
|
||||
private String downloadBootstrapsCommand = "";
|
||||
private boolean aria2Error = false;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
package com.vectras.vm.utils;
|
||||
|
||||
import static android.content.Intent.ACTION_VIEW;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vectras.vm.R;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
|
|
@ -95,4 +103,25 @@ public class DialogUtils {
|
|||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void joinTelegram(Activity _activity) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(_activity);
|
||||
if (!prefs.getBoolean("tgDialog", false)) {
|
||||
threeDialog(_activity, _activity.getResources().getString(R.string.join_us_on_telegram),
|
||||
_activity.getResources().getString(R.string.join_us_on_telegram_where_we_publish_all_the_news_and_updates_and_receive_your_opinions_and_bugs),
|
||||
_activity.getResources().getString(R.string.join), _activity.getResources().getString(R.string.cancel), _activity.getResources().getString(R.string.dont_show_again),
|
||||
true, R.drawable.send_24px, true,
|
||||
() -> {
|
||||
String tg = "https://t.me/vectras_os";
|
||||
Intent f = new Intent(ACTION_VIEW);
|
||||
f.setData(Uri.parse(tg));
|
||||
_activity.startActivity(f);
|
||||
}, null,
|
||||
() -> {
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
edit.putBoolean("tgDialog", true);
|
||||
edit.apply();
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -735,9 +735,12 @@ public class FileUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getFileSize (String _path) {
|
||||
public static int getFileSize(String _path) {
|
||||
try {
|
||||
File file = new File(_path);
|
||||
if (!file.exists()) {
|
||||
return 0;
|
||||
}
|
||||
return (int) file.length();
|
||||
} catch (Exception _e) {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -21,24 +21,17 @@ public class PermissionUtils {
|
|||
return true;
|
||||
} else {
|
||||
if (request) {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.MainDialogTheme).create();
|
||||
alertDialog.setTitle(activity.getResources().getString(R.string.allow_permissions));
|
||||
alertDialog.setMessage(activity.getResources().getString(R.string.you_need_to_grant_permission_to_access_the_storage_before_use));
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, activity.getResources().getString(R.string.allow), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (activity.shouldShowRequestPermissionRationale(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + activity.getPackageName()));
|
||||
activity.startActivity(intent);
|
||||
Toast.makeText(activity, activity.getResources().getString(R.string.find_and_allow_access_to_storage_in_settings), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000);
|
||||
}
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
DialogUtils.oneDialog(activity, activity.getString(R.string.allow_permissions), activity.getString(R.string.you_need_to_grant_permission_to_access_the_storage_before_use), activity.getString(R.string.allow), true, R.drawable.folder_24px, false,
|
||||
() -> {
|
||||
if (activity.shouldShowRequestPermissionRationale(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + activity.getPackageName()));
|
||||
activity.startActivity(intent);
|
||||
Toast.makeText(activity, activity.getResources().getString(R.string.find_and_allow_access_to_storage_in_settings), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
91
app/src/main/java/com/vectras/vm/utils/ZipUtils.java
Normal file
91
app/src/main/java/com/vectras/vm/utils/ZipUtils.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
package com.vectras.vm.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ZipUtils {
|
||||
|
||||
public static int lastProgress = 0;
|
||||
public static double lastZipFileSize = 0;
|
||||
|
||||
public static void reset() {
|
||||
lastProgress = 0;
|
||||
lastZipFileSize = 0;
|
||||
}
|
||||
|
||||
public static int getCompressionProgress(double _allfilesize, double _zipfilesize) {
|
||||
int _result = 0;
|
||||
double allfilesizeMB = _allfilesize / (1024 * 1024);
|
||||
double maximumPredictedSize = allfilesizeMB / 2;
|
||||
double zipFileSizeMB = _zipfilesize / (1024 * 1024);
|
||||
double currentProgress = (zipFileSizeMB / maximumPredictedSize) * 100;
|
||||
if (currentProgress < 0) {
|
||||
// if ((int)currentProgress != lastProgress) {
|
||||
_result = lastProgress + 1 ;
|
||||
// }
|
||||
} else {
|
||||
_result = (int) currentProgress;
|
||||
}
|
||||
if (_result > 99) {
|
||||
_result = 99;
|
||||
}
|
||||
lastProgress = _result;
|
||||
return _result;
|
||||
}
|
||||
|
||||
public static int getRemainingCompressionTime(double _allfilesize, double _zipfilesize) {
|
||||
int _result = 0;
|
||||
double allfilesizeMB = _allfilesize / (1024 * 1024);
|
||||
double zipFileSizeMB = _zipfilesize / (1024 * 1024);
|
||||
double maximumPredictedSize = allfilesizeMB / 2;
|
||||
if (lastProgress > 0) {
|
||||
_result = (int) ((maximumPredictedSize - zipFileSizeMB) / (zipFileSizeMB - lastZipFileSize));
|
||||
} else {
|
||||
_result = 3600;
|
||||
}
|
||||
if (_result < 0) {
|
||||
_result = _result * -1;
|
||||
}
|
||||
lastZipFileSize = zipFileSizeMB;
|
||||
return _result ;
|
||||
}
|
||||
|
||||
public static int getDecompressionProgress(double _unpackedsize, double _zipfilesize) {
|
||||
int _result = 0;
|
||||
double unpackedsizeMB = _unpackedsize / (1024 * 1024);
|
||||
double zipFileSizeMB = _zipfilesize / (1024 * 1024);
|
||||
double maximumPredictedSize = zipFileSizeMB * 2.5;
|
||||
double currentProgress = (unpackedsizeMB / maximumPredictedSize) * 100;
|
||||
if (currentProgress < 0) {
|
||||
// if ((int)currentProgress != lastProgress) {
|
||||
_result = lastProgress + 1 ;
|
||||
// }
|
||||
} else {
|
||||
_result = (int) currentProgress;
|
||||
}
|
||||
if (_result > 99) {
|
||||
_result = 99;
|
||||
}
|
||||
lastProgress = _result;
|
||||
return _result;
|
||||
}
|
||||
|
||||
public static int getRemainingDecompressionTime(double _unpackedsize, double _zipfilesize) {
|
||||
int _result = 0;
|
||||
double unpackedsizeMB = _unpackedsize / (1024 * 1024);
|
||||
double zipFileSizeMB = _zipfilesize / (1024 * 1024);
|
||||
double maximumPredictedSize = zipFileSizeMB * 2.5;
|
||||
if (lastProgress > 0) {
|
||||
_result = (int) ((maximumPredictedSize - unpackedsizeMB) / (unpackedsizeMB - lastZipFileSize));
|
||||
} else {
|
||||
_result = 3600;
|
||||
}
|
||||
if (_result < 0) {
|
||||
_result = _result * -1;
|
||||
}
|
||||
lastZipFileSize = unpackedsizeMB;
|
||||
return _result ;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue