Author: Adam Evyčędo <git@apiote.xyz>
add journey results screen
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a30a386b78e38c4f35b7e686668990530549dce9..1c63870bda8310cca111bf5cfc06ad880e1df2e9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -123,6 +123,7 @@ implementation("ch.acra:acra-http:5.12.0") implementation("ch.acra:acra-notification:5.12.0") implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("com.squareup.moshi:moshi-kotlin:1.15.1") + implementation("androidx.activity:activity:1.9.3") coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.3") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7ade295023643222ffb5ab08ecefc1e87c841fbb..407d80f9dca8393a8cb5dcc5cbc4bb5c7cb05124 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,11 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> - -<!-- -SPDX-FileCopyrightText: Adam Evyčędo - -SPDX-License-Identifier: GPL-3.0-or-later ---> - <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tool="http://schemas.android.com/tools"> @@ -28,6 +21,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Bimba.Style" tool:targetApi="33"> + <activity + android:name=".journeys.JourneysActivity" + android:exported="false" /> <activity android:name=".settings.SettingsActivity" android:exported="false" 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 new file mode 100644 index 0000000000000000000000000000000000000000..943d9ac58206d6b431ff049c580e2796e8b30538 --- /dev/null +++ b/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysActivity.kt @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: Adam Evyčędo +// +// SPDX-License-Identifier: GPL-3.0-or-later + +package xyz.apiote.bimba.czwek.journeys + +import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import androidx.lifecycle.ViewModelProvider +import xyz.apiote.bimba.czwek.databinding.ActivityJourneysBinding + +class JourneysActivity : AppCompatActivity() { + private lateinit var binding: ActivityJourneysBinding + override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() + super.onCreate(savedInstanceState) + binding = ActivityJourneysBinding.inflate(layoutInflater) + setContentView(binding.root) + val journeysViewModel = + ViewModelProvider(this)[JourneysViewModel::class.java] + + // TODO check insets + ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + } +} \ No newline at end of file diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysViewModel.kt b/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysViewModel.kt new file mode 100644 index 0000000000000000000000000000000000000000..d3104ca25c162ca11733440de58fed609f1ab301 --- /dev/null +++ b/app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysViewModel.kt @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: Adam Evyčędo +// +// SPDX-License-Identifier: GPL-3.0-or-later + +package xyz.apiote.bimba.czwek.journeys + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +class JourneysViewModel : ViewModel() { + + private val _text = MutableLiveData<String>().apply { + value = "This is voyage Fragment" + } + val text: LiveData<String> = _text +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_journeys.xml b/app/src/main/res/layout/activity_journeys.xml new file mode 100644 index 0000000000000000000000000000000000000000..1cb7429da693de3981b65125d5a86f94bf6a50ab --- /dev/null +++ b/app/src/main/res/layout/activity_journeys.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?><!-- +SPDX-FileCopyrightText: Adam Evyčędo + +SPDX-License-Identifier: GPL-3.0-or-later +--> +<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".journeys.JourneysActivity"> + + <org.osmdroid.views.MapView + android:id="@+id/map" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/standard_bottom_sheet" + style="@style/Widget.Material3.BottomSheet" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> + + <com.google.android.material.bottomsheet.BottomSheetDragHandleView + android:id="@+id/drag_handle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/journeys" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + app:layout_constraintTop_toBottomOf="@+id/drag_handle" /> + </androidx.constraintlayout.widget.ConstraintLayout> + +</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/journey.xml b/app/src/main/res/layout/journey.xml new file mode 100644 index 0000000000000000000000000000000000000000..9fb18f784ee1669ae34739802823cba34e1ca415 --- /dev/null +++ b/app/src/main/res/layout/journey.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +SPDX-FileCopyrightText: Adam Evyčędo + +SPDX-License-Identifier: GPL-3.0-or-later +--> +<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + xmlns:tool="http://schemas.android.com/tools"> + <androidx.constraintlayout.widget.ConstraintLayout + android:padding="16dp" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/start_time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tool:text="11:25" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/lines" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:textAlignment="center" + android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" + app:layout_constraintEnd_toStartOf="@+id/end_time" + app:layout_constraintStart_toEndOf="@+id/start_time" + app:layout_constraintTop_toTopOf="@+id/start_time" + tool:text="Metropolitan, Circle, Hammersmith&City" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/end_time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="@+id/lines" + tool:text="12:30" /> + + <LinearLayout + android:id="@+id/legs" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_margin="8dp" + android:orientation="vertical" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/lines"> + + <include layout="@layout/journey_leg" /> + + <include layout="@layout/journey_leg" /> + </LinearLayout> + + + </androidx.constraintlayout.widget.ConstraintLayout> + +</com.google.android.material.card.MaterialCardView> \ No newline at end of file diff --git a/app/src/main/res/layout/journey_leg.xml b/app/src/main/res/layout/journey_leg.xml new file mode 100644 index 0000000000000000000000000000000000000000..89ffadb2313f07ab20c16ada3af965c236ffdeee --- /dev/null +++ b/app/src/main/res/layout/journey_leg.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:padding="8dp" + xmlns:tool="http://schemas.android.com/tools"> + <ImageView + android:id="@+id/leg_origin_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/arrow" + android:contentDescription="beginning of journey's leg" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_origin" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + app:layout_constraintBottom_toBottomOf="@+id/leg_origin_image" + app:layout_constraintStart_toEndOf="@+id/leg_origin_image" + app:layout_constraintTop_toTopOf="@+id/leg_origin_image" + tool:text="Polna" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_origin_time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + app:layout_constraintBottom_toBottomOf="@+id/leg_origin" + app:layout_constraintStart_toEndOf="@+id/leg_origin" + app:layout_constraintTop_toTopOf="@+id/leg_origin" + tool:text="11:25" /> + + <ImageView + android:id="@+id/leg_mode_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:src="@drawable/bike" + android:contentDescription="mode of journey's leg: walk" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/leg_origin_image" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_line" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + app:layout_constraintBottom_toBottomOf="@+id/leg_mode_image" + app:layout_constraintStart_toEndOf="@+id/leg_mode_image" + app:layout_constraintTop_toTopOf="@+id/leg_mode_image" + tool:text="610" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_distance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:textAppearance="@style/TextAppearance.Material3.LabelSmall" + app:layout_constraintBottom_toBottomOf="@+id/leg_line" + app:layout_constraintStart_toEndOf="@+id/leg_line" + app:layout_constraintTop_toTopOf="@+id/leg_line" + tool:text="12 stops" /> + + <ImageView + android:id="@+id/leg_destination_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:src="@drawable/arrow" + android:contentDescription="end of journey's leg" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/leg_mode_image" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_destination" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + app:layout_constraintBottom_toBottomOf="@+id/leg_destination_image" + app:layout_constraintStart_toEndOf="@+id/leg_destination_image" + app:layout_constraintTop_toTopOf="@+id/leg_destination_image" + tool:text="Dębiec" /> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/leg_destination_time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + app:layout_constraintBottom_toBottomOf="@+id/leg_destination" + app:layout_constraintStart_toEndOf="@+id/leg_destination" + app:layout_constraintTop_toTopOf="@+id/leg_destination" + tool:text="11:30" /> + +</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file