Skip to content

Commit

Permalink
1.6.6.2
Browse files Browse the repository at this point in the history
Add option to install APK after successfully merging and signing
Sort installed app list alphabetically
Show icon of apps in the app list
  • Loading branch information
AbdurazaaqMohammed committed Aug 30, 2024
1 parent 9a55685 commit 69b8836
Show file tree
Hide file tree
Showing 25 changed files with 1,109 additions and 151 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 = 30
versionName = "1.6.6.1"
versionName = "1.6.6.2"
multiDexEnabled = true
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" android:minSdkVersion="30"
tools:ignore="ScopedStorage" />
Expand Down Expand Up @@ -40,5 +41,14 @@
<data android:mimeType="application/octet-stream" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/paths"/>
</provider>
</application>
</manifest>
773 changes: 773 additions & 0 deletions app/src/main/java/android/support/v4/content/FileProvider.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.abdurazaaqmohammed.AntiSplit.main;

import android.graphics.drawable.Drawable;

public class AppInfo {
String name;
String packageName;
Drawable icon;

public AppInfo(String name, Drawable icon, String packageName) {
this.name = name;
this.icon = icon;
this.packageName = packageName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.abdurazaaqmohammed.AntiSplit.main;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;

import com.abdurazaaqmohammed.AntiSplit.R;

import java.util.ArrayList;
import java.util.List;

public class AppListArrayAdapter extends ArrayAdapter<AppInfo> implements Filterable {
private final Context context;
private final List<AppInfo> originalAppInfoList;
public List<AppInfo> filteredAppInfoList;
private final int textColor;
private final boolean showIcon;
private AppInfoFilter filter;

public AppListArrayAdapter(Context context, List<AppInfo> appInfoList, int textColor, boolean showIcon) {
super(context, R.layout.list_item, appInfoList);
this.context = context;
this.originalAppInfoList = new ArrayList<>(appInfoList);
this.filteredAppInfoList = new ArrayList<>(appInfoList);
this.textColor = textColor;
this.showIcon = showIcon;
}

@Override
public int getCount() {
return filteredAppInfoList.size();
}

@Override
public AppInfo getItem(int position) {
return filteredAppInfoList.get(position);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
}

TextView textView = convertView.findViewById(R.id.text_view);
ImageView iconView = convertView.findViewById(R.id.icon_view);

AppInfo appInfo = getItem(position);
textView.setText(appInfo.name);
textView.setTextColor(textColor);

if (showIcon) {
iconView.setImageDrawable(appInfo.icon);
iconView.setVisibility(View.VISIBLE);
} else {
iconView.setVisibility(View.GONE);
}

return convertView;
}

@Override
public Filter getFilter() {
if (filter == null) {
filter = new AppInfoFilter();
}
return filter;
}

private class AppInfoFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint == null || constraint.length() == 0) {
results.values = new ArrayList<>(originalAppInfoList);
results.count = originalAppInfoList.size();
} else {
List<AppInfo> filteredItems = new ArrayList<>();
String filterPattern = constraint.toString().toLowerCase().trim();
for (AppInfo appInfo : originalAppInfoList) {
if (appInfo.name.toLowerCase().contains(filterPattern)) {
filteredItems.add(appInfo);
}
}
results.values = filteredItems;
results.count = filteredItems.size();
}
return results;
}

@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
filteredAppInfoList.clear();
filteredAppInfoList.addAll((List<AppInfo>) results.values);
notifyDataSetChanged();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.TextView;

import com.abdurazaaqmohammed.AntiSplit.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/** @noinspection NullableProblems*/
Expand All @@ -22,16 +19,13 @@ public class CustomArrayAdapter extends ArrayAdapter<String> {
private final int textColor;
private final boolean lang;
private String langCode;
private final List<String> filteredList;
private CustomFilter filter;

public CustomArrayAdapter(Context context, String[] values, int textColor, boolean lang) {
super(context, android.R.layout.simple_list_item_multiple_choice, values);
this.context = context;
this.values = values;
this.textColor = textColor;
this.lang = lang;
this.filteredList = new ArrayList<>();
if (lang) {
String[] langCodes = MainActivity.rss.getStringArray(R.array.langs);
for (int i = 0; i < langCodes.length; i++) {
Expand All @@ -41,69 +35,17 @@ public CustomArrayAdapter(Context context, String[] values, int textColor, boole
}
}
}
this.filteredList.addAll(List.of(values)); // Initialize filteredList with original values
}

@Override
public int getCount() {
return filteredList.size();
}

@Override
public String getItem(int position) {
return filteredList.get(position);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(lang ? android.R.layout.simple_list_item_1 : android.R.layout.simple_list_item_multiple_choice, parent, false);
}

TextView textView = convertView.findViewById(android.R.id.text1);
String curr = getItem(position); // Use the filtered list item
textView.setText(lang && Objects.equals(curr, langCode) ? Html.fromHtml("<b>" + curr + "</b>") : curr);
String curr = values[position];
textView.setText(lang ? Html.fromHtml(Objects.equals(curr, langCode) ? ("<b>" + curr + "</b>") : curr) : curr);
textView.setTextColor(textColor);

return convertView;
}

@Override
public Filter getFilter() {
if (filter == null) {
filter = new CustomFilter();
}
return filter;
}

private class CustomFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint == null || constraint.length() == 0) {
results.values = List.of(values);
results.count = values.length;
} else {
List<String> filteredItems = new ArrayList<>();
String filterPattern = constraint.toString().toLowerCase().trim();

for (String item : values) {
if (item.toLowerCase().contains(filterPattern)) {
filteredItems.add(item);
}
}

results.values = filteredItems;
results.count = filteredItems.size();
}
return results;
}

@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
filteredList.clear();
filteredList.addAll((List<String>) results.values);
notifyDataSetChanged();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
Expand All @@ -36,7 +37,8 @@ public DeviceSpecsUtil(Context context) {
public List<String> getListOfSplits(Uri splitAPKUri) throws IOException {
List<String> splits = new ArrayList<>();

try (ZipFileInput zis = new ZipFileInput(FileUtils.getInputStream(splitAPKUri, context))) {
try (InputStream is = FileUtils.getInputStream(splitAPKUri, context);
ZipFileInput zis = new ZipFileInput(is)) {
ZipFileHeader header;
while ((header = zis.readFileHeader()) != null) {
final String name = header.getFileName();
Expand All @@ -47,7 +49,9 @@ public List<String> getListOfSplits(Uri splitAPKUri) throws IOException {
if(splits.size() < 2) {
File file = new File(FileUtils.getPath(splitAPKUri, context));
boolean couldNotRead = !file.canRead();
if(couldNotRead) FileUtils.copyFile(FileUtils.getInputStream(splitAPKUri, context), file = new File(context.getCacheDir(), file.getName()));
try(InputStream is = FileUtils.getInputStream(splitAPKUri, context)) {
if(couldNotRead) FileUtils.copyFile(is, file = new File(context.getCacheDir(), file.getName()));
}
Enumeration<ZipArchiveEntry> entries = (zipFile = new ZipFile(file)).getEntries();
// Do not close this ZipFile it could be used later in merger
while (entries.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.abdurazaaqmohammed.AntiSplit.main;
import static com.aefyr.pseudoapksigner.Base64.DEFAULT;
import static com.aefyr.pseudoapksigner.Base64.encodeToString;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

import java.io.ByteArrayOutputStream;

public class IconsHelper {
static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888
);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}

static String bitmapToBase64(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
return encodeToString(byteArray, DEFAULT);
}
}
Loading

0 comments on commit 69b8836

Please sign in to comment.