v0.8.0: added an update notification service

This commit is contained in:
Evan Debenham
2019-11-22 15:05:47 -05:00
parent 2e533b74db
commit 2138ad24ec
24 changed files with 606 additions and 13 deletions

View File

@@ -6,6 +6,8 @@
<uses-feature android:glEsVersion="0x00020000"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Note that the game doesn't truly support small screen resolutions,
it instead forces downscaling to work on these displays.-->

View File

@@ -32,6 +32,8 @@ import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.UpdateImpl;
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
import com.watabou.noosa.Game;
import com.watabou.utils.FileUtils;
@@ -58,9 +60,13 @@ public class AndroidGame extends AndroidApplication {
} catch (PackageManager.NameNotFoundException e) {
Game.versionCode = 0;
}
if (UpdateImpl.supportsUpdates()){
Updates.service = UpdateImpl.getUpdateService();
}
FileUtils.setDefaultFileProperties( Files.FileType.Local, "" );
// grab preferences directly using our instance first
// so that we don't need to rely on Gdx.app, which isn't initialized yet.
SPDSettings.set(instance.getPreferences("ShatteredPixelDungeon"));
@@ -91,7 +97,7 @@ public class AndroidGame extends AndroidApplication {
initialize(new ShatteredPixelDungeon(support), config);
view = (GLSurfaceView)graphics.getView();
}
@Override

View File

@@ -22,7 +22,10 @@
package com.shatteredpixel.shatteredpixeldungeon.android;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
@@ -140,6 +143,23 @@ public class AndroidPlatformSupport extends PlatformSupport {
}
@Override
@SuppressWarnings("deprecation")
public boolean connectedToUnmeteredNetwork() {
//Returns true if using unmetered connection, use shortcut method if available
ConnectivityManager cm = (ConnectivityManager) AndroidGame.instance.getSystemService(Context.CONNECTIVITY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
return !cm.isActiveNetworkMetered();
} else {
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnectedOrConnecting() &&
(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI
|| activeNetwork.getType() == ConnectivityManager.TYPE_WIMAX
|| activeNetwork.getType() == ConnectivityManager.TYPE_BLUETOOTH
|| activeNetwork.getType() == ConnectivityManager.TYPE_ETHERNET);
}
}
@Override
public void promptTextInput(final String title, final String hintText, final int maxLen, final boolean multiLine, final String posTxt, final String negTxt, final TextCallback callback) {
Game.runOnRenderThread( new Callback() {