diff --git a/app/src/acad/res/values/strings.xml b/app/src/acad/res/values/strings.xml
index 2960119..4a9b640 100644
--- a/app/src/acad/res/values/strings.xml
+++ b/app/src/acad/res/values/strings.xml
@@ -227,4 +227,5 @@
Sensitive content: %1$s
%1$s followers instances
Help
+ Sensitive videos
diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml
index 764517d..b200e35 100644
--- a/app/src/full/res/values/strings.xml
+++ b/app/src/full/res/values/strings.xml
@@ -241,6 +241,7 @@
No instances match these criteria
Instances picker
Pickup this instance
+ Sensitive videos
Sensitive content: %1$s
%1$s followers instances
Help
diff --git a/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java b/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java
index 3a17be6..7989745 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java
@@ -17,6 +17,7 @@ package app.fedilab.fedilabtube;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
+import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.Toast;
@@ -26,7 +27,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.entities.Instance;
@@ -35,6 +39,8 @@ import app.fedilab.fedilabtube.drawer.InstanceAdapter;
import app.fedilab.fedilabtube.viewmodel.InstancesVM;
import es.dmoral.toasty.Toasty;
+import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
+
public class InstancePickerActivity extends AppCompatActivity {
@@ -60,6 +66,18 @@ public class InstancePickerActivity extends AppCompatActivity {
textviewNoAction = findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
+ RelativeLayout checkbox_container = findViewById(R.id.checkbox_container);
+ LinkedHashMap categories = peertubeInformation.getCategories();
+ if (categories != null && categories.size() > 0) {
+ Iterator> it = categories.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry pair = it.next();
+ CheckBox cb = new CheckBox(InstancePickerActivity.this);
+ cb.setText(pair.getValue());
+ checkbox_container.addView(cb);
+ it.remove();
+ }
+ }
mainLoader.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java
index 618c9af..5754f40 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeAPI.java
@@ -21,6 +21,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.text.Html;
import android.text.SpannableString;
+import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
@@ -617,8 +618,9 @@ public class PeertubeAPI {
params.put("languagesOr[]", strParam);
}
params.put("minUserQuota", instanceParams.getMinUserQuota());
- params.put("nsfwPolicy", instanceParams.getNsfwPolicy());
+ params.put("nsfwPolicy[]", instanceParams.getNsfwPolicy());
}
+ Log.v(Helper.TAG, "params: " + params);
try {
String response = new HttpsConnection(context).get("https://instances.joinpeertube.org/api/v1/instances", 30, params, null);
@@ -2109,7 +2111,11 @@ public class PeertubeAPI {
instance.setName(resobj.getString("name"));
instance.setVersion(resobj.getString("version"));
instance.setShortDescription(resobj.getString("shortDescription"));
- instance.setNSFW(resobj.getBoolean("isNSFW"));
+ if (resobj.has("isNSFW")) {
+ instance.setNSFW(resobj.getBoolean("isNSFW"));
+ } else {
+ instance.setNSFW(false);
+ }
instance.setSignupAllowed(resobj.getBoolean("signupAllowed"));
instance.setSupportsIPv6(resobj.getBoolean("supportsIPv6"));
instance.setTotalInstanceFollowers(resobj.getInt("totalInstanceFollowers"));
diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/InstanceAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/InstanceAdapter.java
index ffcb58f..7e523a6 100644
--- a/app/src/main/java/app/fedilab/fedilabtube/drawer/InstanceAdapter.java
+++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/InstanceAdapter.java
@@ -16,6 +16,8 @@ package app.fedilab.fedilabtube.drawer;
import android.content.Context;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +34,7 @@ import java.util.Map;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.entities.Instance;
+import app.fedilab.fedilabtube.helper.RoundedBackgroundSpan;
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
@@ -52,7 +55,7 @@ public class InstanceAdapter extends RecyclerView.Adapter 0) {
+ holder.description.setText(instance.getShortDescription());
+ holder.description.setVisibility(View.VISIBLE);
+ } else {
+ holder.description.setVisibility(View.GONE);
+ }
+
holder.name.setText(instance.getName());
holder.host.setText(instance.getHost());
- StringBuilder categories = new StringBuilder();
+
+ SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
+ String between = "";
if (instance.getCategories() != null && instance.getCategories().size() > 0) {
Iterator> it = instance.getCategories().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = it.next();
LinkedHashMap info_cat = peertubeInformation.getCategories();
- categories.append(info_cat.get(pair.getKey())).append(" ");
+ String cat = info_cat.get(pair.getKey());
+ stringBuilder.append(between);
+ if (cat != null && cat.trim().toLowerCase().compareTo("null") != 0) {
+ if (between.length() == 0) between = " ";
+ String tag = " " + cat + " ";
+ stringBuilder.append(tag);
+ stringBuilder.setSpan(new RoundedBackgroundSpan(context), stringBuilder.length() - tag.length(), stringBuilder.length() - tag.length() + tag.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ }
it.remove();
}
}
- holder.tags.setText(categories);
+ holder.tags.setText(stringBuilder);
StringBuilder languages = new StringBuilder();
if (instance.getLanguages() != null && instance.getLanguages().size() > 0) {
Iterator> it = instance.getLanguages().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = it.next();
- languages.append(pair.getKey()).append(" ");
+ LinkedHashMap info_lang = peertubeInformation.getLanguages();
+ languages.append(info_lang.get(pair.getValue())).append(" ");
it.remove();
}
}
- holder.languages.setText(languages);
- holder.sensitive_content.setText(context.getString(R.string.sensitive_content, instance.getDefaultNSFWPolicy()));
+
+ if (languages.toString().trim().length() == 0) {
+ holder.languages.setVisibility(View.GONE);
+ } else {
+ holder.languages.setText(languages);
+ holder.languages.setVisibility(View.VISIBLE);
+ }
+
+ if (instance.getDefaultNSFWPolicy().compareTo("do_not_list") != 0) {
+ holder.sensitive_content.setText(context.getString(R.string.sensitive_content, instance.getDefaultNSFWPolicy()));
+ holder.sensitive_content.setVisibility(View.VISIBLE);
+ } else {
+ holder.sensitive_content.setVisibility(View.GONE);
+ }
holder.followers_instance.setText(context.getString(R.string.followers_instance, String.valueOf(instance.getTotalInstanceFollowers())));
}
@@ -113,6 +144,7 @@ public class InstanceAdapter extends RecyclerView.Adapter
+
+
+
+
+
+
+
+
+
+
+
+
+