OSDN Git Service

Use the new Preference:icon attribute and placeholder for showing icons on the left.
authorAmith Yamasani <yamasani@google.com>
Wed, 17 Nov 2010 23:21:18 +0000 (15:21 -0800)
committerAmith Yamasani <yamasani@google.com>
Thu, 18 Nov 2010 00:37:16 +0000 (16:37 -0800)
res/drawable-hdpi/nav_divider.png
res/drawable-mdpi/nav_divider.png
res/layout/account_preference.xml
res/layout/preference_bluetooth.xml
res/layout/preference_bluetooth_profile.xml
src/com/android/settings/AccountPreference.java
src/com/android/settings/bluetooth/BluetoothDevicePreference.java
src/com/android/settings/bluetooth/BluetoothProfilePreference.java
src/com/android/settings/bluetooth/DeviceProfilesSettings.java
src/com/android/settings/fuelgauge/PowerGaugePreference.java
src/com/android/settings/fuelgauge/PowerUsageSummary.java

index 7ca3e61..b1f035c 100644 (file)
Binary files a/res/drawable-hdpi/nav_divider.png and b/res/drawable-hdpi/nav_divider.png differ
index c9413d7..f7ed6df 100644 (file)
Binary files a/res/drawable-mdpi/nav_divider.png and b/res/drawable-mdpi/nav_divider.png differ
index 810c57a..5e2edc6 100644 (file)
      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>
index 531bdc3..ff1162e 100644 (file)
 <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"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginRight="12dip"
-        android:layout_gravity="center_vertical" />
-
-    <RelativeLayout
+    <LinearLayout android:id="@+id/profileIcons"
         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
index 5ec0a47..03f598a 100644 (file)
 -->
 
 <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
index a860d1a..dc56334 100644 (file)
@@ -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));
index 1f9408d..b54df08 100644 (file)
@@ -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);
 
index c0df8a7..bd28995 100644 (file)
@@ -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);
index d6f192a..780d261 100644 (file)
@@ -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);
index ad8c25b..00e397e 100644 (file)
@@ -64,7 +64,7 @@ public class PowerGaugePreference extends Preference {
         return mInfo;
     }
 
-    void setIcon(Drawable icon) {
+    void setPowerIcon(Drawable icon) {
         mIcon = icon;
         notifyChanged();
     }
index aae60eb..d1b5aef 100644 (file)
@@ -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);
                     }