Skip to content

Commit

Permalink
[FM] Allow opening folders from external apps
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
  • Loading branch information
MuntashirAkon committed Jul 12, 2023
1 parent 7f749c5 commit cfd6fb0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,29 @@
android:name=".fm.FmActivity"
android:exported="true"
android:label="@string/files"
android:taskAffinity=".fm.FmActivity" />
android:taskAffinity=".fm.FmActivity">
<intent-filter android:label="@string/browse_files">
<action android:name="android.intent.action.VIEW" />
<action android:name="org.openintents.action.VIEW_DIRECTORY" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:mimeType="inode/directory" />
<data android:mimeType="resource/folder" />
<data android:mimeType="vnd.android.document/directory" />
<data android:mimeType="vnd.android.cursor.dir/*" />
<data android:mimeType="x-directory/normal" />
<data
android:scheme=""
tools:ignore="AppLinkUrlError" />
<data android:scheme="file" />
<data android:scheme="folder" />
<data android:scheme="directory" />
<data android:scheme="content" />
</intent-filter>
</activity>

<activity
android:name=".fm.OpenWithActivity"
android:label="@string/file_open_with"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package io.github.muntashirakon.AppManager.fm;

import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
Expand Down Expand Up @@ -79,6 +80,15 @@ protected void onAuthenticated(@Nullable Bundle savedInstanceState) {
setSupportActionBar(findViewById(R.id.toolbar));
findViewById(R.id.progress_linear).setVisibility(View.GONE);
Uri uri = getIntent().getData();
if (uri.getScheme() == null) {
// file:// URI can have no schema. So, fix it by adding file://
if (uri.getPath() != null && uri.getAuthority() == null) {
uri = uri.buildUpon().scheme(ContentResolver.SCHEME_FILE).build();
} else {
// Avoid loading invalid paths
uri = null;
}
}
if (savedInstanceState == null) {
Options options = getIntent().getExtras() != null ? BundleCompat.getParcelable(getIntent().getExtras(), EXTRA_OPTIONS, Options.class) : null;
if (options == null) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1424,4 +1424,5 @@
<string name="debloat_removal_caution_short_description">Exercise caution</string>
<string name="debloat_removal_replace_short_description">Replace with alternative</string>
<string name="title_alternatives_to_bloatware">Alternatives</string>
<string name="browse_files">Browse</string>
</resources>

0 comments on commit cfd6fb0

Please sign in to comment.