Skip to content

Commit

Permalink
Merge pull request #16 from ptrLx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ptrLx authored Apr 7, 2023
2 parents bda091f + 37f6743 commit 319fba1
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 126 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [1.1.1] - 2023-04-08

### New features

* German translation

### Bug fixes

* [#5] Image preview too dark: Removed gradient in large image view

## [1.1.0] - 2023-03-15

### New features
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ It stores your photos in a local folder and your diary within the app. Import an

Thank's to [@Cynog](https://github.com/Cynog) for providing the beautiful images in the screenshots!

## Translation

OneShot is currently available in following languages:

* English
* German

## Privacy

Your data is yours!
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "de.ptrlx.oneshot"
minSdk 29
targetSdk 32
versionCode 110
versionName '1.1.0'
versionCode 111
versionName '1.1.1'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ enum class HappinessType {
}
}

fun describe(): String {
return when (this) {
VERY_HAPPY -> "very happy"
HAPPY -> "happy"
NEUTRAL -> "neutral"
SAD -> "sad"
VERY_SAD -> "very sad"
NOT_SPECIFIED -> ""
}
}
// fun describe(): String {
// return when (this) {
// VERY_HAPPY -> "very happy"
// HAPPY -> "happy"
// NEUTRAL -> "neutral"
// SAD -> "sad"
// VERY_SAD -> "very sad"
// NOT_SPECIFIED -> ""
// }
// }

