update android bg, min spec

This commit is contained in:
Anthony Calosa
2024-10-31 20:45:20 +08:00
parent 52d77c6862
commit c55c07b8dd
4 changed files with 116 additions and 104 deletions

View File

@@ -3,6 +3,6 @@
<gradient
android:type="linear"
android:angle="135"
android:startColor="#24476B"
android:endColor="#0C335B" />
android:startColor="#FFFFFF"
android:endColor="#FFFFFF" />
</shape>

View File

@@ -3,14 +3,13 @@
android:id="@+id/mainview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@color/splashBackground">
android:gravity="center">
<ImageView
android:id="@+id/logo_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="400dp"
android:maxHeight="250dp"
android:adjustViewBounds="true"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo"/>

View File

@@ -4,5 +4,5 @@
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="blue">#258cec</color>
<color name="splashBackground">#000000</color>
<color name="splashBackground">#FFFFFF</color>
</resources>

View File

@@ -3,6 +3,7 @@ package forge.app;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.ActivityManager;
@@ -31,6 +32,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.Settings;
import android.text.SpannableString;
import android.text.TextUtils;
@@ -293,12 +295,17 @@ public class Main extends AndroidApplication {
private void loadGame(final String title, final String steps, boolean isLandscape, AndroidAdapter adapter, boolean permissiongranted, int totalRAM, boolean isTabletDevice, AndroidApplicationConfiguration config, boolean exception, String msg) {
try {
final Handler handler = new Handler();
forgeLogo = findViewById(getResources().getIdentifier("logo_id", "id", getPackageName()));
activeView = findViewById(getResources().getIdentifier("mainview", "id", getPackageName()));
activeView.setBackgroundColor(Color.WHITE);
forgeView = initializeForView(Forge.getApp(getAndroidClipboard(), adapter, ASSETS_DIR, false, !isLandscape, totalRAM, isTabletDevice, Build.VERSION.SDK_INT, Build.VERSION.RELEASE, getDeviceName()), config);
getAnimator(ObjectAnimator.ofFloat(forgeLogo, "alpha", 0f, 1f).setDuration(1800), null, new AnimatorListenerAdapter() {
getAnimator(ObjectAnimator.ofFloat(forgeLogo, "alpha", 1f, 1f).setDuration(800), ObjectAnimator.ofObject(activeView, "backgroundColor", new ArgbEvaluator(), Color.WHITE, Color.BLACK).setDuration(1600), new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
handler.postDelayed(() -> {
if (!permissiongranted || exception) {
displayMessage(forgeLogo, adapter, exception, msg, false);
} else if (title.isEmpty() && steps.isEmpty()) {
@@ -383,6 +390,7 @@ public class Main extends AndroidApplication {
TL.setGravity(Gravity.CENTER);
crossfade(TL, forgeLogo);
}
}, 600);
}
}).start();
} catch (Exception e) {
@@ -393,9 +401,8 @@ public class Main extends AndroidApplication {
private AnimatorSet getAnimator(Animator play, Animator with, AnimatorListenerAdapter adapter) {
AnimatorSet animatorSet = new AnimatorSet();
if (with != null) {
animatorSet.playTogether(play, with);
}
else
animatorSet.playSequentially(play, with);
} else
animatorSet.play(play);
animatorSet.addListener(adapter);
return animatorSet;
@@ -465,9 +472,11 @@ public class Main extends AndroidApplication {
adapter.switchOrientationFile = ASSETS_DIR + "switch_orientation.ini";
boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile);
String info = totalRAM < 3500 || Build.VERSION.SDK_INT < Build.VERSION_CODES.Q ? "Device Specification Check\n" + getDeviceName()
+ "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB\n\nMinimum Requirements:" : "";
String lowV = Build.VERSION.SDK_INT < Build.VERSION_CODES.Q ? "\nAPI: Android 10 or higher" : "";
String info = totalRAM < 3500 || Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? "Device Specification Check\n" + getDeviceName()
+ "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB\n\nRecommended API:" : "";
// Even though Forge runs on Android 8 as minimum, just show indicator that Android 11 is recommended
String lowV = Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? "\nAPI: Android 11 or higher" : "";
// also show minimum Device RAM
String lowM = totalRAM < 3500 ? "\nRAM: 4GB RAM or higher" : "";
if (landscapeMode && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { //Android 11 onwards
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
@@ -578,12 +587,15 @@ public class Main extends AndroidApplication {
connected = false;
}
}
private boolean hasInternet() {
return isNetworkConnected(false);
}
private boolean hasWiFiInternet() {
return isNetworkConnected(true);
}
private boolean isNetworkConnected(boolean wifiOnly) {
boolean result = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -612,6 +624,7 @@ public class Main extends AndroidApplication {
}
return result;
}
@Override
public boolean isConnectedToInternet() {
//if it can't determine Internet connection within two seconds, assume not connected