Skip to content

Commit

Permalink
Added level selection, changed to Chinese language.
Browse files Browse the repository at this point in the history
  • Loading branch information
nov30th committed Oct 13, 2024
1 parent 233c7e8 commit e883951
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 54 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "im.hoho.alipayInstallB"
minSdkVersion 23
targetSdkVersion 33
versionCode 105
versionName "2.5.3"
versionCode 107
versionName "2.5.4"
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
namespace 'im.hoho.alipayInstallB'
Expand Down
106 changes: 87 additions & 19 deletions app/src/main/java/im/hoho/alipayInstallB/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -14,9 +13,12 @@
import android.os.Looper;
import android.provider.Settings;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -43,13 +45,14 @@ public class MainActivity extends Activity {
private static final int PERMISSION_REQUEST_CODE = 1001;
private static final String DOWNLOAD_URL = "https://github.com/nov30th/AlipayHighHeadsomeRichAndroid/raw/master/SD%E5%8D%A1%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6%E5%8C%85/SD%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6.zip";
private static final String EXTRACT_PATH = Environment.getExternalStorageDirectory() + "/Android/media/com.eg.android.AlipayGphone/";
private final String[] memberGrades = {"原有", "普通 (primary)", "黄金 (golden)", "铂金 (platinum)", "钻石 (diamond)"};
private Button btnExport, btnDelete, btnUpdate, btnActivate;
private ImageView ivExportStatus, ivDeleteStatus, ivUpdateStatus, ivActivateStatus;
private Button btnDownload;
private ProgressBar progressBar;
private ExecutorService executorService;
private Handler mainHandler;
// private TextView tvPluginStatus;
private Spinner spinnerMemberGrade;

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
Expand All @@ -75,21 +78,8 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// tvPluginStatus = findViewById(R.id.tvPluginStatus);
// updatePluginStatus();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
}
spinnerMemberGrade = findViewById(R.id.spinnerMemberGrade);
setupMemberGradeSpinner();


TextView tvVersion = findViewById(R.id.tvVersion);
Expand Down Expand Up @@ -227,7 +217,7 @@ private void updateStatuses() {
updateStatus(ivUpdateStatus, UPDATE_FILE);
updateStatus(ivActivateStatus, ACTIVATE_FILE);

btnActivate.setText(new File(ACTIVATE_FILE).exists() ? "Deactivate" : "Activate");
btnActivate.setText(new File(ACTIVATE_FILE).exists() ? "点击禁用皮肤" : "点击启用皮肤");
}

private void updateStatus(ImageView imageView, String filePath) {
Expand All @@ -236,10 +226,23 @@ private void updateStatus(ImageView imageView, String filePath) {

private void updateDownloadButtonText() {
File skinFolder = new File(EXTRACT_PATH + "000_HOHO_ALIPAY_SKIN");
btnDownload.setText(skinFolder.exists() ? "Redownload Resources (GITHUB)" : "Download Resources (GITHUB)");
btnDownload.setText(skinFolder.exists() ? "重新下载资源包 (Github) 需要SD卡权限" : "下载资源包 (Github) 需要SD卡权限");
}

private void downloadAndExtract() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
}

btnDownload.setEnabled(false);
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(0);
Expand Down Expand Up @@ -319,4 +322,69 @@ protected void onDestroy() {
executorService.shutdown();
}
}

private void setupMemberGradeSpinner() {
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, memberGrades);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerMemberGrade.setAdapter(adapter);

// 设置当前选中的等级
String currentGrade = getCurrentMemberGrade();
int position = adapter.getPosition(currentGrade);
spinnerMemberGrade.setSelection(position);

spinnerMemberGrade.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedGrade = parent.getItemAtPosition(position).toString();
updateMemberGrade(selectedGrade);
}

@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}

private String getCurrentMemberGrade() {
for (String grade : memberGrades) {
if (grade.equals("原有")) continue;
String folderName = "level_" + grade.split(" ")[1].replace("(", "").replace(")", "");
File folder = new File(EXTERNAL_STORAGE_PATH, folderName);
if (folder.exists()) {
return grade;
}
}
return "原有";
}

