v0.7.5b: added a new android launcher activity which handles missing natives

This commit is contained in:
Evan Debenham 2019-10-12 18:29:26 -04:00
parent b86d7572c8
commit 2b6e79599d
2 changed files with 70 additions and 3 deletions

View File

@ -25,14 +25,18 @@
android:backupAgent=".AndroidBackupHandler"> android:backupAgent=".AndroidBackupHandler">
<activity <activity
android:label="${appName}" android:label="${appName}"
android:name=".AndroidGame" android:name=".AndroidLauncher">
android:screenOrientation="nosensor"
android:configChanges="keyboard|keyboardHidden|orientation">
<intent-filter > <intent-filter >
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:label="${appName}"
android:name=".AndroidGame"
android:screenOrientation="nosensor"
android:configChanges="keyboard|keyboardHidden|orientation">
</activity>
</application> </application>

View File

@ -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 <http://www.gnu.org/licenses/>
*/
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);
}
}
}