Merge pull request 'baptiste2' (#8) from baptiste2 into master

Reviewed-on: baptiste.bonneau/RoadTrip#8
baptiste2
Baptiste BONNEAU 2 years ago
commit 596fd974ee

@ -1,10 +1,14 @@
package uca.baptistearthur.geocaching.converters
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.room.TypeConverter
import java.util.Date
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import uca.baptistearthur.geocaching.model.Place
import uca.baptistearthur.geocaching.model.RoadTripEntity
import java.time.format.DateTimeFormatter
import java.util.*
class Converters {
@TypeConverter
@ -28,5 +32,13 @@ class Converters {
return Gson().fromJson(value, listType)
}
@TypeConverter
fun toRoadTripEntity(value: String?): RoadTripEntity {
return Gson().fromJson(value, RoadTripEntity::class.java)
}
}
fun Date.toFrenchFormat(): String {
return "${this.day}/${this.month}/${this.year} - ${this.hours}h${this.minutes}"
}

@ -17,7 +17,7 @@ class Stub {
2,
"Italie",
Date(),
listOf(Place(48.866667, 2.333333), Place(48.866667, 2.333333)).toMutableList()
listOf(Place(48.866667, 2.34533), Place(98.866667, 2.333333)).toMutableList()
),
RoadTripEntity(
3,

@ -3,6 +3,7 @@ package uca.baptistearthur.geocaching.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.Gson
import java.util.Date
@Entity(tableName = "Roadtrip")
@ -15,5 +16,6 @@ class RoadTripEntity(
fun addPlaceToRoadTripList(place: Place) = places.add(place)
fun addPlaceToRoadTripList(latitude: Double, longitude: Double) = places.add(Place(latitude, longitude))
fun toJSON(): String = Gson().toJson(this)
}

@ -11,12 +11,12 @@ import uca.baptistearthur.geocaching.model.Place
class PlacesAdapter (val places: List<Place>) : RecyclerView.Adapter<PlacesViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlacesViewHolder {
return PlacesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.cell_one_roadtrip, parent, false))
return PlacesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.cell_place, parent, false))
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: PlacesViewHolder, position: Int) {
holder.placeText.text = "> " + places[position].longitude + " - " + places[position].latitude
holder.placeText.text = "" + (position+1) + ") LAT: " + places[position].latitude + " - LONG: " + places[position].longitude
}
override fun getItemCount(): Int = places.size
}

@ -18,6 +18,7 @@ class RoadTripAdapter(val voyages: List<RoadTripEntity>, val navController: NavC
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
override fun onBindViewHolder(holder: RoadTripViewHolder, position: Int) {
holder.roadTripAccessButton.text = "> " + voyages[position].name
holder.clickedRoadTrip = voyages[position]
}
override fun getItemCount(): Int = voyages.size
}

@ -3,23 +3,33 @@ package uca.baptistearthur.geocaching.recyclerview
import android.util.Log
import android.view.View
import android.widget.Button
import androidx.core.os.bundleOf
import androidx.navigation.NavController
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import uca.baptistearthur.geocaching.R
import uca.baptistearthur.geocaching.converters.Converters
import uca.baptistearthur.geocaching.model.RoadTripEntity
class RoadTripViewHolder(val cellule: View, val navController: NavController): ViewHolder(cellule) {
var roadTripAccessButton: Button = cellule.findViewById(R.id.btnGetRoadTripsInfo)
var clickedRoadTrip: RoadTripEntity? = null
init{
roadTripAccessButton.setOnClickListener{
val roadTripName = roadTripAccessButton.text.substring(3)
Log.d("RoadTripViewHolder", "RoadTripViewHolder clicked: ${roadTripName}")
navController.navigate(R.id.action_roadTripFragment_to_roadtripDetail)
// val roadTrip: RoadTrip = Find roadtrip by name here
// FragmentService().loadFragment(DetailledRoadTripFragment(roadTrip), (cellule.context as MainWindow).supportFragmentManager)
Log.d("RoadTripViewHolder", "RoadTripViewHolder clicked: ${clickedRoadTrip?.name}")
var clickRoadTripJSON = clickedRoadTrip?.toJSON()
// navController.navigate(R.id.action_roadTripFragment_to_roadtripDetail)
val bundle = bundleOf("roadTrip" to clickRoadTripJSON)
navController.navigate(R.id.action_roadTripFragment_to_roadtripDetail, bundle)
Log.d("RoadTripViewHolder", "Data sent: ${clickedRoadTrip?.name}")
}
}
}

