Skip to content

Commit

Permalink
Merge pull request BlueWallet#5609 from BlueWallet/storageandroid
Browse files Browse the repository at this point in the history
FIX: can't access storage for unsigned transaction export BlueWallet#5559
  • Loading branch information
GladosBlueWallet authored Jul 9, 2023
2 parents 368b15b + 3684814 commit cc228cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion blue_modules/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const writeFileAndExportToAndroidDestionation = async ({ filename, contents, des
buttonNegative: loc._.cancel,
buttonPositive: loc._.ok,
});
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
if (granted === PermissionsAndroid.RESULTS.GRANTED || Platform.Version >= 33) {
const filePath = destination + `/${filename}`;
try {
await RNFS.writeFile(filePath, contents);
Expand Down
15 changes: 13 additions & 2 deletions screen/selftest.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ScrollView, View, StyleSheet, Linking } from 'react-native';
import { ScrollView, View, StyleSheet, Linking, Platform } from 'react-native';
import wif from 'wif';
import bip38 from 'bip38';
import BIP32Factory from 'bip32';

import loc from '../loc';
import { BlueSpacing20, SafeBlueArea, BlueCard, BlueText, BlueLoading } from '../BlueComponents';
import { BlueSpacing20, SafeBlueArea, BlueCard, BlueText, BlueLoading, BlueButton } from '../BlueComponents';
import navigationStyle from '../components/navigationStyle';
import {
SegwitP2SHWallet,
Expand All @@ -22,6 +22,7 @@ const BlueCrypto = require('react-native-blue-crypto');
const encryption = require('../blue_modules/encryption');
const BlueElectrum = require('../blue_modules/BlueElectrum');
const bip32 = BIP32Factory(ecc);
const fs = require('../blue_modules/fs');

const styles = StyleSheet.create({
center: {
Expand All @@ -37,6 +38,10 @@ export default class Selftest extends Component {
};
}

onPressSaveToStorage = () => {
fs.writeFileAndExport('bluewallet-storagesave-test.txt', 'Success');
};

async componentDidMount() {
let errorMessage = '';
let isOk = true;
Expand Down Expand Up @@ -293,6 +298,12 @@ export default class Selftest extends Component {
);
}
})()}
{Platform.OS === 'android' && (
<>
<BlueSpacing20 />
<BlueButton title="Test Save to Storage" onPress={this.onPressSaveToStorage} />
</>
)}
</ScrollView>
</BlueCard>
</SafeBlueArea>
Expand Down
2 changes: 1 addition & 1 deletion screen/send/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const SendCreate = () => {
buttonPositive: loc._.ok,
});

if (granted === PermissionsAndroid.RESULTS.GRANTED) {
if (granted === PermissionsAndroid.RESULTS.GRANTED || Platform.Version >= 33) {
console.log('Storage Permission: Granted');
const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`;
try {
Expand Down
2 changes: 1 addition & 1 deletion screen/wallets/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ const WalletDetails = () => {
buttonPositive: loc._.ok,
});

if (granted === PermissionsAndroid.RESULTS.GRANTED) {
if (granted === PermissionsAndroid.RESULTS.GRANTED || Platform.Version >= 33) {
console.log('Storage Permission: Granted');
const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`;
try {
Expand Down

0 comments on commit cc228cc

Please sign in to comment.