diff options
Diffstat (limited to 'src')
4 files changed, 64 insertions, 7 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; + } +} diff --git a/src/main/res/layout/search_result_item.xml b/src/main/res/layout/search_result_item.xml index 856aa7ab6..1edefa1f8 100644 --- a/src/main/res/layout/search_result_item.xml +++ b/src/main/res/layout/search_result_item.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <layout 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"> <RelativeLayout android:layout_width="match_parent" @@ -17,26 +18,40 @@ android:scaleType="centerCrop" app:riv_corner_radius="2dp" /> - <LinearLayout + <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="@dimen/avatar_item_distance" android:layout_marginLeft="@dimen/avatar_item_distance" android:layout_toEndOf="@+id/avatar" - android:layout_toRightOf="@+id/avatar" - android:orientation="vertical"> + android:layout_toRightOf="@+id/avatar"> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" - android:textAppearance="@style/TextAppearance.Conversations.Subhead" /> + android:textAppearance="@style/TextAppearance.Conversations.Subhead" + tools:text="Proosdy IM Chat trantu" /> + + <TextView + android:id="@+id/language" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@id/name" + android:layout_marginStart="8sp" + android:layout_marginLeft="8sp" + android:layout_toEndOf="@id/name" + android:layout_toRightOf="@id/name" + android:singleLine="true" + android:textAppearance="@style/TextAppearance.Conversations.Caption" + tools:text="EN" /> <TextView android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_below="@id/name" android:maxLines="2" android:textAppearance="@style/TextAppearance.Conversations.Body1" /> @@ -44,9 +59,9 @@ android:id="@+id/room" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_below="@id/description" android:maxLines="2" android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary" /> - </LinearLayout> - + </RelativeLayout> </RelativeLayout> </layout>
\ No newline at end of file |