Skip to content

Commit

Permalink
classes cleaned of all logs
Browse files Browse the repository at this point in the history
  • Loading branch information
srsingh04 authored and alejandrocalles committed Jun 2, 2024
1 parent ac73a02 commit bef0e09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ fun ProfileCreationScreen(

if (state == CreateProfileState.SAVED) {
LaunchedEffect(state) { navAction.navigateTo(Routes.MAP) }
} else {
Log.d("CreateProfile", "State: $state")
}

ProfileCreationUI(
Expand Down Expand Up @@ -192,7 +190,6 @@ fun ProfileCreationScreen(
.testTag("saving-overlay"),
contentAlignment = Alignment.Center
) {
Log.d("CreateProfile", "Saving overlay")
CircularProgressIndicator()
}
}
Expand Down Expand Up @@ -274,14 +271,9 @@ fun ProfileCreationUI(
Row {
Column {
// Profile picture
Log.d("CreateProfile", "Profile picture")
Log.d("CreateProfile", "Picture: $picture")
ProfilePictureEdit(picture, onPictureChange)
Log.d("CreateProfile", "Picture: $picture")
Log.d("CreateProfile", "Profile picture done")

// First name and last name fields
Log.d("CreateProfile", "First name field")
OutlinedTextField(
value = firstName,
onValueChange = { onFirstNameChange(it) },
Expand All @@ -298,7 +290,7 @@ fun ProfileCreationUI(
Spacer(modifier = modifier.height(spacerHeight))

// Last name field
Log.d("CreateProfile", "Last name field")

OutlinedTextField(
value = lastName,
onValueChange = { onLastNameChange(it) },
Expand All @@ -317,24 +309,21 @@ fun ProfileCreationUI(

// Section and semester dropdown menus

Log.d("CreateProfile", "displaying sections")
DropDownListFunctionWrapper(
sectionList,
R.string.section,
selectedSec ?: "",
onSecChange
)
Log.d("CreateProfile", "end sections")

Spacer(modifier = modifier.height(spacerHeight))

Log.d("CreateProfile", "displaying semesters")
DropDownListFunctionWrapper(
semList,
R.string.select_semester,
selectedSem ?: "",
onSemChange
)
Log.d("CreateProfile", "end semesters")
Spacer(modifier = modifier.height(spacerHeight.times(2)))

// Tags
Expand All @@ -346,16 +335,13 @@ fun ProfileCreationUI(

Spacer(modifier = modifier.height(spacerHeight.times(2)))

Log.d("CreateProfile", "displaying tags")
Log.d("CreateProfile", "Taglist: $tagList")
FlowRow(horizontalArrangement = Arrangement.spacedBy(spaceBetweenTags)) {
for (tag in tagList) {
InputChipFun(tag.name) { tagDelete(tag) }
}
Log.d("CreateProfile", "end Taglist")
Log.d("CreateProfile", "Taglist: $tagList")

// Add tag button
Log.d("CreateProfile", "Add tag button")

SmallFloatingActionButton(
onClick = { onAdd() },
containerColor = MaterialTheme.colorScheme.secondaryContainer,
Expand All @@ -377,21 +363,18 @@ fun ProfileCreationUI(
if (firstName.isBlank() || lastName.isBlank()) {
scope.launch {
if (firstName.isBlank()) {
Log.d("CreateProfile", "First name is blank")
snackbarHostState.showSnackbar(
errorFN,
withDismissAction = true
)
} else {
Log.d("CreateProfile", "Last name is blank")
snackbarHostState.showSnackbar(
errorLN,
withDismissAction = true
)
}
}
} else {
Log.d("CreateProfile", "Saving profile with no internet connection")
try {
onSave(firstName, lastName)
} catch (e: RepositoryStoreWhileNoInternetException) {
Expand Down Expand Up @@ -427,8 +410,6 @@ fun DropDownListFunctionWrapper(
val icon = if (showDropdown) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown
Column {
Box {
Log.d("CreateProfile", "Selected field: $selectedField")
Log.d("CreateProfile", "Label: $label")
OutlinedTextField(
value = selectedField,
onValueChange = {},
Expand Down Expand Up @@ -478,7 +459,6 @@ fun InputChipFun(
) {
var selected by remember { mutableStateOf(true) }
if (!selected) return
Log.d("CreateProfile", "Tag: $text")

InputChip(
selected = selected,
Expand Down Expand Up @@ -525,7 +505,7 @@ fun ProfilePictureEdit(picture: Bitmap?, onPictureChange: (newPicture: Bitmap?)
}
}
}
Log.d("CreateProfile", "Picture: $picture")

val pictureDisplaySize = 100.dp
val pictureStartPadding = 5.dp
val pictureAlpha = 0.5f
Expand All @@ -548,7 +528,6 @@ fun ProfilePictureEdit(picture: Bitmap?, onPictureChange: (newPicture: Bitmap?)

Column(modifier = Modifier.padding(start = pictureStartPadding)) {
Box {
Log.d("CreateProfile", "Picture: $picture")
Image(
modifier =
Modifier.size(pictureDisplaySize)
Expand All @@ -565,7 +544,6 @@ fun ProfilePictureEdit(picture: Bitmap?, onPictureChange: (newPicture: Bitmap?)
if (picture != null) {
BitmapPainter(picture!!.asImageBitmap())
} else {
Log.d("CreateProfile", "Picture is null")
painterResource(R.drawable.echologoround)
},
contentDescription = "",
Expand All @@ -581,8 +559,6 @@ fun ProfilePictureEdit(picture: Bitmap?, onPictureChange: (newPicture: Bitmap?)
if (showCamera) {
dispatchTakePictureIntent(cameraLauncher)
showCamera = false
} else {
Log.d("CreateProfile", "Camera not available")
}
IconButton(
modifier = Modifier.testTag("profile-picture-camera"),
Expand Down Expand Up @@ -616,8 +592,6 @@ fun ProfilePictureEdit(picture: Bitmap?, onPictureChange: (newPicture: Bitmap?)
}
)
}
} else {
Log.d("CreateProfile", "Picture dialog not shown")
}
}

Expand Down Expand Up @@ -711,8 +685,6 @@ fun PictureTransformer(
newPicture =
Bitmap.createScaledBitmap(newPicture, maxResolution, maxResolution, true)
onConfirm(newPicture)
Log.d("CreateProfile", "Picture centered")
Log.d("CreateProfile", "New picture: $newPicture")
}
) {
Text(stringResource(R.string.edit_event_screen_confirm))
Expand All @@ -730,5 +702,8 @@ private fun dispatchTakePictureIntent(cameraLauncher: ActivityResultLauncher<Int
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
try {
cameraLauncher.launch(takePictureIntent)
} catch (_: ActivityNotFoundException) {}
} catch (_: ActivityNotFoundException) {
// display error state to the user
Log.e("CreateProfile", "Error!")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.github.swent.echo.viewmodels.authentication

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.github.swent.echo.authentication.AuthenticationService
Expand All @@ -19,7 +18,6 @@ import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

enum class CreateProfileState {
EDIT,
Expand Down Expand Up @@ -84,12 +82,10 @@ constructor(

fun setSelectedSection(section: Section?) {
_selectedSection.value = section
println("Selected section: ${_selectedSection.value}\n")
}

fun setSelectedSemester(semester: Semester?) {
_selectedSemester.value = semester
println("Selected semester: ${_selectedSemester.value}\n")
}

init {
Expand Down Expand Up @@ -132,22 +128,11 @@ constructor(

val userId = authenticationService.getCurrentUserID()
if (userId == null) {
Log.d("nullUserId", "User ID is null")
_errorMessage.value = "Profile creation error: Not logged in"
} else {
// TODO: show loading animation while saving the profile
runBlocking {
// _state.value = CreateProfileState.SAVING
println("User profile name: ${_firstName.value}\n")
println("User profile section: ${_selectedSection.value}\n")
println("User profile semester: ${_selectedSemester.value}\n")
println("User profile tags: ${_tagList.value}\n")
println("User profile committee member: ${_committeeMember.value}\n")
println(
"User profile associations subscriptions: ${_associationSubscriptions.value}\n"
)
println("User profile picture: ${_picture.value}\n")

viewModelScope.launch {
_state.value = CreateProfileState.SAVING
repository.setUserProfile(
UserProfile(
userId,
Expand All @@ -166,9 +151,7 @@ constructor(
picture.value!!.compress(Bitmap.CompressFormat.JPEG, 100, pictureStream)
repository.setUserProfilePicture(userId, pictureStream.toByteArray())
}
println("NEW User profile picture: ${_picture.value}\n")
println("User profile saved\n")
// _state.value = CreateProfileState.SAVED
_state.value = CreateProfileState.SAVED
}
}
}
Expand Down

0 comments on commit bef0e09

Please sign in to comment.