forked from REAndroid/APKEditor
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to change background and text colors Target SDK 35 Improve logging Fix some issues with storage permission Allow sharing multiple split APKs to be antisplit Allow sharing splits (base.apk, config.arm64_v8a, config.mdpi, etc.) to be antisplit Improve dialog for selection of splits Add option to dialog for selection of splits to select the splits fitting the current device's specifications
- Loading branch information
1 parent
b822f5b
commit 06bff8e
Showing
35 changed files
with
1,084 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
450 changes: 301 additions & 149 deletions
450
app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
355 changes: 148 additions & 207 deletions
355
app/src/main/java/com/reandroid/apkeditor/merge/Merger.java
Large diffs are not rendered by default.
Oops, something went wrong.
278 changes: 278 additions & 0 deletions
278
app/src/main/java/yuku/ambilwarna/AmbilWarnaDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
package yuku.ambilwarna; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.AlertDialog; | ||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.GradientDrawable; | ||
import android.view.LayoutInflater; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.ViewTreeObserver; | ||
import android.widget.ImageView; | ||
import android.widget.RelativeLayout; | ||
|
||
import com.abdurazaaqmohammed.AntiSplit.R; | ||
|
||
public class AmbilWarnaDialog { | ||
public interface OnAmbilWarnaListener { | ||
void onCancel(AmbilWarnaDialog dialog); | ||
|
||
void onOk(AmbilWarnaDialog dialog, int color); | ||
} | ||
|
||
final AlertDialog dialog; | ||
private final boolean supportsAlpha; | ||
final OnAmbilWarnaListener listener; | ||
final View viewHue; | ||
final AmbilWarnaSquare viewSatVal; | ||
final ImageView viewCursor; | ||
final ImageView viewAlphaCursor; | ||
final View viewOldColor; | ||
final View viewNewColor; | ||
final View viewAlphaOverlay; | ||
final ImageView viewTarget; | ||
final ImageView viewAlphaCheckered; | ||
final ViewGroup viewContainer; | ||
final float[] currentColorHsv = new float[3]; | ||
int alpha; | ||
|
||
/** | ||
* Create an AmbilWarnaDialog. | ||
* | ||
* @param context activity context | ||
* @param color current color | ||
* @param listener an OnAmbilWarnaListener, allowing you to get back error or OK | ||
*/ | ||
public AmbilWarnaDialog(final Context context, int color, OnAmbilWarnaListener listener) { | ||
this(context, color, false, listener); | ||
} | ||
|
||
/** | ||
* Create an AmbilWarnaDialog. | ||
* | ||
* @param context activity context | ||
* @param color current color | ||
* @param supportsAlpha whether alpha/transparency controls are enabled | ||
* @param listener an OnAmbilWarnaListener, allowing you to get back error or OK | ||
*/ | ||
@SuppressLint("ClickableViewAccessibility") | ||
public AmbilWarnaDialog(final Context context, int color, boolean supportsAlpha, OnAmbilWarnaListener listener) { | ||
this.supportsAlpha = supportsAlpha; | ||
this.listener = listener; | ||
|
||
if (!supportsAlpha) { // remove alpha if not supported | ||
color = color | 0xff000000; | ||
} | ||
|
||
Color.colorToHSV(color, currentColorHsv); | ||
alpha = Color.alpha(color); | ||
|
||
final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null); | ||
viewHue = view.findViewById(R.id.ambilwarna_viewHue); | ||
viewSatVal = view.findViewById(R.id.ambilwarna_viewSatBri); | ||
viewCursor = view.findViewById(R.id.ambilwarna_cursor); | ||
viewOldColor = view.findViewById(R.id.ambilwarna_oldColor); | ||
viewNewColor = view.findViewById(R.id.ambilwarna_newColor); | ||
viewTarget = view.findViewById(R.id.ambilwarna_target); | ||
viewContainer = view.findViewById(R.id.ambilwarna_viewContainer); | ||
viewAlphaOverlay = view.findViewById(R.id.ambilwarna_overlay); | ||
viewAlphaCursor = view.findViewById(R.id.ambilwarna_alphaCursor); | ||
viewAlphaCheckered = view.findViewById(R.id.ambilwarna_alphaCheckered); | ||
|
||
{ // hide/show alpha | ||
viewAlphaOverlay.setVisibility(supportsAlpha? View.VISIBLE: View.GONE); | ||
viewAlphaCursor.setVisibility(supportsAlpha? View.VISIBLE: View.GONE); | ||
viewAlphaCheckered.setVisibility(supportsAlpha? View.VISIBLE: View.GONE); | ||
} | ||
|
||
viewSatVal.setHue(getHue()); | ||
viewOldColor.setBackgroundColor(color); | ||
viewNewColor.setBackgroundColor(color); | ||
|
||
viewHue.setOnTouchListener((v, event) -> { | ||
if (event.getAction() == MotionEvent.ACTION_MOVE | ||
|| event.getAction() == MotionEvent.ACTION_DOWN | ||
|| event.getAction() == MotionEvent.ACTION_UP) { | ||
|
||
float y = event.getY(); | ||
if (y < 0.f) y = 0.f; | ||
if (y > viewHue.getMeasuredHeight()) { | ||
y = viewHue.getMeasuredHeight() - 0.001f; // to avoid jumping the cursor from bottom to top. | ||
} | ||
float hue = 360.f - 360.f / viewHue.getMeasuredHeight() * y; | ||
if (hue == 360.f) hue = 0.f; | ||
setHue(hue); | ||
|
||
// update view | ||
viewSatVal.setHue(getHue()); | ||
moveCursor(); | ||
viewNewColor.setBackgroundColor(getColor()); | ||
updateAlphaView(); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
|
||
if (supportsAlpha) viewAlphaCheckered.setOnTouchListener((v, event) -> { | ||
if ((event.getAction() == MotionEvent.ACTION_MOVE) | ||
|| (event.getAction() == MotionEvent.ACTION_DOWN) | ||
|| (event.getAction() == MotionEvent.ACTION_UP)) { | ||
|
||
float y = event.getY(); | ||
if (y < 0.f) { | ||
y = 0.f; | ||
} | ||
if (y > viewAlphaCheckered.getMeasuredHeight()) { | ||
y = viewAlphaCheckered.getMeasuredHeight() - 0.001f; // to avoid jumping the cursor from bottom to top. | ||
} | ||
final int a = Math.round(255.f - ((255.f / viewAlphaCheckered.getMeasuredHeight()) * y)); | ||
AmbilWarnaDialog.this.setAlpha(a); | ||
|
||
// update view | ||
moveAlphaCursor(); | ||
int col = AmbilWarnaDialog.this.getColor(); | ||
int c = a << 24 | col & 0x00ffffff; | ||
viewNewColor.setBackgroundColor(c); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
viewSatVal.setOnTouchListener((v, event) -> { | ||
if (event.getAction() == MotionEvent.ACTION_MOVE | ||
|| event.getAction() == MotionEvent.ACTION_DOWN | ||
|| event.getAction() == MotionEvent.ACTION_UP) { | ||
|
||
float x = event.getX(); // touch event are in dp units. | ||
float y = event.getY(); | ||
|
||
if (x < 0.f) x = 0.f; | ||
if (x > viewSatVal.getMeasuredWidth()) x = viewSatVal.getMeasuredWidth(); | ||
if (y < 0.f) y = 0.f; | ||
if (y > viewSatVal.getMeasuredHeight()) y = viewSatVal.getMeasuredHeight(); | ||
|
||
setSat(1.f / viewSatVal.getMeasuredWidth() * x); | ||
setVal(1.f - (1.f / viewSatVal.getMeasuredHeight() * y)); | ||
|
||
// update view | ||
moveTarget(); | ||
viewNewColor.setBackgroundColor(getColor()); | ||
|
||
return true; | ||
} | ||
return false; | ||
}); | ||
|
||
// if back button is used, call back our listener. | ||
dialog = new AlertDialog.Builder(context, AlertDialog.THEME_DEVICE_DEFAULT_DARK) | ||
.setPositiveButton(android.R.string.ok, (dialog, which) -> { | ||
if (AmbilWarnaDialog.this.listener != null) { | ||
AmbilWarnaDialog.this.listener.onOk(AmbilWarnaDialog.this, getColor()); | ||
} | ||
}) | ||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> { | ||
if (AmbilWarnaDialog.this.listener != null) { | ||
AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); | ||
} | ||
}) | ||
.setOnCancelListener(paramDialogInterface -> { | ||
if (AmbilWarnaDialog.this.listener != null) { | ||
AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); | ||
} | ||
|
||
}) | ||
.create(); | ||
// kill all padding from the dialog window | ||
dialog.setView(view, 0, 0, 0, 0); | ||
|
||
// move cursor & target on first draw | ||
ViewTreeObserver vto = view.getViewTreeObserver(); | ||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | ||
@Override | ||
public void onGlobalLayout() { | ||
moveCursor(); | ||
if (AmbilWarnaDialog.this.supportsAlpha) moveAlphaCursor(); | ||
moveTarget(); | ||
if (AmbilWarnaDialog.this.supportsAlpha) updateAlphaView(); | ||
view.getViewTreeObserver().removeGlobalOnLayoutListener(this); | ||
} | ||
}); | ||
} | ||
|
||
protected void moveCursor() { | ||
float y = viewHue.getMeasuredHeight() - (getHue() * viewHue.getMeasuredHeight() / 360.f); | ||
if (y == viewHue.getMeasuredHeight()) y = 0.f; | ||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewCursor.getLayoutParams(); | ||
layoutParams.leftMargin = (int) (viewHue.getLeft() - (double) (viewCursor.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft()); | ||
layoutParams.topMargin = (int) (viewHue.getTop() + y - (double) (viewCursor.getMeasuredHeight() / 2) - viewContainer.getPaddingTop()); | ||
viewCursor.setLayoutParams(layoutParams); | ||
} | ||
|
||
protected void moveTarget() { | ||
float x = getSat() * viewSatVal.getMeasuredWidth(); | ||
float y = (1.f - getVal()) * viewSatVal.getMeasuredHeight(); | ||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewTarget.getLayoutParams(); | ||
layoutParams.leftMargin = (int) (viewSatVal.getLeft() + x - (double) (viewTarget.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft()); | ||
layoutParams.topMargin = (int) (viewSatVal.getTop() + y - (double) (viewTarget.getMeasuredHeight() / 2) - viewContainer.getPaddingTop()); | ||
viewTarget.setLayoutParams(layoutParams); | ||
} | ||
|
||
protected void moveAlphaCursor() { | ||
final int measuredHeight = this.viewAlphaCheckered.getMeasuredHeight(); | ||
float y = measuredHeight - ((this.getAlpha() * measuredHeight) / 255.f); | ||
final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.viewAlphaCursor.getLayoutParams(); | ||
layoutParams.leftMargin = (int) (this.viewAlphaCheckered.getLeft() - (double) (this.viewAlphaCursor.getMeasuredWidth() / 2) - this.viewContainer.getPaddingLeft()); | ||
layoutParams.topMargin = (int) ((this.viewAlphaCheckered.getTop() + y) - (double) (this.viewAlphaCursor.getMeasuredHeight() / 2) - this.viewContainer.getPaddingTop()); | ||
|
||
this.viewAlphaCursor.setLayoutParams(layoutParams); | ||
} | ||
|
||
private int getColor() { | ||
final int argb = Color.HSVToColor(currentColorHsv); | ||
return alpha << 24 | (argb & 0x00ffffff); | ||
} | ||
|
||
private float getHue() { | ||
return currentColorHsv[0]; | ||
} | ||
|
||
private float getAlpha() { | ||
return this.alpha; | ||
} | ||
|
||
private float getSat() { | ||
return currentColorHsv[1]; | ||
} | ||
|
||
private float getVal() { | ||
return currentColorHsv[2]; | ||
} | ||
|
||
private void setHue(float hue) { | ||
currentColorHsv[0] = hue; | ||
} | ||
|
||
private void setSat(float sat) { | ||
currentColorHsv[1] = sat; | ||
} | ||
|
||
private void setAlpha(int alpha) { | ||
this.alpha = alpha; | ||
} | ||
|
||
private void setVal(float val) { | ||
currentColorHsv[2] = val; | ||
} | ||
|
||
public void show() { | ||
dialog.show(); | ||
} | ||
|
||
private void updateAlphaView() { | ||
final GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { | ||
Color.HSVToColor(currentColorHsv), 0x0 | ||
}); | ||
viewAlphaOverlay.setBackgroundDrawable(gd); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package yuku.ambilwarna; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.ComposeShader; | ||
import android.graphics.LinearGradient; | ||
import android.graphics.Paint; | ||
import android.graphics.PorterDuff; | ||
import android.graphics.Shader; | ||
import android.graphics.Shader.TileMode; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
public class AmbilWarnaSquare extends View { | ||
Paint paint; | ||
Shader luar; | ||
final float[] color = { 1.f, 1.f, 1.f }; | ||
|
||
public AmbilWarnaSquare(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public AmbilWarnaSquare(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
} | ||
|
||
@SuppressLint("DrawAllocation") @Override protected void onDraw(Canvas canvas) { | ||
super.onDraw(canvas); | ||
if (paint == null) { | ||
paint = new Paint(); | ||
luar = new LinearGradient(0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP); | ||
} | ||
int rgb = Color.HSVToColor(color); | ||
Shader dalam = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP); | ||
ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY); | ||
paint.setShader(shader); | ||
canvas.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint); | ||
} | ||
|
||
void setHue(float hue) { | ||
color[0] = hue; | ||
invalidate(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
app/src/main/res/drawable/ambilwarna_alphacheckered_tiled.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:src="@drawable/ambilwarna_alphacheckered" | ||
android:tileMode="repeat" > | ||
|
||
</bitmap> |
Oops, something went wrong.