Left align preferences and graphs to leave space for icon.
Bug: 33559277 Test: Visual inspection Change-Id: Iacf9556826174a03b1cbf8a6f179b63d8686c5f5
This commit is contained in:
@@ -33,16 +33,19 @@ public class ProgressCategory extends ProgressCategoryBase {
|
||||
private boolean mNoDeviceFoundAdded;
|
||||
|
||||
public ProgressCategory(Context context) {
|
||||
this(context, null);
|
||||
super(context);
|
||||
setLayoutResource(R.layout.preference_progress_category);
|
||||
}
|
||||
|
||||
public ProgressCategory(Context context, AttributeSet attrs) {
|
||||
super(context, attrs, 0);
|
||||
super(context, attrs);
|
||||
setLayoutResource(R.layout.preference_progress_category);
|
||||
}
|
||||
|
||||
public ProgressCategory(Context context, AttributeSet attrs,
|
||||
int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
super(context, attrs, defStyleAttr);
|
||||
setLayoutResource(R.layout.preference_progress_category);
|
||||
}
|
||||
|
||||
public ProgressCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
@@ -71,7 +74,7 @@ public class ProgressCategory extends ProgressCategoryBase {
|
||||
} else {
|
||||
if (!mNoDeviceFoundAdded) {
|
||||
if (mNoDeviceFoundPreference == null) {
|
||||
mNoDeviceFoundPreference = new Preference(getPreferenceManager().getContext());
|
||||
mNoDeviceFoundPreference = new Preference(getContext());
|
||||
mNoDeviceFoundPreference.setLayoutResource(R.layout.preference_empty_list);
|
||||
mNoDeviceFoundPreference.setTitle(mEmptyTextRes);
|
||||
mNoDeviceFoundPreference.setSelectable(false);
|
||||
|
@@ -22,24 +22,25 @@ import android.util.AttributeSet;
|
||||
|
||||
public abstract class ProgressCategoryBase extends PreferenceCategory {
|
||||
public ProgressCategoryBase(Context context) {
|
||||
this(context, null);
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ProgressCategoryBase(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ProgressCategoryBase(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr, 0);
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public ProgressCategoryBase(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on/off the progress indicator and text on the right.
|
||||
*
|
||||
* @param progressOn whether or not the progress should be displayed
|
||||
*/
|
||||
public abstract void setProgress(boolean progressOn);
|
||||
|
@@ -52,25 +52,25 @@ import java.util.Iterator;
|
||||
public class RunningProcessesView extends FrameLayout
|
||||
implements AdapterView.OnItemClickListener, RecyclerListener,
|
||||
RunningState.OnRefreshUiListener {
|
||||
|
||||
|
||||
final int mMyUserId;
|
||||
|
||||
long SECONDARY_SERVER_MEM;
|
||||
|
||||
|
||||
final HashMap<View, ActiveItem> mActiveItems = new HashMap<View, ActiveItem>();
|
||||
|
||||
ActivityManager mAm;
|
||||
|
||||
|
||||
RunningState mState;
|
||||
|
||||
|
||||
Fragment mOwner;
|
||||
|
||||
|
||||
Runnable mDataAvail;
|
||||
|
||||
StringBuilder mBuilder = new StringBuilder(128);
|
||||
|
||||
|
||||
RunningState.BaseItem mCurSelected;
|
||||
|
||||
|
||||
ListView mListView;
|
||||
View mHeader;
|
||||
ServiceListAdapter mAdapter;
|
||||
@@ -102,19 +102,19 @@ public class RunningProcessesView extends FrameLayout
|
||||
|
||||
void updateTime(Context context, StringBuilder builder) {
|
||||
TextView uptimeView = null;
|
||||
|
||||
|
||||
if (mItem instanceof RunningState.ServiceItem) {
|
||||
// If we are displaying a service, then the service
|
||||
// uptime goes at the top.
|
||||
uptimeView = mHolder.size;
|
||||
|
||||
|
||||
} else {
|
||||
String size = mItem.mSizeStr != null ? mItem.mSizeStr : "";
|
||||
if (!size.equals(mItem.mCurSizeStr)) {
|
||||
mItem.mCurSizeStr = size;
|
||||
mHolder.size.setText(size);
|
||||
}
|
||||
|
||||
|
||||
if (mItem.mBackground) {
|
||||
// This is a background process; no uptime.
|
||||
if (!mSetBackground) {
|
||||
@@ -150,7 +150,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ViewHolder {
|
||||
public View rootView;
|
||||
public ImageView icon;
|
||||
@@ -158,7 +158,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
public TextView description;
|
||||
public TextView size;
|
||||
public TextView uptime;
|
||||
|
||||
|
||||
public ViewHolder(View v) {
|
||||
rootView = v;
|
||||
icon = (ImageView)v.findViewById(R.id.icon);
|
||||
@@ -168,7 +168,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
uptime = (TextView)v.findViewById(R.id.uptime);
|
||||
v.setTag(this);
|
||||
}
|
||||
|
||||
|
||||
public ActiveItem bind(RunningState state, RunningState.BaseItem item,
|
||||
StringBuilder builder) {
|
||||
synchronized (state.mLock) {
|
||||
@@ -202,13 +202,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TimeTicker extends TextView {
|
||||
public TimeTicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ServiceListAdapter extends BaseAdapter {
|
||||
final RunningState mState;
|
||||
final LayoutInflater mInflater;
|
||||
@@ -216,7 +210,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
ArrayList<RunningState.MergedItem> mOrigItems;
|
||||
final ArrayList<RunningState.MergedItem> mItems
|
||||
= new ArrayList<RunningState.MergedItem>();
|
||||
|
||||
|
||||
ServiceListAdapter(RunningState state) {
|
||||
mState = state;
|
||||
mInflater = (LayoutInflater)getContext().getSystemService(
|
||||
@@ -254,11 +248,11 @@ public class RunningProcessesView extends FrameLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasStableIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public int getCount() {
|
||||
return mItems.size();
|
||||
}
|
||||
@@ -294,13 +288,13 @@ public class RunningProcessesView extends FrameLayout
|
||||
bindView(v, position);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
public View newView(ViewGroup parent) {
|
||||
View v = mInflater.inflate(R.layout.running_processes_item, parent, false);
|
||||
new ViewHolder(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
public void bindView(View view, int position) {
|
||||
synchronized (mState.mLock) {
|
||||
if (position >= mItems.size()) {
|
||||
@@ -323,7 +317,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
adapter.refreshItems();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
if (mDataAvail != null) {
|
||||
mDataAvail.run();
|
||||
mDataAvail = null;
|
||||
@@ -396,7 +390,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
ListView l = (ListView)parent;
|
||||
RunningState.MergedItem mi = (RunningState.MergedItem)l.getAdapter().getItem(position);
|
||||
@@ -421,7 +415,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
R.string.runningservicedetails_settings_title, null, null, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onMovedToScrapHeap(View view) {
|
||||
mActiveItems.remove(view);
|
||||
}
|
||||
@@ -430,7 +424,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
super(context, attrs);
|
||||
mMyUserId = UserHandle.myUserId();
|
||||
}
|
||||
|
||||
|
||||
public void doCreate() {
|
||||
mAm = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
mState = RunningState.getInstance(getContext());
|
||||
@@ -464,7 +458,7 @@ public class RunningProcessesView extends FrameLayout
|
||||
mAm.getMemoryInfo(memInfo);
|
||||
SECONDARY_SERVER_MEM = memInfo.secondaryServerThreshold;
|
||||
}
|
||||
|
||||
|
||||
public void doPause() {
|
||||
mState.pause();
|
||||
mDataAvail = null;
|
||||
|
@@ -65,9 +65,9 @@ public final class BluetoothDevicePreference extends Preference implements
|
||||
|
||||
/* Talk-back descriptions for various BT icons */
|
||||
Resources r = getContext().getResources();
|
||||
public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer);
|
||||
public final String COMPUTER = r.getString(R.string.bluetooth_talkback_computer);
|
||||
public final String INPUT_PERIPHERAL = r.getString(
|
||||
R.string.bluetooth_talkback_input_peripheral);
|
||||
R.string.bluetooth_talkback_input_peripheral);
|
||||
public final String HEADSET = r.getString(R.string.bluetooth_talkback_headset);
|
||||
public final String PHONE = r.getString(R.string.bluetooth_talkback_phone);
|
||||
public final String IMAGING = r.getString(R.string.bluetooth_talkback_imaging);
|
||||
@@ -85,11 +85,9 @@ public final class BluetoothDevicePreference extends Preference implements
|
||||
|
||||
mCachedDevice = cachedDevice;
|
||||
|
||||
setLayoutResource(R.layout.preference_bt_icon);
|
||||
|
||||
if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
|
||||
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
if (! um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
|
||||
if (!um.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
|
||||
setWidgetLayoutResource(R.layout.preference_bluetooth);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +264,7 @@ public final class BluetoothDevicePreference extends Preference implements
|
||||
|
||||
case BluetoothClass.Device.Major.PERIPHERAL:
|
||||
return new Pair<Integer, String>(HidProfile.getHidClassDrawable(btClass),
|
||||
INPUT_PERIPHERAL);
|
||||
INPUT_PERIPHERAL);
|
||||
|
||||
case BluetoothClass.Device.Major.IMAGING:
|
||||
return new Pair<Integer, String>(R.drawable.ic_bt_imaging, IMAGING);
|
||||
|
@@ -27,21 +27,28 @@ import com.android.settings.R;
|
||||
*/
|
||||
public class BluetoothProgressCategory extends ProgressCategory {
|
||||
public BluetoothProgressCategory(Context context) {
|
||||
this(context, null);
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public BluetoothProgressCategory(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setIcon(R.drawable.ic_settings_bluetooth);
|
||||
setEmptyTextRes(R.string.bluetooth_no_devices_found);
|
||||
}
|
||||
}
|
||||
|
@@ -161,13 +161,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
||||
@Override
|
||||
void addPreferencesForActivity() {
|
||||
addPreferencesFromResource(R.xml.bluetooth_settings);
|
||||
|
||||
mPairedDevicesCategory = new PreferenceCategory(getPrefContext());
|
||||
final Context prefContext = getPrefContext();
|
||||
mPairedDevicesCategory = new PreferenceCategory(prefContext);
|
||||
mPairedDevicesCategory.setKey(KEY_PAIRED_DEVICES);
|
||||
mPairedDevicesCategory.setOrder(1);
|
||||
getPreferenceScreen().addPreference(mPairedDevicesCategory);
|
||||
|
||||
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity());
|
||||
mAvailableDevicesCategory = new BluetoothProgressCategory(prefContext);
|
||||
mAvailableDevicesCategory.setSelectable(false);
|
||||
mAvailableDevicesCategory.setOrder(2);
|
||||
getPreferenceScreen().addPreference(mAvailableDevicesCategory);
|
||||
|
@@ -25,6 +25,7 @@ import android.os.Looper;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.Settings.Global;
|
||||
import android.support.v4.content.res.TypedArrayUtils;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
@@ -53,7 +54,9 @@ public class CellDataPreference extends CustomDialogPreference implements Templa
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
|
||||
public CellDataPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs, android.R.attr.switchPreferenceStyle);
|
||||
super(context, attrs, TypedArrayUtils.getAttr(context,
|
||||
android.support.v7.preference.R.attr.switchPreferenceStyle,
|
||||
android.R.attr.switchPreferenceStyle));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -46,14 +46,6 @@ import java.lang.ref.WeakReference;
|
||||
import static android.content.Context.CONNECTIVITY_SERVICE;
|
||||
import static android.content.Context.WIFI_SERVICE;
|
||||
|
||||
/**
|
||||
* Display the following information
|
||||
* # Battery Strength : TODO
|
||||
* # Uptime
|
||||
* # Awake Time
|
||||
* # XMPP/buzz/tickle status : TODO
|
||||
*
|
||||
*/
|
||||
public class Status extends SettingsPreferenceFragment {
|
||||
|
||||
private static final String KEY_BATTERY_STATUS = "battery_status";
|
||||
|
Reference in New Issue
Block a user