mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-20 06:47:06 -04:00
[app] Add repo icon and address to repo listing
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
231a8b7710
commit
9fd8d20b7c
@@ -5,14 +5,20 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import org.fdroid.database.Repository;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.index.v2.FileV2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -59,16 +65,20 @@ public class RepoAdapter extends RecyclerView.Adapter<RepoAdapter.RepoViewHolder
|
||||
|
||||
class RepoViewHolder extends RecyclerView.ViewHolder {
|
||||
private final View rootView;
|
||||
private final ImageView imageView;
|
||||
private final CompoundButton switchView;
|
||||
private final TextView nameView;
|
||||
private final TextView addressView;
|
||||
private final View unsignedView;
|
||||
private final View unverifiedView;
|
||||
|
||||
RepoViewHolder(@NonNull View view) {
|
||||
super(view);
|
||||
rootView = view;
|
||||
imageView = view.findViewById(R.id.repo_icon);
|
||||
switchView = view.findViewById(R.id.repo_switch);
|
||||
nameView = view.findViewById(R.id.repo_name);
|
||||
addressView = view.findViewById(R.id.repo_address);
|
||||
unsignedView = view.findViewById(R.id.repo_unsigned);
|
||||
unverifiedView = view.findViewById(R.id.repo_unverified);
|
||||
}
|
||||
@@ -89,7 +99,18 @@ public class RepoAdapter extends RecyclerView.Adapter<RepoAdapter.RepoViewHolder
|
||||
repoItemListener.onSetEnabled(repo, isChecked);
|
||||
}
|
||||
});
|
||||
FileV2 iconFile = repo.getIcon(LocaleListCompat.getDefault());
|
||||
if (iconFile == null) {
|
||||
Glide.with(imageView.getContext()).clear(imageView);
|
||||
imageView.setImageResource(R.drawable.ic_repo_app_default);
|
||||
} else {
|
||||
Glide.with(imageView.getContext())
|
||||
.load(Utils.getDownloadRequest(repo, iconFile))
|
||||
.apply(Utils.getAlwaysShowIconRequestOptions())
|
||||
.into(imageView);
|
||||
}
|
||||
nameView.setText(repo.getName(App.getLocales()));
|
||||
addressView.setText(repo.getAddress().replace("https://", ""));
|
||||
if (repo.getCertificate() != null) {
|
||||
unsignedView.setVisibility(View.GONE);
|
||||
unverifiedView.setVisibility(View.GONE);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingStart="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingEnd="?attr/listPreferredItemPaddingRight"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
<!--
|
||||
descendantFocusability is here because if you have a child that responds
|
||||
to touch events (in our case, the switch/toggle button) then the list item
|
||||
@@ -17,49 +15,72 @@
|
||||
http://syedasaraahmed.wordpress.com/2012/10/03/android-onitemclicklistener-not-responding-clickable-rowitem-of-custom-listview/
|
||||
-->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/repo_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="fitCenter"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
tools:ignore="RtlSymmetry">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"/>
|
||||
android:textAppearance="?attr/textAppearanceListItem"
|
||||
tools:text="This is the name of the Repo as taken from the index. It can be long." />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|start"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp"
|
||||
tools:text="this.is.a.repo.at.the.official.domain.it.can.be.long.at.f-droid.org" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_unverified"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|start"
|
||||
android:text="@string/unverified"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/unverified"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"/>
|
||||
android:text="@string/unverified"
|
||||
android:textColor="@color/unverified"
|
||||
android:textSize="14sp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repo_unsigned"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|start"
|
||||
android:text="@string/unsigned"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/unsigned"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"/>
|
||||
android:text="@string/unsigned"
|
||||
android:textColor="@color/unsigned"
|
||||
android:textSize="14sp"
|
||||
tools:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/repo_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user