mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -04:00
Cleanup: Remove offset preference from code
It was already removed from user UI a few months ago
This commit is contained in:
parent
b9fa6b8756
commit
76e66d7483
@ -1,127 +0,0 @@
|
|||||||
package net.kdt.pojavlaunch.prefs;
|
|
||||||
|
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
|
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_CONTROL_BOTTOM_OFFSET;
|
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_CONTROL_LEFT_OFFSET;
|
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_CONTROL_RIGHT_OFFSET;
|
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_CONTROL_TOP_OFFSET;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import net.kdt.pojavlaunch.R;
|
|
||||||
|
|
||||||
/** Custom preference class displaying a dialog */
|
|
||||||
public class ControlOffsetPreference extends Preference {
|
|
||||||
|
|
||||||
private AlertDialog mPreferenceDialog;
|
|
||||||
|
|
||||||
public ControlOffsetPreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ControlOffsetPreference(Context context) {
|
|
||||||
super(context);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onClick() {
|
|
||||||
mPreferenceDialog.show();
|
|
||||||
|
|
||||||
SeekBar topOffsetSeekbar = mPreferenceDialog.findViewById(R.id.control_offset_top_seekbar);
|
|
||||||
SeekBar rightOffsetSeekbar = mPreferenceDialog.findViewById(R.id.control_offset_right_seekbar);
|
|
||||||
SeekBar bottomOffsetSeekbar = mPreferenceDialog.findViewById(R.id.control_offset_bottom_seekbar);
|
|
||||||
SeekBar leftOffsetSeekbar = mPreferenceDialog.findViewById(R.id.control_offset_left_seekbar);
|
|
||||||
|
|
||||||
TextView topOffsetTextView = mPreferenceDialog.findViewById(R.id.control_offset_top_textview);
|
|
||||||
TextView rightOffsetTextView = mPreferenceDialog.findViewById(R.id.control_offset_right_textview);
|
|
||||||
TextView bottomOffsetTextView = mPreferenceDialog.findViewById(R.id.control_offset_bottom_textview);
|
|
||||||
TextView leftOffsetTextView = mPreferenceDialog.findViewById(R.id.control_offset_left_textview);
|
|
||||||
|
|
||||||
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
|
||||||
if(seekBar == topOffsetSeekbar){
|
|
||||||
String text = String.format("%s %d%s", getContext().getString(R.string.control_top_offset), i, " px");
|
|
||||||
topOffsetTextView.setText(text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(seekBar == rightOffsetSeekbar){
|
|
||||||
String text = String.format("%s %d%s", getContext().getString(R.string.control_right_offset), i, " px");
|
|
||||||
rightOffsetTextView.setText(text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(seekBar == bottomOffsetSeekbar){
|
|
||||||
String text = String.format("%s %d%s", getContext().getString(R.string.control_bottom_offset), i, " px");
|
|
||||||
bottomOffsetTextView.setText(text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(seekBar == leftOffsetSeekbar){
|
|
||||||
String text = String.format("%s %d%s", getContext().getString(R.string.control_left_offset), i, " px");
|
|
||||||
leftOffsetTextView.setText(text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
|
||||||
@Override
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
topOffsetSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
|
|
||||||
rightOffsetSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
|
|
||||||
bottomOffsetSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
|
|
||||||
leftOffsetSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
|
|
||||||
|
|
||||||
topOffsetSeekbar.setProgress(PREF_CONTROL_TOP_OFFSET);
|
|
||||||
rightOffsetSeekbar.setProgress(PREF_CONTROL_RIGHT_OFFSET);
|
|
||||||
bottomOffsetSeekbar.setProgress(PREF_CONTROL_BOTTOM_OFFSET);
|
|
||||||
leftOffsetSeekbar.setProgress(PREF_CONTROL_LEFT_OFFSET);
|
|
||||||
|
|
||||||
seekBarChangeListener.onProgressChanged(topOffsetSeekbar, PREF_CONTROL_TOP_OFFSET, false);
|
|
||||||
seekBarChangeListener.onProgressChanged(rightOffsetSeekbar, PREF_CONTROL_RIGHT_OFFSET, false);
|
|
||||||
seekBarChangeListener.onProgressChanged(bottomOffsetSeekbar, PREF_CONTROL_BOTTOM_OFFSET, false);
|
|
||||||
seekBarChangeListener.onProgressChanged(leftOffsetSeekbar, PREF_CONTROL_LEFT_OFFSET, false);
|
|
||||||
|
|
||||||
// Custom writing to preferences
|
|
||||||
mPreferenceDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> {
|
|
||||||
DEFAULT_PREF.edit().putInt("controlTopOffset", topOffsetSeekbar.getProgress()).apply();
|
|
||||||
DEFAULT_PREF.edit().putInt("controlRightOffset", rightOffsetSeekbar.getProgress()).apply();
|
|
||||||
DEFAULT_PREF.edit().putInt("controlBottomOffset", bottomOffsetSeekbar.getProgress()).apply();
|
|
||||||
DEFAULT_PREF.edit().putInt("controlLeftOffset", leftOffsetSeekbar.getProgress()).apply();
|
|
||||||
|
|
||||||
|
|
||||||
mPreferenceDialog.dismiss();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(){
|
|
||||||
// Setup visual values
|
|
||||||
if(getTitle() == null){
|
|
||||||
setTitle(R.string.preference_control_offset_title);
|
|
||||||
setSummary(R.string.preference_control_offset_description);
|
|
||||||
}
|
|
||||||
if(getIcon() == null){
|
|
||||||
setIcon(android.R.drawable.radiobutton_off_background);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare Alert dialog
|
|
||||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
|
|
||||||
dialogBuilder.setView(R.layout.dialog_control_offset_preference);
|
|
||||||
dialogBuilder.setTitle(getContext().getString(R.string.control_offset_title));
|
|
||||||
|
|
||||||
dialogBuilder.setPositiveButton(android.R.string.ok, null);
|
|
||||||
dialogBuilder.setNegativeButton(android.R.string.cancel, null);
|
|
||||||
|
|
||||||
mPreferenceDialog = dialogBuilder.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -43,10 +43,6 @@ public class LauncherPreferences {
|
|||||||
public static float PREF_MOUSESPEED = 1f;
|
public static float PREF_MOUSESPEED = 1f;
|
||||||
public static int PREF_RAM_ALLOCATION;
|
public static int PREF_RAM_ALLOCATION;
|
||||||
public static String PREF_DEFAULT_RUNTIME;
|
public static String PREF_DEFAULT_RUNTIME;
|
||||||
public static int PREF_CONTROL_TOP_OFFSET = 0;
|
|
||||||
public static int PREF_CONTROL_RIGHT_OFFSET = 0;
|
|
||||||
public static int PREF_CONTROL_BOTTOM_OFFSET = 0;
|
|
||||||
public static int PREF_CONTROL_LEFT_OFFSET = 0;
|
|
||||||
public static boolean PREF_SUSTAINED_PERFORMANCE = false;
|
public static boolean PREF_SUSTAINED_PERFORMANCE = false;
|
||||||
public static boolean PREF_VIRTUAL_MOUSE_START = false;
|
public static boolean PREF_VIRTUAL_MOUSE_START = false;
|
||||||
public static boolean PREF_ARC_CAPES = false;
|
public static boolean PREF_ARC_CAPES = false;
|
||||||
@ -87,10 +83,6 @@ public class LauncherPreferences {
|
|||||||
PREF_DISABLE_GESTURES = DEFAULT_PREF.getBoolean("disableGestures",false);
|
PREF_DISABLE_GESTURES = DEFAULT_PREF.getBoolean("disableGestures",false);
|
||||||
PREF_RAM_ALLOCATION = DEFAULT_PREF.getInt("allocation", findBestRAMAllocation(ctx));
|
PREF_RAM_ALLOCATION = DEFAULT_PREF.getInt("allocation", findBestRAMAllocation(ctx));
|
||||||
PREF_CUSTOM_JAVA_ARGS = DEFAULT_PREF.getString("javaArgs", "");
|
PREF_CUSTOM_JAVA_ARGS = DEFAULT_PREF.getString("javaArgs", "");
|
||||||
PREF_CONTROL_TOP_OFFSET = DEFAULT_PREF.getInt("controlTopOffset", 0);
|
|
||||||
PREF_CONTROL_RIGHT_OFFSET = DEFAULT_PREF.getInt("controlRightOffset", 0);
|
|
||||||
PREF_CONTROL_BOTTOM_OFFSET = DEFAULT_PREF.getInt("controlBottomOffset", 0);
|
|
||||||
PREF_CONTROL_LEFT_OFFSET = DEFAULT_PREF.getInt("controlLeftOffset", 0);
|
|
||||||
PREF_SUSTAINED_PERFORMANCE = DEFAULT_PREF.getBoolean("sustainedPerformance", false);
|
PREF_SUSTAINED_PERFORMANCE = DEFAULT_PREF.getBoolean("sustainedPerformance", false);
|
||||||
PREF_VIRTUAL_MOUSE_START = DEFAULT_PREF.getBoolean("mouse_start", false);
|
PREF_VIRTUAL_MOUSE_START = DEFAULT_PREF.getBoolean("mouse_start", false);
|
||||||
PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false);
|
PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false);
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginHorizontal="15dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/control_offset_top_textview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/control_top_offset"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/control_offset_top_seekbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/control_offset_right_textview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/control_right_offset"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/control_offset_right_seekbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/control_offset_bottom_textview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/control_bottom_offset"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/control_offset_bottom_seekbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/control_offset_left_textview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/control_left_offset"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/control_offset_left_seekbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
Loading…
x
Reference in New Issue
Block a user