summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/location
diff options
context:
space:
mode:
authorLifu Tang <lifu@google.com>2013-10-08 02:24:17 -0700
committerLifu Tang <lifu@google.com>2013-10-08 09:48:41 -0700
commit1673fbc029d569b6424914db48e571b52091b4fc (patch)
tree417be498480b468e24876bda2cdba647bf0b415c /src/com/android/settings/location
parent1955bf1bb3147a06d1856ac002f8cd5aab4f535e (diff)
downloadpackages_apps_Settings-1673fbc029d569b6424914db48e571b52091b4fc.tar.gz
packages_apps_Settings-1673fbc029d569b6424914db48e571b52091b4fc.tar.bz2
packages_apps_Settings-1673fbc029d569b6424914db48e571b52091b4fc.zip
Broadcasting a message for mode changing
- Fix b/10974059 Change-Id: I219ea35e65a36af9f041a487dd8039bb5e2f048b
Diffstat (limited to 'src/com/android/settings/location')
-rw-r--r--src/com/android/settings/location/LocationMode.java13
-rw-r--r--src/com/android/settings/location/LocationSettingsBase.java12
2 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/settings/location/LocationMode.java b/src/com/android/settings/location/LocationMode.java
index 233b010b0..7e95cacbf 100644
--- a/src/com/android/settings/location/LocationMode.java
+++ b/src/com/android/settings/location/LocationMode.java
@@ -16,9 +16,6 @@
package com.android.settings.location;
-import android.app.Activity;
-import android.content.Intent;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.provider.Settings;
@@ -75,7 +72,11 @@ public class LocationMode extends LocationSettingsBase
}
private void updateRadioButtons(RadioButtonPreference activated) {
- if (activated == mHighAccuracy) {
+ if (activated == null) {
+ mHighAccuracy.setChecked(false);
+ mBatterySaving.setChecked(false);
+ mSensorsOnly.setChecked(false);
+ } else if (activated == mHighAccuracy) {
mHighAccuracy.setChecked(true);
mBatterySaving.setChecked(false);
mSensorsOnly.setChecked(false);
@@ -107,9 +108,7 @@ public class LocationMode extends LocationSettingsBase
public void onModeChanged(int mode, boolean restricted) {
switch (mode) {
case Settings.Secure.LOCATION_MODE_OFF:
- Intent intent = new Intent();
- PreferenceActivity pa = (PreferenceActivity) getActivity();
- pa.finishPreferencePanel(LocationMode.this, Activity.RESULT_OK, intent);
+ updateRadioButtons(null);
break;
case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
updateRadioButtons(mSensorsOnly);
diff --git a/src/com/android/settings/location/LocationSettingsBase.java b/src/com/android/settings/location/LocationSettingsBase.java
index 9ceefe711..de18a0e1a 100644
--- a/src/com/android/settings/location/LocationSettingsBase.java
+++ b/src/com/android/settings/location/LocationSettingsBase.java
@@ -19,6 +19,7 @@ package com.android.settings.location;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.CursorLoader;
+import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
@@ -35,8 +36,14 @@ import com.android.settings.SettingsPreferenceFragment;
public abstract class LocationSettingsBase extends SettingsPreferenceFragment
implements LoaderCallbacks<Cursor> {
private static final String TAG = "LocationSettingsBase";
+ /** Broadcast intent action when the location mode is about to change. */
+ private static final String MODE_CHANGING_ACTION =
+ "com.android.settings.location.MODE_CHANGING";
+ private static final String CURRENT_MODE_KEY = "CURRENT_MODE";
+ private static final String NEW_MODE_KEY = "NEW_MODE";
private static final int LOADER_ID_LOCATION_MODE = 1;
+ private int mCurrentMode;
/**
* Whether the fragment is actively running.
@@ -83,6 +90,10 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment
}
return;
}
+ Intent intent = new Intent(MODE_CHANGING_ACTION);
+ intent.putExtra(CURRENT_MODE_KEY, mCurrentMode);
+ intent.putExtra(NEW_MODE_KEY, mode);
+ getActivity().sendBroadcast(intent);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE, mode);
refreshLocationMode();
}
@@ -91,6 +102,7 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment
if (mActive) {
int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF);
+ mCurrentMode = mode;
onModeChanged(mode, isRestricted());
}
}