Use the new Preference:icon attribute and placeholder for showing icons on the left.
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 1012 B After Width: | Height: | Size: 320 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 311 B  | 
@@ -14,51 +14,8 @@
 | 
			
		||||
     limitations under the License.
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<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:paddingLeft="16dip"
 | 
			
		||||
    android:paddingRight="?android:attr/scrollbarSize">
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
        android:id="@+id/providerIcon"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="5dip"
 | 
			
		||||
        android:layout_gravity="center" />
 | 
			
		||||
 | 
			
		||||
    <RelativeLayout
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="6dip"
 | 
			
		||||
        android:layout_marginTop="6dip"
 | 
			
		||||
        android:layout_marginBottom="6dip"
 | 
			
		||||
        android:layout_weight="1">
 | 
			
		||||
 | 
			
		||||
        <TextView android:id="@+android:id/title"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:singleLine="true"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceMedium" />
 | 
			
		||||
 | 
			
		||||
        <TextView android:id="@+android:id/summary"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_below="@android:id/title"
 | 
			
		||||
            android:layout_alignLeft="@android:id/title"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceSmall"
 | 
			
		||||
            android:maxLines="2" />
 | 
			
		||||
 | 
			
		||||
    </RelativeLayout>
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
        android:id="@+id/syncStatusIcon"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginLeft="5dip"
 | 
			
		||||
        android:layout_marginRight="7dip"
 | 
			
		||||
        android:layout_gravity="center" />
 | 
			
		||||
 | 
			
		||||
</LinearLayout>
 | 
			
		||||
 
 | 
			
		||||
@@ -17,49 +17,14 @@
 | 
			
		||||
<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:paddingLeft="16dip"
 | 
			
		||||
    android:paddingRight="?android:attr/scrollbarSize">
 | 
			
		||||
    android:gravity="center_vertical">
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
        android:id="@+id/btClass"
 | 
			
		||||
    <LinearLayout android:id="@+id/profileIcons"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="12dip"
 | 
			
		||||
        android:layout_gravity="center_vertical" />
 | 
			
		||||
 | 
			
		||||
    <RelativeLayout
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="6dip"
 | 
			
		||||
        android:layout_marginTop="6dip"
 | 
			
		||||
        android:layout_marginBottom="6dip"
 | 
			
		||||
        android:layout_weight="1">
 | 
			
		||||
 | 
			
		||||
        <!-- Device name -->
 | 
			
		||||
        <TextView android:id="@+android:id/title"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:singleLine="true"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceLarge" />
 | 
			
		||||
 | 
			
		||||
        <!-- Status summary -->
 | 
			
		||||
        <TextView android:id="@+android:id/summary"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_below="@android:id/title"
 | 
			
		||||
            android:layout_alignLeft="@android:id/title"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceSmall"
 | 
			
		||||
            android:maxLines="2" />
 | 
			
		||||
 | 
			
		||||
        <LinearLayout android:id="@+id/profileIcons"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_centerVertical="true"
 | 
			
		||||
            android:layout_alignParentRight="true"
 | 
			
		||||
            />
 | 
			
		||||
    </RelativeLayout>
 | 
			
		||||
        android:layout_centerVertical="true"
 | 
			
		||||
        android:layout_alignParentRight="true"
 | 
			
		||||
        />
 | 
			
		||||
 | 
			
		||||
    <!-- Divider -->
 | 
			
		||||
    <ImageView
 | 
			
		||||
 
 | 
			
		||||
