Merge pull request #419 from nextcloud/fix-413

First steps towards fixing german
This commit is contained in:
Mario Đanić 2019-01-17 12:33:17 +01:00 committed by GitHub
commit a6f635966a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 39 deletions

View File

@ -21,12 +21,8 @@
package com.nextcloud.talk.adapters.items; package com.nextcloud.talk.adapters.items;
import android.content.Context; import android.content.Context;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.text.style.StyleSpan;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -128,7 +124,6 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
holder.dialogUnreadBubble.setVisibility(View.GONE); holder.dialogUnreadBubble.setVisibility(View.GONE);
} }
String authorDisplayName;
if (conversation.isHasPassword()) { if (conversation.isHasPassword()) {
holder.passwordProtectedRoomImageView.setVisibility(View.VISIBLE); holder.passwordProtectedRoomImageView.setVisibility(View.VISIBLE);
@ -151,29 +146,26 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
holder.dialogLastMessageUserAvatar.setVisibility(View.GONE); holder.dialogLastMessageUserAvatar.setVisibility(View.GONE);
holder.dialogLastMessage.setText(conversation.getLastMessage().getText()); holder.dialogLastMessage.setText(conversation.getLastMessage().getText());
} else { } else {
if (conversation.getLastMessage().getActorId().equals(userEntity.getUserId())) { String authorDisplayName = "";
authorDisplayName = context.getString(R.string.nc_chat_you); conversation.getLastMessage().setActiveUserId(userEntity.getUserId());
} else { String text;
if (!TextUtils.isEmpty(conversation.getLastMessage().getActorDisplayName())) {
authorDisplayName = conversation.getLastMessage().getActorDisplayName();
} else {
authorDisplayName = context.getString(R.string.nc_nick_guest);
}
}
if (conversation.getLastMessage().getMessageType().equals(ChatMessage.MessageType.REGULAR_TEXT_MESSAGE)) { if (conversation.getLastMessage().getMessageType().equals(ChatMessage.MessageType.REGULAR_TEXT_MESSAGE)) {
authorDisplayName += ": "; if (conversation.getLastMessage().getActorId().equals(conversation.getLastMessage().getActiveUserId())) {
text = String.format(context.getString(R.string.nc_formatted_message_you), conversation.getLastMessage().getLastMessageDisplayText();
} else {
authorDisplayName = !TextUtils.isEmpty(conversation.getLastMessage().getActorDisplayName()) ?
conversation.getLastMessage().getActorDisplayName() :
"guests".equals(conversation.getLastMessage().getActorType()) ?
NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest) : "";
text = String.format(context.getString(R.string.nc_formatted_message),
authorDisplayName,
conversation.getLastMessage().getLastMessageDisplayText());
}
} else { } else {
authorDisplayName += " "; text = conversation.getLastMessage().getLastMessageDisplayText();
} }
String fullString = authorDisplayName + conversation.getLastMessage().getLastMessageDisplayText(); holder.dialogLastMessage.setText(text);
Spannable spannableString = new SpannableString(fullString);
final StyleSpan boldStyleSpan = new StyleSpan(Typeface.BOLD);
spannableString.setSpan(boldStyleSpan, 0, authorDisplayName.length(), Spannable
.SPAN_INCLUSIVE_INCLUSIVE);
holder.dialogLastMessage.setText(spannableString);
int smallAvatarSize = Math.round(context.getResources().getDimension(R.dimen.small_item_height)); int smallAvatarSize = Math.round(context.getResources().getDimension(R.dimen.small_item_height));

View File

@ -20,6 +20,7 @@
package com.nextcloud.talk.models.json.chat; package com.nextcloud.talk.models.json.chat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonIgnore; import com.bluelinelabs.logansquare.annotation.JsonIgnore;
@ -197,17 +198,47 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
if (getMessageType().equals(MessageType.SINGLE_LINK_GIPHY_MESSAGE) if (getMessageType().equals(MessageType.SINGLE_LINK_GIPHY_MESSAGE)
|| getMessageType().equals(MessageType.SINGLE_LINK_TENOR_MESSAGE) || getMessageType().equals(MessageType.SINGLE_LINK_TENOR_MESSAGE)
|| getMessageType().equals(MessageType.SINGLE_LINK_GIF_MESSAGE)) { || getMessageType().equals(MessageType.SINGLE_LINK_GIF_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_gif)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_gif_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_a_gif),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} else if (getMessageType().equals(MessageType.SINGLE_NC_ATTACHMENT_MESSAGE)) { } else if (getMessageType().equals(MessageType.SINGLE_NC_ATTACHMENT_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_attachment)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_attachment_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_an_attachment),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} else if (getMessageType().equals(MessageType.SINGLE_LINK_MESSAGE)) { } else if (getMessageType().equals(MessageType.SINGLE_LINK_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_link)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_link_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_a_link),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} else if (getMessageType().equals(MessageType.SINGLE_LINK_AUDIO_MESSAGE)) { } else if (getMessageType().equals(MessageType.SINGLE_LINK_AUDIO_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_audio)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_audio_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_an_audio),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} else if (getMessageType().equals(MessageType.SINGLE_LINK_VIDEO_MESSAGE)) { } else if (getMessageType().equals(MessageType.SINGLE_LINK_VIDEO_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_video)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_a_video_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_a_video),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} else if (getMessageType().equals(MessageType.SINGLE_LINK_IMAGE_MESSAGE)) { } else if (getMessageType().equals(MessageType.SINGLE_LINK_IMAGE_MESSAGE)) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_image)); if (getActorId().equals(getActiveUserId())) {
return (NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_sent_an_image_you));
} else {
return (String.format(NextcloudTalkApplication.getSharedApplication().getResources().getString(R.string.nc_sent_an_image),
!TextUtils.isEmpty(getActorDisplayName()) ? getActorDisplayName() : NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest)));
}
} }
} }

