Skip to content
Closed
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 @@ -124,6 +124,14 @@ object PreferenceData {

// endregion Show Timer Total Time

// region Show On Lock Screen

const val KEY_SHOW_ON_LOCK_SCREEN = "key_show_on_lock_screen"
val Context.showOnLockScreen: Boolean
get() = safeSharedPreference.getBoolean(KEY_SHOW_ON_LOCK_SCREEN, false)

// endregion Show On Lock Screen

// region Week Start

/**
Expand Down
4 changes: 4 additions & 0 deletions app-base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@
<string name="pref_show_timer_total_time_on">Show the total time of the timer and groups</string>
<string name="pref_show_timer_total_time_off">Hide it</string>

<string name="pref_show_on_lock_screen_title">Show timer on lock screen</string>
<string name="pref_show_on_lock_screen_on">Enabled</string>
<string name="pref_show_on_lock_screen_off">Disabled</string>

<!--Use the previously generated speech synthesis file instead of synthesizing the voice every time. Similar to caching.-->
<string name="pref_tts_bakery">Text-to-speech bakery</string>
<string name="pref_tts_bakery_off">Generate the audio file of every Text-to-speech content for a quick speech afterward</string>
Expand Down
9 changes: 9 additions & 0 deletions app-settings/src/main/res/xml/pref_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
app:title="@string/pref_screen_title"
app:useSimpleSummaryProvider="true" />

<SwitchPreferenceCompat
app:defaultValue="false"
app:icon="@drawable/settings_brightness"
app:key="key_show_on_lock_screen"
app:singleLineTitle="false"
app:summaryOff="@string/pref_show_on_lock_screen_off"
app:summaryOn="@string/pref_show_on_lock_screen_on"
app:title="@string/pref_show_on_lock_screen_title" />

<ListPreference
app:defaultValue="@string/pref_screen_timing_value_default"
app:entries="@array/pref_screen_timing_titles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.activity.viewModels
import androidx.core.app.ActivityCompat
import androidx.navigation.fragment.NavHostFragment
import dagger.hilt.android.AndroidEntryPoint
import xyz.aprildown.timer.app.base.data.PreferenceData.showOnLockScreen
import xyz.aprildown.timer.app.base.data.PreferenceData.storedAudioTypeValue
import xyz.aprildown.timer.app.base.ui.BaseActivity
import xyz.aprildown.timer.app.base.utils.ScreenWakeLock
Expand Down Expand Up @@ -40,6 +41,9 @@ class OneActivity : BaseActivity(), OneActivityInterface {
}

volumeControlStream = storedAudioTypeValue
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(showOnLockScreen)
}

viewModel.setTimerId(
intent?.getIntExtra(Constants.EXTRA_TIMER_ID, TimerEntity.NULL_ID)
Expand Down