Show the Use location prompt only once if user agrees. Bug #1910370
This commit is contained in:
@@ -1174,7 +1174,7 @@
|
|||||||
<!-- Title of dialog to user requesting use of location information to improve services -->
|
<!-- Title of dialog to user requesting use of location information to improve services -->
|
||||||
<string name="use_location_summary">Allow Google to use location for improved search and other services</string>
|
<string name="use_location_summary">Allow Google to use location for improved search and other services</string>
|
||||||
<!-- Message of dialog to user requesting use of location information -->
|
<!-- Message of dialog to user requesting use of location information -->
|
||||||
<string name="use_location_warning_message">Allow Google to use location for improved search results and other services</string>
|
<string name="use_location_warning_message">Do you want to allow Google to use location for improved search results and other services?</string>
|
||||||
<!-- Agree -->
|
<!-- Agree -->
|
||||||
<string name="agree">Agree</string>
|
<string name="agree">Agree</string>
|
||||||
<!-- Disagree -->
|
<!-- Disagree -->
|
||||||
|
@@ -25,6 +25,7 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
@@ -68,6 +69,9 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "tactilefeedback";
|
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "tactilefeedback";
|
||||||
private static final int CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE = 55;
|
private static final int CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE = 55;
|
||||||
|
|
||||||
|
private static final String PREFS_NAME = "location_prefs";
|
||||||
|
private static final String PREFS_USE_LOCATION = "use_location";
|
||||||
|
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private CheckBoxPreference mLockEnabled;
|
private CheckBoxPreference mLockEnabled;
|
||||||
private CheckBoxPreference mVisiblePattern;
|
private CheckBoxPreference mVisiblePattern;
|
||||||
@@ -335,6 +339,8 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
mUseLocation.setChecked(true);
|
mUseLocation.setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasAgreedToUseLocation()) return;
|
||||||
|
|
||||||
CharSequence msg = getResources().getText(R.string.use_location_warning_message);
|
CharSequence msg = getResources().getText(R.string.use_location_warning_message);
|
||||||
mUseLocationDialog = new AlertDialog.Builder(this).setMessage(msg)
|
mUseLocationDialog = new AlertDialog.Builder(this).setMessage(msg)
|
||||||
.setTitle(R.string.use_location_title)
|
.setTitle(R.string.use_location_title)
|
||||||
@@ -427,6 +433,7 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
//updateProviders();
|
//updateProviders();
|
||||||
mOkClicked = true;
|
mOkClicked = true;
|
||||||
|
setAgreedToUseLocation(true);
|
||||||
} else {
|
} else {
|
||||||
// Reset the toggle
|
// Reset the toggle
|
||||||
mUseLocation.setChecked(false);
|
mUseLocation.setChecked(false);
|
||||||
@@ -462,6 +469,23 @@ public class SecuritySettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasAgreedToUseLocation() {
|
||||||
|
SharedPreferences sp = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
if (sp == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return sp.getBoolean(PREFS_USE_LOCATION, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class CstorHelper implements DialogInterface.OnClickListener,
|
private class CstorHelper implements DialogInterface.OnClickListener,
|
||||||
DialogInterface.OnDismissListener,
|
DialogInterface.OnDismissListener,
|
||||||
DialogInterface.OnCancelListener {
|
DialogInterface.OnCancelListener {
|
||||||
|
Reference in New Issue
Block a user