Skip to content

Commit

Permalink
1.6.5.9
Browse files Browse the repository at this point in the history
Fix for ReVanced by default, no additional option or steps required
Show errors in a dialog, with option to open issue with the error log on GitHub or copy it
Add button to cancel while processing
Add button to copy log after processing
  • Loading branch information
AbdurazaaqMohammed committed Aug 24, 2024
1 parent 66adab0 commit 366af03
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 178 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk = 4
targetSdk = 35
versionCode = 29
versionName = "1.6.5.8"
versionName = "1.6.5.9"
multiDexEnabled = true
}

Expand Down
306 changes: 183 additions & 123 deletions app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions app/src/main/java/com/reandroid/apkeditor/merge/LogUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.reandroid.apkeditor.merge;

import static com.abdurazaaqmohammed.AntiSplit.main.MainActivity.toggleAnimation;

import android.widget.ImageView;

import com.abdurazaaqmohammed.AntiSplit.main.MainActivity;

import java.util.concurrent.CountDownLatch;

public class LogUtil {
private static Merger.LogListener logListener;

Expand All @@ -10,6 +18,7 @@ public static void setLogListener(Merger.LogListener listener) {
}



public static void logMessage(String msg) {
if (logListener != null && logEnabled) {
logListener.onLog(msg);
Expand Down
39 changes: 19 additions & 20 deletions app/src/main/java/com/reandroid/apkeditor/merge/Merger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.reandroid.apkeditor.merge;

import static com.abdurazaaqmohammed.AntiSplit.main.MainActivity.toggleAnimation;
import static com.reandroid.apkeditor.merge.LogUtil.logMessage;

import android.content.Context;
Expand All @@ -27,7 +26,6 @@
import com.abdurazaaqmohammed.AntiSplit.main.MismatchedSplitsException;
import com.abdurazaaqmohammed.AntiSplit.main.SignUtil;
import com.j256.simplezip.ZipFileInput;
import com.j256.simplezip.format.GeneralPurposeFlag;
import com.j256.simplezip.format.ZipFileHeader;
import com.reandroid.apk.ApkBundle;
import com.reandroid.apk.ApkModule;
Expand Down Expand Up @@ -92,6 +90,8 @@ private static void extractAndLoad(Uri in, File cacheDir, Context context, List<
// If the above failed it probably did not copy any files
// so might as well do it this way instead of trying unreliable methods to see if we need to do this
// and possibly copying the file for no reason

// Check if already copied the file earlier to get list of splits.
if (DeviceSpecsUtil.zipFile == null) {
File input = new File(FileUtils.getPath(in, context));
boolean couldNotRead = !input.canRead();
Expand Down Expand Up @@ -123,7 +123,7 @@ private static void extractZipFile(ZipFile zf, boolean checkSplits, List<String>
zf.close();
}

public static void run(Uri in, File cacheDir, Uri out, Context context, List<String> splits, boolean signApk, boolean revanced) throws Exception {
public static void run(Uri in, File cacheDir, Uri out, Context context, List<String> splits, boolean signApk) throws Exception {
logMessage(com.abdurazaaqmohammed.AntiSplit.main.MainActivity.rss.getString(R.string.searching));
try (ApkBundle bundle = new ApkBundle()) {
if (in == null)
Expand Down Expand Up @@ -213,14 +213,25 @@ public static void run(Uri in, File cacheDir, Uri out, Context context, List<Str
manifest.refresh();
}
logMessage(MainActivity.rss.getString(R.string.saving));

File temp;
if (revanced || signApk) {
if (signApk) {
mergedModule.writeApk(temp = new File(cacheDir, "temp.apk"));
// The apk does not need to be signed to patch with ReVanced and it will make this already long crap take even more time
logMessage(MainActivity.rss.getString(R.string.signing));
boolean noPerm = MainActivity.doesNotHaveStoragePerm(context);
File stupid = new File(noPerm ? (cacheDir + File.separator + "stupid.apk") : FileUtils.getPath(out, context));
try {
SignUtil.signDebugKey(context, temp, stupid);
if (noPerm) FileUtils.copyFile(stupid, FileUtils.getOutputStream(out, context));
} catch (Exception e) {
SignUtil.signPseudoApkSigner(temp, context, out, e);
}
// Below no longer necessary
/*if (revanced) {
// The apk does not need to be signed to patch with ReVanced and it will make this already long crap take even more time
// but someone is probably going to try to install it before patching and complain
// and to avoid confusion/mistakes the sign apk option in the app should not be toggled off when revanced option is on
if (revanced) {
logMessage(MainActivity.rss.getString(R.string.fixing));
logMessage(MainActivity.rss.getString(R.string.fixing));
// Copying the contents of the zip to a new one works on most JRE implementations of java.util.zip but not on Android,
// the exact same problem happens in ReVanced.
try (ZipFileInput zfi = new ZipFileInput(temp);
Expand All @@ -244,19 +255,7 @@ public static void run(Uri in, File cacheDir, Uri out, Context context, List<Str
zfo.writeRawFileData(zfi.openFileDataInputStream(true));
}
}
}
if (signApk) {
logMessage(MainActivity.rss.getString(R.string.signing));
boolean noPerm = MainActivity.doesNotHaveStoragePerm(context);
File stupid = new File(noPerm ? (cacheDir + File.separator + "stupid.apk") : FileUtils.getPath(out, context));
try {
SignUtil.signDebugKey(context, temp, stupid);
if (noPerm)
FileUtils.copyFile(stupid, FileUtils.getOutputStream(out, context));
} catch (Exception e) {
SignUtil.signPseudoApkSigner(temp, context, out, e);
}
}
}*/
} else {
mergedModule.writeApk(FileUtils.getOutputStream(out, context));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public LocalFileHeader copy(){
lfh.setCrc(getCrc());
DataDescriptor dd = getDataDescriptor();
if(dd != null){
lfh.setDataDescriptor(dd.copy());
//lfh.setDataDescriptor(dd.copy());
}
lfh.setDosTime(getDosTime());
lfh.setPlatform(getPlatform());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void visitLocalFile(ZipInput zipInput) throws IOException {
dataDescriptor = null;
}
}
lfh.setDataDescriptor(dataDescriptor);
//lfh.setDataDescriptor(dataDescriptor);
lfh.setIndex(index);

headerList.add(lfh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void writeCEH(ZipOutput zipOutput) throws IOException{
ceh.writeBytes(zipOutput.getOutputStream());
}
void writeDD(ZipOutput apkFileWriter) throws IOException{
DataDescriptor dataDescriptor = getLocalFileHeader().getDataDescriptor();
DataDescriptor dataDescriptor = null;//getLocalFileHeader().getDataDescriptor();
if(dataDescriptor == null){
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void align(long offset, LocalFileHeader lfh){
}
private void createDataDescriptor(LocalFileHeader lfh){
DataDescriptor dataDescriptor;
if(enableDataDescriptor){
if(false){
dataDescriptor = DataDescriptor.fromLocalFile(lfh);
}else {
dataDescriptor = null;
Expand All @@ -96,7 +96,7 @@ public static ZipAligner apkAligner(){
zipAligner.setDefaultAlignment(ALIGNMENT_4);
Pattern patternNativeLib = Pattern.compile("^lib/.+\\.so$");
zipAligner.setFileAlignment(patternNativeLib, ALIGNMENT_PAGE);
zipAligner.setEnableDataDescriptor(true);
zipAligner.setEnableDataDescriptor(false);
return zipAligner;
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/copy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>

</vector>
52 changes: 26 additions & 26 deletions app/src/main/res/layout-v14/dialog_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,33 @@
android:textSize="20sp"
android:text="@string/sign_apk" />

<Switch
android:id="@+id/revancedToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/fix" />
<!--<Switch
android:id="@+id/revancedToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/fix" />-->

<Switch
android:id="@+id/updateToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/auto_update" />
<Switch
android:id="@+id/updateToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/auto_update" />

<Button
android:id="@+id/checkUpdateNow"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/check_update_now" />
<Button
android:id="@+id/checkUpdateNow"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/check_update_now" />

<Button
android:id="@+id/langPicker"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/lang" />
<Button
android:id="@+id/langPicker"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/lang" />

</LinearLayout>
</ScrollView>
</LinearLayout>
</ScrollView>
26 changes: 25 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/wrapImg" >
android:layout_below="@id/wrapImg"
android:layout_above="@id/viewSwitcher">

<LinearLayout
android:id="@+id/linear1"
Expand All @@ -80,4 +81,27 @@

</LinearLayout>
</ScrollView>

<ViewSwitcher
android:id="@+id/viewSwitcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone">

<ImageView
android:id="@+id/cancelButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_close_clear_cancel"
android:contentDescription="@string/cancel" />

<ImageView
android:id="@+id/copyLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/copy"
android:contentDescription="@string/pause" />

</ViewSwitcher>
</RelativeLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/dialog_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"/>

<TextView
<!--<TextView
android:id="@+id/revancedText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -101,7 +101,7 @@
<ToggleButton
android:id="@+id/revancedToggle"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
android:layout_width="match_parent"/>-->

<Button
android:id="@+id/langPicker"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@
<item>uk</item>
</string-array>
<string name="label_parent_dir" translatable="false">…</string>
<string name="create_issue">Create GitHub Issue</string>
<string name="copy_log">Copy log</string>
<string name="pause">Pause button</string>
<string name="resume">Resume button</string>
<string name="copied_log">Copied log</string>
</resources>

0 comments on commit 366af03

Please sign in to comment.