Skip to content

Commit

Permalink
fix run app in all mobile 32bit
Browse files Browse the repository at this point in the history
  • Loading branch information
HanzoDev1375 committed Jul 4, 2024
1 parent 851717f commit b3f8251
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package ninjacoder.ghostide.androidtools.r8.android;

import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Environment;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class BackgroundUtil {

public static void saveSystemWallpaper(Context context) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);

// دریافت Drawable پس‌زمینه سیستمی
Drawable wallpaperDrawable = wallpaperManager.getDrawable();

if (wallpaperDrawable != null) {
// تبدیل Drawable به Bitmap
Bitmap wallpaperBitmap = Bitmap.createBitmap(wallpaperDrawable.getIntrinsicWidth(),
wallpaperDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

// رسم Drawable بر روی Bitmap
wallpaperDrawable.setBounds(0, 0, wallpaperBitmap.getWidth(), wallpaperBitmap.getHeight());
wallpaperDrawable.draw(new Canvas(wallpaperBitmap));

// ذخیره پس‌زمینه در مسیر دلخواه
saveBitmapToFile(context, wallpaperBitmap);
}
}

private static void saveBitmapToFile(Context context, Bitmap bitmap) {
// مسیر ذخیره فایل
String directoryPath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
.getAbsolutePath();
String fileName = "system_wallpaper.png";
File file = new File(directoryPath, fileName);

FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();

// اعلام موفقیت ذخیره سازی
// می‌توانید از اینجا یک پیام Toast یا Log برای نمایش پیام استفاده کنید
// Toast.makeText(context, "پس‌زمینه سیستمی با موفقیت ذخیره شد: " + file.getAbsolutePath(),
// Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
// اعلام خطا در صورت شکست ذخیره سازی
// می‌توانید از اینجا یک پیام Toast یا Log برای نمایش پیام استفاده کنید
// Toast.makeText(context, "خطا در ذخیره سازی پس‌زمینه سیستمی", Toast.LENGTH_SHORT).show();
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
141 changes: 83 additions & 58 deletions app/src/main/java/Ninja/coder/Ghostemane/code/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void onCreate(Bundle _savedInstanceState) {
},
1000);
} else {
initializeLogic();
tryToRunApp();
}
}

Expand All @@ -73,84 +73,109 @@ public void onRequestPermissionsResult(
int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1000) {
initializeLogic();
tryToRunApp();
}
}

private void initialize(Bundle _savedInstanceState) {
setac = getSharedPreferences("setac", Activity.MODE_PRIVATE);
ThemeChaker();
}

private void initializeLogic() {
private void tryToRunApp() {
ThemeChaker();
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/.icon");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/android");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/theme");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/ninjacoder");
FileUtil.makeDir("/storage/emulated/0/ghostweb/icon/vector");
FileUtil.makeDir("/storage/emulated/0/ghostweb/icon/svg");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/font");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/apk");
var mypath = getFilesDir().getAbsolutePath() + "/" + "databins";

