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 <gradient
android:type="linear" android:type="linear"
android:angle="135" android:angle="135"
android:startColor="#24476B" android:startColor="#FFFFFF"
android:endColor="#0C335B" /> android:endColor="#FFFFFF" />
</shape> </shape>

View File

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

View File

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

View File

@@ -3,6 +3,7 @@ package forge.app;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
@@ -31,6 +32,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler;
import android.provider.Settings; import android.provider.Settings;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; 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) { 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 { try {
final Handler handler = new Handler();
forgeLogo = findViewById(getResources().getIdentifier("logo_id", "id", getPackageName())); 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); 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 @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation); super.onAnimationEnd(animation);
handler.postDelayed(() -> {
if (!permissiongranted || exception) { if (!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()) {
@@ -383,6 +390,7 @@ public class Main extends AndroidApplication {
TL.setGravity(Gravity.CENTER); TL.setGravity(Gravity.CENTER);
crossfade(TL, forgeLogo); crossfade(TL, forgeLogo);
} }
}, 600);
} }
}).start(); }).start();
} catch (Exception e) { } catch (Exception e) {
@@ -393,9 +401,8 @@ public class Main extends AndroidApplication {
private AnimatorSet getAnimator(Animator play, Animator with, AnimatorListenerAdapter adapter) { private AnimatorSet getAnimator(Animator play, Animator with, AnimatorListenerAdapter adapter) {
AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet animatorSet = new AnimatorSet();
if (with != null) { if (with != null) {
animatorSet.playTogether(play, with); animatorSet.playSequentially(play, with);
} } else
else
animatorSet.play(play); animatorSet.play(play);
animatorSet.addListener(adapter); animatorSet.addListener(adapter);
return animatorSet; return animatorSet;
@@ -465,9 +472,11 @@ public class Main extends AndroidApplication {
adapter.switchOrientationFile = ASSETS_DIR + "switch_orientation.ini"; adapter.switchOrientationFile = ASSETS_DIR + "switch_orientation.ini";
boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile); 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() 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\nMinimum Requirements:" : ""; + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB\n\nRecommended API:" : "";
String lowV = Build.VERSION.SDK_INT < Build.VERSION_CODES.Q ? "\nAPI: Android 10 or higher" : ""; // 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" : ""; String lowM = totalRAM < 3500 ? "\nRAM: 4GB RAM or higher" : "";
if (landscapeMode && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { //Android 11 onwards if (landscapeMode && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { //Android 11 onwards
Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
@@ -578,12 +587,15 @@ public class Main extends AndroidApplication {
connected = false; connected = false;
} }
} }
private boolean hasInternet() { private boolean hasInternet() {
return isNetworkConnected(false); return isNetworkConnected(false);
} }
private boolean hasWiFiInternet() { private boolean hasWiFiInternet() {
return isNetworkConnected(true); return isNetworkConnected(true);
} }
private boolean isNetworkConnected(boolean wifiOnly) { private boolean isNetworkConnected(boolean wifiOnly) {
boolean result = false; boolean result = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -612,6 +624,7 @@ public class Main extends AndroidApplication {
} }
return result; return result;
} }
@Override @Override
public boolean isConnectedToInternet() { public boolean isConnectedToInternet() {
//if it can't determine Internet connection within two seconds, assume not connected //if it can't determine Internet connection within two seconds, assume not connected