- Added Rom store link with An Bui app.
- Bugs fixed.
This commit is contained in:
An Bui 2026-05-08 20:18:01 +07:00
parent 0897666da7
commit fedec7cadd
8 changed files with 167 additions and 24 deletions

View file

@ -12,8 +12,8 @@ android {
applicationId "com.vectras.vm"
minSdk minApi
targetSdk targetApi
versionCode 119
versionName "4.1.5"
versionCode 120
versionName "4.1.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true

View file

@ -0,0 +1,7 @@
package com.anbui.app.elephant;
import com.anbui.app.elephant.IResultContentCallback;
interface IElephantReceiverService3 {
void getContentUrls(String appId, String contentId, IResultContentCallback callback);
}

View file

@ -0,0 +1,5 @@
package com.anbui.app.elephant;
interface IResultContentCallback {
void onResult(inout String[] urls);
}

View file

@ -0,0 +1,62 @@
package com.anbui.elephant.content;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.anbui.app.elephant.IElephantReceiverService3;
import com.anbui.app.elephant.IResultContentCallback;
import com.anbui.elephant.log.LogPrinter;
public class ContentManager {
private static final String TAG = "ContentManager";
public interface ContentManagerCallback {
void onResult(String[] urls);
}
public static void getUrls(Context context, String id, ContentManagerCallback callback) {
final ServiceConnection[] connection = new ServiceConnection[1];
connection[0] = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
IElephantReceiverService3 elephant =
IElephantReceiverService3.Stub.asInterface(service);
try {
elephant.getContentUrls(context.getPackageName(), id, new IResultContentCallback.Stub() {
@Override
public void onResult(String[] urls) {
callback.onResult(urls);
context.unbindService(connection[0]);
}
});
} catch (RemoteException ignored) {
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LogPrinter.print(TAG, "serviceDisconnected");
}
};
Intent intent = new Intent();
intent.setClassName(
"com.anbui.app",
"com.anbui.app.elephant.ElephantReceiverService3"
);
boolean ok = context.bindService(intent, connection[0], Context.BIND_AUTO_CREATE);
if (!ok) {
callback.onResult(null);
LogPrinter.print(TAG, "serviceFailedToConnect");
}
}
}

View file

