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,74 +14,86 @@
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="4dp"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:padding="5dp"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_centerVertical="true"
|
||||
android:baselineAligned="false" >
|
||||
|
||||
<TextView android:id="@+id/status"
|
||||
android:singleLine="true"
|
||||
android:textSize="13sp"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6sp"
|
||||
android:layout_marginStart="6sp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
android:baselineAligned="false"
|
||||
>
|
||||
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingBottom="3sp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="wrap_content"
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
android:paddingBottom="3sp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_weight="2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/status"
|
||||
android:textSize="13sp"
|
||||
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"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:textAlignment="viewStart"
|
||||
android:layout_toLeftOf="@id/status"
|
||||
android:layout_toStartOf="@id/status" />
|
||||
android:baselineAligned="false"
|
||||
>
|
||||
|
||||
<TextView android:id="@+id/license"
|
||||
android:textSize="12sp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6sp"
|
||||
android:layout_marginStart="6sp"
|
||||
android:layout_below="@id/name"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
<TextView android:id="@+id/summary"
|
||||
android:textSize="13sp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_weight="2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="viewStart"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/summary"
|
||||
android:textSize="13sp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/name"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:textAlignment="viewStart"
|
||||
android:layout_toLeftOf="@id/license"
|
||||
android:layout_toStartOf="@id/license" />
|
||||
<TextView android:id="@+id/license"
|
||||
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"-->
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</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) {
|
||||
|
||||
if (app.suggestedVercode <= 0) {
|
||||
@ -136,19 +129,18 @@ abstract public class AppListAdapter extends CursorAdapter {
|
||||
PackageInfo installedInfo = app.getInstalledInfo(mContext);
|
||||
|
||||
if (installedInfo == null) {
|
||||
return ellipsize(app.getSuggestedVersion(), 12);
|
||||
return app.getSuggestedVersion();
|
||||
}
|
||||
|
||||
String installedVersionString = installedInfo.versionName;
|
||||
int installedVersionCode = installedInfo.versionCode;
|
||||
|
||||
if (app.canAndWantToUpdate(mContext) && showStatusUpdate()) {
|
||||
return ellipsize(installedVersionString, 8) +
|
||||
" → " + ellipsize(app.getSuggestedVersion(), 8);
|
||||
return installedVersionString + " → " + app.getSuggestedVersion();
|
||||
}
|
||||
|
||||
if (installedVersionCode > 0 && showStatusInstalled()) {
|
||||
return ellipsize(installedVersionString, 12) + " ✔";
|
||||
return installedVersionString + " ✔";
|
||||
}
|
||||
|
||||
return installedVersionString;
|
||||
|
Loading…
x
Reference in New Issue
Block a user