Skip to content

Commit

Permalink
in which our hero simplifies further, and makes visual UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janexner committed Jun 3, 2024
1 parent 10bfde1 commit 5f7b305
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 142 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "com.exner.tools.meditationtimer"
minSdk = 29
targetSdk = 34
versionCode = 4
versionName = "1.0.0"
versionCode = 5
versionName = "1.0.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,35 @@ object AppComponent {
val secondUuid = UUID.randomUUID().toString()
var meditationTimerProcess =
MeditationTimerProcess(
name = "Test Process 1",
info = "A test process that runs for 30 minutes, then leads directly into 'Test Process 2'",
categoryId = null,
name = "Basic 1 - Arriving",
info = "5 minutes for you to slow down and arrive.",
categoryId = 1L,
uuid = UUID.randomUUID().toString(),
processTime = 30,
intervalTime = 10,
processTime = 5,
intervalTime = 5,
hasAutoChain = true,
gotoUuid = secondUuid,
gotoName = "Test Process 2",
gotoName = "Basic 1 - Mindful Breathing",
uid = 0L,
)
provider.get().insert(meditationTimerProcess)
meditationTimerProcess =
MeditationTimerProcess(
name = "Test Process 2",
info = "Test process that is launched by 'Test Process 2'. It runs for 15 minutes.",
categoryId = null,
name = "Basic 1 - Mindful Breathing",
info = "15 minutes for mindful breathing.",
categoryId = 1L,
uuid = secondUuid,
processTime = 15,
intervalTime = 5,
intervalTime = 15,
hasAutoChain = false,
gotoUuid = null,
gotoName = null,
uid = 0L,
)
provider.get().insert(meditationTimerProcess)
val demoCategory = MeditationTimerProcessCategory(
name = "Category 1",
uid = 0
name = "Breathing",
uid = 0L
)
provider.get().insertCategory(demoCategory)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,6 @@ class MeditationTimerUserPreferencesManager @Inject constructor(
preferences[KEY_THEME] = newTheme.name
}
}
fun beforeCountingWait(): Flow<Boolean> {
return userDataStorePreferences.data.catch {
emit(emptyPreferences())
}.map { preferences ->
preferences[KEY_BEFORE_COUNTING_WAIT] ?: false
}
}

suspend fun setBeforeCountingWait(newBeforeCountingWait: Boolean) {
userDataStorePreferences.edit { preferences ->
preferences[KEY_BEFORE_COUNTING_WAIT] = newBeforeCountingWait
}
}

fun howLongToWaitBeforeCounting(): Flow<Int> {
return userDataStorePreferences.data.catch {
emit(emptyPreferences())
}.map { preferences ->
preferences[KEY_HOW_LONG_TO_WAIT_BEFORE_COUNTING] ?: 5
}
}

suspend fun setHowLongToWaitBeforeCounting(newHowLongToWaitBeforeCounting: Int) {
userDataStorePreferences.edit { preferences ->
preferences[KEY_HOW_LONG_TO_WAIT_BEFORE_COUNTING] = newHowLongToWaitBeforeCounting
}
}

