mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
@@ -100,6 +100,10 @@ public class Main extends AndroidApplication {
|
|||||||
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
|
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needExternalFileAccess() {
|
||||||
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSystemProperty(String propName) {
|
public static String getSystemProperty(String propName) {
|
||||||
String line;
|
String line;
|
||||||
BufferedReader input = null;
|
BufferedReader input = null;
|
||||||
@@ -126,8 +130,7 @@ public class Main extends AndroidApplication {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
try {
|
try {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
} catch (Exception e) {
|
} catch (Exception ignore) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -214,7 +217,9 @@ public class Main extends AndroidApplication {
|
|||||||
text.setGravity(Gravity.LEFT);
|
text.setGravity(Gravity.LEFT);
|
||||||
text.setTypeface(Typeface.SERIF);
|
text.setTypeface(Typeface.SERIF);
|
||||||
String SP = "Storage Permission";
|
String SP = "Storage Permission";
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (needExternalFileAccess()) {
|
||||||
|
SP = "All File Access Permission";
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
SP = "Photos and Videos, Music and Audio Permissions";
|
SP = "Photos and Videos, Music and Audio Permissions";
|
||||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||||
SP = "Files & Media Permissions";
|
SP = "Files & Media Permissions";
|
||||||
@@ -226,8 +231,11 @@ public class Main extends AndroidApplication {
|
|||||||
" 2) Tap Permissions\n" +
|
" 2) Tap Permissions\n" +
|
||||||
" 3) Enable the " + SP + ".\n\n" +
|
" 3) Enable the " + SP + ".\n\n" +
|
||||||
"(You can tap anywhere to exit and restart the app)\n\n";
|
"(You can tap anywhere to exit and restart the app)\n\n";
|
||||||
|
String allFileAccessSteps = " 1) Tap \"App Settings\" Button.\n" +
|
||||||
|
" 2) Enable the " + SP + ".\n\n" +
|
||||||
|
"(You can tap anywhere to exit and restart the app)\n\n";
|
||||||
if (ex) {
|
if (ex) {
|
||||||
title = manageApp ? "Forge AutoUpdater Permission...\n" : "Forge didn't initialize!\n";
|
title = needExternalFileAccess() ? "All File Access Permission" : manageApp ? "Forge AutoUpdater Permission...\n" : "Forge didn't initialize!\n";
|
||||||
steps = manageApp ? " 1) Tap \"App Settings\" Button.\n" +
|
steps = manageApp ? " 1) Tap \"App Settings\" Button.\n" +
|
||||||
" 2) Enable \"Allow apps from this source\"\n" +
|
" 2) Enable \"Allow apps from this source\"\n" +
|
||||||
"(You can tap anywhere to exit and restart the app)\n\n" : msg + "\n\n";
|
"(You can tap anywhere to exit and restart the app)\n\n" : msg + "\n\n";
|
||||||
@@ -236,7 +244,7 @@ public class Main extends AndroidApplication {
|
|||||||
SpannableString ss1 = new SpannableString(title);
|
SpannableString ss1 = new SpannableString(title);
|
||||||
ss1.setSpan(new StyleSpan(Typeface.BOLD), 0, ss1.length(), 0);
|
ss1.setSpan(new StyleSpan(Typeface.BOLD), 0, ss1.length(), 0);
|
||||||
text.append(ss1);
|
text.append(ss1);
|
||||||
text.append(steps);
|
text.append(needExternalFileAccess() ? allFileAccessSteps : steps);
|
||||||
row.addView(text);
|
row.addView(text);
|
||||||
row.setGravity(Gravity.CENTER);
|
row.setGravity(Gravity.CENTER);
|
||||||
|
|
||||||
@@ -265,7 +273,16 @@ public class Main extends AndroidApplication {
|
|||||||
|
|
||||||
button.setTextColor(Color.RED);
|
button.setTextColor(Color.RED);
|
||||||
button.setOnClickListener(v -> {
|
button.setOnClickListener(v -> {
|
||||||
if (manageApp) {
|
if (needExternalFileAccess()) {
|
||||||
|
/*
|
||||||
|
This is needed for Android 11 and upwards to have access on external storage (direct file path)
|
||||||
|
ie adventure mode -> data -> restore. Though its not fast like the app-specific storage...
|
||||||
|
*/
|
||||||
|
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||||
|
intent.setData(uri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (manageApp) {
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES)
|
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES)
|
||||||
.setData(Uri.parse(String.format("package:%s", getPackageName())))
|
.setData(Uri.parse(String.format("package:%s", getPackageName())))
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@@ -301,7 +318,7 @@ public class Main extends AndroidApplication {
|
|||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
super.onAnimationEnd(animation);
|
super.onAnimationEnd(animation);
|
||||||
handler.postDelayed(() -> {
|
handler.postDelayed(() -> {
|
||||||
if (!permissiongranted || exception) {
|
if (needExternalFileAccess() || !permissiongranted || exception) {
|
||||||
displayMessage(forgeLogo, adapter, exception, msg, false);
|
displayMessage(forgeLogo, adapter, exception, msg, false);
|
||||||
} else if (title.isEmpty() && steps.isEmpty()) {
|
} else if (title.isEmpty() && steps.isEmpty()) {
|
||||||
if (isLandscape) {
|
if (isLandscape) {
|
||||||
|
|||||||
Reference in New Issue
Block a user