@ -5,6 +5,8 @@ import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import androidx.activity.EdgeToEdge;
@ -15,6 +17,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.anbui.elephant.content.ContentManager;
import com.anbui.elephant.interaction.Interaction;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
@ -29,6 +32,7 @@ import com.vectras.vm.utils.PackageUtils;
import java.io.File;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -156,12 +160,7 @@ public class RomInfo extends AppCompatActivity {
private void initialize() {
binding.toolbar.setNavigationOnClickListener(v -> finish());
binding.btnDownload.setOnClickListener(v -> {
Intent openurl = new Intent();
openurl.setAction(Intent.ACTION_VIEW);
openurl.setData(Uri.parse(getIntent().getStringExtra("getrom")));
startActivity(openurl);
});
binding.btnDownload.setOnClickListener(v -> download());
if (getIntent().hasExtra("isRomInfo") && getIntent().getBooleanExtra("isRomInfo", false)) {
binding.btnPick.setOnClickListener(v -> {
@ -367,6 +366,60 @@ public class RomInfo extends AppCompatActivity {
});
}
String[] anbuiContentUrls = null;
boolean isAllowGetAnbuiContentUrls = true;
private void download() {
if (isAnBuiContent && isAllowGetAnbuiContentUrls) {
if (anbuiContentUrls == null) {
binding.btnDownload.setVisibility(View.GONE);
binding.cvIcon.animate().scaleY(0.5f).setDuration(200).start();
binding.cvIcon.animate().scaleX(0.5f).setDuration(200).start();
binding.cpiDownloading.setVisibility(View.VISIBLE);
binding.cpiDownloading.animate().alpha(1).setDuration(200).start();
ContentManager.getUrls(this, contentID, ((urls) -> {
if (isFinishing() || isDestroyed()) return;
openAnBuiContentUrl(urls);
anbuiContentUrls = urls;
runOnUiThread(() -> {
binding.btnDownload.setVisibility(View.VISIBLE);
binding.cvIcon.animate().scaleY(1).setDuration(200).start();
binding.cvIcon.animate().scaleX(1).setDuration(200).start();
binding.cpiDownloading.animate().alpha(0).setDuration(200).start();
new Handler(Looper.getMainLooper()).postDelayed(() -> binding.cpiDownloading.setVisibility(View.GONE), 200);
});
}));
} else {
openAnBuiContentUrl(anbuiContentUrls);
}
} else {
Intent openurl = new Intent();
openurl.setAction(Intent.ACTION_VIEW);
openurl.setData(Uri.parse(getIntent().getStringExtra("getrom")));
startActivity(openurl);
}
}
private void openAnBuiContentUrl(String[] urls) {
if (isFinishing() || isDestroyed()) return;
Intent openurl = new Intent();
openurl.setAction(Intent.ACTION_VIEW);
if (urls != null && urls.length > 0 && !urls[0].isEmpty()) {
openurl.setData(Uri.parse(urls[new Random().nextInt(urls.length)]));
startActivity(openurl);
} else {
isAllowGetAnbuiContentUrls = false;
openurl.setData(Uri.parse(getIntent().getStringExtra("getrom")));
startActivity(openurl);
}
}
@NonNull
private String getArchName(String arch) {
return switch (arch) {

View file

@ -76,8 +76,7 @@ public class FileUtils {
uri.toString().startsWith("content://com.android.fileexplorer.myprovider") ||
uri.toString().startsWith("content://com.estrongs.files") ||
uri.toString().startsWith("content://me.zhanghai.android")) &&
uri.getPath() != null &&
isFileExists(uri.getPath())) {
uri.getPath() != null) {
String path = uri.getPath();
if (uri.toString().startsWith("content://com.android.fileexplorer.myprovider/external_files")) {
@ -86,7 +85,7 @@ public class FileUtils {
path = new File(Uri.decode(path).substring("file://".length())).getAbsolutePath();
}
return path;
if (isFileExists(path)) return path;
}
// check here to KITKAT or new version

View file

@ -44,19 +44,36 @@
android:orientation="horizontal"
android:padding="16dp">
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/colorCard">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivIcon"
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/cpi_downloading"
android:layout_width="84dp"
android:layout_height="84dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_computer_180dp_with_padding" />
</com.google.android.material.card.MaterialCardView>
android:layout_gravity="center"
android:indeterminate="true"
android:alpha="0"
app:indicatorSize="75dp"
android:visibility="gone"
tools:visibility="visible"/>
<com.google.android.material.card.MaterialCardView
android:id="@+id/cv_icon"
style="?attr/materialCardViewFilledStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/colorCard">
<ImageView
android:id="@+id/ivIcon"
android:layout_width="84dp"
android:layout_height="84dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_computer_180dp_with_padding" />
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"

View file

@ -5,11 +5,11 @@
"url": "https://github.com/xoureldeen/Vectras-VM-Android/releases",
"Message": "<h2>4.1.0</h2>\nBugs fixed.",
"cancellable": true,
"versionCodeBeta":"119",
"versionNameBeta":"4.1.5",
"versionNameBetas":"4.0.0,4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,4.0.7,4.0.8,4.0.9,4.1.0,4.1.1,4.1.2,4.1.3,4.1.4,4.1.5",
"versionCodeBeta":"120",
"versionNameBeta":"4.1.6",
"versionNameBetas":"4.0.0,4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,4.0.7,4.0.8,4.0.9,4.1.0,4.1.1,4.1.2,4.1.3,4.1.4,4.1.5,4.1.6",
"sizeBeta": "45 MB",
"urlBeta": "https://github.com/AnBui2004/Vectras-VM-Emu-Android/releases",
"MessageBeta": "<h2>4.1.5</h2>Bugs fixed.",
"MessageBeta": "<h2>4.1.6</h2>Bugs fixed.",
"cancellableBeta": true
}