mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 00:59:35 -04:00
Changes for Serpent
Added access modifiers (why :despair:) Moved the cast Added error reporting if the tex in the HEX edit box is not a valid HEX value (by making the text red)
This commit is contained in:
parent
cfae15c680
commit
d78b396ea7
@ -18,15 +18,15 @@ import net.kdt.pojavlaunch.Tools;
|
||||
import top.defaults.checkerboarddrawable.CheckerboardDrawable;
|
||||
|
||||
public class AlphaView extends View {
|
||||
Drawable mCheckerboardDrawable = CheckerboardDrawable.create();
|
||||
Paint mShaderPaint = new Paint();
|
||||
Paint mBlackPaint;
|
||||
RectF mViewSize = new RectF(0,0,0,0);
|
||||
AlphaSelectionListener mAlphaSelectionListener;
|
||||
int mSelectedAlpha;
|
||||
float mAlphaDiv; // for quick pos->alpha multiplication
|
||||
float mScreenDiv; // for quick alpha->pos multiplication
|
||||
float mHeightThird; // 1/3 of the view size for cursor
|
||||
private final Drawable mCheckerboardDrawable = CheckerboardDrawable.create();
|
||||
private final Paint mShaderPaint = new Paint();
|
||||
private final Paint mBlackPaint;
|
||||
private final RectF mViewSize = new RectF(0,0,0,0);
|
||||
private AlphaSelectionListener mAlphaSelectionListener;
|
||||
private int mSelectedAlpha;
|
||||
private float mAlphaDiv; // for quick pos->alpha multiplication
|
||||
private float mScreenDiv; // for quick alpha->pos multiplication
|
||||
private float mHeightThird; // 1/3 of the view size for cursor
|
||||
public AlphaView(Context ctx, AttributeSet attrs) {
|
||||
super(ctx,attrs);
|
||||
mBlackPaint = new Paint();
|
||||
|
@ -2,6 +2,7 @@ package net.kdt.pojavlaunch.colorselector;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@ -12,18 +13,20 @@ import android.widget.EditText;
|
||||
import net.kdt.pojavlaunch.R;
|
||||
|
||||
public class ColorSelector implements HueSelectionListener, RectangleSelectionListener, AlphaSelectionListener, TextWatcher{
|
||||
static final int ALPHA_MASK = ~(0xFF << 24);
|
||||
HueView mHueView;
|
||||
SVRectangleView mLuminosityIntensityView;
|
||||
AlphaView mAlphaView;
|
||||
ColorSideBySideView mColorView;
|
||||
EditText mTextView;
|
||||
ColorSelectionListener mColorSelectionListener;
|
||||
float[] mHueTemplate = new float[] {0,1,1};
|
||||
float[] mHsvSelected = new float[] {360,1,1};
|
||||
int mAlphaSelected = 0xff;
|
||||
boolean mWatch = true;
|
||||
AlertDialog mDialog;
|
||||
private static final int ALPHA_MASK = ~(0xFF << 24);
|
||||
private final HueView mHueView;
|
||||
private final SVRectangleView mLuminosityIntensityView;
|
||||
private final AlphaView mAlphaView;
|
||||
private final ColorSideBySideView mColorView;
|
||||
private final EditText mTextView;
|
||||
private final AlertDialog mDialog;
|
||||
private ColorSelectionListener mColorSelectionListener;
|
||||
private float[] mHueTemplate = new float[] {0,1,1};
|
||||
private float[] mHsvSelected = new float[] {360,1,1};
|
||||
private int mAlphaSelected = 0xff;
|
||||
private ColorStateList mTextColors;
|
||||
private boolean mWatch = true;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a color selector dialog for this Context.
|
||||
@ -43,6 +46,7 @@ public class ColorSelector implements HueSelectionListener, RectangleSelectionLi
|
||||
mLuminosityIntensityView.setRectSelectionListener(this);
|
||||
mAlphaView.setAlphaSelectionListener(this);
|
||||
mTextView.addTextChangedListener(this);
|
||||
mTextColors = mTextView.getTextColors();
|
||||
builder.setView(view);
|
||||
builder.setPositiveButton(android.R.string.ok,(dialog,which)->{
|
||||
if (mColorSelectionListener != null) {
|
||||
@ -134,8 +138,10 @@ public class ColorSelector implements HueSelectionListener, RectangleSelectionLi
|
||||
if(mWatch) {
|
||||
try {
|
||||
int color = Integer.parseInt(s.toString(), 16);
|
||||
mTextView.setTextColor(mTextColors);
|
||||
runColor(color);
|
||||
}catch (NumberFormatException ignored) {
|
||||
}catch (NumberFormatException exception) {
|
||||
mTextView.setTextColor(Color.RED);
|
||||
}
|
||||
}else{
|
||||
mWatch = true;
|
||||
|
@ -11,13 +11,13 @@ import androidx.annotation.Nullable;
|
||||
import top.defaults.checkerboarddrawable.CheckerboardDrawable;
|
||||
|
||||
public class ColorSideBySideView extends View {
|
||||
Paint mPaint;
|
||||
CheckerboardDrawable mCheckerboardDrawable = CheckerboardDrawable.create();
|
||||
int mColor;
|
||||
int mAlphaColor;
|
||||
float mWidth;
|
||||
float mHeight;
|
||||
float mHalfHeight;
|
||||
private final Paint mPaint;
|
||||
private final CheckerboardDrawable mCheckerboardDrawable = CheckerboardDrawable.create();
|
||||
private int mColor;
|
||||
private int mAlphaColor;
|
||||
private float mWidth;
|
||||
private float mHeight;
|
||||
private float mHalfHeight;
|
||||
public ColorSideBySideView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mPaint = new Paint();
|
||||
|
@ -17,15 +17,15 @@ import net.kdt.pojavlaunch.Tools;
|
||||
|
||||
|
||||
public class HueView extends View {
|
||||
Bitmap mGamma;
|
||||
Paint blackPaint = new Paint();
|
||||
float mSelectionHue;
|
||||
float mWidthHueRatio;
|
||||
float mHueWidthRatio;
|
||||
float mWidth;
|
||||
float mHeight;
|
||||
float mHeightThird;
|
||||
HueSelectionListener mHueSelectionListener;
|
||||
private final Paint blackPaint = new Paint();
|
||||
private Bitmap mGamma;
|
||||
private HueSelectionListener mHueSelectionListener;
|
||||
private float mSelectionHue;
|
||||
private float mWidthHueRatio;
|
||||
private float mHueWidthRatio;
|
||||
private float mWidth;
|
||||
private float mHeight;
|
||||
private float mHeightThird;
|
||||
public HueView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
blackPaint.setColor(Color.BLACK);
|
||||
|
@ -18,15 +18,15 @@ import androidx.annotation.Nullable;
|
||||
import net.kdt.pojavlaunch.Tools;
|
||||
|
||||
public class SVRectangleView extends View {
|
||||
Bitmap mSvRectangle;
|
||||
Paint mColorPaint = new Paint();
|
||||
Paint mPointerPaint = new Paint();
|
||||
RectF mViewSize;
|
||||
float mHeightInverted;
|
||||
float mWidthInverted;
|
||||
float mPointerSize;
|
||||
float mFingerPosX;
|
||||
float mFingerPosY;
|
||||
private final Paint mColorPaint = new Paint();
|
||||
private final Paint mPointerPaint = new Paint();
|
||||
private final float mPointerSize;
|
||||
private Bitmap mSvRectangle;
|
||||
private RectF mViewSize;
|
||||
private float mHeightInverted;
|
||||
private float mWidthInverted;
|
||||
private float mFingerPosX;
|
||||
private float mFingerPosY;
|
||||
RectangleSelectionListener mRectSelectionListener;
|
||||
public SVRectangleView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
@ -176,8 +176,8 @@ public class EditControlButtonPopup {
|
||||
mColorSelector = new ColorSelector(ctx,color -> mEditingView.setImageDrawable(new ColorDrawable(color)));
|
||||
|
||||
//Set color imageButton behavior
|
||||
mBackgroundColorButton.setOnClickListener(this::colorButtonHandler);
|
||||
mStrokeColorButton.setOnClickListener(this::colorButtonHandler);
|
||||
mBackgroundColorButton.setOnClickListener(view -> showColorEditor((ImageView) view));
|
||||
mStrokeColorButton.setOnClickListener(view -> showColorEditor((ImageView) view));
|
||||
|
||||
|
||||
//Set dialog buttons behavior
|
||||
@ -190,8 +190,7 @@ public class EditControlButtonPopup {
|
||||
setupCheckerboards();
|
||||
}
|
||||
|
||||
protected void colorButtonHandler(View view) {
|
||||
ImageView imgView = (ImageView) view;
|
||||
protected void showColorEditor(ImageView imgView) {
|
||||
mEditingView = imgView;
|
||||
mColorSelector.show(((ColorDrawable)(imgView.getDrawable())).getColor());
|
||||
}
|
||||
|
@ -46,12 +46,12 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:hint="@string/color_default_hex"
|
||||
android:inputType="number"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="text"
|
||||
android:minHeight="48dp"
|
||||
android:typeface="monospace"
|
||||
app:layout_constraintBottom_toTopOf="@+id/color_selector_hue_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:importantForAutofill="no"/>
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<net.kdt.pojavlaunch.colorselector.ColorSideBySideView
|
||||
android:id="@+id/color_selector_color_view"
|
||||
|
Loading…
x
Reference in New Issue
Block a user