use of com.orgzly.android.ui.CommonActivity in project orgzly-android by orgzly.
the class DirectoryRepoFragment method onOpenBrowser.
private void onOpenBrowser() {
boolean browserStarted = false;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
/*
* Apparently some devices do not handle this intent.
* Fallback to internal browser.
*/
try {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
getActivity().startActivityForResult(intent, ReposActivity.ACTION_OPEN_DOCUMENT_TREE_REQUEST_CODE);
browserStarted = true;
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
if (!browserStarted) {
Activity activity = getActivity();
if (activity != null) {
/* Close the keyboard before opening the browser. */
ActivityUtils.INSTANCE.closeSoftKeyboard(getActivity());
/* Open internal browser. */
((CommonActivity) activity).runWithPermission(AppPermissions.Usage.LOCAL_REPO, this::startBrowserDelayed);
}
}
}
Aggregations