Rewrote EditControl popups to be easily extended.

This commit is contained in:
SerpentSpirale 2021-05-03 15:37:03 +02:00
parent 6a58867051
commit 55c0d19c49
8 changed files with 559 additions and 1367 deletions

View File

@ -25,39 +25,41 @@ import static net.kdt.pojavlaunch.customcontrols.handleview.ActionPopupWindow.se
public class EditControlButtonPopup {
private Dialog dialog;
protected Dialog dialog;
protected View v;
protected AlertDialog.Builder builder;
private EditText editName;
private Spinner[] spinnersKeycode;
protected EditText editName;
protected Spinner[] spinnersKeycode;
private CheckBox checkToggle;
private CheckBox checkPassThrough;
private CheckBox checkDynamicPosition;
private CheckBox checkHoldAlt;
private CheckBox checkHoldCtrl;
private CheckBox checkHoldShift;
protected CheckBox checkToggle;
protected CheckBox checkPassThrough;
protected CheckBox checkDynamicPosition;
protected CheckBox checkHoldAlt;
protected CheckBox checkHoldCtrl;
protected CheckBox checkHoldShift;
private EditText editWidth;
private EditText editHeight;
private EditText editDynamicX;
private EditText editDynamicY;
protected EditText editWidth;
protected EditText editHeight;
protected EditText editDynamicX;
protected EditText editDynamicY;
private SeekBar seekBarOpacity;
private SeekBar seekBarCornerRadius;
private SeekBar seekBarStrokeWidth;
protected SeekBar seekBarOpacity;
protected SeekBar seekBarCornerRadius;
protected SeekBar seekBarStrokeWidth;
private ImageButton buttonBackgroundColor;
private ImageButton buttonStrokeColor;
protected ImageButton buttonBackgroundColor;
protected ImageButton buttonStrokeColor;
private TextView textOpacity;
private TextView textCornerRadius;
private TextView textStrokeWidth;
protected TextView textOpacity;
protected TextView textCornerRadius;
protected TextView textStrokeWidth;
private final ControlButton button;
private final ControlData properties;
protected final ControlButton button;
protected final ControlData properties;
private ArrayAdapter<String> adapter;
private String[] specialArr;
protected ArrayAdapter<String> adapter;
protected String[] specialArr;
public EditControlButtonPopup(ControlButton button){
@ -65,43 +67,46 @@ public class EditControlButtonPopup {
this.properties = button.getProperties();
initializeEditDialog(button.getContext());
setEditDialogValues();
//Create the finalized dialog
dialog = builder.create();
dialog.setOnShowListener(dialogInterface -> setEditDialogValues());
dialog.show();
}
public void initializeEditDialog(Context ctx){
protected void initializeEditDialog(Context ctx){
//Create the editing dialog
LayoutInflater layoutInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = layoutInflater.inflate(R.layout.control_setting_v2,null);
v = layoutInflater.inflate(R.layout.control_button_setting,null);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
alertBuilder.setTitle(ctx.getResources().getString(R.string.customctrl_edit, properties.name));
alertBuilder.setView(v);
builder = new AlertDialog.Builder(ctx);
builder.setTitle(ctx.getResources().getString(R.string.customctrl_edit, properties.name));
builder.setView(v);
//Linking a lot of stuff
editName = v.findViewById(R.id.controlsetting_edit_name);
editName = v.findViewById(R.id.editName_editText);
spinnersKeycode = new Spinner[]{
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode2),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode3),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode4)
v.findViewById(R.id.editMapping_spinner_1),
v.findViewById(R.id.editMapping_spinner_2),
v.findViewById(R.id.editMapping_spinner_3),
v.findViewById(R.id.editMapping_spinner_4)
};
checkToggle = v.findViewById(R.id.controlsetting_checkbox_toggle);
checkPassThrough = v.findViewById(R.id.controlsetting_checkbox_passthru);
checkToggle = v.findViewById(R.id.checkboxToggle);
checkPassThrough = v.findViewById(R.id.checkboxPassThrough);
editWidth = v.findViewById(R.id.controlsetting_edit_width);
editHeight = v.findViewById(R.id.controlsetting_edit_height);
editWidth = v.findViewById(R.id.editSize_editTextX);
editHeight = v.findViewById(R.id.editSize_editTextY);
editDynamicX = v.findViewById(R.id.controlsetting_edit_dynamicpos_x);
editDynamicY = v.findViewById(R.id.controlsetting_edit_dynamicpos_y);
editDynamicX = v.findViewById(R.id.editDynamicPositionX_editText);
editDynamicY = v.findViewById(R.id.editDynamicPositionY_editText);
seekBarOpacity = v.findViewById(R.id.controlsetting_seek_opacity);
seekBarCornerRadius = v.findViewById(R.id.controlsetting_seek_corner_radius);
seekBarStrokeWidth = v.findViewById(R.id.controlsetting_seek_stroke_width);
seekBarOpacity = v.findViewById(R.id.editButtonOpacity_seekbar);
seekBarCornerRadius = v.findViewById(R.id.editCornerRadius_seekbar);
seekBarStrokeWidth = v.findViewById(R.id.editStrokeWidth_seekbar);
//Add listeners, too bad I don't need all the methods
seekBarOpacity.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@ -152,23 +157,23 @@ public class EditControlButtonPopup {
}
});
buttonBackgroundColor = v.findViewById(R.id.controlsetting_background_color);
buttonStrokeColor = v.findViewById(R.id.controlsetting_stroke_color);
buttonBackgroundColor = v.findViewById(R.id.editBackgroundColor_imageButton);
buttonStrokeColor = v.findViewById(R.id.editStrokeColor_imageButton);
textOpacity = v.findViewById(R.id.controlsetting_text_opacity);
textCornerRadius = v.findViewById(R.id.controlsetting_text_corner_radius);
textStrokeWidth = v.findViewById(R.id.controlsetting_text_stroke_width);
textOpacity = v.findViewById(R.id.editButtonOpacity_textView_percent);
textCornerRadius = v.findViewById(R.id.editCornerRadius_textView_percent);
textStrokeWidth = v.findViewById(R.id.editStrokeWidth_textView_percent);
checkDynamicPosition = v.findViewById(R.id.controlsetting_checkbox_dynamicpos);
checkDynamicPosition = v.findViewById(R.id.checkboxDynamicPosition);
checkDynamicPosition.setOnCheckedChangeListener((btn, checked) -> {
editDynamicX.setEnabled(checked);
editDynamicY.setEnabled(checked);
});
checkHoldAlt = v.findViewById(R.id.controlsetting_checkbox_keycombine_alt);
checkHoldCtrl = v.findViewById(R.id.controlsetting_checkbox_keycombine_control);
checkHoldShift = v.findViewById(R.id.controlsetting_checkbox_keycombine_shift);
checkHoldAlt = v.findViewById(R.id.checkBoxKeyCombination_alt);
checkHoldCtrl = v.findViewById(R.id.checkBoxKeyCombination_ctrl);
checkHoldShift = v.findViewById(R.id.checkBoxKeyCombination_shift);
//Initialize adapter for keycodes
adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item);
@ -190,24 +195,29 @@ public class EditControlButtonPopup {
buttonStrokeColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit stroke color", false, ((ColorDrawable) buttonStrokeColor.getBackground()).getColor(), buttonStrokeColor));
//Set dialog buttons behavior
alertBuilder.setPositiveButton(android.R.string.ok, (dialogInterface1, i) -> {
setupDialogButtons();
hideUselessViews();
}
protected void setupDialogButtons(){
//Set dialog buttons behavior
builder.setPositiveButton(android.R.string.ok, (dialogInterface1, i) -> {
if(!hasPropertiesErrors(dialog.getContext())){
saveProperties();
}
});
alertBuilder.setNegativeButton(android.R.string.cancel, null);
//Create the finalized dialog
dialog = alertBuilder.create();
dialog.setOnShowListener(dialogInterface -> {
//setEditDialogValues();
});
builder.setNegativeButton(android.R.string.cancel, null);
}
private void setEditDialogValues(){
protected void hideUselessViews(){
(v.findViewById(R.id.editOrientation_textView)).setVisibility(View.GONE);
}
protected void setEditDialogValues(){
editName.setText(properties.name);
@ -250,7 +260,7 @@ public class EditControlButtonPopup {
}
private boolean hasPropertiesErrors(Context ctx){
protected boolean hasPropertiesErrors(Context ctx){
if (editName.getText().toString().isEmpty()) {
editName.setError(ctx.getResources().getString(R.string.global_error_field_empty));
return true;
@ -273,7 +283,7 @@ public class EditControlButtonPopup {
return false;
}
private void saveProperties(){
protected void saveProperties(){
//This method assumes there are no error.
properties.name = editName.getText().toString();

View File

@ -24,238 +24,65 @@ import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import static net.kdt.pojavlaunch.customcontrols.handleview.ActionPopupWindow.setPercentageText;
public class EditControlDrawerPopup {
private Dialog dialog;
private EditText editName;
public class EditControlDrawerPopup extends EditControlButtonPopup{
private Spinner spinnerOrientation;
private CheckBox checkDynamicPosition;
private EditText editWidth;
private EditText editHeight;
private EditText editDynamicX;
private EditText editDynamicY;
private SeekBar seekBarOpacity;
private SeekBar seekBarCornerRadius;
private SeekBar seekBarStrokeWidth;
private ImageButton buttonBackgroundColor;
private ImageButton buttonStrokeColor;
private TextView textOpacity;
private TextView textCornerRadius;
private TextView textStrokeWidth;
private ControlDrawer drawer;
private ControlDrawerData drawerData;
public EditControlDrawerPopup(ControlDrawer editedButton) {
super(editedButton);
drawer = editedButton;
drawerData = editedButton.getDrawerData();
initializeEditDialog(drawer.getContext());
setEditDialogValues();
dialog.show();
}
private void initializeEditDialog(Context ctx){
LayoutInflater layoutInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = layoutInflater.inflate(R.layout.control_drawer_setting,null);
@Override
protected void hideUselessViews() {
(v.findViewById(R.id.editMapping_textView)).setVisibility(View.GONE);
checkPassThrough.setVisibility(View.GONE);
checkToggle.setVisibility(View.GONE);
}
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
alertBuilder.setTitle(ctx.getResources().getString(R.string.customctrl_edit, drawerData.properties.name));
alertBuilder.setView(v);
@Override
protected void initializeEditDialog(Context ctx) {
super.initializeEditDialog(ctx);
//LINKING PHASE
editName = v.findViewById(R.id.controlsetting_edit_name);
spinnerOrientation = v.findViewById(R.id.controlsetting_orientation);
editWidth = v.findViewById(R.id.controlsetting_edit_width);
editHeight = v.findViewById(R.id.controlsetting_edit_height);
editDynamicX = v.findViewById(R.id.controlsetting_edit_dynamicpos_x);
editDynamicY = v.findViewById(R.id.controlsetting_edit_dynamicpos_y);
seekBarOpacity = v.findViewById(R.id.controlsetting_seek_opacity);
seekBarCornerRadius = v.findViewById(R.id.controlsetting_seek_corner_radius);
seekBarStrokeWidth = v.findViewById(R.id.controlsetting_seek_stroke_width);
//Add listeners, too bad I don't need all the methods
seekBarOpacity.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textOpacity, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
seekBarCornerRadius.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textCornerRadius, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
seekBarStrokeWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textStrokeWidth, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
buttonBackgroundColor = v.findViewById(R.id.controlsetting_background_color);
buttonStrokeColor = v.findViewById(R.id.controlsetting_stroke_color);
textOpacity = v.findViewById(R.id.controlsetting_text_opacity);
textCornerRadius = v.findViewById(R.id.controlsetting_text_corner_radius);
textStrokeWidth = v.findViewById(R.id.controlsetting_text_stroke_width);
checkDynamicPosition = v.findViewById(R.id.controlsetting_checkbox_dynamicpos);
checkDynamicPosition.setOnCheckedChangeListener((btn, checked) -> {
editDynamicX.setEnabled(checked);
editDynamicY.setEnabled(checked);
});
spinnerOrientation = v.findViewById(R.id.editOrientation_spinner);
ArrayAdapter<ControlDrawerData.Orientation> adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item);
adapter.addAll(ControlDrawerData.getOrientations());
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
spinnerOrientation.setAdapter(adapter);
}
//Set color imageButton behavior
buttonBackgroundColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit background color", true, ((ColorDrawable) buttonBackgroundColor.getBackground()).getColor(), buttonBackgroundColor));
buttonStrokeColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit stroke color", false, ((ColorDrawable) buttonStrokeColor.getBackground()).getColor(), buttonStrokeColor));
@Override
protected void setEditDialogValues() {
super.setEditDialogValues();
//Set dialog buttons behavior
alertBuilder.setNegativeButton(android.R.string.cancel, null);
alertBuilder.setPositiveButton(android.R.string.ok, (dialogInterface1, i) -> {
if(!hasPropertiesErrors(dialog.getContext())){
saveProperties();
}
});
spinnerOrientation.setSelection(ControlDrawerData.orientationToInt(drawerData.orientation));
}
alertBuilder.setNeutralButton("Add sub-button", new DialogInterface.OnClickListener() {
@Override
protected void setupDialogButtons() {
super.setupDialogButtons();
builder.setNeutralButton("Add sub-button", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//TODO add a button;
ControlLayout layout = (ControlLayout) drawer.getParent();
layout.addSubButton(drawer, new ControlData());
}
});
}
//Create the finalized dialog
dialog = alertBuilder.create();
} //initializeEditDialog
private void setEditDialogValues() {
editName.setText(drawerData.properties.name);
spinnerOrientation.setSelection(ControlDrawerData.orientationToInt(drawerData.orientation));
editWidth.setText(Float.toString(drawerData.properties.width));
editHeight.setText(Float.toString(drawerData.properties.height));
editDynamicX.setEnabled(drawerData.properties.isDynamicBtn);
editDynamicY.setEnabled(drawerData.properties.isDynamicBtn);
editDynamicX.setHint(Float.toString(drawerData.properties.x));
editDynamicX.setText(drawerData.properties.dynamicX);
editDynamicY.setHint(Float.toString(drawerData.properties.y));
editDynamicY.setText(drawerData.properties.dynamicY);
seekBarOpacity.setProgress((int)drawerData.properties.opacity*100);
seekBarStrokeWidth.setProgress(drawerData.properties.strokeWidth);
seekBarCornerRadius.setProgress((int)drawerData.properties.cornerRadius);
buttonBackgroundColor.setBackgroundColor(drawerData.properties.bgColor);
buttonStrokeColor.setBackgroundColor(drawerData.properties.strokeColor);
setPercentageText(textCornerRadius,seekBarCornerRadius.getProgress());
setPercentageText(textOpacity,seekBarOpacity.getProgress());
setPercentageText(textStrokeWidth,seekBarStrokeWidth.getProgress());
checkDynamicPosition.setChecked(drawerData.properties.isDynamicBtn);
}//setEditValues
private boolean hasPropertiesErrors(Context ctx){
if (editName.getText().toString().isEmpty()) {
editName.setError(ctx.getResources().getString(R.string.global_error_field_empty));
return true;
}
if (drawerData.properties.isDynamicBtn) {
int errorAt = 0;
try {
drawerData.properties.insertDynamicPos(editDynamicX.getText().toString());
errorAt = 1;
drawerData.properties.insertDynamicPos(editDynamicY.getText().toString());
} catch (Throwable th) {
(errorAt == 0 ? editDynamicX : editDynamicY).setError(th.getMessage());
return true;
}
}
return false;
}//hasErrors
private void saveProperties(){
drawerData.properties.name = editName.getText().toString();
@Override
protected void saveProperties() {
drawerData.orientation = ControlDrawerData.intToOrientation(spinnerOrientation.getSelectedItemPosition());
drawerData.properties.opacity = seekBarOpacity.getProgress()/100f;
drawerData.properties.strokeWidth = seekBarStrokeWidth.getProgress();
drawerData.properties.cornerRadius = seekBarCornerRadius.getProgress();
drawerData.properties.bgColor = ((ColorDrawable) buttonBackgroundColor.getBackground()).getColor();
drawerData.properties.strokeColor = ((ColorDrawable) buttonStrokeColor.getBackground()).getColor();
drawerData.properties.width = Float.parseFloat(editWidth.getText().toString());
drawerData.properties.height = Float.parseFloat(editHeight.getText().toString());
drawerData.properties.isDynamicBtn = checkDynamicPosition.isChecked();
drawerData.properties.dynamicX = editDynamicX.getText().toString().isEmpty() ? drawerData.properties.dynamicX = Float.toString(drawerData.properties.x) : editDynamicX.getText().toString();
drawerData.properties.dynamicY = editDynamicY.getText().toString().isEmpty() ? drawerData.properties.dynamicY = Float.toString(drawerData.properties.y) : editDynamicY.getText().toString();
drawer.updateProperties();
}//saveProperties
super.saveProperties();
}
}

View File

@ -22,242 +22,25 @@ import net.kdt.pojavlaunch.customcontrols.ControlData;
import static net.kdt.pojavlaunch.customcontrols.handleview.ActionPopupWindow.setPercentageText;
public class EditControlSubButtonPopup {
private Dialog dialog;
private EditText editName;
private Spinner[] spinnersKeycode;
private CheckBox checkToggle;
private CheckBox checkPassThrough;
private CheckBox checkHoldAlt;
private CheckBox checkHoldCtrl;
private CheckBox checkHoldShift;
private SeekBar seekBarOpacity;
private SeekBar seekBarCornerRadius;
private SeekBar seekBarStrokeWidth;
private ImageButton buttonBackgroundColor;
private ImageButton buttonStrokeColor;
private TextView textOpacity;
private TextView textCornerRadius;
private TextView textStrokeWidth;
private final ControlButton button;
private final ControlData properties;
private ArrayAdapter<String> adapter;
private String[] specialArr;
public class EditControlSubButtonPopup extends EditControlButtonPopup{
public EditControlSubButtonPopup(ControlButton button){
this.button = button;
this.properties = button.getProperties();
initializeEditDialog(button.getContext());
setEditDialogValues();
dialog.show();
super(button);
}
@Override
protected void hideUselessViews() {
(v.findViewById(R.id.editSize_textView)).setVisibility(View.GONE);
public void initializeEditDialog(Context ctx){
//Create the editing dialog
LayoutInflater layoutInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = layoutInflater.inflate(R.layout.control_sub_button, null);
(v.findViewById(R.id.editOrientation_textView)).setVisibility(View.GONE);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
alertBuilder.setTitle(ctx.getResources().getString(R.string.customctrl_edit, properties.name));
alertBuilder.setView(v);
checkDynamicPosition.setVisibility(View.GONE);
//Linking a lot of stuff
editName = v.findViewById(R.id.controlsetting_edit_name);
spinnersKeycode = new Spinner[]{
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode2),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode3),
v.findViewById(R.id.controlsetting_spinner_lwjglkeycode4)
};
checkToggle = v.findViewById(R.id.controlsetting_checkbox_toggle);
checkPassThrough = v.findViewById(R.id.controlsetting_checkbox_passthru);
seekBarOpacity = v.findViewById(R.id.controlsetting_seek_opacity);
seekBarCornerRadius = v.findViewById(R.id.controlsetting_seek_corner_radius);
seekBarStrokeWidth = v.findViewById(R.id.controlsetting_seek_stroke_width);
//Add listeners, too bad I don't need all the methods
seekBarOpacity.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textOpacity, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
seekBarCornerRadius.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textCornerRadius, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
seekBarStrokeWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
setPercentageText(textStrokeWidth, i);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//AUTO GENERATED STUB
}
});
buttonBackgroundColor = v.findViewById(R.id.controlsetting_background_color);
buttonStrokeColor = v.findViewById(R.id.controlsetting_stroke_color);
textOpacity = v.findViewById(R.id.controlsetting_text_opacity);
textCornerRadius = v.findViewById(R.id.controlsetting_text_corner_radius);
textStrokeWidth = v.findViewById(R.id.controlsetting_text_stroke_width);
checkHoldAlt = v.findViewById(R.id.controlsetting_checkbox_keycombine_alt);
checkHoldCtrl = v.findViewById(R.id.controlsetting_checkbox_keycombine_control);
checkHoldShift = v.findViewById(R.id.controlsetting_checkbox_keycombine_shift);
//Initialize adapter for keycodes
adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item);
String[] oldSpecialArr = ControlData.buildSpecialButtonArray();
specialArr = new String[oldSpecialArr.length];
for (int i = 0; i < specialArr.length; i++) {
specialArr[i] = "SPECIAL_" + oldSpecialArr[specialArr.length - i - 1];
}
adapter.addAll(specialArr);
adapter.addAll(AndroidLWJGLKeycode.generateKeyName());
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
for (Spinner spinner : spinnersKeycode) {
spinner.setAdapter(adapter);
}
//Set color imageButton behavior
buttonBackgroundColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit background color", true, ((ColorDrawable) buttonBackgroundColor.getBackground()).getColor(), buttonBackgroundColor));
buttonStrokeColor.setOnClickListener(view -> ActionPopupWindow.showColorPicker(ctx, "Edit stroke color", false, ((ColorDrawable) buttonStrokeColor.getBackground()).getColor(), buttonStrokeColor));
//Set dialog buttons behavior
alertBuilder.setPositiveButton(android.R.string.ok, (dialogInterface1, i) -> {
if(!hasPropertiesErrors(dialog.getContext())){
saveProperties();
}
});
alertBuilder.setNegativeButton(android.R.string.cancel, null);
//Create the finalized dialog
dialog = alertBuilder.create();
dialog.setOnShowListener(dialogInterface -> {
//setEditDialogValues();
});
(v.findViewById(R.id.editDynamicPositionX_textView)).setVisibility(View.GONE);
editDynamicX.setVisibility(View.GONE);
(v.findViewById(R.id.editDynamicPositionY_textView)).setVisibility(View.GONE);
editDynamicY.setVisibility(View.GONE);
}
private void setEditDialogValues(){
editName.setText(properties.name);
checkToggle.setChecked(properties.isToggle);
checkPassThrough.setChecked(properties.passThruEnabled);
seekBarOpacity.setProgress((int) (properties.opacity*100));
seekBarStrokeWidth.setProgress(properties.strokeWidth);
seekBarCornerRadius.setProgress((int)properties.cornerRadius);
buttonBackgroundColor.setBackgroundColor(properties.bgColor);
buttonStrokeColor.setBackgroundColor(properties.strokeColor);
setPercentageText(textCornerRadius,seekBarCornerRadius.getProgress());
setPercentageText(textOpacity,seekBarOpacity.getProgress());
setPercentageText(textStrokeWidth,seekBarStrokeWidth.getProgress());
checkHoldAlt.setChecked(properties.holdAlt);
checkHoldCtrl.setChecked(properties.holdCtrl);
checkHoldShift.setChecked(properties.holdShift);
for(int i=0; i< properties.keycodes.length; i++){
if (properties.keycodes[i] < 0) {
spinnersKeycode[i].setSelection(properties.keycodes[i] + specialArr.length);
} else {
spinnersKeycode[i].setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycodes[i]) + specialArr.length);
}
}
}
private boolean hasPropertiesErrors(Context ctx){
if (editName.getText().toString().isEmpty()) {
editName.setError(ctx.getResources().getString(R.string.global_error_field_empty));
return true;
}
return false;
}
private void saveProperties(){
//This method assumes there are no error.
properties.name = editName.getText().toString();
//Keycodes
for(int i=0; i<spinnersKeycode.length; ++i){
if (spinnersKeycode[i].getSelectedItemPosition() < specialArr.length) {
properties.keycodes[i] = spinnersKeycode[i].getSelectedItemPosition() - specialArr.length;
} else {
properties.keycodes[i] = AndroidLWJGLKeycode.getKeyByIndex(spinnersKeycode[i].getSelectedItemPosition() - specialArr.length);
}
}
properties.opacity = seekBarOpacity.getProgress()/100f;
properties.strokeWidth = seekBarStrokeWidth.getProgress();
properties.cornerRadius = seekBarCornerRadius.getProgress();
properties.bgColor = ((ColorDrawable) buttonBackgroundColor.getBackground()).getColor();
properties.strokeColor = ((ColorDrawable) buttonStrokeColor.getBackground()).getColor();
properties.isToggle = checkToggle.isChecked();
properties.passThruEnabled = checkPassThrough.isChecked();
properties.holdAlt = checkHoldAlt.isChecked();
properties.holdCtrl = checkHoldCtrl.isChecked();
properties.holdShift = checkHoldShift.isChecked();
button.updateProperties();
}
}

View File

@ -0,0 +1,434 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="500dp"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- EDIT NAME SECTION -->
<TextView
android:id="@+id/editName_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/global_name"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<EditText
android:id="@+id/editName_editText"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@+id/editName_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/editName_textView"
app:layout_constraintBottom_toBottomOf="@+id/editName_textView"
/>
<!-- SIZE SECTION -->
<TextView
android:id="@+id/editSize_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:gravity="center"
android:text="@string/customctrl_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editName_textView"
tools:visibility="visible" />
<EditText
android:id="@+id/editSize_editTextX"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/editSize_textView"
app:layout_constraintTop_toTopOf="@id/editSize_textView"
app:layout_constraintBottom_toBottomOf="@id/editSize_textView"
app:layout_constraintEnd_toStartOf="@id/editSize_editTextY"/>
<EditText
android:id="@+id/editSize_editTextY"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintTop_toTopOf="@id/editSize_textView"
app:layout_constraintBottom_toBottomOf="@id/editSize_textView"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="x"
android:gravity="center"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintEnd_toStartOf="@id/editSize_editTextY"
app:layout_constraintTop_toTopOf="@id/editSize_textView"
app:layout_constraintBottom_toBottomOf="@id/editSize_textView" />
<!-- MAPPING SECTION -->
<TextView
android:id="@+id/editMapping_textView"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="@string/customctrl_mapping"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editSize_textView"/>
<Spinner
android:id="@+id/editMapping_spinner_1"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintStart_toEndOf="@id/editMapping_textView"
app:layout_constraintTop_toTopOf="@id/editMapping_textView"
app:layout_constraintEnd_toStartOf="@id/editMapping_spinner_2"
app:layout_constraintBottom_toTopOf="@id/editMapping_spinner_3"/>
<Spinner
android:id="@+id/editMapping_spinner_2"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
app:layout_constraintStart_toEndOf="@id/editMapping_spinner_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editMapping_textView"
app:layout_constraintBottom_toTopOf="@id/editMapping_spinner_4"
/>
<Spinner
android:id="@+id/editMapping_spinner_3"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
app:layout_constraintStart_toEndOf="@id/editMapping_textView"
app:layout_constraintTop_toBottomOf="@id/editMapping_spinner_1"
app:layout_constraintBottom_toBottomOf="@id/editMapping_textView"
app:layout_constraintEnd_toStartOf="@id/editMapping_spinner_4"/>
<Spinner
android:id="@+id/editMapping_spinner_4"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
app:layout_constraintStart_toEndOf="@id/editMapping_spinner_3"
app:layout_constraintTop_toBottomOf="@id/editMapping_spinner_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/editMapping_textView"
/>
<!-- ORIENTATION SECTION -->
<TextView
android:id="@+id/editOrientation_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_orientation"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editMapping_textView"
/>
<Spinner
android:id="@+id/editOrientation_spinner"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/editOrientation_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editOrientation_textView"
app:layout_constraintBottom_toBottomOf="@id/editOrientation_textView"
/>
<!-- TOGGLE SECTION -->
<CheckBox
android:id="@+id/checkboxToggle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_toggle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editOrientation_textView"
/>
<CheckBox
android:id="@+id/checkboxPassThrough"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_passthru"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxToggle"
/>
<!-- BACKGROUND COLOR SECTION -->
<TextView
android:id="@+id/editBackgroundColor_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_background_color"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
/>
<ImageButton
android:id="@+id/editBackgroundColor_imageButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="5dp"
android:background="#FFFFFFFF"
app:layout_constraintStart_toEndOf="@id/editBackgroundColor_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editBackgroundColor_textView"
app:layout_constraintBottom_toBottomOf="@id/editBackgroundColor_textView"
/>
<!-- STROKE WIDTH -->
<TextView
android:id="@+id/editStrokeWidth_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_stroke_width"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editBackgroundColor_textView"/>
<SeekBar
android:id="@+id/editStrokeWidth_seekbar"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/editStrokeWidth_textView"
app:layout_constraintTop_toTopOf="@id/editStrokeWidth_textView"
app:layout_constraintBottom_toBottomOf="@id/editStrokeWidth_textView"
app:layout_constraintEnd_toStartOf="@id/editStrokeWidth_textView_percent"
/>
<TextView
android:id="@+id/editStrokeWidth_textView_percent"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="100%"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editStrokeWidth_textView"
app:layout_constraintBottom_toBottomOf="@id/editStrokeWidth_textView"
/>
<!-- STROKE COLOR VERSION -->
<TextView
android:id="@+id/editStrokeColor_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_stroke_color"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeWidth_textView"
/>
<ImageButton
android:id="@+id/editStrokeColor_imageButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="5dp"
android:background="#FFFFFFFF"
app:layout_constraintStart_toEndOf="@id/editStrokeColor_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editStrokeColor_textView"
app:layout_constraintBottom_toBottomOf="@id/editStrokeColor_textView"
/>
<!-- CORNER RADIUS SECTION -->
<TextView
android:id="@+id/editCornerRadius_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_corner_radius"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeColor_textView"/>
<SeekBar
android:id="@+id/editCornerRadius_seekbar"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/editCornerRadius_textView"
app:layout_constraintTop_toTopOf="@id/editCornerRadius_textView"
app:layout_constraintBottom_toBottomOf="@id/editCornerRadius_textView"
app:layout_constraintEnd_toStartOf="@id/editCornerRadius_textView_percent"
/>
<TextView
android:id="@+id/editCornerRadius_textView_percent"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="100%"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editCornerRadius_textView"
app:layout_constraintBottom_toBottomOf="@id/editCornerRadius_textView"
/>
<!-- BUTTON OPACITY SECTION -->
<TextView
android:id="@+id/editButtonOpacity_textView"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/customctrl_button_opacity"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editCornerRadius_textView"/>
<SeekBar
android:id="@+id/editButtonOpacity_seekbar"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/editButtonOpacity_textView"
app:layout_constraintTop_toTopOf="@id/editButtonOpacity_textView"
app:layout_constraintBottom_toBottomOf="@id/editButtonOpacity_textView"
app:layout_constraintEnd_toStartOf="@id/editButtonOpacity_textView_percent"
/>
<TextView
android:id="@+id/editButtonOpacity_textView_percent"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="100%"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editButtonOpacity_textView"
app:layout_constraintBottom_toBottomOf="@id/editButtonOpacity_textView"
/>
<!-- DYNAMIC BUTTON SECTION -->
<CheckBox
android:id="@+id/checkboxDynamicPosition"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_dynamicpos"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editButtonOpacity_textView"
/>
<TextView
android:id="@+id/editDynamicPositionX_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customctrl_dynamicpos_x"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxDynamicPosition"
/>
<EditText
android:id="@+id/editDynamicPositionX_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editDynamicPositionX_textView"
/>
<TextView
android:id="@+id/editDynamicPositionY_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customctrl_dynamicpos_y"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editDynamicPositionX_editText"
/>
<EditText
android:id="@+id/editDynamicPositionY_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editDynamicPositionY_textView"
/>
<!-- KEY COMBINATION SECTION -->
<TextView
android:id="@+id/editKeyCombination_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customctrl_keycombine"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editDynamicPositionY_editText"
/>
<CheckBox
android:id="@+id/checkBoxKeyCombination_alt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_keycombine_alt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editKeyCombination_textView" />
<CheckBox
android:id="@+id/checkBoxKeyCombination_ctrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_keycombine_control"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkBoxKeyCombination_alt"
/>
<CheckBox
android:id="@+id/checkBoxKeyCombination_shift"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_keycombine_shift"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkBoxKeyCombination_ctrl"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@ -1,262 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="500dp">
<!-- Yeah I know I'm using a lot of nested LinearLayouts -->
<!-- Should be around 2 layers deep max -->
<!-- However this allows a lot of flexibility to switch setting position for now -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- EDIT NAME SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Name:"
android:gravity="center"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_name"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Orientation:"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/controlsetting_orientation"/>
</LinearLayout>
<!-- SIZE SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/controlsetting_layout_size">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Size:"
android:gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="@+id/controlsetting_edit_width"
android:hint="@string/customctrl_size_width"
android:inputType="numberDecimal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="×"
android:gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:id="@+id/controlsetting_edit_height"
android:hint="@string/customctrl_size_height"
android:inputType="numberDecimal"/>
</LinearLayout>
<!-- BACKGROUND COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Background color:"
android:gravity="center"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:background="#FFFFFFFF"
android:id="@+id/controlsetting_background_color"/>
</LinearLayout>
<!-- STROKE WIDTH SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Stroke width:"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_stroke_width"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100"
android:id="@+id/controlsetting_text_stroke_width"/>
</LinearLayout>
<!-- STROKE COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Stroke color:" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFFFF"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:id="@+id/controlsetting_stroke_color" />
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Corner radius"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_corner_radius"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_corner_radius"/>
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Button opacity"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_opacity"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_opacity"/>
</LinearLayout>
<!-- DYNAMIC POSITION SECTION -->
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_dynamicpos"
android:id="@+id/controlsetting_checkbox_dynamicpos"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_dynamicpos_x"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_dynamicpos_x"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_dynamicpos_y"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_dynamicpos_y"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,341 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="500dp">
<!-- Yeah I know I'm using a lot of nested LinearLayouts -->
<!-- Should be around 2 layers deep max -->
<!-- However this allows a lot of flexibility to switch setting position for now -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- EDIT NAME SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Name:"
android:gravity="center"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_name"/>
</LinearLayout>
<!-- SIZE SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/controlsetting_layout_size">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Size:"
android:gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="@+id/controlsetting_edit_width"
android:hint="@string/customctrl_size_width"
android:inputType="numberDecimal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="×"
android:gravity="center"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:id="@+id/controlsetting_edit_height"
android:hint="@string/customctrl_size_height"
android:inputType="numberDecimal"/>
</LinearLayout>
<!-- MAPPING SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:orientation="horizontal"
android:id="@+id/controlsetting_layout_mapping">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Mapping:"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode4"/>
</LinearLayout>
<!-- TOGGLE SECTION -->
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_toggle"
android:id="@+id/controlsetting_checkbox_toggle"/>
<CheckBox
android:id="@+id/controlsetting_checkbox_passthru"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_passthru" />
<!-- BACKGROUND COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Background color:"
android:gravity="center"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:background="#FFFFFFFF"
android:id="@+id/controlsetting_background_color"/>
</LinearLayout>
<!-- STROKE WIDTH SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Stroke width:"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_stroke_width"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100"
android:id="@+id/controlsetting_text_stroke_width"/>
</LinearLayout>
<!-- STROKE COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Stroke color:" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFFFF"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:id="@+id/controlsetting_stroke_color" />
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Corner radius"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_corner_radius"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_corner_radius"/>
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Button opacity"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_opacity"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_opacity"/>
</LinearLayout>
<!-- DYNAMIC POSITION SECTION -->
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_dynamicpos"
android:id="@+id/controlsetting_checkbox_dynamicpos"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_dynamicpos_x"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_dynamicpos_x"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_dynamicpos_y"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_dynamicpos_y"/>
</LinearLayout>
<!-- KEY COMBINATION SECTION -->
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_keycombine"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_alt"
android:id="@+id/controlsetting_checkbox_keycombine_alt"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_control"
android:id="@+id/controlsetting_checkbox_keycombine_control"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_shift"
android:id="@+id/controlsetting_checkbox_keycombine_shift"/>
</LinearLayout>
</ScrollView>

View File

@ -1,267 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="500dp">
<!-- Yeah I know I'm using a lot of nested LinearLayouts -->
<!-- Should be around 2 layers deep max -->
<!-- However this allows a lot of flexibility to switch setting position for now -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- EDIT NAME SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Name:"
android:gravity="center"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:singleLine="true"
android:id="@+id/controlsetting_edit_name"/>
</LinearLayout>
<!-- MAPPING SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:orientation="horizontal"
android:id="@+id/controlsetting_layout_mapping">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Mapping:"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+"
android:gravity="center"/>
<Spinner
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:id="@+id/controlsetting_spinner_lwjglkeycode4"/>
</LinearLayout>
<!-- TOGGLE SECTION -->
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_toggle"
android:id="@+id/controlsetting_checkbox_toggle"/>
<CheckBox
android:id="@+id/controlsetting_checkbox_passthru"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_passthru" />
<!-- BACKGROUND COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Background color:"
android:gravity="center"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:background="#FFFFFFFF"
android:id="@+id/controlsetting_background_color"/>
</LinearLayout>
<!-- STROKE WIDTH SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Stroke width:"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_stroke_width"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100"
android:id="@+id/controlsetting_text_stroke_width"/>
</LinearLayout>
<!-- STROKE COLOR SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Stroke color:" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#FFFFFFFF"
android:layout_weight="1"
android:layout_marginHorizontal="50dp"
android:layout_marginVertical="2dp"
android:id="@+id/controlsetting_stroke_color" />
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Corner radius"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_corner_radius"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_corner_radius"/>
</LinearLayout>
<!-- CORNER RADIUS SECTION -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Button opacity"
android:gravity="center"/>
<SeekBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/controlsetting_seek_opacity"/>
<TextView
android:layout_width="40dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="100 %"
android:id="@+id/controlsetting_text_opacity"/>
</LinearLayout>
<!-- KEY COMBINATION SECTION -->
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/customctrl_keycombine"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_alt"
android:id="@+id/controlsetting_checkbox_keycombine_alt"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_control"
android:id="@+id/controlsetting_checkbox_keycombine_control"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/customctrl_keycombine_shift"
android:id="@+id/controlsetting_checkbox_keycombine_shift"/>
</LinearLayout>
</ScrollView>

View File

@ -170,12 +170,20 @@
<string name="customctrl_size">Size</string>
<string name="customctrl_size_width">Width</string>
<string name="customctrl_size_height">Height</string>
<string name="customctrl_mapping">Mapping</string>
<string name="customctrl_orientation">Orientation</string>
<string name="customctrl_background_color">Background color</string>
<string name="customctrl_corner_radius">Corner radius</string>
<string name="customctrl_stroke_width">Stroke width</string>
<string name="customctrl_stroke_color">Stroke color</string>
<string name="customctrl_dynamicpos">Dynamic position</string>
<string name="customctrl_dynamicpos_x">Dynamic X</string>
<string name="customctrl_dynamicpos_y">Dynamic Y</string>
<string name="customctrl_transparency_bg">Background transparency</string>
<string name="customctrl_button_opacity">Background Opacity</string>
<string name="customctrl_keycombine">Key combination</string>
<string name="customctrl_keycombine_alt">Alt</string>