File tree Expand file tree Collapse file tree
app/src/main/kotlin/com/fredapp/wbooks
companion/src/main/kotlin/com/fredapp/wbooksutil Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import java.io.InputStream
1414import java.net.HttpURLConnection
1515import java.net.URL
1616import java.net.URLEncoder
17- import java.nio.charset.StandardCharsets
1817import kotlin.coroutines.coroutineContext
1918
2019class GutenbergRepository {
@@ -188,7 +187,7 @@ class GutenbergRepository {
188187
189188 private fun endpoint (path : String , vararg params : Pair <String , String >): String {
190189 val query = if (params.isEmpty()) " " else params.joinToString(" &" , prefix = " ?" ) { (k, v) ->
191- " $k =" + URLEncoder .encode(v, StandardCharsets . UTF_8 )
190+ " $k =" + URLEncoder .encode(v, " UTF-8 " )
192191 }
193192 return " $BASE_NO_SLASH /$path$query "
194193 }
Original file line number Diff line number Diff line change 11package com.fredapp.wbooks.tile
22
3- import androidx.concurrent.futures.ResolvableFuture
3+ import androidx.concurrent.futures.CallbackToFutureAdapter
44import androidx.wear.protolayout.ActionBuilders
55import androidx.wear.protolayout.ColorBuilders
66import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters
@@ -103,6 +103,7 @@ class BooksTileService : TileService() {
103103 val chipLabel = if (hasBook) getString(R .string.tile_resume) else getString(R .string.tile_open)
104104
105105 val foreground = PrimaryLayout .Builder (device)
106+ .setResponsiveContentInsetEnabled(true )
106107 .setPrimaryLabelTextContent(
107108 Text .Builder (this , timeLabel)
108109 .setTypography(Typography .TYPOGRAPHY_CAPTION1 )
@@ -144,7 +145,10 @@ class BooksTileService : TileService() {
144145 }
145146
146147 private fun <T > resolved (value : T ): ListenableFuture <T > =
147- ResolvableFuture .create<T >().also { it.set(value) }
148+ CallbackToFutureAdapter .getFuture { completer ->
149+ completer.set(value)
150+ " resolved tile value"
151+ }
148152
149153 private fun launchActivity (showLibrary : Boolean ): ActionBuilders .LaunchAction {
150154 val activity = ActionBuilders .AndroidActivity .Builder ()
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import java.io.InputStream
1414import java.net.HttpURLConnection
1515import java.net.URL
1616import java.net.URLEncoder
17- import java.nio.charset.StandardCharsets
1817import kotlin.coroutines.coroutineContext
1918
2019/* *
@@ -270,7 +269,7 @@ class GutenbergRepository {
270269 /* * Build `<BASE>/path?k1=v1&k2=v2` with proper URL-encoding. */
271270 private fun endpoint (path : String , vararg params : Pair <String , String >): String {
272271 val query = if (params.isEmpty()) " " else params.joinToString(" &" , prefix = " ?" ) { (k, v) ->
273- " $k =" + URLEncoder .encode(v, StandardCharsets . UTF_8 )
272+ " $k =" + URLEncoder .encode(v, " UTF-8 " )
274273 }
275274 return " $BASE_NO_SLASH /$path$query "
276275 }
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import kotlinx.coroutines.tasks.await
1010import kotlinx.coroutines.withContext
1111import java.io.InputStream
1212import java.net.URLEncoder
13- import java.nio.charset.StandardCharsets
1413
1514/* *
1615 * Thin wrapper over the Wear Data Layer. The watch app advertises a
@@ -146,7 +145,7 @@ class WatchRepository(context: Context) {
146145
147146 internal object WearUploadPath {
148147 fun encode (filename : String , totalBytes : Long , overwrite : Boolean ): String {
149- val encoded = URLEncoder .encode(filename, StandardCharsets . UTF_8 )
148+ val encoded = URLEncoder .encode(filename, " UTF-8 " )
150149 val params = buildList {
151150 if (totalBytes >= 0L ) add(" bytes=$totalBytes " )
152151 if (overwrite) add(" overwrite=1" )
You can’t perform that action at this time.
0 commit comments