Update buildtools and dependencies and prepare for next Android

This commit is contained in:
Jonas Lochmann 2021-05-24 02:00:00 +02:00
parent da572df89a
commit 5c6b028c59
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
13 changed files with 44 additions and 31 deletions

View file

@ -153,22 +153,22 @@ android {
} }
dependencies { dependencies {
def nav_version = "2.2.1" def nav_version = "2.3.5"
def room_version = "2.2.6" def room_version = "2.3.0"
def work_version = '2.3.4' def work_version = '2.5.0'
def paging_version = "2.1.2" def paging_version = "3.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0' implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation "com.google.android.material:material:1.3.0" implementation "com.google.android.material:material:1.3.0"
implementation 'androidx.fragment:fragment-ktx:1.3.2' implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui:$nav_version" implementation "androidx.navigation:navigation-ui:$nav_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:$room_version"
@ -178,12 +178,12 @@ dependencies {
implementation "androidx.paging:paging-runtime:$paging_version" implementation "androidx.paging:paging-runtime:$paging_version"
implementation "android.arch.work:work-runtime:$work_version" implementation "androidx.work:work-runtime:$work_version"
implementation "android.arch.work:work-runtime-ktx:$work_version" implementation "androidx.work:work-runtime-ktx:$work_version"
androidTestImplementation "android.arch.work:work-testing:$work_version" androidTestImplementation "android.arch.work:work-testing:$work_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.3.0' androidTestImplementation 'androidx.test:runner:1.3.0'

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann TimeLimit Copyright <C> 2019 - 2021 Jonas Lochmann
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation version 3 of the License. the Free Software Foundation version 3 of the License.
@ -54,6 +54,7 @@
<!-- UI --> <!-- UI -->
<activity <activity
android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:taskAffinity=":main" android:taskAffinity=":main"
android:name=".ui.MainActivity"> android:name=".ui.MainActivity">
@ -92,6 +93,7 @@
android:name=".ui.manipulation.AnnoyActivity" /> android:name=".ui.manipulation.AnnoyActivity" />
<activity <activity
android:exported="true"
tools:ignore="UnusedAttribute" tools:ignore="UnusedAttribute"
android:enabled="false" android:enabled="false"
android:excludeFromRecents="true" android:excludeFromRecents="true"
@ -117,13 +119,13 @@
<!-- system integration --> <!-- system integration -->
<receiver android:name=".integration.platform.android.receiver.BootReceiver"> <receiver android:name=".integration.platform.android.receiver.BootReceiver" android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name=".integration.platform.android.receiver.UpdateReceiver"> <receiver android:name=".integration.platform.android.receiver.UpdateReceiver" android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter> </intent-filter>
@ -138,6 +140,7 @@
android:exported="false" /> android:exported="false" />
<receiver <receiver
android:exported="false"
android:name=".integration.platform.android.AdminReceiver" android:name=".integration.platform.android.AdminReceiver"
android:description="@string/admin_description" android:description="@string/admin_description"
android:label="@string/app_name" android:label="@string/app_name"
@ -151,7 +154,7 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name=".ui.widget.TimesWidgetProvider"> <receiver android:name=".ui.widget.TimesWidgetProvider" android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter> </intent-filter>
@ -160,6 +163,7 @@
</receiver> </receiver>
<service <service
android:exported="false"
android:name=".integration.platform.android.NotificationListener" android:name=".integration.platform.android.NotificationListener"
android:label="@string/app_name" android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
@ -169,6 +173,7 @@
</service> </service>
<service android:name=".integration.platform.android.AccessibilityService" <service android:name=".integration.platform.android.AccessibilityService"
android:exported="false"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter> <intent-filter>
@ -181,6 +186,7 @@
</service> </service>
<service android:name=".ui.widget.TimesWidgetService" <service android:name=".ui.widget.TimesWidgetService"
android:exported="false"
android:permission="android.permission.BIND_REMOTEVIEWS"/> android:permission="android.permission.BIND_REMOTEVIEWS"/>
</application> </application>

View file

@ -381,7 +381,7 @@ class AndroidIntegration(context: Context): PlatformIntegration(maximumProtectio
context, context,
PendingIntentIds.REVOKE_TEMPORARILY_ALLOWED, PendingIntentIds.REVOKE_TEMPORARILY_ALLOWED,
BackgroundActionService.prepareRevokeTemporarilyAllowed(context), BackgroundActionService.prepareRevokeTemporarilyAllowed(context),
PendingIntent.FLAG_UPDATE_CURRENT PendingIntentIds.PENDING_INTENT_FLAGS
) )
val notification = NotificationCompat.Builder(context, NotificationChannels.APP_STATUS) val notification = NotificationCompat.Builder(context, NotificationChannels.APP_STATUS)

View file

@ -56,7 +56,7 @@ class BackgroundActionService: Service() {
context, context,
PendingIntentIds.OPEN_MAIN_APP, PendingIntentIds.OPEN_MAIN_APP,
Intent(context, MainActivity::class.java), Intent(context, MainActivity::class.java),
PendingIntent.FLAG_UPDATE_CURRENT PendingIntentIds.PENDING_INTENT_FLAGS
) )
fun getSyncNotificationsPendingIntent(context: Context) = PendingIntent.getService( fun getSyncNotificationsPendingIntent(context: Context) = PendingIntent.getService(
@ -64,7 +64,7 @@ class BackgroundActionService: Service() {
PendingIntentIds.SYNC_NOTIFICATIONS, PendingIntentIds.SYNC_NOTIFICATIONS,
Intent(context, BackgroundActionService::class.java) Intent(context, BackgroundActionService::class.java)
.putExtra(ACTION, ACTION_UPDATE_NOTIFICATION), .putExtra(ACTION, ACTION_UPDATE_NOTIFICATION),
PendingIntent.FLAG_UPDATE_CURRENT PendingIntentIds.PENDING_INTENT_FLAGS
) )
} }

