Greatly improve app list layout
* Don't hard-code ellipsis in the code * Separate the two rows into two linear layouts * Don't abuse relative layouts * Use ellipsize with weights to achieve best results
This commit is contained in:
parent
b731ab57b3
commit
a477f421cb
@ -14,34 +14,26 @@
|
|||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:padding="4dp"
|
android:padding="5dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="5dp"
|
android:padding="5dp"
|
||||||
android:paddingStart="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:paddingEnd="5dp"
|
|
||||||
android:layout_toRightOf="@id/icon"
|
android:layout_toRightOf="@id/icon"
|
||||||
android:layout_toEndOf="@id/icon"
|
android:layout_toEndOf="@id/icon"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:baselineAligned="false" >
|
android:baselineAligned="false" >
|
||||||
|
|
||||||
<TextView android:id="@+id/status"
|
<LinearLayout
|
||||||
android:singleLine="true"
|
android:orientation="horizontal"
|
||||||
android:textSize="13sp"
|
android:layout_width="fill_parent"
|
||||||
android:ellipsize="end"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="6sp"
|
android:baselineAligned="false"
|
||||||
android:layout_marginStart="6sp"
|
>
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentEnd="true" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/name"
|
<TextView android:id="@+id/name"
|
||||||
android:textSize="17sp"
|
android:textSize="17sp"
|
||||||
@ -49,39 +41,59 @@
|
|||||||
android:paddingBottom="3sp"
|
android:paddingBottom="3sp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:layout_weight="2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:layout_toLeftOf="@id/status"
|
/>
|
||||||
android:layout_toStartOf="@id/status" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/license"
|
<TextView android:id="@+id/status"
|
||||||
android:textSize="12sp"
|
android:textSize="13sp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="6sp"
|
android:layout_marginLeft="6sp"
|
||||||
android:layout_marginStart="6sp"
|
android:layout_marginStart="6sp"
|
||||||
android:layout_below="@id/name"
|
android:textAlignment="viewEnd"
|
||||||
android:layout_alignParentRight="true"
|
/>
|
||||||
android:layout_alignParentEnd="true" />
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
>
|
||||||
|
|
||||||
<TextView android:id="@+id/summary"
|
<TextView android:id="@+id/summary"
|
||||||
android:textSize="13sp"
|
android:textSize="13sp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:layout_weight="2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/name"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:layout_toLeftOf="@id/license"
|
/>
|
||||||
android:layout_toStartOf="@id/license" />
|
|
||||||
|
<TextView android:id="@+id/license"
|
||||||
</RelativeLayout>
|
android:textSize="12sp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="6sp"
|
||||||
|
android:layout_marginStart="6sp"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
/>
|
||||||
|
<!--android:layout_alignParentRight="true"-->
|
||||||
|
<!--android:layout_alignParentEnd="true"-->
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -120,13 +120,6 @@ abstract public class AppListAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String ellipsize(String input, int maxLength) {
|
|
||||||
if (input == null || input.length() < maxLength+1) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
return input.substring(0, maxLength) + "…";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVersionInfo(App app) {
|
private String getVersionInfo(App app) {
|
||||||
|
|
||||||
if (app.suggestedVercode <= 0) {
|
if (app.suggestedVercode <= 0) {
|
||||||
@ -136,19 +129,18 @@ abstract public class AppListAdapter extends CursorAdapter {
|
|||||||
PackageInfo installedInfo = app.getInstalledInfo(mContext);
|
PackageInfo installedInfo = app.getInstalledInfo(mContext);
|
||||||
|
|
||||||
if (installedInfo == null) {
|
if (installedInfo == null) {
|
||||||
return ellipsize(app.getSuggestedVersion(), 12);
|
return app.getSuggestedVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
String installedVersionString = installedInfo.versionName;
|
String installedVersionString = installedInfo.versionName;
|
||||||
int installedVersionCode = installedInfo.versionCode;
|
int installedVersionCode = installedInfo.versionCode;
|
||||||
|
|
||||||
if (app.canAndWantToUpdate(mContext) && showStatusUpdate()) {
|
if (app.canAndWantToUpdate(mContext) && showStatusUpdate()) {
|
||||||
return ellipsize(installedVersionString, 8) +
|
return installedVersionString + " → " + app.getSuggestedVersion();
|
||||||
" → " + ellipsize(app.getSuggestedVersion(), 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installedVersionCode > 0 && showStatusInstalled()) {
|
if (installedVersionCode > 0 && showStatusInstalled()) {
|
||||||
return ellipsize(installedVersionString, 12) + " ✔";
|
return installedVersionString + " ✔";
|
||||||
}
|
}
|
||||||
|
|
||||||
return installedVersionString;
|
return installedVersionString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user