Skip to content

Commit

Permalink
Merge pull request #25 from raj457036/v0.1.24
Browse files Browse the repository at this point in the history
V0.1.24 ( 0.1.28 - patches )
  • Loading branch information
raj457036 authored Nov 16, 2024
2 parents 4e875ed + 5d6168d commit 7ae08b2
Show file tree
Hide file tree
Showing 18 changed files with 186 additions and 107 deletions.
2 changes: 1 addition & 1 deletion android/app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"project_info": {
"project_number": "892296995692",
"project_id": "clipboard-419514",
"storage_bucket": "clipboard-419514.appspot.com"
"storage_bucket": "clipboard-419514.firebasestorage.app"
},
"client": [
{
Expand Down
30 changes: 30 additions & 0 deletions git-scripts/switch-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Usage: $0 <branch-name>"
exit 1
fi

BRANCH=$1

# Switch the main repository to the specified branch
echo "Switching main repository to branch: $BRANCH"
git checkout "$BRANCH"
if [ $? -ne 0 ]; then
echo "Failed to switch main repository to branch: $BRANCH"
exit 1
fi

# Update submodules to ensure they are initialized
echo "Initializing and updating submodules..."
git submodule update --init --recursive

# Switch all submodules to the specified branch
echo "Switching all submodules to branch: $BRANCH"
git submodule foreach --recursive "git checkout $BRANCH || echo 'Branch $BRANCH does not exist in submodule'"

# Update submodules to match the branch and main repo's references
echo "Updating submodules to remote tracking branch: $BRANCH"
git submodule update --remote --recursive

echo "Switched main repository and all submodules to branch: $BRANCH"
38 changes: 19 additions & 19 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
D32916227F280D31E202A571 /* [CP] Embed Pods Frameworks */,
D2C8199ACC7208E63509A4F9 /* [CP] Copy Pods Resources */,
ADB4322C3E21A9B959E553DB /* FlutterFire: "flutterfire upload-crashlytics-symbols" */,
1F1257162C8A34FED2858627 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */,
);
buildRules = (
);
Expand Down Expand Up @@ -378,6 +378,24 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1F1257162C8A34FED2858627 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\"";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\n#!/bin/bash\nPATH=${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=$PODS_ROOT/FirebaseCrashlytics/upload-symbols --platform=ios --apple-project-path=${SRCROOT} --env-platform-name=${PLATFORM_NAME} --env-configuration=${CONFIGURATION} --env-project-dir=${PROJECT_DIR} --env-built-products-dir=${BUILT_PRODUCTS_DIR} --env-dwarf-dsym-folder-path=${DWARF_DSYM_FOLDER_PATH} --env-dwarf-dsym-file-name=${DWARF_DSYM_FILE_NAME} --env-infoplist-path=${INFOPLIST_PATH} --default-config=default\n";
};
2579210AC2D0D9A6ECBC51F0 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -453,24 +471,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
ADB4322C3E21A9B959E553DB /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\"";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\n#!/bin/bash\nPATH=${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=$PODS_ROOT/FirebaseCrashlytics/upload-symbols --platform=ios --apple-project-path=${SRCROOT} --env-platform-name=${PLATFORM_NAME} --env-configuration=${CONFIGURATION} --env-project-dir=${PROJECT_DIR} --env-built-products-dir=${BUILT_PRODUCTS_DIR} --env-dwarf-dsym-folder-path=${DWARF_DSYM_FOLDER_PATH} --env-dwarf-dsym-file-name=${DWARF_DSYM_FILE_NAME} --env-infoplist-path=${INFOPLIST_PATH} --default-config=default\n";
};
D23738D31A79A78D4DE2D496 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit
import Flutter
import share_handler_ios

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>PROJECT_ID</key>
<string>clipboard-419514</string>
<key>STORAGE_BUCKET</key>
<string>clipboard-419514.appspot.com</string>
<string>clipboard-419514.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
Expand Down
10 changes: 5 additions & 5 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DefaultFirebaseOptions {
messagingSenderId: '892296995692',
projectId: 'clipboard-419514',
authDomain: 'clipboard-419514.firebaseapp.com',
storageBucket: 'clipboard-419514.appspot.com',
storageBucket: 'clipboard-419514.firebasestorage.app',
measurementId: 'G-8LF9RP87DF',
);

