Skip to content

Commit

Permalink
[MBL-17720][All] Updated Jetpack Compose #2576
Browse files Browse the repository at this point in the history
refs: MBL-17720
affects: All
release note: Accessibility improvements in the calendar
  • Loading branch information
tamaskozmer authored Oct 2, 2024
1 parent 2f6e3d8 commit e9f26a0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import androidx.compose.material.Text
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -236,7 +236,7 @@ private fun StudentListItem(
}
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(color = Color(uiState.studentColor.color()))
indication = ripple(color = Color(uiState.studentColor.color()))
) {
actionHandler(ManageStudentsAction.ShowColorPickerDialog(uiState.studentId, uiState.studentColor))
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
implementation("com.android.tools.build:gradle-api:$agpVersion")
implementation("org.javassist:javassist:3.24.1-GA")
implementation("com.google.code.gson:gson:2.8.8")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
}

plugins {
Expand Down
15 changes: 8 additions & 7 deletions buildSrc/src/main/java/GlobalDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ object Versions {
const val JACOCO_ANDROID = "0.1.5"

/* Kotlin */
const val KOTLIN = "1.9.23"
const val KOTLIN = "1.9.25"
const val KOTLIN_COROUTINES = "1.6.4"
const val KOTLIN_COMPOSE_COMPILER_VERSION = "1.5.11"
const val KOTLIN_COMPOSE_COMPILER_VERSION = "1.5.15"

/* Google, Play Services */
const val GOOGLE_SERVICES = "4.3.15"
Expand Down Expand Up @@ -75,6 +75,7 @@ object Libs {
const val ANDROIDX_WORK_MANAGER_KTX = "androidx.work:work-runtime-ktx:${Versions.WORK_MANAGER}"
const val ANDROIDX_WEBKIT = "androidx.webkit:webkit:1.9.0"
const val ANDROIDX_DATABINDING_COMPILER = "androidx.databinding:databinding-compiler:${Versions.ANDROID_GRADLE_TOOLS}" // This is bundled with the gradle plugin so we use the same version
const val ANDROIDX_COMPOSE_ACTIVITY = "androidx.activity:activity-compose:1.8.2"

/* Firebase */
const val FIREBASE_BOM = "com.google.firebase:firebase-bom:32.6.0"
Expand Down Expand Up @@ -119,6 +120,7 @@ object Libs {
const val LIVE_DATA = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.LIFECYCLE}"
const val VIEW_MODE_SAVED_STATE = "androidx.lifecycle:lifecycle-viewmodel-savedstate:${Versions.LIFECYCLE}"
const val LIFECYCLE_COMPILER = "androidx.lifecycle:lifecycle-compiler:${Versions.LIFECYCLE}"
const val COMPOSE_VIEW_MODEL = "androidx.lifecycle:lifecycle-viewmodel-compose:${Versions.LIFECYCLE}"

/* Media and content handling */
const val PSPDFKIT = "com.pspdfkit:pspdfkit:${Versions.PSPDFKIT}"
Expand All @@ -133,6 +135,7 @@ object Libs {
const val GLIDE = "com.github.bumptech.glide:glide:${Versions.GLIDE_VERSION}"
const val GLIDE_OKHTTP = "com.github.bumptech.glide:okhttp3-integration:${Versions.GLIDE_VERSION}"
const val GLIDE_COMPILER = "com.github.bumptech.glide:compiler:${Versions.GLIDE_VERSION}"
const val GLIDE_COMPOSE = "com.github.bumptech.glide:compose:1.0.0-beta01"
const val SCALE_IMAGE_VIEW = "com.davemorrissey.labs:subsampling-scale-image-view:3.10.0"

/* Network */
Expand Down Expand Up @@ -170,16 +173,14 @@ object Libs {
const val RRULE = "org.scala-saddle:google-rfc-2445:20110304"

// Compose
const val COMPOSE_BOM = "androidx.compose:compose-bom:2024.03.00"
const val COMPOSE_BOM = "androidx.compose:compose-bom:2024.09.02"
const val COMPOSE_MATERIAL = "androidx.compose.material:material"
const val COMPOSE_MATERIAL_ICONS = "androidx.compose.material:material-icons-core"
const val COMPOSE_PREVIEW = "androidx.compose.ui:ui-tooling-preview"
const val COMPOSE_TOOLING = "androidx.compose.ui:ui-tooling"
const val COMPOSE_UI = "androidx.compose.ui:ui-android"
const val COMPOSE_VIEW_MODEL = "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
const val COMPOSE_UI_TEST = "androidx.compose.ui:ui-test-junit4:1.6.4"
const val COMPOSE_UI_TEST = "androidx.compose.ui:ui-test-junit4"
const val COMPOSE_UI_TEST_MANIFEST = "androidx.compose.ui:ui-test-manifest"
const val COMPOSE_ACTIVITY = "androidx.activity:activity-compose:1.8.2"
const val COMPOSE_GLIDE = "com.github.bumptech.glide:compose:1.0.0-beta01"

// Navigation
const val NAVIGATION_FRAGMENT = "androidx.navigation:navigation-fragment-ktx:${Versions.NAVIGATION}"
Expand Down
5 changes: 3 additions & 2 deletions libs/pandautils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,13 @@ dependencies {

api Libs.COMPOSE_BOM
api Libs.COMPOSE_MATERIAL
api Libs.COMPOSE_MATERIAL_ICONS
api Libs.COMPOSE_PREVIEW
debugApi Libs.COMPOSE_TOOLING
api Libs.COMPOSE_VIEW_MODEL
api Libs.COMPOSE_UI
api Libs.COMPOSE_ACTIVITY
api Libs.COMPOSE_GLIDE
api Libs.ANDROIDX_COMPOSE_ACTIVITY
api Libs.GLIDE_COMPOSE

implementation Libs.FLEXBOX_LAYOUT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import androidx.annotation.FontRes
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.LocalRippleConfiguration
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.RippleConfiguration
import androidx.compose.material.Typography
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.ripple.RippleAlpha
import androidx.compose.material.ripple.RippleTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
Expand All @@ -41,6 +42,7 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import com.instructure.pandautils.R

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun CanvasTheme(content: @Composable () -> Unit) {
MaterialTheme(
Expand All @@ -49,7 +51,7 @@ fun CanvasTheme(content: @Composable () -> Unit) {
)
) {
CompositionLocalProvider(
LocalRippleTheme provides CanvasRippleTheme,
LocalRippleConfiguration provides RippleConfiguration(color = colorResource(id = R.color.backgroundDark), getRippleAlpha(isSystemInDarkTheme())),
LocalTextSelectionColors provides getCustomTextSelectionColors(context = LocalContext.current),
LocalTextStyle provides TextStyle(
fontFamily = lato,
Expand Down Expand Up @@ -78,15 +80,23 @@ fun overrideComposeFonts(@FontRes fontResource: Int) {
)
}

private object CanvasRippleTheme : RippleTheme {
@Composable
override fun defaultColor(): Color = colorResource(id = R.color.backgroundDark)
private fun getRippleAlpha(isSystemInDarkTheme: Boolean): RippleAlpha {
return if (isSystemInDarkTheme) {
RippleAlpha(
pressedAlpha = 0.10f,
focusedAlpha = 0.12f,
draggedAlpha = 0.08f,
hoveredAlpha = 0.04f
)
} else {
RippleAlpha(
pressedAlpha = 0.24f,
focusedAlpha = 0.24f,
draggedAlpha = 0.16f,
hoveredAlpha = 0.08f
)
}

@Composable
override fun rippleAlpha(): RippleAlpha = RippleTheme.defaultRippleAlpha(
Color.Black,
lightTheme = !isSystemInDarkTheme()
)
}

private fun getCustomTextSelectionColors(context: Context): TextSelectionColors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ fun ComposeRCE(
MediaUploadUtils.showPickImageDialog(
activity = context.getFragmentActivity(),
onNewPhotoClick = {
photoLauncher.launch(imageUri)
imageUri?.let {
photoLauncher.launch(it)
}
},
onChooseFromGalleryClick = {
imagePickerLauncher.launch("image/*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fun Calendar(calendarUiState: CalendarUiState, actionHandler: (CalendarAction) -
thresholds = { _, _ -> FractionalThreshold(0.5f) },
).testTag("calendarPager"),
state = pagerState,
beyondBoundsPageCount = 2,
beyondViewportPageCount = 2,
reverseLayout = false,
pageSize = PageSize.Fill,
pageContent = { page ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fun CalendarEvents(
HorizontalPager(
state = pagerState,
modifier = modifier,
beyondBoundsPageCount = 2,
beyondViewportPageCount = 2,
reverseLayout = false,
pageSize = PageSize.Fill,
pageContent = { page ->
Expand Down

0 comments on commit e9f26a0

Please sign in to comment.