diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-01-17 19:17:58 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-02-03 16:36:46 -0800 |
commit | 263bcc8b732dbb47d3ce63904e0e05191fabbad6 (patch) | |
tree | dc8fd51052ac94e418473d378c1244cb42594665 /src/com/android/settings/location | |
parent | af79ddb358ff6ed078708ce5995da9ff269f1679 (diff) | |
download | packages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.zip packages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.tar.gz packages_apps_Settings-263bcc8b732dbb47d3ce63904e0e05191fabbad6.tar.bz2 |
Use Drawer in Settings app
- get rid of PreferenceActivity as much as we can and use fragments instead
- add Drawer widget
- add Dashboard high level entry into the Drawer (but this is work in progress and would be done in another CL)
- add bypass of fragment's Header validation when launched from the Drawer but *force* validation if external
call thru an Intent
Be aware that WifiPickerActivity should remain for now a PreferenceActivity. It is used by SetupWizard and should
not trigger running the SettingsActivity's header building code. SetupWizard is a Home during the provisionnig process
and then deactivate itself as a Home but would make the Home header to appear in the Drawer (because momentarily we
would have two Home).
Also, verified that:
- the WiFi settings still work when called from SetupWizard
- when you have multiple Launchers, the Home header will appear in the list of Headers in the Drawer
Change-Id: I407a5e0fdd843ad7615d3d511c416a44e3d97c90
Diffstat (limited to 'src/com/android/settings/location')
-rw-r--r-- | src/com/android/settings/location/LocationSettings.java | 79 | ||||
-rw-r--r-- | src/com/android/settings/location/RecentLocationApps.java | 6 |
2 files changed, 54 insertions, 31 deletions
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java index 6612ba9..40156cf 100644 --- a/src/com/android/settings/location/LocationSettings.java +++ b/src/com/android/settings/location/LocationSettings.java @@ -17,23 +17,24 @@ package com.android.settings.location; import android.app.ActionBar; +import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.SettingInjectorService; +import android.os.Bundle; import android.preference.Preference; -import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; -import android.provider.Settings; import android.util.Log; import android.view.Gravity; import android.widget.CompoundButton; import android.widget.Switch; import com.android.settings.R; +import com.android.settings.SettingsActivity; import java.util.Collections; import java.util.Comparator; @@ -67,10 +68,48 @@ public class LocationSettings extends LocationSettingsBase } @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + final Activity activity = getActivity(); + + mSwitch = new Switch(activity); + final int padding = activity.getResources().getDimensionPixelSize( + R.dimen.action_bar_switch_padding); + mSwitch.setPaddingRelative(0, 0, padding, 0); + mSwitch.setOnCheckedChangeListener(this); + } + + @Override + public void onStart() { + super.onStart(); + + final SettingsActivity activity = (SettingsActivity) getActivity(); + + // Only show the master switch when we're not being used as Setup Wizard. + if (!activity.onIsHidingHeaders()) { + activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, + ActionBar.DISPLAY_SHOW_CUSTOM); + activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams( + ActionBar.LayoutParams.WRAP_CONTENT, + ActionBar.LayoutParams.WRAP_CONTENT, + Gravity.CENTER_VERTICAL | Gravity.END)); + } + } + + @Override + public void onStop() { + super.onStop(); + final SettingsActivity activity = (SettingsActivity) getActivity(); + if (!activity.onIsHidingHeaders()) { + activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM); + activity.getActionBar().setCustomView(null); + } + } + + @Override public void onResume() { super.onResume(); - mSwitch = new Switch(getActivity()); - mSwitch.setOnCheckedChangeListener(this); mValidListener = true; createPreferenceHierarchy(); } @@ -101,7 +140,7 @@ public class LocationSettings extends LocationSettingsBase } private PreferenceScreen createPreferenceHierarchy() { - final PreferenceActivity activity = (PreferenceActivity) getActivity(); + final SettingsActivity activity = (SettingsActivity) getActivity(); PreferenceScreen root = getPreferenceScreen(); if (root != null) { root.removeAll(); @@ -139,22 +178,6 @@ public class LocationSettings extends LocationSettingsBase addLocationServices(activity, root); - // Only show the master switch when we're not in multi-pane mode, and not being used as - // Setup Wizard. - if (activity.onIsHidingHeaders() || !activity.onIsMultiPane()) { - final int padding = activity.getResources().getDimensionPixelSize( - R.dimen.action_bar_switch_padding); - mSwitch.setPaddingRelative(0, 0, padding, 0); - activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, - ActionBar.DISPLAY_SHOW_CUSTOM); - activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams( - ActionBar.LayoutParams.WRAP_CONTENT, - ActionBar.LayoutParams.WRAP_CONTENT, - Gravity.CENTER_VERTICAL | Gravity.END)); - } - - setHasOptionsMenu(true); - refreshLocationMode(); return root; } @@ -202,16 +225,16 @@ public class LocationSettings extends LocationSettingsBase @Override public void onModeChanged(int mode, boolean restricted) { switch (mode) { - case Settings.Secure.LOCATION_MODE_OFF: + case android.provider.Settings.Secure.LOCATION_MODE_OFF: mLocationMode.setSummary(R.string.location_mode_location_off_title); break; - case Settings.Secure.LOCATION_MODE_SENSORS_ONLY: + case android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY: mLocationMode.setSummary(R.string.location_mode_sensors_only_title); break; - case Settings.Secure.LOCATION_MODE_BATTERY_SAVING: + case android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING: mLocationMode.setSummary(R.string.location_mode_battery_saving_title); break; - case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY: + case android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY: mLocationMode.setSummary(R.string.location_mode_high_accuracy_title); break; default: @@ -221,7 +244,7 @@ public class LocationSettings extends LocationSettingsBase // Restricted user can't change the location mode, so disable the master switch. But in some // corner cases, the location might still be enabled. In such case the master switch should // be disabled but checked. - boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF); + boolean enabled = (mode != android.provider.Settings.Secure.LOCATION_MODE_OFF); mSwitch.setEnabled(!restricted); mLocationMode.setEnabled(enabled && !restricted); mCategoryRecentLocationRequests.setEnabled(enabled); @@ -247,9 +270,9 @@ public class LocationSettings extends LocationSettingsBase @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); + setLocationMode(android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); } else { - setLocationMode(Settings.Secure.LOCATION_MODE_OFF); + setLocationMode(android.provider.Settings.Secure.LOCATION_MODE_OFF); } } } diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java index 5708434..164f4e7 100644 --- a/src/com/android/settings/location/RecentLocationApps.java +++ b/src/com/android/settings/location/RecentLocationApps.java @@ -26,10 +26,10 @@ import android.os.Bundle; import android.os.Process; import android.os.UserHandle; import android.preference.Preference; -import android.preference.PreferenceActivity; import android.util.Log; import com.android.settings.R; +import com.android.settings.SettingsActivity; import com.android.settings.applications.InstalledAppDetails; import java.util.ArrayList; @@ -44,10 +44,10 @@ public class RecentLocationApps { private static final int RECENT_TIME_INTERVAL_MILLIS = 15 * 60 * 1000; - private final PreferenceActivity mActivity; + private final SettingsActivity mActivity; private final PackageManager mPackageManager; - public RecentLocationApps(PreferenceActivity activity) { + public RecentLocationApps(SettingsActivity activity) { mActivity = activity; mPackageManager = activity.getPackageManager(); } |