Show the Use location prompt only once if user agrees. Bug #1910370

This commit is contained in:
Amith Yamasani
2009-08-31 17:27:53 -07:00
parent b89653cb95
commit f411c9625c
2 changed files with 25 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
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 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 CheckBoxPreference mLockEnabled;
private CheckBoxPreference mVisiblePattern;
@@ -335,6 +339,8 @@ public class SecuritySettings extends PreferenceActivity implements
mUseLocation.setChecked(true);
}
if (hasAgreedToUseLocation()) return;
CharSequence msg = getResources().getText(R.string.use_location_warning_message);
mUseLocationDialog = new AlertDialog.Builder(this).setMessage(msg)
.setTitle(R.string.use_location_title)
@@ -427,6 +433,7 @@ public class SecuritySettings extends PreferenceActivity implements
if (which == DialogInterface.BUTTON_POSITIVE) {
//updateProviders();
mOkClicked = true;
setAgreedToUseLocation(true);
} else {
// Reset the toggle
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,
DialogInterface.OnDismissListener,
DialogInterface.OnCancelListener {