Added more fields to server list
This commit is contained in:
parent
b9d6aff740
commit
9ffea41df5
|
@ -65,6 +65,9 @@ android {
|
|||
// date formatter
|
||||
implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final'
|
||||
|
||||
// Version comparison
|
||||
implementation 'org.apache.maven:maven-artifact:3.0.3'
|
||||
|
||||
// testing
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
|
|
|
@ -160,7 +160,7 @@ public class ChannelAdapter extends RecyclerView.Adapter<ChannelAdapter.AccountV
|
|||
|
||||
AccountViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = itemView.findViewById(R.id.name);
|
||||
name = itemView.findViewById(R.id.sl_row_name);
|
||||
thumb = itemView.findViewById(R.id.thumb);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
videoMeta = itemView.findViewById(R.id.videoMeta);
|
||||
|
|
|
@ -17,13 +17,11 @@
|
|||
*/
|
||||
package net.schueller.peertube.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -38,6 +36,8 @@ import java.util.ArrayList;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
|
||||
|
@ -74,20 +74,38 @@ public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.AccountVie
|
|||
R.string.server_selection_signup_allowed_yes :
|
||||
R.string.server_selection_signup_allowed_no
|
||||
)));
|
||||
holder.shortDescription.setText(serverList.get(position).getShortDescription());
|
||||
|
||||
holder.videoTotals.setText(
|
||||
activity.getString(R.string.server_selection_video_totals,
|
||||
serverList.get(position).getTotalVideos().toString(),
|
||||
serverList.get(position).getTotalLocalVideos().toString()
|
||||
));
|
||||
|
||||
// don't show description if it hasn't been changes from the default
|
||||
if (!activity.getString(R.string.peertube_instance_search_default_description).equals(serverList.get(position).getShortDescription())) {
|
||||
holder.shortDescription.setText(serverList.get(position).getShortDescription());
|
||||
holder.shortDescription.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.shortDescription.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
DefaultArtifactVersion serverVersion = new DefaultArtifactVersion(serverList.get(position).getVersion());
|
||||
|
||||
// at least version 2.2
|
||||
DefaultArtifactVersion minVersion22 = new DefaultArtifactVersion("2.2.0");
|
||||
if (serverVersion.compareTo(minVersion22) >= 0) {
|
||||
// show NSFW Icon
|
||||
if (serverList.get(position).getNSFW()) {
|
||||
holder.isNSFW.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// select server
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
|
||||
// SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
// SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
String serverUrl = APIUrlHelper.cleanServerUrl(serverList.get(position).getHost());
|
||||
|
||||
// editor.putString("pref_api_base", serverUrl);
|
||||
// editor.apply();
|
||||
//
|
||||
//
|
||||
|
||||
Toast.makeText(activity, activity.getString(R.string.server_selection_set_server, serverUrl), Toast.LENGTH_LONG).show();
|
||||
|
||||
Intent intent = new Intent();
|
||||
|
@ -138,17 +156,19 @@ public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.AccountVie
|
|||
return serverList.size();
|
||||
}
|
||||
|
||||
class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||
static class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView name, host, signupAllowed, shortDescription;
|
||||
TextView name, host, signupAllowed, shortDescription, videoTotals;
|
||||
ImageView isNSFW;
|
||||
|
||||
AccountViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = itemView.findViewById(R.id.name);
|
||||
host = itemView.findViewById(R.id.host);
|
||||
signupAllowed = itemView.findViewById(R.id.signupAllowed);
|
||||
shortDescription = itemView.findViewById(R.id.shortDescription);
|
||||
|
||||
name = itemView.findViewById(R.id.sl_row_name);
|
||||
host = itemView.findViewById(R.id.sl_row_host);
|
||||
signupAllowed = itemView.findViewById(R.id.sl_row_signup_allowed);
|
||||
shortDescription = itemView.findViewById(R.id.sl_row_short_description);
|
||||
isNSFW = itemView.findViewById(R.id.sl_row_is_nsfw);
|
||||
videoTotals = itemView.findViewById(R.id.sl_row_video_totals);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
|
|||
|
||||
VideoViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = itemView.findViewById(R.id.name);
|
||||
name = itemView.findViewById(R.id.sl_row_name);
|
||||
thumb = itemView.findViewById(R.id.thumb);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
videoMeta = itemView.findViewById(R.id.videoMeta);
|
||||
|
|
|
@ -172,7 +172,7 @@ public class VideoMetaDataFragment extends Fragment {
|
|||
|
||||
|
||||
// title / name
|
||||
TextView videoName = activity.findViewById(R.id.name);
|
||||
TextView videoName = activity.findViewById(R.id.sl_row_name);
|
||||
videoName.setText(video.getName());
|
||||
|
||||
// created at / views
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
package net.schueller.peertube.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class Server {
|
||||
|
||||
private Integer id;
|
||||
|
@ -26,16 +29,20 @@ public class Server {
|
|||
private String version;
|
||||
private Boolean signupAllowed;
|
||||
private Double userVideoQuota;
|
||||
private Category category;
|
||||
private ArrayList<String> languages;
|
||||
private Boolean autoBlacklistUserVideosEnabled;
|
||||
private String defaultNSFWPolicy;
|
||||
private Boolean isNSFW;
|
||||
private Integer totalUsers;
|
||||
private Integer totalVideos;
|
||||
private Integer totalLocalVideos;
|
||||
private Integer totalInstanceFollowers;
|
||||
private Integer totalInstanceFollowing;
|
||||
|
||||
private Boolean supportsIPv6;
|
||||
private String country;
|
||||
|
||||
private Integer health;
|
||||
private Date createdAt;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
@ -93,6 +100,46 @@ public class Server {
|
|||
this.userVideoQuota = userVideoQuota;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public ArrayList<String> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
public void setLanguages(ArrayList<String> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
public Boolean getAutoBlacklistUserVideosEnabled() {
|
||||
return autoBlacklistUserVideosEnabled;
|
||||
}
|
||||
|
||||
public void setAutoBlacklistUserVideosEnabled(Boolean autoBlacklistUserVideosEnabled) {
|
||||
this.autoBlacklistUserVideosEnabled = autoBlacklistUserVideosEnabled;
|
||||
}
|
||||
|
||||
public String getDefaultNSFWPolicy() {
|
||||
return defaultNSFWPolicy;
|
||||
}
|
||||
|
||||
public void setDefaultNSFWPolicy(String defaultNSFWPolicy) {
|
||||
this.defaultNSFWPolicy = defaultNSFWPolicy;
|
||||
}
|
||||
|
||||
public Boolean getNSFW() {
|
||||
return isNSFW;
|
||||
}
|
||||
|
||||
public void setNSFW(Boolean NSFW) {
|
||||
isNSFW = NSFW;
|
||||
}
|
||||
|
||||
public Integer getTotalUsers() {
|
||||
return totalUsers;
|
||||
}
|
||||
|
@ -156,4 +203,12 @@ public class Server {
|
|||
public void setHealth(Integer health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
|
||||
</vector>
|
|
@ -16,7 +16,7 @@
|
|||
android:paddingEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -31,7 +31,7 @@
|
|||
android:id="@+id/videoMeta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:layout_below="@+id/sl_row_name"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="0dp"
|
||||
|
@ -58,7 +58,7 @@
|
|||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toEndOf="@+id/name"
|
||||
android:layout_toEndOf="@+id/sl_row_name"
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/descr_overflow_button"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" />
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
android:paddingEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/thumb"
|
||||
|
@ -66,7 +66,7 @@
|
|||
android:id="@+id/videoMeta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:layout_below="@+id/sl_row_name"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
|
@ -93,7 +93,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toEndOf="@+id/name"
|
||||
android:layout_toEndOf="@+id/sl_row_name"
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/descr_overflow_button"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
android:paddingEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/thumb"
|
||||
|
@ -66,7 +66,7 @@
|
|||
android:id="@+id/videoMeta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:layout_below="@+id/sl_row_name"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
|
@ -93,7 +93,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toEndOf="@+id/name"
|
||||
android:layout_toEndOf="@+id/sl_row_name"
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/descr_overflow_button"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
android:paddingEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/thumb"
|
||||
|
@ -66,7 +66,7 @@
|
|||
android:id="@+id/videoMeta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:layout_below="@+id/sl_row_name"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
|
@ -93,7 +93,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toEndOf="@+id/name"
|
||||
android:layout_toEndOf="@+id/sl_row_name"
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/descr_overflow_button"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
|
||||
|
|
|
@ -7,15 +7,18 @@
|
|||
card_view:cardElevation="0dp"
|
||||
card_view:cardUseCompatPadding="true">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:padding="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
|
@ -24,7 +27,7 @@
|
|||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Headline" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/host"
|
||||
android:id="@+id/sl_row_host"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
|
@ -33,7 +36,7 @@
|
|||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/signupAllowed"
|
||||
android:id="@+id/sl_row_signup_allowed"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
|
@ -43,14 +46,45 @@
|
|||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/shortDescription"
|
||||
android:id="@+id/sl_row_short_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:paddingTop="0dp"
|
||||
android:visibility="gone"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="0dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sl_row_video_totals"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sl_row_is_nsfw"
|
||||
android:src="@drawable/ic_baseline_remove_red_eye_24"
|
||||
android:visibility="gone"
|
||||
android:layout_width="24dp"
|
||||
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_selection_nsfw_instance" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
android:paddingEnd="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:id="@+id/sl_row_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/thumb"
|
||||
|
@ -74,7 +74,7 @@
|
|||
android:id="@+id/videoMeta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/name"
|
||||
android:layout_below="@+id/sl_row_name"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
|
@ -101,7 +101,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="-16dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toEndOf="@+id/name"
|
||||
android:layout_toEndOf="@+id/sl_row_name"
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/descr_overflow_button"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption"
|
||||
|
|
|
@ -372,6 +372,10 @@
|
|||
<string name="settings_activity_about_category_title">About</string>
|
||||
<string name="settings_activity_look_and_feel_category_title"><![CDATA[Look & Feel]]></string>
|
||||
|
||||
<string name="peertube_instance_search_default_description" translatable="false">PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.</string>
|
||||
<string name="server_selection_nsfw_instance">NSFW Instance</string>
|
||||
<string name="server_selection_video_totals">Videos: %s, Local Videos: %s</string>
|
||||
|
||||
|
||||
<!-- Constants, Don't translate -->
|
||||
<string name="pref_token_access" translatable="false">pref_token_access</string>
|
||||
|
|
Loading…
Reference in New Issue