fun countBackwards(): Flow<Boolean> {
return userDataStorePreferences.data.catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,15 @@ const val STEP_LENGTH_IN_MILLISECONDS = 1000

fun getProcessStepListForOneProcess(
process: MeditationTimerProcess,
hasLeadIn: Boolean = false,
leadInTime: Int = 5,
useSounds: Boolean = true,
countBackwards: Boolean = false,
): MutableList<List<ProcessStepAction>> {

val result = mutableListOf<List<ProcessStepAction>>()

var processParameters = ""
if (hasLeadIn && leadInTime > 0) {
processParameters += "$leadInTime > "
}
processParameters += "${process.processTime} / ${process.intervalTime}"

// do we need steps for lead-in, and how many?
if (hasLeadIn && leadInTime > 0) {
val howManySteps = leadInTime * 1000 / STEP_LENGTH_IN_MILLISECONDS
for (i in 1..howManySteps) {
val actionsList = mutableListOf<ProcessStepAction>()
val timeToShow =
if (countBackwards) (howManySteps + 1) - i * STEP_LENGTH_IN_MILLISECONDS / 1000 else i * STEP_LENGTH_IN_MILLISECONDS / 1000
// add actions as needed
val ftpliAction = ProcessLeadInDisplayStepAction(
processName = process.name,
processParameters = processParameters,
currentLeadInTime = timeToShow
)
actionsList.add(ftpliAction)
// add the chain of actions to the overall list
result.add(actionsList)
}
}

// how many steps do we need for the regular interval?
val howManySteps = process.processTime * 60 * 1000 / STEP_LENGTH_IN_MILLISECONDS
for (i in 1..howManySteps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.ListItem
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -122,7 +122,7 @@ fun TextFieldForTimes(
placeholder: @Composable (() -> Unit)? = null,
) {
var text by remember(value) { mutableStateOf(value.toString()) }
OutlinedTextField(
TextField(
value = text,
label = label,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class ProcessRunViewModel @Inject constructor(
val partialResult =
getProcessStepListForOneProcess(
process = process,
hasLeadIn = firstRound && userPreferencesRepository.beforeCountingWait().firstOrNull() ?: false,
leadInTime = userPreferencesRepository.howLongToWaitBeforeCounting().firstOrNull() ?: 5,
countBackwards = userPreferencesRepository.countBackwards().firstOrNull() ?: false,
)
result.addAll(partialResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ class SettingsViewModel @Inject constructor(
SharingStarted.WhileSubscribed(),
Theme.Auto
)
val beforeCountingWait: StateFlow<Boolean> = userPreferencesManager.beforeCountingWait().stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(),
false
)
val howLongToWaitBeforeCounting: StateFlow<Int> = userPreferencesManager.howLongToWaitBeforeCounting().stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(),
5
)
val countBackwards: StateFlow<Boolean> = userPreferencesManager.countBackwards().stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(),
Expand Down Expand Up @@ -63,18 +53,6 @@ class SettingsViewModel @Inject constructor(
}
}

fun updateBeforeCountingWait(newBeforeCountingWait: Boolean) {
viewModelScope.launch {
userPreferencesManager.setBeforeCountingWait(newBeforeCountingWait)
}
}

fun updateHowLongToWaitBeforeCounting(newHowLongToWaitBeforeCounting: Int) {
viewModelScope.launch {
userPreferencesManager.setHowLongToWaitBeforeCounting(newHowLongToWaitBeforeCounting)
}
}

fun updateCountBackwards(newCountBackwards: Boolean) {
viewModelScope.launch {
userPreferencesManager.setCountBackwards(newCountBackwards)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
Expand Down Expand Up @@ -95,7 +95,7 @@ fun ProcessEdit(
Row(modifier = Modifier
.fillMaxWidth()
.padding(8.dp)) {
OutlinedTextField(
TextField(
value = name ?: "Name",
onValueChange = {
processEditViewModel.updateName(it)
Expand All @@ -111,7 +111,7 @@ fun ProcessEdit(
.fillMaxWidth()
.padding(8.dp)
) {
OutlinedTextField(
TextField(
value = info ?: "Details",
onValueChange = {
processEditViewModel.updateInfo(it)
Expand All @@ -133,7 +133,7 @@ fun ProcessEdit(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
OutlinedTextField(
TextField(
// The `menuAnchor` modifier must be passed to the text field for correctness.
modifier = Modifier
.menuAnchor()
Expand Down Expand Up @@ -210,7 +210,7 @@ fun ProcessEdit(
ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = { expanded = !expanded }) {
OutlinedTextField(
TextField(
// The `menuAnchor` modifier must be passed to the text field for correctness.
modifier = Modifier
.menuAnchor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ package com.exner.tools.meditationtimer.ui.destinations

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.BottomAppBarDefaults
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
Expand All @@ -28,6 +31,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -73,23 +77,23 @@ fun ProcessList(
var categoryExpanded by remember {
mutableStateOf(false)
}
ExposedDropdownMenuBox(
expanded = categoryExpanded,
onExpandedChange = { categoryExpanded = !categoryExpanded }
Box(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp, 0.dp)
.wrapContentSize(Alignment.TopEnd)
) {
OutlinedTextField(
// The `menuAnchor` modifier must be passed to the text field for correctness.
modifier = Modifier
.menuAnchor()
.fillMaxWidth()
.padding(8.dp),
readOnly = true,
value = currentCategory.name,
onValueChange = {},
label = { Text("Process category") },
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = categoryExpanded) },
)
ExposedDropdownMenu(
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text(text = "Category: ")
Button(
onClick = { categoryExpanded = true }
) {
Text(text = currentCategory.name)
}
}
DropdownMenu(
expanded = categoryExpanded,
onDismissRequest = { categoryExpanded = false }) {
DropdownMenuItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
package com.exner.tools.meditationtimer.ui.destinations

import android.content.pm.ActivityInfo
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.exner.tools.meditationtimer.ui.LockScreenOrientation
import com.exner.tools.meditationtimer.ui.SettingsViewModel
import com.exner.tools.meditationtimer.ui.TextAndSwitch
import com.exner.tools.meditationtimer.ui.TextAndTriStateToggle
import com.exner.tools.meditationtimer.ui.TextFieldForTimes
import com.exner.tools.meditationtimer.ui.theme.MeditationTimerTheme
import com.exner.tools.meditationtimer.ui.theme.Theme
import com.ramcosta.composedestinations.annotation.Destination
Expand All @@ -33,8 +27,6 @@ fun Settings(
) {

val userSelectedTheme by settingsViewModel.userSelectedTheme.collectAsStateWithLifecycle()
val beforeCountingWait by settingsViewModel.beforeCountingWait.collectAsStateWithLifecycle()
val howLongToWaitBeforeCounting by settingsViewModel.howLongToWaitBeforeCounting.collectAsStateWithLifecycle()
val countBackwards by settingsViewModel.countBackwards.collectAsStateWithLifecycle()
val chainToSameCategoryOnly by settingsViewModel.chainToSameCategoryOnly.collectAsStateWithLifecycle()
val noSounds by settingsViewModel.noSounds.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -62,24 +54,6 @@ fun Settings(
TextAndSwitch(text = "Simplify Display", checked = showSimpleDisplay) {
settingsViewModel.updateShowSimpleDisplay(it)
}
TextAndSwitch(text = "Before counting, wait", checked = beforeCountingWait) {
settingsViewModel.updateBeforeCountingWait(it)
}
AnimatedVisibility(visible = beforeCountingWait) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp, 0.dp)
) {
TextFieldForTimes(
value = howLongToWaitBeforeCounting,
label = { Text(text = "How long to wait before counting (seconds)") },
onValueChange = {
settingsViewModel.updateHowLongToWaitBeforeCounting(it)
}
) { Text(text = "5") }
}
}
TextAndSwitch(
text = "Count backwards (down to 0)",
checked = countBackwards
Expand Down
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fastlane/metadata/android/en-US/images/phoneScreenshots/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f7b305

Please sign in to comment.