private void updateMemberGrade(String selectedGrade) {
// 删除所有 level_ 文件夹
for (String grade : memberGrades) {
if (grade.equals("原有")) continue;
String folderName = "level_" + grade.split(" ")[1].replace("(", "").replace(")", "");
File folder = new File(EXTERNAL_STORAGE_PATH, folderName);
if (folder.exists()) {
deleteRecursive(folder);
}
}

// 如果选择不是"原有",创建新的 level_ 文件夹
if (!selectedGrade.equals("原有")) {
String folderName = "level_" + selectedGrade.split(" ")[1].replace("(", "").replace(")", "");
File newFolder = new File(EXTERNAL_STORAGE_PATH, folderName);
newFolder.mkdirs();
}

Toast.makeText(this, "会员等级已更新为:" + selectedGrade, Toast.LENGTH_SHORT).show();
}

private void deleteRecursive(File fileOrDirectory) {
if (fileOrDirectory.isDirectory()) {
for (File child : fileOrDirectory.listFiles()) {
deleteRecursive(child);
}
}
fileOrDirectory.delete();
}
}
38 changes: 27 additions & 11 deletions app/src/main/java/im/hoho/alipayInstallB/PluginMain.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package im.hoho.alipayInstallB;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Environment;
Expand All @@ -19,7 +18,6 @@

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
Expand All @@ -28,15 +26,15 @@
* Created by qzj_ on 2016/5/9.
*/
public class PluginMain implements IXposedHookLoadPackage {
private static final String EXTERNAL_STORAGE_PATH = Environment.getExternalStorageDirectory() + "/Android/media/com.eg.android.AlipayGphone/000_HOHO_ALIPAY_SKIN";
private static final String packageName = "com.eg.android.AlipayGphone";
public static volatile boolean isModuleLoaded = false;

private static final String packageName = "com.eg.android.AlipayGphone";
public PluginMain() {
XposedBridge.log("Now Loading HOHO`` alipay plugin...");
}



@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

Expand All @@ -51,13 +49,18 @@ public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) thr
XposedHelpers.findAndHookMethod("com.alipay.mobilegw.biz.shared.processer.login.UserLoginResult", lpparam.classLoader, "getExtResAttrs", new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param1MethodHookParam) throws Throwable {
XposedBridge.log("Now, let's install B...");
String diamond = "diamond";
Map<String, String> map = (Map) param1MethodHookParam.getResult();
if (map.containsKey("memberGrade")) {
XposedBridge.log("Original member grade: " + map.get("memberGrade"));
XposedBridge.log("Putting " + diamond + " into dict...");
map.put("memberGrade", diamond);
XposedBridge.log("Member grade changed to: " + map.get("memberGrade"));

String newGrade = getCurrentMemberGrade();
if (!newGrade.equals("原有")) {
XposedBridge.log("Putting " + newGrade + " into dict...");
map.put("memberGrade", newGrade);
XposedBridge.log("Member grade changed to: " + map.get("memberGrade"));
} else {
XposedBridge.log("Member grade not modified.");
}
} else {
XposedBridge.log("Can not get the member grade in return value...WTF?");
}
Expand All @@ -67,7 +70,9 @@ protected void afterHookedMethod(MethodHookParam param1MethodHookParam) throws T
XposedHelpers.findAndHookMethod("android.app.Activity", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (isDbUpdated[0]) {
String newGrade = getCurrentMemberGrade();

if (isDbUpdated[0] || newGrade.equals("原有")) {
return;
}
Context context = (Context) param.thisObject; // 获取到Activity作为Context
Expand All @@ -76,8 +81,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (dbFile.exists()) {
XposedBridge.log("GET DATABASE: " + context.getDatabasePath("alipayclient.db").getParentFile());
try (SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READWRITE)) {
// 将本来的普通会员直接替换为钻石会员
db.execSQL("UPDATE 'main'.'userinfo' SET 'memberGrade' = 'diamond'");
// 将本来的普通会员直接替换
db.execSQL("UPDATE 'main'.'userinfo' SET 'memberGrade' = '" + newGrade + "'");
XposedBridge.log("Database update successful!");
} catch (Exception e) {
XposedBridge.log("Database update error: " + e);
Expand Down Expand Up @@ -265,4 +270,15 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

}

private String getCurrentMemberGrade() {
String[] grades = {"primary", "golden", "platinum", "diamond", "unknown"};
for (String grade : grades) {
File folder = new File(EXTERNAL_STORAGE_PATH, "level_" + grade);
if (folder.exists()) {
return grade;
}
}
return "原有";
}
}
Loading

0 comments on commit e883951

Please sign in to comment.