-
Notifications
You must be signed in to change notification settings - Fork 181
Migrate ResultsScreen to use Nav3 #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df7c28c
7bb6ccd
048c502
500f5dc
50e8395
2c19c4a
4647f0f
7c64ea7
d5ef994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2025 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.android.developers.androidify.navigation | ||
|
||
import android.net.Uri | ||
import androidx.core.net.toUri | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
object UriSerializer : KSerializer<Uri> { | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("Uri", PrimitiveKind.STRING) | ||
|
||
override fun serialize(encoder: Encoder, value: Uri) { | ||
encoder.encodeString(value.toString()) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): Uri = decoder.decodeString().toUri() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2025 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.android.developers.testing.data | ||
|
||
import android.graphics.Bitmap | ||
|
||
val bitmapSample = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ package com.android.developers.androidify.util | |||||||||||||||
import android.app.Application | ||||||||||||||||
import android.content.ContentValues | ||||||||||||||||
import android.graphics.Bitmap | ||||||||||||||||
import android.graphics.BitmapFactory | ||||||||||||||||
import android.net.Uri | ||||||||||||||||
import android.os.Build | ||||||||||||||||
import android.os.Environment | ||||||||||||||||
|
@@ -53,6 +54,9 @@ interface LocalFileProvider { | |||||||||||||||
|
||||||||||||||||
@WorkerThread | ||||||||||||||||
suspend fun saveUriToSharedStorage(inputUri: Uri, fileName: String, mimeType: String): Uri | ||||||||||||||||
|
||||||||||||||||
@WorkerThread | ||||||||||||||||
suspend fun loadBitmapFromUri(uri: Uri): Bitmap? | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
@Singleton | ||||||||||||||||
|
@@ -120,6 +124,20 @@ class LocalFileProviderImpl @Inject constructor( | |||||||||||||||
return@withContext newUri | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
override suspend fun loadBitmapFromUri(uri: Uri): Bitmap? { | ||||||||||||||||
return withContext(ioDispatcher) { | ||||||||||||||||
try { | ||||||||||||||||
application.contentResolver.openInputStream(uri)?.use { | ||||||||||||||||
return@withContext BitmapFactory.decodeStream(it) | ||||||||||||||||
} | ||||||||||||||||
null | ||||||||||||||||
} catch (e: Exception) { | ||||||||||||||||
e.printStackTrace() | ||||||||||||||||
null | ||||||||||||||||
Comment on lines
+134
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
@Throws(IOException::class) | ||||||||||||||||
@WorkerThread | ||||||||||||||||
private fun saveFileToUri(file: File, uri: Uri) { | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I wonder if there is a way to register the UriSerializer for Nav3? @dturner