From 8f506a835cc8ea209c0fec6e200d8d31d0894b42 Mon Sep 17 00:00:00 2001 From: Gino Miceli Date: Sun, 10 Sep 2023 18:20:34 -0400 Subject: [PATCH 1/6] Disable download button while estimating size --- .../ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt index 2786ddde75..2a0d4b00fa 100644 --- a/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt @@ -125,6 +125,7 @@ internal constructor( } private fun onStartEstimatingDownloadSize() { + downloadButtonEnabled.postValue(false) sizeOnDisk.postValue(resources.getString(R.string.offline_area_size_loading_symbol)) visibleBottomTextViewId.postValue(R.id.size_on_disk_text_view) } From fd4a33b147105bf4f14f6a43959136b51a5e0096 Mon Sep 17 00:00:00 2001 From: Gino Miceli Date: Sun, 10 Sep 2023 18:50:51 -0400 Subject: [PATCH 2/6] Disable download button while estimating size --- .../ground/ui/common/BaseMapViewModel.kt | 2 +- .../selector/OfflineAreaSelectorViewModel.kt | 7 ++++++- .../res/color/color_states_primary_button.xml | 21 +++++++++++++++++++ .../layout/offline_base_map_selector_frag.xml | 10 +++++---- ground/src/main/res/values/styles.xml | 2 +- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 ground/src/main/res/color/color_states_primary_button.xml diff --git a/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt index a426fe5444..aa4854f8ec 100644 --- a/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/common/BaseMapViewModel.kt @@ -180,7 +180,7 @@ constructor( } /** Called when the map starts to move by the user. */ - fun onMapDragged() { + open fun onMapDragged() { if (locationLock.value.getOrDefault(false)) { Timber.d("User dragged map. Disabling location lock") viewModelScope.launch { disableLocationLock() } diff --git a/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt b/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt index 2a0d4b00fa..56a88678ba 100644 --- a/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt +++ b/ground/src/main/java/com/google/android/ground/ui/offlinebasemap/selector/OfflineAreaSelectorViewModel.kt @@ -111,8 +111,14 @@ internal constructor( disposeOnClear(cameraBoundUpdates.subscribe { viewport = it }) } + override fun onMapDragged() { + onStartEstimatingDownloadSize() + super.onMapDragged() + } + override fun onMapCameraMoved(newCameraPosition: CameraPosition) { super.onMapCameraMoved(newCameraPosition) + val bounds = newCameraPosition.bounds val zoomLevel = newCameraPosition.zoomLevel if (bounds == null || zoomLevel == null) return @@ -131,7 +137,6 @@ internal constructor( } private suspend fun updateDownloadSize(bounds: Bounds) { - onStartEstimatingDownloadSize() val sizeInMb = offlineAreaRepository.estimateSizeOnDisk(bounds) / (1024f * 1024f) if (sizeInMb > MAX_AREA_DOWNLOAD_SIZE_MB) { onLargeAreaSelected() diff --git a/ground/src/main/res/color/color_states_primary_button.xml b/ground/src/main/res/color/color_states_primary_button.xml new file mode 100644 index 0000000000..68dcf54f69 --- /dev/null +++ b/ground/src/main/res/color/color_states_primary_button.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/ground/src/main/res/layout/offline_base_map_selector_frag.xml b/ground/src/main/res/layout/offline_base_map_selector_frag.xml index 2ec2d50246..d16c100b51 100644 --- a/ground/src/main/res/layout/offline_base_map_selector_frag.xml +++ b/ground/src/main/res/layout/offline_base_map_selector_frag.xml @@ -101,7 +101,7 @@ app:layout_constraintTop_toBottomOf="@id/top_mask" app:layout_constraintBottom_toTopOf="@id/bottom_mask" app:layout_constraintLeft_toRightOf="@id/left_mask" - app:layout_constraintRight_toLeftOf="@id/right_mask"/> + app:layout_constraintRight_toLeftOf="@id/right_mask" /> + android:alpha="0.4" /> + android:text="@{@string/selected_offline_area_size(viewModel.sizeOnDisk)}" /> + android:text="@string/selected_offline_area_too_large" /> diff --git a/ground/src/main/res/values/styles.xml b/ground/src/main/res/values/styles.xml index 5e7b2c367e..9c6310b723 100644 --- a/ground/src/main/res/values/styles.xml +++ b/ground/src/main/res/values/styles.xml @@ -139,7 +139,7 @@