Merge pull request #1045 from kekkyojin/open-file-external
Offer opening unsupported filetypes with external app
This commit is contained in:
commit
896c566a02
3 changed files with 28 additions and 0 deletions
|
@ -1522,6 +1522,12 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
onMainActionButtonClicked();
|
onMainActionButtonClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
root.findViewById(R.id.file_view_open_external_button).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
openClaimExternally(claim, claim.getMediaType());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (metadata instanceof Claim.StreamMetadata) {
|
if (metadata instanceof Claim.StreamMetadata) {
|
||||||
Claim.StreamMetadata streamMetadata = (Claim.StreamMetadata) metadata;
|
Claim.StreamMetadata streamMetadata = (Claim.StreamMetadata) metadata;
|
||||||
|
@ -2069,6 +2075,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
openClaimExternally(claim, mediaType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2155,6 +2163,18 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
" </html>";
|
" </html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openClaimExternally(Claim claim, String mediaType) {
|
||||||
|
File file = new File(claim.getFile().getDownloadPath());
|
||||||
|
Uri fileUri = Uri.parse(claim.getFile().getDownloadPath());
|
||||||
|
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(fileUri, mediaType.toLowerCase());
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
Intent chooser = Intent.createChooser(intent, getString(R.string.choose_app));
|
||||||
|
startActivityForResult(chooser, 419);
|
||||||
|
}
|
||||||
|
|
||||||
public void showError(String message) {
|
public void showError(String message) {
|
||||||
View root = getView();
|
View root = getView();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
|
|
|
@ -157,6 +157,13 @@
|
||||||
android:textFontWeight="300"
|
android:textFontWeight="300"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/file_view_open_external_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/inter"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:text="@string/open" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
<string name="please_select_repost_channel">Please select a channel to repost on.</string>
|
<string name="please_select_repost_channel">Please select a channel to repost on.</string>
|
||||||
<string name="reply">Reply</string>
|
<string name="reply">Reply</string>
|
||||||
<string name="replying_to">Replying to %1$s</string>
|
<string name="replying_to">Replying to %1$s</string>
|
||||||
|
<string name="choose_app">Choose app</string>
|
||||||
<plurals name="post_and_tip">
|
<plurals name="post_and_tip">
|
||||||
<item quantity="one">Post and tip %1$s credit?</item>
|
<item quantity="one">Post and tip %1$s credit?</item>
|
||||||
<item quantity="other">Post and tip %1$s credits?</item>
|
<item quantity="other">Post and tip %1$s credits?</item>
|
||||||
|
|
Loading…
Reference in a new issue