Page MenuHomeGitPull.it

D257.1790003919.diff
No OneTemporary

Authored By
Unknown
Size
20 KB
Referenced Files
None
Subscribers
None

D257.1790003919.diff

diff --git a/app/src/main/java/it/reyboz/bustorino/backend/gtfs/LivePositionUpdate.kt b/app/src/main/java/it/reyboz/bustorino/backend/gtfs/LivePositionUpdate.kt
--- a/app/src/main/java/it/reyboz/bustorino/backend/gtfs/LivePositionUpdate.kt
+++ b/app/src/main/java/it/reyboz/bustorino/backend/gtfs/LivePositionUpdate.kt
@@ -61,6 +61,11 @@
fun getLineGTFSFormat(): String{
return "gtt:$routeID"
}
+
+ fun hasTripId(): Boolean{
+ val r = tripID.isEmpty() || tripID == "null"
+ return !r
+ }
}
diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
--- a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
+++ b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
@@ -57,6 +57,7 @@
import it.reyboz.bustorino.backend.LivePositionTripPattern
import it.reyboz.bustorino.backend.LivePositionsServiceStatus
import it.reyboz.bustorino.backend.Stop
+import it.reyboz.bustorino.backend.VehicleClassInfo
import it.reyboz.bustorino.backend.VehicleUtils
import it.reyboz.bustorino.backend.gtfs.GtfsUtils
import it.reyboz.bustorino.backend.gtfs.LivePositionUpdate
@@ -178,6 +179,8 @@
protected lateinit var locationComponent: LocationComponent
protected lateinit var busPositionsIconButton: ImageButton
protected lateinit var vehicleIcon: ImageView
+ protected lateinit var warningTripIcon: ImageView
+ private lateinit var loadingTripIcon: ImageView
protected var lastLocation : Location? = null
@@ -273,11 +276,18 @@
arrivalsCard = view.findViewById(R.id.arrivalsCardButton)
directionsCard = view.findViewById(R.id.directionsCardButton)
vehicleIcon = view.findViewById(R.id.vehicleIcon)
+ loadingTripIcon = view.findViewById(R.id.downloadingIcon)
+ warningTripIcon = view.findViewById(R.id.warningIconTrip)
linesBottomTextView = view.findViewById(R.id.linesBottomTextView)
linesBottomTextView.text = getString(R.string.lines_fill, "")
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
+ //set onclick listener for warning trip icon
+ warningTripIcon.setOnClickListener {
+ showToastMessage(R.string.no_trip_info_warning, true)
+ }
+ loadingTripIcon.setOnClickListener { showToastMessage(R.string.downloading_trip_info, true) }
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -523,6 +533,11 @@
locationEngine?.removeLocationUpdates(mapLibreLocationCallback)
}
+ protected fun showVehClassInfo(vehInfo: VehicleClassInfo){
+ val print = "${vehInfo.type.getName()}: ${vehInfo.name}"
+ makeToast(print)
+ }
+
/**
* Update function for the bus positions
@@ -538,6 +553,7 @@
hasVehicleTracking: Boolean = true,
trackVehicleCallback: ((String) -> Unit)? = null
) {
+ //TODO: Eventually change this (incomingData should be keyed by vehicle)
val vehsNew = HashSet(incomingData.values.map { up -> up.first.vehicle })
val vehsOld = HashSet(updatesByVehDict.keys)
@@ -670,13 +686,17 @@
GtfsUtils.getLineNameFromGtfsID(data.posUpdate.routeID), false
)
val pat = data.pattern
+ val update = data.posUpdate
+
if (pat != null) {
stopTitleTextView.text = pat.headsign
stopTitleTextView.visibility = View.VISIBLE
stopNumberTextView.text = getString(R.string.line_fill_towards, lineName)
+ loadingTripIcon.visibility = View.GONE
} else {
stopTitleTextView.visibility = View.GONE
stopNumberTextView.text = getString(R.string.line_fill, lineName)
+ loadingTripIcon.visibility = if (update.hasTripId()) View.VISIBLE else View.GONE
}
directionsCard.setOnClickListener {
onDirectionsClick(pat?.code ?: "", veh)
@@ -695,10 +715,10 @@
extraBottomTextView.text = getString(R.string.updated_fill, utils.unixTimestampToLocalTime(data.posUpdate.timestamp))
extraBottomTextView.visibility = View.VISIBLE
- val update = data.posUpdate
val vehInfo = VehicleUtils.getTypeForLabel(update.vehicle)
if(vehInfo == null){
vehicleIcon.visibility = View.GONE
+ linesPassingTextView.setOnClickListener { } //empty click listener
} else{
val ico = when(vehInfo.type){
VehicleUtils.VehicleType.BUS -> R.drawable.ic_bus
@@ -709,9 +729,14 @@
vehicleIcon.visibility = View.VISIBLE
vehicleIcon.setOnClickListener {
- val print = "${vehInfo.type.getName()}: ${vehInfo.name}"
- makeToast(print)
+ showVehClassInfo(vehInfo)
}
+ linesPassingTextView.setOnClickListener { showVehClassInfo(vehInfo) }
+ }
+ if (!update.hasTripId()){
+ warningTripIcon.visibility = View.VISIBLE
+ } else{
+ warningTripIcon.visibility = View.GONE
}
}
@@ -866,6 +891,8 @@
else stop.routesThatStopHereToString() //requireContext().getString(R.string.lines_fill, stop.routesThatStopHereToString())
linesPassingTextView.text = string_show
linesPassingTextView.visibility = View.VISIBLE
+ linesPassingTextView.setOnClickListener { } //empty click listener (needed when switching from vehicle)
+
linesPassingTextView.gravity = Gravity.TOP
linesBottomTextView.visibility =View.VISIBLE
@@ -880,14 +907,17 @@
directionsCard.setOnClickListener {
ViewUtils.openStopInOutsideApp(stop, context)
}
+
context?.let {
val colorIcon = ViewUtils.getColorFromTheme(it, R.attr.colorAccent)//ResourcesCompat.getColor(resources,R.attr.colorAccent,activity?.theme)
ViewCompat.setBackgroundTintList(directionsCard, ColorStateList.valueOf(colorIcon))
}
bottomrightImage.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.navigation_right, activity?.theme))
-
+ // icons for the vehicles
vehicleIcon.visibility = View.GONE
+ warningTripIcon.visibility = View.GONE
+ loadingTripIcon.visibility = View.GONE
}
//add stop marker
diff --git a/app/src/main/java/it/reyboz/bustorino/viewmodels/LivePositionsViewModel.kt b/app/src/main/java/it/reyboz/bustorino/viewmodels/LivePositionsViewModel.kt
--- a/app/src/main/java/it/reyboz/bustorino/viewmodels/LivePositionsViewModel.kt
+++ b/app/src/main/java/it/reyboz/bustorino/viewmodels/LivePositionsViewModel.kt
@@ -207,15 +207,22 @@
* This livedata object contains the final updates with patterns present in the DB
*/
val updatesWithTripAndPatterns = gtfsTripsPatternsInDB.map { tripPatterns->
- //TODO: Change the mapping in the final updates, I don't know why the key is the tripID and not the vehicle ID
- Log.i(DEBUG_TI, "Mapping trips and patterns")
- val mdict = HashMap<String,FullPositionUpdate>()
+ //Integrate trips and patterns
+ //Log.i(DEBUG_TI, "Mapping trips and patterns")
+ //val mdict = HashMap<String,FullPositionUpdate>()
+ val upsByVeh = HashMap<String, FullPositionUpdate>()
//missing patterns
val routesToDownload = HashSet<String>()
if(positionsToBeMatchedLiveData.value!=null)
for(update in positionsToBeMatchedLiveData.value!!){
+ if(!update.hasTripId()){
+ //when there is no trip information
+ upsByVeh[update.vehicle] = Pair(update, null)
+ continue
+ }
- val trID:String = update.tripID
+ val trID = update.tripID
+ val veh = update.vehicle
var found = false
for(trip in tripPatterns){
if (trip.pattern == null){
@@ -226,14 +233,14 @@
if (trip.trip.tripID == "gtt:$trID"){
found = true
//insert directly
- mdict[trID] = Pair(update,trip)
+ upsByVeh[veh] = Pair(update,trip)
break
}
}
if (!found){
//Log.d(DEBUG_TI, "Cannot find pattern ${tr}")
//give the update anyway
- mdict[trID] = Pair(update,null)
+ upsByVeh[veh] = Pair(update,null)
}
}
//have to request download of missing Patterns
@@ -243,7 +250,7 @@
MatoPatternsDownloadWorker.downloadPatternsForRoutes(routesToDownload.toList(), getApplication())
}
- return@map mdict
+ return@map upsByVeh
}
fun clearOldPositionsUpdates(){
@@ -297,14 +304,14 @@
Pair<HashMap<String,FullPositionUpdate>, List<String>>{
val gtfsLineId = linePatt.first
val pattern = linePatt.second
- val updsForTripId = HashMap<String, Pair<LivePositionUpdate, TripAndPatternWithStops?>>()
+ val updsByVeh = HashMap<String, Pair<LivePositionUpdate, TripAndPatternWithStops?>>()
val vehicleOnWrongDirection = mutableListOf<String>()
//supporting the eventual null case when there is no need to filter
if (gtfsLineId == "ALL"){
//copy the dict
- for ((tripId, pair) in updates.entries) {
- updsForTripId[tripId] = pair
+ for ((vehicle, pair) in updates.entries) {
+ updsByVeh[vehicle] = pair
}
} else {
@@ -318,11 +325,11 @@
)
// cannot understand where this is used
//val patternsDirections = HashMap<String,Int>()
- for ((tripId, pair) in updates.entries) {
+ for ((veh, pair) in updates.entries) {
//remove trips with wrong line
val posUp = pair.first
val vehicle = pair.first.vehicle
- if (pair.first.routeID != filtdLineID)
+ if (posUp.routeID != filtdLineID)
continue
if (directionId != -100 && pair.second != null && pair.second?.pattern != null) {
@@ -330,22 +337,22 @@
if (dir == directionId) {
//add the trip
- updsForTripId[tripId] = pair
+ updsByVeh[veh] = pair
//Log.d(DEBUG_TI, "Add vehicle ${pair.first.vehicle}, route ${pair.first.routeID}")
} else {
vehicleOnWrongDirection.add(vehicle)
}
- //patternsDirections[tripId] = dir ?: -10
+ //patternsDirections[veh] = dir ?: -10
} else {
- updsForTripId[tripId] = pair
- //Log.d(DEBUG_TAG, "No pattern for tripID: $tripId")
- //patternsDirections[tripId] = -10
+ updsByVeh[veh] = pair
+ //Log.d(DEBUG_TAG, "No pattern for tripID: $veh")
+ //patternsDirections[veh] = -10
}
}
}
- Log.d(DEBUG_TI, "Filtered updates are ${updsForTripId.keys.size}") // Original updates directs: $patternsDirections\n
+ Log.d(DEBUG_TI, "Filtered updates are ${updsByVeh.keys.size}") // Original updates directs: $patternsDirections\n
- return Pair(updsForTripId, vehicleOnWrongDirection)
+ return Pair(updsByVeh, vehicleOnWrongDirection)
}
diff --git a/app/src/main/res/drawable/ic_round_downloading.xml b/app/src/main/res/drawable/ic_round_downloading.xml
new file mode 100644
--- /dev/null
+++ b/app/src/main/res/drawable/ic_round_downloading.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="32dp"
+ android:height="32dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M17.33,3.55c-0.94,-0.6 -1.99,-1.04 -3.12,-1.3a0.998,0.998 0,0 0,-1.21 0.98c0,0.45 0.3,0.87 0.74,0.97c0.91,0.2 1.77,0.56 2.53,1.05c0.39,0.25 0.89,0.17 1.22,-0.16c0.45,-0.45 0.38,-1.2 -0.16,-1.54M20.77,11c0.64,0 1.13,-0.59 0.98,-1.21c-0.26,-1.12 -0.7,-2.17 -1.3,-3.12c-0.34,-0.54 -1.1,-0.61 -1.55,-0.16c-0.32,0.32 -0.4,0.83 -0.16,1.22c0.49,0.77 0.85,1.62 1.05,2.53a1,1 0,0 0,0.98 0.74m-1.87,6.49c0.45,0.45 1.21,0.38 1.55,-0.15c0.6,-0.94 1.04,-1.99 1.3,-3.11c0.14,-0.62 -0.35,-1.21 -0.98,-1.21c-0.45,0 -0.87,0.3 -0.97,0.74c-0.2,0.91 -0.57,1.76 -1.05,2.53c-0.25,0.37 -0.17,0.88 0.15,1.2M13,20.77c0,0.64 0.59,1.13 1.21,0.98c1.12,-0.26 2.17,-0.7 3.11,-1.3c0.54,-0.34 0.61,-1.1 0.16,-1.55c-0.32,-0.32 -0.83,-0.4 -1.21,-0.15c-0.76,0.49 -1.61,0.85 -2.53,1.05c-0.44,0.1 -0.74,0.51 -0.74,0.97M13,12L13,8c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1v4L9.41,12c-0.89,0 -1.34,1.08 -0.71,1.71l2.59,2.59c0.39,0.39 1.02,0.39 1.41,0l2.59,-2.59c0.63,-0.63 0.18,-1.71 -0.71,-1.71zM11,20.77c0,0.64 -0.59,1.13 -1.21,0.99C5.33,20.75 2,16.77 2,12s3.33,-8.75 7.79,-9.75a0.998,0.998 0,0 1,1.21 0.98c0,0.46 -0.31,0.87 -0.76,0.97C6.67,5 4,8.19 4,12s2.67,7 6.24,7.8c0.45,0.1 0.76,0.51 0.76,0.97"
+ android:fillColor="#000"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_round_warning_larger.xml b/app/src/main/res/drawable/ic_round_warning_larger.xml
new file mode 100644
--- /dev/null
+++ b/app/src/main/res/drawable/ic_round_warning_larger.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="32dp"
+ android:height="32dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M3.777,21.287H20.223c1.682,0 2.73,-1.824 1.889,-3.276l-8.223,-14.208c-0.841,-1.452 -2.938,-1.452 -3.779,0L1.887,18.011c-0.841,1.452 0.207,3.276 1.889,3.276M12,13.642c-0.601,0 -1.092,-0.491 -1.092,-1.092v-2.184c0,-0.601 0.491,-1.092 1.092,-1.092 0.601,0 1.092,0.491 1.092,1.092v2.184c0,0.601 -0.491,1.092 -1.092,1.092m1.092,4.368h-2.184v-2.184h2.184z"
+ android:strokeWidth="1.09208"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/app/src/main/res/layout/include_map_bottom_sheet.xml b/app/src/main/res/layout/include_map_bottom_sheet.xml
--- a/app/src/main/res/layout/include_map_bottom_sheet.xml
+++ b/app/src/main/res/layout/include_map_bottom_sheet.xml
@@ -60,9 +60,8 @@
android:layout_marginTop="5dp"
app:layout_constraintTop_toBottomOf="@id/stopTitleTextView"
android:id="@+id/bottomLinearLayout"
- app:layout_constraintEnd_toStartOf="@id/arrivalsCardButton"
+ app:layout_constraintEnd_toStartOf="@id/arrivalsCardButton"
android:layout_marginEnd="10dp"
-
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -71,30 +70,45 @@
android:id="@+id/linesBottomTextView"
android:fontFamily="@font/lato_regular"
android:textSize="15sp"
+ android:gravity="center_vertical"
/>
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:minHeight="24dp"
+ android:minHeight="26dp"
android:textSize="15sp"
android:text="32119"
- android:gravity="top"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
+ android:gravity="center_vertical"
android:fontFamily="@font/lato_regular"
/>
<ImageView
android:layout_width="33dp"
- android:layout_height="24dp"
+ android:layout_height="26dp"
android:id="@+id/vehicleIcon"
- android:layout_marginStart="1dp"
+ android:layout_marginStart="2dp"
android:src="@drawable/ic_bus_electric_filled"
app:tint="@color/blue_700"
/>
- </LinearLayout>
+ <ImageView android:layout_width="30dp"
+ android:layout_height="26dp"
+ android:id="@+id/downloadingIcon"
+ android:src="@drawable/ic_round_downloading"
+ app:tint="?colorPrimary"
+ android:layout_marginStart="2dp"
+ android:visibility="gone"
+ />
+ <ImageView android:layout_width="30dp"
+ android:layout_height="26dp"
+ android:id="@+id/warningIconTrip"
+ android:src="@drawable/ic_round_warning_larger"
+ app:tint="@color/yellow_warning"
+ android:layout_marginStart="2dp"
+ android:visibility="gone"
+ />
+ </LinearLayout>
<TextView
@@ -112,6 +126,32 @@
android:fontFamily="@font/lato_regular"
android:visibility="gone"
/>
+ <!--
+ <LinearLayout android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/warningLayout"
+ android:layout_marginStart="10dp"
+ android:layout_marginTop="5dp"
+ app:layout_constraintTop_toBottomOf="@id/extraBottomTextView"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="@id/btnClose"
+ >
+
+ <TextView
+ android:id="@+id/warningMessageTextView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minHeight="40dp"
+ android:textSize="15sp"
+ android:text="@string/no_trip_info_warning"
+ android:gravity="center_vertical"
+ android:layout_marginEnd="10dp"
+ android:layout_marginStart="5dp"
+ android:fontFamily="@font/lato_regular"
+ />
+
+ </LinearLayout>
+ -->
<androidx.cardview.widget.CardView
android:id="@+id/arrivalsCardButton"
android:layout_width="50sp"
@@ -193,4 +233,5 @@
app:layout_constraintBottom_toBottomOf="parent"
/>
+
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -266,4 +266,7 @@
<string name="day_night_theme_keep_system">Segui il sistema</string>
<string name="pref_theme_day_night_title">Imposta tema scuro o chiaro</string>
+
+ <string name="no_trip_info_warning">Nessuna informazione trasmessa sulla direzione o sul viaggio del veicolo.</string>
+ <string name="downloading_trip_info">Download in corso delle informazioni sul viaggio</string>
</resources>
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -99,4 +99,5 @@
<color name="lines_nearby_color">@color/blue_700</color>
<color name="stop_number_color">@color/light_blue_900</color>
+ <color name="yellow_warning">#fbb504</color>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -417,4 +417,6 @@
<string name="back_again_to_close">Press back again to close the app</string>
<string name="action_donate">Donate</string>
+ <string name="no_trip_info_warning">No information on the direction or trip of the vehicle was transmitted.</string>
+ <string name="downloading_trip_info">Downloading trip information…</string>
</resources>

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 21, 17:18 (23 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2169442
Default Alt Text
D257.1790003919.diff (20 KB)

Event Timeline