Skip to content

Commit 58ca34e

Browse files
authored
Merge pull request #78 from android/upgrade-ink-110alpha03
Upgrade to Ink 1.1.0-alpha03
2 parents 375e24f + f7eb0c3 commit 58ca34e

10 files changed

Lines changed: 42 additions & 42 deletions

File tree

app/src/main/java/com/example/cahier/core/ui/CahierTextureBitmapStore.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import android.content.Context
2121
import android.graphics.Bitmap
2222
import android.graphics.BitmapFactory
2323
import androidx.annotation.DrawableRes
24-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
2524
import androidx.ink.brush.TextureBitmapStore
2625
import com.example.cahier.R
2726
import dagger.hilt.android.qualifiers.ApplicationContext
@@ -31,7 +30,6 @@ import kotlinx.coroutines.flow.update
3130
import javax.inject.Inject
3231
import javax.inject.Singleton
3332

34-
@OptIn(ExperimentalInkCustomBrushApi::class)
3533
@Singleton
3634
class CahierTextureBitmapStore @Inject constructor(@ApplicationContext context: Context) :
3735
TextureBitmapStore {

app/src/main/java/com/example/cahier/developer/brushdesigner/ui/BrushDesignerScreen.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import androidx.compose.ui.tooling.preview.Preview
7979
import androidx.compose.ui.unit.dp
8080
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
8181
import androidx.ink.brush.Brush
82-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
8382
import androidx.ink.brush.StockBrushes
8483
import androidx.lifecycle.compose.collectAsStateWithLifecycle
8584
import com.example.cahier.R
@@ -95,7 +94,6 @@ import ink.proto.BrushTip as ProtoBrushTip
9594
ExperimentalMaterial3Api::class,
9695
ExperimentalMaterial3WindowSizeClassApi::class,
9796
ExperimentalMaterial3AdaptiveApi::class,
98-
ExperimentalInkCustomBrushApi::class
9997
)
10098
@Composable
10199
fun BrushDesignerScreen(
@@ -267,7 +265,7 @@ fun BrushDesignerScreen(
267265
* Note: Still accepts ViewModel for delegation to tab content and input model
268266
* sections. All state (activeProto, selectedCoatIndex) is hoisted from the screen.
269267
*/
270-
@OptIn(ExperimentalInkCustomBrushApi::class, ExperimentalMaterial3Api::class)
268+
@OptIn(ExperimentalMaterial3Api::class)
271269
@Composable
272270
private fun ControlsPane(
273271
modifier: Modifier = Modifier,

app/src/main/java/com/example/cahier/developer/brushdesigner/ui/PreviewPane.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import androidx.compose.ui.text.font.FontWeight
5353
import androidx.compose.ui.text.style.TextAlign
5454
import androidx.compose.ui.unit.dp
5555
import androidx.ink.brush.Brush
56-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
5756
import androidx.ink.rendering.android.canvas.CanvasStrokeRenderer
5857
import androidx.ink.strokes.Stroke
5958
import com.example.cahier.R
@@ -72,7 +71,6 @@ import ink.proto.BrushFamily as ProtoBrushFamily
7271
*
7372
* Stateless: receives all state and callbacks, does not access ViewModel.
7473
*/
75-
@OptIn(ExperimentalInkCustomBrushApi::class)
7674
@Composable
7775
internal fun PreviewPane(
7876
modifier: Modifier = Modifier,

app/src/main/java/com/example/cahier/developer/brushdesigner/ui/TipShapeTab.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import androidx.compose.ui.Modifier
3333
import androidx.compose.ui.res.stringResource
3434
import androidx.compose.ui.unit.dp
3535
import androidx.ink.brush.Brush
36-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
3736
import com.example.cahier.R
3837
import ink.proto.BrushTip as ProtoBrushTip
3938

@@ -46,7 +45,6 @@ import ink.proto.BrushTip as ProtoBrushTip
4645
*
4746
* Stateless: receives data and callbacks, does not access ViewModel.
4847
*/
49-
@OptIn(ExperimentalInkCustomBrushApi::class)
5048
@Composable
5149
internal fun TipShapeTabContent(
5250
currentTip: ProtoBrushTip,

app/src/main/java/com/example/cahier/developer/brushdesigner/viewmodel/BrushDesignerViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import android.net.Uri
2323
import androidx.compose.ui.graphics.Color
2424
import androidx.ink.brush.Brush
2525
import androidx.ink.brush.BrushFamily
26-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
2726
import androidx.ink.brush.Version
2827
import androidx.ink.brush.compose.createWithComposeColor
2928
import androidx.ink.storage.decode
@@ -65,7 +64,7 @@ import ink.proto.BrushFamily as ProtoBrushFamily
6564
import ink.proto.BrushPaint as ProtoBrushPaint
6665
import ink.proto.BrushTip as ProtoBrushTip
6766

68-
@OptIn(ExperimentalInkCustomBrushApi::class, FlowPreview::class)
67+
@OptIn(FlowPreview::class)
6968
@HiltViewModel
7069
class BrushDesignerViewModel @Inject constructor(
7170
@param:ApplicationContext private val context: Context,

app/src/main/java/com/example/cahier/developer/brushgraph/ui/GraphCanvas.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@file:OptIn(androidx.ink.brush.ExperimentalInkCustomBrushApi::class)
1716

1817
package com.example.cahier.developer.brushgraph.ui
1918

app/src/main/java/com/example/cahier/features/drawing/CustomBrushes.kt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
/*
2+
* Copyright 2025 Google LLC. All rights reserved.
23
*
3-
* *
4-
* * * Copyright 2025 Google LLC. All rights reserved.
5-
* * *
6-
* * * Licensed under the Apache License, Version 2.0 (the "License");
7-
* * * you may not use this file except in compliance with the License.
8-
* * * You may obtain a copy of the License at
9-
* * *
10-
* * * http://www.apache.org/licenses/LICENSE-2.0
11-
* * *
12-
* * * Unless required by applicable law or agreed to in writing, software
13-
* * * distributed under the License is distributed on an "AS IS" BASIS,
14-
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* * * See the License for the specific language governing permissions and
16-
* * * limitations under the License.
17-
* *
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
187
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1915
*/
2016

2117
package com.example.cahier.features.drawing
2218

2319
import android.content.Context
2420
import android.util.Log
25-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
2621
import androidx.ink.brush.Version
2722
import androidx.ink.storage.AndroidBrushFamilySerialization
2823
import com.example.cahier.R
@@ -40,7 +35,6 @@ object CustomBrushes {
4035
}
4136
}
4237

43-
@OptIn(ExperimentalInkCustomBrushApi::class)
4438
private fun loadCustomBrushes(
4539
context: Context,
4640
textureStore: CahierTextureBitmapStore,

app/src/main/java/com/example/cahier/features/drawing/viewmodel/DrawingCanvasViewModel.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import androidx.core.graphics.createBitmap
2929
import androidx.core.net.toUri
3030
import androidx.ink.brush.Brush
3131
import androidx.ink.brush.BrushFamily
32-
import androidx.ink.brush.ExperimentalInkCustomBrushApi
3332
import androidx.ink.brush.StockBrushes
3433
import androidx.ink.brush.Version
3534
import androidx.ink.brush.compose.composeColor
@@ -92,9 +91,12 @@ class DrawingCanvasViewModel @Inject constructor(
9291

9392
private val currentNightMode = AppCompatDelegate.getDefaultNightMode()
9493

95-
private val heartHighlighter = StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true)
96-
private val poopHighlighter = StockBrushes.emojiHighlighter("emoji-poop", showMiniEmojiTrail = true)
97-
private val starHighlighter = StockBrushes.emojiHighlighter("emoji-star", showMiniEmojiTrail = true)
94+
private val heartHighlighter =
95+
StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true)
96+
private val poopHighlighter =
97+
StockBrushes.emojiHighlighter("emoji-poop", showMiniEmojiTrail = true)
98+
private val starHighlighter =
99+
StockBrushes.emojiHighlighter("emoji-star", showMiniEmojiTrail = true)
98100
private val highlighter = StockBrushes.highlighter()
99101

100102
private val _defaultBrush = MutableStateFlow(
@@ -382,7 +384,7 @@ class DrawingCanvasViewModel @Inject constructor(
382384
isBrushSelectedInSession = true
383385
_selectedBrush.update { currentBrush ->
384386
val newBrush = currentBrush.copy(family = brushFamily)
385-
val colorToApply = when(newBrush.family) {
387+
val colorToApply = when (newBrush.family) {
386388
highlighter -> newBrush.composeColor.copy(alpha = HIGHLIGHTER_ALPHA)
387389
heartHighlighter -> Color(0xFFFF45CA).copy(alpha = HIGHLIGHTER_ALPHA)
388390
poopHighlighter -> Color(0xFF783013).copy(alpha = HIGHLIGHTER_ALPHA)
@@ -397,7 +399,7 @@ class DrawingCanvasViewModel @Inject constructor(
397399
isBrushSelectedInSession = true
398400
_selectedBrush.update { currentBrush ->
399401
val newBrush = currentBrush.copy(family = brushFamily, size = size)
400-
val colorToApply = when(newBrush.family) {
402+
val colorToApply = when (newBrush.family) {
401403
highlighter -> newBrush.composeColor.copy(alpha = HIGHLIGHTER_ALPHA)
402404
heartHighlighter -> Color(0xFFFF45CA).copy(alpha = HIGHLIGHTER_ALPHA)
403405
poopHighlighter -> Color(0xFF783013).copy(alpha = HIGHLIGHTER_ALPHA)
@@ -411,12 +413,14 @@ class DrawingCanvasViewModel @Inject constructor(
411413
fun changeBrushColor(color: Color) {
412414
isBrushSelectedInSession = true
413415
_selectedBrush.update { currentBrush ->
414-
val colorToApply = when(currentBrush.family) {
416+
val colorToApply = when (currentBrush.family) {
415417
heartHighlighter,
416418
poopHighlighter,
417419
starHighlighter,
418-
highlighter -> color.copy(alpha = HIGHLIGHTER_ALPHA)
419-
else -> color.copy(alpha = 1f)
420+
highlighter,
421+
-> color.copy(alpha = HIGHLIGHTER_ALPHA)
422+
423+
else -> color.copy(alpha = 1f)
420424
}
421425
currentBrush.copyWithComposeColor(color = colorToApply)
422426
}
@@ -467,7 +471,6 @@ class DrawingCanvasViewModel @Inject constructor(
467471
return _selectedBrush.value
468472
}
469473

470-
@OptIn(ExperimentalInkCustomBrushApi::class)
471474
suspend fun saveCurrentBrushToAutosave() {
472475
withContext(Dispatchers.IO) {
473476
try {
@@ -491,7 +494,6 @@ class DrawingCanvasViewModel @Inject constructor(
491494
}
492495
}
493496

494-
@OptIn(ExperimentalInkCustomBrushApi::class)
495497
private fun loadCustomBrushes() {
496498
viewModelScope.launch(Dispatchers.IO) {
497499
val builtInBrushes = CustomBrushes.getBrushes(context, textureStore)

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coilCompose = "3.4.0"
55
foundation = "1.10.5"
66
hiltAndroid = "2.59.2"
77
hiltNavigationCompose = "1.3.0"
8-
ink = "1.1.0-alpha02"
8+
ink = "1.1.0-alpha03"
99
kotlin = "2.3.20"
1010
coreKtx = "1.18.0"
1111
junit = "4.13.2"

ink-proto/src/main/proto/brush_family.proto

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ message BrushPaint {
474474
// (self overlap is discarded). More complex examples may involve color or
475475
// opacity variations (e.g. with
476476
// `BrushBehavior::Target::HUE_OFFSET_IN_RADIANS`), or complex textures (e.g.
477-
// with `TextureMapping::kStamping`).
477+
// with `BrushPaint::StampingTexture`).
478478
enum SelfOverlap {
479479
SELF_OVERLAP_UNSPECIFIED = 0 [(ink.proto.enum_value_min_version) = 0];
480480
SELF_OVERLAP_ANY = 1 [(ink.proto.enum_value_min_version) = 0];
@@ -1349,8 +1349,22 @@ message ColorFunction {
13491349
option (ink.proto.message_min_version) = 0;
13501350

13511351
oneof function {
1352+
// Applies a multiplier to the color's opacity. The multiplier must be
1353+
// finite and nonnegative. Typical multiplier values range between 0 and 1.
13521354
float opacity_multiplier = 1 [(ink.proto.field_min_version) = 0];
1355+
// Ignores the original color and replaces it with a fixed color.
13531356
Color replace_color = 2 [(ink.proto.field_min_version) = 0];
1357+
// Applies an additive offset to the color's hue angle. The offset angle
1358+
// must be finite, but can be positive or negative (or zero).
1359+
float hue_offset_radians = 3 [(ink.proto.field_min_version) = 2147483647];
1360+
// Applies a multiplier to the color's saturation. The multiplier must be
1361+
// finite and nonnegative. Typical multiplier values range between 0 and 1.
1362+
float saturation_multiplier = 4
1363+
[(ink.proto.field_min_version) = 2147483647];
1364+
// Applies an additive offset to the color's luminosity. The offset must be
1365+
// finite, but can be positive or negative (or zero). Typical offset values
1366+
// range between -1 and 1.
1367+
float luminosity_offset = 5 [(ink.proto.field_min_version) = 2147483647];
13541368
}
13551369
}
13561370

0 commit comments

Comments
 (0)