Restructure applistitem:
* Move it to the top right corner * Don't let the app name overlap it * Ellipsize version names to leave space for name * Summary can now take two lines if it needs them * Installed versions are now bold
This commit is contained in:
parent
f3b247dc81
commit
e3789631ba
@ -4,7 +4,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="3dp"
|
android:paddingTop="3dp"
|
||||||
android:paddingBottom="5dp"
|
android:paddingBottom="4dp"
|
||||||
android:paddingLeft="3dp"
|
android:paddingLeft="3dp"
|
||||||
android:paddingRight="3dp"
|
android:paddingRight="3dp"
|
||||||
android:baselineAligned="false" >
|
android:baselineAligned="false" >
|
||||||
@ -44,6 +44,15 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/status"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="3dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentRight="true" />
|
||||||
|
|
||||||
<TextView android:id="@+id/name"
|
<TextView android:id="@+id/name"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@ -51,33 +60,26 @@
|
|||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toLeftOf="@id/status"
|
||||||
android:layout_toRightOf="@id/icon" />
|
android:layout_toRightOf="@id/icon" />
|
||||||
|
|
||||||
<TextView android:id="@+id/summary"
|
<TextView android:id="@+id/summary"
|
||||||
android:singleLine="true"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
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_below="@id/name"
|
||||||
android:layout_toRightOf="@id/icon" />
|
android:layout_toRightOf="@id/icon" />
|
||||||
|
|
||||||
<TextView android:id="@+id/status"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toRightOf="@id/icon"
|
|
||||||
android:layout_below="@id/summary" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/license"
|
<TextView android:id="@+id/license"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:paddingLeft="4dp"
|
||||||
|
android:paddingRight="4dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true" />
|
||||||
android:layout_alignBaseline="@id/status" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -4,10 +4,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import org.fdroid.fdroid.DB;
|
import org.fdroid.fdroid.DB;
|
||||||
@ -133,20 +136,38 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
String ellipsize(String input, int maxLength) {
|
||||||
|
if (input == null || input.length() < maxLength+1) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return input.substring(0, maxLength) + "…";
|
||||||
|
}
|
||||||
|
|
||||||
|
private SpannableString getVersionInfo(DB.App app) {
|
||||||
|
|
||||||
|
if (app.curApk == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.installedVersion == null) {
|
||||||
|
return new SpannableString(
|
||||||
|
ellipsize(app.curApk.version, 12));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpannableString span;
|
||||||
|
String cur;
|
||||||
|
|
||||||
private String getVersionInfo(DB.App app) {
|
|
||||||
if (app.installedVersion != null) {
|
|
||||||
if (app.toUpdate) {
|
if (app.toUpdate) {
|
||||||
return app.installedVersion + " -> " + app.curApk.version;
|
cur = ellipsize(app.installedVersion, 8);
|
||||||
}
|
span = new SpannableString(
|
||||||
return app.installedVersion;
|
cur + " -> " + ellipsize(app.curApk.version, 8));
|
||||||
} else {
|
} else {
|
||||||
int numav = app.apks.size();
|
cur = ellipsize(app.installedVersion, 12);
|
||||||
if (numav == 1) {
|
span = new SpannableString(cur);
|
||||||
return mContext.getString(R.string.n_version_available, numav);
|
|
||||||
}
|
|
||||||
return mContext.getString(R.string.n_versions_available, numav);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.setSpan(new StyleSpan(Typeface.BOLD), 0, cur.length(), 0);
|
||||||
|
return span;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void layoutIcon(ImageView icon, boolean compact) {
|
private void layoutIcon(ImageView icon, boolean compact) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user