v1.3.0: renamed AndroidGame to AndroidLauncher and added activity to handle missing natives
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
android:fullBackupOnly="true"
|
android:fullBackupOnly="true"
|
||||||
android:backupAgent=".AndroidBackupHandler">
|
android:backupAgent=".AndroidBackupHandler">
|
||||||
<activity
|
<activity
|
||||||
android:name=".AndroidGame"
|
android:name=".AndroidLauncher"
|
||||||
android:screenOrientation="nosensor"
|
android:screenOrientation="nosensor"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
|
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
@@ -42,6 +42,9 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".AndroidMissingNativesHandler">
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,13 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.android;
|
package com.shatteredpixel.shatteredpixeldungeon.android;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Files;
|
import com.badlogic.gdx.Files;
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
@@ -48,12 +46,13 @@ import com.watabou.noosa.Game;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||||
import com.watabou.utils.FileUtils;
|
import com.watabou.utils.FileUtils;
|
||||||
|
|
||||||
public class AndroidGame extends AndroidApplication {
|
public class AndroidLauncher extends AndroidApplication {
|
||||||
|
|
||||||
public static AndroidApplication instance;
|
public static AndroidApplication instance;
|
||||||
|
|
||||||
private static AndroidPlatformSupport support;
|
private static AndroidPlatformSupport support;
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate (Bundle savedInstanceState) {
|
protected void onCreate (Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -62,17 +61,10 @@ public class AndroidGame extends AndroidApplication {
|
|||||||
GdxNativesLoader.load();
|
GdxNativesLoader.load();
|
||||||
FreeType.initFreeType();
|
FreeType.initFreeType();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
TextView text = new TextView(this);
|
AndroidMissingNativesHandler.errorMsg = e.getMessage();
|
||||||
text.setText("Shattered Pixel Dungeon cannot start because some of its code is missing!\n\n" +
|
Intent intent = new Intent(this, AndroidMissingNativesHandler.class);
|
||||||
"This usually happens when the Google Play version of the game is installed from somewhere outside of Google Play.\n\n" +
|
startActivity(intent);
|
||||||
"If you're unsure of how to fix this, please email the developer (Evan@ShatteredPixel.com), and include this error message:\n\n" +
|
finish();
|
||||||
e.getMessage());
|
|
||||||
text.setTextSize(16);
|
|
||||||
text.setTextColor(0xFFFFFFFF);
|
|
||||||
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/pixel_font.ttf"));
|
|
||||||
text.setGravity(Gravity.CENTER_VERTICAL);
|
|
||||||
text.setPadding(10, 10, 10, 10);
|
|
||||||
setContentView(text);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* Shattered Pixel Dungeon
|
||||||
|
* Copyright (C) 2014-2022 Evan Debenham
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.android;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class AndroidMissingNativesHandler extends Activity {
|
||||||
|
|
||||||
|
public static String errorMsg = "";
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
TextView text = new TextView(this);
|
||||||
|
text.setText("Shattered Pixel Dungeon cannot start because some of its code is missing!\n\n" +
|
||||||
|
"This usually happens when the Google Play version of the game is installed from somewhere outside of Google Play.\n\n" +
|
||||||
|
"If you're unsure of how to fix this, please email the developer (Evan@ShatteredPixel.com), and include this error message:\n\n" +
|
||||||
|
errorMsg);
|
||||||
|
text.setTextSize(16);
|
||||||
|
text.setTextColor(0xFFFFFFFF);
|
||||||
|
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/pixel_font.ttf"));
|
||||||
|
text.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
text.setPadding(10, 10, 10, 10);
|
||||||
|
setContentView(text);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
|
|
||||||
public void updateDisplaySize(){
|
public void updateDisplaySize(){
|
||||||
if (SPDSettings.landscape() != null) {
|
if (SPDSettings.landscape() != null) {
|
||||||
AndroidGame.instance.setRequestedOrientation( SPDSettings.landscape() ?
|
AndroidLauncher.instance.setRequestedOrientation( SPDSettings.landscape() ?
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE :
|
||||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT );
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
Game.dispHeight = view.getMeasuredHeight();
|
Game.dispHeight = view.getMeasuredHeight();
|
||||||
|
|
||||||
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||||
|| !AndroidGame.instance.isInMultiWindowMode();
|
|| !AndroidLauncher.instance.isInMultiWindowMode();
|
||||||
|
|
||||||
if (fullscreen && SPDSettings.landscape() != null
|
if (fullscreen && SPDSettings.landscape() != null
|
||||||
&& (Game.dispWidth >= Game.dispHeight) != SPDSettings.landscape()){
|
&& (Game.dispWidth >= Game.dispHeight) != SPDSettings.landscape()){
|
||||||
@@ -98,7 +98,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
final int finalH = Math.round(renderHeight);
|
final int finalH = Math.round(renderHeight);
|
||||||
if (finalW != Game.width || finalH != Game.height){
|
if (finalW != Game.width || finalH != Game.height){
|
||||||
|
|
||||||
AndroidGame.instance.runOnUiThread(new Runnable() {
|
AndroidLauncher.instance.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
view.getHolder().setFixedSize(finalW, finalH);
|
view.getHolder().setFixedSize(finalW, finalH);
|
||||||
@@ -107,7 +107,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AndroidGame.instance.runOnUiThread(new Runnable() {
|
AndroidLauncher.instance.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
view.getHolder().setSizeFromLayout();
|
view.getHolder().setSizeFromLayout();
|
||||||
@@ -118,29 +118,29 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
|
|
||||||
public void updateSystemUI() {
|
public void updateSystemUI() {
|
||||||
|
|
||||||
AndroidGame.instance.runOnUiThread(new Runnable() {
|
AndroidLauncher.instance.runOnUiThread(new Runnable() {
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
boolean fullscreen = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
|
||||||
|| !AndroidGame.instance.isInMultiWindowMode();
|
|| !AndroidLauncher.instance.isInMultiWindowMode();
|
||||||
|
|
||||||
if (fullscreen){
|
if (fullscreen){
|
||||||
AndroidGame.instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
AndroidLauncher.instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
} else {
|
} else {
|
||||||
AndroidGame.instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
AndroidLauncher.instance.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
|
||||||
if (SPDSettings.fullscreen()) {
|
if (SPDSettings.fullscreen()) {
|
||||||
AndroidGame.instance.getWindow().getDecorView().setSystemUiVisibility(
|
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY );
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY );
|
||||||
} else {
|
} else {
|
||||||
AndroidGame.instance.getWindow().getDecorView().setSystemUiVisibility(
|
AndroidLauncher.instance.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean connectedToUnmeteredNetwork() {
|
public boolean connectedToUnmeteredNetwork() {
|
||||||
//Returns true if using unmetered connection, use shortcut method if available
|
//Returns true if using unmetered connection, use shortcut method if available
|
||||||
ConnectivityManager cm = (ConnectivityManager) AndroidGame.instance.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) AndroidLauncher.instance.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
||||||
return !cm.isActiveNetworkMetered();
|
return !cm.isActiveNetworkMetered();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user