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

Commit

Permalink
Hotfixes (#44)
Browse files Browse the repository at this point in the history
* collected states more safely

* corrected spelling mistake

* replaced hardcoded strings with resources

* bumped release version

* parallel gradle building

---------

Co-authored-by: Philip Cramer <s224319@dtu.dk>
  • Loading branch information
MikaelFangel and PhilipCramer authored Oct 23, 2023
1 parent 62954f4 commit c7b3e40
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 23 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.slgi.slgiapp"
minSdk 28
targetSdk 34
versionCode 3
versionName "1.8.0"
versionCode 4
versionName "1.8.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -51,6 +51,7 @@ dependencies {

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-runtime-compose:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2'
implementation 'androidx.activity:activity-compose:1.8.0'
implementation "androidx.compose.ui:ui:$compose_version"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/slgi/slgiapp/SLGINavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
Expand Down Expand Up @@ -74,7 +74,7 @@ fun SLGINavHost(
RegistrationScreenViewModel(RequestRepository(RequestDataSource()))
}

val loginState = loginScreenViewModel.uiState.collectAsState()
val loginState = loginScreenViewModel.uiState.collectAsStateWithLifecycle()


// TODO Temporary delete user safety
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/slgi/slgiapp/ui/LoginScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.slgi.slgiapp.R
import com.slgi.slgiapp.data.LoginNetworkDataSource
import com.slgi.slgiapp.data.LoginRepository
Expand All @@ -72,7 +73,7 @@ fun LoginScreen(
requestAction: () -> Unit,
forgotPasswordAction: (Int) -> Unit
) {
val uiState = viewModel.uiState.collectAsState()
val uiState = viewModel.uiState.collectAsStateWithLifecycle()
val focusManager = LocalFocusManager.current

val scope = rememberCoroutineScope()
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/slgi/slgiapp/ui/MyEventsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.slgi.slgiapp.R
import com.slgi.slgiapp.ui.shared.CreateEventModal
import com.slgi.slgiapp.ui.shared.EventCard
Expand All @@ -22,8 +23,8 @@ fun MyEventsScreen(
viewModel: UpcomingEventsScreenViewModel,
bottomBar: @Composable () -> Unit,
) {
val events = viewModel.events.collectAsState(initial = emptyList())
val uiState = viewModel.uiState.collectAsState()
val events = viewModel.events.collectAsStateWithLifecycle(initialValue = emptyList())
val uiState = viewModel.uiState.collectAsStateWithLifecycle()

Scaffold(
bottomBar = bottomBar
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/slgi/slgiapp/ui/RegistrationScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -39,6 +38,7 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.slgi.slgiapp.R
import com.slgi.slgiapp.ui.shared.TopBar
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -66,7 +66,7 @@ fun RegistrationScreen(
)
}
) { innerPadding ->
val uiState = viewModel.uiState.collectAsState()
val uiState = viewModel.uiState.collectAsStateWithLifecycle()
val focusManager = LocalFocusManager.current

Column(
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/slgi/slgiapp/ui/UpcomingEventsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.slgi.slgiapp.R
import com.slgi.slgiapp.ui.shared.CreateEventModal
import com.slgi.slgiapp.ui.shared.EventCard
Expand All @@ -29,9 +30,9 @@ fun UpcomingEventsScreen(
loginScreenViewModel: LoginScreenViewModel,
bottomBar: @Composable () -> Unit,
) {
val events = viewModel.events.collectAsState(initial = emptyList())
val uiState = viewModel.uiState.collectAsState()
val loginState = loginScreenViewModel.uiState.collectAsState()
val events = viewModel.events.collectAsStateWithLifecycle(initialValue = emptyList())
val uiState = viewModel.uiState.collectAsStateWithLifecycle()
val loginState = loginScreenViewModel.uiState.collectAsStateWithLifecycle()

Scaffold(
bottomBar = bottomBar,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/slgi/slgiapp/ui/UserRequestsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.slgi.slgiapp.R
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -39,7 +39,7 @@ fun UserRequestsScreen(
viewModel: UserRequestsViewModel,
bottomBar: @Composable () -> Unit,
) {
val requests = viewModel.requests.collectAsState(initial = emptyList())
val requests = viewModel.requests.collectAsStateWithLifecycle(initialValue = emptyList())

val scope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.slgi.slgiapp.R
import com.slgi.slgiapp.ui.UpcomingEventsScreenViewModel

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -27,7 +29,7 @@ fun SelectDateDialog(viewModel: UpcomingEventsScreenViewModel){
},
enabled = datePickerState.selectedDateMillis != null
) {
Text("OK")
Text(text = stringResource(id = R.string.confirm))
}
},
dismissButton = {
Expand All @@ -36,7 +38,7 @@ fun SelectDateDialog(viewModel: UpcomingEventsScreenViewModel){
viewModel.dismissDateDialog()
}
) {
Text("Cancel")
Text(text = stringResource(id = R.string.cancel))
}
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties
import com.slgi.slgiapp.R
import com.slgi.slgiapp.ui.UpcomingEventsScreenViewModel

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -87,7 +89,7 @@ fun SelectTimeDialog(viewModel: UpcomingEventsScreenViewModel) {
TextButton(onClick = {
viewModel.dismissTimeDialog()
}) {
Text(text = "Dismiss")
Text(text = stringResource(id = R.string.cancel))
}

// confirm button
Expand All @@ -97,7 +99,7 @@ fun SelectTimeDialog(viewModel: UpcomingEventsScreenViewModel) {
viewModel.dismissTimeDialog()
}
) {
Text(text = "Confirm")
Text(text = stringResource(id = R.string.confirm))
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<string name="firstNameLabel">Fornavn</string>
<string name="lastNameLabel">Efternavn</string>
<string name="repeatPasswordLabel">Password igen</string>
<string name="acceptsTerms">Jeg acceptere betignelserne.</string>
<string name="acceptsTerms">Jeg acceptere betingelserne.</string>
<string name="requestButton">Anmod</string>
<string name="requestAccessLabel">Anmod om adgang</string>
<string name="login">Login</string>
Expand All @@ -37,6 +37,7 @@
<string name="approve">Godkend</string>
<string name="Settings">Indstillinger</string>
<string name="areYouSure">Er du sikker på at du ønsker at gennemføre handlingen? Denne handling kan ikke fortrydes når gennemført</string>

<string name="ok">OK</string>
<string name="logout">Log Af</string>
<string name="confirm">Bekræft</string>
</resources>
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ kotlin.code.style=official
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonFinalResIds=false

## Custom
org.gradle.daemon=true
org.gradle.parallel=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 21 12:59:22 CEST 2023
#Tue Oct 17 00:58:27 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit c7b3e40

Please sign in to comment.