This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic search * add rooms & lectures * design + fix search aggregation * add result types * improve user experience * add search history * adjustments + refactor * remove legacy searches * fix ktlint issues * - migrate to NavigaTum - new navigation details screen - integrate NavigaTumApi to centralized search * moved from roomfinder to navigatum * - fix map rendering - move to new navigation details view * new navigation UI * add room_code parameter and move to bindings * adjustments after merge * removed unused RoomFinder logic * Update app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/api/app/TUMCabeClient.java Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/domain/NavigationMap.kt Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/component/other/general/RecentsDao.java Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/component/ui/search/SearchFragment.kt Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/component/tumui/roomfinder/NavigationDetailsFragment.kt Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/res/values-de/strings.xml Co-authored-by: Frank Elsinga <frank@elsinga.de> * Update app/src/main/java/de/tum/in/tumcampusapp/component/tumui/roomfinder/NavigationDetailsFragment.kt Co-authored-by: Frank Elsinga <frank@elsinga.de> * general fixes * fix ordering * fix lint Co-authored-by: Frank Elsinga <frank@elsinga.de>
- Loading branch information
1 parent
0f27eb7
commit e697dd7
Showing
50 changed files
with
1,202 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/NavigaTumAPIClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum | ||
|
||
import android.content.Context | ||
import de.tum.`in`.tumcampusapp.api.app.ApiHelper | ||
import de.tum.`in`.tumcampusapp.api.navigatum.domain.NavigationDetails | ||
import de.tum.`in`.tumcampusapp.api.navigatum.domain.toNavigationDetails | ||
import de.tum.`in`.tumcampusapp.api.navigatum.model.details.NavigationDetailsDto | ||
import de.tum.`in`.tumcampusapp.api.navigatum.model.search.NavigaTumSearchResponseDto | ||
import de.tum.`in`.tumcampusapp.api.tumonline.interceptors.CacheResponseInterceptor | ||
import de.tum.`in`.tumcampusapp.utils.CacheManager | ||
import io.reactivex.Single | ||
import retrofit2.Retrofit | ||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
class NavigaTumAPIClient(private val apiService: NavigaTumAPIService) { | ||
|
||
fun search(query: String): NavigaTumSearchResponseDto? { | ||
return apiService.search(query) | ||
.execute() | ||
.body() | ||
} | ||
|
||
fun getNavigationDetails(id: String): NavigationDetails? { | ||
return apiService.getNavigationDetails(id) | ||
.execute() | ||
.body() | ||
?.toNavigationDetails() | ||
} | ||
|
||
fun searchSingle(query: String): Single<NavigaTumSearchResponseDto> { | ||
return apiService.searchSingle(query) | ||
} | ||
|
||
fun getNavigationDetailsSingle(id: String): Single<NavigationDetailsDto> { | ||
return apiService.getNavigationDetailsSingle(id) | ||
} | ||
|
||
companion object { | ||
private const val BASE_URL = "https://nav.tum.sexy/" | ||
|
||
private var apiClient: NavigaTumAPIClient? = null | ||
|
||
@JvmStatic | ||
@Synchronized | ||
fun getInstance(context: Context): NavigaTumAPIClient { | ||
if (apiClient == null) { | ||
apiClient = buildAPIClient(context) | ||
} | ||
return apiClient!! | ||
} | ||
|
||
private fun buildAPIClient(context: Context): NavigaTumAPIClient { | ||
val cacheManager = CacheManager(context) | ||
|
||
val client = ApiHelper.getOkHttpClient(context) | ||
.newBuilder() | ||
.cache(cacheManager.cache) | ||
.addNetworkInterceptor(CacheResponseInterceptor()) | ||
.build() | ||
|
||
val apiService = Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.client(client) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | ||
.build() | ||
.create(NavigaTumAPIService::class.java) | ||
|
||
return NavigaTumAPIClient(apiService) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/NavigaTumAPIService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum | ||
|
||
import de.tum.`in`.tumcampusapp.api.navigatum.model.details.NavigationDetailsDto | ||
import de.tum.`in`.tumcampusapp.api.navigatum.model.search.NavigaTumSearchResponseDto | ||
import io.reactivex.Single | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface NavigaTumAPIService { | ||
|
||
@GET(API_SEARCH) | ||
fun search( | ||
@Query(QUERY_PARAM) query: String | ||
): Call<NavigaTumSearchResponseDto> | ||
|
||
@GET(API_GET) | ||
fun getNavigationDetails( | ||
@Path(ID_PARAM) id: String | ||
): Call<NavigationDetailsDto> | ||
|
||
@GET(API_SEARCH) | ||
fun searchSingle( | ||
@Query(QUERY_PARAM) query: String | ||
): Single<NavigaTumSearchResponseDto> | ||
|
||
@GET(API_GET) | ||
fun getNavigationDetailsSingle( | ||
@Path(ID_PARAM) id: String | ||
): Single<NavigationDetailsDto> | ||
|
||
companion object { | ||
private const val API_SEARCH = "api/search" | ||
private const val QUERY_PARAM = "q" | ||
private const val ID_PARAM = "id" | ||
private const val API_GET = "api/get/{$ID_PARAM}" | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/domain/NavigationDetails.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.domain | ||
|
||
import de.tum.`in`.tumcampusapp.api.navigatum.model.details.NavigationDetailsDto | ||
import de.tum.`in`.tumcampusapp.component.other.locations.model.Geo | ||
|
||
data class NavigationDetails( | ||
val id: String, | ||
val name: String, | ||
val type: String, | ||
val typeCommonName: String, | ||
val geo: Geo, | ||
val parentsList: List<String> = listOf(), | ||
val properties: List<NavigationProperty> = listOf(), | ||
val availableMaps: List<RoomfinderMap> = listOf() | ||
) { | ||
fun getFormattedParentNames(): String { | ||
return parentsList.reduce { acc, parentName -> "$acc \\ $parentName" } | ||
} | ||
} | ||
|
||
fun NavigationDetailsDto.toNavigationDetails(): NavigationDetails { | ||
|
||
return NavigationDetails( | ||
id = this.id, | ||
name = this.name, | ||
type = this.type, | ||
typeCommonName = this.typeCommonName, | ||
geo = Geo(this.cords.lat, this.cords.lon), | ||
parentsList = this.parentNames, | ||
properties = this.additionalProperties.propsList | ||
.map { it.toNavigationProperty() }, | ||
availableMaps = this.maps.roomFinder.available | ||
.map { it.toNavigationMap() } | ||
) | ||
} |
57 changes: 57 additions & 0 deletions
57
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/domain/NavigationEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.domain | ||
|
||
import com.google.gson.Gson | ||
import com.google.gson.annotations.SerializedName | ||
import de.tum.`in`.tumcampusapp.component.other.general.model.Recent | ||
import java.io.Serializable | ||
|
||
data class NavigationEntity( | ||
@SerializedName("id") | ||
var id: String = "", | ||
@SerializedName("type") | ||
var type: String = "", | ||
@SerializedName("name") | ||
var name: String = "", | ||
@SerializedName("subtext") | ||
var subtext: String = "", | ||
@SerializedName("parsed_id") | ||
var parsedId: String? = null | ||
) : Serializable { | ||
|
||
fun getFormattedName(): String { | ||
return if (parsedId == null) removeHighlight(name) | ||
else removeHighlight(parsedId!!) + " ➤ " + removeHighlight(name) | ||
} | ||
|
||
fun getFormattedSubtext(): String { | ||
return removeHighlight(subtext) | ||
} | ||
|
||
private fun removeHighlight(field: String): String { | ||
/*** | ||
* Info from NavigaTum swagger: https://editor.swagger.io/?url=https://raw.githubusercontent.com/TUM-Dev/navigatum/main/openapi.yaml | ||
* In future maybe there will be query parameter for this | ||
* "Some fields support highlighting the query terms and it uses DC3 (\x19 or \u{0019}) | ||
* and DC1 (\x17 or \u{0017}) to mark the beginning/end of a highlighted sequence" | ||
*/ | ||
return field | ||
.replace("\u0019", "") | ||
.replace("\u0017", "") | ||
.replace("\\x19", "") | ||
.replace("\\x17", "") | ||
} | ||
|
||
companion object { | ||
@JvmStatic fun toRecent(navigationEntity: NavigationEntity, type: Int): Recent { | ||
val gson = Gson() | ||
val jsonString = gson.toJson(navigationEntity) | ||
return Recent(name = jsonString, type = type) | ||
} | ||
|
||
@JvmStatic | ||
fun fromRecent(recent: Recent): NavigationEntity { | ||
val gson = Gson() | ||
return gson.fromJson(recent.name, NavigationEntity::class.java) | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/domain/NavigationProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.domain | ||
|
||
import de.tum.`in`.tumcampusapp.api.navigatum.model.details.NavigationPropertyDto | ||
|
||
data class NavigationProperty( | ||
val title: String = "", | ||
val value: String = "" | ||
) | ||
|
||
fun NavigationPropertyDto.toNavigationProperty(): NavigationProperty { | ||
return NavigationProperty( | ||
title = this.name, | ||
value = this.text | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/domain/RoomfinderMap.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.domain | ||
|
||
import de.tum.`in`.tumcampusapp.api.navigatum.model.details.RoomFinderMapDto | ||
|
||
data class RoomfinderMap( | ||
val mapId: String, | ||
val mapName: String, | ||
val mapImgUrl: String, | ||
val pointerXCord: Int, | ||
val pointerYCord: Int, | ||
val mapImgWidth: Int, | ||
val mapImgHeight: Int | ||
) | ||
|
||
fun RoomFinderMapDto.toNavigationMap(): RoomfinderMap { | ||
val basicMapUrl = "https://nav.tum.sexy/cdn/maps/roomfinder/" | ||
return RoomfinderMap( | ||
mapId = this.id, | ||
mapName = this.name, | ||
mapImgUrl = "$basicMapUrl${this.imgUrl}", | ||
pointerXCord = this.x, | ||
pointerYCord = this.y, | ||
mapImgWidth = this.width, | ||
mapImgHeight = this.height | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
...n/java/de/tum/in/tumcampusapp/api/navigatum/model/details/NavigationAdditionalPropsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NavigationAdditionalPropsDto( | ||
@SerializedName("computed") | ||
var propsList: List<NavigationPropertyDto> = listOf() | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/NavigationCordsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
data class NavigationCordsDto( | ||
var lat: Double = 0.0, | ||
var lon: Double = 0.0 | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/NavigationDetailsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NavigationDetailsDto( | ||
val id: String = "", | ||
val name: String = "", | ||
@SerializedName("parent_names") | ||
val parentNames: List<String> = listOf(), | ||
val type: String = "", | ||
@SerializedName("type_common_name") | ||
val typeCommonName: String = "", | ||
@SerializedName("props") | ||
val additionalProperties: NavigationAdditionalPropsDto = NavigationAdditionalPropsDto(), | ||
@SerializedName("coords") | ||
val cords: NavigationCordsDto = NavigationCordsDto(), | ||
val maps: NavigationMapsDto = NavigationMapsDto() | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/NavigationMapsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NavigationMapsDto( | ||
var default: String = "", | ||
@SerializedName("roomfinder") | ||
var roomFinder: RoomFinderMapsDto = RoomFinderMapsDto() | ||
) |
6 changes: 6 additions & 0 deletions
6
...src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/NavigationPropertyDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
data class NavigationPropertyDto( | ||
var name: String = "", | ||
var text: String = "" | ||
) |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/RoomFinderMapDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class RoomFinderMapDto( | ||
var id: String = "", | ||
var name: String = "", | ||
@SerializedName("file") | ||
var imgUrl: String = "", | ||
var height: Int = 0, | ||
var width: Int = 0, | ||
var x: Int = 0, | ||
var y: Int = 0, | ||
var scale: String = "" | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/de/tum/in/tumcampusapp/api/navigatum/model/details/RoomFinderMapsDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.tum.`in`.tumcampusapp.api.navigatum.model.details | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class RoomFinderMapsDto( | ||
var available: List<RoomFinderMapDto> = listOf(), | ||
@SerializedName("default") | ||
var defaultMapId: String = "" | ||
) |
Oops, something went wrong.