-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from infinum/develop
Update Master with Release 1.4.0
- Loading branch information
Showing
28 changed files
with
306 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
ext { | ||
def major = 1 | ||
def minor = 3 | ||
def patch = 3 | ||
def minor = 4 | ||
def patch = 0 | ||
|
||
buildConfig = [ | ||
"minSdk" : 21, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[versions] | ||
sentinel = "1.3.3" | ||
sentinel = "1.4.0" | ||
gradle = "8.3.2" | ||
kotlin = "1.9.22" | ||
coroutines = "1.8.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
sentinel/src/main/kotlin/com/infinum/sentinel/di/WorkManagerInitializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.infinum.sentinel.di | ||
|
||
import com.infinum.sentinel.di.component.DomainComponent | ||
import com.infinum.sentinel.ui.certificates.observer.CertificateCheckWorker | ||
import com.infinum.sentinel.ui.certificates.observer.DelegateWorker | ||
import com.infinum.sentinel.ui.certificates.observer.SentinelWorkerFactory | ||
|
||
internal object WorkManagerInitializer { | ||
|
||
fun init(domainComponent: DomainComponent) { | ||
DelegateWorker.workerFactories[CertificateCheckWorker.NAME] = | ||
SentinelWorkerFactory(domainComponent.collectors, domainComponent.notificationFactory) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
sentinel/src/main/kotlin/com/infinum/sentinel/ui/certificates/observer/DelegateWorker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.infinum.sentinel.ui.certificates.observer | ||
|
||
import android.content.Context | ||
import androidx.annotation.UiThread | ||
import androidx.work.ListenableWorker | ||
import androidx.work.WorkerFactory | ||
import androidx.work.WorkerParameters | ||
import com.google.common.util.concurrent.ListenableFuture | ||
import com.infinum.sentinel.ui.shared.Constants.Keys.WORKER_CLASS_NAME | ||
import com.infinum.sentinel.ui.shared.Constants.Keys.WORKER_ID | ||
|
||
/** | ||
* A worker to delegate work requests from within the library to workers | ||
* that require factories with custom dependencies. | ||
*/ | ||
internal class DelegateWorker( | ||
appContext: Context, | ||
parameters: WorkerParameters, | ||
) : ListenableWorker(appContext, parameters) { | ||
|
||
private val workerClassName = | ||
parameters.inputData.getString(WORKER_CLASS_NAME) ?: "" | ||
private val workerId = parameters.inputData.getString(WORKER_ID) | ||
private val delegateWorkerFactory = workerFactories[workerId] | ||
private val delegatedWorker = delegateWorkerFactory?.createWorker(appContext, workerClassName, parameters) | ||
|
||
override fun startWork(): ListenableFuture<Result> { | ||
return if (delegatedWorker != null) { | ||
delegatedWorker.startWork() | ||
} else { | ||
val errorMessage = "No delegateWorker available for $workerId" + | ||
" with workerClassName of $workerClassName. Is the " + | ||
"DelegateWorker.workerFactories populated correctly?" | ||
throw IllegalStateException(errorMessage) | ||
} | ||
} | ||
|
||
companion object { | ||
const val DELEGATE_WORKER_ID = "com.infinum.sentinel.ui.certificates.observer.CertificateCheckWorker" | ||
|
||
val workerFactories = object : AbstractMutableMap<String, WorkerFactory>() { | ||
|
||
private val backingWorkerMap = mutableMapOf<String, WorkerFactory>() | ||
|
||
@UiThread | ||
override fun put(key: String, value: WorkerFactory): WorkerFactory? { | ||
return backingWorkerMap.put(key, value) | ||
} | ||
|
||
override val entries: MutableSet<MutableMap.MutableEntry<String, WorkerFactory>> | ||
get() = backingWorkerMap.entries | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.