Skip to content

Commit 320ff81

Browse files
committed
Disable authorization's snack-bar cancellation
Signed-off-by: Saeed Rezaee <saeed.rezaee@kynetics.it>
1 parent 7ad5e8d commit 320ff81

File tree

1 file changed

+10
-0
lines changed
  • uf-service-api-reference-implementation/src/main/kotlin/com/kynetics/uf/clientexample/activity

1 file changed

+10
-0
lines changed

uf-service-api-reference-implementation/src/main/kotlin/com/kynetics/uf/clientexample/activity/MainActivity.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import androidx.core.view.GravityCompat
3838
import androidx.drawerlayout.widget.DrawerLayout
3939
import androidx.fragment.app.Fragment
4040
import com.google.android.material.navigation.NavigationView
41+
import com.google.android.material.snackbar.BaseTransientBottomBar
4142
import com.google.android.material.snackbar.Snackbar
4243
import com.kynetics.uf.android.api.Communication
4344
import com.kynetics.uf.android.api.UFServiceConfigurationV2
@@ -394,6 +395,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
394395
val content = getString(R.string.auth_request_toast_message, authType)
395396
val toolbarView = findViewById<View>(R.id.my_toolbar)
396397
authSnackBar = Snackbar.make(toolbarView, content, Snackbar.LENGTH_INDEFINITE)
398+
.setBehavior(NoSwipeBehavior())
397399
.setAction(R.string.action_grant) {
398400
sendPermissionResponse()
399401
}
@@ -404,6 +406,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
404406
val toolbarView = findViewById<View>(R.id.my_toolbar)
405407
authWarningSnackBar = Snackbar.make(toolbarView, R.string.auth_request_warning,
406408
Snackbar.LENGTH_INDEFINITE)
409+
.setBehavior(NoSwipeBehavior())
407410
authWarningSnackBar?.show()
408411
}
409412

@@ -488,6 +491,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
488491
}
489492
}
490493

494+
internal class NoSwipeBehavior : BaseTransientBottomBar.Behavior() {
495+
override fun canSwipeDismissView(child: View): Boolean {
496+
return false
497+
}
498+
}
499+
500+
491501
companion object {
492502
private val TAG = MainActivity::class.java.simpleName
493503
}

0 commit comments

Comments
 (0)