Fix ProgressCategory theming and layout
- add missing constructors for correct theming - fix layout by adding missing paddingStart / paddingEnd Change-Id: I52a511d326b760a47339b2b9dad349c9f825dbd2
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="?android:attr/listSeparatorTextViewStyle"
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" >
|
||||||
|
|
||||||
<!-- This text view has the style of the list separator text view without the background and padding. -->
|
<!-- This text view has the style of the list separator text view without the background and padding. -->
|
||||||
<TextView
|
<TextView
|
||||||
|
@@ -21,17 +21,35 @@ import android.preference.Preference;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A category with a progress spinner
|
||||||
|
*/
|
||||||
public class ProgressCategory extends ProgressCategoryBase {
|
public class ProgressCategory extends ProgressCategoryBase {
|
||||||
|
|
||||||
private final int mEmptyTextRes;
|
private int mEmptyTextRes;
|
||||||
private boolean mProgress = false;
|
private boolean mProgress = false;
|
||||||
private Preference mNoDeviceFoundPreference;
|
private Preference mNoDeviceFoundPreference;
|
||||||
private boolean mNoDeviceFoundAdded;
|
private boolean mNoDeviceFoundAdded;
|
||||||
|
|
||||||
|
public ProgressCategory(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressCategory(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public ProgressCategory(Context context, AttributeSet attrs,
|
public ProgressCategory(Context context, AttributeSet attrs,
|
||||||
int emptyTextRes) {
|
int defStyleAttr) {
|
||||||
super(context, attrs);
|
this(context, attrs, defStyleAttr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
setLayoutResource(R.layout.preference_progress_category);
|
setLayoutResource(R.layout.preference_progress_category);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmptyTextRes(int emptyTextRes) {
|
||||||
mEmptyTextRes = emptyTextRes;
|
mEmptyTextRes = emptyTextRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,8 +21,21 @@ import android.preference.PreferenceCategory;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
public abstract class ProgressCategoryBase extends PreferenceCategory {
|
public abstract class ProgressCategoryBase extends PreferenceCategory {
|
||||||
|
public ProgressCategoryBase(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
public ProgressCategoryBase(Context context, AttributeSet attrs) {
|
public ProgressCategoryBase(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressCategoryBase(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressCategoryBase(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
|
int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -22,8 +22,26 @@ import com.android.settings.R;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Bluetooth discovery progress category
|
||||||
|
*/
|
||||||
public class BluetoothProgressCategory extends ProgressCategory {
|
public class BluetoothProgressCategory extends ProgressCategory {
|
||||||
|
public BluetoothProgressCategory(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
public BluetoothProgressCategory(Context context, AttributeSet attrs) {
|
public BluetoothProgressCategory(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs, R.string.bluetooth_no_devices_found);
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
this(context, attrs, defStyleAttr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluetoothProgressCategory(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
|
int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
|
setEmptyTextRes(R.string.bluetooth_no_devices_found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -292,7 +292,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
|
|||||||
|
|
||||||
// Available devices category
|
// Available devices category
|
||||||
if (mAvailableDevicesCategory == null) {
|
if (mAvailableDevicesCategory == null) {
|
||||||
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity(), null);
|
mAvailableDevicesCategory = new BluetoothProgressCategory(getActivity());
|
||||||
} else {
|
} else {
|
||||||
mAvailableDevicesCategory.removeAll();
|
mAvailableDevicesCategory.removeAll();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user