Status Update
Comments
rv...@google.com <rv...@google.com>
p....@gmail.com <p....@gmail.com> #2
Branch: androidx-master-dev
commit d46999fa005b4726287814ea0f8abe30cf189a01
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue May 26 15:36:06 2020
Clean up ActivityResultCaller implementation
Instead of using two separate anonymous classes to be returned by the
register methods, lets clean it up by using an internal class and only
doing the implementation once.
Test: Tested in app
Bug: 156875743
Change-Id: Ia63dd0dce4ecd7115ea93168f889e119738e3352
M activity/activity-ktx/api/1.2.0-alpha06.txt
M activity/activity-ktx/api/current.txt
M activity/activity-ktx/api/public_plus_experimental_1.2.0-alpha06.txt
M activity/activity-ktx/api/public_plus_experimental_current.txt
M activity/activity-ktx/api/restricted_1.2.0-alpha06.txt
M activity/activity-ktx/api/restricted_current.txt
M activity/activity-ktx/src/main/java/androidx/activity/result/ActivityResultCaller.kt
rv...@google.com <rv...@google.com> #3
Branch: androidx-master-dev
commit 55c784def8b9942026075af6fc659b551732ef44
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue May 26 08:45:51 2020
Add getContract to ActivityResultLauncher
Intents provide a way to check if the intent can be handled by any
Activity components and the ActivityResultLauncher should provide
the ability to do something similar.
This change adds a getContract API to ActivityResultLauncher that gives
the returns the contract used to register the launcher. This means that
users can create an Intent from their contract and make all of their
desired checks.
Test: ActivityResultLauncherTest
Bug: 156875743
RelNote: "ActivityResultLauncher now allows you to get the
ActivityResultContract that was used to register the launcher."
Change-Id: I64f536f2b3dde3e87cea884c6b9c111e5efe26ed
M activity/activity-ktx/build.gradle
M activity/activity-ktx/src/androidTest/AndroidManifest.xml
A activity/activity-ktx/src/androidTest/java/androidx/activity/result/ActivityResultCallerTest.kt
M activity/activity-ktx/src/main/java/androidx/activity/result/ActivityResultCaller.kt
M activity/activity/api/1.2.0-alpha06.txt
M activity/activity/api/current.txt
M activity/activity/api/public_plus_experimental_1.2.0-alpha06.txt
M activity/activity/api/public_plus_experimental_current.txt
M activity/activity/api/restricted_1.2.0-alpha06.txt
M activity/activity/api/restricted_current.txt
M activity/activity/src/androidTest/java/androidx/activity/result/ActivityResultLauncherTest.kt
M activity/activity/src/main/java/androidx/activity/result/ActivityResultLauncher.java
M activity/activity/src/main/java/androidx/activity/result/ActivityResultRegistry.java
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
p....@gmail.com <p....@gmail.com> #4
This has been fixed internally and will be available in the Activity 1.2.0-alpha06 release.
To address this the ActivityResultLauncher
now gives access to the ActivityResultContract
.
With the contract, you can create the intent and use it to call resolveActivity()
directly:
launcher.contract.createIntent(context, input).resolveActivity(packageManager)
rv...@google.com <rv...@google.com> #5
Keep in mind that due to the resolveActivity()
will return null unless you add the specific <queries>
elements to your manifest.
As per that doc, the alternative is to catch the ActivityNotFoundException
yourself by wrapping your launch()
call in a try
/ catch
, just like if you were using startActivityForResult()
yourself.
p....@gmail.com <p....@gmail.com> #6
rv...@google.com <rv...@google.com> #7
Okay. And what if there are more items to the right and the user clicks DPAD_RIGHT in the above image? Where do you expect the focus to go? And how should it look like?
p....@gmail.com <p....@gmail.com> #8
rv...@google.com <rv...@google.com> #9
This looks like a custom implementation of PositionFocusedItemInLazyLayout. You can use that as a starter and update the math logic in the function based on your needs.
p....@gmail.com <p....@gmail.com> #10
[Deleted User] <[Deleted User]> #11
rv...@google.com <rv...@google.com> #12
It is not clear what the issue is. Can you please file a new issue with a minimal reproducible snippet of code along with the library versions?
Description
Starting from version
1.0.0-alpha11
ofandroidx.tv.foundation
, tv lazy layouts are deprecated and will be removed in the future releases. This includes the following components and their respective tv-foundation dependencies.TvLazyRow
TvLazyColumn
TvLazyHorizontalGrid
TvLazyVerticalGrid
This deprecation follows a new feature addition in the compose foundation's lazy layouts. The tv lazy layouts offered a Feature CL
pivotOffsets
functionality that would allow to position the current focused item at a specific position. This can now be achieved by providing a custom BringIntoViewSpec to the compose foundation's lazy layouts.The following part of the ticket will talk about migration from tv lazy layouts to compose foundation layouts.
Prerequisites
1.7.0-beta02
or above.androidx.compose.foundation
androidx.compose.runtime
androidx.tv.foundation
dependency from your package if you were only using the tv lazy layouts.Option 1. If you are using tv lazy layouts WITHOUT customizing the
pivotOffsets
.Changes
androidx.compose.foundation
Tv
prefix from all theTvLazy*
components.Before: Using
androidx.tv.foundation
After: Using
androidx.compose.foundation
Option 2. If you are customizing the
pivotOffsets
in the tv lazy layouts.Changes
androidx.compose.foundation
Tv
prefix from all theTvLazy*
components.Custom BringIntoView spec:
Now that we have the custom BringIntoView spec, usage it pretty straightforward. Wrap the entire app with
PositionFocusedItemInLazyLayout
and all your inner lazy layouts will respect that.You can even override it for specific layouts like shown below: