diff --git a/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidgetService.kt b/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidgetService.kt index c48ad1fc..57470d96 100644 --- a/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidgetService.kt +++ b/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidgetService.kt @@ -32,7 +32,8 @@ class CalendarWidgetService : RemoteViewsService() { val widgetData = HomeWidgetPlugin.getData(applicationContext) val data = widgetData.getString("calendar", null) if (data != null) { - calendarEvents = Json.decodeFromString>(data).asList() + val json = Json { ignoreUnknownKeys = true } + calendarEvents = json.decodeFromString>(data).asList() } calendarEvents.filter { widgetCalendarItem -> @@ -114,7 +115,11 @@ class CalendarWidgetService : RemoteViewsService() { remoteViews.setTextViewText(R.id.calendar_widget_event_time, eventTime) // Setup event location - remoteViews.setTextViewText(R.id.calendar_widget_event_location, currentItem.location) + if (currentItem.location?.isNotEmpty() == true) { + val locationText = currentItem.location.firstOrNull() + ?: applicationContext.getString(R.string.unknown) + remoteViews.setTextViewText(R.id.calendar_widget_event_location, locationText) + } // Setup action to open calendar val fillInIntent = Intent().apply { diff --git a/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/WidgetCalendarItem.kt b/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/WidgetCalendarItem.kt index 853768fe..9002ddb8 100644 --- a/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/WidgetCalendarItem.kt +++ b/android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/WidgetCalendarItem.kt @@ -23,7 +23,7 @@ data class WidgetCalendarItem( @Serializable(with = DateTimeSerializer::class) @SerialName("dtend") val endDate: LocalDateTime, - val location: String? = null, + val location: List? = null, val color: Long? = null, val isVisible: Boolean? = null, var isFirstOnDay: Boolean = false diff --git a/android/app/src/main/res/values-de/strings.xml b/android/app/src/main/res/values-de/strings.xml index 57d74f70..1b6b0f99 100644 --- a/android/app/src/main/res/values-de/strings.xml +++ b/android/app/src/main/res/values-de/strings.xml @@ -11,6 +11,7 @@ Minuten Gerade eben Gestern + Unbekannt Vor %d Jahr Vor %d Jahren diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index ce4c3a9c..d6ff8930 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -12,6 +12,7 @@ moments ago Yesterday %1$s–%2$s + Unknown %d year ago %d years ago diff --git a/android/settings.gradle b/android/settings.gradle index e1006e6c..69a41be9 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version '8.7.2' apply false + id "com.android.application" version '8.7.3' apply false id "org.jetbrains.kotlin.android" version "1.9.20" apply false id "org.jetbrains.kotlin.plugin.serialization" version "2.0.21" apply false id "com.google.gms.google-services" version "4.4.2" apply false diff --git a/ios/CalendarWidget/CalendarEntry.swift b/ios/CalendarWidget/CalendarEntry.swift index f266c91f..bb3d6973 100644 --- a/ios/CalendarWidget/CalendarEntry.swift +++ b/ios/CalendarWidget/CalendarEntry.swift @@ -14,7 +14,7 @@ struct CalendarEntry: Codable, Identifiable { let status: String let startDate: Date let endDate: Date - let location: String? + let location: [String] let color: Int? enum CodingKeys: String, CodingKey { diff --git a/ios/CalendarWidget/CalendarEventView.swift b/ios/CalendarWidget/CalendarEventView.swift index 7b86ded6..90b081ac 100644 --- a/ios/CalendarWidget/CalendarEventView.swift +++ b/ios/CalendarWidget/CalendarEventView.swift @@ -51,15 +51,16 @@ struct CalendarEventView: View { let timeText = "\(timeFormatter.string(from: event.startDate)) - \(timeFormatter.string(from: event.endDate))" - if (event.location != nil) { - Text("\(timeText) | \(event.location!)") - .font(.caption2) - .lineLimit(1) - } else { - Text(timeText) - .font(.caption2) - .lineLimit(1) + Group { + if (event.location.isEmpty == false) { + let locationText = event.location.first ?? String(localized: "Unknown") + Text("\(timeText) | \(locationText)") + } else { + Text(timeText) + } } + .font(.caption2) + .lineLimit(1) } .padding(6) .widgetAccentable(false) diff --git a/ios/CalendarWidget/CalendarWidget.swift b/ios/CalendarWidget/CalendarWidget.swift index cb4349c9..da6c86e2 100644 --- a/ios/CalendarWidget/CalendarWidget.swift +++ b/ios/CalendarWidget/CalendarWidget.swift @@ -13,8 +13,8 @@ struct Provider: TimelineProvider { CalendarWidgetEntry( date: Date(), entries: [ - CalendarEntry(id: "0", title: "Lineare Algebra für Informatik", status: "Test", startDate: Date.now, endDate: Date.now, location: "Galileo Audimax", color: nil), - CalendarEntry(id: "0", title: "Einführung in die Buchführung", status: "Test", startDate: Date.now, endDate: Date.now, location: "Audimax", color: nil) + CalendarEntry(id: "0", title: "Lineare Algebra für Informatik", status: "Test", startDate: Date.now, endDate: Date.now, location: ["Galileo Audimax"], color: nil), + CalendarEntry(id: "0", title: "Einführung in die Buchführung", status: "Test", startDate: Date.now, endDate: Date.now, location: ["Audimax"], color: nil) ], size: context.family ) diff --git a/ios/Runner/Localizable.xcstrings b/ios/Runner/Localizable.xcstrings index 67bd4912..ca22f8e5 100644 --- a/ios/Runner/Localizable.xcstrings +++ b/ios/Runner/Localizable.xcstrings @@ -100,6 +100,16 @@ } } } + }, + "Unknown" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Unbekannt" + } + } + } } }, "version" : "1.0" diff --git a/lib/base/util/read_list_value.dart b/lib/base/util/read_list_value.dart index b132961d..602532f9 100644 --- a/lib/base/util/read_list_value.dart +++ b/lib/base/util/read_list_value.dart @@ -2,7 +2,7 @@ List readListValue(Map data, String key) { final relevantData = data[key]; if (relevantData is List) { return relevantData; - } else if (relevantData is Map) { + } else if (relevantData is Map || relevantData is String) { return [relevantData]; } else { return []; diff --git a/lib/calendarComponent/model/calendar_event.dart b/lib/calendarComponent/model/calendar_event.dart index d77b55c6..67e23cb8 100644 --- a/lib/calendarComponent/model/calendar_event.dart +++ b/lib/calendarComponent/model/calendar_event.dart @@ -20,7 +20,7 @@ class CalendarEvent extends Searchable { final DateTime startDate; @JsonKey(name: "dtend") final DateTime endDate; - @JsonKey(readValue: readListValue) + @JsonKey(name: "location", readValue: readListValue) final List locations; int? color; diff --git a/lib/calendarComponent/model/calendar_event.g.dart b/lib/calendarComponent/model/calendar_event.g.dart index b0eef3f4..0b4e3156 100644 --- a/lib/calendarComponent/model/calendar_event.g.dart +++ b/lib/calendarComponent/model/calendar_event.g.dart @@ -15,7 +15,7 @@ CalendarEvent _$CalendarEventFromJson(Map json) => description: json['description'] as String?, startDate: DateTime.parse(json['dtstart'] as String), endDate: DateTime.parse(json['dtend'] as String), - locations: (readListValue(json, 'locations') as List) + locations: (readListValue(json, 'location') as List) .map((e) => e as String) .toList(), color: (json['color'] as num?)?.toInt(), @@ -30,7 +30,7 @@ Map _$CalendarEventToJson(CalendarEvent instance) => 'description': instance.description, 'dtstart': instance.startDate.toIso8601String(), 'dtend': instance.endDate.toIso8601String(), - 'locations': instance.locations, + 'location': instance.locations, 'color': instance.color, 'isVisible': instance.isVisible, }; diff --git a/pubspec.lock b/pubspec.lock index 53e0578f..d14e31cc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -817,10 +817,10 @@ packages: dependency: transitive description: name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" js: dependency: transitive description: @@ -1185,10 +1185,10 @@ packages: dependency: transitive description: name: quick_actions_ios - sha256: "402596dea62a1028960b93f7651ec22be0e2a91e4fbf92a1c62d3b95f8ff95a5" + sha256: "837b7e6b5973784d3da56b8c959b446b215914f20405d88cd7d22a2fb94e4e4c" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" quick_actions_platform_interface: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7df3f42a..d66f8faf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: campus_flutter description: "TUM Campus App" publish_to: 'none' -version: 5.1.2+1 +version: 5.1.3+1 environment: sdk: '>=3.2.3 <4.0.0'