Some fixes

This commit is contained in:
Thomas 2020-09-15 16:07:05 +02:00
parent 3e694b8ac2
commit a87ec4ffa5
5 changed files with 19 additions and 13 deletions

View File

@ -155,11 +155,11 @@ public class LoginActivity extends AppCompatActivity {
Toasty.error(LoginActivity.this, getString(R.string.not_valide_instance)).show();
return;
}
instance = host = login_instance.getText().toString();
instance = host = login_instance.getText().toString().trim().toLowerCase();
}
if (Arrays.asList(Helper.openid).contains(host) || !BuildConfig.full_instances) {
if (Arrays.asList(Helper.openid).contains(host) && !BuildConfig.full_instances) {
new Thread(() -> {
try {
actionToken = "/api/v1/oauth-clients/local";

View File

@ -319,9 +319,8 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
Map.Entry<Integer, String> entryInt = privacyToSend.entrySet().iterator().next();
privacy = entryInt.getValue();
}
String category = null;
if (categoryToSend != null) {
if (categoryToSend != null && categoryToSend.entrySet().iterator().hasNext()) {
Map.Entry<Integer, String> entryInt = categoryToSend.entrySet().iterator().next();
category = entryInt.getValue();
}
@ -358,7 +357,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
Iterator<Map.Entry<Integer, String>> it = privacies.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(privacy))
if (pair.getValue().compareTo(privacy) == 0)
break;
it.remove();
privacyPosition++;
@ -369,7 +368,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
Iterator<Map.Entry<Integer, String>> it = licences.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(license))
if (pair.getValue().compareTo(license) == 0)
break;
it.remove();
licensePosition++;
@ -380,7 +379,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next();
if (pair.getValue().equals(category))
if (pair.getValue().compareTo(category) == 0)
break;
it.remove();
categoryPosition++;

View File

@ -377,8 +377,16 @@ public class PeertubeAPI {
LinkedHashMap<Integer, String> category = new LinkedHashMap<>();
LinkedHashMap<Integer, String> license = new LinkedHashMap<>();
LinkedHashMap<Integer, String> privacy = new LinkedHashMap<>();
category.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label"));
if (!resobj.getJSONObject("category").isNull("id")) {
license.put(resobj.getJSONObject("category").getInt("id"), resobj.getJSONObject("category").getString("label"));
} else {
license.put(1, resobj.getJSONObject("category").getString("label"));
}
if (!resobj.getJSONObject("licence").isNull("id")) {
license.put(resobj.getJSONObject("licence").getInt("id"), resobj.getJSONObject("licence").getString("label"));
} else {
license.put(1, resobj.getJSONObject("licence").getString("label"));
}
privacy.put(resobj.getJSONObject("privacy").getInt("id"), resobj.getJSONObject("privacy").getString("label"));
langue.put(resobj.getJSONObject("language").getString("id"), resobj.getJSONObject("language").get("label").toString());

View File

@ -48,7 +48,6 @@ import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.helper.CustomQuoteSpan;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.viewmodel.FeedsVM;