From aead26f02caa1b2c182936086c04bd2ad375ece7 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 13 Aug 2018 20:56:51 +0200 Subject: [PATCH] show "Open" button when media is installed and viewable This checks if there is an app that can view the installed media file, and if so, it shows an "Open" button where the "Run" button is for apps. --- app/src/main/AndroidManifest.xml | 2 +- .../installer/InstallHistoryService.java | 4 +- .../fdroid/fdroid/installer/Installer.java | 3 ++ .../views/AppDetailsRecyclerViewAdapter.java | 39 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + .../res/xml/install_history_file_provider.xml | 6 --- .../main/res/xml/installer_file_provider.xml | 5 +++ 7 files changed, 50 insertions(+), 10 deletions(-) delete mode 100644 app/src/main/res/xml/install_history_file_provider.xml create mode 100644 app/src/main/res/xml/installer_file_provider.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d098cdc47..354df5dd0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -129,7 +129,7 @@ android:grantUriPermissions="true"> + android:resource="@xml/installer_file_provider"/> 0) { + buttonPrimaryView.setText(R.string.menu_open); + buttonPrimaryView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + context.startActivity(viewIntent); + } catch (ActivityNotFoundException e) { + e.printStackTrace(); + } + } + }); + } else { + buttonPrimaryView.setVisibility(View.GONE); + } + } else { + buttonPrimaryView.setVisibility(View.GONE); + } } else { buttonPrimaryView.setVisibility(View.GONE); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0ebf4b3b8..0052e632b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -171,6 +171,7 @@ This often occurs with apps installed via Google Play or other sources, if they New Repository Run + Open Share Install Uninstall diff --git a/app/src/main/res/xml/install_history_file_provider.xml b/app/src/main/res/xml/install_history_file_provider.xml deleted file mode 100644 index 06e42c762..000000000 --- a/app/src/main/res/xml/install_history_file_provider.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/installer_file_provider.xml b/app/src/main/res/xml/installer_file_provider.xml new file mode 100644 index 000000000..9b5dfbcd5 --- /dev/null +++ b/app/src/main/res/xml/installer_file_provider.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file