Skip to content

Commit

Permalink
Merge pull request #165 from astarub/deutschlandticket
Browse files Browse the repository at this point in the history
Deutschlandticket
  • Loading branch information
henry-herrmann authored Apr 7, 2024
2 parents bd2d443 + 1eab2ea commit fd8b1d4
Show file tree
Hide file tree
Showing 35 changed files with 1,478 additions and 652 deletions.
20 changes: 8 additions & 12 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,10 +13,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
Expand All @@ -27,13 +30,6 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdk 34

Expand Down Expand Up @@ -81,7 +77,7 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.20"
implementation('androidx.appcompat:appcompat:1.6.1')
implementation("androidx.appcompat:appcompat-resources:1.6.1")
}
16 changes: 0 additions & 16 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.14'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
31 changes: 23 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
id "com.google.gms.google-services" version "4.4.0" apply false
}

include ":app"
24 changes: 10 additions & 14 deletions assets/img/bogestra-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/icons/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/wiki/Pages/ticket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Semesterticket

This page is to provide a basic overview about the "Calendar" feature located inside
`lib/pages/wallet/ticket`.

---

## Ticket usescases

| Type | Name | Description |
|------|------|-------------|
| Future<Image?> | renderAztecCode() | Returns an Image object, containing the resized Aztec code loaded from storage.
| Future<Map<String, dynamic>?> | getTicketDetails() | Returns a map, containing the ticket details such as the name of the owner, the birthdate and validity information.

---

## Ticket repository

| Type | Name | Description |
|------|------|-------------|
| Future<void> | loadTicket() | Calls the ticket datasource to load the remote ticket and then saves it to storage or deletes the exisiting one if it expired or was removed.
| Future<String?> | getAztecCode() | Returns the Aztec code as a Base64 String
| Future<String?> | getTicketDetails() | Returns the whole ticket map as JSON
| Future<void> | saveTicket(Map<String, dynamic> ticket) | Saves the Aztec Code and ticket details to two separate files using the passed Map
| Future<void> | deleteTicket() | Deletes the ticket from storage

---

## Ticket datasource

| Type | Name | Description |
|------|------|-------------|
| Future<Map<String, dynamic>> | getRemoteTicket() | Loads the remote ticket using a headless webview which clicks through the RUB login process and then extracts the Aztec code and ticket details from the RIDE website.
4 changes: 4 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
D9D1457A69A7F122B3FE81D8 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0756A62BDDAF9D89B947FE5A /* Pods_Runner.framework */; };
FB4008602BB4AC74007EAF92 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = FB40085F2BB4AC74007EAF92 /* PrivacyInfo.xcprivacy */; };
FBBEF41D2A214655000BABFD /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FBBEF41C2A214655000BABFD /* GoogleService-Info.plist */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -49,6 +50,7 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F8216C20DF2A8BB04CD1C856 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
FB40085F2BB4AC74007EAF92 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
FBBEF41C2A214655000BABFD /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -107,6 +109,7 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
FB40085F2BB4AC74007EAF92 /* PrivacyInfo.xcprivacy */,
);
path = Runner;
sourceTree = "<group>";
Expand Down Expand Up @@ -193,6 +196,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FB4008602BB4AC74007EAF92 /* PrivacyInfo.xcprivacy in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
FBBEF41D2A214655000BABFD /* GoogleService-Info.plist in Resources */,
Expand Down
24 changes: 24 additions & 0 deletions ios/Runner/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
PrivacyInfo.xcprivacy
Runner
Created by Henry Herrmann on 27.03.24.
Copyright (c) 2024 . All rights reserved.
-->
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions lib/core/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class EmptyResponseException implements Exception {}
/// RUB login credentials incorrect
class InvalidLoginIDAndPasswordException implements Exception {}

class MissingCredentialsException implements Exception {}

class TicketNotFoundException implements Exception {}

/// 2FA token is not correct
class Invalid2FATokenException implements Exception {}

Expand Down
40 changes: 28 additions & 12 deletions lib/core/injection.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import 'dart:io';

import 'package:appwrite/appwrite.dart';
import 'package:campus_app/utils/pages/main_utils.dart';
import 'package:campus_app/utils/pages/wallet_utils.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:get_it/get_it.dart';
import 'package:hive/hive.dart';
Expand All @@ -17,16 +14,17 @@ import 'package:campus_app/pages/mensa/mensa_datasource.dart';
import 'package:campus_app/pages/mensa/mensa_repository.dart';
import 'package:campus_app/pages/mensa/mensa_usecases.dart';

//import 'package:campus_app/pages/ecampus/bloc/ecampus_bloc.dart';
//import 'package:campus_app/pages/ecampus/ticket_datasource.dart';
//import 'package:campus_app/pages/ecampus/ticket_repository.dart';
import 'package:campus_app/pages/feed/news/news_datasource.dart';
import 'package:campus_app/pages/feed/news/news_repository.dart';
import 'package:campus_app/pages/feed/news/news_usecases.dart';
import 'package:campus_app/utils/dio_utils.dart';
import 'package:campus_app/pages/wallet/ticket/ticket_datasource.dart';
import 'package:campus_app/pages/wallet/ticket/ticket_repository.dart';
import 'package:campus_app/pages/wallet/ticket/ticket_usecases.dart';
import 'package:campus_app/utils/pages/calendar_utils.dart';
import 'package:campus_app/utils/pages/feed_utils.dart';
import 'package:campus_app/utils/pages/mensa_utils.dart';
import 'package:campus_app/utils/pages/main_utils.dart';
import 'package:campus_app/utils/dio_utils.dart';
import 'package:campus_app/utils/constants.dart';
import 'package:native_dio_adapter/native_dio_adapter.dart';

Expand Down Expand Up @@ -60,14 +58,20 @@ Future<void> init() async {
);

sl.registerLazySingleton(() {
final Client client = Client().setEndpoint(appwrite).setProject('campus_app');
return BackendRepository(client: client);
return TicketDataSource(
secureStorage: sl(),
);
});

//!
//! Repositories
//!

sl.registerLazySingleton(() {
final Client client = Client().setEndpoint(appwrite).setProject('campus_app');
return BackendRepository(client: client);
});

sl.registerSingletonWithDependencies(
() => NewsRepository(newsDatasource: sl()),
dependsOn: [NewsDatasource],
Expand All @@ -83,6 +87,10 @@ Future<void> init() async {
dependsOn: [MensaDataSource],
);

sl.registerLazySingleton(
() => TicketRepository(ticketDataSource: sl(), secureStorage: sl()),
);

//!
//! Usecases
//!
Expand All @@ -102,6 +110,10 @@ Future<void> init() async {
dependsOn: [MensaRepository],
);

sl.registerLazySingleton(
() => TicketUsecases(ticketRepository: sl()),
);

//!
//! Utils
//!
Expand All @@ -116,17 +128,21 @@ Future<void> init() async {
sl.registerLazySingleton(CalendarUtils.new);
sl.registerLazySingleton(FeedUtils.new);
sl.registerLazySingleton(MensaUtils.new);

sl.registerLazySingleton(MainUtils.new);
sl.registerLazySingleton(WalletUtils.new);

//!
//! External
//!

//sl.registerLazySingleton(http.Client.new);
sl.registerLazySingleton(FlutterSecureStorage.new);
sl.registerLazySingleton(Dio.new);
sl.registerLazySingleton(CookieJar.new);
sl.registerLazySingleton(
() => const FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
),
);

await sl.allReady();
}
Loading

0 comments on commit fd8b1d4

Please sign in to comment.