am be9ebb44
: Merge "Minor UI tweakings" into klp-dev
* commit 'be9ebb4436678ab5afecccc8a4bb7b9be6af370a': Minor UI tweakings
This commit is contained in:
47
res/layout/location_list_no_item.xml
Normal file
47
res/layout/location_list_no_item.xml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- text that appears when the recent app list is empty -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingEnd="?android:attr/scrollbarSize"
|
||||||
|
android:background="?android:attr/selectableItemBackground" >
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="15dip"
|
||||||
|
android:layout_marginEnd="6dip"
|
||||||
|
android:layout_marginTop="6dip"
|
||||||
|
android:layout_marginBottom="6dip"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<TextView android:id="@+android:id/title"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@@ -2377,8 +2377,8 @@
|
|||||||
<string name="location_mode_location_off_title">Location off</string>
|
<string name="location_mode_location_off_title">Location off</string>
|
||||||
<!-- [CHAR LIMIT=30] Location settings screen, sub category for recent location requests -->
|
<!-- [CHAR LIMIT=30] Location settings screen, sub category for recent location requests -->
|
||||||
<string name="location_category_recent_location_requests">Recent location requests</string>
|
<string name="location_category_recent_location_requests">Recent location requests</string>
|
||||||
<!-- [CHAR LIMIT=30] Location settings screen, displayed when there's no recent app accessing location -->
|
<!-- Location settings screen, displayed when there's no recent app accessing location -->
|
||||||
<string name="location_no_recent_apps">No recent apps</string>
|
<string name="location_no_recent_apps">No apps have requested location in the last 15 minutes.</string>
|
||||||
<!-- [CHAR LIMIT=30] Location settings screen, sub category for location services -->
|
<!-- [CHAR LIMIT=30] Location settings screen, sub category for location services -->
|
||||||
<string name="location_category_location_services">Location services</string>
|
<string name="location_category_location_services">Location services</string>
|
||||||
<!-- [CHAR LIMIT=30] Location settings screen, recent location requests high battery use-->
|
<!-- [CHAR LIMIT=30] Location settings screen, recent location requests high battery use-->
|
||||||
|
@@ -16,10 +16,7 @@
|
|||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/location_settings_title">
|
android:title="@string/location_settings_title">
|
||||||
<PreferenceScreen
|
<Preference
|
||||||
android:title="Under Construction"
|
|
||||||
android:summary="This page is under construction and everything here is expected to be broken for a while. Keep calm and carry on!" />
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="location_mode"
|
android:key="location_mode"
|
||||||
android:title="@string/location_mode_title"
|
android:title="@string/location_mode_title"
|
||||||
android:summary="@string/location_mode_location_off_title" />
|
android:summary="@string/location_mode_location_off_title" />
|
||||||
|
@@ -52,9 +52,7 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
|
|
||||||
private Switch mSwitch;
|
private Switch mSwitch;
|
||||||
private boolean mValidListener;
|
private boolean mValidListener;
|
||||||
private PreferenceScreen mLocationMode;
|
private Preference mLocationMode;
|
||||||
private PreferenceCategory mRecentLocationRequests;
|
|
||||||
private PreferenceCategory mLocationServices;
|
|
||||||
|
|
||||||
private BatteryStatsHelper mStatsHelper;
|
private BatteryStatsHelper mStatsHelper;
|
||||||
|
|
||||||
@@ -125,7 +123,7 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
addPreferencesFromResource(R.xml.location_settings);
|
addPreferencesFromResource(R.xml.location_settings);
|
||||||
root = getPreferenceScreen();
|
root = getPreferenceScreen();
|
||||||
|
|
||||||
mLocationMode = (PreferenceScreen) root.findPreference(KEY_LOCATION_MODE);
|
mLocationMode = root.findPreference(KEY_LOCATION_MODE);
|
||||||
mLocationMode.setOnPreferenceClickListener(
|
mLocationMode.setOnPreferenceClickListener(
|
||||||
new Preference.OnPreferenceClickListener() {
|
new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -140,25 +138,31 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
|
|
||||||
final PreferenceManager preferenceManager = getPreferenceManager();
|
final PreferenceManager preferenceManager = getPreferenceManager();
|
||||||
|
|
||||||
mRecentLocationRequests =
|
PreferenceCategory categoryRecentLocationRequests =
|
||||||
(PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
(PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
||||||
RecentLocationApps recentApps = new RecentLocationApps(activity, mStatsHelper);
|
RecentLocationApps recentApps = new RecentLocationApps(activity, mStatsHelper);
|
||||||
List<Preference> recentLocationRequests = recentApps.getAppList(preferenceManager);
|
List<Preference> recentLocationRequests = recentApps.getAppList();
|
||||||
if (recentLocationRequests.size() > 0) {
|
if (recentLocationRequests.size() > 0) {
|
||||||
addPreferencesSorted(recentLocationRequests, mRecentLocationRequests);
|
addPreferencesSorted(recentLocationRequests, categoryRecentLocationRequests);
|
||||||
} else {
|
} else {
|
||||||
// If there's no item to display, add a "No recent apps" item.
|
// If there's no item to display, add a "No recent apps" item.
|
||||||
PreferenceScreen screen = preferenceManager.createPreferenceScreen(activity);
|
Preference banner = new Preference(activity);
|
||||||
screen.setTitle(R.string.location_no_recent_apps);
|
banner.setLayoutResource(R.layout.location_list_no_item);
|
||||||
screen.setSelectable(false);
|
banner.setTitle(R.string.location_no_recent_apps);
|
||||||
screen.setEnabled(false);
|
banner.setSelectable(false);
|
||||||
mRecentLocationRequests.addPreference(screen);
|
banner.setEnabled(false);
|
||||||
|
categoryRecentLocationRequests.addPreference(banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
mLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
|
PreferenceCategory categoryLocationServices =
|
||||||
List<Preference> locationServices = SettingsInjector.getInjectedSettings(
|
(PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
|
||||||
activity, preferenceManager);
|
List<Preference> locationServices = SettingsInjector.getInjectedSettings(activity);
|
||||||
addPreferencesSorted(locationServices, mLocationServices);
|
if (locationServices.size() > 0) {
|
||||||
|
addPreferencesSorted(locationServices, categoryLocationServices);
|
||||||
|
} else {
|
||||||
|
// If there's no item to display, remove the whole category.
|
||||||
|
root.removePreference(categoryLocationServices);
|
||||||
|
}
|
||||||
|
|
||||||
// Only show the master switch when we're not in multi-pane mode, and not being used as
|
// Only show the master switch when we're not in multi-pane mode, and not being used as
|
||||||
// Setup Wizard.
|
// Setup Wizard.
|
||||||
@@ -206,7 +210,6 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
|
|
||||||
boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
|
boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
|
||||||
mLocationMode.setEnabled(enabled);
|
mLocationMode.setEnabled(enabled);
|
||||||
mLocationServices.setEnabled(enabled);
|
|
||||||
|
|
||||||
if (enabled != mSwitch.isChecked()) {
|
if (enabled != mSwitch.isChecked()) {
|
||||||
// set listener to null so that that code below doesn't trigger onCheckedChanged()
|
// set listener to null so that that code below doesn't trigger onCheckedChanged()
|
||||||
|
@@ -24,8 +24,6 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -93,22 +91,21 @@ public class RecentLocationApps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PreferenceScreen createRecentLocationEntry(
|
private Preference createRecentLocationEntry(
|
||||||
PreferenceManager preferenceManager,
|
|
||||||
Drawable icon,
|
Drawable icon,
|
||||||
CharSequence label,
|
CharSequence label,
|
||||||
boolean isHighBattery,
|
boolean isHighBattery,
|
||||||
Preference.OnPreferenceClickListener listener) {
|
Preference.OnPreferenceClickListener listener) {
|
||||||
PreferenceScreen screen = preferenceManager.createPreferenceScreen(mActivity);
|
Preference pref = new Preference(mActivity);
|
||||||
screen.setIcon(icon);
|
pref.setIcon(icon);
|
||||||
screen.setTitle(label);
|
pref.setTitle(label);
|
||||||
if (isHighBattery) {
|
if (isHighBattery) {
|
||||||
screen.setSummary(R.string.location_high_battery_use);
|
pref.setSummary(R.string.location_high_battery_use);
|
||||||
} else {
|
} else {
|
||||||
screen.setSummary(R.string.location_low_battery_use);
|
pref.setSummary(R.string.location_low_battery_use);
|
||||||
}
|
}
|
||||||
screen.setOnPreferenceClickListener(listener);
|
pref.setOnPreferenceClickListener(listener);
|
||||||
return screen;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +137,7 @@ public class RecentLocationApps {
|
|||||||
* Fills a list of applications which queried location recently within
|
* Fills a list of applications which queried location recently within
|
||||||
* specified time.
|
* specified time.
|
||||||
*/
|
*/
|
||||||
public List<Preference> getAppList(PreferenceManager preferenceManager) {
|
public List<Preference> getAppList() {
|
||||||
// Retrieve Uid-based battery blaming info and generate a package to BatterySipper HashMap
|
// Retrieve Uid-based battery blaming info and generate a package to BatterySipper HashMap
|
||||||
// for later faster looking up.
|
// for later faster looking up.
|
||||||
mStatsHelper.refreshStats();
|
mStatsHelper.refreshStats();
|
||||||
@@ -169,9 +166,9 @@ public class RecentLocationApps {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
for (AppOpsManager.PackageOps ops : appOps) {
|
for (AppOpsManager.PackageOps ops : appOps) {
|
||||||
BatterySipperWrapper wrapper = sipperMap.get(ops.getUid());
|
BatterySipperWrapper wrapper = sipperMap.get(ops.getUid());
|
||||||
PreferenceScreen screen = getScreenFromOps(preferenceManager, now, ops, wrapper);
|
Preference pref = getPreferenceFromOps(now, ops, wrapper);
|
||||||
if (screen != null) {
|
if (pref != null) {
|
||||||
prefs.add(screen);
|
prefs.add(pref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,19 +176,17 @@ public class RecentLocationApps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PreferenceScreen entry for the given PackageOps.
|
* Creates a Preference entry for the given PackageOps.
|
||||||
*
|
*
|
||||||
* This method examines the time interval of the PackageOps first. If the PackageOps is older
|
* This method examines the time interval of the PackageOps first. If the PackageOps is older
|
||||||
* than the designated interval, this method ignores the PackageOps object and returns null.
|
* than the designated interval, this method ignores the PackageOps object and returns null.
|
||||||
*
|
*
|
||||||
* When the PackageOps is fresh enough, if the package has a corresponding battery blaming entry
|
* When the PackageOps is fresh enough, if the package has a corresponding battery blaming entry
|
||||||
* in the Uid-based battery sipper list, this method returns a PreferenceScreen pointing to the
|
* in the Uid-based battery sipper list, this method returns a Preference pointing to the Uid
|
||||||
* Uid battery blaming page. If the package doesn't have a battery sipper entry (typically
|
* battery blaming page. If the package doesn't have a battery sipper entry (typically shouldn't
|
||||||
* shouldn't happen), this method returns a PreferenceScreen pointing to the App Info page for
|
* happen), this method returns a Preference pointing to the App Info page for that package.
|
||||||
* that package.
|
|
||||||
*/
|
*/
|
||||||
private PreferenceScreen getScreenFromOps(
|
private Preference getPreferenceFromOps(
|
||||||
PreferenceManager preferenceManager,
|
|
||||||
long now,
|
long now,
|
||||||
AppOpsManager.PackageOps ops,
|
AppOpsManager.PackageOps ops,
|
||||||
BatterySipperWrapper wrapper) {
|
BatterySipperWrapper wrapper) {
|
||||||
@@ -224,7 +219,7 @@ public class RecentLocationApps {
|
|||||||
|
|
||||||
// The package is fresh enough, continue.
|
// The package is fresh enough, continue.
|
||||||
|
|
||||||
PreferenceScreen screen = null;
|
Preference pref = null;
|
||||||
if (wrapper != null) {
|
if (wrapper != null) {
|
||||||
// Contains sipper. Link to Battery Blaming page.
|
// Contains sipper. Link to Battery Blaming page.
|
||||||
|
|
||||||
@@ -233,8 +228,7 @@ public class RecentLocationApps {
|
|||||||
if (!wrapper.used()) {
|
if (!wrapper.used()) {
|
||||||
BatterySipper sipper = wrapper.batterySipper();
|
BatterySipper sipper = wrapper.batterySipper();
|
||||||
sipper.loadNameAndIcon();
|
sipper.loadNameAndIcon();
|
||||||
screen = createRecentLocationEntry(
|
pref = createRecentLocationEntry(
|
||||||
preferenceManager,
|
|
||||||
sipper.getIcon(),
|
sipper.getIcon(),
|
||||||
sipper.getLabel(),
|
sipper.getLabel(),
|
||||||
highBattery,
|
highBattery,
|
||||||
@@ -249,8 +243,7 @@ public class RecentLocationApps {
|
|||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = mPackageManager.getApplicationInfo(
|
ApplicationInfo appInfo = mPackageManager.getApplicationInfo(
|
||||||
packageName, PackageManager.GET_META_DATA);
|
packageName, PackageManager.GET_META_DATA);
|
||||||
screen = createRecentLocationEntry(
|
pref = createRecentLocationEntry(
|
||||||
preferenceManager,
|
|
||||||
mPackageManager.getApplicationIcon(appInfo),
|
mPackageManager.getApplicationIcon(appInfo),
|
||||||
mPackageManager.getApplicationLabel(appInfo),
|
mPackageManager.getApplicationLabel(appInfo),
|
||||||
highBattery,
|
highBattery,
|
||||||
@@ -260,6 +253,6 @@ public class RecentLocationApps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return screen;
|
return pref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,8 +31,6 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -240,14 +238,13 @@ class SettingsInjector {
|
|||||||
* TODO: extract InjectedLocationSettingGetter that returns an iterable over
|
* TODO: extract InjectedLocationSettingGetter that returns an iterable over
|
||||||
* InjectedSetting objects, so that this class can focus on UI
|
* InjectedSetting objects, so that this class can focus on UI
|
||||||
*/
|
*/
|
||||||
public static List<Preference> getInjectedSettings(Context context,
|
public static List<Preference> getInjectedSettings(Context context) {
|
||||||
PreferenceManager preferenceManager) {
|
|
||||||
|
|
||||||
Iterable<InjectedSetting> settings = getSettings(context);
|
Iterable<InjectedSetting> settings = getSettings(context);
|
||||||
ArrayList<Preference> prefs = new ArrayList<Preference>();
|
ArrayList<Preference> prefs = new ArrayList<Preference>();
|
||||||
StatusLoader loader = null;
|
StatusLoader loader = null;
|
||||||
for (InjectedSetting setting : settings) {
|
for (InjectedSetting setting : settings) {
|
||||||
Preference pref = addServiceSetting(context, prefs, setting, preferenceManager);
|
Preference pref = addServiceSetting(context, prefs, setting);
|
||||||
Intent intent = createUpdatingIntent(context, pref, setting, loader);
|
Intent intent = createUpdatingIntent(context, pref, setting, loader);
|
||||||
loader = new StatusLoader(context, intent, loader);
|
loader = new StatusLoader(context, intent, loader);
|
||||||
}
|
}
|
||||||
@@ -263,22 +260,21 @@ class SettingsInjector {
|
|||||||
/**
|
/**
|
||||||
* Adds an injected setting to the root with status "Loading...".
|
* Adds an injected setting to the root with status "Loading...".
|
||||||
*/
|
*/
|
||||||
private static PreferenceScreen addServiceSetting(Context context,
|
private static Preference addServiceSetting(
|
||||||
List<Preference> prefs, InjectedSetting info, PreferenceManager preferenceManager) {
|
Context context, List<Preference> prefs, InjectedSetting info) {
|
||||||
|
Preference pref = new Preference(context);
|
||||||
PreferenceScreen screen = preferenceManager.createPreferenceScreen(context);
|
pref.setTitle(info.title);
|
||||||
screen.setTitle(info.title);
|
pref.setSummary(R.string.location_loading_injected_setting);
|
||||||
screen.setSummary(R.string.location_loading_injected_setting);
|
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
Drawable icon = pm.getDrawable(info.packageName, info.iconId, null);
|
Drawable icon = pm.getDrawable(info.packageName, info.iconId, null);
|
||||||
screen.setIcon(icon);
|
pref.setIcon(icon);
|
||||||
|
|
||||||
Intent settingIntent = new Intent();
|
Intent settingIntent = new Intent();
|
||||||
settingIntent.setClassName(info.packageName, info.settingsActivity);
|
settingIntent.setClassName(info.packageName, info.settingsActivity);
|
||||||
screen.setIntent(settingIntent);
|
pref.setIntent(settingIntent);
|
||||||
|
|
||||||
prefs.add(screen);
|
prefs.add(pref);
|
||||||
return screen;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user