Merge commit 'refs/merge-requests/55' of gitorious.org:f-droid/fdroidclient
This commit is contained in:
commit
960e04d425
@ -9,14 +9,17 @@
|
|||||||
android:paddingRight="3dp"
|
android:paddingRight="3dp"
|
||||||
android:baselineAligned="false" >
|
android:baselineAligned="false" >
|
||||||
|
|
||||||
|
<!-- Actual icon size is dependent on preferences and set in
|
||||||
|
AppListAdapater.java:layoutIcon() -->
|
||||||
<ImageView android:id="@+id/icon"
|
<ImageView android:id="@+id/icon"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:layout_width="40dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_marginRight="6dp"
|
android:layout_marginRight="6dp"
|
||||||
android:layout_marginLeft="2dp"
|
android:layout_marginLeft="2dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/status_icons"
|
<LinearLayout android:id="@+id/status_icons"
|
||||||
@ -48,8 +51,15 @@
|
|||||||
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_toRightOf="@id/icon"
|
android:layout_toRightOf="@id/icon" />
|
||||||
android:paddingTop="4dp" />
|
|
||||||
|
<TextView android:id="@+id/summary"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/name"
|
||||||
|
android:layout_toRightOf="@id/icon" />
|
||||||
|
|
||||||
<TextView android:id="@+id/status"
|
<TextView android:id="@+id/status"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
@ -58,7 +68,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/icon"
|
android:layout_toRightOf="@id/icon"
|
||||||
android:layout_below="@id/name" />
|
android:layout_below="@id/summary" />
|
||||||
|
|
||||||
<TextView android:id="@+id/license"
|
<TextView android:id="@+id/license"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
@ -67,14 +77,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:layout_alignParentRight="true" />
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignBaseline="@id/status" />
|
||||||
<TextView android:id="@+id/summary"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/icon"
|
|
||||||
android:paddingLeft="@dimen/applist_summary_padding" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="applist_summary_padding">3dp</dimen>
|
<dimen name="applist_icon_normal_size">48dp</dimen>
|
||||||
|
<dimen name="applist_icon_compact_size">32dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -14,15 +14,24 @@ import org.fdroid.fdroid.Preferences;
|
|||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.compat.LayoutCompat;
|
import org.fdroid.fdroid.compat.LayoutCompat;
|
||||||
|
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||||
|
|
||||||
abstract public class AppListAdapter extends BaseAdapter {
|
abstract public class AppListAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private List<DB.App> items = new ArrayList<DB.App>();
|
private List<DB.App> items = new ArrayList<DB.App>();
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private DisplayImageOptions displayImageOptions;
|
||||||
|
|
||||||
public AppListAdapter(Context context) {
|
public AppListAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
|
DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
|
||||||
|
builder.imageScaleType(ImageScaleType.NONE); // let android scale
|
||||||
|
builder.resetViewBeforeLoading(true); // required for multiple loading
|
||||||
|
builder.cacheInMemory(true); // default even if doc says otherwise
|
||||||
|
displayImageOptions = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected boolean showStatusUpdate();
|
abstract protected boolean showStatusUpdate();
|
||||||
@ -80,9 +89,10 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
iconContainer.setVisibility(visibleOnCompact);
|
iconContainer.setVisibility(visibleOnCompact);
|
||||||
status.setVisibility(notVisibleOnCompact);
|
status.setVisibility(notVisibleOnCompact);
|
||||||
license.setVisibility(notVisibleOnCompact);
|
license.setVisibility(notVisibleOnCompact);
|
||||||
layoutSummary(summary);
|
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(app.iconUrl, icon);
|
layoutIcon(icon, compact);
|
||||||
|
ImageLoader.getInstance().displayImage(app.iconUrl, icon,
|
||||||
|
displayImageOptions);
|
||||||
|
|
||||||
if (!compact) {
|
if (!compact) {
|
||||||
status.setText(getVersionInfo(app));
|
status.setText(getVersionInfo(app));
|
||||||
@ -116,38 +126,6 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In compact view, the summary sites next to the icon, below the name.
|
|
||||||
* In non-compact view, it sits under the icon, with some padding pushing
|
|
||||||
* it away from the left margin.
|
|
||||||
*/
|
|
||||||
private void layoutSummary(TextView summaryView) {
|
|
||||||
|
|
||||||
if (Preferences.get().hasCompactLayout()) {
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams summaryLayout =
|
|
||||||
new RelativeLayout.LayoutParams(
|
|
||||||
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
summaryLayout.addRule(RelativeLayout.BELOW, R.id.name);
|
|
||||||
summaryLayout.addRule(LayoutCompat.RelativeLayout.END_OF, R.id.icon);
|
|
||||||
summaryView.setLayoutParams(summaryLayout);
|
|
||||||
summaryView.setPadding(0,0,0,0);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams summaryLayout =
|
|
||||||
new RelativeLayout.LayoutParams(
|
|
||||||
RelativeLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
summaryLayout.addRule(RelativeLayout.BELOW, R.id.icon);
|
|
||||||
summaryView.setLayoutParams(summaryLayout);
|
|
||||||
float padding = mContext.getResources().getDimension(R.dimen.applist_summary_padding);
|
|
||||||
summaryView.setPadding((int)padding, 0, 0, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVersionInfo(DB.App app) {
|
private String getVersionInfo(DB.App app) {
|
||||||
if (app.installedVersion != null) {
|
if (app.installedVersion != null) {
|
||||||
if (app.toUpdate) {
|
if (app.toUpdate) {
|
||||||
@ -163,4 +141,18 @@ abstract public class AppListAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void layoutIcon(ImageView icon, boolean compact) {
|
||||||
|
int size = (int)mContext.getResources().getDimension((compact
|
||||||
|
? R.dimen.applist_icon_compact_size
|
||||||
|
: R.dimen.applist_icon_normal_size));
|
||||||
|
|
||||||
|
RelativeLayout.LayoutParams params =
|
||||||
|
(RelativeLayout.LayoutParams)icon.getLayoutParams();
|
||||||
|
|
||||||
|
params.height = size;
|
||||||
|
params.width = size;
|
||||||
|
|
||||||
|
icon.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user