Skip to content

Commit

Permalink
Add BackgroundType with options of Transparent and Solid (#22)
Browse files Browse the repository at this point in the history
Adds a new field to Style to select, Background Type: lets athletes choose to have their art with a transparent background or a solid color background. In the future, this will be used for multiple different gradient backgrounds too.
Adds feature education next to transparent choice and in the preview menu when a checkered background is shown.
Update the about screen to provide a link to personal e-mail.
  • Loading branch information
Tyler-Lopez authored Jan 31, 2023
1 parent 868fee9 commit 667af89
Show file tree
Hide file tree
Showing 31 changed files with 735 additions and 304 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
applicationId "com.activityartapp"
minSdk 26
targetSdk 33
versionCode 7
versionName "1.1.1"
versionCode 8
versionName "1.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -173,4 +173,5 @@ dependencies {
androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.9.1"
androidTestImplementation "io.mockk:mockk-android:1.10.5"
androidTestImplementation 'androidx.test:runner:1.5.2'
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AthleteUsageRepositoryImpl @Inject constructor(private val db: FirebaseDat
AthleteUsageRepository {

companion object {
private const val TIMEOUT_TASK_MS = 5000L
private const val TIMEOUT_TASK_MS = 7500L
}

override suspend fun getAthleteUsage(athleteId: String): Response<Int> {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/activityartapp/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ object AppModule {
@Provides
fun provideActivitySortUtils(timeUtils: TimeUtils) = ActivitySortUtils(timeUtils)

@Provides
fun provideColorBrightnessUtils() = ColorBrightnessUtils()

@Provides
fun provideImageSizeUtils() = ImageSizeUtils()

Expand All @@ -155,9 +158,10 @@ object AppModule {
@Provides
fun provideVisualizationUtils(
activitySortUtils: ActivitySortUtils,
colorBrightnessUtils: ColorBrightnessUtils,
@ApplicationContext appContext: Context
) =
VisualizationUtils(appContext, activitySortUtils)
VisualizationUtils(appContext, activitySortUtils, colorBrightnessUtils)

@Provides
fun provideFileRepository(@ApplicationContext appContext: Context): FileRepository =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ class MainActivity : ComponentActivity(), Router<MainDestination> {
route = SaveArt.withArgs(
args = arrayOf(
ActivityTypes to gson.toJson(activityTypes),
BackgroundType to backgroundType.toString(),
ColorActivitiesArgb to colorActivitiesArgb.toString(),
ColorBackgroundArgb to colorBackgroundArgb.toString(),
ColorsBackgroundArgb to gson.toJson(backgroundColorsArgb),
ColorFontArgb to colorFontArgb.toString(),
FilterDateAfterMs to filterAfterMs.toString(),
FilterDateBeforeMs to filterBeforeMs.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.activityartapp.architecture.ViewEvent
import com.activityartapp.architecture.ViewState
import com.activityartapp.presentation.editArtScreen.StrokeWidthType
import com.activityartapp.presentation.errorScreen.ErrorScreenType
import com.activityartapp.util.enums.BackgroundType
import com.activityartapp.util.enums.EditArtSortDirectionType
import com.activityartapp.util.enums.EditArtSortType
import com.activityartapp.util.enums.FontSizeType
Expand Down Expand Up @@ -34,8 +35,9 @@ sealed interface MainDestination : Destination {

data class NavigateSaveArt(
val activityTypes: List<String>,
val backgroundType: BackgroundType,
val backgroundColorsArgb: List<Int>,
val colorActivitiesArgb: Int,
val colorBackgroundArgb: Int,
val colorFontArgb: Int,
val filterBeforeMs: Long,
val filterAfterMs: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ fun MainNavHost(
screen = SaveArt,
navArgSpecifications = listOf(
ActivityTypes,
BackgroundType,
ColorActivitiesArgb,
ColorBackgroundArgb,
ColorsBackgroundArgb,
ColorFontArgb,
FilterDateAfterMs,
FilterDateBeforeMs,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.activityartapp.presentation.editArtScreen

enum class EditArtDialogType {
INFO_CHECKERED_BACKGROUND,
INFO_TRANSPARENT,
NAVIGATE_UP,
NONE
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.foundation.ScrollState
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.room.Ignore
import com.activityartapp.R
import com.activityartapp.architecture.ViewEvent
import com.activityartapp.architecture.ViewState
Expand All @@ -30,9 +29,10 @@ annotation class UnixMS

sealed interface EditArtViewEvent : ViewEvent {

object DialogNavigateUpCancelled : EditArtViewEvent
object ClickedInfoCheckeredBackground : EditArtViewEvent
object ClickedInfoTransparentBackground : EditArtViewEvent
object DialogDismissed : EditArtViewEvent
object DialogNavigateUpConfirmed : EditArtViewEvent
object MakeFullscreenClicked : EditArtViewEvent
object NavigateUpClicked : EditArtViewEvent
data class PageHeaderClicked(val position: Int) : EditArtViewEvent
object SaveClicked : EditArtViewEvent
Expand Down Expand Up @@ -82,13 +82,25 @@ sealed interface EditArtViewEvent : ViewEvent {
data class SizeRotated(val rotatedIndex: Int) : ArtMutatingEvent
data class SortDirectionChanged(val changedTo: EditArtSortDirectionType) : ArtMutatingEvent
data class SortTypeChanged(val changedTo: EditArtSortType) : ArtMutatingEvent
data class StyleColorFontUseCustomChanged(val useCustom: Boolean) : ArtMutatingEvent
data class StylesColorChanged(
val styleType: StyleType,
data class StyleBackgroundTypeChanged(val changedTo: BackgroundType) : ArtMutatingEvent
data class StyleColorActivitiesChanged(
val colorType: ColorType,
val changedTo: Float
) : ArtMutatingEvent

data class StyleColorsBackgroundChanged(
val changedIndex: Int,
val changedColorType: ColorType,
val changedTo: Float
) : ArtMutatingEvent

data class StyleColorFontChanged(
val colorType: ColorType,
val changedTo: Float
) : ArtMutatingEvent

data class StyleColorFontUseCustomChanged(val useCustom: Boolean) : ArtMutatingEvent

data class StylesStrokeWidthChanged(val changedTo: StrokeWidthType) : ArtMutatingEvent
data class TypeCustomTextChanged(
val section: EditArtTypeSection,
Expand All @@ -112,11 +124,11 @@ sealed interface EditArtViewState : ViewState {
private const val FADE_LENGTH_MS = 1000
}

val dialogNavigateUpActive: Boolean
val dialogActive: EditArtDialogType
val pagerStateWrapper: PagerStateWrapper

data class Loading(
override val dialogNavigateUpActive: Boolean = false,
override val dialogActive: EditArtDialogType = EditArtDialogType.NONE,
override val pagerStateWrapper: PagerStateWrapper = PagerStateWrapper(
pagerHeaders = EditArtHeaderType.values().toList(),
pagerState = PagerState(EditArtHeaderType.values().toList().size),
Expand All @@ -133,7 +145,7 @@ sealed interface EditArtViewState : ViewState {
@Parcelize
data class Standby(
@IgnoredOnParcel val bitmap: Bitmap? = null,
@IgnoredOnParcel override val dialogNavigateUpActive: Boolean = false,
@IgnoredOnParcel override val dialogActive: EditArtDialogType = EditArtDialogType.NONE,
val filterActivitiesCountDate: Int = 0,
val filterActivitiesCountDistance: Int = 0,
val filterActivitiesCountType: Int = 0,
Expand Down Expand Up @@ -166,11 +178,14 @@ sealed interface EditArtViewState : ViewState {
green = INIT_ACTIVITIES_GREEN,
red = INIT_ACTIVITIES_RED
),
val styleBackground: ColorWrapper = ColorWrapper(
alpha = INIT_BACKGROUND_ALPHA,
blue = INIT_BACKGROUND_BLUE,
green = INIT_BACKGROUND_GREEN,
red = INIT_BACKGROUND_RED
val styleBackgroundType: BackgroundType = BackgroundType.SOLID,
val styleBackgroundColors: List<ColorWrapper> = listOf(
ColorWrapper(
alpha = INIT_BACKGROUND_ALPHA,
blue = INIT_BACKGROUND_BLUE,
green = INIT_BACKGROUND_GREEN,
red = INIT_BACKGROUND_RED
)
),
val styleFont: ColorWrapper? = null,
val styleStrokeWidthType: StrokeWidthType = INIT_STROKE_WIDTH,
Expand Down Expand Up @@ -317,24 +332,6 @@ sealed interface DateSelection : Parcelable {
}
}

enum class StyleType(
@StringRes val headerStrRes: Int,
@StringRes val descriptionStrRes: Int
) {
BACKGROUND(
R.string.edit_art_style_background_header,
R.string.edit_art_style_background_description
),
ACTIVITIES(
R.string.edit_art_style_activities_header,
R.string.edit_art_style_activities_description
),
FONT(
R.string.edit_art_style_font_header,
R.string.edit_art_style_font_description
);
}

enum class ColorType {
RED,
GREEN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.activityartapp.presentation.editArtScreen

import androidx.activity.compose.BackHandler
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.tween
Expand All @@ -10,6 +11,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.activityartapp.R
Expand All @@ -19,6 +21,8 @@ import com.activityartapp.presentation.common.type.SubheadHeavy
import com.activityartapp.presentation.editArtScreen.EditArtHeaderType.*
import com.activityartapp.presentation.editArtScreen.EditArtViewEvent.NavigateUpClicked
import com.activityartapp.presentation.editArtScreen.EditArtViewEvent.SaveClicked
import com.activityartapp.presentation.editArtScreen.EditArtDialogType.*
import com.activityartapp.presentation.editArtScreen.composables.EditArtDialogInfo
import com.activityartapp.presentation.editArtScreen.composables.EditArtDialogNavigateUp
import com.activityartapp.presentation.editArtScreen.subscreens.filters.EditArtFiltersScreen
import com.activityartapp.presentation.editArtScreen.subscreens.preview.EditArtPreview
Expand All @@ -29,8 +33,7 @@ import com.activityartapp.presentation.editArtScreen.subscreens.type.EditArtType
import com.activityartapp.presentation.ui.theme.White
import com.activityartapp.presentation.ui.theme.spacing
import com.activityartapp.util.classes.YearMonthDay
import com.activityartapp.util.enums.EditArtSortDirectionType
import com.activityartapp.util.enums.EditArtSortType
import com.activityartapp.util.enums.BackgroundType
import com.google.accompanist.pager.ExperimentalPagerApi

private const val DISABLED_ALPHA = 0.5f
Expand Down Expand Up @@ -100,7 +103,9 @@ fun EditArtViewDelegate(viewModel: EditArtViewModel) {
when (it) {
PREVIEW -> EditArtPreview(
atLeastOneActivitySelected,
bitmap
styleBackgroundType == BackgroundType.TRANSPARENT,
bitmap,
viewModel
)
FILTERS -> YearMonthDay.run {
EditArtFiltersScreen(
Expand All @@ -120,8 +125,9 @@ fun EditArtViewDelegate(viewModel: EditArtViewModel) {
)
}
STYLE -> EditArtStyleViewDelegate(
styleBackgroundColors,
styleBackgroundType,
styleActivities,
styleBackground,
styleFont,
styleStrokeWidthType,
viewModel
Expand Down Expand Up @@ -161,6 +167,24 @@ fun EditArtViewDelegate(viewModel: EditArtViewModel) {
}
}
}
EditArtDialogNavigateUp(eventReceiver = viewModel, isVisible = dialogNavigateUpActive)

/** Only intercept when the dialog box is not visible **/
BackHandler(enabled = dialogActive == NONE) {
viewModel.onEvent(NavigateUpClicked)
}

println("Here, dialog active is $dialogActive")
when (dialogActive) {
INFO_CHECKERED_BACKGROUND -> EditArtDialogInfo(
body = stringArrayResource(id = R.array.edit_art_dialog_info_background_checkered),
eventReceiver = viewModel
)
INFO_TRANSPARENT -> EditArtDialogInfo(
body = stringArrayResource(id = R.array.edit_art_dialog_info_background_transparent),
eventReceiver = viewModel
)
NAVIGATE_UP -> EditArtDialogNavigateUp(eventReceiver = viewModel)
NONE -> {} // No-op
}
}
}
Loading

0 comments on commit 667af89

Please sign in to comment.