From 2b6e79599da582e360237fd12247a174c03e8fa3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 12 Oct 2019 18:29:26 -0400 Subject: [PATCH] v0.7.5b: added a new android launcher activity which handles missing natives --- android/src/main/AndroidManifest.xml | 10 ++- .../android/AndroidLauncher.java | 63 +++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 298475f14..c162fa2cb 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -25,14 +25,18 @@ android:backupAgent=".AndroidBackupHandler"> + android:name=".AndroidLauncher"> + + diff --git a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java new file mode 100644 index 000000000..e8f62e5c6 --- /dev/null +++ b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java @@ -0,0 +1,63 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2019 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 + */ + +package com.shatteredpixel.shatteredpixeldungeon.android; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Intent; +import android.graphics.Typeface; +import android.os.Bundle; +import android.view.Gravity; +import android.widget.TextView; + +import com.badlogic.gdx.graphics.g2d.freetype.FreeType; +import com.badlogic.gdx.utils.GdxNativesLoader; + +public class AndroidLauncher extends Activity { + + @SuppressLint("SetTextI18n") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + try { + GdxNativesLoader.load(); + FreeType.initFreeType(); + + Intent intent = new Intent(this, AndroidGame.class); + startActivity(intent); + finish(); + } catch (Exception e){ + 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" + + e.getMessage()); + text.setTextSize(16); + text.setTextColor(0xFFFFFFFF); + text.setTypeface(Typeface.createFromAsset(getAssets(), "pixel_font.ttf")); + text.setGravity(Gravity.CENTER_VERTICAL); + text.setPadding(10, 10, 10, 10); + setContentView(text); + } + } +}