Add cellular backup toggle for message backup.

This commit is contained in:
Clark
2024-05-07 17:04:44 -04:00
committed by Alex Hart
parent 83c34dd4cc
commit ba4cdea75d
5 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.jobmanager.impl
import android.app.Application
import android.app.job.JobInfo
import org.thoughtcrime.securesms.jobmanager.Constraint
import org.thoughtcrime.securesms.util.NetworkUtil
/**
* Constraint that, when added, means that a job cannot be performed unless the user has Wifi
*/
class WifiConstraint(private val application: Application) : Constraint {
companion object {
const val KEY = "WifiConstraint"
}
override fun isMet(): Boolean {
return NetworkUtil.isConnectedWifi(application)
}
override fun getFactoryKey(): String = KEY
override fun applyToJobInfo(jobInfoBuilder: JobInfo.Builder) = Unit
class Factory(val application: Application) : Constraint.Factory<WifiConstraint> {
override fun create(): WifiConstraint {
return WifiConstraint(application)
}
}
}