Skip to content

Commit

Permalink
Merge pull request #39 from makeen-project/fix/ALS-1667_UI_issue_geof…
Browse files Browse the repository at this point in the history
…ence

[Makeen] [Bug- ALS-1667] - fixed UI issue inside geofence and tracking tab
  • Loading branch information
vinguthh authored Oct 2, 2023
2 parents 07023e5 + 67be6f8 commit d1ef9de
Show file tree
Hide file tree
Showing 11 changed files with 1,451 additions and 1,277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ class MainActivity : BaseActivity(), CrashListener {
mBinding.bottomNavigationMain.selectedItemId = R.id.menu_geofence
}

fun getBottomNavHeight(): Int {
return mBinding.bottomNavigationMain.height
}

private fun initObserver() {
lifecycleScope.launchWhenStarted {
mSignInViewModel.mSignInResponse.collect { handleResult ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.plugins.annotation.OnSymbolDragListener
import java.text.DecimalFormat
import java.util.regex.Pattern
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import java.text.DecimalFormat
import java.util.regex.Pattern

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down Expand Up @@ -566,7 +566,27 @@ class GeofenceUtils {
mBottomSheetGeofenceListBehavior?.isHideable = false
mBottomSheetGeofenceListBehavior?.isDraggable = true
mBottomSheetGeofenceListBehavior?.isFitToContents = false
mBottomSheetGeofenceListBehavior?.halfExpandedRatio = 0.58f
mBindingGeofenceList?.clGeofenceList?.post {
val clEmptyGeofenceListInnerHeight =
mBindingGeofenceList?.clEmptyGeofenceListInner?.height ?: 0
val clEmptyGeofenceListHeight =
mBindingGeofenceList?.clGeofenceListMain?.height ?: 0
val clGeofenceListHeight =
mBindingGeofenceList?.clGeofenceList?.height ?: 0

val topLogoMargin = clEmptyGeofenceListHeight - clGeofenceListHeight
val screenHeight = (mActivity as MainActivity).resources.displayMetrics.heightPixels
val isTablet = (mActivity as MainActivity).isTablet
val bottomNavHeight = if (isTablet) (mActivity as MainActivity).getBottomNavHeight().toFloat() else 0f
val topLogoHeight = if (isTablet) 0f else topLogoMargin.toFloat()

val halfExpandedRatio = if (screenHeight.toFloat() != 0.toFloat()) {
((clEmptyGeofenceListInnerHeight.toFloat() + bottomNavHeight + topLogoHeight)) / screenHeight
} else {
0.55f
}
mBottomSheetGeofenceListBehavior?.halfExpandedRatio = halfExpandedRatio
}
mBindingGeofenceList?.clGeofenceList?.context?.let {
if ((mActivity as MainActivity).isTablet) {
mBottomSheetGeofenceListBehavior?.peekHeight = it.resources.getDimensionPixelSize(R.dimen.dp_150)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,27 @@ class TrackingUtils(
TrackingEnum.ENABLE_TRACKING -> {
mBottomSheetTrackingBehavior?.isDraggable = true
mBottomSheetTrackingBehavior?.isFitToContents = false
mBottomSheetTrackingBehavior?.halfExpandedRatio = 0.58f
mBindingTracking?.clTracking?.post {
val clEnableTrackingInnerHeight =
mBindingTracking?.clEnableTrackingInner?.height ?: 0
val clPersistentBottomSheetHeight =
mBindingTracking?.clPersistentBottomSheet?.height ?: 0
val clTrackingHeight =
mBindingTracking?.clTracking?.height ?: 0

val topLogoMargin = clPersistentBottomSheetHeight - clTrackingHeight
val screenHeight = (mActivity as MainActivity).resources.displayMetrics.heightPixels
val isTablet = (mActivity as MainActivity).isTablet
val bottomNavHeight = if (isTablet) (mActivity as MainActivity).getBottomNavHeight().toFloat() else 0f
val topLogoHeight = if (isTablet) 0f else topLogoMargin.toFloat()

val halfExpandedRatio = if (screenHeight.toFloat() != 0.toFloat()) {
((clEnableTrackingInnerHeight.toFloat() + bottomNavHeight + topLogoHeight)) / screenHeight
} else {
0.55f
}
mBottomSheetTrackingBehavior?.halfExpandedRatio = halfExpandedRatio
}
mBindingTracking?.clEnableTracking?.context?.let {
if ((activity as MainActivity).isTablet) {
mBottomSheetTrackingBehavior?.peekHeight = it.resources.getDimensionPixelSize(R.dimen.dp_150)
Expand Down Expand Up @@ -162,11 +182,19 @@ class TrackingUtils(
trackingHistoryData.clear()
getCurrentDateData()

val clTracking = mBindingTracking?.clTracking?.height ?: 0
val clPersistentBottomSheetHeight = mBindingTracking?.clPersistentBottomSheet?.height ?: 0
val clTrackingInnerHeight = mBindingTracking?.clTrackingInner?.height ?: 0
val totalHeight = (clPersistentBottomSheetHeight - clTracking) + clTrackingInnerHeight
mBottomSheetTrackingBehavior?.peekHeight = totalHeight

mBottomSheetTrackingBehavior?.isDraggable = true
if ((activity as MainActivity).isTablet) {
mBottomSheetTrackingBehavior?.peekHeight = clTracking.context.resources.getDimensionPixelSize(R.dimen.dp_150)
mBottomSheetTrackingBehavior?.peekHeight =
totalHeight
} else {
mBottomSheetTrackingBehavior?.peekHeight = clTracking.context.resources.getDimensionPixelSize(R.dimen.dp_127)
mBottomSheetTrackingBehavior?.peekHeight =
totalHeight
}
mBottomSheetTrackingBehavior?.state = BottomSheetBehavior.STATE_HALF_EXPANDED
}
Expand Down
Loading

0 comments on commit d1ef9de

Please sign in to comment.