Don't show run button for apps which cannot be launched.

The feedback from ACRA was:

> tried to run an app that doesn't have a launcher (termux api)
This commit is contained in:
Peter Serwylo 2017-04-18 18:24:07 +10:00
parent 4cc6e5bc89
commit 1eb224fc5e

View File

@ -322,7 +322,11 @@ public class AppListItemController extends RecyclerView.ViewHolder {
actionButton.setVisibility(View.VISIBLE); actionButton.setVisibility(View.VISIBLE);
if (wasSuccessfullyInstalled(app) != null) { if (wasSuccessfullyInstalled(app) != null) {
if (activity.getPackageManager().getLaunchIntentForPackage(currentApp.packageName) != null) {
actionButton.setText(R.string.menu_launch); actionButton.setText(R.string.menu_launch);
} else {
actionButton.setVisibility(View.GONE);
}
} else if (isReadyToInstall(app)) { } else if (isReadyToInstall(app)) {
if (app.isInstalled()) { if (app.isInstalled()) {
actionButton.setText(R.string.app__install_downloaded_update); actionButton.setText(R.string.app__install_downloaded_update);
@ -520,12 +524,14 @@ public class AppListItemController extends RecyclerView.ViewHolder {
AppUpdateStatusManager.AppUpdateStatus successfullyInstalledStatus = wasSuccessfullyInstalled(currentApp); AppUpdateStatusManager.AppUpdateStatus successfullyInstalledStatus = wasSuccessfullyInstalled(currentApp);
if (successfullyInstalledStatus != null) { if (successfullyInstalledStatus != null) {
Intent intent = activity.getPackageManager().getLaunchIntentForPackage(currentApp.packageName); Intent intent = activity.getPackageManager().getLaunchIntentForPackage(currentApp.packageName);
if (intent != null) {
activity.startActivity(intent); activity.startActivity(intent);
// Once it is explicitly launched by the user, then we can pretty much forget about // Once it is explicitly launched by the user, then we can pretty much forget about
// any sort of notification that the app was successfully installed. It should be // any sort of notification that the app was successfully installed. It should be
// apparent to the user because they just launched it. // apparent to the user because they just launched it.
AppUpdateStatusManager.getInstance(activity).removeApk(successfullyInstalledStatus.getUniqueKey()); AppUpdateStatusManager.getInstance(activity).removeApk(successfullyInstalledStatus.getUniqueKey());
}
return; return;
} }