Merge branch 'master' into 'master'

Prevent rendering issue and adjust screen timeout when downloading resource

See merge request core-developers/forge!2055
This commit is contained in:
Michael Kamensky
2019-08-25 04:25:05 +00:00
3 changed files with 14 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
@@ -14,14 +15,14 @@
<application
android:allowBackup="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:largeHeap="true">
<activity
android:name=".Main"
android:label="@string/app_name">
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

View File

@@ -17,6 +17,8 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.PowerManager;
import android.provider.Settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import com.badlogic.gdx.Gdx;
@@ -35,6 +37,8 @@ import java.io.OutputStream;
import java.util.concurrent.Callable;
public class Main extends AndroidApplication {
public int time = -2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -235,13 +239,17 @@ public class Main extends AndroidApplication {
@Override
public void preventSystemSleep(final boolean preventSleep) {
if (time == -2)
time = Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, 0);
FThreads.invokeInEdtNowOrLater(new Runnable() { //must set window flags from EDT thread
@Override
public void run() {
if (preventSleep) {
Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, Integer.MAX_VALUE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
else {
Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, time);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}

View File

@@ -255,7 +255,9 @@ public abstract class GuiDownloadService implements Runnable {
byte[] buffer = new byte[1024];
for (Entry<String, String> kv : files.entrySet()) {
if (cancel) { break; }
if (cancel) {//stop prevent sleep
GuiBase.getInterface().preventSystemSleep(false);
break; }
count++;
cardSkipped = true; //assume skipped unless saved successfully