Skip to content

Commit 01a915e

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/koinon-thesis
2 parents 7d5fca7 + a840a54 commit 01a915e

File tree

272 files changed

+4027
-4361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

272 files changed

+4027
-4361
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
# Tum Campus App - An Unofficial Guide Through University Life
1313

14-
The TUM Campus App (TCA) is an open source project, developed by volunteers. This repository is dedicated to the development and transition to Flutter and currently in Beta. <!-- and [available on the App Store](https://itunes.apple.com/app/id1217412716), [on the Play Store]() and as a [web app](https://web.tum.app). -->
14+
The TUM Campus App (TCA) is an open source project, developed by volunteers. This repository is dedicated to the development and transition to Flutter.
1515

16-
The application mostly targets phones, but can also be used on tablets, Macs and in your browser. We currently support iOS, iPadOS, macOS and Android.
16+
The application mostly targets phones, but can also be used on tablet and Macs. We currently support iOS, iPadOS, macOS and Android.
1717

1818
## Features
1919

@@ -59,7 +59,7 @@ Please refer to the respective installation instructions:
5959
|------------------------------------------|------------------------------------------|----------------------------------------------|
6060
| `Flutter` (includes the `Dart` compiler) | SDK to develop this app | https://docs.flutter.dev/get-started/install |
6161

62-
### Updating the `.proto` files of the
62+
### Updating the `.proto` files
6363

6464
To update the generated stubs for the Campus, you need protoc installed, then activte it in dart and then you can generate the new client
6565

@@ -70,14 +70,14 @@ curl -o protos/tumdev/campus_backend.proto https://raw.githubusercontent.com/TUM
7070
protoc --dart_out=grpc:lib/base/networking/apis -I./protos google/protobuf/timestamp.proto google/protobuf/empty.proto tumdev/campus_backend.proto
7171
```
7272

73-
### Current needed Forks
73+
### Currently needed Forks
7474

7575
To ensure that campus_flutter runs on every supported platform, we need to make some modifications to packages.
7676

77-
| Package | Reason | Link |
78-
|-----------------|-------------------------------------|----------------------------------------------|
79-
| gRPC | Caching | https://github.com/jakobkoerber/grpc-dart |
80-
| Xml2Json | Fix Parsing of XML to JSON | https://github.com/jakobkoerber/xml2json |
77+
| Package | Reason | Link |
78+
|-----------------|-------------------------------------|-------------------------------------------------|
79+
| gRPC | Caching | https://github.com/jakobkoerber/grpc-dart |
80+
| Xml2Json | Fix Parsing of XML to JSON | https://github.com/jakobkoerber/xml2json |
8181
| flutter_linkify | Fix Selection Menu and Text Scaling | https://github.com/jakobkoerber/flutter_linkify |
8282

8383

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
**/.cxx
89

910
# Remember to never publicly share your keystore.
1011
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app

android/app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,31 @@
3535
android:name="${applicationName}"
3636
android:icon="@mipmap/ic_launcher"
3737
android:label="Campus">
38+
3839
<receiver
39-
android:name=".widgets.calendar.CalendarWidget"
40-
android:exported="false">
40+
android:name=".widgets.calendar.CalendarWidgetProvider"
41+
android:exported="true">
4142
<intent-filter>
4243
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
4344
</intent-filter>
44-
4545
<meta-data
4646
android:name="android.appwidget.provider"
4747
android:resource="@xml/calendar_widget_info" />
4848
</receiver>
4949

50+
<receiver
51+
android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver"
52+
android:exported="true">
53+
<intent-filter>
54+
<action android:name="es.antonborri.home_widget.action.BACKGROUND" />
55+
</intent-filter>
56+
</receiver>
57+
58+
<service
59+
android:name="es.antonborri.home_widget.HomeWidgetBackgroundService"
60+
android:exported="true"
61+
android:permission="android.permission.BIND_JOB_SERVICE" />
62+
5063
<service
5164
android:name=".widgets.calendar.CalendarWidgetService"
5265
android:permission="android.permission.BIND_REMOTEVIEWS" />
@@ -74,6 +87,9 @@
7487
<action android:name="android.intent.action.MAIN" />
7588
<category android:name="android.intent.category.LAUNCHER" />
7689
</intent-filter>
90+
<intent-filter>
91+
<action android:name="es.antonborri.home_widget.action.LAUNCH" />
92+
</intent-filter>
7793
</activity>
7894
<!--
7995
Don't delete the meta-data below.

android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidget.kt

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package de.tum.`in`.tumcampus.widgets.calendar
2+
3+
import android.appwidget.AppWidgetManager
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.content.SharedPreferences
7+
import android.view.View
8+
import android.widget.RemoteViews
9+
import de.tum.`in`.tumcampus.MainActivity
10+
import de.tum.`in`.tumcampus.R
11+
import de.tum.`in`.tumcampus.util.DateTimeSerializer
12+
import de.tum.`in`.tumcampus.util.timeAgo
13+
import es.antonborri.home_widget.HomeWidgetLaunchIntent
14+
import es.antonborri.home_widget.HomeWidgetProvider
15+
import java.time.LocalDate
16+
import java.time.LocalDateTime
17+
import java.time.Period
18+
import java.time.format.DateTimeFormatter
19+
import java.time.format.FormatStyle
20+
import java.time.format.TextStyle
21+
import java.util.Locale
22+
import androidx.core.net.toUri
23+
24+
class CalendarWidgetProvider : HomeWidgetProvider() {
25+
override fun onUpdate(
26+
context: Context,
27+
appWidgetManager: AppWidgetManager,
28+
appWidgetIds: IntArray,
29+
widgetData: SharedPreferences
30+
) {
31+
// There may be multiple widgets active, so update all of them
32+
for (appWidgetId in appWidgetIds) {
33+
updateAppWidget(context, appWidgetManager, appWidgetId, widgetData)
34+
}
35+
}
36+
37+
private fun updateAppWidget(
38+
context: Context,
39+
appWidgetManager: AppWidgetManager,
40+
appWidgetId: Int,
41+
widgetData: SharedPreferences
42+
) {
43+
// Instantiate the RemoteViews object for the app widget layout.
44+
val remoteViews = RemoteViews(context.packageName, R.layout.calendar_widget)
45+
46+
// Set formatted date in the header
47+
val localDate = LocalDate.now()
48+
val dateFormatter =
49+
DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.getDefault())
50+
val date = localDate.format(dateFormatter)
51+
val weekday = localDate.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault())
52+
remoteViews.setTextViewText(R.id.calendar_widget_date, "$weekday, $date")
53+
54+
// Set last saved date in the header
55+
val lastSaved = widgetData.getString("calendar_save", null)
56+
val lastSavedDate = DateTimeSerializer.deserializeStringToDate(lastSaved)
57+
val lastSavedDateString = (lastSavedDate ?: LocalDateTime.now()).timeAgo(context)
58+
remoteViews.setTextViewText(R.id.calendar_widget_updated_on, lastSavedDateString)
59+
60+
if (lastSavedDate != null && Period.between(
61+
LocalDate.now(),
62+
lastSavedDate.toLocalDate(),
63+
).days < 14
64+
) {
65+
// Set up the intent that starts the calendarWidgetService
66+
val intent = Intent(context, CalendarWidgetService::class.java)
67+
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
68+
intent.data = intent.toUri(Intent.URI_INTENT_SCHEME).toUri()
69+
remoteViews.setRemoteAdapter(R.id.calendar_widget_listview, intent)
70+
71+
// The empty view is displayed when the collection has no items.
72+
// It should be in the same layout used to instantiate the RemoteViews
73+
// object above.
74+
remoteViews.setEmptyView(R.id.calendar_widget_listview, R.id.empty_list_item)
75+
remoteViews.setViewVisibility(R.id.old_data_item, View.INVISIBLE)
76+
} else {
77+
remoteViews.setViewVisibility(R.id.old_data_item, View.VISIBLE)
78+
remoteViews.setViewVisibility(R.id.calendar_widget_listview, View.INVISIBLE)
79+
}
80+
81+
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
82+
context,
83+
MainActivity::class.java,
84+
"tumCampusApp://message?homeWidget=calendar".toUri()
85+
)
86+
remoteViews.setOnClickPendingIntent(R.id.calendar_widget, pendingIntentWithData)
87+
88+
// Instruct the widget manager to update the widget
89+
appWidgetManager.updateAppWidget(appWidgetId, remoteViews)
90+
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.calendar_widget_listview)
91+
}
92+
}

android/app/src/main/kotlin/de/tum/in/tumcampus/widgets/calendar/CalendarWidgetService.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package de.tum.`in`.tumcampus.widgets.calendar
22

33
import android.content.Context
44
import android.content.Intent
5+
import android.content.res.ColorStateList
6+
import android.os.Build
57
import android.widget.RemoteViews
68
import android.widget.RemoteViewsService
79
import de.tum.`in`.tumcampus.util.DateTimeUtils
@@ -94,11 +96,19 @@ class CalendarWidgetService : RemoteViewsService() {
9496
}
9597

9698
// Setup event color
97-
remoteViews.setInt(
98-
R.id.calendar_widget_event,
99-
"setBackgroundColor",
100-
currentItem.getEventColor(applicationContext)
101-
)
99+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
100+
remoteViews.setColorStateList(
101+
R.id.calendar_widget_event,
102+
"setBackgroundTintList",
103+
ColorStateList.valueOf(currentItem.getEventColor(applicationContext))
104+
)
105+
} else {
106+
remoteViews.setInt(
107+
R.id.calendar_widget_event,
108+
"setBackgroundColor",
109+
currentItem.getEventColor(applicationContext)
110+
)
111+
}
102112

103113
// Setup event title
104114
remoteViews.setTextViewText(R.id.calendar_widget_event_title, currentItem.title)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
5+
<corners android:radius="8dp" />
6+
</shape>

android/app/src/main/res/layout/calendar_widget_item.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
android:layout_height="wrap_content"
5454
android:layout_below="@id/calendar_widget_date_month"
5555
android:layout_marginStart="30dp"
56+
android:background="@drawable/rounded_background"
57+
android:backgroundTint="@color/color_primary"
5658
android:orientation="vertical"
57-
android:padding="@dimen/material_small_padding"
58-
tools:background="@color/text_dark_gray">
59+
android:padding="@dimen/material_small_padding">
5960

6061
<TextView
6162
android:id="@+id/calendar_widget_event_title"

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip

android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version '8.8.0' apply false
21+
id "com.android.application" version '8.9.0' apply false
2222
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
2323
id "org.jetbrains.kotlin.plugin.serialization" version "2.0.21" apply false
2424
id "com.google.gms.google-services" version "4.4.2" apply false
25-
id "com.google.firebase.crashlytics" version "3.0.2" apply false
25+
id "com.google.firebase.crashlytics" version "3.0.3" apply false
2626
}
2727

2828
include ":app"

0 commit comments

Comments
 (0)