Commit 7d96b799 authored by Jonas L.'s avatar Jonas L.

Update dependencies

parent f04b649c
......@@ -40,9 +40,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
......@@ -52,12 +52,12 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "me.henrytao:recycler-pager-adapter:2.1.0"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'android.arch.work:work-runtime-ktx:1.0.0-alpha10'
implementation "com.mikepenz:materialdrawer:6.1.1"
implementation 'android.arch.work:work-runtime-ktx:1.0.0-beta01'
implementation "com.mikepenz:materialdrawer:6.1.2"
}
......@@ -11,9 +11,9 @@ import de.determapp.android.content.projectdata.Image
import de.determapp.android.content.projectdata.Project
import de.determapp.android.ui.viewer.ProjectSpec
import de.determapp.android.util.*
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.consumeEach
import okhttp3.HttpUrl
import okhttp3.Request
import okio.Okio
......
......@@ -87,12 +87,12 @@ class DownloadPackageSourceContentWork(context: Context, workerParameters: Worke
if (projectEntry == null) {
// this failed and should not be retried
return Result.FAILURE
return Result.failure()
}
if (projectEntry.localFilename != null) {
// there is nothing to do anymore
return Result.SUCCESS
return Result.success()
}
val notificationBuilder = NotificationCompat.Builder(applicationContext, NotificationChannels.DOWNLOAD_PROGRESS)
......@@ -168,7 +168,7 @@ class DownloadPackageSourceContentWork(context: Context, workerParameters: Worke
// deleting old images is not required here (because this downloads only)
return Result.SUCCESS
return Result.success()
} finally {
// delete if download was not finished
if (!done) {
......@@ -183,15 +183,15 @@ class DownloadPackageSourceContentWork(context: Context, workerParameters: Worke
Log.w(LOG_TAG, "error during downloading", ex)
}
return Result.RETRY
return Result.retry()
} finally {
notificationManager.cancel(notificationTag, notificationId)
}
}
}
override fun onStopped(cancelled: Boolean) {
super.onStopped(cancelled)
override fun onStopped() {
super.onStopped()
cancellationSignal?.cancel()
}
......
......@@ -26,6 +26,7 @@ import de.determapp.android.ui.viewer.ProjectSpec
import de.determapp.android.util.Async
import de.determapp.android.util.Progress
import de.determapp.android.util.ProgressListener
import kotlinx.coroutines.runBlocking
import java.io.File
import java.util.concurrent.TimeUnit
......@@ -68,28 +69,30 @@ class UpdateContentWorker(context: Context, workerParameters: WorkerParameters):
fun enqueueManually() {
Async.disk.submit {
synchronized(enqueueLock) {
val statuses = WorkManager.getInstance().getStatusesByTag(TAG_MANUALLY).get()
val statuses = WorkManager.getInstance().getWorkInfosByTag(TAG_MANUALLY).get()
if (!scheduledOrRunning(statuses)) {
WorkManager.getInstance().enqueue(
OneTimeWorkRequestBuilder<UpdateContentWorker>()
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.addTag(TAG)
.addTag(TAG_MANUALLY)
.build()
).get()
runBlocking {
WorkManager.getInstance().enqueue(
OneTimeWorkRequestBuilder<UpdateContentWorker>()
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.addTag(TAG)
.addTag(TAG_MANUALLY)
.build()
).await()
}
}
}
}
}
private fun scheduledOrRunning(statuses: Collection<WorkStatus>): Boolean {
private fun scheduledOrRunning(statuses: Collection<WorkInfo>): Boolean {
return statuses.find {
it.state == State.RUNNING || it.state == State.BLOCKED || it.state == State.ENQUEUED
it.state == WorkInfo.State.RUNNING || it.state == WorkInfo.State.BLOCKED || it.state == WorkInfo.State.ENQUEUED
} != null
}
......@@ -101,17 +104,17 @@ class UpdateContentWorker(context: Context, workerParameters: WorkerParameters):
fun getStatus(): LiveData<UpdateContentStatus> {
return Transformations.map(
WorkManager.getInstance().getStatusesByTagLiveData(TAG)) {
WorkManager.getInstance().getWorkInfosByTagLiveData(TAG)) {
statuses ->
val periodicEntries = statuses.filter { it.tags.contains(TAG_PERIODICALLY) }
val manuelEntries = statuses.filter { it.tags.contains(TAG_MANUALLY) }
if (periodicEntries.find { it.state == State.RUNNING } != null) {
if (periodicEntries.find { it.state == WorkInfo.State.RUNNING } != null) {
UpdateContentStatus.RunningPeriodically
} else if (manuelEntries.find { it.state == State.RUNNING } != null) {
} else if (manuelEntries.find { it.state == WorkInfo.State.RUNNING } != null) {
UpdateContentStatus.RunningManually
} else if (manuelEntries.find { (it.state == State.ENQUEUED || it.state == State.BLOCKED) } != null) {
} else if (manuelEntries.find { (it.state == WorkInfo.State.ENQUEUED || it.state == WorkInfo.State.BLOCKED) } != null) {
UpdateContentStatus.ScheduledManually
} else {
UpdateContentStatus.Idle
......@@ -285,7 +288,7 @@ class UpdateContentWorker(context: Context, workerParameters: WorkerParameters):
Log.w(LOG_TAG, "error during background update", ex)
}
return Result.RETRY
return Result.retry()
} finally {
notificationManager.cancel(notificationId)
......@@ -295,11 +298,11 @@ class UpdateContentWorker(context: Context, workerParameters: WorkerParameters):
}
}
return Result.SUCCESS
return Result.success()
}
override fun onStopped(cancelled: Boolean) {
super.onStopped(cancelled)
override fun onStopped() {
super.onStopped()
this.cancel?.cancel()
}
......
......@@ -4,7 +4,7 @@ import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.Observer
import androidx.work.State
import androidx.work.WorkInfo
import androidx.work.WorkManager
import de.determapp.android.content.database.AppDatabaseInstance
import de.determapp.android.service.work.DownloadPackageSourceContentWork
......@@ -28,7 +28,7 @@ fun getViewerInfoMode(spec: ProjectSpec, context: Context): LiveData<ViewerInfoM
private fun getProjectViewerInfoModeForPackageSourceProject(projectId: String, context: Context): LiveData<ViewerInfoMode> {
val projectEntryLive = AppDatabaseInstance.with(context).packageSourceProjectDao().getById(projectId)
val workStatusLive = WorkManager.getInstance().getStatusesByTagLiveData(DownloadPackageSourceContentWork.projectIdTag(projectId))
val workStatusLive = WorkManager.getInstance().getWorkInfosByTagLiveData(DownloadPackageSourceContentWork.projectIdTag(projectId))
val result = MediatorLiveData<ViewerInfoMode>()
......@@ -42,15 +42,15 @@ private fun getProjectViewerInfoModeForPackageSourceProject(projectId: String, c
if (projectEntry.localFilename != null) {
result.value = ViewerInfoMode.Downloaded;
} else if (workStatus.find { it.state == State.RUNNING } != null) {
} else if (workStatus.find { it.state == WorkInfo.State.RUNNING } != null) {
result.value = ViewerInfoMode.Downloading
} else if (workStatus.find {
(it.state == State.ENQUEUED || it.state == State.BLOCKED) &&
(it.state == WorkInfo.State.ENQUEUED || it.state == WorkInfo.State.BLOCKED) &&
it.tags.contains(DownloadPackageSourceContentWork.TAG_WITHOUT_CONSTRAINTS)
} != null) {
result.value = ViewerInfoMode.DownloadScheduled
} else if (workStatus.find {
(it.state == State.ENQUEUED || it.state == State.BLOCKED)
(it.state == WorkInfo.State.ENQUEUED || it.state == WorkInfo.State.BLOCKED)
} != null) {
result.value = ViewerInfoMode.DownloadScheduledWithConstraints
} else {
......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.11'
ext.room_version = "2.0.0"
repositories {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment