diff --git a/app/src/main/kotlin/org/fossify/voicerecorder/activities/SettingsActivity.kt b/app/src/main/kotlin/org/fossify/voicerecorder/activities/SettingsActivity.kt index bf8f1c83..f04f09ef 100644 --- a/app/src/main/kotlin/org/fossify/voicerecorder/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/org/fossify/voicerecorder/activities/SettingsActivity.kt @@ -51,6 +51,7 @@ class SettingsActivity : SimpleActivity() { setupBitrate() setupAudioSource() setupRecordAfterLaunch() + setupKeepScreenOn() setupUseRecycleBin() setupEmptyRecycleBin() updateTextColors(binding.settingsNestedScrollview) @@ -184,6 +185,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupKeepScreenOn() { + binding.settingsKeepScreenOn.isChecked = config.keepScreenOn + binding.settingsKeepScreenOnHolder.setOnClickListener { + binding.settingsKeepScreenOn.toggle() + config.keepScreenOn = binding.settingsKeepScreenOn.isChecked + } + } + private fun setupUseRecycleBin() { updateRecycleBinButtons() binding.settingsUseRecycleBin.isChecked = config.useRecycleBin diff --git a/app/src/main/kotlin/org/fossify/voicerecorder/fragments/RecorderFragment.kt b/app/src/main/kotlin/org/fossify/voicerecorder/fragments/RecorderFragment.kt index ec2f19c6..7a314325 100644 --- a/app/src/main/kotlin/org/fossify/voicerecorder/fragments/RecorderFragment.kt +++ b/app/src/main/kotlin/org/fossify/voicerecorder/fragments/RecorderFragment.kt @@ -6,11 +6,14 @@ import android.graphics.drawable.Drawable import android.os.Handler import android.os.Looper import android.util.AttributeSet +import android.view.WindowManager import org.fossify.commons.activities.BaseSimpleActivity +import org.fossify.commons.compose.extensions.getActivity import org.fossify.commons.dialogs.PermissionRequiredDialog import org.fossify.commons.extensions.* import org.fossify.commons.helpers.isNougatPlus import org.fossify.voicerecorder.databinding.FragmentRecorderBinding +import org.fossify.voicerecorder.extensions.config import org.fossify.voicerecorder.helpers.* import org.fossify.voicerecorder.models.Events import org.fossify.voicerecorder.services.RecorderService @@ -135,6 +138,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag Intent(context, RecorderService::class.java).apply { context.stopService(this) } + context.getActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } private fun getPauseBlinkTask() = object : TimerTask() { @@ -160,6 +164,9 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag if (status == RECORDING_RUNNING) { binding.togglePauseButton.alpha = 1f + if (context.config.keepScreenOn) { + context.getActivity().window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } } } diff --git a/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Config.kt b/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Config.kt index 46cf1bdd..ce9f2066 100644 --- a/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Config.kt +++ b/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Config.kt @@ -80,4 +80,8 @@ class Config(context: Context) : BaseConfig(context) { var lastRecycleBinCheck: Long get() = prefs.getLong(LAST_RECYCLE_BIN_CHECK, 0L) set(lastRecycleBinCheck) = prefs.edit().putLong(LAST_RECYCLE_BIN_CHECK, lastRecycleBinCheck).apply() + + var keepScreenOn: Boolean + get() = prefs.getBoolean(KEEP_SCREEN_ON, true) + set(keepScreenOn) = prefs.edit().putBoolean(KEEP_SCREEN_ON, keepScreenOn).apply() } diff --git a/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Constants.kt b/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Constants.kt index c7a3eba8..c12e5f74 100644 --- a/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Constants.kt +++ b/app/src/main/kotlin/org/fossify/voicerecorder/helpers/Constants.kt @@ -38,6 +38,7 @@ const val BITRATE = "bitrate" const val RECORD_AFTER_LAUNCH = "record_after_launch" const val USE_RECYCLE_BIN = "use_recycle_bin" const val LAST_RECYCLE_BIN_CHECK = "last_recycle_bin_check" +const val KEEP_SCREEN_ON = "keep_screen_on" @SuppressLint("InlinedApi") fun getAudioFileContentUri(id: Long): Uri { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e5738106..e07b1ca9 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -178,6 +178,21 @@ + + + + + + Źródło dźwięku Przepływność Rozpoczynaj nagrywanie automatycznie przy uruchomieniu aplikacji + Pozostawiaj ekran włączony podczas nagrywania Aparat Domyślne systemowe Nieprzetworzone diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 580d4609..074b149b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,6 +21,7 @@ Audio source Bitrate Start recording automatically after launching the app + Keep the screen on during recording Camera Android default