mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
VUI fixes & improvements pt. 1
Re-enabled multi-process and fixed controls notch offset in multi-process Used ThreadPoolExecutor for task execution with 0 starting threads Used translation strings instead of hardcoded strings Added terminate button for lazy service Added arrow for tasks list
This commit is contained in:
parent
d3a8c0bf17
commit
93396eff44
@ -18,6 +18,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:process=":launcher"
|
||||
android:resizeableActivity="true"
|
||||
android:hasFragileUserData="true"
|
||||
android:allowNativeHeapPointerTagging="false">
|
||||
@ -80,6 +81,7 @@
|
||||
android:configChanges="keyboardHidden|orientation|screenSize|keyboard|navigation"/>
|
||||
|
||||
<activity
|
||||
android:process=":game"
|
||||
android:launchMode="standard"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:name=".MainActivity"
|
||||
|
@ -2,10 +2,9 @@ package com.kdt.mcgui;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -26,7 +25,7 @@ import java.util.Arrays;
|
||||
*
|
||||
* This class relies on ExtraCore for its behavior.
|
||||
*/
|
||||
public class ProgressLayout extends ConstraintLayout implements View.OnClickListener {
|
||||
public class ProgressLayout extends ConstraintLayout implements View.OnClickListener{
|
||||
public static final String UNPACK_RUNTIME = "unpack_runtime";
|
||||
public static final String DOWNLOAD_MINECRAFT = "download_minecraft";
|
||||
public static final String INSTALL_MODPACK = "install_modpack";
|
||||
@ -52,6 +51,7 @@ public class ProgressLayout extends ConstraintLayout implements View.OnClickList
|
||||
private final ArrayMap<String, TextProgressBar> mMap = new ArrayMap<>();
|
||||
private LinearLayout mLinearLayout;
|
||||
private TextView mTaskNumberDisplayer;
|
||||
private ImageView mFlipArrow;
|
||||
private final Runnable mCheckProgressRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -100,7 +100,7 @@ public class ProgressLayout extends ConstraintLayout implements View.OnClickList
|
||||
|
||||
setVisibility(hasProcesses() ? VISIBLE : GONE);
|
||||
|
||||
mTaskNumberDisplayer.setText(mActiveProcesses + " tasks in progress");
|
||||
mTaskNumberDisplayer.setText(getContext().getString(R.string.progresslayout_tasks_in_progress, mActiveProcesses));
|
||||
postDelayed(this, 1000);
|
||||
}
|
||||
};
|
||||
@ -123,6 +123,7 @@ public class ProgressLayout extends ConstraintLayout implements View.OnClickList
|
||||
inflate(getContext(), R.layout.view_progress, this);
|
||||
mLinearLayout = findViewById(R.id.progress_linear_layout);
|
||||
mTaskNumberDisplayer = findViewById(R.id.progress_textview);
|
||||
mFlipArrow = findViewById(R.id.progress_flip_arrow);
|
||||
postDelayed(mCheckProgressRunnable, 1000);
|
||||
|
||||
setBackgroundColor(getResources().getColor(R.color.background_bottom_bar));
|
||||
@ -159,6 +160,6 @@ public class ProgressLayout extends ConstraintLayout implements View.OnClickList
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mLinearLayout.setVisibility(mLinearLayout.getVisibility() == GONE ? VISIBLE : GONE);
|
||||
mFlipArrow.setRotation(mLinearLayout.getVisibility() == GONE? 0 : 180);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,11 +134,10 @@ public class LauncherActivity extends BaseActivity {
|
||||
try {
|
||||
Intent mainIntent = new Intent(getBaseContext(), MainActivity.class);
|
||||
mainIntent.putExtra(INTENT_MINECRAFT_VERSION, mcVersion.id);
|
||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
mainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(mainIntent);
|
||||
finish();
|
||||
Log.i("ActCheck","mainActivity finishing=" + isFinishing() + ", destroyed=" + isDestroyed());
|
||||
android.os.Process.killProcess(android.os.Process.myPid()); //You should kill yourself, NOW!
|
||||
} catch (Throwable e) {
|
||||
Tools.showError(getBaseContext(), e);
|
||||
}
|
||||
|
@ -101,25 +101,7 @@ public class MainActivity extends BaseActivity {
|
||||
// Recompute the gui scale when options are changed
|
||||
MCOptionUtils.MCOptionListener optionListener = MCOptionUtils::getMcScale;
|
||||
MCOptionUtils.addMCOptionListener(optionListener);
|
||||
|
||||
try {
|
||||
// Load keys
|
||||
mControlLayout.loadLayout(
|
||||
minecraftProfile.controlFile == null
|
||||
? LauncherPreferences.PREF_DEFAULTCTRL_PATH
|
||||
: Tools.CTRLMAP_PATH + minecraftProfile.controlFile);
|
||||
} catch(IOException e) {
|
||||
try {
|
||||
Log.w("MainActivity", "Unable to load the control file, loading the default now");
|
||||
mControlLayout.loadLayout(Tools.CTRLDEF_FILE);
|
||||
} catch (IOException ioException) {
|
||||
Tools.showError(this, ioException);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(this, th);
|
||||
}
|
||||
mControlLayout.setModifiable(false);
|
||||
mControlLayout.toggleControlVisible();
|
||||
}
|
||||
|
||||
protected void initLayout(int resId) {
|
||||
@ -202,6 +184,32 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadControls() {
|
||||
try {
|
||||
// Load keys
|
||||
mControlLayout.loadLayout(
|
||||
minecraftProfile.controlFile == null
|
||||
? LauncherPreferences.PREF_DEFAULTCTRL_PATH
|
||||
: Tools.CTRLMAP_PATH + minecraftProfile.controlFile);
|
||||
} catch(IOException e) {
|
||||
try {
|
||||
Log.w("MainActivity", "Unable to load the control file, loading the default now");
|
||||
mControlLayout.loadLayout(Tools.CTRLDEF_FILE);
|
||||
} catch (IOException ioException) {
|
||||
Tools.showError(this, ioException);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
Tools.showError(this, th);
|
||||
}
|
||||
mControlLayout.toggleControlVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
LauncherPreferences.computeNotchSize(this);
|
||||
loadControls();
|
||||
}
|
||||
|
||||
/** Boilerplate binding */
|
||||
private void bindValues(){
|
||||
mControlLayout = findViewById(R.id.main_control_layout);
|
||||
|
@ -12,13 +12,15 @@ import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.kdt.pojavlaunch.utils.*;
|
||||
|
||||
public class PojavApplication extends Application {
|
||||
public static String CRASH_REPORT_TAG = "PojavCrashReport";
|
||||
public static ExecutorService sExecutorService = Executors.newFixedThreadPool(4);
|
||||
public static ExecutorService sExecutorService = new ThreadPoolExecutor(0, 4, 500, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
@ -21,7 +21,7 @@ public class AddSubButton extends Button implements ActionButtonInterface {
|
||||
public AddSubButton(Context context, @Nullable AttributeSet attrs) {super(context, attrs); init();}
|
||||
|
||||
public void init() {
|
||||
setText("Add Button");
|
||||
setText(R.string.customctrl_addsubbutton);
|
||||
setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@ public class CloneButton extends Button implements ActionButtonInterface {
|
||||
|
||||
public void init() {
|
||||
setOnClickListener(this);
|
||||
setText("CLONE");
|
||||
setAllCaps(true);
|
||||
setText(R.string.global_clone);
|
||||
}
|
||||
|
||||
private ControlInterface mCurrentlySelectedButton = null;
|
||||
|
@ -21,7 +21,8 @@ public class DeleteButton extends Button implements ActionButtonInterface {
|
||||
|
||||
public void init() {
|
||||
setOnClickListener(this);
|
||||
setText("DELETE");
|
||||
setAllCaps(true);
|
||||
setText(R.string.global_delete);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
package net.kdt.pojavlaunch.services;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
@ -27,15 +30,9 @@ public class LazyService extends Service {
|
||||
|
||||
private static WeakReference<Service> sLazyService = new WeakReference<>(null);
|
||||
|
||||
/** Simple wrappers to start the service */
|
||||
/** Simple wrapper to start the service */
|
||||
public static void startService(Context context){
|
||||
startService(context, R.string.lazy_service_default_title, R.string.lazy_service_default_description);
|
||||
}
|
||||
|
||||
public static void startService(Context context, int titleID, int descriptionID){
|
||||
Intent intent = new Intent(context, LazyService.class);
|
||||
intent.putExtra(NOTIF_TITLE, titleID);
|
||||
intent.putExtra(NOTIF_DESC, descriptionID);
|
||||
ContextCompat.startForegroundService(context, intent);
|
||||
}
|
||||
|
||||
@ -55,14 +52,19 @@ public class LazyService extends Service {
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if(intent.getBooleanExtra("kill", false)) {
|
||||
Process.killProcess(Process.myPid());
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
buildNotificationChannel();
|
||||
//TODO custom strings ?
|
||||
Intent killIntent = new Intent(getApplicationContext(), LazyService.class);
|
||||
killIntent.putExtra("kill", true);
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "channel_id")
|
||||
.setContentTitle(getString(intent.getIntExtra(NOTIF_TITLE, R.string.lazy_service_default_title)))
|
||||
.setContentText(getString(intent.getIntExtra(NOTIF_DESC ,R.string.lazy_service_default_description)))
|
||||
.setContentTitle(getString(R.string.lazy_service_default_title))
|
||||
.setContentText(getString(R.string.lazy_service_default_description))
|
||||
.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notification_terminate), PendingIntent.getService(this, 0, killIntent, Build.VERSION.SDK_INT >=23 ? PendingIntent.FLAG_IMMUTABLE : 0))
|
||||
.setSmallIcon(R.mipmap.ic_launcher_round);
|
||||
|
||||
startForeground(1, builder.build());
|
||||
startForeground(1,builder.build());
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
|
@ -30,11 +30,21 @@
|
||||
tools:text="5 tasks in progress"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/progress_flip_arrow"
|
||||
app:layout_constraintStart_toEndOf="@+id/progress_generic_progressbar"
|
||||
app:layout_constraintTop_toTopOf="@+id/progress_generic_progressbar"
|
||||
tools:ignore="RtlSymmetry" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/progress_flip_arrow"
|
||||
android:layout_width="@dimen/_24sdp"
|
||||
android:layout_height="@dimen/_24sdp"
|
||||
android:layout_marginEnd="@dimen/_8sdp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/progress_generic_progressbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/progress_generic_progressbar"
|
||||
app:srcCompat="@drawable/spinner_arrow" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
@ -50,8 +60,6 @@
|
||||
tools:layout_height="@dimen/_100sdp"
|
||||
tools:visibility="visible"
|
||||
>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -309,4 +309,6 @@
|
||||
<string name="mcl_setting_veroption_installed">Installed</string>
|
||||
<string name="use_global_default">(Use global default)</string>
|
||||
<string name="default_control">Default control</string>
|
||||
<string name="progresslayout_tasks_in_progress">%d tasks in progress</string>
|
||||
<string name="notification_terminate">Terminate</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user