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

View file

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

View file

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

View file

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

View file

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