mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2026-08-28 05:45:03 -06:00
Cleanup unused files
This commit is contained in:
parent
6cd284fc24
commit
a0afe5d587
16 changed files with 17 additions and 716 deletions
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Paul Burke
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ipaulpro.afilechooser;
|
||||
|
||||
import android.content.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
|
||||
/**
|
||||
* List adapter for Files.
|
||||
*
|
||||
* @version 2013-12-11
|
||||
* @author paulburke (ipaulpro)
|
||||
*
|
||||
* @addDate 2018-08-08
|
||||
* @addToMyProject khanhduy032
|
||||
*/
|
||||
public class FileListAdapter extends BaseAdapter {
|
||||
|
||||
private final static int ICON_FOLDER = R.drawable.ic_folder;
|
||||
private final static int ICON_FILE = R.drawable.ic_file;
|
||||
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
private List<File> mData = new ArrayList<File>();
|
||||
|
||||
public FileListAdapter(Context context) {
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void add(File file) {
|
||||
mData.add(file);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void remove(File file) {
|
||||
mData.remove(file);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void insert(File file, int index) {
|
||||
mData.add(index, file);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mData.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getItem(int position) {
|
||||
return mData.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
public List<File> getListItems() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list items without notifying on the clear. This prevents loss of
|
||||
* scroll position.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void setListItems(List<File> data) {
|
||||
mData = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
|
||||
if (row == null)
|
||||
row = mInflater.inflate(android.R.layout.simple_list_item_1, parent, false);
|
||||
|
||||
TextView view = (TextView) row;
|
||||
|
||||
// Get the file at the current position
|
||||
final File file = getItem(position);
|
||||
|
||||
// Set the TextView as the file name
|
||||
view.setText(file.getName());
|
||||
|
||||
// If the item is not a directory, use the file icon
|
||||
int icon = file.isDirectory() ? ICON_FOLDER : ICON_FILE;
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
|
||||
view.setCompoundDrawablePadding(20);
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
package com.kdt;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
public class DefocusableScrollView extends ScrollView {
|
||||
|
||||
/*
|
||||
What is this class for ?
|
||||
It allows to ignore the focusing from an item such an EditText.
|
||||
Ignoring it will stop the scrollView from refocusing on the view
|
||||
*/
|
||||
|
||||
private boolean keepFocusing = false;
|
||||
|
||||
|
||||
public DefocusableScrollView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public DefocusableScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public DefocusableScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public DefocusableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void setKeepFocusing(boolean shouldKeepFocusing){
|
||||
keepFocusing = shouldKeepFocusing;
|
||||
}
|
||||
|
||||
public boolean isKeepFocusing(){
|
||||
return keepFocusing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
|
||||
if(!keepFocusing) return 0;
|
||||
return super.computeScrollDeltaToGetChildRectOnScreen(rect);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +1,13 @@
|
|||
package com.kdt;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import net.kdt.pojavlaunch.Logger;
|
||||
import net.kdt.pojavlaunch.R;
|
||||
|
||||
/**
|
||||
* A class able to display logs to the user.
|
||||
|
|
@ -22,9 +15,6 @@ import net.kdt.pojavlaunch.R;
|
|||
*/
|
||||
public class LoggerView extends ConstraintLayout {
|
||||
private Logger.eventLogListener logListener;
|
||||
private ToggleButton toggleButton;
|
||||
private ScrollView scrollView;
|
||||
private TextView log;
|
||||
|
||||
|
||||
public LoggerView(@NonNull Context context) {
|
||||
|
|
@ -33,53 +23,11 @@ public class LoggerView extends ConstraintLayout {
|
|||
|
||||
public LoggerView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflate the layout, and add component behaviors
|
||||
*/
|
||||
private void init(){
|
||||
inflate(getContext(), R.layout.loggerview_layout, this);
|
||||
log = findViewById(R.id.content_log_view);
|
||||
log.setTypeface(Typeface.MONOSPACE);
|
||||
//TODO clamp the max text so it doesn't go oob
|
||||
log.setMaxLines(Integer.MAX_VALUE);
|
||||
log.setEllipsize(null);
|
||||
log.setVisibility(GONE);
|
||||
|
||||
// Toggle log visibility
|
||||
toggleButton = findViewById(R.id.content_log_toggle_log);
|
||||
toggleButton.setOnCheckedChangeListener(
|
||||
(compoundButton, isChecked) -> {
|
||||
log.setVisibility(isChecked ? VISIBLE : GONE);
|
||||
if(!isChecked) log.setText("");
|
||||
});
|
||||
toggleButton.setChecked(false);
|
||||
|
||||
// Remove the loggerView from the user View
|
||||
ImageButton cancelButton = findViewById(R.id.log_view_cancel);
|
||||
cancelButton.setOnClickListener(view -> LoggerView.this.setVisibility(GONE));
|
||||
|
||||
// Set the scroll view
|
||||
scrollView = findViewById(R.id.content_log_scroll);
|
||||
|
||||
// Listen to logs
|
||||
logListener = text -> {
|
||||
if(log.getVisibility() != VISIBLE) return;
|
||||
post(() -> {
|
||||
log.append(text + '\n');
|
||||
scrollView.fullScroll(View.FOCUS_DOWN);
|
||||
Log.i("miniclient log: ",text);
|
||||
});
|
||||
|
||||
};
|
||||
Logger.getInstance().setLogListener(logListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
// Triggers the log view shown state by default when viewing it
|
||||
toggleButton.setChecked(visibility == VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
package com.kdt.mcgui;
|
||||
|
||||
import android.content.*;
|
||||
import android.util.*;
|
||||
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
|
||||
import net.kdt.pojavlaunch.R;
|
||||
|
||||
public class MineButton extends androidx.appcompat.widget.AppCompatButton
|
||||
{
|
||||
|
||||
public MineButton(Context ctx) {
|
||||
this(ctx, null);
|
||||
}
|
||||
|
||||
public MineButton(Context ctx, AttributeSet attrs) {
|
||||
super(ctx, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
setTypeface(ResourcesCompat.getFont(getContext(), R.font.noto_sans_bold));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.kdt.mcgui;
|
||||
|
||||
import android.content.*;
|
||||
import android.util.*;
|
||||
import android.graphics.*;
|
||||
|
||||
public class MineEditText extends com.google.android.material.textfield.TextInputEditText
|
||||
{
|
||||
public MineEditText(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
init();
|
||||
}
|
||||
|
||||
public MineEditText(Context ctx, AttributeSet attrs)
|
||||
{
|
||||
super(ctx, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
setBackgroundColor(Color.parseColor("#131313"));
|
||||
setPadding(5, 5, 5, 5);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
package com.kdt.pickafile;
|
||||
|
||||
import androidx.appcompat.app.*;
|
||||
import android.content.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.widget.AdapterView.*;
|
||||
import com.ipaulpro.afilechooser.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.os.*;
|
||||
|
||||
public class FileListView extends LinearLayout
|
||||
{
|
||||
//For list view:
|
||||
private String fullPath;
|
||||
private ListView mainLv;
|
||||
private Context context;
|
||||
|
||||
//For File selected listener:
|
||||
private FileSelectedListener listener;
|
||||
private AlertDialog build;
|
||||
private String lockPath = "/";
|
||||
|
||||
//For filtering by file types:
|
||||
private final String[] fileSuffixes;
|
||||
|
||||
public FileListView(AlertDialog build) {
|
||||
this(build.getContext(), null, new String[0]);
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public FileListView(AlertDialog build, String fileSuffix) {
|
||||
this(build.getContext(), null, new String[]{fileSuffix});
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public FileListView(AlertDialog build, String[] fileSuffixes){
|
||||
this(build.getContext(), null, fileSuffixes);
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public FileListView(Context context, AttributeSet attrs, String[] fileSuffixes) {
|
||||
this(context, attrs, 0, fileSuffixes);
|
||||
}
|
||||
|
||||
public FileListView(Context context, AttributeSet attrs, int defStyle, String[] fileSuffixes) {
|
||||
super(context, attrs, defStyle);
|
||||
this.fileSuffixes = fileSuffixes;
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void init(final Context context) {
|
||||
//Main setup:
|
||||
this.context = context;
|
||||
|
||||
LayoutParams layParam = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
|
||||
mainLv = new ListView(context);
|
||||
|
||||
mainLv.setOnItemClickListener(new OnItemClickListener(){
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4)
|
||||
{
|
||||
// TODO: Implement this method
|
||||
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
||||
if (p3 == 0 && !lockPath.equals(fullPath)) {
|
||||
parentDir();
|
||||
} else {
|
||||
listFileAt(mainFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
});
|
||||
mainLv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> p1, View p2, int p3, long p4)
|
||||
{
|
||||
// TODO: Implement this method
|
||||
File mainFile = new File(p1.getItemAtPosition(p3).toString());
|
||||
if (mainFile.isFile()) {
|
||||
listener.onFileLongClick(mainFile, mainFile.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
addView(mainLv, layParam);
|
||||
|
||||
try {
|
||||
listFileAt(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
} catch (NullPointerException e) {} // Android 10+ disallows access to sdcard
|
||||
}
|
||||
public void setFileSelectedListener(FileSelectedListener listener)
|
||||
{
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void listFileAt(final String path)
|
||||
{
|
||||
try{
|
||||
final File mainPath = new File(path);
|
||||
if(mainPath.exists()){
|
||||
if(mainPath.isDirectory()){
|
||||
fullPath = path;
|
||||
|
||||
File[] listFile = mainPath.listFiles();
|
||||
FileListAdapter fileAdapter = new FileListAdapter(context);
|
||||
if(!path.equals(lockPath)){
|
||||
fileAdapter.add(new File(path, ".."));
|
||||
}
|
||||
|
||||
if(listFile.length != 0){
|
||||
Arrays.sort(listFile, new SortFileName());
|
||||
if(fileSuffixes.length > 0){ //Meaning we want only specific files
|
||||
for(File file : listFile){
|
||||
if(file.isDirectory()){
|
||||
if((!file.getName().startsWith(".")) || file.getName().equals(".minecraft"))
|
||||
fileAdapter.add(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
for(String suffix : fileSuffixes){
|
||||
if(file.getName().endsWith("." + suffix)){
|
||||
fileAdapter.add(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{ //We get every file
|
||||
for(File file : listFile){
|
||||
fileAdapter.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mainLv.setAdapter(fileAdapter);
|
||||
if (build != null) build.setTitle(new File(path).getName());
|
||||
} else {
|
||||
listener.onFileSelected(mainPath, path);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(context, "This folder (or file) doesn't exist", Toast.LENGTH_SHORT).show();
|
||||
refreshPath();
|
||||
}
|
||||
} catch (Exception e){
|
||||
Tools.showError(context, e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFullPath(){
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
public void refreshPath() {
|
||||
listFileAt(getFullPath());
|
||||
}
|
||||
|
||||
public void parentDir() {
|
||||
File pathFile = new File(fullPath);
|
||||
if(!pathFile.getAbsolutePath().equals("/")){
|
||||
listFileAt(pathFile.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
public void lockPathAt(String path) {
|
||||
lockPath = path;
|
||||
listFileAt(path);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.kdt.pickafile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class FileSelectedListener
|
||||
{
|
||||
public abstract void onFileSelected(File file, String path);
|
||||
public void onFileLongClick(File file, String path) {}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.kdt.pickafile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SortFileName implements Comparator<File>
|
||||
{
|
||||
@Override
|
||||
public int compare(File f1, File f2) {
|
||||
return f1.getName().compareToIgnoreCase(f2.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4,33 +4,12 @@ import static net.kdt.pojavlaunch.Tools.getFileName;
|
|||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.net.Uri;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public abstract class BaseLauncherActivity extends BaseActivity {
|
||||
public Button mPlayButton;
|
||||
public ProgressBar mLaunchProgress;
|
||||
public Spinner mVersionSelector;
|
||||
public TextView mLaunchTextStatus;
|
||||
|
||||
public String[] mAvailableVersions;
|
||||
|
||||
public boolean mIsAssetsProcessing = false;
|
||||
protected boolean canBack = false;
|
||||
|
||||
public abstract void statusIsLaunching(boolean isLaunching);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used by the install button from the layout_main_v4
|
||||
|
|
@ -39,18 +18,6 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
|
||||
|
||||
public static final int RUN_MOD_INSTALLER = 2050;
|
||||
|
||||
public void launchGame(View v) {
|
||||
if (!canBack && mIsAssetsProcessing) {
|
||||
mIsAssetsProcessing = false;
|
||||
statusIsLaunching(false);
|
||||
} else if (canBack) {
|
||||
v.setEnabled(false);
|
||||
//mTask = new MinecraftDownloaderTask(this);
|
||||
//mTask.execute(mProfile.selectedVersion);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
|
@ -77,68 +44,26 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
System.out.println("call to onResume; E");
|
||||
}
|
||||
|
||||
SharedPreferences.OnSharedPreferenceChangeListener listRefreshListener = null;
|
||||
@Override
|
||||
protected void onResumeFragments() {
|
||||
super.onResumeFragments();
|
||||
if(listRefreshListener == null) {
|
||||
final BaseLauncherActivity thiz = this;
|
||||
listRefreshListener = (sharedPreferences, key) -> {
|
||||
if(key.startsWith("vertype_")) {
|
||||
System.out.println("Verlist update needed!");
|
||||
}
|
||||
};
|
||||
}
|
||||
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener(listRefreshListener);
|
||||
System.out.println("call to onResumeFragments");
|
||||
|
||||
//TODO ADD CRASH CHECK AND FOCUS
|
||||
System.out.println("call to onResumeFragments; E");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode,resultCode,data);
|
||||
System.out.println(resultCode);
|
||||
if(resultCode == Activity.RESULT_OK) {
|
||||
final ProgressDialog barrier = new ProgressDialog(this);
|
||||
barrier.setMessage(getString(R.string.global_waiting));
|
||||
barrier.setProgressStyle(barrier.STYLE_SPINNER);
|
||||
barrier.setCancelable(false);
|
||||
barrier.show();
|
||||
|
||||
// Run a mod installer
|
||||
if (requestCode == RUN_MOD_INSTALLER) {
|
||||
if (data == null) return;
|
||||
|
||||
//final Uri uri = data.getData();
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||
String path = uri.getPath();
|
||||
//File modFile = new File(new URI(path));
|
||||
|
||||
|
||||
barrier.setMessage(BaseLauncherActivity.this.getString(R.string.multirt_progress_caching));
|
||||
Thread t = new Thread(()->{
|
||||
try {
|
||||
final String name = getFileName(this, uri);
|
||||
final File modInstallerFile = new File(getCacheDir(), name);
|
||||
FileOutputStream fos = new FileOutputStream(modInstallerFile);
|
||||
IOUtils.copy(getContentResolver().openInputStream(uri), fos);
|
||||
fos.close();
|
||||
BaseLauncherActivity.this.runOnUiThread(() -> {
|
||||
barrier.dismiss();
|
||||
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
|
||||
intent.putExtra("modFile", modInstallerFile);
|
||||
startActivity(intent);
|
||||
});
|
||||
}catch(IOException e) {
|
||||
Tools.showError(BaseLauncherActivity.this,e);
|
||||
}
|
||||
BaseLauncherActivity.this.runOnUiThread(() -> {
|
||||
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void initTabs(int pageIndex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
|
@ -20,6 +21,7 @@ import net.kdt.pojavlaunch.prefs.*;
|
|||
import net.kdt.pojavlaunch.utils.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
|
||||
import static net.kdt.pojavlaunch.Tools.getFileName;
|
||||
import static net.kdt.pojavlaunch.utils.MathUtils.map;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
|
@ -27,7 +29,6 @@ import androidx.preference.PreferenceManager;
|
|||
import com.kdt.LoggerView;
|
||||
|
||||
public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouchListener {
|
||||
private static final int MSG_LEFT_MOUSE_BUTTON_CHECK = 1028;
|
||||
|
||||
private AWTCanvasView mTextureView;
|
||||
private int totalMovement;
|
||||
|
|
@ -222,7 +223,9 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
|
||||
placeMouseAt(CallbackBridge.physicalWidth / 2, CallbackBridge.physicalHeight / 2);
|
||||
|
||||
final File miniclient = (File) getIntent().getExtras().getSerializable("miniclient");
|
||||
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||
final File miniclient = new File(getCacheDir(), getFileName(this, uri));
|
||||
final File config = new File(getFilesDir(), "config.json");
|
||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||
|
||||
|
|
@ -249,7 +252,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTou
|
|||
});
|
||||
new Thread(() -> {
|
||||
try {
|
||||
launchJavaRuntime(miniclient, javaArgs,config);
|
||||
launchJavaRuntime(miniclient, javaArgs, config);
|
||||
} catch (Throwable e) {
|
||||
Tools.showError(JavaGUILauncherActivity.this, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
|
|
@ -41,9 +40,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PojavLoginActivity extends BaseActivity
|
||||
// MineActivity
|
||||
{
|
||||
public class PojavLoginActivity extends BaseActivity {
|
||||
private final Object mLockStoragePerm = new Object();
|
||||
private final Object mLockSelectJRE = new Object();
|
||||
|
||||
|
|
@ -68,7 +65,8 @@ public class PojavLoginActivity extends BaseActivity
|
|||
Tools.updateWindowSize(this);
|
||||
firstLaunchPrefs = getSharedPreferences("pojav_extract", MODE_PRIVATE);
|
||||
new Thread(new InitRunnable()).start();
|
||||
System.out.println("I got to loginactivity again");
|
||||
// If we get here that's because the client was closed.
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,24 +144,14 @@ public class PojavLoginActivity extends BaseActivity
|
|||
}
|
||||
private void uiInit() {
|
||||
setContentView(R.layout.launcher_main_v4);
|
||||
final ProgressDialog barrier = new ProgressDialog(this);
|
||||
barrier.setMessage(getString(R.string.global_waiting));
|
||||
barrier.setProgressStyle(barrier.STYLE_SPINNER);
|
||||
barrier.setCancelable(false);
|
||||
barrier.show();
|
||||
|
||||
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.miniclient);
|
||||
|
||||
barrier.setMessage(PojavLoginActivity.this.getString(R.string.multirt_progress_caching));
|
||||
Thread t = new Thread(()->{
|
||||
try {
|
||||
final String name = getFileName(this, uri);
|
||||
final File miniclient = new File(getCacheDir(), name);
|
||||
final File miniclient = new File(getCacheDir(), getFileName(this, uri));
|
||||
FileOutputStream fos = new FileOutputStream(miniclient);
|
||||
IOUtils.copy(getContentResolver().openInputStream(uri), fos);
|
||||
fos.close();
|
||||
PojavLoginActivity.this.runOnUiThread(() -> {
|
||||
barrier.dismiss();
|
||||
Intent intent = new Intent(PojavLoginActivity.this, JavaGUILauncherActivity.class);
|
||||
intent.putExtra("miniclient", miniclient);
|
||||
startActivity(intent);
|
||||
|
|
|
|||
|
|
@ -326,15 +326,6 @@ public final class Tools {
|
|||
from.renameTo(toFrom);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openURL(Activity act, String url) {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
act.startActivity(browserIntent);
|
||||
}
|
||||
|
||||
public static String convertStream(InputStream inputStream) throws IOException {
|
||||
return convertStream(inputStream, Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
public static String convertStream(InputStream inputStream, Charset charset) throws IOException {
|
||||
String out = "";
|
||||
|
|
@ -414,26 +405,6 @@ public final class Tools {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
public static void downloadFile(String urlInput, String nameOutput) throws IOException {
|
||||
File file = new File(nameOutput);
|
||||
DownloadUtils.downloadFile(urlInput, file);
|
||||
}
|
||||
public static boolean compareSHA1(File f, String sourceSHA) {
|
||||
try {
|
||||
String sha1_dst;
|
||||
try (InputStream is = new FileInputStream(f)) {
|
||||
sha1_dst = new String(Hex.encodeHex(org.apache.commons.codec.digest.DigestUtils.sha1(is)));
|
||||
}
|
||||
if(sha1_dst != null && sourceSHA != null) {
|
||||
return sha1_dst.equalsIgnoreCase(sourceSHA);
|
||||
} else{
|
||||
return true; // fake match
|
||||
}
|
||||
}catch (IOException e) {
|
||||
Log.i("SHA1","Fake-matching a hash due to a read error",e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static class ZipTool
|
||||
{
|
||||
private ZipTool(){}
|
||||
|
|
@ -504,18 +475,6 @@ public final class Tools {
|
|||
}
|
||||
}
|
||||
|
||||
public static void ignoreNotch(boolean shouldIgnore, Activity ctx){
|
||||
if (SDK_INT >= P) {
|
||||
if (shouldIgnore) {
|
||||
ctx.getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
} else {
|
||||
ctx.getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
|
||||
}
|
||||
ctx.getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
|
||||
Tools.updateWindowSize(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTotalDeviceMemory(Context ctx){
|
||||
ActivityManager actManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
|
|
@ -530,12 +489,6 @@ public final class Tools {
|
|||
return (int) (memInfo.availMem / 1048576L);
|
||||
}
|
||||
|
||||
public static int getDisplayFriendlyRes(int displaySideRes, float scaling){
|
||||
displaySideRes *= scaling;
|
||||
if(displaySideRes % 2 != 0) displaySideRes ++;
|
||||
return displaySideRes;
|
||||
}
|
||||
|
||||
public static String getFileName(Context ctx, Uri uri) {
|
||||
String result = null;
|
||||
if (uri.getScheme().equals("content")) {
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
package net.kdt.pojavlaunch.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.charset.*;
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import org.apache.commons.io.*;
|
||||
|
||||
public class DownloadUtils {
|
||||
public static final String USER_AGENT = Tools.APP_NAME;
|
||||
public static final Charset utf8 = Charset.forName("UTF-8");
|
||||
|
||||
public static void download(String url, OutputStream os) throws IOException {
|
||||
download(new URL(url), os);
|
||||
}
|
||||
|
||||
public static void download(URL url, OutputStream os) throws IOException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
// System.out.println("Connecting: " + url.toString());
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException("Server returned HTTP " + conn.getResponseCode()
|
||||
+ ": " + conn.getResponseMessage());
|
||||
}
|
||||
is = conn.getInputStream();
|
||||
IOUtils.copy(is, os);
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Unable to download from " + url.toString(), e);
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String downloadString(String url) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
download(url, bos);
|
||||
bos.close();
|
||||
return new String(bos.toByteArray(), utf8);
|
||||
}
|
||||
|
||||
public static void downloadFile(String url, File out) throws IOException {
|
||||
out.getParentFile().mkdirs();
|
||||
File tempOut = File.createTempFile(out.getName(), ".part", out.getParentFile());
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
OutputStream bos2 = new BufferedOutputStream(new FileOutputStream(tempOut));
|
||||
try {
|
||||
download(url, bos2);
|
||||
tempOut.renameTo(out);
|
||||
if (bos2 != null) {
|
||||
bos2.close();
|
||||
}
|
||||
if (tempOut.exists()) {
|
||||
tempOut.delete();
|
||||
}
|
||||
} catch (IOException th2) {
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
if (tempOut.exists()) {
|
||||
tempOut.delete();
|
||||
}
|
||||
throw th2;
|
||||
}
|
||||
} catch (IOException th3) {
|
||||
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
if (tempOut.exists()) {
|
||||
tempOut.delete();
|
||||
}
|
||||
throw th3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package net.kdt.pojavlaunch.utils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtils {
|
||||
public static boolean exists(String filePath){
|
||||
return new File(filePath).exists();
|
||||
}
|
||||
}
|
||||
|
|
@ -306,7 +306,6 @@ public class JREUtils {
|
|||
if(LOCAL_RENDERER != null) userArgs.add("-Dorg.lwjgl.opengl.libname=" + graphicsLib);
|
||||
|
||||
userArgs.addAll(JVMArgs);
|
||||
activity.runOnUiThread(() -> Toast.makeText(activity, activity.getString(R.string.autoram_info_msg,LauncherPreferences.PREF_RAM_ALLOCATION), Toast.LENGTH_SHORT).show());
|
||||
System.out.println(JVMArgs);
|
||||
|
||||
initJavaRuntime();
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@
|
|||
<string name="main_no_news_feed">Failed to fetch the news feed !</string>
|
||||
<string name="auto_ram_subtitle">Enables automatic RAM adjuster</string>
|
||||
<string name="auto_ram_title">Auto RAM</string>
|
||||
<string name="autoram_info_msg">Memory set to %d MB</string>
|
||||
<string name="mcl_setting_check_libraries">Check libraries after downloading</string>
|
||||
<string name="mcl_setting_check_libraries_subtitle">This option forces launcher to check the library hash if it\'s available. Prevents broken downloads.</string>
|
||||
<string name="dl_library_sha_fail">Library %s is damaged and will be redownloaded</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue