Skip to content

Commit a691e8e

Browse files
committed
Merge remote-tracking branch 'origin/main' into ray/ui-update
* origin/main: Upgrade the compile SDK to 31. Moves us to s01.oss.sonatype.org Fixes version name after 1.3.0 release, forgot to bump it. Use Gradle 7.3.2. Log4shell mitigation. 608: Update TypedWorker kdoc Releasing v1.3.0 End CHANGELOG.md Replaces *.initializeView with *.viewStarter Adds (failing) DecorativeViewFactory double update test Fixes index out of bounds crash when attempting to add characters or moving the cursor to the ends of the string being edited. View.launchWhenAttached tolerates strange ids
2 parents d54fc48 + e85d260 commit a691e8e

File tree

27 files changed

+348
-143
lines changed

27 files changed

+348
-143
lines changed

.buildscript/configure-android-defaults.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
android {
2-
compileSdkVersion Versions.targetSdk
2+
compileSdkVersion Versions.compileSdk
33

44
compileOptions {
55
sourceCompatibility JavaVersion.VERSION_1_8

.buildscript/configure-maven-publish.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ apply plugin: 'com.vanniktech.maven.publish'
22

33
group = GROUP
44
version = VERSION_NAME
5+
6+
mavenPublish {
7+
sonatypeHost = "S01"
8+
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Change Log
22
==========
33

4+
> This file is no longer updated, please visit [Releases](https://github.com/square/workflow-kotlin/releases) instead.
5+
46
## Version 1.2.0
57

68
_2021-11-10_

RELEASING.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
## Production Releases
44

55
---
6-
1. Merge an update of [the change log](CHANGELOG.md) with the changes since the last release.
7-
86
1. Make sure you're on the `main` branch (or fix branch, e.g. `v0.1-fixes`).
97

108
1. Confirm that the kotlin build is green before committing any changes
@@ -23,14 +21,13 @@
2321

2422
1. Upload the kotlin artifacts:
2523
```bash
26-
./gradlew clean build && ./gradlew uploadArchives --no-parallel
24+
./gradlew clean build && ./gradlew publish --no-parallel
2725
```
2826

2927
Disabling parallelism and daemon sharing is required by the vanniktech maven publish plugin.
3028
Without those, the artifacts will be split across multiple (invalid) staging repositories.
31-
(Note that `uploadArchives` is deprecated in favor of `publish`, but `publish` makes bad artifacts.)
3229

33-
1. Close and release the staging repository at https://oss.sonatype.org/#stagingRepositories.
30+
1. Close and release the staging repository at https://s01.oss.sonatype.org/#stagingRepositories.
3431

3532
1. Bump the version
3633
- **Kotlin:** Update the `VERSION_NAME` property in `gradle.properties` to the new
@@ -51,10 +48,11 @@
5148
1. Create the release on GitHub:
5249
1. Go to the [Releases](https://github.com/square/workflow-kotlin/releases) page for the GitHub
5350
project.
54-
1. Click "Draft a new release".
51+
1. Click _Draft a new release_.
5552
1. Enter the tag name you just pushed.
56-
1. Title the release with the same name as the tag.
57-
1. Copy & paste the changelog entry for this release into the description.
53+
1. Click _Auto-generate release notes_.
54+
- Edit the generated notes if you feel the need.
55+
- See [this page](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) if you have an itch to customize how our notes are generated.
5856
1. If this is a pre-release version, check the pre-release box.
5957
1. Hit "Publish release".
6058

@@ -112,12 +110,11 @@ To build and install the current version to your local Maven repository (`~/.m2`
112110

113111
#### Configuration
114112

115-
In order to deploy artifacts to a Maven repository, you'll need to set 4 properties in your private
116-
Gradle properties file (`~/.gradle/gradle.properties`):
113+
In order to deploy artifacts to `s01.oss.sonatype.org`, you'll need to provide
114+
your credentials via these two properties in your private Gradle properties
115+
file(`~/.gradle/gradle.properties`).
117116

118117
```
119-
RELEASE_REPOSITORY_URL=<url of release repository>
120-
SNAPSHOT_REPOSITORY_URL=<url of snapshot repository
121118
mavenCentralUsername=<username>
122119
mavenCentralPassword=<password>
123120
```
@@ -128,8 +125,8 @@ Double-check that `gradle.properties` correctly contains the `-SNAPSHOT` suffix,
128125
snapshot artifacts to Sonatype just like you would for a production release:
129126

130127
```bash
131-
./gradlew clean build && ./gradlew uploadArchives --no-parallel
128+
./gradlew clean build && ./gradlew publish --no-parallel
132129
```
133130

134131
You can verify the artifacts are available by visiting
135-
https://oss.sonatype.org/content/repositories/snapshots/com/squareup/workflow/.
132+
https://s01.oss.sonatype.org/content/repositories/snapshots/com/squareup/workflow1/.

buildSrc/src/main/java/Dependencies.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import java.util.Locale.US
44
import kotlin.reflect.full.declaredMembers
55

66
object Versions {
7+
const val compileSdk = 31
78
const val targetSdk = 30
89
}
910

@@ -109,7 +110,7 @@ object Dependencies {
109110
const val generator = "org.openjdk.jmh:jmh-generator-annprocess:1.32"
110111
}
111112

112-
const val mavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.16.0"
113+
const val mavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.18.0"
113114
const val ktlint = "org.jlleitschuh.gradle:ktlint-gradle:10.1.0"
114115
const val lanterna = "com.googlecode.lanterna:lanterna:3.1.1"
115116
const val okio = "com.squareup.okio:okio:2.10.0"

gradle.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ android.useAndroidX=true
88
systemProp.org.gradle.internal.publish.checksums.insecure=true
99

1010
GROUP=com.squareup.workflow1
11-
VERSION_NAME=1.3.0-SNAPSHOT
11+
VERSION_NAME=1.4.0-SNAPSHOT
1212

13-
POM_DESCRIPTION=Reactive workflows
13+
POM_DESCRIPTION=Square Workflow
1414

1515
POM_URL=https://github.com/square/workflow/
1616
POM_SCM_URL=https://github.com/square/workflow/
1717
POM_SCM_CONNECTION=scm:git:git://github.com/square/workflow.git
1818
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/square/workflow.git
1919

20-
POM_LICENCE_NAME=The Apache Software License, Version 2.0
21-
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
22-
POM_LICENCE_DIST=repo
20+
POM_LICENSE_NAME=The Apache Software License, Version 2.0
21+
POM_LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
22+
POM_LICENSE_DIST=repo
2323

2424
POM_DEVELOPER_ID=square
2525
POM_DEVELOPER_NAME=Square, Inc.
26+
POM_DEVELOPER_URL=https://github.com/square/
27+
SONATYPE_STAGING_PROFILE=com.squareup
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/Component.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Component(context: AppCompatActivity) {
3838
@OptIn(ExperimentalTime::class)
3939
val clock = Monotonic
4040

41+
@Suppress("DEPRECATION")
4142
val vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
4243

4344
val boardLoader = BoardLoader(

samples/hello-terminal/todo-terminal-app/src/main/java/com/squareup/sample/hellotodo/EditTextWorkflow.kt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class EditTextWorkflow : StatefulWorkflow<EditTextProps, EditTextState, String,
3131
override fun initialState(
3232
props: EditTextProps,
3333
snapshot: Snapshot?
34-
) = EditTextState(props.text.length)
34+
) = EditTextState(cursorPosition = props.text.length)
3535

3636
override fun onPropsChanged(
3737
old: EditTextProps,
@@ -40,7 +40,7 @@ class EditTextWorkflow : StatefulWorkflow<EditTextProps, EditTextState, String,
4040
): EditTextState {
4141
return if (old.text != new.text) {
4242
// Clamp the cursor position to the text length.
43-
state.copy(cursorPosition = state.cursorPosition.coerceIn(0..new.text.length))
43+
state.copy(cursorPosition = state.cursorPosition.coerceIn(new.text))
4444
} else state
4545
}
4646

@@ -68,18 +68,19 @@ class EditTextWorkflow : StatefulWorkflow<EditTextProps, EditTextState, String,
6868
) = action {
6969
when (key.keyType) {
7070
Character -> {
71-
state = moveCursor(props, state, 1)
72-
props.text.insertCharAt(state.cursorPosition, key.character!!)
71+
val newText = props.text.insertCharAt(state.cursorPosition, key.character!!)
72+
setOutput(newText)
73+
state = moveCursor(newText, state, 1)
7374
}
74-
7575
Backspace -> {
76-
if (props.text.isNotEmpty()) {
77-
state = moveCursor(props, state, -1)
78-
props.text.removeRange(state.cursorPosition - 1, state.cursorPosition)
76+
if (props.text.isNotEmpty() && state.cursorPosition > 0) {
77+
val newText = props.text.removeRange(state.cursorPosition - 1, state.cursorPosition)
78+
setOutput(newText)
79+
state = moveCursor(newText, state, -1)
7980
}
8081
}
81-
ArrowLeft -> state = moveCursor(props, state, -1)
82-
ArrowRight -> state = moveCursor(props, state, 1)
82+
ArrowLeft -> state = moveCursor(props.text, state, -1)
83+
ArrowRight -> state = moveCursor(props.text, state, 1)
8384
else -> {
8485
// Nothing to do.
8586
}
@@ -88,13 +89,15 @@ class EditTextWorkflow : StatefulWorkflow<EditTextProps, EditTextState, String,
8889
}
8990

9091
private fun moveCursor(
91-
props: EditTextProps,
92+
text: String,
9293
state: EditTextState,
9394
delta: Int
9495
): EditTextState =
95-
state.copy(cursorPosition = (state.cursorPosition + delta).coerceIn(0..props.text.length + 1))
96+
state.copy(cursorPosition = (state.cursorPosition + delta).coerceIn(text))
9697

9798
private fun String.insertCharAt(
9899
index: Int,
99100
char: Char
100101
): String = substring(0, index) + char + substring(index, length)
102+
103+
private fun Int.coerceIn(text: String): Int = coerceIn(0..text.length)

samples/tutorial/tutorial-1-complete/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion 30
7+
compileSdkVersion 31
88

99
defaultConfig {
1010
applicationId "com.squareup.workflow.tutorial"

0 commit comments

Comments
 (0)