Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to keep screen on during recording (#67) #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SettingsActivity : SimpleActivity() {
setupBitrate()
setupAudioSource()
setupRecordAfterLaunch()
setupKeepScreenOn()
setupUseRecycleBin()
setupEmptyRecycleBin()
updateTextColors(binding.settingsNestedScrollview)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@

</RelativeLayout>

<RelativeLayout
android:id="@+id/settings_keep_screen_on_holder"
style="@style/SettingsHolderCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<org.fossify.commons.views.MyAppCompatCheckbox
android:id="@+id/settings_keep_screen_on"
style="@style/SettingsCheckboxStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/keep_screen_on" />

</RelativeLayout>

<RelativeLayout
android:id="@+id/settings_save_recordings_holder"
style="@style/SettingsHolderTextViewStyle"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<string name="audio_source">Źródło dźwięku</string>
<string name="bitrate">Przepływność</string>
<string name="record_after_launch">Rozpoczynaj nagrywanie automatycznie przy uruchomieniu aplikacji</string>
<string name="keep_screen_on">Pozostawiaj ekran włączony podczas nagrywania</string>
<string name="audio_source_camcorder">Aparat</string>
<string name="audio_source_default">Domyślne systemowe</string>
<string name="audio_source_unprocessed">Nieprzetworzone</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="audio_source">Audio source</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<string name="keep_screen_on">Keep the screen on during recording</string>
<!-- Settings Audio source selection -->
<string name="audio_source_camcorder">Camera</string>
<string name="audio_source_default">Android default</string>
Expand Down
Loading