From 18de950fae7243e1a3be704ca355f01517f4ea68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 4 May 2013 13:14:30 +0200 Subject: [PATCH 1/3] Don't show LAUNCH if not available. Fix crashes. --- src/org/fdroid/fdroid/AppDetails.java | 39 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 5430bedb9..4bb251067 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -502,10 +502,13 @@ public class AppDetails extends ListActivity { toShow.add(menu.add(Menu.NONE, INSTALL, 1, R.string.menu_install).setIcon( android.R.drawable.ic_menu_add)); } else { - toShow.add(menu.add( Menu.NONE, LAUNCH, 1, R.string.menu_launch ).setIcon( - android.R.drawable.ic_media_play)); menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall).setIcon( android.R.drawable.ic_menu_delete); + + if (mPm.getLaunchIntentForPackage(app.id) != null) { + toShow.add(menu.add( Menu.NONE, LAUNCH, 1, R.string.menu_launch ).setIcon( + android.R.drawable.ic_media_play)); + } } if (app.detail_webURL.length() > 0) { menu.add(Menu.NONE, WEBSITE, 2, R.string.menu_website).setIcon( @@ -534,6 +537,16 @@ public class AppDetails extends ListActivity { return true; } + public void tryOpenUri(String s) { + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(s))); + } catch (android.content.ActivityNotFoundException e) { + Toast toast = Toast.makeText(this, + "You don't have any app installed that can handle " + s, 3); + toast.show(); + } + } + @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -555,28 +568,30 @@ public class AppDetails extends ListActivity { return true; case WEBSITE: - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse(app.detail_webURL))); + tryOpenUri(app.detail_webURL); return true; case ISSUES: - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse(app.detail_trackerURL))); + tryOpenUri(app.detail_trackerURL); return true; case SOURCE: - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse(app.detail_sourceURL))); + tryOpenUri(app.detail_sourceURL); return true; case MARKET: - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse("http://market.android.com/details?id=" + app.id))); + try { + startActivity(new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + app.id))); + } catch (android.content.ActivityNotFoundException e) { + tryOpenUri("https://play.google.com/store/apps/details?id=" + app.id); + } return true; + // TODO: Separate donate links if there are many (e.g. paypal and + // bitcoin) and use their link schemas if possible. case DONATE: - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse(app.detail_donateURL))); + tryOpenUri(app.detail_donateURL); return true; } From 6556745618ed6b0627567ec350af4ccbb6f61271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 5 May 2013 11:38:19 +0200 Subject: [PATCH 2/3] Move string to its place. Add issue reference. --- res/values/strings.xml | 1 + src/org/fdroid/fdroid/AppDetails.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 3e6a8eda1..ec1044d9d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -166,5 +166,6 @@ Permissions for v%s Show permissions Display a list of permissions an app needs + You don\'t have any app installed that can handle %s diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 4bb251067..ea5cf5434 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -542,7 +542,7 @@ public class AppDetails extends ListActivity { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(s))); } catch (android.content.ActivityNotFoundException e) { Toast toast = Toast.makeText(this, - "You don't have any app installed that can handle " + s, 3); + String.format(getString(R.string.no_handler_app), s), 4); toast.show(); } } @@ -590,6 +590,7 @@ public class AppDetails extends ListActivity { // TODO: Separate donate links if there are many (e.g. paypal and // bitcoin) and use their link schemas if possible. + // http://f-droid.org/repository/issues/?do=view_issue&issue=212 case DONATE: tryOpenUri(app.detail_donateURL); return true; From 387b3726061b11e75fc8e682a1515a6e00243865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 5 May 2013 11:52:40 +0200 Subject: [PATCH 3/3] Removed some unnecessary calls (I think they are) --- src/org/fdroid/fdroid/AppDetails.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index ea5cf5434..c9d62d481 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -386,7 +386,7 @@ public class AppDetails extends ListActivity { if (app.installedVersion == null) tv.setText(getString(R.string.details_notinstalled)); else - tv.setText(String.format(getString(R.string.details_installed), + tv.setText(getString(R.string.details_installed, app.installedVersion)); tv = (TextView) infoView.findViewById(R.id.description); @@ -464,7 +464,7 @@ public class AppDetails extends ListActivity { tv.setText("NONE"); } tv = (TextView) infoView.findViewById(R.id.permissions); - tv.setText(getResources().getString( + tv.setText(getString( R.string.permissions, app.apks.get(0).version)); } else { tv.setVisibility(View.GONE); @@ -542,7 +542,7 @@ public class AppDetails extends ListActivity { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(s))); } catch (android.content.ActivityNotFoundException e) { Toast toast = Toast.makeText(this, - String.format(getString(R.string.no_handler_app), s), 4); + getString(R.string.no_handler_app, s), 4); toast.show(); } }