From 200f8906d8565f0ac15f1b63b840ef264183a60b Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 15 Jul 2020 08:13:06 +0530 Subject: [PATCH 1/2] Enable support for Java 8 API desugaring. --- Source/Android/app/build.gradle | 5 +++++ Source/Android/build.gradle | 2 +- Source/Android/gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index b86192129a..0e84467163 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -4,6 +4,9 @@ android { compileSdkVersion 30 compileOptions { + // Flag to enable support for the new language APIs + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -76,6 +79,8 @@ android { } dependencies { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.exifinterface:exifinterface:1.1.0' implementation 'androidx.cardview:cardview:1.0.0' diff --git a/Source/Android/build.gradle b/Source/Android/build.gradle index 3333dd49ac..8d8b1e2d4f 100644 --- a/Source/Android/build.gradle +++ b/Source/Android/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:4.0.0' } } diff --git a/Source/Android/gradle/wrapper/gradle-wrapper.properties b/Source/Android/gradle/wrapper/gradle-wrapper.properties index e972e5cc78..cfdbb2c3bb 100644 --- a/Source/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Source/Android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip From 1c9132ba2b9827e3b05458b65690f362136ce3b0 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 15 Jul 2020 08:36:01 +0530 Subject: [PATCH 2/2] Use Instant in StartupHandler. --- .../dolphinemu/dolphinemu/utils/StartupHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java index 4ef8a5bd18..ed6415821e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java @@ -11,12 +11,12 @@ import androidx.fragment.app.FragmentActivity; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.activities.EmulationActivity; -import java.util.Date; +import java.time.Instant; +import java.time.temporal.ChronoUnit; public final class StartupHandler { public static final String LAST_CLOSED = "LAST_CLOSED"; - public static final long SESSION_TIMEOUT = 21600000L; // 6 hours in milliseconds public static void HandleInit(FragmentActivity parent) { @@ -61,7 +61,7 @@ public final class StartupHandler { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor sPrefsEditor = preferences.edit(); - sPrefsEditor.putLong(LAST_CLOSED, new Date(System.currentTimeMillis()).getTime()); + sPrefsEditor.putLong(LAST_CLOSED, System.currentTimeMillis()); sPrefsEditor.apply(); } @@ -70,10 +70,11 @@ public final class StartupHandler */ public static void checkSessionReset(Context context) { - long currentTime = new Date(System.currentTimeMillis()).getTime(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); long lastOpen = preferences.getLong(LAST_CLOSED, 0); - if (currentTime > (lastOpen + SESSION_TIMEOUT)) + final Instant current = Instant.now(); + final Instant lastOpened = Instant.ofEpochMilli(lastOpen); + if (current.isAfter(lastOpened.plus(6, ChronoUnit.HOURS))) { new AfterDirectoryInitializationRunner().run(context, false, NativeLibrary::ReportStartToAnalytics);