Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Add overalay preference item
Browse files Browse the repository at this point in the history
Add annotation tool settings to bottom sheet

Switch back to using Preferences object for managing preferences
  • Loading branch information
SuhasDissa authored and Bnyro committed Jul 11, 2023
1 parent 11d1a19 commit 016e87c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ fun SettingsBottomSheet(
)
}
Spacer(modifier = Modifier.height(10.dp))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CheckboxPref(
prefKey = Preferences.showOverlayAnnotationToolKey,
title = stringResource(R.string.screen_recorder_annotation),
summary = stringResource(R.string.screen_recorder_annotation_desc)
)
}
Spacer(modifier = Modifier.height(10.dp))
NamingPatternPref()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import com.bnyro.recorder.canvas_overlay.CanvasOverlay
import com.bnyro.recorder.enums.AudioSource
import com.bnyro.recorder.enums.RecorderState
import com.bnyro.recorder.services.AudioRecorderService
import com.bnyro.recorder.services.LosslessRecorderService
import com.bnyro.recorder.services.RecorderService
import com.bnyro.recorder.services.ScreenRecorderService
import com.bnyro.recorder.canvas_overlay.CanvasOverlay
import com.bnyro.recorder.util.PermissionHelper
import com.bnyro.recorder.util.Preferences

Expand Down Expand Up @@ -61,7 +61,9 @@ class RecorderModel : ViewModel() {
activityResult = result
val serviceIntent = Intent(context, ScreenRecorderService::class.java)
startRecorderService(context, serviceIntent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val showOverlayAnnotation =
Preferences.prefs.getBoolean(Preferences.showOverlayAnnotationToolKey, false)
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) && showOverlayAnnotation) {
canvasOverlay = CanvasOverlay(context)
canvasOverlay?.showAll()
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/bnyro/recorder/util/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ object Preferences {
const val themeModeKey = "themeMode"
const val losslessRecorderKey = "losslessRecorder"
const val namingPatternKey = "namingPattern"
const val showOverlayAnnotationToolKey = "annotationTool"

fun init(context: Context) {
prefs = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE)
Expand All @@ -29,4 +30,4 @@ object Preferences {
}

fun getString(key: String, defValue: String) = prefs.getString(key, defValue) ?: defValue
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@
<string name="system">System</string>
<string name="dark">Dark</string>
<string name="light">Light</string>
<string name="screen_recorder_annotation">Screen Record Annotation</string>
<string name="screen_recorder_annotation_desc">Show annotation tool during screen recording</string>
</resources>

0 comments on commit 016e87c

Please sign in to comment.