Merge pull request #8954 from Isira-Seneviratne/Use_Java_8_Date_Time_API

Android: Use Java 8 Date/Time API.
This commit is contained in:
JosJuice 2020-10-06 10:05:48 +02:00 committed by GitHub
commit 0029ca84b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 7 deletions

View File

@ -4,6 +4,9 @@ android {
compileSdkVersion 30 compileSdkVersion 30
compileOptions { compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
@ -76,6 +79,8 @@ android {
} }
dependencies { dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.1.0' implementation 'androidx.exifinterface:exifinterface:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'

View File

@ -11,12 +11,12 @@ import androidx.fragment.app.FragmentActivity;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import java.util.Date; import java.time.Instant;
import java.time.temporal.ChronoUnit;
public final class StartupHandler public final class StartupHandler
{ {
public static final String LAST_CLOSED = "LAST_CLOSED"; 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) public static void HandleInit(FragmentActivity parent)
{ {
@ -61,7 +61,7 @@ public final class StartupHandler
{ {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor sPrefsEditor = preferences.edit(); SharedPreferences.Editor sPrefsEditor = preferences.edit();
sPrefsEditor.putLong(LAST_CLOSED, new Date(System.currentTimeMillis()).getTime()); sPrefsEditor.putLong(LAST_CLOSED, System.currentTimeMillis());
sPrefsEditor.apply(); sPrefsEditor.apply();
} }
@ -70,10 +70,11 @@ public final class StartupHandler
*/ */
public static void checkSessionReset(Context context) public static void checkSessionReset(Context context)
{ {
long currentTime = new Date(System.currentTimeMillis()).getTime();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
long lastOpen = preferences.getLong(LAST_CLOSED, 0); 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, new AfterDirectoryInitializationRunner().run(context, false,
NativeLibrary::ReportStartToAnalytics); NativeLibrary::ReportStartToAnalytics);

View File

@ -4,7 +4,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.3' classpath 'com.android.tools.build:gradle:4.0.0'
} }
} }

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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