Skip to content

Commit

Permalink
Dropbox sign in (#46)
Browse files Browse the repository at this point in the history
* Implement dropbox sign in

* Implement dropbox sign in

* Implement dropbox-sign-in

* Fix dropbox-sign-in

* Fix dropbox-sign-in

* Fix dropbox-sign-in

* Added feature flags

* Added feature flags
  • Loading branch information
cp-pratik-k authored Nov 18, 2024
1 parent 1b136d7 commit 939b07f
Show file tree
Hide file tree
Showing 52 changed files with 2,291 additions and 331 deletions.
206 changes: 170 additions & 36 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

55 changes: 36 additions & 19 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,25 @@
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- If a user clicks on a shared link that uses the "http" scheme, your
app should be able to delegate that traffic to "https". -->
<data android:scheme="cloudgallery" />
<data android:host="cloudgallery.com" />
<data android:pathPrefix="/auth" />
</intent-filter>

</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
4 changes: 4 additions & 0 deletions app/assets/images/icons/dropbox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"common_accounts": "Accounts",
"common_local": "Local",
"common_google_drive": "Google Drive",
"common_dropbox": "Dropbox",
"common_term_and_condition": "Terms and Conditions",
"common_privacy_policy": "Privacy Policy",
"common_today": "Today",
Expand All @@ -28,6 +29,7 @@
"something_went_wrong_error": "Something went wrong! Please try again later.",
"user_google_sign_in_account_not_found_error": "You haven't signed in with Google account yet. Please sign in with Google account and try again.",
"back_up_folder_not_found_error": "Back up folder not found!",
"auth_session_expired_error": "Your session has expired. Please log in again to continue using the app.",

"unable_to_load_media_error": "Unable to load media!",

Expand All @@ -53,9 +55,7 @@
"greetings_hey_there_text": "Hey There!",
"greetings_hey_text": "Hey",

"hint_google_sign_in_message": "Sign in with Google and effortlessly link your Google Drive to your Cloud Gallery. Enjoy quick access to all your awesome content in one spot",
"hint_google_auto_backup_message": "Enable Auto Back Up to Google Drive and never lose your precious memories. Your photos and videos will be automatically backed up to your Google Drive",
"hint_action_auto_backup": "Enable Auto Back Up",
"hint_sign_in_message": "Sign in with Google Drive or Dropbox and enjoy quick access to all your awesome content in one spot",

"delete_media_from_device_confirmation_message": "Are you sure you want to delete this media? It will be permanently deleted from your device.",
"delete_media_from_google_drive_confirmation_message": "Are you sure you want to delete this media? It will be permanently deleted from your Google Drive.",
Expand All @@ -79,6 +79,9 @@
"download_from_google_drive_text": "Download from Google Drive",
"download_from_google_drive_alert_message": " Are you sure you want to download this media? It will be saved to your gallery.",

"sign_in_with_google_drive_text": "Sign in with Google Drive",
"sign_in_with_dropbox_text": "Sign in with Dropbox",

"name_text": "Name",
"size_text": "Size",
"created_at_text": "Created at",
Expand Down
34 changes: 20 additions & 14 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PODS:
- app_links (0.0.2):
- Flutter
- AppAuth (1.7.5):
- AppAuth/Core (= 1.7.5)
- AppAuth/ExternalUserAgent (= 1.7.5)
Expand All @@ -7,14 +9,14 @@ PODS:
- AppAuth/Core
- Firebase/CoreOnly (11.4.0):
- FirebaseCore (= 11.4.0)
- firebase_core (3.7.0):
- firebase_core (3.8.0):
- Firebase/CoreOnly (= 11.4.0)
- Flutter
- FirebaseCore (11.4.0):
- FirebaseCoreInternal (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/Logger (~> 8.0)
- FirebaseCoreInternal (11.4.2):
- FirebaseCoreInternal (11.5.0):
- "GoogleUtilities/NSData+zlib (~> 8.0)"
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
Expand All @@ -23,11 +25,9 @@ PODS:
- Flutter
- Toast
- google_sign_in_ios (0.0.1):
- AppAuth (>= 1.7.4)
- Flutter
- FlutterMacOS
- GoogleSignIn (~> 7.1)
- GTMSessionFetcher (>= 3.4.0)
- GoogleSignIn (~> 7.0)
- GoogleSignIn (7.1.0):
- AppAuth (< 2.0, >= 1.7.3)
- GTMAppAuth (< 5.0, >= 4.1.1)
Expand All @@ -43,11 +43,7 @@ PODS:
- GTMAppAuth (4.1.1):
- AppAuth/Core (~> 1.7)
- GTMSessionFetcher/Core (< 4.0, >= 3.3)
- GTMSessionFetcher (3.5.0):
- GTMSessionFetcher/Full (= 3.5.0)
- GTMSessionFetcher/Core (3.5.0)
- GTMSessionFetcher/Full (3.5.0):
- GTMSessionFetcher/Core
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
Expand All @@ -67,6 +63,8 @@ PODS:
- Flutter
- FlutterMacOS
- Toast (4.1.1)
- url_launcher_ios (0.0.1):
- Flutter
- video_player_avfoundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -75,6 +73,7 @@ PODS:
- FlutterMacOS

DEPENDENCIES:
- app_links (from `.symlinks/plugins/app_links/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
Expand All @@ -87,6 +86,7 @@ DEPENDENCIES:
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)

Expand All @@ -103,6 +103,8 @@ SPEC REPOS:
- Toast

EXTERNAL SOURCES:
app_links:
:path: ".symlinks/plugins/app_links/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
Flutter:
Expand All @@ -127,34 +129,38 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite_darwin:
:path: ".symlinks/plugins/sqflite_darwin/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"

SPEC CHECKSUMS:
app_links: e7a6750a915a9e161c58d91bc610e8cd1d4d0ad0
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
Firebase: cf1b19f21410b029b6786a54e9764a0cacad3c99
firebase_core: f8c5b220a8f9c436fdbd075ae321cef3d96ef181
firebase_core: 9efc3ecf689cdbc90f13f4dc58108c83ea46b266
FirebaseCore: e0510f1523bc0eb21653cac00792e1e2bd6f1771
FirebaseCoreInternal: 35731192cab10797b88411be84940d2beb33a238
FirebaseCoreInternal: f47dd28ae7782e6a4738aad3106071a8fe0af604
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_local_notifications: df98d66e515e1ca797af436137b4459b160ad8c9
fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c
google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38
google_sign_in_ios: 989eea5abe94af62050782714daf920be883d4a2
GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586
video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4

PODFILE CHECKSUM: 4c438addb11b6da45ed7ae408823d68256222460
Expand Down
1 change: 1 addition & 0 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.64221198282-h8h8gjo3991iijeg2agdkmfh6tr014nq</string>
<string>cloudgallery</string>
</array>
</dict>
</array>
Expand Down
4 changes: 4 additions & 0 deletions app/ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:cloudgallery.com</string>
</array>
</dict>
</plist>
1 change: 1 addition & 0 deletions app/lib/domain/assets/assets_paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ class PathImages {

class PathIcons {
String get googleDrive => 'assets/images/icons/google-drive.svg';
String get dropbox => 'assets/images/icons/dropbox.svg';
}
6 changes: 4 additions & 2 deletions app/lib/domain/extensions/app_error_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ extension AppErrorExtensions on Object {
String l10nMessage(BuildContext context) {
if (this is AppError) {
switch ((this as AppError).l10nCode) {
case AppErrorL10nCodes.noInternetConnection:
case AppErrorL10nCodes.noInternetConnectionError:
return context.l10n.no_internet_connection_error;
case AppErrorL10nCodes.somethingWentWrongError:
return context.l10n.something_went_wrong_error;
case AppErrorL10nCodes.googleSignInUserNotFoundError:
return context.l10n.user_google_sign_in_account_not_found_error;
case AppErrorL10nCodes.backUpFolderNotFound:
case AppErrorL10nCodes.backUpFolderNotFoundError:
return context.l10n.back_up_folder_not_found_error;
case AppErrorL10nCodes.authSessionExpiredError:
return context.l10n.auth_session_expired_error;
default:
return (this as AppError).message ??
context.l10n.something_went_wrong_error;
Expand Down
56 changes: 56 additions & 0 deletions app/lib/domain/handlers/deep_links_handler.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'dart:developer';

import 'package:app_links/app_links.dart';
import 'package:data/apis/network/urls.dart';
import 'package:data/services/auth_service.dart';
import 'package:data/services/dropbox_services.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final appLinksProvider = Provider<AppLinks>((ref) {
return AppLinks();
});

class DeepLinkHandler {
static Future<void> observeDeepLinks({
required ProviderContainer container,
}) async {
final appLinks = container.read(appLinksProvider);

Future<void> handleDeepLink(Uri link) async {
if (link.toString().contains(RedirectURL.auth) &&
link.queryParameters['code'] != null) {
// Set the dropbox token from the code
final authService = container.read(authServiceProvider);
await authService.setDropboxTokenFromCode(
code: link.queryParameters['code']!,
);

final dropboxService = container.read(dropboxServiceProvider);
await dropboxService.setCurrentUserAccount();
}
}

try {
final initialLink = await appLinks.getInitialLink();
if (initialLink != null && !kDebugMode) handleDeepLink(initialLink);
} catch (error) {
log(
"Failed to handle initial deep link",
error: error,
name: "DeepLinkHandler",
);
}

appLinks.uriLinkStream.listen(
(link) => handleDeepLink(link),
onError: (error) {
log(
"Failed to listen to deep links",
error: error,
name: "DeepLinkHandler",
);
},
);
}
}
3 changes: 3 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'domain/handlers/deep_links_handler.dart';
import 'firebase_options.dart';
import 'package:data/storage/provider/preferences_provider.dart';
import 'package:firebase_core/firebase_core.dart';
Expand All @@ -23,6 +24,8 @@ Future<void> main() async {

final container = await _configureContainerWithAsyncDependency();

DeepLinkHandler.observeDeepLinks(container: container);

runApp(
UncontrolledProviderScope(
container: container,
Expand Down
Loading

0 comments on commit 939b07f

Please sign in to comment.