Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions FluentUI.Demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
<activity android:name="com.microsoft.fluentuidemo.demos.V2BasicControlsActivity" />
<activity android:name="com.microsoft.fluentuidemo.demos.V2BottomDrawerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustResize"
android:enableOnBackInvokedCallback="true"/>
android:windowSoftInputMode="adjustResize"/>
<activity android:name="com.microsoft.fluentuidemo.demos.V2BottomSheetActivity"
android:configChanges="orientation|keyboardHidden|screenSize"/>
<activity android:name="com.microsoft.fluentuidemo.demos.V2CardActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import SearchViewModelFactory
import Searchable
import android.content.res.Configuration
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
Expand Down Expand Up @@ -92,22 +90,11 @@ class V2BottomDrawerActivity : V2DemoActivity() {
override val paramsUrl = "https://github.com/microsoft/fluentui-android/wiki/Controls#params-9"
override val controlTokensUrl =
"https://github.com/microsoft/fluentui-android/wiki/Controls#control-tokens-9"
private val onBackCallback =
object : OnBackPressedCallback(true) { //callback to end the activity
override fun handleOnBackPressed() {
finish()
}

}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setActivityContent {
CreateActivityUI()
LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher?.addCallback(
this,
onBackCallback
) //registering the callback to end the activity when back button is pressed
}
}
}
Expand Down Expand Up @@ -566,7 +553,7 @@ private fun CreateSearchableDrawerWithButtonOnPrimarySurfaceToInvokeIt(
)
val open: () -> Unit = {
scope.launch {
if(drawerState.currentValue == DrawerValue.Closed) {
if (drawerState.currentValue == DrawerValue.Closed) {
viewModel.clearSelection()
}
drawerState.open()
Expand Down
1 change: 1 addition & 0 deletions azure-maven-central-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:

- task: Gradle@2
displayName: Hydra Lab UI test
condition: eq(coalesce(variables['runHydraLabTests'], 'false'), 'true')
inputs:
gradleWrapperFile: "gradlew"
tasks: "requestHydraLabTest -PappPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/development/debug/FluentUI.Demo-development-debug.apk -PtestAppPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/androidTest/development/debug/FluentUI.Demo-development-debug-androidTest.apk -PbuildFlavor=$(buildFlavor) -PtestSuiteName=$(testSuiteName) -PrunTimeOutSeconds=$(timeOutSeconds) -PdeviceIdentifier=$(deviceIdentifier) -PgroupTestType=$(groupTestType) -PreportAudience=TestLabOwner -PauthToken=$(authToken) -PpkgName=$(pkgName) -PtestPkgName=$(testPkgName) -PrunningType=$(runningType) -PframeworkType=$(frameworkType) -PhydraLabAPIHost=$(hydraLabAPIHost) -PhydraLabAPISchema=$(hydraLabAPISchema)"
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines-fork-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:

- task: Gradle@3
displayName: Hydra Lab UI test
condition: eq(coalesce(variables['runHydraLabTests'], 'false'), 'true')
inputs:
gradleWrapperFile: "gradlew"
tasks: "requestHydraLabTest -PappPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/development/debug/FluentUI.Demo-development-debug.apk -PtestAppPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/androidTest/development/debug/FluentUI.Demo-development-debug-androidTest.apk -PbuildFlavor=$(buildFlavor) -PtestSuiteName=$(testSuiteName) -PrunTimeOutSeconds=$(timeOutSeconds) -PdeviceIdentifier=$(deviceIdentifier) -PgroupTestType=$(groupTestType) -PreportAudience=TestLabOwner -PauthToken=$(authToken) -PpkgName=$(pkgName) -PtestPkgName=$(testPkgName) -PrunningType=$(runningType) -PframeworkType=$(frameworkType) -PhydraLabAPIHost=$(hydraLabAPIHost) -PhydraLabAPISchema=$(hydraLabAPISchema)"
Expand Down
1 change: 1 addition & 0 deletions fluentui-maven-central-publish-1espt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extends:
spotBugsAnalysis: false
- task: Gradle@2
displayName: Hydra Lab UI test
condition: eq(coalesce(variables['runHydraLabTests'], 'false'), 'true')
inputs:
gradleWrapperFile: "gradlew"
tasks: "requestHydraLabTest -PappPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/development/debug/FluentUI.Demo-development-debug.apk -PtestAppPath=$(build.sourcesdirectory)/FluentUI.Demo/build/outputs/apk/androidTest/development/debug/FluentUI.Demo-development-debug-androidTest.apk -PbuildFlavor=$(buildFlavor) -PtestSuiteName=$(testSuiteName) -PrunTimeOutSeconds=$(timeOutSeconds) -PdeviceIdentifier=$(deviceIdentifier) -PgroupTestType=$(groupTestType) -PreportAudience=TestLabOwner -PauthToken=$(authToken) -PpkgName=$(pkgName) -PtestPkgName=$(testPkgName) -PrunningType=$(runningType) -PframeworkType=$(frameworkType) -PhydraLabAPIHost=$(hydraLabAPIHost) -PhydraLabAPISchema=$(hydraLabAPISchema)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.graphics.PixelFormat
import android.graphics.Rect
import android.os.Build
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewOutlineProvider
Expand Down Expand Up @@ -66,13 +67,15 @@ import java.util.UUID
*/
@Composable
fun ModalPopup(
onDismissRequest:(() -> Unit)? = null,
onDismissRequest: (() -> Unit)? = null,
properties: PopupProperties = PopupProperties(
focusable = true,
dismissOnBackPress = true,
dismissOnClickOutside = true
),
windowInsetsType: Int = WindowInsetsCompat.Type.systemBars(),
content: @Composable () -> Unit,
) {
val properties = PopupProperties(
focusable = true,
)
val view = LocalView.current
val density = LocalDensity.current
val layoutDirection = LocalLayoutDirection.current
Expand Down Expand Up @@ -263,6 +266,25 @@ private class ModalWindow(
// Do nothing.
}

override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (event.keyCode == KeyEvent.KEYCODE_BACK && properties.dismissOnBackPress) {
if (keyDispatcherState == null) {
return super.dispatchKeyEvent(event)
}
val state = keyDispatcherState
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
state?.startTracking(event, this)
return true
} else if (event.action == KeyEvent.ACTION_UP) {
if (state != null && state.isTracking(event) && !event.isCanceled) {
onDismissRequest?.invoke()
return true
}
}
}
return super.dispatchKeyEvent(event)
}

fun superSetLayoutDirection(layoutDirection: LayoutDirection) {
val direction = when (layoutDirection) {
LayoutDirection.Ltr -> android.util.LayoutDirection.LTR
Expand All @@ -271,7 +293,7 @@ private class ModalWindow(
super.setLayoutDirection(direction)
}

private fun createLayoutParams(): WindowManager.LayoutParams{
private fun createLayoutParams(): WindowManager.LayoutParams {
return WindowManager.LayoutParams().apply {
// Position bottom sheet from the bottom of the screen
gravity = Gravity.BOTTOM or Gravity.START
Expand Down Expand Up @@ -326,7 +348,11 @@ private open class PopupLayoutHelperImpl {

@RequiresApi(29) // android.view.View#setSystemGestureExclusionRects call requires API 29 and above
private class PopupLayoutHelperImpl29 : PopupLayoutHelperImpl() {
override fun setGestureExclusionRects(composeView: View, width: Int, height: Int) { // We need to explicitly specify to exclude the entire screen from system gestures
override fun setGestureExclusionRects(
composeView: View,
width: Int,
height: Int
) { // We need to explicitly specify to exclude the entire screen from system gestures
composeView.systemGestureExclusionRects = mutableListOf(
Rect(
0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.microsoft.fluentui.tokenized.drawer

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -327,7 +326,10 @@ internal fun Scrim(
}

@Composable
internal fun AnnounceDrawerActions(drawerState: DrawerState, talkbackAnnouncement: DrawerAccessibilityAnnouncement){ // Announces actions for drawer through Talkback
internal fun AnnounceDrawerActions(
drawerState: DrawerState,
talkbackAnnouncement: DrawerAccessibilityAnnouncement
) { // Announces actions for drawer through Talkback
val view = LocalView.current
var previousState by remember { mutableStateOf(drawerState.enable) }

Expand All @@ -343,6 +345,7 @@ internal fun AnnounceDrawerActions(drawerState: DrawerState, talkbackAnnouncemen
}

}

/**
*
* Drawer block interaction with the rest of an app’s content with a scrim.
Expand Down Expand Up @@ -522,12 +525,16 @@ fun BottomDrawer(
scope.launch { drawerState.close() }
}
}
BackHandler { //TODO: Add pull down animation with predictive back
close()
}
ModalPopup(
windowInsetsType = windowInsetsType,
onDismissRequest = close,
properties = PopupProperties(
focusable = true,
dismissOnBackPress = true,
dismissOnClickOutside = false
),
onDismissRequest = {
close()
},
)
{
val drawerShape: Shape =
Expand Down