OSDN Git Service

Remove USE_LOCATION_FOR_SERVICES from Settings
authorBjorn Bringert <bringert@android.com>
Mon, 8 Feb 2010 21:26:49 +0000 (21:26 +0000)
committerBjorn Bringert <bringert@android.com>
Mon, 8 Feb 2010 21:26:49 +0000 (21:26 +0000)
This has been moved to GoogleSettingsProvider
as part of unbundling.

Part of http://b/issue?id=2383870

Change-Id: Ia8e5725b1749fa95436fade0ea23061eb2ca4822

res/values/strings.xml
res/xml/privacy_settings.xml
src/com/android/settings/PrivacySettings.java
src/com/android/settings/SecuritySettings.java

index d145841..17d13fc 100644 (file)
     <string name="assisted_gps_enabled">Use server to assist GPS (uncheck to reduce network usage)</string>
     <!-- Security & location settings screen, setting summary when Assisted GPS check box is clear -->
     <string name="assisted_gps_disabled">Use server to assist GPS (uncheck to improve GPS performance)</string>
-    <!-- Setting title for allow sending location to google -->
-    <string name="use_location_title">Use My Location</string>
-    <!-- Setting summary for allowing Google to use location information for improved search results. -->
-    <string name="use_location_summary">Use My Location for Google search results and other Google services</string>
-    <!-- Message of dialog to user requesting use of location information -->
-    <string name="use_location_warning_message">Do you want to allow Google to use location for improved search results and other services?</string>
-    <!-- Agree -->
-    <string name="agree">Agree</string>
-    <!-- Disagree -->
-    <string name="disagree">Disagree</string>
-
 
     <!-- About --> <skip />
     <!-- Main settings screen, setting title for the user to go into the About phone screen -->
@@ -2270,8 +2259,6 @@ found in the list of installed applications.</string>
     <string name="privacy_settings">Privacy</string>
     <!-- Privacy settings activity title -->
     <string name="privacy_settings_title">Privacy settings</string>
-    <!-- Location settings section title -->
-    <string name="location_section_title">Location</string>
     <!-- Backup section title -->
     <string name="backup_section_title">Backup and Restore</string>
     <!-- Personal data section title -->
index 9a440cc..cb145d5 100644 (file)
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <PreferenceCategory android:key="location_category"
-            android:title="@string/location_section_title">
-        <!-- Share location with Google -->
-        <CheckBoxPreference
-                android:key="use_location"
-                android:title="@string/use_location_title"
-                android:persistent="false"
-                android:summary="@string/use_location_summary"/>
-    </PreferenceCategory>
-
     <PreferenceCategory android:key="backup_category"
             android:title="@string/backup_section_title">
         <!-- Backup settings -->
index a92f09b..c9f3523 100644 (file)
@@ -39,26 +39,17 @@ import android.widget.TextView;
  * Gesture lock pattern settings.
  */
 public class PrivacySettings extends PreferenceActivity implements
-        DialogInterface.OnDismissListener, DialogInterface.OnClickListener {
-
-    private static final String PREFS_NAME = "location_prefs";
-    private static final String PREFS_USE_LOCATION = "use_location";
+        DialogInterface.OnClickListener {
 
     // Vendor specific
     private static final String GSETTINGS_PROVIDER = "com.google.settings";
-    private static final String LOCATION_CATEGORY = "location_category";
     private static final String BACKUP_CATEGORY = "backup_category";
-    private static final String USE_LOCATION = "use_location";
     private static final String BACKUP_SETTINGS = "backup_settings";
     private static final String AUTO_RESTORE = "auto_restore";
-    private static final String KEY_DONE_USE_LOCATION = "doneLocation";
-    private CheckBoxPreference mUseLocation;
     private CheckBoxPreference mBackup;
     private CheckBoxPreference mAutoRestore;
-    private boolean mOkClicked;
     private Dialog mConfirmDialog;
 
-    private static final int DIALOG_USE_LOCATION = 1;
     private static final int DIALOG_ERASE_BACKUP = 2;
     private int     mDialogType;
 
@@ -68,23 +59,14 @@ public class PrivacySettings extends PreferenceActivity implements
         addPreferencesFromResource(R.xml.privacy_settings);
         final PreferenceScreen screen = getPreferenceScreen();
 
-        mUseLocation = (CheckBoxPreference) screen.findPreference(USE_LOCATION);
         mBackup = (CheckBoxPreference) screen.findPreference(BACKUP_SETTINGS);
         mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
 
         // Vendor specific
         if (getPackageManager().resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
-            screen.removePreference(findPreference(LOCATION_CATEGORY));
             screen.removePreference(findPreference(BACKUP_CATEGORY));
         }
         updateToggles();
-
-        boolean doneUseLocation = savedInstanceState == null
-                ? false : savedInstanceState.getBoolean(KEY_DONE_USE_LOCATION, true);
-        if (!doneUseLocation && (getIntent().getBooleanExtra("SHOW_USE_LOCATION", false)
-                || savedInstanceState != null)) {
-            showUseLocationDialog(true);
-        }
     }
 
     @Override
@@ -98,25 +80,9 @@ public class PrivacySettings extends PreferenceActivity implements
     }
 
     @Override
