From 5cdbb605f2764e8651b0828ace097109c1b0bd19 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:54:21 +0100 Subject: [PATCH] fix: Show low storage message dependent on whether user uses internal or external storage Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../main/java/app/myzel394/alibi/helpers/BatchesFolder.kt | 8 ++++---- .../ui/components/RecorderScreen/atoms/LowStorageInfo.kt | 8 +++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt index a025dca..3c3716c 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt @@ -522,8 +522,8 @@ abstract class BatchesFolder( return uri!! } - fun getAvailableBytes(): Long { - val storageManager = context.getSystemService(StorageManager::class.java) ?: return -1 + fun getAvailableBytes(): Long? { + val storageManager = context.getSystemService(StorageManager::class.java) ?: return null val file = when (type) { BatchType.INTERNAL -> context.filesDir BatchType.CUSTOM -> customFolder!!.uri.toFile() @@ -545,8 +545,8 @@ abstract class BatchesFolder( companion object { fun requiredBytesForOneMinuteOfRecording(appSettings: AppSettings): Long { - // 300 MiB sounds like a good default - return 300 * 1024 * 1024 + // 250 MiB sounds like a good default + return 250 * 1024 * 1024 } } } diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/LowStorageInfo.kt b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/LowStorageInfo.kt index 9ee6dac..d567704 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/LowStorageInfo.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/LowStorageInfo.kt @@ -22,6 +22,10 @@ fun LowStorageInfo( val availableBytes = VideoBatchesFolder.importFromFolder(appSettings.saveFolder, context).getAvailableBytes() + if (availableBytes == null) { + return + } + val bytesPerMinute = BatchesFolder.requiredBytesForOneMinuteOfRecording(appSettings) val requiredBytes = appSettings.maxDuration / 1000 / 60 * bytesPerMinute @@ -35,7 +39,9 @@ fun LowStorageInfo( ) { MessageBox( type = MessageType.WARNING, - message = stringResource(R.string.ui_recorder_lowOnStorage_hint), + message = if (appSettings.saveFolder == null) + stringResource(R.string.ui_recorder_lowOnStorage_hintANDswitchSaveFolder) + else stringResource(R.string.ui_recorder_lowOnStorage_hint) ) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e826fa3..baefa03 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -194,4 +194,5 @@ Save now? You can save the current ongoing recording by pressing and holding down on the save button. The recording will continue in the background. You are low on storage. Alibi may not function properly. Please free up some space. + You are low on storage. Alibi may not function properly. Please free up some space. Alternatively, change the batches folder to a different location in the settings. \ No newline at end of file