Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana committed Dec 3, 2024
2 parents a102c11 + b5002b7 commit 80d6ba6
Show file tree
Hide file tree
Showing 223 changed files with 4,104 additions and 2,636 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
flutter build appbundle
- name: Upload App Bundle
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: appbundle
if-no-files-found: error
Expand All @@ -147,7 +147,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Get App Bundle
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: appbundle

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
build/
*.bin
.flutter-plugins*
packages/uni_ui/pubspec.lock

# IDE files
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To use the translation import `'package:uni/generated/l10n.dart'` and use `S.of(
For this project, we separate the code into *model, *view* and *controller*.
By making sure view-only components are clear from the rest of the code, we can assure safe reuse of widgets as well as separated testing and development.

![MVC Scheme](../readme-src/MVC.png "MVC Scheme")
![MVC Scheme](../../readme-src/MVC.png "MVC Scheme")

### Model
The *model* represents the entities that are used in the app, including the session, the classes, the exams. They should be generated from the controller's methods and passed to the view. The model should not contain logic, but only the data that is needed to display the information.
Expand Down
3 changes: 3 additions & 0 deletions packages/uni_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ android {
"proguard-rules.pro"
)
}
debug {
applicationIdSuffix ".dev"
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/uni_app/android/app/src/debug/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">uni (dev)</string>
</resources>
8 changes: 5 additions & 3 deletions packages/uni_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application
android:label="uni"
<application
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:allowBackup="false"
>
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
4 changes: 4 additions & 0 deletions packages/uni_app/android/app/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">uni</string>
</resources>
2 changes: 1 addition & 1 deletion packages/uni_app/app_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.0-beta.23+286
1.10.0-beta.42+345
2 changes: 1 addition & 1 deletion packages/uni_app/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/uni_app/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
end
2 changes: 1 addition & 1 deletion packages/uni_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
378A17102ACF02E100B89C1C = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
34 changes: 34 additions & 0 deletions packages/uni_app/lib/app_links/uni_app_links.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:uni/utils/uri.dart';

final _authUri = Uri(scheme: 'pt.up.fe.ni.uni', host: 'auth');

class UniAppLinks {
final login = _AuthenticationAppLink(
redirectUri: _authUri.replace(path: '/login'),
);

final logout = _AuthenticationAppLink(
redirectUri: _authUri.replace(path: '/logout'),
);
}

class _AuthenticationAppLink {
_AuthenticationAppLink({required this.redirectUri});

final AppLinks _appLinks = AppLinks();
final Uri redirectUri;

Future<Uri> intercept(
FutureOr<void> Function(Uri redirectUri) callback,
) async {
final interceptedUri = _appLinks.uriLinkStream
.firstWhere((uri) => redirectUri == uri.stripQueryComponent());

await callback(redirectUri);
final data = await interceptedUri;
return data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'package:tuple/tuple.dart';
import 'package:uni/controller/background_workers/notifications/tuition_notification.dart';
import 'package:uni/controller/local_storage/notification_timeout_storage.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';
import 'package:workmanager/workmanager.dart';

///
Expand Down Expand Up @@ -103,7 +102,8 @@ class NotificationManager {
_localNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()!;
try {
final permissionGranted = await androidPlugin.requestPermission();
final permissionGranted =
await androidPlugin.requestNotificationsPermission();
if (permissionGranted != true) {
return;
}
Expand Down Expand Up @@ -143,44 +143,14 @@ class NotificationManager {

static Future<void> updateAndTriggerNotifications() async {
PreferencesController.prefs = await SharedPreferences.getInstance();
final userInfo = await PreferencesController.getPersistentUserInfo();
final faculties = PreferencesController.getUserFaculties();
final refreshToken = await PreferencesController.getSessionRefreshToken();
final savedSession = await PreferencesController.getSavedSession();

if (faculties.isEmpty) {
if (savedSession == null) {
return;
}
if (userInfo == null && refreshToken == null) {
return; // Session not persistent
}

Session? session;
if (userInfo != null) {
session = await NetworkRouter.login(
userInfo.item1,
userInfo.item2,
faculties,
persistentSession: false,
);
}

if (refreshToken != null) {
final token = await NetworkRouter.getAccessToken(refreshToken);
final studentNumber = await PreferencesController.getUserNumber();
if (token == null || studentNumber == null) {
return;
}
session = await NetworkRouter.loginWithToken(
token,
studentNumber,
faculties,
persistentSession: false,
);
}

if (session == null) {
return;
}
final request = savedSession.createRefreshRequest();
final session = await request.perform();

// Get the .json file that contains the last time that the
// notification has ran
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:uni/controller/background_workers/notifications.dart';
import 'package:uni/controller/fetchers/fees_fetcher.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
import 'package:uni/controller/parsers/parser_fees.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';
import 'package:uni/utils/duration_string_formatter.dart';

class TuitionNotification extends Notification {
Expand Down
6 changes: 1 addition & 5 deletions packages/uni_app/lib/controller/cleanup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import 'package:uni/controller/local_storage/database/app_last_user_info_update_
import 'package:uni/controller/local_storage/database/app_lectures_database.dart';
import 'package:uni/controller/local_storage/database/app_user_database.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/providers/state_providers.dart';

Future<void> cleanupStoredData(BuildContext context) async {
StateProviders.fromContext(context).invalidate();

final prefs = await SharedPreferences.getInstance();
final faculties = PreferencesController.getUserFaculties();
await prefs.clear();

await Future.wait([
Expand All @@ -31,9 +29,7 @@ Future<void> cleanupStoredData(BuildContext context) async {
AppLastUserInfoUpdateDatabase().deleteLastUpdate(),
AppBusStopDatabase().deleteBusStops(),
AppCourseUnitsDatabase().deleteCourseUnits(),
NetworkRouter.killSigarraAuthentication(faculties),
PreferencesController.removePersistentUserInfo(),
PreferencesController.removeSessionRefreshToken(),
PreferencesController.removeSavedSession(),
]);

final toCleanDirectory = await getApplicationDocumentsDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:uni/controller/fetchers/session_dependant_fetcher.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/controller/parsers/parser_calendar.dart';
import 'package:uni/model/entities/calendar_event.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

/// Fetch the school calendar from HTML
class CalendarFetcherHtml implements SessionDependantFetcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/controller/parsers/parser_course_units.dart';
import 'package:uni/model/entities/course.dart';
import 'package:uni/model/entities/course_units/course_unit.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

class AllCourseUnitsFetcher {
Future<List<CourseUnit>?> getAllCourseUnitsAndCourseAverages(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:uni/model/entities/course_units/course_unit_class.dart';
import 'package:uni/model/entities/course_units/course_unit_directory.dart';
import 'package:uni/model/entities/course_units/course_unit_sheet.dart';
import 'package:uni/model/entities/course_units/sheet.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

class CourseUnitsInfoFetcher implements SessionDependantFetcher {
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:uni/controller/fetchers/session_dependant_fetcher.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/course_units/course_unit.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

class CurrentCourseUnitsFetcher implements SessionDependantFetcher {
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:http/http.dart';
import 'package:uni/controller/fetchers/session_dependant_fetcher.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/course_units/course_unit.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

/// Returns the user's current list of [CourseUnit].
class CoursesFetcher implements SessionDependantFetcher {
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/lib/controller/fetchers/exam_fetcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:uni/controller/parsers/parser_exams.dart';
import 'package:uni/model/entities/course.dart';
import 'package:uni/model/entities/course_units/course_unit.dart';
import 'package:uni/model/entities/exam.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

class ExamFetcher implements SessionDependantFetcher {
ExamFetcher(this.courses, this.userUcs);
Expand Down
19 changes: 12 additions & 7 deletions packages/uni_app/lib/controller/fetchers/faculties_fetcher.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import 'package:html/parser.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/session.dart';
import 'package:http/http.dart' as http;
import 'package:uni/http/client/cookie.dart';
import 'package:uni/session/flows/base/session.dart';

Future<List<String>> getStudentFaculties(Session session) async {
final response = await NetworkRouter.getWithCookies(
'https://sigarra.up.pt/up/pt/vld_entidades_geral.entidade_pagina',
{'pct_codigo': session.username},
session,
Future<List<String>> getStudentFaculties(
Session session,
http.Client httpClient,
) async {
final client = CookieClient(httpClient, cookies: () => session.cookies);

final response = await client.get(
Uri.parse('https://sigarra.up.pt/up/pt/vld_entidades_geral.entidade_pagina')
.replace(queryParameters: {'pct_codigo': session.username}),
);

final document = parse(response.body);
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/lib/controller/fetchers/fees_fetcher.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:http/http.dart';
import 'package:uni/controller/fetchers/session_dependant_fetcher.dart';
import 'package:uni/controller/networking/network_router.dart';
import 'package:uni/model/entities/session.dart';
import 'package:uni/session/flows/base/session.dart';

class FeesFetcher implements SessionDependantFetcher {
@override
Expand Down
Loading

0 comments on commit 80d6ba6

Please sign in to comment.