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

Commit

Permalink
Merge branch 'main' into header-offset-empirically
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammadali Rezaei authored Jul 7, 2024
2 parents cbe1d3b + 2b60ca9 commit 4416930
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 171 deletions.
26 changes: 26 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright 2024 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx5120m
org.gradle.workers.max=2

kotlin.incremental=false
kotlin.compiler.execution.strategy=in-process

# Controls KotlinOptions.allWarningsAsErrors. This is used in CI and can be set in local properties.
warningsAsErrors=true
53 changes: 53 additions & 0 deletions .github/workflows/update_deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Copyright 2024 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name: Update Versions / Dependencies

on:
schedule:
- cron: '9 0 1 * *'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
cache: gradle

- name: Update dependencies
run: ./gradlew versionCatalogUpdate
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.PAT }}
commit-message: 🤖 Update Dependencies
committer: compose-devrel-github-bot <[email protected]>
author: compose-devrel-github-bot <[email protected]>
signoff: false
branch: bot-update-deps
delete-branch: true
title: '🤖 Update Dependencies'
body: Updated depedencies
reviewers: ${{ github.actor }}
9 changes: 3 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt)
alias(libs.plugins.compose.compiler)
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()
buildFeatures {
dataBinding = true
}

defaultConfig {
applicationId = "com.google.samples.apps.sunflower"
minSdk = libs.versions.minSdk.get().toInt()
Expand Down Expand Up @@ -76,9 +75,6 @@ android {
dataBinding = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
packagingOptions {
// Multiple dependency bring these files in. Exclude them to enable
// our test APK to build (has no effect on our AARs)
Expand Down Expand Up @@ -142,6 +138,7 @@ dependencies {
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.runtime.livedata)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.glide)
implementation(libs.accompanist.systemuicontroller)
debugImplementation(libs.androidx.compose.ui.tooling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication : Application(), Configuration.Provider {
override fun getWorkManagerConfiguration(): Configuration =
Configuration.Builder()
.setMinimumLoggingLevel(if (BuildConfig.DEBUG) android.util.Log.DEBUG else android.util.Log.ERROR)
.build()
override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setMinimumLoggingLevel(if (BuildConfig.DEBUG) android.util.Log.DEBUG else android.util.Log.ERROR)
.build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand All @@ -33,11 +32,9 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.material3.Button
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -49,15 +46,17 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.data.GardenPlanting
import com.google.samples.apps.sunflower.data.Plant
import com.google.samples.apps.sunflower.data.PlantAndGardenPlantings
import com.google.samples.apps.sunflower.ui.SunflowerTheme
import com.google.samples.apps.sunflower.viewmodels.GardenPlantingListViewModel
import com.google.samples.apps.sunflower.viewmodels.PlantAndGardenPlantingsViewModel
import java.util.*
import java.util.Calendar

@Composable
fun GardenScreen(
Expand All @@ -66,7 +65,7 @@ fun GardenScreen(
onAddPlantClick: () -> Unit,
onPlantClick: (PlantAndGardenPlantings) -> Unit
) {
val gardenPlants by viewModel.plantAndGardenPlantings.collectAsState(initial = emptyList())
val gardenPlants by viewModel.plantAndGardenPlantings.collectAsStateWithLifecycle()
GardenScreen(
gardenPlants = gardenPlants,
modifier = modifier,
Expand Down Expand Up @@ -117,7 +116,7 @@ private fun GardenList(
}

@OptIn(
ExperimentalMaterial3Api::class
ExperimentalGlideComposeApi::class
)
@Composable
private fun GardenListItem(
Expand All @@ -140,7 +139,7 @@ private fun GardenListItem(
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.secondaryContainer)
) {
Column(Modifier.fillMaxWidth()) {
SunflowerImage(
GlideImage(
model = vm.imageUrl,
contentDescription = plant.plant.description,
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
Expand All @@ -55,7 +55,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState

import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
Expand All @@ -82,13 +82,15 @@ import androidx.compose.ui.viewinterop.AndroidViewBinding
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.core.text.HtmlCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.Dimens
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.compose.utils.TextSnackbarContainer
import com.google.samples.apps.sunflower.compose.visible
import com.google.samples.apps.sunflower.data.Plant
Expand All @@ -115,10 +117,10 @@ fun PlantDetailsScreen(
onGalleryClick: (Plant) -> Unit,
) {
val plant = plantDetailsViewModel.plant.observeAsState().value
val isPlanted = plantDetailsViewModel.isPlanted.collectAsState(initial = false).value
val isPlanted = plantDetailsViewModel.isPlanted.collectAsStateWithLifecycle().value
val showSnackbar = plantDetailsViewModel.showSnackbar.observeAsState().value

if (plant != null && isPlanted != null && showSnackbar != null) {
if (plant != null && showSnackbar != null) {
Surface {
TextSnackbarContainer(
snackbarText = stringResource(R.string.added_plant_to_garden),
Expand Down Expand Up @@ -265,6 +267,7 @@ private fun PlantDetailsContent(
}
}

@OptIn(ExperimentalGlideComposeApi::class)
@Composable
private fun PlantImage(
imageUrl: String,
Expand All @@ -287,7 +290,7 @@ private fun PlantImage(
.background(placeholderColor)
)
}
SunflowerImage(
GlideImage(
model = imageUrl,
contentDescription = null,
modifier = Modifier
Expand Down Expand Up @@ -388,7 +391,7 @@ private fun PlantDetailsToolbar(
Modifier.align(Alignment.CenterVertically)
) {
Icon(
Icons.Filled.ArrowBack,
Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.a11y_back)
)
}
Expand Down Expand Up @@ -451,7 +454,7 @@ private fun PlantHeaderActions(
.then(iconModifier)
) {
Icon(
Icons.Filled.ArrowBack,
Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.a11y_back)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -33,8 +32,9 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.google.samples.apps.sunflower.R
import com.google.samples.apps.sunflower.compose.utils.SunflowerImage
import com.google.samples.apps.sunflower.data.Plant
import com.google.samples.apps.sunflower.data.UnsplashPhoto

Expand All @@ -48,7 +48,7 @@ fun PhotoListItem(photo: UnsplashPhoto, onClick: () -> Unit) {
ImageListItem(name = photo.user.name, imageUrl = photo.urls.small, onClick = onClick)
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
Card(
Expand All @@ -59,7 +59,7 @@ fun ImageListItem(name: String, imageUrl: String, onClick: () -> Unit) {
.padding(bottom = dimensionResource(id = R.dimen.card_bottom_margin))
) {
Column(Modifier.fillMaxWidth()) {
SunflowerImage(
GlideImage(
model = imageUrl,
contentDescription = stringResource(R.string.a11y_plant_item_image),
Modifier
Expand Down

This file was deleted.

Loading

0 comments on commit 4416930

Please sign in to comment.