Expand All @@ -50,15 +50,15 @@ class DefaultFirebaseOptions {
appId: '1:892296995692:android:64012302abe55897490949',
messagingSenderId: '892296995692',
projectId: 'clipboard-419514',
storageBucket: 'clipboard-419514.appspot.com',
storageBucket: 'clipboard-419514.firebasestorage.app',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyDu5UXxIRpcUq1h680iS6mUtbEEsTNwsfA',
appId: '1:892296995692:ios:4bf415b9b852d3af490949',
messagingSenderId: '892296995692',
projectId: 'clipboard-419514',
storageBucket: 'clipboard-419514.appspot.com',
storageBucket: 'clipboard-419514.firebasestorage.app',
iosBundleId: 'com.entilitystudio.CopyCat',
);

Expand All @@ -67,7 +67,7 @@ class DefaultFirebaseOptions {
appId: '1:892296995692:ios:4bf415b9b852d3af490949',
messagingSenderId: '892296995692',
projectId: 'clipboard-419514',
storageBucket: 'clipboard-419514.appspot.com',
storageBucket: 'clipboard-419514.firebasestorage.app',
iosBundleId: 'com.entilitystudio.CopyCat',
);

Expand All @@ -77,7 +77,7 @@ class DefaultFirebaseOptions {
messagingSenderId: '892296995692',
projectId: 'clipboard-419514',
authDomain: 'clipboard-419514.firebaseapp.com',
storageBucket: 'clipboard-419514.appspot.com',
storageBucket: 'clipboard-419514.firebasestorage.app',
measurementId: 'G-TBGBJVH2GS',
);

Expand Down
53 changes: 34 additions & 19 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:copycat_base/bloc/offline_persistance_cubit/offline_persistance_
import 'package:copycat_base/bloc/sync_manager_cubit/sync_manager_cubit.dart';
import 'package:copycat_base/bloc/window_action_cubit/window_action_cubit.dart';
import 'package:copycat_base/common/bloc_config.dart';
import 'package:copycat_base/common/logging.dart';
import 'package:copycat_base/constants/key.dart';
import 'package:copycat_base/constants/widget_styles.dart';
import 'package:copycat_base/l10n/generated/app_localizations.dart';
Expand All @@ -46,10 +47,15 @@ import 'package:window_manager/window_manager.dart';
import 'firebase_options.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeServices();
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeServices();

runApp(const MainApp());
runApp(const MainApp());
}, (error, stack) async {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
debugPrint('Uncaught Error: $error');
});
}

Future<void> initializeServices() async {
Expand Down Expand Up @@ -96,27 +102,36 @@ Future<void> initializeDesktopServices() async {
titleBarStyle: TitleBarStyle.hidden,
);
windowManager.waitUntilReadyToShow(windowOptions).then((_) async {
// if (Platform.isMacOS) {
// await windowManager.setVisibleOnAllWorkspaces(
// true,
// visibleOnFullScreen: true,
// );
// }
windowManager.hide();
await windowManager.hide();
});
}