@@ -15,51 +15,9 @@
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_width="wrap_content"
 | 
			
		||||
    android:layout_height="wrap_content"
 | 
			
		||||
    android:minHeight="?android:attr/listPreferredItemHeight"
 | 
			
		||||
    android:gravity="center_vertical"
 | 
			
		||||
    android:paddingLeft="16dip"
 | 
			
		||||
    android:paddingRight="?android:attr/scrollbarSize">
 | 
			
		||||
 | 
			
		||||
    <ImageView
 | 
			
		||||
        android:id="@+id/profileIcon"
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="12dip"
 | 
			
		||||
        android:layout_gravity="center_vertical" />
 | 
			
		||||
 | 
			
		||||
    <RelativeLayout
 | 
			
		||||
        android:layout_width="wrap_content"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:layout_marginRight="6dip"
 | 
			
		||||
        android:layout_marginTop="6dip"
 | 
			
		||||
        android:layout_marginBottom="6dip"
 | 
			
		||||
        android:layout_weight="1">
 | 
			
		||||
 | 
			
		||||
        <!-- Device name -->
 | 
			
		||||
        <TextView android:id="@+android:id/title"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:singleLine="true"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceLarge" />
 | 
			
		||||
 | 
			
		||||
        <!-- Status summary -->
 | 
			
		||||
        <TextView android:id="@+android:id/summary"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_below="@android:id/title"
 | 
			
		||||
            android:layout_alignLeft="@android:id/title"
 | 
			
		||||
            android:textAppearance="?android:attr/textAppearanceSmall"
 | 
			
		||||
            android:maxLines="2" />
 | 
			
		||||
 | 
			
		||||
        <LinearLayout android:id="@+id/profileIcons"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_centerVertical="true"
 | 
			
		||||
            android:layout_alignParentRight="true"
 | 
			
		||||
            />
 | 
			
		||||
    </RelativeLayout>
 | 
			
		||||
    android:gravity="center_vertical">
 | 
			
		||||
 | 
			
		||||
    <!-- Divider -->
 | 
			
		||||
    <ImageView
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ public class AccountPreference extends Preference {
 | 
			
		||||
        mAccount = account;
 | 
			
		||||
        mAuthorities = authorities;
 | 
			
		||||
        mProviderIcon = icon;
 | 
			
		||||
        setLayoutResource(R.layout.account_preference);
 | 
			
		||||
        setWidgetLayoutResource(R.layout.account_preference);
 | 
			
		||||
        setTitle(mAccount.name);
 | 
			
		||||
        setSummary("");
 | 
			
		||||
        // Add account info to the intent for AccountSyncSettings
 | 
			
		||||
@@ -72,7 +72,7 @@ public class AccountPreference extends Preference {
 | 
			
		||||
    protected void onBindView(View view) {
 | 
			
		||||
        super.onBindView(view);
 | 
			
		||||
        setSummary(getSyncStatusMessage(mStatus));
 | 
			
		||||
        mProviderIconView = (ImageView) view.findViewById(R.id.providerIcon);
 | 
			
		||||
        mProviderIconView = (ImageView) view.findViewById(android.R.id.icon);
 | 
			
		||||
        mProviderIconView.setImageDrawable(mProviderIcon);
 | 
			
		||||
        mSyncStatusIcon = (ImageView) view.findViewById(R.id.syncStatusIcon);
 | 
			
		||||
        mSyncStatusIcon.setImageResource(getSyncStatusIcon(mStatus));
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,7 @@ public class BluetoothDevicePreference extends Preference implements
 | 
			
		||||
        mCachedDevice = cachedDevice;
 | 
			
		||||
        mAccessibleProfile = accessibleProfile;
 | 
			
		||||
 | 
			
		||||
        setLayoutResource(R.layout.preference_bluetooth);
 | 
			
		||||
        setWidgetLayoutResource(R.layout.preference_bluetooth);
 | 
			
		||||
 | 
			
		||||
        cachedDevice.registerCallback(this);
 | 
			
		||||
 | 
			
		||||
@@ -127,7 +127,7 @@ public class BluetoothDevicePreference extends Preference implements
 | 
			
		||||
 | 
			
		||||
        super.onBindView(view);
 | 
			
		||||
 | 
			
		||||
        ImageView btClass = (ImageView) view.findViewById(R.id.btClass);
 | 
			
		||||
        ImageView btClass = (ImageView) view.findViewById(android.R.id.icon);
 | 
			
		||||
        btClass.setImageResource(mCachedDevice.getBtClassDrawable());
 | 
			
		||||
        btClass.setAlpha(isEnabled() ? 255 : sDimAlpha);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -48,7 +48,7 @@ public class BluetoothProfilePreference extends Preference implements OnClickLis
 | 
			
		||||
 | 
			
		||||
        mProfile = profile;
 | 
			
		||||
 | 
			
		||||
        setLayoutResource(R.layout.preference_bluetooth_profile);
 | 
			
		||||
        setWidgetLayoutResource(R.layout.preference_bluetooth_profile);
 | 
			
		||||
        setExpanded(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -73,7 +73,7 @@ public class BluetoothProfilePreference extends Preference implements OnClickLis
 | 
			
		||||
    protected void onBindView(View view) {
 | 
			
		||||
        super.onBindView(view);
 | 
			
		||||
 | 
			
		||||
        ImageView btProfile = (ImageView) view.findViewById(R.id.profileIcon);
 | 
			
		||||
        ImageView btProfile = (ImageView) view.findViewById(android.R.id.icon);
 | 
			
		||||
        btProfile.setImageDrawable(mProfileDrawable);
 | 
			
		||||
 | 
			
		||||
        mProfileExpandView = (ImageView) view.findViewById(R.id.profileExpand);
 | 
			
		||||
 
 | 
			
		||||
@@ -295,6 +295,7 @@ public class DeviceProfilesSettings extends SettingsPreferenceFragment
 | 
			
		||||
            CheckBoxPreference autoConnectPref = mAutoConnectPrefs.get(prof.toString());
 | 
			
		||||
            if (autoConnectPref == null) {
 | 
			
		||||
                autoConnectPref = new CheckBoxPreference(getActivity());
 | 
			
		||||
                autoConnectPref.setLayoutResource(com.android.internal.R.layout.preference_child);
 | 
			
		||||
                autoConnectPref.setKey(prof.toString() + AUTO_CONNECT_KEY_SUFFIX);
 | 
			
		||||
                autoConnectPref.setTitle(getCheckBoxTitle(prof));
 | 
			
		||||
                autoConnectPref.setOrder(getProfilePreferenceIndex(prof) + 1);
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,7 @@ public class PowerGaugePreference extends Preference {
 | 
			
		||||
        return mInfo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void setIcon(Drawable icon) {
 | 
			
		||||
    void setPowerIcon(Drawable icon) {
 | 
			
		||||
        mIcon = icon;
 | 
			
		||||
        notifyChanged();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -734,7 +734,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
 | 
			
		||||
                            (PowerGaugePreference) findPreference(
 | 
			
		||||
                                    Integer.toString(bs.uidObj.getUid()));
 | 
			
		||||
                    if (pgp != null) {
 | 
			
		||||
                        pgp.setIcon(bs.icon);
 | 
			
		||||
                        pgp.setPowerIcon(bs.icon);
 | 
			
		||||
                        pgp.setPercent(bs.percent);
 | 
			
		||||
                        pgp.setTitle(bs.name);
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user