View File

@ -18,7 +18,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>. ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Bottom Navigation --> <!-- Bottom Navigation -->
<string name="nc_settings">Settings</string> <string name="nc_settings">Settings</string>
@ -179,14 +179,21 @@
<string name="nc_conversation_menu_conversation_info">Conversation info</string> <string name="nc_conversation_menu_conversation_info">Conversation info</string>
<string name="nc_new_messages">New messages</string> <string name="nc_new_messages">New messages</string>
<string name="nc_no_messages_yet">No messages yet</string> <string name="nc_no_messages_yet">No messages yet</string>
<string name="nc_chat_you">You</string> <string name="nc_sent_a_link" formatted="true">%1$s sent a link.</string>
<string name="nc_sent_a_link">sent a link.</string> <string name="nc_sent_a_gif" formatted="true">%1$s sent a GIF.</string>
<string name="nc_sent_a_gif">sent a GIF.</string> <string name="nc_sent_an_attachment" formatted="true">%1$s sent an attachment.</string>
<string name="nc_sent_an_attachment">sent an attachment.</string> <string name="nc_sent_an_audio" formatted="true">%1$s sent an audio.</string>
<string name="nc_sent_an_audio">sent an audio.</string> <string name="nc_sent_a_video" formatted="true">%1$s sent a video.</string>
<string name="nc_sent_a_video">sent a video.</string> <string name="nc_sent_an_image" formatted="true">%1$s sent an image.</string>
<string name="nc_sent_an_image">sent an image.</string> <string name="nc_sent_a_link_you" tools:ignore="ExtraTranslation">You sent a link.</string>
<string name="nc_sent_a_gif_you">You sent a GIF.</string>
<string name="nc_sent_an_attachment_you">You sent an attachment.</string>
<string name="nc_sent_an_audio_you">You sent an audio.</string>
<string name="nc_sent_a_video_you">You sent a video.</string>
<string name="nc_sent_an_image_you">You sent an image.</string>
<string name="nc_formatted_message" translatable="false">%1$s: %2$s</string>
<!-- When translating to German, please use non-formal variant -->
<string name="nc_formatted_message_you">You: %1$s</string>
<!-- Contacts endless loading --> <!-- Contacts endless loading -->
<string name="nc_no_more_load_retry">No more items to load. Refresh to retry.</string> <string name="nc_no_more_load_retry">No more items to load. Refresh to retry.</string>