Replace field naming _foo with mFoo

This commit is contained in:
Torsten Grote 2024-05-03 15:57:01 -03:00
parent 01dbcf5f2f
commit 4651ad5eb3
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
5 changed files with 42 additions and 42 deletions

View file

@ -23,26 +23,26 @@ class StoragePluginManager(
webDavFactory: WebDavFactory,
) {
private var _appPlugin: StoragePlugin<*>?
private var _filesPlugin: org.calyxos.backup.storage.api.StoragePlugin?
private var _storageProperties: StorageProperties<*>?
private var mAppPlugin: StoragePlugin<*>?
private var mFilesPlugin: org.calyxos.backup.storage.api.StoragePlugin?
private var mStorageProperties: StorageProperties<*>?
val appPlugin: StoragePlugin<*>
@Synchronized
get() {
return _appPlugin ?: error("App plugin was loaded, but still null")
return mAppPlugin ?: error("App plugin was loaded, but still null")
}
val filesPlugin: org.calyxos.backup.storage.api.StoragePlugin
@Synchronized
get() {
return _filesPlugin ?: error("Files plugin was loaded, but still null")
return mFilesPlugin ?: error("Files plugin was loaded, but still null")
}
val storageProperties: StorageProperties<*>?
@Synchronized
get() {
return _storageProperties
return mStorageProperties
}
val isOnRemovableDrive: Boolean get() = storageProperties?.isUsb == true
@ -51,30 +51,30 @@ class StoragePluginManager(
StoragePluginEnum.SAF -> {
val safStorage = settingsManager.getSafStorage() ?: error("No SAF storage saved")
val documentsStorage = DocumentsStorage(context, settingsManager, safStorage)
_appPlugin = safFactory.createAppStoragePlugin(safStorage, documentsStorage)
_filesPlugin = safFactory.createFilesStoragePlugin(safStorage, documentsStorage)
_storageProperties = safStorage
mAppPlugin = safFactory.createAppStoragePlugin(safStorage, documentsStorage)
mFilesPlugin = safFactory.createFilesStoragePlugin(safStorage, documentsStorage)
mStorageProperties = safStorage
}
StoragePluginEnum.WEB_DAV -> {
val webDavProperties =
settingsManager.webDavProperties ?: error("No WebDAV config saved")
_appPlugin = webDavFactory.createAppStoragePlugin(webDavProperties.config)
_filesPlugin = webDavFactory.createFilesStoragePlugin(webDavProperties.config)
_storageProperties = webDavProperties
mAppPlugin = webDavFactory.createAppStoragePlugin(webDavProperties.config)
mFilesPlugin = webDavFactory.createFilesStoragePlugin(webDavProperties.config)
mStorageProperties = webDavProperties
}
null -> {
_appPlugin = null
_filesPlugin = null
_storageProperties = null
mAppPlugin = null
mFilesPlugin = null
mStorageProperties = null
}
}
}
fun isValidAppPluginSet(): Boolean {
if (_appPlugin == null || _filesPlugin == null) return false
if (_appPlugin is DocumentsProviderStoragePlugin) {
if (mAppPlugin == null || mFilesPlugin == null) return false
if (mAppPlugin is DocumentsProviderStoragePlugin) {
val storage = settingsManager.getSafStorage() ?: return false
if (storage.isUsb) return true
return permitDiskReads {
@ -96,9 +96,9 @@ class StoragePluginManager(
filesPlugin: org.calyxos.backup.storage.api.StoragePlugin,
) {
settingsManager.setStoragePlugin(appPlugin)
_storageProperties = storageProperties
_appPlugin = appPlugin
_filesPlugin = filesPlugin
mStorageProperties = storageProperties
mAppPlugin = appPlugin
mFilesPlugin = filesPlugin
}
/**

View file

@ -46,27 +46,27 @@ internal class WebDavHandler(
}
}
private val _configState = MutableStateFlow<WebDavConfigState>(WebDavConfigState.Empty)
val configState = _configState.asStateFlow()
private val mConfigState = MutableStateFlow<WebDavConfigState>(WebDavConfigState.Empty)
val configState = mConfigState.asStateFlow()
suspend fun onConfigReceived(config: WebDavConfig) {
_configState.value = WebDavConfigState.Checking
mConfigState.value = WebDavConfigState.Checking
val plugin = webDavFactory.createAppStoragePlugin(config) as WebDavStoragePlugin
try {
if (plugin.test()) {
val properties = createWebDavProperties(context, config)
_configState.value = WebDavConfigState.Success(properties, plugin)
mConfigState.value = WebDavConfigState.Success(properties, plugin)
} else {
_configState.value = WebDavConfigState.Error(null)
mConfigState.value = WebDavConfigState.Error(null)
}
} catch (e: Exception) {
Log.e(TAG, "Error testing WebDAV config at ${config.url}", e)
_configState.value = WebDavConfigState.Error(e)
mConfigState.value = WebDavConfigState.Error(e)
}
}
fun resetConfigState() {
_configState.value = WebDavConfigState.Empty
mConfigState.value = WebDavConfigState.Empty
}
/**

View file

@ -99,11 +99,11 @@ internal class SettingsViewModel(
private val mAppEditMode = MutableLiveData<Boolean>()
internal val appEditMode: LiveData<Boolean> = mAppEditMode
private val _filesSummary = MutableLiveData<String>()
internal val filesSummary: LiveData<String> = _filesSummary
private val mFilesSummary = MutableLiveData<String>()
internal val filesSummary: LiveData<String> = mFilesSummary
private val _initEvent = MutableLiveEvent<Boolean>()
val initEvent: LiveEvent<Boolean> = _initEvent
private val mInitEvent = MutableLiveEvent<Boolean>()
val initEvent: LiveEvent<Boolean> = mInitEvent
private val storageObserver = object : ContentObserver(null) {
override fun onChange(selfChange: Boolean, uris: MutableCollection<Uri>, flags: Int) {
@ -252,7 +252,7 @@ internal class SettingsViewModel(
@UiThread
fun loadFilesSummary() = viewModelScope.launch {
val uriSummary = storageBackup.getUriSummaryString()
_filesSummary.value = uriSummary.ifEmpty {
mFilesSummary.value = uriSummary.ifEmpty {
app.getString(R.string.settings_backup_files_summary)
}
}
@ -268,10 +268,10 @@ internal class SettingsViewModel(
}
viewModelScope.launch(Dispatchers.IO) {
backupInitializer.initialize(onError) {
_initEvent.postEvent(false)
mInitEvent.postEvent(false)
scheduleAppBackup(CANCEL_AND_REENQUEUE)
}
_initEvent.postEvent(true)
mInitEvent.postEvent(true)
}
}
// enable call log backups for existing installs (added end of 2020)

View file

@ -33,8 +33,8 @@ internal class StorageBackupService : BackupService() {
companion object {
internal const val EXTRA_START_APP_BACKUP = "startAppBackup"
private val _isRunning = MutableStateFlow(false)
val isRunning = _isRunning.asStateFlow()
private val mIsRunning = MutableStateFlow(false)
val isRunning = mIsRunning.asStateFlow()
}
override val storageBackup: StorageBackup by inject()
@ -47,12 +47,12 @@ internal class StorageBackupService : BackupService() {
override fun onCreate() {
super.onCreate()
_isRunning.value = true
mIsRunning.value = true
}
override fun onDestroy() {
super.onDestroy()
_isRunning.value = false
mIsRunning.value = false
}
override fun onBackupFinished(intent: Intent, success: Boolean) {

View file

@ -21,8 +21,8 @@ private val TAG = ConfigurableBackupTransportService::class.java.simpleName
class ConfigurableBackupTransportService : Service(), KoinComponent {
companion object {
private val _isRunning = MutableStateFlow(false)
val isRunning = _isRunning.asStateFlow()
private val mIsRunning = MutableStateFlow(false)
val isRunning = mIsRunning.asStateFlow()
}
private var transport: ConfigurableBackupTransport? = null
@ -34,7 +34,7 @@ class ConfigurableBackupTransportService : Service(), KoinComponent {
override fun onCreate() {
super.onCreate()
transport = ConfigurableBackupTransport(applicationContext)
_isRunning.value = true
mIsRunning.value = true
Log.d(TAG, "Service created.")
}
@ -55,7 +55,7 @@ class ConfigurableBackupTransportService : Service(), KoinComponent {
super.onDestroy()
notificationManager.onServiceDestroyed()
transport = null
_isRunning.value = false
mIsRunning.value = false
Log.d(TAG, "Service destroyed.")
}