fun progress(): Float {
return when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ class DiaryViewModel @Inject constructor(
)
recentlyDeleteDiaryEntry = null
}
} else if (snackbarCause == SnackbarCause.SUCCESS) {
// nothing to do here
} else if (snackbarCause == SnackbarCause.SUCCESS) {
// nothing to do here
}
// else if (snackbarCause == SnackbarCause.SUCCESS) {
// nothing to do here
// } else if (snackbarCause == SnackbarCause.ERROR) {
// nothing to do here
// }
}
is DiaryEvent.WriteDBExport -> {
if (entries.isNotEmpty()) {
Expand Down Expand Up @@ -305,7 +306,7 @@ class DiaryViewModel @Inject constructor(

val uri = copyImageUri?.let {
fileManager?.copyImage(srcUri = copyImageUri, filename = filename)
}?: run {
} ?: run {
fileManager?.createNewImageDummy(filename)
}

Expand Down Expand Up @@ -348,4 +349,4 @@ class DiaryViewModel @Inject constructor(
modalBottomSheetShowEvent = true
modalBottomSheetHideEvent = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.rememberNavController
Expand Down Expand Up @@ -57,17 +58,17 @@ class MainActivity : ComponentActivity() {
BottomNavigationBar(
items = listOf(
BottomNavItem(
name = "Home",
name = stringResource(R.string.route_home),
route = "home",
painter = painterResource(id = R.drawable.ic_baseline_cottage_24)
),
BottomNavItem(
name = "Diary",
name = stringResource(R.string.route_diary),
route = "diary",
painter = painterResource(id = R.drawable.ic_baseline_photo_library_24)
),
BottomNavItem(
name = "Statistics",
name = stringResource(R.string.route_statistics),
route = "stats",
painter = painterResource(id = R.drawable.ic_baseline_leaderboard_24)
),
Expand All @@ -78,11 +79,12 @@ class MainActivity : ComponentActivity() {

) { _ ->
if (viewModel.isSnackbarShowing) {
val context = LocalContext.current
LaunchedEffect(viewModel.isSnackbarShowing) {
try {
when (scaffoldState.snackbarHostState.showSnackbar(
viewModel.snackbarCause.msg(),
actionLabel = viewModel.snackbarCause.actionLabel()
context.getString(viewModel.snackbarCause.msg()),
actionLabel = context.getString(viewModel.snackbarCause.actionLabel())
)) {
SnackbarResult.ActionPerformed -> {
viewModel.onEvent(DiaryEvent.SnackbarDismissed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -47,13 +48,13 @@ fun AddEntryButton(

RoundedButton(
modifier = modifier,
text = "Capture today",
text = stringResource(R.string.btn_capture_today),
onClick = {
viewModel.createNewImageDummy()?.let {
launcher.launch(it)
} ?: run {
val toast =
Toast.makeText(context, "Please set your base location path", Toast.LENGTH_LONG)
Toast.makeText(context, context.getString(R.string.msg_set_base_location), Toast.LENGTH_LONG)
toast.show()
}
}
Expand All @@ -75,7 +76,7 @@ fun AddEditEntryModalBottomSheetContent(
if (!viewModel.currentIsNewEntry)
Icon(
Icons.Default.Delete,
contentDescription = "delete",
contentDescription = stringResource(R.string.delete),
modifier = Modifier
.align(Alignment.TopStart)
.padding(16.dp)
Expand All @@ -87,7 +88,7 @@ fun AddEditEntryModalBottomSheetContent(
})
Icon(
Icons.Default.Done,
contentDescription = "done",
contentDescription = stringResource(R.string.done),
modifier = Modifier
.align(Alignment.TopEnd)
.padding(16.dp)
Expand All @@ -101,7 +102,7 @@ fun AddEditEntryModalBottomSheetContent(
) {
Icon(
painter = painterResource(id = R.drawable.ic_baseline_drag_handle_24),
contentDescription = "drag"
contentDescription = stringResource(R.string.drag)
)

Spacer(modifier = Modifier.size(18.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
Expand All @@ -30,7 +31,6 @@ fun ImageCard(
description: String,
expandOnClick: Boolean = false
) {
val contentDescription = "Diary entry: $description"
var expanded by remember { mutableStateOf(false) }

Card(
Expand All @@ -55,46 +55,47 @@ fun ImageCard(
AsyncImage(
modifier = Modifier.fillMaxWidth(),
model = viewModel.fileManager?.resolveUri(entry.relativePath),
contentDescription = contentDescription,
contentDescription = stringResource(R.string.desc_img_card, description),
error = painterResource(R.drawable.ic_baseline_error_24),
contentScale = if (!expanded) ContentScale.Crop else ContentScale.FillWidth,
)
// }

Box(
modifier = Modifier
.fillMaxSize()
.background(
brush = Brush.verticalGradient(
colors = listOf(
Color.Transparent,
Color.Black
),
startY = 300f
if (!expanded) {
Box(
modifier = Modifier
.fillMaxSize()
.background(
brush = Brush.verticalGradient(
colors = listOf(
Color.Transparent,
Color.Black
),
startY = 300f
)
)
)
)

Box(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
contentAlignment = Alignment.BottomStart
) {
Text(
description,
style = TextStyle(color = Color.White, fontSize = 16.sp),
fontWeight = FontWeight.Bold
)
}

Box(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
contentAlignment = Alignment.BottomEnd
) {
Text(entry.happiness.emoticon(), style = TextStyle(fontSize = 16.sp))
Box(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
contentAlignment = Alignment.BottomStart
) {
Text(
description,
style = TextStyle(color = Color.White, fontSize = 16.sp),
fontWeight = FontWeight.Bold
)
}

Box(
modifier = Modifier
.fillMaxSize()
.padding(12.dp),
contentAlignment = Alignment.BottomEnd
) {
Text(entry.happiness.emoticon(), style = TextStyle(fontSize = 16.sp))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import de.ptrlx.oneshot.R
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryEvent
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryViewModel

Expand All @@ -22,7 +24,7 @@ fun ImportImageButton(

RoundedButton(
modifier = modifier,
text = "Import image",
text = stringResource(R.string.btn_import_img),
onClick = {
launcher.launch("image/*")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import de.ptrlx.oneshot.R
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryEvent
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryViewModel

Expand All @@ -26,7 +28,7 @@ fun SetLocation(
val toast =
Toast.makeText(
context,
"Please move old images manually to the new folder",
context.getString(R.string.msg_move_old_imgs),
Toast.LENGTH_LONG
)
toast.show()
Expand All @@ -37,7 +39,7 @@ fun SetLocation(

RoundedButton(
modifier = modifier,
text = "Set image file path",
text = stringResource(R.string.btn_set_base_location),
onClick = { launcher.launch(viewModel.fileManager?.baseLocation) },
arrow = arrow
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import de.ptrlx.oneshot.R
import de.ptrlx.oneshot.feature_diary.domain.model.DiaryEntry
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryEvent
import de.ptrlx.oneshot.feature_diary.presentation.diary.DiaryViewModel
Expand Down Expand Up @@ -78,7 +80,11 @@ fun Flashbacks(
viewModel: DiaryViewModel
) {
val flashbackTitles =
listOf("Yesterday", "Last very happy day", "7 days ago", "14 days ago")
listOf(
stringResource(R.string.yesterday),
stringResource(R.string.last_very_happy_day),
stringResource(R.string.days_ago_7),
stringResource(R.string.days_ago_14))
val stripedFlashbacks = (if (viewModel.flashbacks.size >= 4)
(flashbackTitles.mapIndexed { i, title ->
Pair(
Expand All @@ -90,6 +96,7 @@ fun Flashbacks(
"Day ${entry?.dayOfYear} of ${entry?.date?.year}",
entry,
)
//todo extract string
}).filter { it.second != null }
else
emptyList()) as List<Pair<String, DiaryEntry>> // This cast is not unchecked as .filter will remove null values
Expand All @@ -98,7 +105,7 @@ fun Flashbacks(
Column(modifier = modifier) {
Text(
modifier = Modifier.padding(start = 8.dp, end = 8.dp),
text = "Flashbacks",
text = stringResource(R.string.flashbacks),
style = MaterialTheme.typography.h4,
fontWeight = FontWeight.Bold
)
Expand Down
Loading

0 comments on commit 319fba1

Please sign in to comment.