mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
- Migrated from viewPager to viewPager2
- Implemented new settings screens - Removed Context out of logging functions - W.I.P Streamlining the UI, a few things are broken rn
This commit is contained in:
parent
5812761838
commit
71e39273c9
8 changed files with 186 additions and 2743 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,7 @@
|
|||
package net.kdt.pojavlaunch;
|
||||
|
||||
import static net.kdt.pojavlaunch.Tools.getFileName;
|
||||
|
||||
import android.app.*;
|
||||
import android.content.*;
|
||||
import android.database.Cursor;
|
||||
|
|
@ -28,8 +30,6 @@ import org.apache.commons.io.IOUtils;
|
|||
|
||||
public abstract class BaseLauncherActivity extends BaseActivity {
|
||||
public Button mPlayButton;
|
||||
public ConsoleFragment mConsoleView;
|
||||
public CrashFragment mCrashView;
|
||||
public ProgressBar mLaunchProgress;
|
||||
public Spinner mVersionSelector;
|
||||
public MultiRTConfigDialog mRuntimeConfigDialog;
|
||||
|
|
@ -73,15 +73,12 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
final EditText edit = new EditText(this);
|
||||
edit.setSingleLine();
|
||||
edit.setHint("-jar/-cp /path/to/file.jar ...");
|
||||
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface di, int i) {
|
||||
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
|
||||
intent.putExtra("skipDetectMod", true);
|
||||
intent.putExtra("javaArgs", edit.getText().toString());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(android.R.string.ok, (di, i) -> {
|
||||
Intent intent = new Intent(BaseLauncherActivity.this, JavaGUILauncherActivity.class);
|
||||
intent.putExtra("skipDetectMod", true);
|
||||
intent.putExtra("javaArgs", edit.getText().toString());
|
||||
startActivity(intent);
|
||||
});
|
||||
dialog = builder.create();
|
||||
dialog.setView(edit);
|
||||
dialog.show();
|
||||
|
|
@ -104,7 +101,7 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
v.setEnabled(false);
|
||||
mTask = new MinecraftDownloaderTask(this);
|
||||
mTask.execute(mProfile.selectedVersion);
|
||||
mCrashView.resetCrashLog = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +129,7 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
decorView.setSystemUiVisibility(uiOptions);
|
||||
System.out.println("call to onResume; E");
|
||||
}
|
||||
|
||||
SharedPreferences.OnSharedPreferenceChangeListener listRefreshListener = null;
|
||||
@Override
|
||||
protected void onResumeFragments() {
|
||||
|
|
@ -150,76 +148,11 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
System.out.println("call to onResumeFragments");
|
||||
mRuntimeConfigDialog = new MultiRTConfigDialog();
|
||||
mRuntimeConfigDialog.prepare(this);
|
||||
try{
|
||||
final ProgressDialog barrier = new ProgressDialog(this);
|
||||
barrier.setMessage(getString(R.string.global_waiting));
|
||||
barrier.setProgressStyle(barrier.STYLE_SPINNER);
|
||||
barrier.setCancelable(false);
|
||||
barrier.show();
|
||||
|
||||
new Thread(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while (mConsoleView == null) {
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (Throwable th) {}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Throwable th) {}
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
mConsoleView.putLog("");
|
||||
barrier.dismiss();
|
||||
} catch (Throwable th) {
|
||||
startActivity(getIntent());
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
||||
File lastCrashFile = Tools.lastFileModified(Tools.DIR_HOME_CRASH);
|
||||
if(CrashFragment.isNewCrash(lastCrashFile) || !mCrashView.getLastCrash().isEmpty()){
|
||||
mCrashView.resetCrashLog = false;
|
||||
initTabs(2);
|
||||
|
||||
} /*else throw new Exception();*/
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//TODO ADD CRASH CHECK AND FOCUS
|
||||
System.out.println("call to onResumeFragments; E");
|
||||
}
|
||||
public static String getFileName(Context ctx, Uri uri) {
|
||||
String result = null;
|
||||
if (uri.getScheme().equals("content")) {
|
||||
Cursor cursor = ctx.getContentResolver().query(uri, null, null, null, null);
|
||||
try {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
result = uri.getPath();
|
||||
int cut = result.lastIndexOf('/');
|
||||
if (cut != -1) {
|
||||
result = result.substring(cut + 1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode,resultCode,data);
|
||||
|
|
@ -229,62 +162,58 @@ public abstract class BaseLauncherActivity extends BaseActivity {
|
|||
barrier.setProgressStyle(barrier.STYLE_SPINNER);
|
||||
barrier.setCancelable(false);
|
||||
barrier.show();
|
||||
if (requestCode == MultiRTConfigDialog.MULTIRT_PICK_RUNTIME) {
|
||||
if (data != null) {
|
||||
final Uri uri = data.getData();
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
String name = getFileName(this, uri);
|
||||
MultiRTUtils.installRuntimeNamed(getContentResolver().openInputStream(uri), name,
|
||||
(resid, stuff) -> BaseLauncherActivity.this.runOnUiThread(
|
||||
() -> barrier.setMessage(BaseLauncherActivity.this.getString(resid, stuff))));
|
||||
MultiRTUtils.postPrepare(BaseLauncherActivity.this, name);
|
||||
} catch (IOException e) {
|
||||
Tools.showError(BaseLauncherActivity.this
|
||||
, e);
|
||||
}
|
||||
BaseLauncherActivity.this.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
barrier.dismiss();
|
||||
mRuntimeConfigDialog.refresh();
|
||||
mRuntimeConfigDialog.dialog.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
} else if (requestCode == RUN_MOD_INSTALLER) {
|
||||
if (data != null) {
|
||||
final Uri uri = data.getData();
|
||||
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);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Catching touch exception
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return super.onTouchEvent(event);
|
||||
// Install the runtime
|
||||
if (requestCode == MultiRTConfigDialog.MULTIRT_PICK_RUNTIME) {
|
||||
if (data == null) return;
|
||||
|
||||
final Uri uri = data.getData();
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
String name = getFileName(this, uri);
|
||||
MultiRTUtils.installRuntimeNamed(getContentResolver().openInputStream(uri), name,
|
||||
(resid, stuff) -> BaseLauncherActivity.this.runOnUiThread(
|
||||
() -> barrier.setMessage(BaseLauncherActivity.this.getString(resid, stuff))));
|
||||
MultiRTUtils.postPrepare(BaseLauncherActivity.this, name);
|
||||
} catch (IOException e) {
|
||||
Tools.showError(BaseLauncherActivity.this, e);
|
||||
}
|
||||
BaseLauncherActivity.this.runOnUiThread(() -> {
|
||||
barrier.dismiss();
|
||||
mRuntimeConfigDialog.refresh();
|
||||
mRuntimeConfigDialog.dialog.show();
|
||||
});
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
// Run a mod installer
|
||||
if (requestCode == RUN_MOD_INSTALLER) {
|
||||
if (data == null) return;
|
||||
|
||||
final Uri uri = data.getData();
|
||||
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);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void initTabs(int pageIndex);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package net.kdt.pojavlaunch;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.P;
|
||||
import static net.kdt.pojavlaunch.Tools.ignoreNotch;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_HIDE_SIDEBAR;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
|
|
@ -8,7 +13,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.design.widget.VerticalTabLayout.ViewPagerAdapter;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
|
@ -19,54 +23,72 @@ import android.widget.Spinner;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Guideline;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import net.kdt.pojavlaunch.extra.ExtraCore;
|
||||
import net.kdt.pojavlaunch.extra.ExtraListener;
|
||||
import net.kdt.pojavlaunch.fragments.ConsoleFragment;
|
||||
import net.kdt.pojavlaunch.fragments.CrashFragment;
|
||||
import net.kdt.pojavlaunch.fragments.LauncherFragment;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferenceFragment;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||
import net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceFragment;
|
||||
import net.kdt.pojavlaunch.value.MinecraftAccount;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.P;
|
||||
import static net.kdt.pojavlaunch.Tools.ignoreNotch;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_HIDE_SIDEBAR;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||
|
||||
public class PojavLauncherActivity extends BaseLauncherActivity
|
||||
{
|
||||
|
||||
private ViewPager viewPager;
|
||||
// An equivalent ViewPager2 adapter class
|
||||
private static class ScreenSlidePagerAdapter extends FragmentStateAdapter {
|
||||
public ScreenSlidePagerAdapter(FragmentActivity fa) {
|
||||
super(fa);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
if (position == 0) return new LauncherFragment();
|
||||
if (position == 1) return new ConsoleFragment();
|
||||
if (position == 2) return new CrashFragment();
|
||||
if (position == 3) return new LauncherPreferenceFragment();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TextView tvConnectStatus;
|
||||
private Spinner accountSelector;
|
||||
private ViewPagerAdapter viewPageAdapter;
|
||||
private ViewPager2 viewPager;
|
||||
private final Button[] Tabs = new Button[4];
|
||||
private View selected;
|
||||
private View selectedTab;
|
||||
private ImageView accountFaceImageView;
|
||||
|
||||
private Button logoutBtn; // MineButtons
|
||||
private ExtraListener backPreferenceListener;
|
||||
|
||||
public PojavLauncherActivity() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.launcher_main_v4);
|
||||
|
||||
//Boilerplate linking/initialisation
|
||||
viewPager = findViewById(R.id.launchermainTabPager);
|
||||
selected = findViewById(R.id.viewTabSelected);
|
||||
selectedTab = findViewById(R.id.viewTabSelected);
|
||||
tvConnectStatus = findViewById(R.id.launchermain_text_accountstatus);
|
||||
accountFaceImageView = findViewById(R.id.launchermain_account_image);
|
||||
accountSelector = findViewById(R.id.launchermain_spinner_account);
|
||||
|
|
@ -85,48 +107,46 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
Toast.makeText(this, "Launcher process id: " + android.os.Process.myPid(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
mConsoleView = new ConsoleFragment();
|
||||
mCrashView = new CrashFragment();
|
||||
|
||||
viewPageAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
||||
viewPageAdapter.addFragment(new LauncherFragment(), 0, getString(R.string.mcl_tab_news));
|
||||
viewPageAdapter.addFragment(mConsoleView, 0, getString(R.string.mcl_tab_console));
|
||||
viewPageAdapter.addFragment(mCrashView, 0, getString(R.string.mcl_tab_crash));
|
||||
viewPageAdapter.addFragment(new LauncherPreferenceFragment(), 0, getString(R.string.mcl_option_settings));
|
||||
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
// Setup the viewPager to slide across fragments
|
||||
viewPager.setAdapter(new ScreenSlidePagerAdapter(this));
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
setTabActive(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels){}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {}
|
||||
});
|
||||
viewPager.setAdapter(viewPageAdapter);
|
||||
initTabs(0);
|
||||
|
||||
//Setup listener to the backPreference system
|
||||
backPreferenceListener = new ExtraListener() {
|
||||
@Override
|
||||
public boolean onValueSet(String key, String value) {
|
||||
if(value.equals("true")){
|
||||
onBackPressed();
|
||||
ExtraCore.setValue(key, "false");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
ExtraCore.addExtraListener("back_preference", backPreferenceListener);
|
||||
|
||||
|
||||
pickAccount();
|
||||
|
||||
|
||||
final List<String> accountList = new ArrayList<String>();
|
||||
final MinecraftAccount tempProfile = PojavProfile.getTempProfileContent(this);
|
||||
// Try to load the temporary account
|
||||
final List<String> accountList = new ArrayList<>();
|
||||
final MinecraftAccount tempProfile = PojavProfile.getTempProfileContent();
|
||||
if (tempProfile != null) {
|
||||
accountList.add(tempProfile.username);
|
||||
}
|
||||
for (String s : new File(Tools.DIR_ACCOUNT_NEW).list()) {
|
||||
accountList.add(s.substring(0, s.length() - 5));
|
||||
}
|
||||
|
||||
|
||||
// Setup account spinner
|
||||
pickAccount();
|
||||
ArrayAdapter<String> adapterAcc = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, accountList);
|
||||
adapterAcc.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
|
||||
|
||||
//TODO AUTHENTICATION WHEN CHANGING ACCOUNT
|
||||
//TODO SHOW ACCOUNT IMAGE IF AVAILABLE
|
||||
accountSelector.setAdapter(adapterAcc);
|
||||
|
||||
if (tempProfile != null) {
|
||||
accountSelector.setSelection(0);
|
||||
} else {
|
||||
|
|
@ -155,7 +175,8 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
// TODO: Implement this method
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Setup the minecraft version list
|
||||
List<String> versions = new ArrayList<>();
|
||||
final File fVers = new File(Tools.DIR_HOME_VERSION);
|
||||
|
||||
|
|
@ -183,7 +204,6 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
|
||||
statusIsLaunching(false);
|
||||
|
||||
initTabs(0);
|
||||
|
||||
//Add the preference changed listener
|
||||
LauncherPreferences.DEFAULT_PREF.registerOnSharedPreferenceChangeListener((sharedPreferences, key) -> {
|
||||
|
|
@ -247,9 +267,9 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
Tabs[index].setTextColor(Color.WHITE);
|
||||
|
||||
//Animating the white bar on the left
|
||||
ValueAnimator animation = ValueAnimator.ofFloat(selected.getY(), Tabs[index].getY()+(Tabs[index].getHeight()-selected.getHeight())/2f);
|
||||
ValueAnimator animation = ValueAnimator.ofFloat(selectedTab.getY(), Tabs[index].getY()+(Tabs[index].getHeight()- selectedTab.getHeight())/2f);
|
||||
animation.setDuration(250);
|
||||
animation.addUpdateListener(animation1 -> selected.setY((float) animation1.getAnimatedValue()));
|
||||
animation.addUpdateListener(animation1 -> selectedTab.setY((float) animation1.getAnimatedValue()));
|
||||
animation.start();
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +292,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
guideLine.setLayoutParams(params);
|
||||
|
||||
//Remove the selected Tab and the head image
|
||||
selected.setVisibility(View.GONE);
|
||||
selectedTab.setVisibility(View.GONE);
|
||||
accountFaceImageView.setVisibility(View.GONE);
|
||||
|
||||
//Enlarge the button, but just a bit.
|
||||
|
|
@ -285,7 +305,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
guideLine.setLayoutParams(params);
|
||||
|
||||
//Show the selected Tab
|
||||
selected.setVisibility(View.VISIBLE);
|
||||
selectedTab.setVisibility(View.VISIBLE);
|
||||
accountFaceImageView.setVisibility(View.VISIBLE);
|
||||
|
||||
//Set the default button size
|
||||
|
|
@ -310,5 +330,22 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom back stack system. Use the classic backstack when the focus is on the setting screen,
|
||||
* finish the activity and remove the back_preference listener otherwise
|
||||
*/
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
int count = getSupportFragmentManager().getBackStackEntryCount();
|
||||
|
||||
if (count == 0 && viewPager.getCurrentItem() == 3) {
|
||||
super.onBackPressed();
|
||||
//additional code
|
||||
ExtraCore.removeExtraListener("back_preference", backPreferenceListener);
|
||||
finish();
|
||||
} else {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ public class PojavProfile
|
|||
public static MinecraftAccount getCurrentProfileContent(Context ctx) throws JsonSyntaxException {
|
||||
MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName(ctx));
|
||||
if (build == null) {
|
||||
System.out.println("isTempProfile null? " + (getTempProfileContent(ctx) == null));
|
||||
return getTempProfileContent(ctx);
|
||||
System.out.println("isTempProfile null? " + (getTempProfileContent() == null));
|
||||
return getTempProfileContent();
|
||||
}
|
||||
return build;
|
||||
}
|
||||
|
||||
public static MinecraftAccount getTempProfileContent(Context ctx) {
|
||||
public static MinecraftAccount getTempProfileContent() {
|
||||
try {
|
||||
MinecraftAccount acc = MinecraftAccount.parse(Tools.read(Tools.DIR_DATA+"/cache/tempacc.json"));
|
||||
if (acc.accessToken == null) {
|
||||
|
|
|
|||
|
|
@ -1,104 +0,0 @@
|
|||
package net.kdt.pojavlaunch.prefs;
|
||||
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.*;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.*;
|
||||
import net.kdt.pojavlaunch.R;
|
||||
import net.kdt.pojavlaunch.fragments.LauncherFragment;
|
||||
|
||||
import android.content.*;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import static net.kdt.pojavlaunch.Architecture.is32BitsDevice;
|
||||
import static net.kdt.pojavlaunch.Tools.getTotalDeviceMemory;
|
||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||
|
||||
public class LauncherPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
view.setBackgroundColor(Color.parseColor("#44000000"));
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle b, String str) {
|
||||
addPreferencesFromResource(R.xml.pref_main);
|
||||
|
||||
//Disable notch checking behavior on android 8.1 and below.
|
||||
findPreference("ignoreNotch").setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && PREF_NOTCH_SIZE != 0);
|
||||
|
||||
CustomSeekBarPreference seek2 = findPreference("timeLongPressTrigger");
|
||||
seek2.setRange(100, 1000);
|
||||
seek2.setValue(LauncherPreferences.PREF_LONGPRESS_TRIGGER);
|
||||
seek2.setSuffix(" ms");
|
||||
|
||||
CustomSeekBarPreference seek3 = findPreference("buttonscale");
|
||||
seek3.setRange(80, 250);
|
||||
seek3.setValue((int) LauncherPreferences.PREF_BUTTONSIZE);
|
||||
seek3.setSuffix(" %");
|
||||
|
||||
CustomSeekBarPreference seek4 = findPreference("mousescale");
|
||||
seek4.setRange(25, 300);
|
||||
seek4.setValue((int) LauncherPreferences.PREF_MOUSESCALE);
|
||||
seek4.setSuffix(" %");
|
||||
|
||||
CustomSeekBarPreference seek5 = findPreference("resolutionRatio");
|
||||
seek5.setMin(25);
|
||||
seek5.setSuffix(" %");
|
||||
|
||||
CustomSeekBarPreference seek6 = findPreference("mousespeed");
|
||||
seek6.setRange(25, 300);
|
||||
seek6.setValue((int)(LauncherPreferences.PREF_MOUSESPEED*100f));
|
||||
seek6.setSuffix(" %");
|
||||
|
||||
|
||||
int maxRAM;
|
||||
int deviceRam = getTotalDeviceMemory(getContext());
|
||||
|
||||
|
||||
CustomSeekBarPreference seek7 = findPreference("allocation");
|
||||
seek7.setMin(256);
|
||||
|
||||
if(is32BitsDevice()) maxRAM = Math.min(1100, deviceRam);
|
||||
else maxRAM = deviceRam - (deviceRam < 3064 ? 800 : 1024); //To have a minimum for the device to breathe
|
||||
|
||||
seek7.setMax(maxRAM);
|
||||
seek7.setValue(LauncherPreferences.PREF_RAM_ALLOCATION);
|
||||
seek7.setSuffix(" MB");
|
||||
|
||||
// #724 bug fix
|
||||
if (seek5.getValue() < 25) {
|
||||
seek5.setValue(100);
|
||||
}
|
||||
|
||||
EditTextPreference editJVMArgs = findPreference("javaArgs");
|
||||
if (editJVMArgs != null) {
|
||||
editJVMArgs.setOnBindEditTextListener((editText) -> editText.setSingleLine());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences p, String s) {
|
||||
LauncherPreferences.loadPreferences(getContext());
|
||||
}
|
||||
}
|
||||
|
|
@ -324,7 +324,7 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
|||
}
|
||||
|
||||
if (p1.length < 3) {
|
||||
mActivity.mConsoleView.putLog(p1[1] + "\n");
|
||||
//mActivity.mConsoleView.putLog(p1[1] + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
|||
Tools.showError(mActivity, p1);
|
||||
}
|
||||
if(!launchWithError) {
|
||||
mActivity.mCrashView.setLastCrash("");
|
||||
//mActivity.mCrashView.setLastCrash("");
|
||||
|
||||
try {
|
||||
Intent mainIntent = new Intent(mActivity, MainActivity.class /* MainActivity.class */);
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/guidelineBottom" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/launchermainTabPager"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
|
|
|
|||
|
|
@ -1,129 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<androidx.preference.PreferenceScreen xmlns:app2="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.chom/apk/res-auto">
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/mcl_setting_category_general">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<net.kdt.pojavlaunch.prefs.RuntimeManagerPreference
|
||||
android:summary="@string/multirt_subtitle"
|
||||
android:title="@string/multirt_title"/>
|
||||
<androidx.preference.ListPreference
|
||||
android:title="@string/mcl_setting_category_renderer"
|
||||
android:key="renderer"
|
||||
android:defaultValue="opengles2"
|
||||
android:entries="@array/renderer"
|
||||
android:entryValues="@array/renderer_values"/>
|
||||
<Preference
|
||||
android:key="video_screen_setting"
|
||||
android:title="Video and renderer"
|
||||
android:summary="Resolution, scaling type, and renderer"
|
||||
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceVideoFragment"
|
||||
/>
|
||||
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="timeLongPressTrigger"
|
||||
android:summary="@string/mcl_setting_subtitle_longpresstrigger"
|
||||
android:title="@string/mcl_setting_title_longpresstrigger"
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false"
|
||||
app2:icon="@drawable/tap_len" />
|
||||
<Preference
|
||||
android:key="control_screen_setting"
|
||||
android:title="Control customization"
|
||||
android:summary="Gestures types, triggers, and scaling"
|
||||
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceControlFragment"
|
||||
/>
|
||||
|
||||
<Preference
|
||||
android:key="java_screen_setting"
|
||||
android:title="Java Tweaks"
|
||||
android:summary="Java versions, JVM Arguments, and RAM amount"
|
||||
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceJavaFragment"
|
||||
/>
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_disable_gestures"
|
||||
android:key="disableGestures"
|
||||
android:summary="@string/mcl_disable_gestures_subtitle"
|
||||
android:title="@string/mcl_disable_gestures" />
|
||||
<Preference
|
||||
android:key="misc_screen_setting"
|
||||
android:title="Miscellaneous settings"
|
||||
android:summary="Version list, and libs checks"
|
||||
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceMiscellaneousFragment"
|
||||
/>
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="hideSidebar"
|
||||
android:summary="@string/mcl_setting_subtitle_hide_sidebar"
|
||||
android:title="@string/mcl_setting_title_hide_sidebar"
|
||||
app2:icon="@drawable/hide_sidebar" />
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="allocation"
|
||||
android:icon="@drawable/ic_auto_ram"
|
||||
android:summary="@string/mcl_memory_allocation_subtitle"
|
||||
android:title="@string/mcl_memory_allocation"
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false"/>
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="ignoreNotch"
|
||||
android:summary="@string/mcl_setting_subtitle_ignore_notch"
|
||||
android:title="@string/mcl_setting_title_ignore_notch"
|
||||
app2:icon="@drawable/ignore_notch" />
|
||||
<Preference
|
||||
android:key="experimental_screen_setting"
|
||||
android:title="Experimental Stuff"
|
||||
android:summary="Use things there with consideration, no support."
|
||||
android:fragment="net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceMiscellaneousFragment"
|
||||
/>
|
||||
|
||||
<androidx.preference.EditTextPreference
|
||||
android:dialogTitle="@string/mcl_setting_title_javaargs"
|
||||
android:icon="@drawable/jre_args"
|
||||
android:key="javaArgs"
|
||||
android:singleLine="true"
|
||||
android:summary="@string/mcl_setting_subtitle_javaargs"
|
||||
android:title="@string/mcl_setting_title_javaargs" />
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_lib_check"
|
||||
android:key="checkLibraries"
|
||||
android:summary="@string/mcl_setting_check_libraries_subtitle"
|
||||
android:title="@string/mcl_setting_check_libraries" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/mcl_setting_category_scaling">
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="resolutionRatio"
|
||||
android:summary="@string/mcl_setting_subtitle_resolution_scaler"
|
||||
android:title="@string/mcl_setting_title_resolution_scaler"
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false"
|
||||
app2:icon="@drawable/resolution_scaler"/>
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="buttonscale"
|
||||
android:title="@string/mcl_setting_title_buttonscale"
|
||||
android:summary="@string/mcl_setting_subtitle_buttonscale"
|
||||
app2:showSeekBarValue="true"
|
||||
app2:selectable="false"
|
||||
app2:icon="@drawable/btn_scale"/>
|
||||
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="mousescale"
|
||||
android:summary="@string/mcl_setting_subtitle_mousescale"
|
||||
android:title="@string/mcl_setting_title_mousescale"
|
||||
app2:icon="@drawable/mouse_pointer_1"
|
||||
app2:selectable="false"
|
||||
app2:showSeekBarValue="true" />
|
||||
<net.kdt.pojavlaunch.prefs.CustomSeekBarPreference
|
||||
android:key="mousespeed"
|
||||
android:summary="@string/mcl_setting_subtitle_mousespeed"
|
||||
android:title="@string/mcl_setting_title_mousespeed"
|
||||
app2:icon="@drawable/mouse_pointer_spd"
|
||||
app2:selectable="false"
|
||||
app2:showSeekBarValue="true" />
|
||||
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/mcl_setting_category_veroption">
|
||||
|
||||
<androidx.preference.CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="vertype_release"
|
||||
android:title="@string/mcl_setting_veroption_release" />
|
||||
|
||||
<androidx.preference.CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="vertype_snapshot"
|
||||
android:title="@string/mcl_setting_veroption_snapshot" />
|
||||
|
||||
<androidx.preference.CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="vertype_oldalpha"
|
||||
android:title="@string/mcl_setting_veroption_oldalpha" />
|
||||
|
||||
<androidx.preference.CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="vertype_oldbeta"
|
||||
android:title="@string/mcl_setting_veroption_oldbeta" />
|
||||
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
Loading…
Add table
Add a link
Reference in a new issue