Skip to content

Commit

Permalink
2.1.2
Browse files Browse the repository at this point in the history
Fix bug: Mismatched splits error was shown when trying to merge splits without base.apk
Check base.apk by default in the splits selection dialog.
  • Loading branch information
AbdurazaaqMohammed committed Oct 28, 2024
1 parent 95d72de commit bb44dfd
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 84 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId = "com.abdurazaaqmohammed.AntiSplit"
minSdk = 19
targetSdk = 35
versionCode = 39
versionName = "2.1.1"
versionCode = 40
versionName = "2.1.2"
multiDexEnabled = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
iconView.setImageDrawable(appInfo.icon);
iconView.setVisibility(View.VISIBLE);
iconView.setContentDescription(MainActivity.rss.getString(R.string.app_icon_list_label));
} else {
iconView.setVisibility(View.GONE);
}
} else iconView.setVisibility(View.GONE);

return convertView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,89 +892,101 @@ public void showApkSelectionDialog() {
checkedItems[i] = false;
}

styleAlertDialog(new MaterialAlertDialogBuilder(this).setTitle(rss.getString(R.string.select_splits)).setMultiChoiceItems(apkNames, checkedItems, (dialog, which, isChecked) -> {
switch (which) {
case 0:
// "Select All" option
for (int i = 5; i < checkedItems.length; i++) ((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
case 1:
// device specs option
for (int i = 5; i < checkedItems.length; i++) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = (isChecked && DeviceSpecsUtil.shouldIncludeSplit(apkNames[i])));
AlertDialog ad = new MaterialAlertDialogBuilder(this).setTitle(rss.getString(R.string.select_splits)).setMultiChoiceItems(apkNames, checkedItems, (dialog, which, isChecked) -> {
switch (which) {
case 0:
// "Select All" option
for (int i = 5; i < checkedItems.length; i++)
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
case 1:
// device specs option
for (int i = 5; i < checkedItems.length; i++) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = (isChecked && DeviceSpecsUtil.shouldIncludeSplit(apkNames[i])));
}
boolean didNotFindAppropriateDpi = true;
for (int i = 5; i < checkedItems.length; i++) {
if (checkedItems[i] && apkNames[i].contains("dpi")) {
didNotFindAppropriateDpi = false;
break;
}
boolean didNotFindAppropriateDpi = true;
}
if (didNotFindAppropriateDpi) {
for (int i = 5; i < checkedItems.length; i++) {
if (checkedItems[i] && apkNames[i].contains("dpi")) {
didNotFindAppropriateDpi = false;
if (apkNames[i].contains("hdpi")) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
}
}
if (didNotFindAppropriateDpi) {
for (int i = 5; i < checkedItems.length; i++) {
if (apkNames[i].contains("hdpi")) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
}
}
}
break;
case 2:
//arch for device
for (int i = 5; i < checkedItems.length; i++) {
if(DeviceSpecsUtil.shouldIncludeArch(apkNames[i])) ((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
}
}
break;
case 3:
//dpi for device
for (int i = 5; i < checkedItems.length; i++) {
if(DeviceSpecsUtil.shouldIncludeDpi(apkNames[i])) ((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
case 2:
//arch for device
for (int i = 5; i < checkedItems.length; i++) {
if (DeviceSpecsUtil.shouldIncludeArch(apkNames[i]))
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
}
break;
case 3:
//dpi for device
for (int i = 5; i < checkedItems.length; i++) {
if (DeviceSpecsUtil.shouldIncludeDpi(apkNames[i]))
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
}
boolean didNotFoundAppropriateDpi = true;
for (int i = 5; i < checkedItems.length; i++) {
if (checkedItems[i] && apkNames[i].contains("dpi")) {
didNotFoundAppropriateDpi = false;
break;
}
boolean didNotFoundAppropriateDpi = true;
}
if (didNotFoundAppropriateDpi) {
for (int i = 5; i < checkedItems.length; i++) {
if (checkedItems[i] && apkNames[i].contains("dpi")) {
didNotFoundAppropriateDpi = false;
if (apkNames[i].contains("hdpi")) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
}
}
if (didNotFoundAppropriateDpi) {
for (int i = 5; i < checkedItems.length; i++) {
if (apkNames[i].contains("hdpi")) {
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
break;
}
}
}
}
break;
case 4:
//lang for device
for (int i = 5; i < checkedItems.length; i++) {
if(DeviceSpecsUtil.shouldIncludeLang(apkNames[i])) ((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
}
case 4:
//lang for device
for (int i = 5; i < checkedItems.length; i++) {
if (DeviceSpecsUtil.shouldIncludeLang(apkNames[i]))
((AlertDialog) dialog).getListView().setItemChecked(i, checkedItems[i] = isChecked);
}
break;
default:
ListView listView = ((AlertDialog) dialog).getListView();
if (!isChecked) listView.setItemChecked(0, checkedItems[0] = false); // Uncheck "Select All" if any individual item is unchecked
for (int i = 1; i <= 4; i++) {
if (checkedItems[i] && !DeviceSpecsUtil.shouldIncludeSplit(apkNames[which])) {
listView.setItemChecked(i, checkedItems[i] = false); // uncheck device arch if non device arch selected
}
default:
ListView listView = ((AlertDialog) dialog).getListView();
if (!isChecked)
listView.setItemChecked(0, checkedItems[0] = false); // Uncheck "Select All" if any individual item is unchecked
for (int i = 1; i <= 4; i++) {
if (checkedItems[i] && !DeviceSpecsUtil.shouldIncludeSplit(apkNames[which])) {
listView.setItemChecked(i, checkedItems[i] = false); // uncheck device arch if non device arch selected
}
break;
}
}).setPositiveButton("OK", (dialog, which) -> {
for (int i = 1; i < checkedItems.length; i++) {
if (checkedItems[i]) splits.remove(apkNames[i]); // ?????
}
}
break;
}
}).setPositiveButton("OK", (dialog, which) -> {
for (int i = 1; i < checkedItems.length; i++) {
if (checkedItems[i]) splits.remove(apkNames[i]); // ?????
}

if (splits.size() == initialSize) {
urisAreSplitApks = true; // reset
showError(rss.getString(R.string.nothing));
} else {
splitsToUse = splits;
selectDirToSaveAPKOrSaveNow();
}
}).setNegativeButton("Cancel", null).create());
if (splits.size() == initialSize) {
urisAreSplitApks = true; // reset
showError(rss.getString(R.string.nothing));
} else {
splitsToUse = splits;
selectDirToSaveAPKOrSaveNow();
}
}).setNegativeButton("Cancel", null).create();
styleAlertDialog(ad);
for (int i = 5; i < apkNames.length; i++) {
if (com.abdurazaaqmohammed.AntiSplit.main.DeviceSpecsUtil.isBaseApk(apkNames[i])) {
ad.getListView().setItemChecked(i, true);
break;
}
}
} catch (IOException e) {
showError(e);
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/reandroid/apk/ApkBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public void loadApkDirectory(File dir, boolean recursive, Context context) throw
versionCodes[i] = -1;
}
}
if(base == -1) load(apkList);
if(base == -1) {
// It is a valid usage to merge only some files and then merge that merged file with the base later.
base = versionCodes[0]; // Just set first file as base for checking.
}
List<File> mismatchedDpis = new ArrayList<>();
StringBuilder mismatchedLangs = new StringBuilder();
for(int i = 0; i < size; i++) {
Expand Down
12 changes: 2 additions & 10 deletions app/src/main/java/com/reandroid/archive/InputSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,8 @@ public static int getDexNumber(String name) {
public static int compareDex(String dex1, String dex2){
int d1 = getDexNumber(dex1);
int d2 = getDexNumber(dex2);
if(d1 == d2){
return 0;
}
if(d1 < 0){
return 1;
}
if(d2 < 0){
return -1;
}
return Integer.compare(d1, d2);
return (d1 == d2) ? 0 : (d1 < 0) ? 1 : (d2 < 0) ? -1 : Integer.compare(d1, d2);

}
private static int getSortOrder(String[] alias){
int length = alias.length;
Expand Down

0 comments on commit bb44dfd

Please sign in to comment.