Future<void> initializeFirebase() async {
if (isAnalyticsSupported) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
try {
if (isAnalyticsSupported) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
PlatformDispatcher.instance.onError = (error, stack) {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
return true;
};
FlutterError.onError = (errorDetail) {
try {
FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetail);
} catch (e) {
logger.e(e);
}
};
PlatformDispatcher.instance.onError = (error, stack) {
try {
FirebaseCrashlytics.instance
.recordError(error, stack, printDetails: true, fatal: false);
} catch (e) {
logger.e(e);
}
return true;
};
}
} catch (e) {
logger.e(e);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/pages/settings/widgets/info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class InfoCard extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(padding12),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Expand Down
61 changes: 45 additions & 16 deletions lib/widgets/dialogs/e2ee_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert' show jsonEncode, jsonDecode, utf8;

import 'package:clipboard/widgets/dialogs/e2ee_dialogs/export_e2ee.dart';
Expand Down Expand Up @@ -39,13 +40,35 @@ class _E2EESettingDialogState extends State<E2EESettingDialog> {
bool invalidImportedKey = false;
String? secret;
bool rebuilding = false;
Timer? canContinueTimer;
int allowedIn = 0;

late AppConfigCubit appConfigCubit;

@override
void initState() {
super.initState();
appConfigCubit = context.read<AppConfigCubit>();
allowedIn = 9;
startTimer();
}

void updateCanContinueTimer(Timer? timer) {
setState(() {
allowedIn -= 1;
});
if (allowedIn <= 0) {
timer?.cancel();
canContinueTimer = null;
}
}

void startTimer() {
setState(() {
allowedIn = 5;
});
canContinueTimer =
Timer.periodic(const Duration(seconds: 1), updateCanContinueTimer);
}

Future<void> importEnc2Key(String keyId) async {
Expand Down Expand Up @@ -116,22 +139,27 @@ class _E2EESettingDialogState extends State<E2EESettingDialog> {
}

Future<void> generateEnc2Key() async {
final enc2 = EncryptionSecret.generate();
final keyId = const Uuid().v4();
final encryptor = EncryptionManager(enc2);

final enc1Decrypt = EncryptionSecret.generate();
final enc1 = encryptor.encrypt(enc1Decrypt.serialized);

setState(() => loading = true);

await context.read<AuthCubit>().setupEncryption(keyId, enc1);

setState(() {
loading = false;
});

appConfigCubit.setE2EEKey(enc2.serialized);
try {
setState(() => loading = true);
final enc2 = EncryptionSecret.generate();
final keyId = const Uuid().v4();
final encryptor = EncryptionManager(enc2);
final authCubit = context.read<AuthCubit>();

final enc1Decrypt = EncryptionSecret.generate();
final enc1 = encryptor.encrypt(enc1Decrypt.serialized);

final failure = await appConfigCubit.setE2EEKey(enc2.serialized);
if (failure != null) {
showFailureSnackbar(failure);
return;
}
await authCubit.setupEncryption(keyId, enc1);
} finally {
setState(() {
loading = false;
});
}
}

@override
Expand Down Expand Up @@ -180,6 +208,7 @@ class _E2EESettingDialogState extends State<E2EESettingDialog> {
return GenerateE2eeDialog(
loading: loading,
generateEnc2Key: generateEnc2Key,
allowedIn: allowedIn,
);
}

Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/dialogs/e2ee_dialogs/generate_e2ee.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import 'package:flutter/material.dart';
class GenerateE2eeDialog extends StatelessWidget {
final bool loading;
final VoidCallback generateEnc2Key;
final int allowedIn;

const GenerateE2eeDialog({
super.key,
required this.loading,
required this.generateEnc2Key,
this.allowedIn = 0,
});

@override
Expand Down Expand Up @@ -62,11 +64,13 @@ class GenerateE2eeDialog extends StatelessWidget {
),
height10,
ElevatedButton.icon(
onPressed: loading ? null : generateEnc2Key,
onPressed: loading || allowedIn > 0 ? null : generateEnc2Key,
icon: const Icon(Icons.key),
label: loading
? Text(context.locale.generating)
: Text(context.locale.generateKey),
: allowedIn > 0
? Text("${context.locale.generateKey} ($allowedIn s )")
: Text(context.locale.generateKey),
),
],
),
Expand Down
Loading

0 comments on commit 7ae08b2

Please sign in to comment.