-    public void onSaveInstanceState(Bundle icicle) {
-        if (mConfirmDialog != null && mConfirmDialog.isShowing()
-                && mDialogType == DIALOG_USE_LOCATION) {
-            icicle.putBoolean(KEY_DONE_USE_LOCATION, false);
-        }
-        super.onSaveInstanceState(icicle);
-    }
-
-    @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
             Preference preference) {
-        if (preference == mUseLocation) {
-            //normally called on the toggle click
-            if (mUseLocation.isChecked()) {
-                showUseLocationDialog(false);
-            } else {
-                updateUseLocation();
-            }
-        } else if (preference == mBackup) {
+        if (preference == mBackup) {
             if (!mBackup.isChecked()) {
                 showEraseBackupDialog();
             } else {
@@ -139,34 +105,7 @@ public class PrivacySettings extends PreferenceActivity implements
         return false;
     }
 
-    private void showUseLocationDialog(boolean force) {
-        // Show a warning to the user that location data will be shared
-        mOkClicked = false;
-        if (force) {
-            mUseLocation.setChecked(true);
-        }
-
-        if (hasAgreedToUseLocation()) {
-            updateUseLocation();
-            return;
-        }
-
-        mDialogType = DIALOG_USE_LOCATION;
-        CharSequence msg = getResources().getText(R.string.use_location_warning_message);
-        mConfirmDialog = new AlertDialog.Builder(this).setMessage(msg)
-                .setTitle(R.string.use_location_title)
-                .setIcon(android.R.drawable.ic_dialog_alert)
-                .setPositiveButton(R.string.agree, this)
-                .setNegativeButton(R.string.disagree, this)
-                .show();
-        ((TextView)mConfirmDialog.findViewById(android.R.id.message))
-                .setMovementMethod(LinkMovementMethod.getInstance());
-        mConfirmDialog.setOnDismissListener(this);
-    }
-
     private void showEraseBackupDialog() {
-        // Show a warning to the user that location data will be shared
-        mOkClicked = false;
         mBackup.setChecked(true);
 
         mDialogType = DIALOG_ERASE_BACKUP;
@@ -177,7 +116,6 @@ public class PrivacySettings extends PreferenceActivity implements
                 .setPositiveButton(android.R.string.ok, this)
                 .setNegativeButton(android.R.string.cancel, this)
                 .show();
-        mConfirmDialog.setOnDismissListener(this);
     }
 
     /*
@@ -185,8 +123,6 @@ public class PrivacySettings extends PreferenceActivity implements
      */
     private void updateToggles() {
         ContentResolver res = getContentResolver();
-        mUseLocation.setChecked(Settings.Secure.getInt(res,
-                Settings.Secure.USE_LOCATION_FOR_SERVICES, 2) == 1);
 
         final boolean backupEnabled = Settings.Secure.getInt(res,
                 Settings.Secure.BACKUP_ENABLED, 0) == 1;
@@ -197,67 +133,21 @@ public class PrivacySettings extends PreferenceActivity implements
         mAutoRestore.setEnabled(backupEnabled);
     }
 
-    private void updateUseLocation() {
-        boolean use = mUseLocation.isChecked();
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.USE_LOCATION_FOR_SERVICES, use ? 1 : 0);
-    }
-
     public void onClick(DialogInterface dialog, int which) {
         if (which == DialogInterface.BUTTON_POSITIVE) {
             //updateProviders();
-            mOkClicked = true;
-            if (mDialogType == DIALOG_USE_LOCATION) {
-                setAgreedToUseLocation(true);
-            } else if (mDialogType == DIALOG_ERASE_BACKUP) {
+            if (mDialogType == DIALOG_ERASE_BACKUP) {
                 setBackupEnabled(false);
             }
         } else {
-            if (mDialogType == DIALOG_USE_LOCATION) {
-                // Reset the toggle
-                mUseLocation.setChecked(false);
-            } else if (mDialogType == DIALOG_ERASE_BACKUP) {
+            if (mDialogType == DIALOG_ERASE_BACKUP) {
                 mBackup.setChecked(true);
                 mAutoRestore.setEnabled(true);
             }
         }
-        updateUseLocation();
         mDialogType = 0;
     }
 
-    public void onDismiss(DialogInterface dialog) {
-        // Assuming that onClick gets called first
-        if (!mOkClicked) {
-            if (mDialogType == DIALOG_USE_LOCATION) {
-                mUseLocation.setChecked(false);
-            }
-        }
-    }
-
-    /**
-     * Checks if the user has agreed to the dialog in the past.
-     */
-    private boolean hasAgreedToUseLocation() {
-        SharedPreferences sp = getSharedPreferences(PREFS_NAME, 0);
-        if (sp == null) {
-            return false;
-        }
-        return sp.getBoolean(PREFS_USE_LOCATION, false);
-    }
-
-    /**
-     * Notes that the user has agreed to the dialog and won't need to be prompted in the
-     * future.
-     */
-    private void setAgreedToUseLocation(boolean agreed) {
-        if (agreed) {
-            SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
-            SharedPreferences.Editor editor = settings.edit();
-            editor.putBoolean(PREFS_USE_LOCATION, true);
-            editor.commit();
-        }
-    }
-
     /**
      * Informs the BackupManager of a change in backup state - if backup is disabled,
      * the data on the server will be erased.
index b8ea18c..1ef137d 100644 (file)
@@ -77,9 +77,6 @@ public class SecuritySettings extends PreferenceActivity {
     private static final String PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
     private static final String PROPERTY_EFS_TRANSITION = "persist.security.efs.trans";
 
-    private static final String PREFS_NAME = "location_prefs";
-    private static final String PREFS_USE_LOCATION = "use_location";
-
     private CheckBoxPreference mVisiblePattern;
     private CheckBoxPreference mTactileFeedback;