mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-22 10:37:16 -04:00
[Custom controls] Changes
- Fixes color in popup window. - Catch error when could not calculate dynamic position.
This commit is contained in:
@@ -31,6 +31,7 @@ import android.view.View.OnClickListener;
|
||||
import net.kdt.pojavlaunch.customcontrols.*;
|
||||
import android.support.v7.app.*;
|
||||
import android.content.res.*;
|
||||
import net.objecthunter.exp4j.*;
|
||||
|
||||
public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListener {
|
||||
private TextView mEditTextView;
|
||||
@@ -51,7 +52,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
LinearLayout linearLayout = new LinearLayout(mHandleView.getContext());
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
mContentView = linearLayout;
|
||||
mContentView.setBackgroundResource(Resources.getSystem().getIdentifier("text_edit_paste_window", "drawable", "com.android.internal"));
|
||||
mContentView.setBackgroundResource(R.drawable.control_side_action_window);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) mHandleView.getContext().
|
||||
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@@ -114,7 +115,7 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
if (properties.keycode < 0) {
|
||||
spinnerKeycode.setSelection(properties.keycode + specialArr.length);
|
||||
} else {
|
||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode));
|
||||
spinnerKeycode.setSelection(AndroidLWJGLKeycode.getIndexByLWJGLKey(properties.keycode) + specialArr.length);
|
||||
}
|
||||
spinnerKeycode.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
|
||||
|
||||
@@ -162,6 +163,34 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
if (editName.getText().toString().isEmpty()) {
|
||||
editName.setError(view.getResources().getString(R.string.global_error_field_empty));
|
||||
} else {
|
||||
/*
|
||||
String errorAt = null;
|
||||
try {
|
||||
errorAt = "DynamicX";
|
||||
properties.insertDynamicPos(editDynamicX.getText().toString());
|
||||
errorAt = "DynamicY";
|
||||
properties.insertDynamicPos(editDynamicY.getText().toString());
|
||||
} catch (Throwable th) {
|
||||
Error e = new Error(errorAt, th);
|
||||
e.setStackTrace(null);
|
||||
Tools.showError(view.getContext(), e);
|
||||
return;
|
||||
}
|
||||
errorAt = null;
|
||||
*/
|
||||
|
||||
int errorAt = 0;
|
||||
try {
|
||||
properties.insertDynamicPos(editDynamicX.getText().toString());
|
||||
errorAt = 1;
|
||||
properties.insertDynamicPos(editDynamicY.getText().toString());
|
||||
} catch (Throwable th) {
|
||||
(errorAt == 0 ? editDynamicX : editDynamicY)
|
||||
.setError(th.getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (spinnerKeycode.getSelectedItemPosition() < specialArr.length) {
|
||||
properties.keycode = spinnerKeycode.getSelectedItemPosition() - specialArr.length;
|
||||
} else {
|
||||
@@ -170,8 +199,6 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
||||
properties.name = editName.getText().toString();
|
||||
properties.hidden = checkHidden.isChecked();
|
||||
properties.isDynamicBtn = checkDynamicPos.isChecked();
|
||||
properties.dynamicX = editDynamicX.getText().toString();
|
||||
properties.dynamicY = editDynamicY.getText().toString();
|
||||
|
||||
if (properties.dynamicX.isEmpty()) {
|
||||
properties.dynamicX = Float.toString(properties.x);
|
||||
|
||||
@@ -73,25 +73,6 @@ public abstract class HandleView extends View implements ViewPositionListener, V
|
||||
return mPositionListener;
|
||||
}
|
||||
|
||||
private int getInternalId(String type, String name) {
|
||||
try {
|
||||
for (Class perType : Class.forName("com.android.internal.R").getDeclaredClasses()) {
|
||||
if (perType.getSimpleName().equals(type)) {
|
||||
try {
|
||||
Field f = perType.getDeclaredField(name);
|
||||
f.setAccessible(true);
|
||||
return (int) f.get(null);
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public HandleView(ControlButton view) {
|
||||
super(view.getContext());
|
||||
|
||||
@@ -100,7 +81,7 @@ public abstract class HandleView extends View implements ViewPositionListener, V
|
||||
mDownWidth = view.getLayoutParams().width;
|
||||
mDownHeight = view.getLayoutParams().height;
|
||||
|
||||
mContainer = new PopupWindow(view.getContext(), null, getInternalId("attr", "textSelectHandleWindowStyle"));
|
||||
mContainer = new PopupWindow(view.getContext(), null, android.R.attr.textSelectHandleWindowStyle);
|
||||
mContainer.setSplitTouchEnabled(true);
|
||||
mContainer.setClippingEnabled(false);
|
||||
mContainer.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL);
|
||||
@@ -108,7 +89,7 @@ public abstract class HandleView extends View implements ViewPositionListener, V
|
||||
|
||||
mDrawableLtr = view.getContext().getDrawable(R.drawable.text_select_handle_left_material);
|
||||
mDrawableRtl = view.getContext().getDrawable(R.drawable.text_select_handle_right_material);
|
||||
mMinSize = view.getContext().getResources().getDimensionPixelSize(getInternalId("dimen", "text_handle_min_size"));
|
||||
mMinSize = view.getContext().getResources().getDimensionPixelSize(R.dimen.text_handle_min_size);
|
||||
|
||||
setOnLongClickListener(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user