if (!FileUtil.isExistFile(mypath)) {
nameFile("databins.7z");

} else if (!FileUtil.isExistFile(
getFilesDir().getAbsolutePath() + File.separator + "files" + File.separator + "env.sh")) {
nameFile("python.7z");
// start
} else {
try {
if (!FileUtil.isExistFile(mypath)) {
nameFile("databins.7z");

} else if (!FileUtil.isExistFile(
getFilesDir().getAbsolutePath() + File.separator + "files" + File.separator + "env.sh")) {
nameFile("python.7z");
// start
} else {
startApp();
}
} catch (Exception err) {
Log.e("Error", err.getLocalizedMessage());
startApp();
}
if (!FileUtil.isExistFile(
getFilesDir().getAbsolutePath() + File.separator + "lib" + File.separator + "libx265.so")) {
nameFile("lib.7z");
} else {

try {
if (!FileUtil.isExistFile(
getFilesDir().getAbsolutePath()
+ File.separator
+ "lib"
+ File.separator
+ "libx265.so")) {
nameFile("lib.7z");
} else {
startApp();
}
} catch (Exception err) {
Log.e("Error ", err.getLocalizedMessage());
startApp();
}
if (!FileUtil.isExistFile("/storage/emulated/0/GhostWebIDE/theme/GhostThemeapp.ghost")) {
SetThemeForJson.winterToPath();
} else {
Log.e("File is ExistFile", "");

try {
if (!FileUtil.isExistFile("/storage/emulated/0/GhostWebIDE/theme/GhostThemeapp.ghost")) {
SetThemeForJson.winterToPath();
} else {
Log.e("File is ExistFile", "");
startApp();
}
} catch (Exception err) {
Log.e("Error ", err.getLocalizedMessage());
startApp();
}

if (!FileUtil.isExistFile("/storage/emulated/0/GhostWebIDE/android/android.jar")) {
var asster = getAssets();
Z7Extractor.extractAsset(
asster,
"android.7z",
"/storage/emulated/0/GhostWebIDE/android/",
new IExtractCallback() {

@Override
public void onError(int arg0, String arg1) {}

@Override
public void onGetFileNum(int arg0) {}

@Override
public void onProgress(String arg0, long arg1) {}

@Override
public void onStart() {}

@Override
public void onSucceed() {
Toast.makeText(MainActivity.this, "done", Toast.LENGTH_SHORT).show();
}
});
} else {

try {
if (!FileUtil.isExistFile("/storage/emulated/0/GhostWebIDE/android/android.jar")) {
var asster = getAssets();
Z7Extractor.extractAsset(
asster,
"android.7z",
"/storage/emulated/0/GhostWebIDE/android/",
new IExtractCallback() {

@Override
public void onError(int arg0, String arg1) {}

@Override
public void onGetFileNum(int arg0) {}

@Override
public void onProgress(String arg0, long arg1) {}

@Override
public void onStart() {}

@Override
public void onSucceed() {
Toast.makeText(MainActivity.this, "done", Toast.LENGTH_SHORT).show();
}
});
} else {
startApp();
}
} catch (Exception err) {
Log.e("Error ", err.getLocalizedMessage());
startApp();
}

if (!FileUtil.isExistFile(getFilesDir().getAbsolutePath() + File.separator + "php.ini")) {
var softApi = new AssetsSoft();
softApi.copyOneFileFromAssets("php.ini", getFilesDir().getAbsolutePath() + "/", this);
} else Log.e("File Copyed", AssetsSoft.class.getSimpleName());

FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/.icon");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/android");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/theme");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/ninjacoder");
FileUtil.makeDir("/storage/emulated/0/ghostweb/icon/vector");
FileUtil.makeDir("/storage/emulated/0/ghostweb/icon/svg");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/font");
FileUtil.makeDir("/storage/emulated/0/GhostWebIDE/apk");
}

void startApp() {
Expand Down Expand Up @@ -195,7 +220,7 @@ void nameFile(String name) {

@Override
public void onError(int arg0, String arg1) {
startApp();
runOnUiThread(() -> startApp());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2015,13 +2015,7 @@ public int getItemCount() {
return _data.size();
}

boolean isSize() {
for (int i = _data.size() - 1; i >= 0; i--) {
return true;
}
return false;
}


public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View v) {
super(v);
Expand Down
Binary file modified app/src/main/jniLibs/arm64-v8a/libun7zip.so
Binary file not shown.
Binary file modified app/src/main/jniLibs/armeabi-v7a/libun7zip.so
Binary file not shown.
Binary file modified app/src/main/jniLibs/x86/libun7zip.so
Binary file not shown.
Binary file modified app/src/main/jniLibs/x86_64/libun7zip.so
Binary file not shown.

0 comments on commit b3f8251

Please sign in to comment.