Merge "Fix LintImplTrimIndent lint issue in UnsafeNewApiCallsDetector" into androidx-master-dev
diff --git a/compose/material/material/api/current.txt b/compose/material/material/api/current.txt
index a9963c2..86bc5ab 100644
--- a/compose/material/material/api/current.txt
+++ b/compose/material/material/api/current.txt
@@ -82,7 +82,7 @@
public final class BottomNavigationKt {
method @androidx.compose.runtime.Composable public static void BottomNavigation-ye6PvEY(androidx.compose.ui.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.compose.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelect, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
+ method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
return <init>()
}), long selectedContentColor = contentColor(), long unselectedContentColor = EmphasisAmbient.current.medium.applyEmphasis(selectedContentColor));
}
diff --git a/compose/material/material/api/public_plus_experimental_current.txt b/compose/material/material/api/public_plus_experimental_current.txt
index a9963c2..86bc5ab 100644
--- a/compose/material/material/api/public_plus_experimental_current.txt
+++ b/compose/material/material/api/public_plus_experimental_current.txt
@@ -82,7 +82,7 @@
public final class BottomNavigationKt {
method @androidx.compose.runtime.Composable public static void BottomNavigation-ye6PvEY(androidx.compose.ui.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.compose.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelect, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
+ method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
return <init>()
}), long selectedContentColor = contentColor(), long unselectedContentColor = EmphasisAmbient.current.medium.applyEmphasis(selectedContentColor));
}
diff --git a/compose/material/material/api/restricted_current.txt b/compose/material/material/api/restricted_current.txt
index a9963c2..86bc5ab 100644
--- a/compose/material/material/api/restricted_current.txt
+++ b/compose/material/material/api/restricted_current.txt
@@ -82,7 +82,7 @@
public final class BottomNavigationKt {
method @androidx.compose.runtime.Composable public static void BottomNavigation-ye6PvEY(androidx.compose.ui.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.compose.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelect, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
+ method @androidx.compose.runtime.Composable public static void BottomNavigationItem-S1l6qvI(kotlin.jvm.functions.Function0<kotlin.Unit> icon, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, androidx.compose.ui.Modifier modifier = Modifier, kotlin.jvm.functions.Function0<kotlin.Unit> label = emptyContent(), boolean alwaysShowLabels = true, androidx.compose.foundation.InteractionState interactionState = remember({
return <init>()
}), long selectedContentColor = contentColor(), long unselectedContentColor = EmphasisAmbient.current.medium.applyEmphasis(selectedContentColor));
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomNavigationSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomNavigationSamples.kt
index 2806fb3..cb79754 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomNavigationSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomNavigationSamples.kt
@@ -41,7 +41,7 @@
icon = { Icon(Icons.Filled.Favorite) },
label = { Text(item) },
selected = selectedItem == index,
- onSelect = { selectedItem = index }
+ onClick = { selectedItem = index }
)
}
}
@@ -58,7 +58,7 @@
icon = { Icon(Icons.Filled.Favorite) },
label = { Text(item) },
selected = selectedItem == index,
- onSelect = { selectedItem = index },
+ onClick = { selectedItem = index },
alwaysShowLabels = false
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
index fd8cf78..c373fab 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
@@ -318,18 +318,18 @@
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = true,
- onSelect = {},
+ onClick = {},
interactionState = interactionState
)
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = false,
- onSelect = {}
+ onClick = {}
)
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = false,
- onSelect = {}
+ onClick = {}
)
}
}
@@ -362,7 +362,7 @@
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = true,
- onSelect = {},
+ onClick = {},
interactionState = interactionState,
selectedContentColor = selectedContentColor,
unselectedContentColor = unselectedContentColor
@@ -370,14 +370,14 @@
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = false,
- onSelect = {},
+ onClick = {},
selectedContentColor = selectedContentColor,
unselectedContentColor = unselectedContentColor
)
BottomNavigationItem(
icon = { Icon(Icons.Filled.Favorite) },
selected = false,
- onSelect = {},
+ onClick = {},
selectedContentColor = selectedContentColor,
unselectedContentColor = unselectedContentColor
)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationTest.kt
index b5eebd8..095b8c6 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationTest.kt
@@ -83,7 +83,7 @@
icon = { Icon(Icons.Filled.Favorite) },
label = { Text("Item $index") },
selected = index == 0,
- onSelect = {},
+ onClick = {},
modifier = Modifier.onPositioned { coords: LayoutCoordinates ->
itemCoords[index] = coords
}
@@ -126,7 +126,7 @@
Text("ItemText")
},
selected = true,
- onSelect = {}
+ onClick = {}
)
}
}
@@ -173,7 +173,7 @@
Text("ItemText")
},
selected = false,
- onSelect = {},
+ onClick = {},
alwaysShowLabels = false
)
}
@@ -207,7 +207,7 @@
},
label = {},
selected = false,
- onSelect = {}
+ onClick = {}
)
}
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
index fffb0d5..5bed6c9 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
@@ -123,7 +123,7 @@
*
* @param icon icon for this item, typically this will be a [androidx.compose.foundation.Icon]
* @param selected whether this item is selected
- * @param onSelect the callback to be invoked when this item is selected
+ * @param onClick the callback to be invoked when this item is selected
* @param modifier optional [Modifier] for this item
* @param label optional text label for this item
* @param alwaysShowLabels whether to always show labels for this item. If false, labels will
@@ -140,7 +140,7 @@
fun BottomNavigationItem(
icon: @Composable () -> Unit,
selected: Boolean,
- onSelect: () -> Unit,
+ onClick: () -> Unit,
modifier: Modifier = Modifier,
label: @Composable () -> Unit = emptyContent(),
alwaysShowLabels: Boolean = true,
@@ -164,7 +164,7 @@
modifier
.selectable(
selected = selected,
- onClick = onSelect,
+ onClick = onClick,
interactionState = interactionState,
indication = ripple
)
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt
index e534679..18a6a8b 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentViewTest.kt
@@ -26,7 +26,7 @@
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
+import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.testutils.withActivity
import com.google.common.truth.Truth.assertThat
@@ -36,7 +36,7 @@
import org.junit.Test
import org.junit.runner.RunWith
-@SmallTest
+@MediumTest
@RunWith(AndroidJUnit4::class)
class FragmentViewTest {
@Suppress("DEPRECATION")
@@ -421,6 +421,9 @@
assertWithMessage("Fragment should not go through lifecycle changes until it is added")
.that(fragment.lifecycle.currentState)
.isEqualTo(Lifecycle.State.INITIALIZED)
+ assertWithMessage("Fragment should not be considered active until it is added")
+ .that(fm.activeFragments)
+ .doesNotContain(fragment)
}
// Show a hidden fragment and its View should be VISIBLE. Then pop it and the View should be
@@ -480,6 +483,9 @@
assertWithMessage("Fragment should not go through lifecycle changes until it is added")
.that(fragment.lifecycle.currentState)
.isEqualTo(Lifecycle.State.INITIALIZED)
+ assertWithMessage("Fragment should not be considered active until it is added")
+ .that(fm.activeFragments)
+ .doesNotContain(fragment)
}
// Detaching a fragment should remove the View from the hierarchy. Then popping it should
@@ -572,6 +578,9 @@
assertWithMessage("Fragment should not go through lifecycle changes until it is added")
.that(fragment.lifecycle.currentState)
.isEqualTo(Lifecycle.State.INITIALIZED)
+ assertWithMessage("Fragment should not be considered active until it is added")
+ .that(fm.activeFragments)
+ .doesNotContain(fragment)
}
// Attaching a fragment should add the View back into the hierarchy. Then popping it should
@@ -665,6 +674,9 @@
assertWithMessage("Fragment should not go through lifecycle changes until it is added")
.that(fragment.lifecycle.currentState)
.isEqualTo(Lifecycle.State.INITIALIZED)
+ assertWithMessage("Fragment should not be considered active until it is added")
+ .that(fm.activeFragments)
+ .doesNotContain(fragment)
}
// Simple replace of one fragment in a container. Popping should replace it back again
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java b/fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
index c09ad78..ae73f30 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
@@ -1692,6 +1692,7 @@
void addFragment(@NonNull Fragment fragment) {
if (isLoggingEnabled(Log.VERBOSE)) Log.v(TAG, "add: " + fragment);
FragmentStateManager fragmentStateManager = createOrGetFragmentStateManager(fragment);
+ fragment.mFragmentManager = this;
mFragmentStore.makeActive(fragmentStateManager);
if (!fragment.mDetached) {
mFragmentStore.addFragment(fragment);
@@ -2129,7 +2130,7 @@
BackStackRecord record = records.get(index);
for (FragmentTransaction.Op op : record.mOps) {
Fragment fragment = op.mFragment;
- if (fragment != null) {
+ if (fragment != null && fragment.mFragmentManager != null) {
FragmentStateManager fragmentStateManager =
createOrGetFragmentStateManager(fragment);
mFragmentStore.makeActive(fragmentStateManager);