Author: Adam <git@apiote.xyz>
add loading and empty states to journeys
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a9704629f4fa1df98130fdae2194e41f2cdfe710..8bcc1218356a1fad5ae316e934dcaff28ca13d68 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -81,6 +81,7 @@ } kotlin.sourceSets["main"].kotlin.srcDir("${layout.buildDirectory.get()}/generated/src/main/kotlin") +// TODO only in debug tasks.withType<KotlinCompile> { dependsOn("openApiGenerate") dependsOn("lintReuse") diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/MainActivity.kt b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/MainActivity.kt index 0ac2110a07cbac7e22c698867779985daae5ff9e..6e848a144af2c35c587c4347558d324745536f14 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/MainActivity.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/MainActivity.kt @@ -205,6 +205,7 @@ Manifest.permission.ACCESS_COARSE_LOCATION ) -> { when (fragment) { is HomeFragment -> { + // TODO make Query class and use also in journey showResults(ResultsActivity.Mode.MODE_LOCATION) } @@ -233,6 +234,7 @@ } } fun onSearchClicked(text: CharSequence?) { + // TODO make Query class and use also in journey if (OpenLocationCode.isValidCode(text.toString())) { val olc = OpenLocationCode(text.toString()) if (!olc.isFull) { diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysActivity.kt b/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysActivity.kt index 058c1489442f28428b92c9a0398c7af00dfea2fe..5f9707b1c1f5a80b54d9c20dc1ee9d4753f9216e 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysActivity.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysActivity.kt @@ -11,7 +11,7 @@ import android.content.res.Configuration.UI_MODE_NIGHT_UNDEFINED import android.content.res.Configuration.UI_MODE_NIGHT_YES import android.os.Build import android.os.Bundle -import android.util.Log +import android.view.View import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat @@ -96,9 +96,16 @@ val destination = getDestination() journeysViewModel.journeys.observe(this) { zoomMap(100) - binding.journeys.adapter = JourneysAdapter(layoutInflater, this, it) { - // todo move map accordingly - // todo show shape on map + binding.journeysProgress.visibility = View.GONE + if (it.isEmpty()) { + binding.emptyText.visibility = View.VISIBLE + binding.emptyImage.visibility = View.VISIBLE + } else { + binding.journeys.visibility = View.VISIBLE + binding.journeys.adapter = JourneysAdapter(layoutInflater, this, it) { + // todo move map accordingly + // todo show shape on map + } } } journeysViewModel.getJourneys(this, origin, destination) diff --git a/app/src/main/res/drawable/error_journeys.xml b/app/src/main/res/drawable/error_journeys.xml new file mode 100644 index 0000000000000000000000000000000000000000..45256f408b44b2b2e9684242a2732b1e51175efd --- /dev/null +++ b/app/src/main/res/drawable/error_journeys.xml @@ -0,0 +1,21 @@ +<!-- +SPDX-FileCopyrightText: Google + +SPDX-License-Identifier: Apache-2.0 +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:tint="?attr/colorOnSurface" + android:viewportWidth="24" + android:viewportHeight="24"> + + <path + android:fillColor="@android:color/white" + android:pathData="M12.83,10h0.67V7.5L17,11l-1.59,1.59L18.83,16l2.59,-2.59c0.78,-0.78 0.78,-2.05 0,-2.83l-7.99,-8c-0.78,-0.78 -2.05,-0.78 -2.83,0L8,5.17L12.83,10z" /> + + <path + android:fillColor="@android:color/white" + android:pathData="M2.81,2.81L1.39,4.22L5.17,8l-2.59,2.59c-0.78,0.78 -0.78,2.05 0,2.83l8.01,8c0.78,0.78 2.05,0.78 2.83,0L16,18.83l3.78,3.78l1.41,-1.41L2.81,2.81zM10,15H8v-4c0,-0.05 0.02,-0.09 0.03,-0.14L10,12.83V15z" /> + +</vector> diff --git a/app/src/main/res/layout/activity_journeys.xml b/app/src/main/res/layout/activity_journeys.xml index 23884c043666b148164bde917d548dbf2229c97b..c1ab83ad33ed4df004b224065382d003a5a0a836 100644 --- a/app/src/main/res/layout/activity_journeys.xml +++ b/app/src/main/res/layout/activity_journeys.xml @@ -13,14 +13,16 @@ <org.osmdroid.views.MapView android:id="@+id/map" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"> + + </org.osmdroid.views.MapView> <androidx.constraintlayout.widget.ConstraintLayout - app:behavior_hideable="false" android:id="@+id/journeys_bottom_sheet" style="@style/Widget.Material3.BottomSheet" android:layout_width="match_parent" android:layout_height="640dp" + app:behavior_hideable="false" app:behavior_peekHeight="256dp" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> @@ -37,8 +39,47 @@ android:id="@+id/journeys" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" + android:visibility="gone" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_constraintTop_toBottomOf="@+id/drag_handle" /> + + <com.google.android.material.progressindicator.CircularProgressIndicator + android:id="@+id/journeys_progress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="48dp" + android:indeterminate="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/drag_handle" /> + + <ImageView + android:id="@+id/empty_image" + android:layout_width="92dp" + android:layout_height="92dp" + android:visibility="gone" + android:layout_marginTop="36dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/drag_handle" + tools:ignore="ContentDescription" + android:src="@drawable/error_journeys" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/empty_text" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:visibility="gone" + android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" + android:textAlignment="center" + android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/empty_image" + android:text="@string/no_journeys_found" /> + </androidx.constraintlayout.widget.ConstraintLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e8c3ac7e24ad1cb12e0698b034c734f6987bbbc..8bbbfa15f1a140cd61743fc3b96b8dbabc6498c5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -312,4 +312,5 @@ <string name="use_as_origin">use as origin</string> <string name="use_as_destination">use as destination</string> <string name="here">here</string> + <string name="no_journeys_found">No journeys found</string> </resources>