mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-01-28 16:51:26 -05:00
Merge branch 'app-list-items' into 'master'
Split up name and summary in app list items See merge request fdroid/fdroidclient!1389
This commit is contained in:
@@ -1,26 +1,42 @@
|
||||
package org.fdroid.fdroid.views.main;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
public class LatestLayoutPolicy {
|
||||
class LatestLayoutPolicy {
|
||||
private final Context context;
|
||||
|
||||
public LatestLayoutPolicy(Context context) {
|
||||
LatestLayoutPolicy(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public RecyclerView.ItemDecoration getItemDecoration() {
|
||||
return new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
||||
RecyclerView.ItemDecoration getItemDecoration() {
|
||||
return new RecyclerView.ItemDecoration() {
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent,
|
||||
@NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
Resources resources = context.getResources();
|
||||
int padding = (int) resources.getDimension(R.dimen.latest__padding__app_card__normal);
|
||||
outRect.set(padding, padding, padding, 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int getItemViewType(int position) {
|
||||
/** @noinspection unused*/
|
||||
int getItemViewType(int position) {
|
||||
return R.id.latest_regular_list;
|
||||
}
|
||||
|
||||
public int getSpanSize(int position) {
|
||||
/** @noinspection unused*/
|
||||
int getSpanSize(int position) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,8 @@ public class AppCardController extends RecyclerView.ViewHolder
|
||||
@NonNull
|
||||
private final ImageView icon;
|
||||
|
||||
/**
|
||||
* Text starting with the app name (in bold) followed by a short summary of the app.
|
||||
*/
|
||||
@NonNull
|
||||
private final TextView name;
|
||||
@NonNull
|
||||
private final TextView summary;
|
||||
|
||||
@@ -61,6 +60,7 @@ public class AppCardController extends RecyclerView.ViewHolder
|
||||
this.activity = activity;
|
||||
|
||||
icon = ViewCompat.requireViewById(itemView, R.id.icon);
|
||||
name = ViewCompat.requireViewById(itemView, R.id.name);
|
||||
summary = ViewCompat.requireViewById(itemView, R.id.summary);
|
||||
|
||||
newTag = itemView.findViewById(R.id.new_tag);
|
||||
@@ -71,8 +71,8 @@ public class AppCardController extends RecyclerView.ViewHolder
|
||||
public void bindApp(@NonNull AppOverviewItem app) {
|
||||
currentApp = app;
|
||||
|
||||
String name = app.getName();
|
||||
summary.setText(Utils.formatAppNameAndSummary(name == null ? "" : name, app.getSummary()));
|
||||
name.setText(app.getName());
|
||||
summary.setText(app.getSummary());
|
||||
|
||||
if (newTag != null) {
|
||||
if (isConsideredNew(app)) {
|
||||
|
||||
@@ -24,18 +24,33 @@
|
||||
tools:src="@drawable/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="4"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" />
|
||||
tools:text="F-Droid An application name which takes up too much space" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toBottomOf="@+id/name"
|
||||
tools:text="An application summary which takes up too much space and must ellipsize if it is really longer than all the space there is and it may be a lot if we allow so many lines on a big screen." />
|
||||
|
||||
<include
|
||||
android:id="@+id/new_tag"
|
||||
|
||||
@@ -29,18 +29,31 @@
|
||||
tools:src="@drawable/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="4"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/icon"
|
||||
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" />
|
||||
tools:text="F-Droid An application name which takes up too much space and must ellipsize" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/name"
|
||||
tools:text="An application summary which takes up too much space and must ellipsize if it is too long so it does not fit the space available." />
|
||||
|
||||
<include
|
||||
android:id="@+id/new_tag"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
@@ -25,28 +25,46 @@
|
||||
tools:src="@drawable/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:gravity="start"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/new_tag"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteY="8dp"
|
||||
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" />
|
||||
app:layout_goneMarginEnd="0dp"
|
||||
tools:text="F-Droid app name which can be longer for some apps" />
|
||||
|
||||
<include
|
||||
android:id="@+id/new_tag"
|
||||
layout="@layout/app_status_new"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
app:layout_constraintStart_toStartOf="@+id/summary"
|
||||
app:layout_constraintTop_toBottomOf="@+id/summary" />
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toBottomOf="@+id/name"
|
||||
tools:layout_editor_absoluteY="8dp"
|
||||
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@@ -8,47 +8,53 @@
|
||||
android:layout_height="144dp"
|
||||
android:layout_margin="4dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
|
||||
when it will inevitably read out the name of the app straight after. -->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/linearLayout"
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dip"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="fitCenter"
|
||||
android:transitionName="@string/transition_app_item_icon"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@drawable/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/icon"
|
||||
tools:text="F-Droid" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dip"
|
||||
android:layout_marginTop="8dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:transitionName="@string/transition_app_item_icon"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@drawable/ic_launcher" />
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/name"
|
||||
tools:text="An application summary which takes up too much space and must ellipsize" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/icon"
|
||||
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
<dimen name="latest__padding__app_card__horizontal">12dp</dimen>
|
||||
<dimen name="latest__padding__app_card__vertical">10dp</dimen>
|
||||
<dimen name="latest__padding__app_card__normal">8dp</dimen>
|
||||
|
||||
<!-- Used by the BottomNavigation library so that our text labels are not truncated so easily.
|
||||
The default is 12dp or something like that which only really allows for very short labels. -->
|
||||
|
||||
Reference in New Issue
Block a user