Fixed
Status Update
Comments
il...@google.com <il...@google.com>
hu...@google.com <hu...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit df318e2b31a94cc5e84deb9f0ae5bb085d457f19
Author: Ian Lake <ilake@google.com>
Date: Wed Jul 03 13:50:41 2019
Allow add() or replace() that take a Class
Rather than manually construct a Fragment to
pass it into a FragmentTransaction's add() and
replace() methods, leverage the FragmentFactory
already set on the FragmentManager to instantiate
the Fragment.
Besides allowing us to build reified versions of
these methods for Kotlin users, it also ensures
that both the intial creation and recreation
go through the same path.
Test: updated tests
BUG: 126124987
Change-Id: I726aee9a82d22c8803cf5e7aec858539c12d40bc
M fragment/fragment-ktx/api/1.2.0-alpha02.txt
M fragment/fragment-ktx/api/current.txt
A fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
A fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentTransaction.kt
M fragment/fragment/api/1.2.0-alpha02.txt
M fragment/fragment/api/current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/BackStackRecord.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
https://android-review.googlesource.com/1011464
https://goto.google.com/android-sha1/df318e2b31a94cc5e84deb9f0ae5bb085d457f19
Branch: androidx-master-dev
commit df318e2b31a94cc5e84deb9f0ae5bb085d457f19
Author: Ian Lake <ilake@google.com>
Date: Wed Jul 03 13:50:41 2019
Allow add() or replace() that take a Class
Rather than manually construct a Fragment to
pass it into a FragmentTransaction's add() and
replace() methods, leverage the FragmentFactory
already set on the FragmentManager to instantiate
the Fragment.
Besides allowing us to build reified versions of
these methods for Kotlin users, it also ensures
that both the intial creation and recreation
go through the same path.
Test: updated tests
BUG: 126124987
Change-Id: I726aee9a82d22c8803cf5e7aec858539c12d40bc
M fragment/fragment-ktx/api/1.2.0-alpha02.txt
M fragment/fragment-ktx/api/current.txt
A fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
A fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentTransaction.kt
M fragment/fragment/api/1.2.0-alpha02.txt
M fragment/fragment/api/current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/BackStackRecord.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
ru...@gmail.com <ru...@gmail.com> #3
We've added overloads for add and replace that take a Class and use FragmentFactory to instantiate a Fragment instance from the class name as well as Kotlin reified methods to do the same without requiring you type YourFragment::class.java. This will be available in Fragments 1.2.0-alpha02.
hu...@google.com <hu...@google.com> #4
Thanks for the explanation and link to the changeset, that's better than my original suggestion. Looking forward to trying it.
hu...@google.com <hu...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9bfc29b0becb32aa98d135f59be47db13d82a2a0
Author: Ian Lake <ilake@google.com>
Date: Tue Jul 16 16:48:32 2019
Add optional Bundle to FragmentTransaction Class APIs
When adding or replacing a Fragment with a
Class<? extends Fragment> (added in b/126124987 ), allow
developers to pass in an optional Bundle of arguments.
In FragmentTransaction itself, the methods take
a @Nullable Bundle, ensuring that developers are
aware that they are expected to pass arguments through
that method if they want them set.
In the Kotlin extensions, the Bundle is the last
parameter, with a default value of null.
Test: updated tests
Fixes: 137684600
Change-Id: Ic492556e92031d2116d394b561002f338e5b1824
M fragment/fragment-ktx/api/1.2.0-alpha02.txt
M fragment/fragment-ktx/api/current.txt
M fragment/fragment-ktx/api/restricted_1.2.0-alpha02.txt
M fragment/fragment-ktx/api/restricted_current.txt
M fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentTransaction.kt
M fragment/fragment/api/1.2.0-alpha02.txt
M fragment/fragment/api/current.txt
M fragment/fragment/api/restricted_1.2.0-alpha02.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
https://android-review.googlesource.com/1053563
https://goto.google.com/android-sha1/9bfc29b0becb32aa98d135f59be47db13d82a2a0
Branch: androidx-master-dev
commit 9bfc29b0becb32aa98d135f59be47db13d82a2a0
Author: Ian Lake <ilake@google.com>
Date: Tue Jul 16 16:48:32 2019
Add optional Bundle to FragmentTransaction Class APIs
When adding or replacing a Fragment with a
Class<? extends Fragment> (added in
developers to pass in an optional Bundle of arguments.
In FragmentTransaction itself, the methods take
a @Nullable Bundle, ensuring that developers are
aware that they are expected to pass arguments through
that method if they want them set.
In the Kotlin extensions, the Bundle is the last
parameter, with a default value of null.
Test: updated tests
Fixes: 137684600
Change-Id: Ic492556e92031d2116d394b561002f338e5b1824
M fragment/fragment-ktx/api/1.2.0-alpha02.txt
M fragment/fragment-ktx/api/current.txt
M fragment/fragment-ktx/api/restricted_1.2.0-alpha02.txt
M fragment/fragment-ktx/api/restricted_current.txt
M fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment-ktx/src/main/java/androidx/fragment/app/FragmentTransaction.kt
M fragment/fragment/api/1.2.0-alpha02.txt
M fragment/fragment/api/current.txt
M fragment/fragment/api/restricted_1.2.0-alpha02.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransactionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
om...@gmail.com <om...@gmail.com> #7
Sorry for interrupt, but I found this bug occur in fragment-testing 1.1.0-alpha09 again.
Here is my small project to reproduce it. (Reproduced in both AS 3.6.1 Canary 1 and AS 3.4.1)
Just run the `androidTest/LoginFragmentInstrumentedTest` as these two images show.
Here is my small project to reproduce it. (Reproduced in both AS 3.6.1 Canary 1 and AS 3.4.1)
Just run the `androidTest/LoginFragmentInstrumentedTest` as these two images show.
il...@google.com <il...@google.com> #8
Re #7 - you have to use one of the overloads to launchFragmentInContainer that take the theme resource ID for it to use a custom theme:
private val loginFragmentScenario = launchFragmentInContainer<LoginFragment>(
themeResId = R.style.Theme_Shrine)
private val loginFragmentScenario = launchFragmentInContainer<LoginFragment>(
themeResId = R.style.Theme_Shrine)
om...@gmail.com <om...@gmail.com> #9
Re #8
Yes, this way will "fix" this issue. But you could find that the "Theme_Shrine" is actually a descendant of "Theme.MaterialComponents.Light.NoActionBar" which is a "Theme.Appcompat.Light".
Therefore, I wonder if the solution you post above is by designed or a bug.
Yes, this way will "fix" this issue. But you could find that the "Theme_Shrine" is actually a descendant of "Theme.MaterialComponents.Light.NoActionBar" which is a "Theme.Appcompat.Light".
Therefore, I wonder if the solution you post above is by designed or a bug.
il...@google.com <il...@google.com> #10
You need to tell FragmentScenario what theme you want if you want something other than the default Theme.WithActionBar, that's correct.
Description
com.google.android.material:material:1.0.0
Using FragmentScenario to launch a Fragment with a MaterialButton, my instrumentation test crashes with:
"IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant)."
It appears that the EmptyFragmentActivity in FragmentScenario doesn't inherent a compatible theme with Material. I am currently working around this issue by manually overriding the EmptyFragmentActivity theme with a material one:
<style name="FragmentScenarioEmptyFragmentActivityTheme" parent="@style/Theme.MaterialComponents">
<item name="android:windowIsFloating">false</item>
</style>