Skip to content

Commit

Permalink
2.0.8
Browse files Browse the repository at this point in the history
Allow customizing suffix for saving merged files
Cleanup app folder if it is empty
Try to fix navigation and status bar on Samsung below Android 11 again
  • Loading branch information
AbdurazaaqMohammed committed Sep 29, 2024
1 parent 22f3fc1 commit 97faf14
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 35 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk = 21
targetSdk = 35
versionCode = 38
versionName = "2.0.7"
versionName = "2.0.8"
}

buildTypes {
Expand All @@ -38,7 +38,6 @@ android {
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.multidex:multidex:2.0.1")
implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0")
implementation("com.google.android.material:material:1.12.0")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
import com.google.android.material.color.DynamicColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.google.android.material.textview.MaterialTextView;
import com.reandroid.apk.ApkBundle;
import com.reandroid.apkeditor.merge.LogUtil;
Expand Down Expand Up @@ -104,6 +106,7 @@ public class MainActivity extends AppCompatActivity implements Merger.LogListene
public static int sortMode;
public DeviceSpecsUtil DeviceSpecsUtil;
private String pkgName;
private static String suffix;
private boolean systemTheme;

public Handler getHandler() {
Expand All @@ -113,7 +116,6 @@ public Handler getHandler() {
/** @noinspection AssignmentUsedAsCondition*/
@Override
protected void onCreate(Bundle savedInstanceState) {
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
DynamicColors.applyToActivitiesIfAvailable(getApplication());
handler = new Handler(Looper.getMainLooper());
Expand All @@ -129,6 +131,7 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_main);

suffix = settings.getString("suffix", "_antisplit");
lang = settings.getString("lang", "en");
if(Objects.equals(lang, Locale.getDefault().getLanguage())) rss = getResources();
else updateLang(LocaleHelper.setLocale(MainActivity.this, lang).getResources(), null);
Expand All @@ -137,6 +140,7 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().setNavigationBarColor(transparent);
getWindow().setStatusBarColor(transparent);
if (!LegacyUtils.supportsWriteExternalStorage) {
EdgeToEdge.enable(this);
getWindow().setStatusBarContrastEnforced(true);
getWindow().setNavigationBarContrastEnforced(true);
}
Expand Down Expand Up @@ -247,9 +251,28 @@ public void afterTextChanged(Editable s) {
((TextView) settingsDialog.findViewById(R.id.selectSplitsForDeviceToggle)).setText(rss.getString(R.string.automatically_select));
((TextView) settingsDialog.findViewById(R.id.updateToggle)).setText(rss.getString(R.string.auto_update));
((TextView) settingsDialog.findViewById(R.id.checkUpdateNow)).setText(rss.getString(R.string.check_update_now));
((TextInputLayout) settingsDialog.findViewById(R.id.suffixLayout)).setHint(rss.getString(R.string.suffix));
TextInputEditText suffixInput = settingsDialog.findViewById(R.id.suffixInput);
suffixInput.setText(suffix);
suffixInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
suffix = s.toString();
}

@Override
public void afterTextChanged(Editable s) {

}
});
MaterialButtonToggleGroup themeButtons = settingsDialog.findViewById(R.id.themeToggleGroup);
themeButtons.check(
systemTheme ? R.id.systemThemeButton :
systemTheme ? R.id.systemThemeButton :
theme == com.google.android.material.R.style.Theme_Material3_Light_NoActionBar ? R.id.lightThemeButton :
theme == com.google.android.material.R.style.Theme_Material3_Dark_NoActionBar ? R.id.darkThemeButton :
R.id.blackThemeButton
Expand Down Expand Up @@ -461,6 +484,7 @@ private void updateLang(Resources res, ScrollView settingsDialog) {
((TextView) settingsDialog.findViewById(R.id.selectSplitsForDeviceToggle)).setText(res.getString(R.string.automatically_select));
((TextView) settingsDialog.findViewById(R.id.updateToggle)).setText(res.getString(R.string.auto_update));
((TextView) settingsDialog.findViewById(R.id.checkUpdateNow)).setText(res.getString(R.string.check_update_now));
((TextInputLayout) settingsDialog.findViewById(R.id.suffixLayout)).setHint(rss.getString(R.string.suffix));
}
}

Expand Down Expand Up @@ -498,6 +522,7 @@ protected void onPause() {
.putInt("sortMode", sortMode)
.putBoolean("checkForUpdates", checkForUpdates)
.putString("lang", lang)
.putString("suffix", suffix)
.apply();
super.onPause();
}
Expand All @@ -524,9 +549,28 @@ public static void deleteDir(File dir) {
for (String child : dir.list()) new File(dir, child).delete();
}

/** @noinspection ResultOfMethodCallIgnored*/
private void cleanupAppFolder() {
if(!doesNotHaveStoragePerm(this)) {
File appFolder = new File(Environment.getExternalStorageDirectory(), "AntiSplit-M");
if(appFolder.exists()) {
File[] children = appFolder.listFiles();
if(children != null) {
if (children.length == 0) appFolder.delete();
else {
for (File child : children) if (child.isFile() && child.length() == 0) child.delete();
children = appFolder.listFiles();
if (children.length == 0) appFolder.delete();
}
}
}
}
}

@Override
protected void onDestroy() {
deleteDir(getCacheDir());
cleanupAppFolder();
super.onDestroy();
}

Expand Down Expand Up @@ -984,6 +1028,7 @@ private void copyText(CharSequence text) {
}

private void showError(Exception e) {
cleanupAppFolder();
if (!(e instanceof ClosedByInterruptException)) {
final String mainErr = e.toString();
errorOccurred = !mainErr.equals(rss.getString(R.string.sign_failed));
Expand Down Expand Up @@ -1050,7 +1095,7 @@ public static String getOriginalFileName(Context context, Uri uri) {
if (cut != -1) result = result.substring(cut + 1);
}
LogUtil.logMessage(result);
return result.replaceFirst("\\.(?:xapk|aspk|apk[sm])", "_antisplit.apk");
return result.replaceFirst("\\.(?:xapk|aspk|apk[sm])", suffix + ".apk");
} catch (Exception ignored) {
return "filename_not_found";
}
Expand All @@ -1061,7 +1106,7 @@ private void selectDirToSaveAPKOrSaveNow() {
if (ask) startActivityForResult(new Intent(Intent.ACTION_CREATE_DOCUMENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.setType("application/vnd.android.package-archive")
.putExtra(Intent.EXTRA_TITLE, TextUtils.isEmpty(pkgName) ? (urisAreSplitApks ? getOriginalFileName(this, splitAPKUri) : getNameFromNonSplitApks()) : pkgName + "_antisplit"), 2);
.putExtra(Intent.EXTRA_TITLE, TextUtils.isEmpty(pkgName) ? (urisAreSplitApks ? getOriginalFileName(this, splitAPKUri) : getNameFromNonSplitApks()) : pkgName + suffix), 2);
else {
checkStoragePerm();
try {
Expand All @@ -1076,7 +1121,7 @@ private void selectDirToSaveAPKOrSaveNow() {
File f;
String newFilePath = TextUtils.isEmpty(originalFilePath) ?
getAntisplitMFolder() + File.separator + getOriginalFileName(this, splitAPKUri) // If originalFilePath is null urisAreSplitApks must be true because getNameFromNonSplitApks will always return something
: originalFilePath.replaceFirst("\\.(?:xapk|aspk|apk[sm])", "_antisplit.apk");
: originalFilePath.replaceFirst("\\.(?:xapk|aspk|apk[sm])", suffix + ".apk");
if(TextUtils.isEmpty(newFilePath) ||
newFilePath.startsWith("/data/")
// || !(f = new File(newFilePath)).createNewFile() || f.canWrite()
Expand Down Expand Up @@ -1111,6 +1156,6 @@ private String getNameFromNonSplitApks() {
break;
}
}
return (TextUtils.isEmpty(realName) ? "unknown" : realName.replace(".apk", "")) + "_antisplit.apk";
return (TextUtils.isEmpty(realName) ? "unknown" : realName.replace(".apk", "")) + suffix + ".apk";
}
}
24 changes: 24 additions & 0 deletions app/src/main/res/layout/setty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,29 @@
android:text="@string/lang"
style="@style/Widget.Material3.Button.OutlinedButton" />

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:id="@+id/suffixLayout"
android:layout_height="wrap_content"
android:hint="@string/suffix"
app:endIconMode="clear_text"
app:boxBackgroundMode="outline"
android:layout_marginTop="5dp"
app:boxCornerRadiusTopStart="24dp"
app:boxCornerRadiusTopEnd="24dp"
app:boxCornerRadiusBottomStart="24dp"
app:boxCornerRadiusBottomEnd="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/filter_button"
app:layout_constraintTop_toTopOf="parent">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/suffixInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>
</ScrollView>
28 changes: 2 additions & 26 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name" translatable="false">AntiSplit M</string>
<string name="merge">اختر ملف APK المقسم للدمج/أنتي سبلت</string>
<string name="success_saved">تم حفظ الملف بنجاح</string>
<string name="enable_logs">تفعيل السجلات</string>
Expand Down Expand Up @@ -33,7 +32,6 @@
<string name="label_parent_directory">الدليل الرئيسي</string>
<string name="last_edit">آخر تعديل: </string>
<string name="error_dir_access">لا يمكن الوصول إلى الدليل</string>
<string name="lang" translatable="false">Language</string>
<string name="update">تحديث متاح</string>
<string name="new_ver">إصدار جديد من AntiSplit M متاح</string>
<string name="dl">تحميل</string>
Expand All @@ -45,34 +43,12 @@
<string name="mismatch">المقاطع التالية (%1$s) تحتوي على رموز إصدار غير متطابقة. هي فقط رموز لغات، لذا يمكن للتطبيق العمل بدونها، لكن هذه اللغات لن تعمل في التطبيق. هل ترغب في الاستمرار في الدمج على أي حال؟</string>
<string name="warning">تحذير</string>
<string name="mismatch_base">" رمز الإصدار لا يتطابق مع base.apk"</string>
<string-array name="langs_display">
<item>الإنجليزية</item>
<item>الإسبانية</item>
<item>الفرنسية</item>
<item>البهاسا الإندونيسية</item>
<item>الإيطالية</item>
<item>الروسية</item>
<item>التركية</item>
<item>الأوكرانية</item>
<item>البرتغالية</item>
</string-array>
<string-array name="langs">
<item>en</item>
<item>es</item>
<item>fr</item>
<item>in</item>
<item>it</item>
<item>ru</item>
<item>tr</item>
<item>uk</item>
<item>pt-BR</item>
</string-array>
<string name="label_parent_dir" translatable="false">…</string>
<string name="create_issue">إنشاء مشكلة على GitHub</string>
<string name="copy_log">نسخ السجل</string>
<string name="pause">زر الإيقاف المؤقت</string>
<string name="copied_log">تم نسخ السجل</string>
<string name="select_from_installed_apps">اختر من التطبيقات المثبتة</string>
<string name="app_icon_list_label">أيقونة التطبيق</string>
<string name="install">تثبيت</string>
</resources>
<string name="suffix">اللاحقة</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@
<string name="pause">Botón de pausa</string>
<string name="copied_log">Registro copiado</string>
<string name="select_from_installed_apps">Seleccionar desde aplicaciones instaladas</string>
<string name="suffix">Sufijo</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@
<string name="mismatch">Les splits suivants (%1$s) ont des codes de version incompatibles. Ce sont uniquement des codes de langue, donc l\'application peut fonctionner sans eux, mais ces langues ne seront pas disponibles dans l\'application. Voulez-vous continuer la fusion malgré tout ?</string>
<string name="warning">Avertissement</string>
<string name="mismatch_base">" le code de version ne correspond pas à celui de base.apk"</string>
<string name="app_icon_list_label">Icône de l\'application</string>
<string name="install">Installer</string>
<string name="suffix">Suffixe</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
<string name="last_edit">Terakhir kali disunting: </string>
<string name="error_dir_access">Direktorinya tidak bisa diakses</string>
<string name="lang" translatable="false">Bahasa</string>
<string name="suffix">Akhiran</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
<string name="select_from_installed_apps">Scegli dalle App Installate</string>
<string name="app_icon_list_label">Icona app</string>
<string name="install">Installa</string>
<string name="suffix">Suffisso</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name" translatable="false">AntiSplit M</string>
<string name="merge">Selecione split APK para mesclar/AntiSplit</string>
<string name="success_saved">Arquivo salvo com sucesso</string>
<string name="enable_logs" >Ativar logs</string>
Expand Down Expand Up @@ -50,4 +49,5 @@
<string name="copy_log">Copiar log</string>
<string name="pause">Botão de pausa</string>
<string name="copied_log">Log copiado</string>
<string name="suffix">Sufixo</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<string name="skipping">"Пропуск "</string>
<string name="success_saved">Файл успешно сохранен</string>
<string name="unselected">: Не выбрано</string>
<string name="suffix">Суффикс</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
<string name="label_parent_directory">Ana Klasör</string>
<string name="last_edit">Son düzenlenme: </string>
<string name="error_dir_access">Klasöre erişilemedi</string>
<string name="suffix">Sonek</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<string name="skipping">"Перепустка "</string>
<string name="success_saved">Файл успішно збережено</string>
<string name="unselected">: Не вибрано</string>
<string name="suffix">Суфікс</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@
<string name="dark_theme">Dark theme</string>
<string name="light_theme">Light theme</string>
<string name="system_theme">System theme</string>
<string name="suffix">Suffix</string>
</resources>

0 comments on commit 97faf14

Please sign in to comment.