diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlData.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlData.java index f9c69783b..47f4146f3 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlData.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlData.java @@ -32,7 +32,7 @@ public class ControlData { public static final int SPECIALBTN_MENU = -9; private static ControlData[] SPECIAL_BUTTONS; - private static String[] SPECIAL_BUTTON_NAME_ARRAY; + private static List SPECIAL_BUTTON_NAME_ARRAY; // Internal usage only public boolean isHideable; @@ -74,13 +74,14 @@ public class ControlData { return SPECIAL_BUTTONS; } - public static String[] buildSpecialButtonArray() { + public static List buildSpecialButtonArray() { if (SPECIAL_BUTTON_NAME_ARRAY == null) { List nameList = new ArrayList(); for (ControlData btn : getSpecialButtons()) { - nameList.add(btn.name); + nameList.add("SPECIAL_" + btn.name); } - SPECIAL_BUTTON_NAME_ARRAY = nameList.toArray(new String[0]); + SPECIAL_BUTTON_NAME_ARRAY = nameList; + Collections.reverse(SPECIAL_BUTTON_NAME_ARRAY); } return SPECIAL_BUTTON_NAME_ARRAY; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java index ca08e63e8..23217dbb9 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/handleview/EditControlPopup.java @@ -42,6 +42,7 @@ import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface; import java.util.Arrays; import java.util.Collections; +import java.util.List; /** * Class providing a sort of popup on top of a Layout, allowing to edit a given ControlButton @@ -87,7 +88,7 @@ public class EditControlPopup { protected TextView mStrokePercentTextView, mCornerRadiusPercentTextView, mAlphaPercentTextView; protected TextView mSelectBackgroundColor, mSelectStrokeColor; protected ArrayAdapter mAdapter; - protected String[] mSpecialArray; + protected List mSpecialArray; // Decorative textviews private TextView mOrientationTextView, mMappingTextView, mNameTextView, mCornerRadiusTextView; @@ -215,10 +216,7 @@ public class EditControlPopup { //Initialize adapter for keycodes mAdapter = new ArrayAdapter<>(mRootView.getContext(), R.layout.item_centered_textview); mSpecialArray = ControlData.buildSpecialButtonArray(); - for (int i = 0; i < mSpecialArray.length; i++) { - mSpecialArray[i] = "SPECIAL_" + mSpecialArray[i]; - } - Collections.reverse(Arrays.asList(mSpecialArray)); + mAdapter.addAll(mSpecialArray); mAdapter.addAll(EfficientAndroidLWJGLKeycode.generateKeyName()); mAdapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); @@ -278,9 +276,9 @@ public class EditControlPopup { for(int i = 0; i< data.keycodes.length; i++){ if (data.keycodes[i] < 0) { - mKeycodeSpinners[i].setSelection(data.keycodes[i] + mSpecialArray.length); + mKeycodeSpinners[i].setSelection(data.keycodes[i] + mSpecialArray.size()); } else { - mKeycodeSpinners[i].setSelection(EfficientAndroidLWJGLKeycode.getIndexByValue(data.keycodes[i]) + mSpecialArray.length); + mKeycodeSpinners[i].setSelection(EfficientAndroidLWJGLKeycode.getIndexByValue(data.keycodes[i]) + mSpecialArray.size()); } } } @@ -482,10 +480,10 @@ public class EditControlPopup { public void onItemSelected(AdapterView parent, View view, int position, long id) { // Side note, spinner listeners are fired later than all the other ones. // Meaning the internalChanges bool is useless here. - if (position < mSpecialArray.length) { - mCurrentlyEditedButton.getProperties().keycodes[finalI] = mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.length; + if (position < mSpecialArray.size()) { + mCurrentlyEditedButton.getProperties().keycodes[finalI] = mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size(); } else { - mCurrentlyEditedButton.getProperties().keycodes[finalI] = EfficientAndroidLWJGLKeycode.getValueByIndex(mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.length); + mCurrentlyEditedButton.getProperties().keycodes[finalI] = EfficientAndroidLWJGLKeycode.getValueByIndex(mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size()); } }