mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-07-14 07:30:29 +03:00
Merge branch '0xd9a-update_peertube_picker_drawer' into develop
This commit is contained in:
commit
5e2e91df3d
2 changed files with 88 additions and 79 deletions
|
@ -22,13 +22,12 @@ import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
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.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.google.android.material.chip.Chip;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -39,7 +38,6 @@ import java.util.List;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.DrawerInstancePeertubeBinding;
|
import app.fedilab.android.databinding.DrawerInstancePeertubeBinding;
|
||||||
import app.fedilab.android.peertube.client.data.InstanceData.Instance;
|
import app.fedilab.android.peertube.client.data.InstanceData.Instance;
|
||||||
import app.fedilab.android.peertube.helper.RoundedBackgroundSpan;
|
|
||||||
|
|
||||||
|
|
||||||
public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
@ -95,28 +93,22 @@ public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
||||||
holder.binding.name.setText(instance.getName());
|
holder.binding.name.setText(instance.getName());
|
||||||
holder.binding.host.setText(instance.getHost());
|
holder.binding.host.setText(instance.getHost());
|
||||||
|
|
||||||
|
holder.binding.chips.removeAllViews();
|
||||||
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
|
|
||||||
String between = "";
|
|
||||||
if (peertubeInformation != null && peertubeInformation.getCategories() != null) {
|
if (peertubeInformation != null && peertubeInformation.getCategories() != null) {
|
||||||
LinkedHashMap<Integer, String> info_cat = new LinkedHashMap<>(peertubeInformation.getCategories());
|
LinkedHashMap<Integer, String> info_cat = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||||
if (instance.getCategories() != null && instance.getCategories().size() > 0 && instance.getSpannableStringBuilder() == null) {
|
if (instance.getCategories() != null && instance.getCategories().size() > 0 && instance.getSpannableStringBuilder() == null) {
|
||||||
for (int category : instance.getCategories()) {
|
for (int category : instance.getCategories()) {
|
||||||
String cat = info_cat.get(category);
|
String cat = info_cat.get(category);
|
||||||
stringBuilder.append(between);
|
|
||||||
if (cat != null && cat.trim().toLowerCase().compareTo("null") != 0) {
|
if (cat != null && cat.trim().toLowerCase().compareTo("null") != 0) {
|
||||||
if (between.length() == 0) between = " ";
|
Chip chip = new Chip(context);
|
||||||
String tag = " " + cat + " ";
|
chip.setClickable(false);
|
||||||
stringBuilder.append(tag);
|
chip.setEnsureMinTouchTargetSize(false);
|
||||||
stringBuilder.setSpan(new RoundedBackgroundSpan(context), stringBuilder.length() - tag.length(), stringBuilder.length() - tag.length() + tag.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
chip.setText(cat);
|
||||||
|
holder.binding.chips.addView(chip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instance.setSpannableStringBuilder(stringBuilder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (instance.getSpannableStringBuilder() != null) {
|
|
||||||
holder.binding.tags.setText(instance.getSpannableStringBuilder());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (peertubeInformation != null && peertubeInformation.getLanguages() != null) {
|
if (peertubeInformation != null && peertubeInformation.getLanguages() != null) {
|
||||||
LinkedHashMap<String, String> info_lang = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
LinkedHashMap<String, String> info_lang = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||||
|
|
|
@ -14,91 +14,108 @@
|
||||||
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/main_container"
|
android:id="@+id/main_container"
|
||||||
|
style="@style/Widget.Material3.CardView.Outlined"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:layout_marginVertical="6dp">
|
||||||
android:divider="?android:dividerHorizontal"
|
|
||||||
android:gravity="bottom"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:showDividers="end">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="12dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
android:textAppearance="@style/TextAppearance.Material3.BodyLarge"
|
||||||
android:textStyle="bold"
|
app:layout_constraintBottom_toTopOf="@id/host"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/pickup"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="@tools:sample/cities" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
|
||||||
app:layout_constraintStart_toEndOf="@+id/name"
|
app:layout_constraintBottom_toTopOf="@id/barrier_1"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintEnd_toStartOf="@id/pickup"
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/name" />
|
app:layout_constraintTop_toBottomOf="@id/name"
|
||||||
|
tools:text="@tools:sample/cities" />
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/tags"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/description" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/followers_instance"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:drawablePadding="10dp"
|
|
||||||
app:drawableStartCompat="@drawable/ic_baseline_group_24"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tags" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/languages"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:drawablePadding="10dp"
|
|
||||||
app:drawableStartCompat="@drawable/ic_baseline_forum_24"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/followers_instance" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
|
||||||
android:id="@+id/sensitive_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/languages" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/pickup"
|
android:id="@+id/pickup"
|
||||||
style="@style/Widget.Material3.Button.ElevatedButton"
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:text="@string/pickup_instance"
|
android:text="@string/pickup_instance"
|
||||||
|
app:icon="@drawable/ic_navigate_next"
|
||||||
|
app:iconGravity="end"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/barrier_1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/sensitive_content" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
android:id="@+id/barrier_1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barrierDirection="bottom"
|
||||||
|
app:constraint_referenced_ids="host,pickup" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/barrier_1"
|
||||||
|
tools:maxLines="4"
|
||||||
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
||||||
|
<com.google.android.material.chip.ChipGroup
|
||||||
|
android:id="@+id/chips"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
app:chipSpacingHorizontal="6dp"
|
||||||
|
app:chipSpacingVertical="6dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/description">
|
||||||
|
|
||||||
|
</com.google.android.material.chip.ChipGroup>
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/followers_instance"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:drawablePadding="12dp"
|
||||||
|
app:drawableStartCompat="@drawable/ic_baseline_group_24"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/chips" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/languages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
android:drawablePadding="12dp"
|
||||||
|
app:drawableStartCompat="@drawable/ic_baseline_forum_24"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/followers_instance" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/sensitive_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="6dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/languages" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</com.google.android.material.card.MaterialCardView>
|
Loading…
Reference in a new issue