From 55c0d19c49ef75d339b87f20d2fcc7391d69b588 Mon Sep 17 00:00:00 2001 From: SerpentSpirale Date: Mon, 3 May 2021 15:37:03 +0200 Subject: [PATCH] Rewrote EditControl popups to be easily extended. --- .../handleview/EditControlButtonPopup.java | 146 +++--- .../handleview/EditControlDrawerPopup.java | 229 ++------- .../handleview/EditControlSubButtonPopup.java | 239 +--------- .../res/layout/control_button_setting.xml | 434 ++++++++++++++++++ .../res/layout/control_drawer_setting.xml | 262 ----------- .../main/res/layout/control_setting_v2.xml | 341 -------------- .../main/res/layout/control_sub_button.xml | 267 ----------- .../src/main/res/values/strings.xml | 8 + 8 files changed, 559 insertions(+), 1367 deletions(-) create mode 100644 app_pojavlauncher/src/main/res/layout/control_button_setting.xml delete mode 100644 app_pojavlauncher/src/main/res/layout/control_drawer_setting.xml delete mode 100644 app_pojavlauncher/src/main/res/layout/control_setting_v2.xml delete mode 100644 app_pojavlauncher/src/main/res/layout/control_sub_button.xml diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlButtonPopup.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlButtonPopup.java index e98a6a2bd..683e0daf6 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlButtonPopup.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlButtonPopup.java @@ -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 adapter; - private String[] specialArr; + protected ArrayAdapter 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(); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlDrawerPopup.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlDrawerPopup.java index 272d62692..638e00197 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlDrawerPopup.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlDrawerPopup.java @@ -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 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(); + } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlSubButtonPopup.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlSubButtonPopup.java index 2bc0ae966..4e0022e03 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlSubButtonPopup.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlSubButtonPopup.java @@ -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 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/layout/control_drawer_setting.xml b/app_pojavlauncher/src/main/res/layout/control_drawer_setting.xml deleted file mode 100644 index 80981f709..000000000 --- a/app_pojavlauncher/src/main/res/layout/control_drawer_setting.xml +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/layout/control_setting_v2.xml b/app_pojavlauncher/src/main/res/layout/control_setting_v2.xml deleted file mode 100644 index 8f5a72af0..000000000 --- a/app_pojavlauncher/src/main/res/layout/control_setting_v2.xml +++ /dev/null @@ -1,341 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/layout/control_sub_button.xml b/app_pojavlauncher/src/main/res/layout/control_sub_button.xml deleted file mode 100644 index 0a75b9829..000000000 --- a/app_pojavlauncher/src/main/res/layout/control_sub_button.xml +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml index db2b039af..c8c352a30 100644 --- a/app_pojavlauncher/src/main/res/values/strings.xml +++ b/app_pojavlauncher/src/main/res/values/strings.xml @@ -170,12 +170,20 @@ Size Width Height + + Mapping + Orientation + Background color + Corner radius + Stroke width + Stroke color Dynamic position Dynamic X Dynamic Y Background transparency + Background Opacity Key combination Alt