View file

@ -92,7 +92,7 @@ class BackgroundService: Service() {
context, context,
PendingIntentIds.SWITCH_TO_DEFAULT_USER, PendingIntentIds.SWITCH_TO_DEFAULT_USER,
BackgroundActionService.prepareSwitchToDefaultUser(context), BackgroundActionService.prepareSwitchToDefaultUser(context),
PendingIntent.FLAG_UPDATE_CURRENT PendingIntentIds.PENDING_INTENT_FLAGS
) )
).build() ).build()
) )

View file

@ -17,6 +17,7 @@ package io.timelimit.android.integration.platform.android
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
@ -153,4 +154,10 @@ object PendingIntentIds {
const val UPDATE_STATUS = 5 const val UPDATE_STATUS = 5
const val OPEN_UPDATER = 6 const val OPEN_UPDATER = 6
val DYNAMIC_NOTIFICATION_RANGE = 100..10000 val DYNAMIC_NOTIFICATION_RANGE = 100..10000
val PENDING_INTENT_FLAGS = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}
} }

View file

@ -139,7 +139,7 @@ class SuspendAppsLogic(private val appLogic: AppLogic): Observer {
} }
} while (didModify) } while (didModify)
categoryHandlings.minBy { it.dependsOnMaxTime }?.let { categoryHandlings.minByOrNull { it.dependsOnMaxTime }?.let {
scheduleUpdate((it.dependsOnMaxTime - realTime.timeInMillis)) scheduleUpdate((it.dependsOnMaxTime - realTime.timeInMillis))
} }

View file