@ -1,57 +1,43 @@
package uca.baptistearthur.geocaching.ui.fragment
import android.content.Context
import android.content.pm.PackageManager
import android.location.LocationManager
import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import org.osmdroid.config.Configuration
import org.osmdroid.util.GeoPoint
import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.ScaleBarOverlay
import android.Manifest.permission.ACCESS_FINE_LOCATION
import android.location.Location
import android.location.LocationListener
import android.util.Log
import android.widget.ProgressBar
import androidx.activity.result.contract.ActivityResultContracts
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import org.osmdroid.bonuspack.routing.OSRMRoadManager
import org.osmdroid.bonuspack.routing.RoadManager
import org.osmdroid.config.IConfigurationProvider
import org.osmdroid.library.BuildConfig
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
import org.osmdroid.tileprovider.util.StorageUtils.getStorage
import org.osmdroid.views.overlay.compass.CompassOverlay
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay
import uca.baptistearthur.geocaching.R
import uca.baptistearthur.geocaching.converters.Converters
import uca.baptistearthur.geocaching.converters.toFrenchFormat
import uca.baptistearthur.geocaching.recyclerview.PlacesAdapter
import uca.baptistearthur.geocaching.ui.overlay.AddMarkerOverlay
import uca.baptistearthur.geocaching.ui.overlay.RecenterOverlay
import java.time.format.DateTimeFormatter
import java.util.*
class RoadtripDetail : Fragment() {
private var placesRecyclerView : RecyclerView? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Log.d("GeoMap", "MAP ON CREATE VIEW")
// Inflate the layout for this fragment
val view = inflater.inflate(R.layout.roadtrip_detail, container, false)
// val roadTrip = // récupérer le roadtrip cliqué
// placesRecyclerView = view?.findViewById(R.id.recyclerViewPlacesList)
// placesRecyclerView?.adapter = PlacesAdapter(roadTrip.places)
// placesRecyclerView?.layoutManager = LinearLayoutManager(context)
return view
}
var roadTripJSON = arguments?.getString("roadTrip")
val roadTrip = Converters().toRoadTripEntity(roadTripJSON)
placesRecyclerView = view?.findViewById(R.id.recyclerViewPlacesList)
placesRecyclerView?.adapter = PlacesAdapter(roadTrip.places)
placesRecyclerView?.layoutManager = LinearLayoutManager(context)
view?.findViewById<TextView>(R.id.roadTripDetailTitle)?.text = roadTrip.name
view?.findViewById<TextView>(R.id.roadTripDetailDate)?.text = roadTrip.date.toFrenchFormat()
return view
}
}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:gravity="bottom">
<shape>
<size android:height="1dp" />
<solid android:color="@color/black" />
</shape>
</item>
</layer-list>

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
app:defaultNavHost="true"
app:navGraph="@navigation/navgraph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_turquoise_700"
app:menu="@menu/bottom_tabs" />
</LinearLayout>

@ -6,10 +6,15 @@
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="start"
android:background="@color/white"
android:backgroundTint="@color/white"
android:drawableStart="@drawable/right_arrow"
android:drawableLeft="@drawable/right_arrow"
android:gravity="left"
android:textColor="@color/black"
android:textSize="20sp"
tools:ignore="RtlHardcoded" />
android:text="> TMP name"
tools:ignore="RtlHardcoded"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/bottom_border"
/>

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="@+id/txtPlaceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="> TMP/ Place Name"
android:textColor="@color/black"
android:padding="5dp"
android:text="1) LAT: 49.264562 - LONG: 48.5485248"
android:textSize="17sp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" />
android:textColor="@color/main_turquoise_500"
/>
<Button
android:id="@+id/btnDeletePlace"
@ -26,6 +26,4 @@
android:backgroundTint="@color/main_turquoise_200"
/>
</LinearLayout>

@ -16,7 +16,9 @@
android:textColor="@color/main_turquoise_50"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:textSize="20sp"/>
android:textSize="20sp"
android:paddingStart="10dp"
tools:ignore="RtlSymmetry" />
<TextView
android:id="@+id/roadTripDetailDate"

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}
Loading…
Cancel
Save