From 5c3052936883038d25b2afe52c2dd023e9aa6812 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Mon, 30 Sep 2013 15:59:43 -0700 Subject: [PATCH] Remove Google Play specific search URIs from Settings. 1. If there are no installed print services or NFC payment services, we would like to allow the user to search for one in Play. However, Play is Google specific and we should not have hard coded URI that rely on it in settings. Declare secure settings for each of these URI and check at runtime if the URI is non-empty, then show the add menu item. bug:11011519 Change-Id: I2c5cb172015bbecd7d2f8ffd3cb7fd790b01dab8 --- res/menu/nfc_payment_settings.xml | 23 ------------------- res/menu/print_settings.xml | 23 ------------------- res/values/donottranslate.xml | 4 ---- .../android/settings/nfc/PaymentSettings.java | 12 ++++++---- .../settings/print/PrintSettingsFragment.java | 11 +++++---- 5 files changed, 15 insertions(+), 58 deletions(-) delete mode 100644 res/menu/nfc_payment_settings.xml delete mode 100644 res/menu/print_settings.xml diff --git a/res/menu/nfc_payment_settings.xml b/res/menu/nfc_payment_settings.xml deleted file mode 100644 index f35374ea185..00000000000 --- a/res/menu/nfc_payment_settings.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/res/menu/print_settings.xml b/res/menu/print_settings.xml deleted file mode 100644 index 9df1181ef5a..00000000000 --- a/res/menu/print_settings.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/res/values/donottranslate.xml b/res/values/donottranslate.xml index f290f38eba6..e6bd9a6bb7b 100644 --- a/res/values/donottranslate.xml +++ b/res/values/donottranslate.xml @@ -33,8 +33,4 @@ @string/input_method_selector_always_show_value @string/input_method_selector_always_hide_value - - market://search?q=print service - - market://search?q=nfc payment diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java index 06697a463e8..7548c5099ef 100644 --- a/src/com/android/settings/nfc/PaymentSettings.java +++ b/src/com/android/settings/nfc/PaymentSettings.java @@ -25,6 +25,7 @@ import android.os.Message; import android.preference.Preference; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; +import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -152,10 +153,13 @@ public class PaymentSettings extends SettingsPreferenceFragment implements @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - inflater.inflate(R.menu.nfc_payment_settings, menu); - MenuItem menuItem = menu.findItem(R.id.nfc_payment_menu_item_add_service); - menuItem.setIntent(new Intent(Intent.ACTION_VIEW, - Uri.parse(getString(R.string.download_nfc_payment_service_query)))); + String searchUri = Settings.Secure.getString(getContentResolver(), + Settings.Secure.PAYMENT_SERVICE_SEARCH_URI); + if (!TextUtils.isEmpty(searchUri)) { + MenuItem menuItem = menu.add(R.string.nfc_payment_menu_item_add_service); + menuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); + menuItem.setIntent(new Intent(Intent.ACTION_VIEW,Uri.parse(searchUri))); + } } private final Handler mHandler = new Handler() { diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java index 84865c339a3..8d080ce0100 100644 --- a/src/com/android/settings/print/PrintSettingsFragment.java +++ b/src/com/android/settings/print/PrintSettingsFragment.java @@ -150,10 +150,13 @@ public class PrintSettingsFragment extends SettingsPreferenceFragment implements @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - inflater.inflate(R.menu.print_settings, menu); - MenuItem menuItem = menu.findItem(R.id.print_menu_item_add_service); - menuItem.setIntent(new Intent(Intent.ACTION_VIEW, - Uri.parse(getString(R.string.download_print_service_query)))); + String searchUri = Settings.Secure.getString(getContentResolver(), + Settings.Secure.PRINT_SERVICE_SEARCH_URI); + if (!TextUtils.isEmpty(searchUri)) { + MenuItem menuItem = menu.add(R.string.print_menu_item_add_service); + menuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); + menuItem.setIntent(new Intent(Intent.ACTION_VIEW,Uri.parse(searchUri))); + } } @Override