Skip to content

Commit

Permalink
Fix add and add camera
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-terc authored and mariobodemann committed Jul 3, 2024
1 parent 2632429 commit 40e0b22
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion zeapp/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
applicationId = "de.berlindroid.zeapp"
compileSdk = 34
targetSdk = 34
minSdk = 33
minSdk = 29
versionCode = appVersionCode
versionName = "1.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private fun ZeScreen(vm: ZeBadgeViewModel, modifier: Modifier = Modifier) {
drawerState.close()
}
},
onTitleClick = goToGithubPage
onTitleClick = goToGithubPage,
)
},
) {
Expand All @@ -269,7 +269,7 @@ private fun ZeScreen(vm: ZeBadgeViewModel, modifier: Modifier = Modifier) {
onTitleClick = {
scope.launch { drawerState.close() }
goToGithubPage()
}
},
)
},
content = { paddingValues ->
Expand Down Expand Up @@ -299,7 +299,7 @@ private fun ZeDrawerContent(
onGotoReleaseClick: () -> Unit = {},
onUpdateConfig: () -> Unit = {},
onCloseDrawer: () -> Unit = {},
onTitleClick: () -> Unit = {}
onTitleClick: () -> Unit = {},
) {

@Composable
Expand Down Expand Up @@ -360,7 +360,7 @@ private fun ZeDrawerContent(
) {
ZeTitle(
modifier = Modifier.padding(horizontal = 16.dp, vertical = 64.dp),
){
) {
onTitleClick()
}

Expand Down Expand Up @@ -489,7 +489,7 @@ private fun ZeTopBar(
}
},
title = {
ZeTitle{
ZeTitle {
onTitleClick()
}
},
Expand All @@ -514,7 +514,7 @@ private fun ZeTopBar(
@Composable
private fun ZeTitle(
modifier: Modifier = Modifier,
titleClick: () -> Unit
titleClick: () -> Unit,
) {
ZeText(
modifier = modifier.clickable {
Expand Down Expand Up @@ -774,6 +774,8 @@ private fun SelectedEditor(
ZeSlot.Weather,
ZeSlot.Quote,
ZeSlot.BarCode,
ZeSlot.Add,
ZeSlot.Camera,
)
) {
Timber.e("Slot", "This slot '${editor.slot}' is not supposed to be editable.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ sealed class ZeSlot(val name: String) {
data object Weather : ZeSlot("Wa")
data object Quote : ZeSlot("Quite")
data object BarCode : ZeSlot("Ba")
data object Add: ZeSlot("Add")
data object Add : ZeSlot("Add")
data object Camera : ZeSlot("Camera")
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ class ZePreferencesService @Inject constructor(
ZeBadgeType.RANDOM_QUOTE -> ZeConfiguration.Quote(
message = slot.preferencesValue("quote_message"),
author = slot.preferencesValue("quote_author"),
bitmap = bitmap
bitmap = bitmap,
)

ZeBadgeType.CAMERA -> ZeConfiguration.Camera(bitmap)

else -> {
Timber.e(
"Slot from Prefs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import de.berlindroid.zeapp.zemodels.ZeEditor
import de.berlindroid.zeapp.zemodels.ZeSlot
import de.berlindroid.zeapp.zemodels.ZeTemplateChooser
import de.berlindroid.zeapp.zeservices.*
import de.berlindroid.zeapp.zeui.ZeCameraEditor
import de.berlindroid.zeapp.zeui.pixelManipulation
import de.berlindroid.zekompanion.ditherFloydSteinberg
import kotlinx.coroutines.*
Expand Down Expand Up @@ -107,7 +108,7 @@ class ZeBadgeViewModel @Inject constructor(
if (bitmap.isBinary()) {
viewModelScope.launch {
badgeManager.storePage(configuration.type.name, bitmap).fold(
onSuccess = {storeResult ->
onSuccess = { storeResult ->
delay(300) // serial stuff
badgeManager.showPage(configuration.type.name).fold(
onSuccess = { showResult ->
Expand Down Expand Up @@ -201,6 +202,16 @@ class ZeBadgeViewModel @Inject constructor(
slots[ZeSlot.BarCode]!!,
)

is ZeSlot.Add -> ZeEditor(
slot,
slots[ZeSlot.Add]!!,
)

is ZeSlot.Camera -> ZeEditor(
slot,
slots[ZeSlot.Camera]!!,
)

else -> {
Timber.d("Customize Page", "Cannot configure slot '${slot.name}'.")
null
Expand Down Expand Up @@ -346,11 +357,16 @@ class ZeBadgeViewModel @Inject constructor(
"",
R.drawable.soon.toBitmap(),
)

ZeSlot.Add -> ZeConfiguration.Name(
null,
null,
imageProviderService.provideImageBitmap(R.drawable.add),
)

ZeSlot.Camera -> ZeConfiguration.Camera(
imageProviderService.provideImageBitmap(R.drawable.soon),
)
}
}

Expand Down Expand Up @@ -469,6 +485,7 @@ class ZeBadgeViewModel @Inject constructor(
val slots = mapOf(
ZeSlot.Name to initialConfiguration(ZeSlot.Name),
ZeSlot.FirstSponsor to initialConfiguration(ZeSlot.FirstSponsor),
ZeSlot.Camera to initialConfiguration(ZeSlot.Camera),
ZeSlot.Add to initialConfiguration(ZeSlot.Add),
)
_uiState.update {
Expand Down
2 changes: 1 addition & 1 deletion zeapp/badge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ android {
namespace = "de.berlindroid.zebadge"
compileSdk = 34
defaultConfig {
minSdk = 33
minSdk = 29
}
}
2 changes: 1 addition & 1 deletion zeapp/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
}

defaultConfig {
minSdk = 33
minSdk = 29
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down

0 comments on commit 40e0b22

Please sign in to comment.