Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loading #389

Merged
merged 13 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.5.x'
flutter-version: '2.10.x'
channel: 'stable'
- run: flutter doctor
- name: Decrypt SignETS certificate and Google Services files
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.5.x'
flutter-version: '2.10.x'
channel: 'stable'
- name: Install Android dependencies
if: matrix.target == 'Android'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.x'
channel: 'stable'
- name: Setup Fastlane
uses: ruby/setup-ruby@v1
with:
Expand Down
10 changes: 5 additions & 5 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -49,11 +49,11 @@ android {
defaultConfig {
applicationId "ca.etsmtl.applets.etsmobile"
minSdkVersion 20
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
manifestPlaceholders = [mapsApiKey: project.env.get("MAPS_API_KEY") ?:"$System.env.MAPS_API_KEY"]
manifestPlaceholders += [mapsApiKey: project.env.get("MAPS_API_KEY") ?:"$System.env.MAPS_API_KEY"]
}

signingConfigs {
Expand All @@ -70,7 +70,7 @@ android {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
firebaseCrashlytics {
mappingFileUploadEnabled false
}
Expand All @@ -79,7 +79,7 @@ android {
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
}
Expand Down
9 changes: 6 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
</intent>
</queries>
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="ÉTS Mobile"
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="sharedpref" path="FlutterSecureStorage"/>
</full-backup-content>
54 changes: 37 additions & 17 deletions lib/core/managers/user_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class UserRepository {
await _secureStorage.write(key: usernameSecureKey, value: username);
await _secureStorage.write(key: passwordSecureKey, value: password);
} on PlatformException catch (e, stacktrace) {
await _secureStorage.deleteAll();
_analyticsService.logError(
tag,
"Authenticate - PlatformException - ${e.toString()}",
Expand All @@ -131,15 +132,21 @@ class UserRepository {
/// Check if there are credentials saved and so authenticate the user, otherwise
/// return false
Future<bool> silentAuthenticate() async {
final String username = await _secureStorage.read(key: usernameSecureKey);

if (username != null) {
final String password = await _secureStorage.read(key: passwordSecureKey);

return authenticate(
username: username, password: password, isSilent: true);
try {
final username = await _secureStorage.read(key: usernameSecureKey);
if (username != null) {
final password = await _secureStorage.read(key: passwordSecureKey);
return await authenticate(
username: username, password: password, isSilent: true);
}
} on PlatformException catch (e, stacktrace) {
await _secureStorage.deleteAll();
_analyticsService.logError(
tag,
"SilentAuthenticate - PlatformException(Handled) - ${e.toString()}",
e,
stacktrace);
}

return false;
}

Expand All @@ -152,6 +159,7 @@ class UserRepository {
await _secureStorage.delete(key: usernameSecureKey);
await _secureStorage.delete(key: passwordSecureKey);
} on PlatformException catch (e, stacktrace) {
await _secureStorage.deleteAll();
_analyticsService.logError(tag,
"Authenticate - PlatformException - ${e.toString()}", e, stacktrace);
return false;
Expand All @@ -171,10 +179,15 @@ class UserRepository {
throw const ApiException(prefix: tag, message: "Not authenticated");
}
}

final String password = await _secureStorage.read(key: passwordSecureKey);

return password;
try {
final password = await _secureStorage.read(key: passwordSecureKey);
return password;
} on PlatformException catch (e, stacktrace) {
await _secureStorage.deleteAll();
_analyticsService.logError(tag,
"getPassword - PlatformException - ${e.toString()}", e, stacktrace);
throw const ApiException(prefix: tag, message: "Not authenticated");
}
}

/// Get the list of programs on which the student was active.
Expand Down Expand Up @@ -293,12 +306,19 @@ class UserRepository {
return _info;
}

/// Check whether the user was previously authenticated.
Future<bool> wasPreviouslyLoggedIn() async {
final String username = await _secureStorage.read(key: usernameSecureKey);

if (username != null) {
final String password = await _secureStorage.read(key: passwordSecureKey);
return password.isNotEmpty;
try {
final String username = await _secureStorage.read(key: passwordSecureKey);
if (username != null) {
final String password =
await _secureStorage.read(key: passwordSecureKey);
return password.isNotEmpty;
}
} on PlatformException catch (e, stacktrace) {
await _secureStorage.deleteAll();
_analyticsService.logError(tag,
"getPassword - PlatformException - ${e.toString()}", e, stacktrace);
}
return false;
}
Expand Down
12 changes: 10 additions & 2 deletions lib/core/services/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ class GithubApi {
CommitUser('clubapplets-server', 'clubapplets@gmail.com'),
branch: 'main'))
.catchError((error) {
// ignore: avoid_dynamic_calls
_logger.e("uploadFileToGithub error: ${error.message}");
_analyticsService.logError(
tag, "uploadFileToGithub: ${error.message}", error as GitHubError);
tag,
// ignore: avoid_dynamic_calls
"uploadFileToGithub: ${error.message}",
error as GitHubError);
});
}

Expand All @@ -80,9 +84,13 @@ class GithubApi {
"${await _internalInfoService.getDeviceInfoForErrorReporting()}",
labels: ['bug', 'platform: ${Platform.operatingSystem}']))
.catchError((error) {
// ignore: avoid_dynamic_calls
_logger.e("createGithubIssue error: ${error.message}");
_analyticsService.logError(
tag, "createGithubIssue: ${error.message}", error as GitHubError);
tag,
// ignore: avoid_dynamic_calls
"createGithubIssue: ${error.message}",
error as GitHubError);
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/core/viewmodels/dashboard_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ class DashboardViewModel extends FutureViewModel<Map<PreferencesFlag, int>> {
}

Future<List<CourseActivity>> removeLaboratoryGroup(
List todayDateEvents) async {
List<CourseActivity> todayDateEvents) async {
final List<CourseActivity> todayDateEventsCopy = List.from(todayDateEvents);

for (final courseAcronym in todayDateEvents) {
final courseKey = courseAcronym.courseGroup.toString().split('-')[0];
final courseKey = courseAcronym.courseGroup.split('-')[0];

final String activityCodeToUse = await _settingsManager.getDynamicString(
PreferencesFlag.scheduleSettingsLaboratoryGroup, courseKey);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/viewmodels/profile_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:notredame/core/managers/user_repository.dart';
import 'package:ets_api_clients/models.dart';

// OTHERS
import '../../locator.dart';
import 'package:notredame/locator.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch


class ProfileViewModel extends FutureViewModel<List<Program>> {
/// Load the user
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"schedule_settings_calendar_format_2_weeks": "2 weeks",
"schedule_settings_calendar_format_week": "Week",
"schedule_settings_starting_weekday_pref": "First day of the week",
"schedule_settings_show_week_events_btn_pref": "Show activies for entire week",
"schedule_settings_show_week_events_btn_pref": "Show activities for entire week",
"schedule_no_event": "No events scheduled.",
"schedule_settings_starting_weekday_monday": "Monday",
"schedule_settings_starting_weekday_tuesday": "Tuesday",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/base_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:notredame/ui/utils/app_theme.dart';
// WIDGETS
import 'package:notredame/ui/widgets/bottom_bar.dart';

import '../../locator.dart';
import 'package:notredame/locator.dart';

/// Basic Scaffold to avoid boilerplate code in the application.
/// Contains a loader controlled by [_isLoading]
Expand Down
Loading