Conversation
It offers a cleaner API and is much faster than SimpleXML.
Reasons: 1. Cleaner API 2. Much faster 3. SimpleXML is no longer being developed
…o th/migrate-tumonlinerequest-to-retrofit
@thellmund still WIP or Ready to review? |
@kordianbruck Basically done, but I want to do some more testing before submitting it for review. Will likely do that tomorrow. |
…o th/migrate-tumonlinerequest-to-retrofit
…hub.com/TCA-Team/TumCampusApp into th/migrate-tumonlinerequest-to-retrofit
@kordianbruck Ready for review |
@@ -80,7 +80,7 @@ public static OkHttpClient getOkHttpClient(Context c) { | |||
builder.connectTimeout(Helper.HTTP_TIMEOUT, TimeUnit.MILLISECONDS); | |||
builder.readTimeout(Helper.HTTP_TIMEOUT, TimeUnit.MILLISECONDS); | |||
|
|||
builder.addNetworkInterceptor(new TumHttpLoggingInterceptor(message -> Utils.logwithTag(TAG, message))); | |||
//builder.addNetworkInterceptor(new TumHttpLoggingInterceptor(message -> Utils.logwithTag(TAG, message))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented this for testing. Will re-enable.
*/ | ||
public boolean hasValidAccessToken() { | ||
public static boolean hasValidAccessToken(Context context) { | ||
final String oldAccessToken = Utils.getSetting(context, Const.ACCESS_TOKEN, ""); | ||
return oldAccessToken != null && oldAccessToken.length() > 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only remaining method in AccessTokenManager
?
Probably completely remove the class in favor of Utils or something
|
||
class TUMOnlineClient(private val apiService: TUMOnlineAPIService) { | ||
|
||
fun getCalendar(force: Boolean = false): Call<Events> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like boolean parameters.
From looking at a function call, one can't tell WTH this means.
getCalendar(true);
Without looking at the function definition, that parameter could be anything.
Please consider a proper Enum as parameter, which might even directly reference the underlying String.
getCalendar(CacheControl.doNotCache)
Is much nicer to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android Studio displays the parameter name, but I agree with your feedback. Will adapt this accordingly.
|
||
companion object { | ||
|
||
private val cachingDurations = mapOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we're not actually using the Map capabilities of that map, because we always linearly search the map, please use a List of tuples instead of a Map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
TokenLimitReachedException::class, | ||
InvalidTokenException::class, | ||
MissingPermissionException::class, | ||
UnknownErrorException::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If only there was a common exception type to be declared 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
holder.tvTypeSWSSemester.setText(String.format("%s - %s - %s SWS", lvItem.getStp_lv_art_name(), lvItem.getSemester_id(), lvItem.getDauer_info())); | ||
holder.tvDozent.setText(lvItem.getVortragende_mitwirkende()); | ||
holder.tvLectureName.setText(lvItem.getTitle()); | ||
holder.tvTypeSWSSemester.setText(String.format("%s - %s - %s SWS", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@PropertyElement(name = "sj_name") val semesterYears: String, | ||
@PropertyElement(name = "stp_lv_art_kurz") val shortLectureType: String, | ||
@PropertyElement(name = "stp_lv_art_name") val lectureType: String, | ||
@PropertyElement(name = "stp_lv_nr") val stp_lv_nr: String, // TODO: Rename valiables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still want to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least fix the typo in the TODO 🙈
@PropertyElement(name = "sj_name") val semesterYears: String? = null, | ||
@PropertyElement(name = "stp_lv_art_kurz") val shortLectureType: String? = null, | ||
@PropertyElement(name = "stp_lv_art_name") val lectureType: String? = null, | ||
@PropertyElement(name = "stp_lv_nr") val stp_lv_nr: String, // TODO: Rename variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover TODO
@Xml(name = "row") | ||
data class LectureDetails( | ||
@PropertyElement(name = "dauer_info") val duration: String? = null, | ||
@PropertyElement(name = "ersttermin") val firstAppointment: String? = null, // TODO: TypeConverters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further inspection, I saw that the value can also be “geplant” (“planned”). For that reason, I’ll remove the to-do.
|
||
return infoText + name + ' ' + surname | ||
return arrayOf(title, name, surname) | ||
.filterNotNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't you missing empty strings for titles then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further inspection, I don’t believe that the string representation of Employee
is used anywhere (we use getNameWithTitle(Context)
). I’ve removed it now.
Grades are sorted by date, with the newest grade at the top.
@@ -92,7 +83,7 @@ | |||
<string name="licences_summary">Rechtliche Hinweise zu Lizenzen</string> | |||
|
|||
<!-- Startup Wizard --> | |||
<string name="token_not_enabled">Nicht angemeldet</string> | |||
<string name="not_connected_to_tumonline">Nicht angemeldet</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a proper translation of "Not connected"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think “angemeldet” fits better than “verbunden”, but since we seem to use the latter throughout the app, I’ve changed this translation.
compareTo(other) | ||
} else { | ||
-1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is quite literally compareValues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only learned about compareValues()
through your comment today – thanks btw, @pfent 😊
Given that I stopped using this extension with the last commit, I’ll remove the entire file.
private fun syncPersonalLectures() { | ||
TUMOnlineClient | ||
.getInstance(context) | ||
.getPersonalLectures(CacheControl.NO_CACHE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It his correct?
We call this in fillCache()
, but then set NO_CACHE
?
Ok, I still think this is confusing...
This should probably be called BYPASS_CACHE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the naming accordingly and changed the method to CacheControl.USE_CACHE
, because we only want to refresh the content in the background if it’s past its max-age
(same behavior as before the refactoring).
…o th/migrate-tumonlinerequest-to-retrofit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let the merge conflicts begin!
This is work in progress
This pull request replaces
TUMOnlineRequest
withTUMOnlineClient
, which uses Retrofit. The steps we took:TUMOnlineClient
andTUMOnlineAPIService
for API access.TUMOnlineInterceptor
to intercept requests, append the token parameter and throw exceptions in case of errors. This is necessary because TUMonline always returns 200, even in case of errors.TumLock
and its associated DAO.Building on these changes, we should do these things next:
Issues: #544 #674 #388