@ -58,7 +58,7 @@ class UsedTimeUpdateHelper (private val appLogic: AppLogic) {
val newIds = handlings.map { it.createdWithCategoryRelatedData.category.id }.toSet() val newIds = handlings.map { it.createdWithCategoryRelatedData.category.id }.toSet()
val oldIds = categoryIds val oldIds = categoryIds
maxTimeToAdd = handlings.minBy { it.maxTimeToAdd }?.maxTimeToAdd ?: Long.MAX_VALUE maxTimeToAdd = handlings.minByOrNull { it.maxTimeToAdd }?.maxTimeToAdd ?: Long.MAX_VALUE
categoryIds = newIds categoryIds = newIds
if (lastCategoryHandlings.size != handlings.size) { if (lastCategoryHandlings.size != handlings.size) {

View file

@ -167,7 +167,7 @@ data class CategoryItselfHandling (
val missingNetworkTimeForRules = categoryRelatedData.rules.isNotEmpty() val missingNetworkTimeForRules = categoryRelatedData.rules.isNotEmpty()
val okByTimeLimitRules = regularRelatedRules.isEmpty() || (remainingTime != null && remainingTime.hasRemainingTime) val okByTimeLimitRules = regularRelatedRules.isEmpty() || (remainingTime != null && remainingTime.hasRemainingTime)
val dependsOnMaxTimeByMinuteOfDay = (allRelatedRules.minBy { it.endMinuteOfDay }?.endMinuteOfDay ?: Int.MAX_VALUE).coerceAtMost( val dependsOnMaxTimeByMinuteOfDay = (allRelatedRules.minByOrNull { it.endMinuteOfDay }?.endMinuteOfDay ?: Int.MAX_VALUE).coerceAtMost(
categoryRelatedData.rules categoryRelatedData.rules
.filter { .filter {
// related to today // related to today
@ -175,7 +175,7 @@ data class CategoryItselfHandling (
// will be applied later at this day // will be applied later at this day
it.startMinuteOfDay > minuteInWeek % MinuteOfDay.LENGTH it.startMinuteOfDay > minuteInWeek % MinuteOfDay.LENGTH
} }
.minBy { it.startMinuteOfDay }?.startMinuteOfDay ?: Int.MAX_VALUE .minByOrNull { it.startMinuteOfDay }?.startMinuteOfDay ?: Int.MAX_VALUE
).coerceAtMost(dependsOnMaxMinuteOfDayByBlockedTimeAreas) ).coerceAtMost(dependsOnMaxMinuteOfDayByBlockedTimeAreas)
// this must depend on the current day to invalidate day dependent values like the extra time // this must depend on the current day to invalidate day dependent values like the extra time
val dependsOnMaxTimeByRules = if (dependsOnMaxTimeByMinuteOfDay <= MinuteOfDay.MAX) { val dependsOnMaxTimeByRules = if (dependsOnMaxTimeByMinuteOfDay <= MinuteOfDay.MAX) {
@ -200,7 +200,7 @@ data class CategoryItselfHandling (
categoryRelatedData.durations.map { it.lastUsage + it.maxSessionDuration - it.lastSessionDuration } categoryRelatedData.durations.map { it.lastUsage + it.maxSessionDuration - it.lastSessionDuration }
) )
.filter { it > timeInMillis } .filter { it > timeInMillis }
.min() ?: Long.MAX_VALUE .minOrNull() ?: Long.MAX_VALUE
val okBySessionDurationLimits = remainingSessionDuration == null || remainingSessionDuration > 0 val okBySessionDurationLimits = remainingSessionDuration == null || remainingSessionDuration > 0
val okByCurrentDevice = assumeCurrentDevice || (remainingTime == null && remainingSessionDuration == null) val okByCurrentDevice = assumeCurrentDevice || (remainingTime == null && remainingSessionDuration == null)

View file

@ -158,7 +158,7 @@ class InstallUpdateDialogModel(application: Application): AndroidViewModel(appli
application, application,
PendingIntentIds.UPDATE_STATUS, PendingIntentIds.UPDATE_STATUS,
Intent(action).setPackage(BuildConfig.APPLICATION_ID), Intent(action).setPackage(BuildConfig.APPLICATION_ID),
0 PendingIntentIds.PENDING_INTENT_FLAGS
).intentSender ).intentSender
) )

View file

@ -86,7 +86,7 @@ object UpdateUtil {
context, context,
PendingIntentIds.OPEN_UPDATER, PendingIntentIds.OPEN_UPDATER,
Intent(context, UpdateActivity::class.java), Intent(context, UpdateActivity::class.java),
PendingIntent.FLAG_UPDATE_CURRENT PendingIntentIds.PENDING_INTENT_FLAGS
) )
notificationManager.notify( notificationManager.notify(

View file

@ -17,13 +17,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.32' ext.kotlin_version = '1.5.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.3' classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0" classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"

View file

@ -2,5 +2,5 @@ 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-6.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionSha256Sum=23e7d37e9bb4f8dabb8a3ea7fdee9dd0428b9b1a71d298aefd65b11dccea220f distributionSha256Sum=3239b5ed86c3838a37d983ac100573f64c1f3fd8e1eb6c89fa5f9529b5ec091d