Skip to content

Commit

Permalink
Merge pull request #10 from htynkn/feature/open-with-nsp-file-directly
Browse files Browse the repository at this point in the history
open nsp/nsz/xci/xcz file with app
  • Loading branch information
developersu authored Oct 22, 2020
2 parents 0d589ef + ff331ac commit 17460aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
android:resource="@xml/device_filter" />
<!-- TODO: fix, implement, etc.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="application/octet-stream"
android:host="*"
android:pathPattern=".*\\.nsp"
/>
<data android:host="*"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.nsp"/>
<data android:pathPattern=".*\\.nsz"/>
<data android:pathPattern=".*\\.xci"/>
<data android:pathPattern=".*\\.xcz"/>
<data android:scheme="content"/>
</intent-filter>
-->
</activity>

<receiver
Expand All @@ -80,4 +80,4 @@
android:exported="false" />
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ protected void onCreate(Bundle savedInstanceState) {
});
// Upload to NS button
uploadToNsBtn = findViewById(R.id.buttonUpload);

//check if it's from file selected
Intent intent = getIntent();
Uri uri = intent.getData();

if (savedInstanceState == null && uri != null) {
readFile(intent);
}
}

private void updateUploadBtnState(){ // TODO: this function is bad. It multiplies entropy and sorrow.
Expand Down Expand Up @@ -296,6 +304,10 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
if (requestCode != ADD_NSP_INTENT_CODE || data == null)
return;

readFile(data);
}

private void readFile(Intent data) {
Uri uri = data.getData();

if (uri == null || uri.getScheme() == null || ! uri.getScheme().equals("content"))
Expand Down

0 comments on commit 17460aa

Please sign in to comment.