OSDN Git Service

Remove Google Play specific search URIs from Settings.
authorSvetoslav <svetoslavganov@google.com>
Mon, 30 Sep 2013 22:59:43 +0000 (15:59 -0700)
committerSvetoslav <svetoslavganov@google.com>
Mon, 30 Sep 2013 22:59:46 +0000 (15:59 -0700)
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 [deleted file]
res/menu/print_settings.xml [deleted file]
res/values/donottranslate.xml
src/com/android/settings/nfc/PaymentSettings.java
src/com/android/settings/print/PrintSettingsFragment.java

diff --git a/res/menu/nfc_payment_settings.xml b/res/menu/nfc_payment_settings.xml
deleted file mode 100644 (file)
index f35374e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item
-        android:id="@+id/nfc_payment_menu_item_add_service"
-        android:title="@string/nfc_payment_menu_item_add_service"
-        android:showAsAction="ifRoom">
-    </item>
-</menu>
diff --git a/res/menu/print_settings.xml b/res/menu/print_settings.xml
deleted file mode 100644 (file)
index 9df1181..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item
-        android:id="@+id/print_menu_item_add_service"
-        android:title="@string/print_menu_item_add_service"
-        android:showAsAction="ifRoom">
-    </item>
-</menu>
index f290f38..e6bd9a6 100644 (file)
@@ -33,8 +33,4 @@
         <item>@string/input_method_selector_always_show_value</item>
         <item>@string/input_method_selector_always_hide_value</item>
     </string-array>
-    <!-- Default query string to search for a print service. -->
-    <string name="download_print_service_query">market://search?q=print service</string>
-    <!-- Default query string to search for a NFC payment service. -->
-    <string name="download_nfc_payment_service_query">market://search?q=nfc payment</string>
 </resources>
index 06697a4..7548c50 100644 (file)
@@ -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() {
index 84865c3..8d080ce 100644 (file)
@@ -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