Skip to content

Commit

Permalink
Merge pull request #5 from wdiasjunior/dev
Browse files Browse the repository at this point in the history
Release Version 0.6.1
  • Loading branch information
wdiasjunior authored Aug 2, 2024
2 parents 9823925 + dd226e8 commit 182fcb6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 34 deletions.
15 changes: 10 additions & 5 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -37,14 +38,18 @@
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:mimeType="application/json"/>
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
<data android:mimeType="application/json" />
</intent-filter>

</activity>
Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/assets/index.android.bundle

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions android/app/src/main/java/com/barbellwhip/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ private void handleIntent(Intent intent) {
if(intent != null) {
String action = intent.getAction();
String type = intent.getType();
Uri data = intent.getData();

if (Intent.ACTION_SEND.equals(action) && type != null) {
handleSendFile(intent);
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
handleSendMultipleFiles(intent);
if(Intent.ACTION_SEND.equals(action) && type != null) {
if("application/json".equals(type)) {
handleSendFile(intent);
}
} else if(Intent.ACTION_VIEW.equals(action) && data != null) {
handleViewFile(intent);
}
}
}
Expand All @@ -73,16 +76,11 @@ void handleSendFile(Intent intent) {
}
}

void handleSendMultipleFiles(Intent intent) {
ArrayList<Uri> fileUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if(fileUris != null) {
ArrayList<String> filePaths = new ArrayList<>();
ArrayList<String> fileNames = new ArrayList<>();
for(Uri uri : fileUris) {
filePaths.add(uri.toString());
fileNames.add(getFileName(uri));
}
sendToReactNative("files", filePaths.toString(), fileNames.toString());
void handleViewFile(Intent intent) {
Uri fileUri = intent.getData();
if(fileUri != null) {
String fileName = getFileName(fileUri);
sendToReactNative("file", fileUri.toString(), fileName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "barbellwhip",
"version": "0.6.0",
"version": "0.6.1",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
4 changes: 1 addition & 3 deletions src/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@

# BUGS

- program page
- [ ] "content shift" glitch on first load

- [ ] program page - "content shift" glitch on first load
- [ ] File system alerts using hard coded messages

---
3 changes: 2 additions & 1 deletion src/db/fileSystem/fsWrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const writeToJSON = async (programName: string, programJSON: object) => {
}

export const importJSON = async (programName: string, programJSON: object, isIntentImport: boolean) => {
const _programNameFromJSON = JSON.parse(programJSON).programName;
try {
const availableFileName = await getAvailableFileName(programName);
const availableFileName = await getAvailableFileName(_programNameFromJSON);
const fileUri = `${RNFS.ExternalDirectoryPath}/${availableFileName}`;
const contents = isIntentImport ? programJSON : JSON.stringify(programJSON, null, 2);
await RNFS.writeFile(fileUri, contents);
Expand Down
8 changes: 1 addition & 7 deletions src/pages/AppWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ const AppWrapper = () => {

async function handleImportFileFromIntent() {
const fileContents = await readImportedJSON(data);
// TODO
// properly test if file matches the program schema
if(fileName.includes(".json")) {
importJSON(fileName, fileContents, true);
} else {
alert(selectedLocale.fileSystem.invalidFileType);
}
importJSON(fileName, fileContents, true);
}
handleImportFileFromIntent();
})
Expand Down

0 comments on commit 182fcb6

Please sign in to comment.