Some another fixes for Android. Never ask us about that.
M committed
Jan 28, 2021 at 19:58 UTC
5631961e478013b3f19892b8fff83e0f08bacdb4
7 files changed
+57
-25
android/app/src/main/AndroidManifest.xml
+2
-10
@@ -3,7 +3,8 @@
3
4
<uses-permission android:name="android.permission.INTERNET"/>
5
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
6
-
6
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7
+
8
<application
9
android:label="Cake Wallet"
10
android:allowBackup="false"
@@ -17,15 +18,6 @@
18
android:hardwareAccelerated="true"
19
android:windowSoftInputMode="adjustResize"
20
android:screenOrientation="portrait">
20
-<!-- <meta-data-->
21
-<!-- android:name="io.flutter.embedding.android.NormalTheme"-->
22
-<!-- android:resource="@style/NormalTheme"-->
23
-<!-- />-->
24
- <!-- Displays an Android View that continues showing the launch screen
25
- Drawable until Flutter paints its first frame, then this splash
26
- screen fades out. A splash screen is useful to avoid any visual
27
- gap between the end of Android's launch screen and the painting of
28
- Flutter's first frame. -->
21
<meta-data
22
android:name="io.flutter.embedding.android.SplashScreenDrawable"
23
android:resource="@drawable/launch_background"
android/build.gradle
+1
-1
@@ -5,7 +5,7 @@ buildscript {
5
}
6
7
dependencies {
8
- classpath 'com.android.tools.build:gradle:3.5.0'
8
+ classpath 'com.android.tools.build:gradle:3.5.4'
9
}
10
}
11
cw_monero/android/build.gradle
+1
-1
@@ -9,7 +9,7 @@ buildscript {
9
}
10
11
dependencies {
12
- classpath 'com.android.tools.build:gradle:3.5.0'
12
+ classpath 'com.android.tools.build:gradle:3.5.4'
13
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
}
15
}
cw_monero/ios/Classes/monero_api.cpp
+1
-1
@@ -696,7 +696,7 @@ extern "C"
696
void on_startup()
697
{
698
Monero::Utils::onStartup();
699
- Monero::WalletManagerFactory::setLogLevel(4);
699
+ Monero::WalletManagerFactory::setLogLevel(0);
700
}
701
702
void rescan_blockchain()
lib/src/screens/backup/backup_page.dart
+41
-11
@@ -1,3 +1,4 @@
1
+import 'dart:io';
2
import 'package:flutter/material.dart';
3
import 'package:flutter/cupertino.dart';
4
import 'package:flutter/services.dart';
@@ -91,17 +92,46 @@ class BackupPage extends BasePage {
92
context: context,
93
builder: (dialogContext) {
94
return AlertWithTwoActions(
94
- alertTitle: S.of(context).export_backup,
95
- alertContent: S.of(context).save_backup_password,
96
- rightButtonText: S.of(context).seed_alert_yes,
97
- leftButtonText: S.of(context).seed_alert_back,
98
- actionRightButton: () async {
99
- Navigator.of(dialogContext).pop();
100
- final backup = await backupViewModelBase.exportBackup();
101
- await Share.file(
102
- S.of(context).backup_file, backup.name, backup.content, 'text');
103
- },
104
- actionLeftButton: () => Navigator.of(dialogContext).pop());
95
+ alertTitle: S.of(context).export_backup,
96
+ alertContent: S.of(context).save_backup_password,
97
+ rightButtonText: S.of(context).seed_alert_yes,
98
+ leftButtonText: S.of(context).seed_alert_back,
99
+ actionRightButton: () async {
100
+ Navigator.of(dialogContext).pop();
101
+ final backup = await backupViewModelBase.exportBackup();
102
+ await backupViewModelBase.saveToDownload(
103
+ backup.name, backup.content);
104
+
105
+ if (Platform.isAndroid) {
106
+ onExportAndroid(context, backup);
107
+ } else {
108
+ await Share.file(S.of(context).backup_file, backup.name,
109
+ backup.content, 'application/*');
110
+ }
111
+ },
112
+ actionLeftButton: () => Navigator.of(dialogContext).pop());
113
+ });
114
+ }
115
+
116
+ void onExportAndroid(BuildContext context, BackupExportFile backup) {
117
+ showPopUp<void>(
118
+ context: context,
119
+ builder: (dialogContext) {
120
+ return AlertWithTwoActions(
121
+ alertTitle: S.of(context).export_backup,
122
+ alertContent: 'Please select destination for the backup file.',
123
+ rightButtonText: 'Save to Downloads',
124
+ leftButtonText: 'Share',
125
+ actionRightButton: () async {
126
+ Navigator.of(dialogContext).pop();
127
+ await backupViewModelBase.saveToDownload(
128
+ backup.name, backup.content);
129
+ },
130
+ actionLeftButton: () {
131
+ Navigator.of(dialogContext).pop();
132
+ Share.file(S.of(context).backup_file, backup.name,
133
+ backup.content, 'application/*');
134
+ });
135
});
136
}
137
}
lib/view_model/backup_view_model.dart
+10
@@ -1,3 +1,5 @@
1
+import 'dart:io';
2
+
3
import 'package:cake_wallet/core/backup_service.dart';
4
import 'package:cake_wallet/core/execution_state.dart';
5
import 'package:cake_wallet/entities/secret_store_key.dart';
@@ -66,4 +68,12 @@ abstract class BackupViewModelBase with Store {
68
69
@action
70
void showMasterPassword() => isBackupPasswordVisible = true;
71
+
72
+ @action
73
+ Future<void> saveToDownload(String name, List<int> content) async {
74
+ const downloadDirPath = '/storage/emulated/0/Download'; // For Android
75
+ final filePath = '$downloadDirPath/${name}';
76
+ final file = File(filePath);
77
+ await file.writeAsBytes(content);
78
+ }
79
}
pubspec.yaml
+1
-1
@@ -11,7 +11,7 @@ description: Cake Wallet.
11
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12
# Read more about iOS versioning at
13
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14
-version: 4.1.0+34
14
+version: 4.1.0+37
15
16
environment:
17
sdk: ">=2.7.0 <3.0.0"