aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/http/services/MuclumbusService.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ChannelSearchResultAdapter.java9
-rw-r--r--src/main/java/de/pixart/messenger/utils/LanguageUtils.java27
3 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/http/services/MuclumbusService.java b/src/main/java/de/pixart/messenger/http/services/MuclumbusService.java
index 7c8ca9e32..b849b664d 100644
--- a/src/main/java/de/pixart/messenger/http/services/MuclumbusService.java
+++ b/src/main/java/de/pixart/messenger/http/services/MuclumbusService.java
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Set;
import de.pixart.messenger.services.AvatarService;
+import de.pixart.messenger.utils.LanguageUtils;
import de.pixart.messenger.utils.UIHelper;
import retrofit2.Call;
import retrofit2.http.Body;
@@ -35,6 +36,7 @@ public interface MuclumbusService {
public String address;
public String name;
public String description;
+ public String language;
public String getName() {
return name;
@@ -52,6 +54,10 @@ public interface MuclumbusService {
}
}
+ public String getLanguage() {
+ return LanguageUtils.convert(language);
+ }
+
@Override
public int getAvatarBackgroundColor() {
Jid room = getRoom();
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ChannelSearchResultAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ChannelSearchResultAdapter.java
index d137e3a6f..bfb9665be 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ChannelSearchResultAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ChannelSearchResultAdapter.java
@@ -10,6 +10,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import java.util.Locale;
+
import de.pixart.messenger.R;
import de.pixart.messenger.databinding.SearchResultItemBinding;
import de.pixart.messenger.http.services.MuclumbusService;
@@ -47,12 +49,19 @@ public class ChannelSearchResultAdapter extends ListAdapter<MuclumbusService.Roo
final MuclumbusService.Room searchResult = getItem(position);
viewHolder.binding.name.setText(searchResult.getName());
final String description = searchResult.getDescription();
+ final String language = searchResult.getLanguage();
if (TextUtils.isEmpty(description)) {
viewHolder.binding.description.setVisibility(View.GONE);
} else {
viewHolder.binding.description.setText(description);
viewHolder.binding.description.setVisibility(View.VISIBLE);
}
+ if (language == null || language.length() != 2) {
+ viewHolder.binding.language.setVisibility(View.GONE);
+ } else {
+ viewHolder.binding.language.setText("(" + language.toUpperCase(Locale.ENGLISH) + ")");
+ viewHolder.binding.language.setVisibility(View.VISIBLE);
+ }
viewHolder.binding.room.setText(searchResult.getRoom().asBareJid().toString());
AvatarWorkerTask.loadAvatar(searchResult, viewHolder.binding.avatar, R.dimen.avatar);
viewHolder.binding.getRoot().setOnClickListener(v -> listener.onChannelSearchResult(searchResult));
diff --git a/src/main/java/de/pixart/messenger/utils/LanguageUtils.java b/src/main/java/de/pixart/messenger/utils/LanguageUtils.java
new file mode 100644
index 000000000..f0229e785
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/utils/LanguageUtils.java
@@ -0,0 +1,27 @@
+package de.pixart.messenger.utils;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Locale;
+import java.util.Map;
+
+public class LanguageUtils {
+ private static final Map<String, String> LANGUAGE_MAP;
+
+ static {
+ ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
+ builder.put("german", "de");
+ builder.put("deutsch", "de");
+ builder.put("english", "en");
+ builder.put("russian", "ru");
+ LANGUAGE_MAP = builder.build();
+ }
+
+ public static String convert(final String in) {
+ if (in == null) {
+ return null;
+ }
+ final String out = LANGUAGE_MAP.get(in.toLowerCase(Locale.US));
+ return out == null ? in : out;
+ }
+}