diff --git a/build.gradle.kts b/build.gradle.kts
index 63c1c06..df335e0 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,13 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- val compose_version by extra("1.0.1")
+ val kotlinCompilerExtensionVersion by extra("1.3.2")
+
repositories {
google()
mavenCentral()
}
dependencies {
- classpath("com.android.tools.build:gradle:7.0.1")
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")
+ classpath("com.android.tools.build:gradle:7.3.1")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index be18468..48bba24 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Jul 22 19:40:39 IST 2021
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
diff --git a/plot/build.gradle.kts b/plot/build.gradle.kts
index 340577b..92b15b6 100644
--- a/plot/build.gradle.kts
+++ b/plot/build.gradle.kts
@@ -16,11 +16,11 @@ ext {
apply(from = "publish.gradle")
android {
- compileSdk = 30
+ compileSdk = 33
defaultConfig {
minSdk = 21
- targetSdk = 30
+ targetSdk = 33
version = libVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@@ -45,24 +45,32 @@ android {
compose = true
}
composeOptions {
- kotlinCompilerExtensionVersion = rootProject.extra["compose_version"] as String
+ kotlinCompilerExtensionVersion = rootProject.extra["kotlinCompilerExtensionVersion"] as String
}
lint {
- isAbortOnError = true
- isWarningsAsErrors = true
+ abortOnError = true
+ warningsAsErrors = true
}
+ namespace = "com.madrapps.plot"
}
dependencies {
- implementation("androidx.core:core-ktx:1.6.0")
- implementation("androidx.appcompat:appcompat:1.3.1")
- implementation("com.google.android.material:material:1.4.0")
- implementation("androidx.compose.ui:ui:${rootProject.extra["compose_version"]}")
- implementation("androidx.compose.material:material:${rootProject.extra["compose_version"]}")
- implementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}")
+ implementation("androidx.core:core-ktx:1.9.0")
+ implementation("androidx.appcompat:appcompat:1.5.1")
+ implementation("com.google.android.material:material:1.7.0")
+
+ // Compose
+ val composeBom = platform("androidx.compose:compose-bom:2022.10.00")
+ implementation(composeBom)
+ androidTestImplementation(composeBom)
+ implementation("androidx.compose.material3:material3")
+ implementation("androidx.compose.ui:ui")
+ implementation("androidx.compose.ui:ui-tooling-preview")
+ debugImplementation("androidx.compose.ui:ui-tooling")
+ androidTestImplementation("androidx.compose.ui:ui-test-junit4")
+ implementation("androidx.activity:activity-compose:1.6.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
- androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}")
}
diff --git a/plot/src/main/AndroidManifest.xml b/plot/src/main/AndroidManifest.xml
index b9a6cdd..8072ee0 100644
--- a/plot/src/main/AndroidManifest.xml
+++ b/plot/src/main/AndroidManifest.xml
@@ -1,2 +1,2 @@
-
+
diff --git a/plot/src/main/java/com/madrapps/plot/Gestures.kt b/plot/src/main/java/com/madrapps/plot/Gestures.kt
index 5791349..f9f8c56 100644
--- a/plot/src/main/java/com/madrapps/plot/Gestures.kt
+++ b/plot/src/main/java/com/madrapps/plot/Gestures.kt
@@ -1,5 +1,6 @@
package com.madrapps.plot
+import android.annotation.SuppressLint
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.calculateCentroidSize
import androidx.compose.foundation.gestures.calculateZoom
@@ -13,18 +14,15 @@ import androidx.compose.ui.input.pointer.PointerInputChange
import androidx.compose.ui.input.pointer.PointerInputScope
import androidx.compose.ui.input.pointer.changedToUp
import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed
-import androidx.compose.ui.input.pointer.consumeAllChanges
-import androidx.compose.ui.input.pointer.consumeDownChange
-import androidx.compose.ui.input.pointer.consumePositionChange
import androidx.compose.ui.input.pointer.isOutOfBounds
import androidx.compose.ui.input.pointer.positionChange
-import androidx.compose.ui.input.pointer.positionChangeConsumed
import androidx.compose.ui.input.pointer.positionChanged
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.withTimeout
import kotlin.coroutines.cancellation.CancellationException
import kotlin.math.abs
+@SuppressLint("ReturnFromAwaitPointerEventScope", "MultipleAwaitPointerEventScopes")
@SuppressWarnings("LoopWithTooManyJumpStatements")
internal suspend fun PointerInputScope.detectDragZoomGesture(
isZoomAllowed: Boolean = false,
@@ -47,7 +45,7 @@ internal suspend fun PointerInputScope.detectDragZoomGesture(
do {
val event = awaitPointerEvent()
- val canceled = event.changes.any { it.positionChangeConsumed() }
+ val canceled = event.changes.any { it.isConsumed }
if (event.changes.size == 1) {
break
} else if (event.changes.size == 2) {
@@ -72,7 +70,7 @@ internal suspend fun PointerInputScope.detectDragZoomGesture(
}
event.changes.forEach {
if (it.positionChanged()) {
- it.consumeAllChanges()
+ it.consume()
}
}
}
@@ -93,13 +91,13 @@ internal suspend fun PointerInputScope.detectDragZoomGesture(
if (
drag(drag.id) {
onDrag(it, it.positionChange())
- it.consumePositionChange()
+ if (it.positionChange() != Offset.Zero) it.consume()
}
) {
// consume up if we quit drag gracefully with the up
currentEvent.changes.forEach {
if (it.changedToUp()) {
- it.consumeDownChange()
+ if (it.pressed != it.previousPressed) it.consume()
}
}
onDragEnd()
@@ -136,7 +134,11 @@ private suspend fun PointerInputScope.awaitLongPressOrCancellation(
}
if (
- event.changes.any { it.consumed.downChange || it.isOutOfBounds(size) }
+ event.changes.any { it.isConsumed || it.isOutOfBounds(
+ size,
+ extendedTouchPadding
+ )
+ }
) {
finished = true // Canceled
}
@@ -145,7 +147,7 @@ private suspend fun PointerInputScope.awaitLongPressOrCancellation(
// the existing pointer event because it comes after the Main pass we checked
// above.
val consumeCheck = awaitPointerEvent(PointerEventPass.Final)
- if (consumeCheck.changes.any { it.positionChangeConsumed() }) {
+ if (consumeCheck.changes.any { it.isConsumed }) {
finished = true
}
if (!event.isPointerUp(currentDown.id)) {
diff --git a/plot/src/main/java/com/madrapps/plot/line/Components.kt b/plot/src/main/java/com/madrapps/plot/line/Components.kt
index 28925b2..0aeb66c 100644
--- a/plot/src/main/java/com/madrapps/plot/line/Components.kt
+++ b/plot/src/main/java/com/madrapps/plot/line/Components.kt
@@ -1,7 +1,7 @@
package com.madrapps.plot.line
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
@@ -288,8 +288,8 @@ data class LinePlot(
text = value.string(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
- style = MaterialTheme.typography.caption,
- color = MaterialTheme.colors.onSurface
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.onSurface
)
if (value > max) {
break
@@ -322,8 +322,8 @@ data class LinePlot(
text = value.string(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
- style = MaterialTheme.typography.caption,
- color = MaterialTheme.colors.onSurface
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.onSurface
)
}
}
diff --git a/plot/src/main/java/com/madrapps/plot/line/LineGraph.kt b/plot/src/main/java/com/madrapps/plot/line/LineGraph.kt
index 16ff880..aa6a538 100644
--- a/plot/src/main/java/com/madrapps/plot/line/LineGraph.kt
+++ b/plot/src/main/java/com/madrapps/plot/line/LineGraph.kt
@@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
-import androidx.compose.material.MaterialTheme
+import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
@@ -74,7 +74,7 @@ fun LineGraph(
val xZoom = remember { mutableStateOf(globalXScale) }
val rowHeight = remember { mutableStateOf(0f) }
val columnWidth = remember { mutableStateOf(0f) }
- val bgColor = MaterialTheme.colors.surface
+ val bgColor = MaterialTheme.colorScheme.surface
val lines = plot.lines
val xUnit = plot.xAxis.unit
diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts
index 710e174..3cd142d 100644
--- a/sample/build.gradle.kts
+++ b/sample/build.gradle.kts
@@ -4,13 +4,13 @@ plugins {
}
android {
- compileSdk = 30
+ compileSdk = 33
buildToolsVersion = "30.0.3"
defaultConfig {
applicationId = "com.madrapps.plot"
minSdk = 21
- targetSdk = 30
+ targetSdk = 33
versionCode = 1
versionName = "0.1.0"
@@ -35,37 +35,40 @@ android {
}
kotlinOptions {
jvmTarget = "1.8"
- useIR = true
}
buildFeatures {
compose = true
}
composeOptions {
- kotlinCompilerExtensionVersion = rootProject.extra["compose_version"] as String
+ kotlinCompilerExtensionVersion = rootProject.extra["kotlinCompilerExtensionVersion"] as String
}
lint {
- isAbortOnError = true
- isWarningsAsErrors = true
+ abortOnError = true
+ warningsAsErrors = true
}
+ namespace = "com.madrapps.sample"
}
dependencies {
// implementation(project(mapOf("path" to ":plot")))
implementation("com.github.madrapps:plot:0.1.1")
- implementation("androidx.core:core-ktx:1.6.0")
- implementation("androidx.appcompat:appcompat:1.3.1")
- implementation("com.google.android.material:material:1.4.0")
- implementation("androidx.compose.ui:ui:${rootProject.extra["compose_version"]}")
- implementation("androidx.compose.material:material:${rootProject.extra["compose_version"]}")
- implementation("androidx.compose.ui:ui-tooling:${rootProject.extra["compose_version"]}")
- implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
- implementation("androidx.activity:activity-compose:1.3.1")
- implementation("androidx.activity:activity-ktx:1.3.1")
- implementation("androidx.compose.runtime:runtime-livedata:${rootProject.extra["compose_version"]}")
+ implementation("androidx.core:core-ktx:1.9.0")
+ implementation("androidx.appcompat:appcompat:1.5.1")
+ implementation("com.google.android.material:material:1.7.0")
+
+ // Compose
+ val composeBom = platform("androidx.compose:compose-bom:2022.10.00")
+ implementation(composeBom)
+ androidTestImplementation(composeBom)
+ implementation("androidx.compose.material3:material3")
+ implementation("androidx.compose.ui:ui")
+ implementation("androidx.compose.ui:ui-tooling-preview")
+ debugImplementation("androidx.compose.ui:ui-tooling")
+ androidTestImplementation("androidx.compose.ui:ui-test-junit4")
+ implementation("androidx.activity:activity-compose:1.6.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
- androidTestImplementation("androidx.compose.ui:ui-test-junit4:${rootProject.extra["compose_version"]}")
}
\ No newline at end of file
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 55cb6d4..2151fb1 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
+
diff --git a/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph3.kt b/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph3.kt
index fe60d5e..e7ee712 100644
--- a/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph3.kt
+++ b/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph3.kt
@@ -3,8 +3,8 @@ package com.madrapps.sample.linegraph
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Text
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -38,7 +38,7 @@ internal fun LineGraph3(lines: List>) {
androidx.compose.foundation.layout.Column {
val isMajor = value % 4 == 0f
val radius = if (isMajor) 6f else 3f
- val color = MaterialTheme.colors.onSurface
+ val color = MaterialTheme.colorScheme.onSurface
Canvas(
modifier = Modifier
.align(Alignment.CenterHorizontally)
@@ -55,7 +55,7 @@ internal fun LineGraph3(lines: List>) {
text = DecimalFormat("#.#").format(value),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
- style = MaterialTheme.typography.caption,
+ style = MaterialTheme.typography.labelMedium,
color = color
)
}
diff --git a/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph4.kt b/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph4.kt
index 6dffc53..4b01f41 100644
--- a/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph4.kt
+++ b/sample/src/main/java/com/madrapps/sample/linegraph/LineGraph4.kt
@@ -9,9 +9,9 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Surface
-import androidx.compose.material.Text
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -69,7 +69,7 @@ internal fun LineGraph4(lines: List>, modifier: Modifier) {
Text(
modifier = Modifier.padding(vertical = 8.dp),
text = "Score at $x:00 hrs",
- style = MaterialTheme.typography.subtitle1,
+ style = MaterialTheme.typography.headlineMedium,
color = Color.Gray
)
ScoreRow("Today", value[1].y, Color.Blue)
@@ -81,7 +81,7 @@ internal fun LineGraph4(lines: List>, modifier: Modifier) {
}
}
val padding = 16.dp
- MaterialTheme(colors = MaterialTheme.colors.copy(surface = Color.White)) {
+ MaterialTheme(colorScheme = MaterialTheme.colorScheme.copy(surface = Color.White)) {
LineGraph(
plot = LinePlot(
listOf(
@@ -150,7 +150,7 @@ private fun ScoreRow(title: String, value: Float, color: Color) {
)
Text(
text = title,
- style = MaterialTheme.typography.subtitle1,
+ style = MaterialTheme.typography.headlineMedium,
color = Color.DarkGray
)
}
@@ -159,7 +159,7 @@ private fun ScoreRow(title: String, value: Float, color: Color) {
.padding(end = 8.dp)
.align(Alignment.CenterEnd),
text = formatted,
- style = MaterialTheme.typography.subtitle2,
+ style = MaterialTheme.typography.headlineSmall,
color = Color.DarkGray
)
}
diff --git a/sample/src/main/java/com/madrapps/sample/ui/theme/Shape.kt b/sample/src/main/java/com/madrapps/sample/ui/theme/Shape.kt
index 3be07a5..63111f5 100644
--- a/sample/src/main/java/com/madrapps/sample/ui/theme/Shape.kt
+++ b/sample/src/main/java/com/madrapps/sample/ui/theme/Shape.kt
@@ -1,7 +1,7 @@
package com.madrapps.sample.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.Shapes
+import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp
val Shapes = Shapes(
diff --git a/sample/src/main/java/com/madrapps/sample/ui/theme/Theme.kt b/sample/src/main/java/com/madrapps/sample/ui/theme/Theme.kt
index 105cb1f..e350d17 100644
--- a/sample/src/main/java/com/madrapps/sample/ui/theme/Theme.kt
+++ b/sample/src/main/java/com/madrapps/sample/ui/theme/Theme.kt
@@ -1,25 +1,25 @@
package com.madrapps.sample.ui.theme
import androidx.compose.foundation.isSystemInDarkTheme
-import androidx.compose.material.MaterialTheme
-import androidx.compose.material.darkColors
-import androidx.compose.material.lightColors
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
-private val DarkColorPalette = darkColors(
+private val DarkColorPalette = darkColorScheme(
primary = Purple200,
- primaryVariant = Purple700,
secondary = Teal200,
+ tertiary = Purple700,
background = Color.White,
onSurface = Color.Black,
surface = Grey50
)
-private val LightColorPalette = lightColors(
+private val LightColorPalette = lightColorScheme(
primary = Purple500,
- primaryVariant = Purple700,
secondary = Teal200,
+ tertiary = Purple700,
background = Color.White,
onSurface = Color.Black,
surface = Grey50
@@ -43,7 +43,7 @@ fun PlotTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable (
}
MaterialTheme(
- colors = colors,
+ colorScheme = colors,
typography = Typography,
shapes = Shapes,
content = content
diff --git a/sample/src/main/java/com/madrapps/sample/ui/theme/Type.kt b/sample/src/main/java/com/madrapps/sample/ui/theme/Type.kt
index 57210a6..49050e6 100644
--- a/sample/src/main/java/com/madrapps/sample/ui/theme/Type.kt
+++ b/sample/src/main/java/com/madrapps/sample/ui/theme/Type.kt
@@ -1,35 +1,8 @@
package com.madrapps.sample.ui.theme
-import androidx.compose.material.Typography
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.font.FontFamily
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.unit.sp
+import androidx.compose.material3.Typography
// Set of Material typography styles to start with
val Typography = Typography(
- body1 = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp
- ),
- caption = TextStyle(
- fontFamily = FontFamily.Default,
- fontWeight = FontWeight.Normal,
- fontSize = 14.sp,
- lineHeight = 18.sp
- ),
- subtitle1 = TextStyle(
- fontFamily = FontFamily.SansSerif,
- fontWeight = FontWeight.Normal,
- fontSize = 16.sp,
- lineHeight = 18.sp
- ),
- subtitle2 = TextStyle(
- fontFamily = FontFamily.SansSerif,
- fontWeight = FontWeight.Medium,
- fontSize = 16.sp,
- lineHeight = 18.sp
- )
)
diff --git a/sample/src/main/res/values-night/themes.xml b/sample/src/main/res/values-night/themes.xml
index 760ba11..ded03cf 100644
--- a/sample/src/main/res/values-night/themes.xml
+++ b/sample/src/main/res/values-night/themes.xml
@@ -10,7 +10,7 @@
- @color/teal_200
- @color/black
- - ?attr/colorPrimaryVariant
+ - ?attr/colorPrimaryVariant
\ No newline at end of file
diff --git a/sample/src/main/res/values/themes.xml b/sample/src/main/res/values/themes.xml
index 9112a6c..f2c393c 100644
--- a/sample/src/main/res/values/themes.xml
+++ b/sample/src/main/res/values/themes.xml
@@ -10,7 +10,7 @@
- @color/teal_700
- @color/black
- - ?attr/colorPrimaryVariant
+ - ?attr/colorPrimaryVariant
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 4495a96..fde8be4 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -3,7 +3,6 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
- jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "plot"