Skip to content

Commit

Permalink
Merge pull request #115 from halilozercan/0.17.0
Browse files Browse the repository at this point in the history
Update dependencies and release new version
  • Loading branch information
halilozercan authored Jun 30, 2023
2 parents 6e9d61d + 8ee5f49 commit 4b41fe3
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 96 deletions.
9 changes: 8 additions & 1 deletion android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

android {
namespace = "com.zachklipp.richtext.sample"
compileSdk = AndroidConfiguration.compileSdk

defaultConfig {
Expand All @@ -15,7 +16,13 @@ android {
compose = true
}

kotlinOptions { jvmTarget = "11" }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}

composeOptions {
kotlinCompilerExtensionVersion = Compose.compilerVersion
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ plugins {

dependencies {
// keep in sync with Dependencies.BuildPlugins.androidGradlePlugin
implementation("com.android.tools.build:gradle:7.2.2")
implementation("com.android.tools.build:gradle:7.4.0")
// keep in sync with Dependencies.Kotlin.gradlePlugin
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
implementation(kotlin("script-runtime"))
}
27 changes: 11 additions & 16 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
object BuildPlugins {
val androidGradlePlugin = "com.android.tools.build:gradle:7.2.2"
// keep in sync with buildSrc/build.gradle.kts
val androidGradlePlugin = "com.android.tools.build:gradle:7.4.0"
}

object AndroidX {
val activity = "androidx.activity:activity:1.5.0-rc01"
val annotations = "androidx.annotation:annotation:1.1.0"
val appcompat = "androidx.appcompat:appcompat:1.3.0"
val constraintLayout = "androidx.constraintlayout:constraintlayout:1.1.3"
val fragment = "androidx.fragment:fragment:1.2.2"
val material = "com.google.android.material:material:1.1.0"
val recyclerview = "androidx.recyclerview:recyclerview:1.1.0"
val savedstate = "androidx.savedstate:savedstate-ktx:1.2.0-rc01"
val transition = "androidx.transition:transition:1.3.1"
val viewbinding = "androidx.databinding:viewbinding:3.6.1"
}

object Network {
val okHttp = "com.squareup.okhttp3:okhttp:4.9.0"
}

object Kotlin {
val version = "1.7.10"
// keep in sync with buildSrc/build.gradle.kts
val version = "1.8.10"
val binaryCompatibilityValidatorPlugin = "org.jetbrains.kotlinx:binary-compatibility-validator:0.9.0"
val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"

object Test {
val common = "org.jetbrains.kotlin:kotlin-test-common"
val annotations = "org.jetbrains.kotlin:kotlin-test-annotations-common"
val jdk = "org.jetbrains.kotlin:kotlin-test-junit"
val mockito = "com.nhaarman:mockito-kotlin-kt1.1:1.6.0"
}
}

val ktlint = "org.jlleitschuh.gradle:ktlint-gradle:10.0.0"

object Compose {
val version = "1.2.1"
val compilerVersion = "1.3.1"
val desktopVersion = "1.2.0"
val activity = "androidx.activity:activity-compose:1.6.0-rc01"
val version = "1.4.3"
val compilerVersion = "1.4.4"
val desktopVersion = "1.4.1"
val activity = "androidx.activity:activity-compose:1.7.2"
val foundation = "androidx.compose.foundation:foundation:$version"
val material = "androidx.compose.material:material:$version"
val material3 = "androidx.compose.material3:material3:1.0.0-beta02"
val material3 = "androidx.compose.material3:material3:1.0.1"
val icons = "androidx.compose.material:material-icons-extended:$version"
val test = "androidx.ui:ui-test:$version"
val tooling = "androidx.compose.ui:ui-tooling:$version"
val toolingData = "androidx.compose.ui:ui-tooling-data:$version"
val desktopPreview = "org.jetbrains.compose.ui:ui-tooling-preview-desktop:$desktopVersion"
val multiplatformUiUtil = "org.jetbrains.compose.ui:ui-util:$desktopVersion"
val coil = "io.coil-kt:coil-compose:2.2.1"
val coil = "io.coil-kt:coil-compose:2.4.0"
}

object Commonmark {
private val version = "0.20.0"
private val version = "0.21.0"
val core = "org.commonmark:commonmark:$version"
val tables = "org.commonmark:commonmark-ext-gfm-tables:$version"
val strikethrough = "org.commonmark:commonmark-ext-gfm-strikethrough:$version"
Expand Down
8 changes: 7 additions & 1 deletion buildSrc/src/main/kotlin/richtext-android-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ android {
targetSdk = AndroidConfiguration.targetSdk
}

kotlinOptions { jvmTarget = "11" }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}

buildFeatures {
compose = true
Expand Down
9 changes: 9 additions & 0 deletions buildSrc/src/main/kotlin/richtext-kmp-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ kotlin {
jvm()
android {
publishLibraryVariants("release", "debug")
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
explicitApi()
}

android {
compileSdk = 33
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

defaultConfig {
minSdk = 21
targetSdk = compileSdk
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ kotlin.code.style=official
systemProp.org.gradle.internal.publish.checksums.insecure=true

GROUP=com.halilibo.compose-richtext
VERSION_NAME=0.16.0
VERSION_NAME=0.17.0

POM_DESCRIPTION=A collection of Compose libraries for advanced text formatting and alternative display types.

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions printing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ plugins {
id("org.jetbrains.dokka")
}

android {
namespace = "com.zachklipp.richtext.ui.printing"
}

dependencies {
implementation(Compose.foundation)
implementation(Compose.tooling)
Expand Down
2 changes: 1 addition & 1 deletion printing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.zachklipp.richtext.printing" />
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import androidx.compose.ui.graphics.Color.Companion.White
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.ViewTreeViewModelStoreOwner
import androidx.lifecycle.setViewTreeLifecycleOwner
import androidx.lifecycle.setViewTreeViewModelStoreOwner
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -175,8 +175,8 @@ private fun createWindowComposeView(
activity: ComponentActivity,
content: @Composable () -> Unit
): View = ComposeView(activity).apply {
ViewTreeLifecycleOwner.set(this, activity)
ViewTreeViewModelStoreOwner.set(this, activity)
this.setViewTreeLifecycleOwner(activity)
this.setViewTreeViewModelStoreOwner(activity)
setViewTreeSavedStateRegistryOwner(activity)
setContent(content)
}
Expand Down
4 changes: 4 additions & 0 deletions richtext-commonmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

android {
namespace = "com.halilibo.richtext.markdown"
}

kotlin {
sourceSets {
val commonMain by getting {
Expand Down
4 changes: 4 additions & 0 deletions richtext-ui-material/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

android {
namespace = "com.halilibo.richtext.ui.material"
}

kotlin {
sourceSets {
val commonMain by getting {
Expand Down
4 changes: 4 additions & 0 deletions richtext-ui-material3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

android {
namespace = "com.halilibo.richtext.ui.material3"
}

kotlin {
sourceSets {
val commonMain by getting {
Expand Down
6 changes: 4 additions & 2 deletions richtext-ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.jetbrains.compose.compose

plugins {
id("richtext-kmp-library")
id("org.jetbrains.compose") version Compose.desktopVersion
Expand All @@ -10,6 +8,10 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

android {
namespace = "com.halilibo.richtext.ui"
}

kotlin {
sourceSets {
val commonMain by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package com.halilibo.richtext.ui.util

import androidx.compose.foundation.gestures.GestureCancellationException
import androidx.compose.foundation.gestures.PressGestureScope
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.geometry.Offset
Expand Down Expand Up @@ -64,79 +66,77 @@ public suspend fun PointerInputScope.detectTapGesturesIf(
val pressScope =
PressGestureScopeImpl(this@detectTapGesturesIf)

forEachGesture {
awaitPointerEventScope {
val down = awaitFirstDown()
if (!predicate(down.position)) {
pressScope.reset()
return@awaitPointerEventScope
}
down.consume()
awaitEachGesture {
val down = awaitFirstDown()
if (!predicate(down.position)) {
pressScope.reset()
if (onPress !== NoPressGesture) launch {
pressScope.onPress(down.position)
return@awaitEachGesture
}
down.consume()
pressScope.reset()
if (onPress !== NoPressGesture) launch {
pressScope.onPress(down.position)
}
val longPressTimeout = onLongPress?.let {
viewConfiguration.longPressTimeoutMillis
} ?: (Long.MAX_VALUE / 2)
var upOrCancel: PointerInputChange? = null
try {
// wait for first tap up or long press
upOrCancel = withTimeout(longPressTimeout) {
waitForUpOrCancellation()
}
val longPressTimeout = onLongPress?.let {
viewConfiguration.longPressTimeoutMillis
} ?: (Long.MAX_VALUE / 2)
var upOrCancel: PointerInputChange? = null
try {
// wait for first tap up or long press
upOrCancel = withTimeout(longPressTimeout) {
waitForUpOrCancellation()
}
if (upOrCancel == null) {
pressScope.cancel() // tap-up was canceled
} else {
upOrCancel.consume()
pressScope.release()
}
} catch (_: PointerEventTimeoutCancellationException) {
onLongPress?.invoke(down.position)
consumeUntilUp()
if (upOrCancel == null) {
pressScope.cancel() // tap-up was canceled
} else {
upOrCancel.consume()
pressScope.release()
}
} catch (_: PointerEventTimeoutCancellationException) {
onLongPress?.invoke(down.position)
consumeUntilUp()
pressScope.release()
}

if (upOrCancel != null) {
// tap was successful.
if (onDoubleTap == null) {
onTap?.invoke(upOrCancel.position) // no need to check for double-tap.
} else {
// check for second tap
val secondDown = awaitSecondDown(upOrCancel)

if (upOrCancel != null) {
// tap was successful.
if (onDoubleTap == null) {
onTap?.invoke(upOrCancel.position) // no need to check for double-tap.
if (secondDown == null) {
onTap?.invoke(upOrCancel.position) // no valid second tap started
} else {
// check for second tap
val secondDown = awaitSecondDown(upOrCancel)

if (secondDown == null) {
onTap?.invoke(upOrCancel.position) // no valid second tap started
} else {
// Second tap down detected
pressScope.reset()
if (onPress !== NoPressGesture) {
launch { pressScope.onPress(secondDown.position) }
}
// Second tap down detected
pressScope.reset()
if (onPress !== NoPressGesture) {
launch { pressScope.onPress(secondDown.position) }
}

try {
// Might have a long second press as the second tap
withTimeout(longPressTimeout) {
val secondUp = waitForUpOrCancellation()
if (secondUp != null) {
secondUp.consume()
pressScope.release()
onDoubleTap(secondUp.position)
} else {
pressScope.cancel()
onTap?.invoke(upOrCancel.position)
}
try {
// Might have a long second press as the second tap
withTimeout(longPressTimeout) {
val secondUp = waitForUpOrCancellation()
if (secondUp != null) {
secondUp.consume()
pressScope.release()
onDoubleTap(secondUp.position)
} else {
pressScope.cancel()
onTap?.invoke(upOrCancel.position)
}
} catch (e: PointerEventTimeoutCancellationException) {
// The first tap was valid, but the second tap is a long press.
// notify for the first tap
onTap?.invoke(upOrCancel.position)

// notify for the long press
onLongPress?.invoke(secondDown.position)
consumeUntilUp()
pressScope.release()
}
} catch (e: PointerEventTimeoutCancellationException) {
// The first tap was valid, but the second tap is a long press.
// notify for the first tap
onTap?.invoke(upOrCancel.position)

// notify for the long press
onLongPress?.invoke(secondDown.position)
consumeUntilUp()
pressScope.release()
}
}
}
Expand Down
Loading

0 comments on commit 4b41fe3

Please sign in to comment.