diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bff30dc3..89123b88 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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 } diff --git a/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/AppListArrayAdapter.java b/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/AppListArrayAdapter.java index 0fc1ed37..e2e47074 100644 --- a/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/AppListArrayAdapter.java +++ b/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/AppListArrayAdapter.java @@ -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; } diff --git a/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java b/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java index bb2cb578..790bb38d 100644 --- a/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java +++ b/app/src/main/java/com/abdurazaaqmohammed/AntiSplit/main/MainActivity.java @@ -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); } diff --git a/app/src/main/java/com/reandroid/apk/ApkBundle.java b/app/src/main/java/com/reandroid/apk/ApkBundle.java index 8af50662..12612be7 100644 --- a/app/src/main/java/com/reandroid/apk/ApkBundle.java +++ b/app/src/main/java/com/reandroid/apk/ApkBundle.java @@ -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 mismatchedDpis = new ArrayList<>(); StringBuilder mismatchedLangs = new StringBuilder(); for(int i = 0; i < size; i++) { diff --git a/app/src/main/java/com/reandroid/archive/InputSource.java b/app/src/main/java/com/reandroid/archive/InputSource.java index 15c39996..e666681f 100644 --- a/app/src/main/java/com/reandroid/archive/InputSource.java +++ b/app/src/main/java/com/reandroid/archive/InputSource.java @@ -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;