shorten >4 names to a, b, c +n more
This commit is contained in:
		
							parent
							
								
									8696cf2235
								
							
						
					
					
						commit
						03c34649b4
					
				|  | @ -86,7 +86,27 @@ import eu.siacs.conversations.xmpp.jid.Jid; | ||||||
| 
 | 
 | ||||||
| public class ConversationFragment extends Fragment implements EditMessage.KeyboardListener { | public class ConversationFragment extends Fragment implements EditMessage.KeyboardListener { | ||||||
| 
 | 
 | ||||||
|  | 	final protected List<Message> messageList = new ArrayList<>(); | ||||||
| 	protected Conversation conversation; | 	protected Conversation conversation; | ||||||
|  | 	protected ListView messagesView; | ||||||
|  | 	protected MessageAdapter messageListAdapter; | ||||||
|  | 	private EditMessage mEditMessage; | ||||||
|  | 	private ImageButton mSendButton; | ||||||
|  | 	private RelativeLayout snackbar; | ||||||
|  | 	private TextView snackbarMessage; | ||||||
|  | 	private TextView snackbarAction; | ||||||
|  | 	private Toast messageLoaderToast; | ||||||
|  | 	private OnClickListener clickToMuc = new OnClickListener() { | ||||||
|  | 
 | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View v) { | ||||||
|  | 			Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class); | ||||||
|  | 			intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC); | ||||||
|  | 			intent.putExtra("uuid", conversation.getUuid()); | ||||||
|  | 			startActivity(intent); | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private ConversationActivity activity; | ||||||
| 	private OnClickListener leaveMuc = new OnClickListener() { | 	private OnClickListener leaveMuc = new OnClickListener() { | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | @ -120,16 +140,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 			}); | 			}); | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 	protected ListView messagesView; |  | ||||||
| 	final protected List<Message> messageList = new ArrayList<>(); |  | ||||||
| 	protected MessageAdapter messageListAdapter; |  | ||||||
| 	private EditMessage mEditMessage; |  | ||||||
| 	private ImageButton mSendButton; |  | ||||||
| 	private RelativeLayout snackbar; |  | ||||||
| 	private TextView snackbarMessage; |  | ||||||
| 	private TextView snackbarAction; |  | ||||||
| 	private Toast messageLoaderToast; |  | ||||||
| 
 |  | ||||||
| 	private OnScrollListener mOnScrollListener = new OnScrollListener() { | 	private OnScrollListener mOnScrollListener = new OnScrollListener() { | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | @ -211,70 +221,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 
 |  | ||||||
| 	private int getIndexOf(String uuid, List<Message> messages) { |  | ||||||
| 		if (uuid == null) { |  | ||||||
| 			return messages.size() - 1; |  | ||||||
| 		} |  | ||||||
| 		for(int i = 0; i < messages.size(); ++i) { |  | ||||||
| 			if (uuid.equals(messages.get(i).getUuid())) { |  | ||||||
| 				return i; |  | ||||||
| 			} else { |  | ||||||
| 				Message next = messages.get(i); |  | ||||||
| 				while(next != null && next.wasMergedIntoPrevious()) { |  | ||||||
| 					if (uuid.equals(next.getUuid())) { |  | ||||||
| 						return i; |  | ||||||
| 					} |  | ||||||
| 					next = next.next(); |  | ||||||
| 				} |  | ||||||
| 
 |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		return -1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public Pair<Integer,Integer> getScrollPosition() { |  | ||||||
| 		if (this.messagesView.getCount() == 0 || |  | ||||||
| 				this.messagesView.getLastVisiblePosition() == this.messagesView.getCount() - 1) { |  | ||||||
| 			return null; |  | ||||||
| 		} else { |  | ||||||
| 			final int pos = messagesView.getFirstVisiblePosition(); |  | ||||||
| 			final View view = messagesView.getChildAt(0); |  | ||||||
| 			if (view == null) { |  | ||||||
| 				return null; |  | ||||||
| 			} else { |  | ||||||
| 				return new Pair<>(pos, view.getTop()); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public void setScrollPosition(Pair<Integer,Integer> scrollPosition) { |  | ||||||
| 		if (scrollPosition != null) { |  | ||||||
| 			this.messagesView.setSelectionFromTop(scrollPosition.first, scrollPosition.second); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	protected OnClickListener clickToDecryptListener = new OnClickListener() { |  | ||||||
| 
 |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(View v) { |  | ||||||
| 			PendingIntent pendingIntent = conversation.getAccount().getPgpDecryptionService().getPendingIntent(); |  | ||||||
| 			if (pendingIntent != null) { |  | ||||||
| 				try { |  | ||||||
| 					activity.startIntentSenderForResult(pendingIntent.getIntentSender(), |  | ||||||
|                             ConversationActivity.REQUEST_DECRYPT_PGP, |  | ||||||
|                             null, |  | ||||||
|                             0, |  | ||||||
|                             0, |  | ||||||
|                             0); |  | ||||||
| 				} catch (SendIntentException e) { |  | ||||||
| 					Toast.makeText(activity,R.string.unable_to_connect_to_keychain, Toast.LENGTH_SHORT).show(); |  | ||||||
| 					conversation.getAccount().getPgpDecryptionService().continueDecryption(true); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			updateSnackBar(conversation); |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 	protected OnClickListener clickToVerify = new OnClickListener() { | 	protected OnClickListener clickToVerify = new OnClickListener() { | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | @ -282,23 +228,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 			activity.verifyOtrSessionDialog(conversation, v); | 			activity.verifyOtrSessionDialog(conversation, v); | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 	private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() { |  | ||||||
| 
 |  | ||||||
| 		@Override |  | ||||||
| 		public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |  | ||||||
| 			if (actionId == EditorInfo.IME_ACTION_SEND) { |  | ||||||
| 				InputMethodManager imm = (InputMethodManager) v.getContext() |  | ||||||
| 						.getSystemService(Context.INPUT_METHOD_SERVICE); |  | ||||||
| 				if (imm.isFullscreenMode()) { |  | ||||||
| 					imm.hideSoftInputFromWindow(v.getWindowToken(), 0); |  | ||||||
| 				} |  | ||||||
| 				sendMessage(); |  | ||||||
| 				return true; |  | ||||||
| 			} else { |  | ||||||
| 				return false; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 	private EditMessage.OnCommitContentListener mEditorContentListener = new EditMessage.OnCommitContentListener() { | 	private EditMessage.OnCommitContentListener mEditorContentListener = new EditMessage.OnCommitContentListener() { | ||||||
| 		@Override | 		@Override | ||||||
| 		public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] contentMimeTypes) { | 		public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] contentMimeTypes) { | ||||||
|  | @ -324,6 +253,119 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
|  | 	private Message selectedMessage; | ||||||
|  | 	private OnClickListener mEnableAccountListener = new OnClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View v) { | ||||||
|  | 			final Account account = conversation == null ? null : conversation.getAccount(); | ||||||
|  | 			if (account != null) { | ||||||
|  | 				account.setOption(Account.OPTION_DISABLED, false); | ||||||
|  | 				activity.xmppConnectionService.updateAccount(account); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private OnClickListener mUnblockClickListener = new OnClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(final View v) { | ||||||
|  | 			v.post(new Runnable() { | ||||||
|  | 				@Override | ||||||
|  | 				public void run() { | ||||||
|  | 					v.setVisibility(View.INVISIBLE); | ||||||
|  | 				} | ||||||
|  | 			}); | ||||||
|  | 			if (conversation.isDomainBlocked()) { | ||||||
|  | 				BlockContactDialog.show(activity, conversation); | ||||||
|  | 			} else { | ||||||
|  | 				activity.unblockConversation(conversation); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private OnClickListener mBlockClickListener = new OnClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(final View view) { | ||||||
|  | 			showBlockSubmenu(view); | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private OnClickListener mAddBackClickListener = new OnClickListener() { | ||||||
|  | 
 | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View v) { | ||||||
|  | 			final Contact contact = conversation == null ? null : conversation.getContact(); | ||||||
|  | 			if (contact != null) { | ||||||
|  | 				activity.xmppConnectionService.createContact(contact); | ||||||
|  | 				activity.switchToContactDetails(contact); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private View.OnLongClickListener mLongPressBlockListener = new View.OnLongClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public boolean onLongClick(View v) { | ||||||
|  | 			showBlockSubmenu(v); | ||||||
|  | 			return true; | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private OnClickListener mAllowPresenceSubscription = new OnClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View v) { | ||||||
|  | 			final Contact contact = conversation == null ? null : conversation.getContact(); | ||||||
|  | 			if (contact != null) { | ||||||
|  | 				activity.xmppConnectionService.sendPresencePacket(contact.getAccount(), | ||||||
|  | 						activity.xmppConnectionService.getPresenceGenerator() | ||||||
|  | 								.sendPresenceUpdatesTo(contact)); | ||||||
|  | 				hideSnackbar(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private OnClickListener mAnswerSmpClickListener = new OnClickListener() { | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View view) { | ||||||
|  | 			Intent intent = new Intent(activity, VerifyOTRActivity.class); | ||||||
|  | 			intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT); | ||||||
|  | 			intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString()); | ||||||
|  | 			intent.putExtra(VerifyOTRActivity.EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString()); | ||||||
|  | 			intent.putExtra("mode", VerifyOTRActivity.MODE_ANSWER_QUESTION); | ||||||
|  | 			startActivity(intent); | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	protected OnClickListener clickToDecryptListener = new OnClickListener() { | ||||||
|  | 
 | ||||||
|  | 		@Override | ||||||
|  | 		public void onClick(View v) { | ||||||
|  | 			PendingIntent pendingIntent = conversation.getAccount().getPgpDecryptionService().getPendingIntent(); | ||||||
|  | 			if (pendingIntent != null) { | ||||||
|  | 				try { | ||||||
|  | 					activity.startIntentSenderForResult(pendingIntent.getIntentSender(), | ||||||
|  | 							ConversationActivity.REQUEST_DECRYPT_PGP, | ||||||
|  | 							null, | ||||||
|  | 							0, | ||||||
|  | 							0, | ||||||
|  | 							0); | ||||||
|  | 				} catch (SendIntentException e) { | ||||||
|  | 					Toast.makeText(activity, R.string.unable_to_connect_to_keychain, Toast.LENGTH_SHORT).show(); | ||||||
|  | 					conversation.getAccount().getPgpDecryptionService().continueDecryption(true); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			updateSnackBar(conversation); | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 	private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false); | ||||||
|  | 	private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() { | ||||||
|  | 
 | ||||||
|  | 		@Override | ||||||
|  | 		public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | ||||||
|  | 			if (actionId == EditorInfo.IME_ACTION_SEND) { | ||||||
|  | 				InputMethodManager imm = (InputMethodManager) v.getContext() | ||||||
|  | 						.getSystemService(Context.INPUT_METHOD_SERVICE); | ||||||
|  | 				if (imm.isFullscreenMode()) { | ||||||
|  | 					imm.hideSoftInputFromWindow(v.getWindowToken(), 0); | ||||||
|  | 				} | ||||||
|  | 				sendMessage(); | ||||||
|  | 				return true; | ||||||
|  | 			} else { | ||||||
|  | 				return false; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
| 	private OnClickListener mSendButtonListener = new OnClickListener() { | 	private OnClickListener mSendButtonListener = new OnClickListener() { | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | @ -369,18 +411,53 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 	private OnClickListener clickToMuc = new OnClickListener() { | 	private int completionIndex = 0; | ||||||
|  | 	private int lastCompletionLength = 0; | ||||||
|  | 	private String incomplete; | ||||||
|  | 	private int lastCompletionCursor; | ||||||
|  | 	private boolean firstWord = false; | ||||||
| 
 | 
 | ||||||
| 		@Override | 	private int getIndexOf(String uuid, List<Message> messages) { | ||||||
| 		public void onClick(View v) { | 		if (uuid == null) { | ||||||
| 			Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class); | 			return messages.size() - 1; | ||||||
| 			intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC); | 		} | ||||||
| 			intent.putExtra("uuid", conversation.getUuid()); | 		for (int i = 0; i < messages.size(); ++i) { | ||||||
| 			startActivity(intent); | 			if (uuid.equals(messages.get(i).getUuid())) { | ||||||
|  | 				return i; | ||||||
|  | 			} else { | ||||||
|  | 				Message next = messages.get(i); | ||||||
|  | 				while (next != null && next.wasMergedIntoPrevious()) { | ||||||
|  | 					if (uuid.equals(next.getUuid())) { | ||||||
|  | 						return i; | ||||||
|  | 					} | ||||||
|  | 					next = next.next(); | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return -1; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public Pair<Integer, Integer> getScrollPosition() { | ||||||
|  | 		if (this.messagesView.getCount() == 0 || | ||||||
|  | 				this.messagesView.getLastVisiblePosition() == this.messagesView.getCount() - 1) { | ||||||
|  | 			return null; | ||||||
|  | 		} else { | ||||||
|  | 			final int pos = messagesView.getFirstVisiblePosition(); | ||||||
|  | 			final View view = messagesView.getChildAt(0); | ||||||
|  | 			if (view == null) { | ||||||
|  | 				return null; | ||||||
|  | 			} else { | ||||||
|  | 				return new Pair<>(pos, view.getTop()); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setScrollPosition(Pair<Integer, Integer> scrollPosition) { | ||||||
|  | 		if (scrollPosition != null) { | ||||||
|  | 			this.messagesView.setSelectionFromTop(scrollPosition.first, scrollPosition.second); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	}; |  | ||||||
| 	private ConversationActivity activity; |  | ||||||
| 	private Message selectedMessage; |  | ||||||
| 
 | 
 | ||||||
| 	private void sendMessage() { | 	private void sendMessage() { | ||||||
| 		final String body = mEditMessage.getText().toString(); | 		final String body = mEditMessage.getText().toString(); | ||||||
|  | @ -961,34 +1038,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private OnClickListener mEnableAccountListener = new OnClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(View v) { |  | ||||||
| 			final Account account = conversation == null ? null : conversation.getAccount(); |  | ||||||
| 			if (account != null) { |  | ||||||
| 				account.setOption(Account.OPTION_DISABLED, false); |  | ||||||
| 				activity.xmppConnectionService.updateAccount(account); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private OnClickListener mUnblockClickListener = new OnClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(final View v) { |  | ||||||
| 			v.post(new Runnable() { |  | ||||||
| 				@Override |  | ||||||
| 				public void run() { |  | ||||||
| 					v.setVisibility(View.INVISIBLE); |  | ||||||
| 				} |  | ||||||
| 			}); |  | ||||||
| 			if (conversation.isDomainBlocked()) { |  | ||||||
| 				BlockContactDialog.show(activity, conversation); |  | ||||||
| 			} else { |  | ||||||
| 				activity.unblockConversation(conversation); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private void showBlockSubmenu(View view) { | 	private void showBlockSubmenu(View view) { | ||||||
| 		final Jid jid = conversation.getJid(); | 		final Jid jid = conversation.getJid(); | ||||||
| 		if (jid.isDomainJid()) { | 		if (jid.isDomainJid()) { | ||||||
|  | @ -1015,58 +1064,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private OnClickListener mBlockClickListener = new OnClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(final View view) { |  | ||||||
| 			showBlockSubmenu(view); |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private OnClickListener mAddBackClickListener = new OnClickListener() { |  | ||||||
| 
 |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(View v) { |  | ||||||
| 			final Contact contact = conversation == null ? null : conversation.getContact(); |  | ||||||
| 			if (contact != null) { |  | ||||||
| 				activity.xmppConnectionService.createContact(contact); |  | ||||||
| 				activity.switchToContactDetails(contact); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private View.OnLongClickListener mLongPressBlockListener = new View.OnLongClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public boolean onLongClick(View v) { |  | ||||||
| 			showBlockSubmenu(v); |  | ||||||
| 			return true; |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private OnClickListener mAllowPresenceSubscription = new OnClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(View v) { |  | ||||||
| 			final Contact contact = conversation == null ? null : conversation.getContact(); |  | ||||||
| 			if (contact != null) { |  | ||||||
| 				activity.xmppConnectionService.sendPresencePacket(contact.getAccount(), |  | ||||||
| 						activity.xmppConnectionService.getPresenceGenerator() |  | ||||||
| 								.sendPresenceUpdatesTo(contact)); |  | ||||||
| 				hideSnackbar(); |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private OnClickListener mAnswerSmpClickListener = new OnClickListener() { |  | ||||||
| 		@Override |  | ||||||
| 		public void onClick(View view) { |  | ||||||
| 			Intent intent = new Intent(activity, VerifyOTRActivity.class); |  | ||||||
| 			intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT); |  | ||||||
| 			intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString()); |  | ||||||
| 			intent.putExtra(VerifyOTRActivity.EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString()); |  | ||||||
| 			intent.putExtra("mode", VerifyOTRActivity.MODE_ANSWER_QUESTION); |  | ||||||
| 			startActivity(intent); |  | ||||||
| 		} |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	private void updateSnackBar(final Conversation conversation) { | 	private void updateSnackBar(final Conversation conversation) { | ||||||
| 		final Account account = conversation.getAccount(); | 		final Account account = conversation.getAccount(); | ||||||
| 		final XmppConnection connection = account.getXmppConnection(); | 		final XmppConnection connection = account.getXmppConnection(); | ||||||
|  | @ -1189,17 +1186,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		mSendingPgpMessage.set(false); | 		mSendingPgpMessage.set(false); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE, RECORD_VIDEO; |  | ||||||
| 
 |  | ||||||
| 		public static SendButtonAction valueOfOrDefault(String setting, SendButtonAction text) { |  | ||||||
| 			try { |  | ||||||
| 				return valueOf(setting); |  | ||||||
| 			} catch (IllegalArgumentException e) { |  | ||||||
| 				return TEXT; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) { | 	private int getSendButtonImageResource(SendButtonAction action, Presence.Status status) { | ||||||
| 		switch (action) { | 		switch (action) { | ||||||
| 			case TEXT: | 			case TEXT: | ||||||
|  | @ -1420,10 +1406,17 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 						} | 						} | ||||||
| 						final ReadByMarker markerForSender = ReadByMarker.from(messageList.get(i)); | 						final ReadByMarker markerForSender = ReadByMarker.from(messageList.get(i)); | ||||||
| 						final Message statusMessage; | 						final Message statusMessage; | ||||||
| 						if (shownMarkers.size() > 1) { | 						final int size = shownMarkers.size(); | ||||||
| 							statusMessage = Message.createStatusMessage(conversation, getString(R.string.contacts_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers))); | 						if (size > 1) { | ||||||
|  | 							final String body; | ||||||
|  | 							if (size <= 4) { | ||||||
|  | 								body = getString(R.string.contacts_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers)); | ||||||
|  | 							} else { | ||||||
|  | 								body = getString(R.string.contacts_and_n_more_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers, 3), size - 3); | ||||||
|  | 							} | ||||||
|  | 							statusMessage = Message.createStatusMessage(conversation, body); | ||||||
| 							statusMessage.setCounterparts(shownMarkers); | 							statusMessage.setCounterparts(shownMarkers); | ||||||
| 						} else if (shownMarkers.size() == 1) { | 						} else if (size == 1) { | ||||||
| 							statusMessage = Message.createStatusMessage(conversation, getString(R.string.contact_has_read_up_to_this_point, UIHelper.getDisplayName(shownMarkers.get(0)))); | 							statusMessage = Message.createStatusMessage(conversation, getString(R.string.contact_has_read_up_to_this_point, UIHelper.getDisplayName(shownMarkers.get(0)))); | ||||||
| 							statusMessage.setCounterpart(shownMarkers.get(0).getFullJid()); | 							statusMessage.setCounterpart(shownMarkers.get(0).getFullJid()); | ||||||
| 							statusMessage.setTrueCounterpart(shownMarkers.get(0).getRealJid()); | 							statusMessage.setTrueCounterpart(shownMarkers.get(0).getRealJid()); | ||||||
|  | @ -1508,8 +1501,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		messageSent(); | 		messageSent(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false); |  | ||||||
| 
 |  | ||||||
| 	protected void sendPgpMessage(final Message message) { | 	protected void sendPgpMessage(final Message message) { | ||||||
| 		final ConversationActivity activity = (ConversationActivity) getActivity(); | 		final ConversationActivity activity = (ConversationActivity) getActivity(); | ||||||
| 		final XmppConnectionService xmppService = activity.xmppConnectionService; | 		final XmppConnectionService xmppService = activity.xmppConnectionService; | ||||||
|  | @ -1698,12 +1689,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private int completionIndex = 0; |  | ||||||
| 	private int lastCompletionLength = 0; |  | ||||||
| 	private String incomplete; |  | ||||||
| 	private int lastCompletionCursor; |  | ||||||
| 	private boolean firstWord = false; |  | ||||||
| 
 |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean onTabPressed(boolean repeated) { | 	public boolean onTabPressed(boolean repeated) { | ||||||
| 		if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) { | 		if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) { | ||||||
|  | @ -1763,4 +1748,16 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	enum SendButtonAction { | ||||||
|  | 		TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE, RECORD_VIDEO; | ||||||
|  | 
 | ||||||
|  | 		public static SendButtonAction valueOfOrDefault(String setting, SendButtonAction text) { | ||||||
|  | 			try { | ||||||
|  | 				return valueOf(setting); | ||||||
|  | 			} catch (IllegalArgumentException e) { | ||||||
|  | 				return TEXT; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -365,13 +365,17 @@ public class UIHelper { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static String concatNames(List<MucOptions.User> users) { | 	public static String concatNames(List<MucOptions.User> users) { | ||||||
|  | 		return concatNames(users,users.size()); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public static String concatNames(List<MucOptions.User> users, int max) { | ||||||
| 		StringBuilder builder = new StringBuilder(); | 		StringBuilder builder = new StringBuilder(); | ||||||
| 		final boolean shortNames = users.size() >= 3; | 		final boolean shortNames = users.size() >= 3; | ||||||
| 		for(MucOptions.User user : users) { | 		for(int i = 0; i < Math.max(users.size(),max); ++i) { | ||||||
| 			if (builder.length() != 0) { | 			if (builder.length() != 0) { | ||||||
| 				builder.append(", "); | 				builder.append(", "); | ||||||
| 			} | 			} | ||||||
| 			final String name = UIHelper.getDisplayName(user); | 			final String name = UIHelper.getDisplayName(users.get(0)); | ||||||
| 			builder.append(shortNames ? name.split("\\s+")[0] : name); | 			builder.append(shortNames ? name.split("\\s+")[0] : name); | ||||||
| 		} | 		} | ||||||
| 		return builder.toString(); | 		return builder.toString(); | ||||||
|  |  | ||||||
|  | @ -248,6 +248,7 @@ | ||||||
| 	<string name="add_back">Add back</string> | 	<string name="add_back">Add back</string> | ||||||
| 	<string name="contact_has_read_up_to_this_point">%s has read up to this point</string> | 	<string name="contact_has_read_up_to_this_point">%s has read up to this point</string> | ||||||
| 	<string name="contacts_have_read_up_to_this_point">%s have read up to this point</string> | 	<string name="contacts_have_read_up_to_this_point">%s have read up to this point</string> | ||||||
|  | 	<string name="contacts_and_n_more_have_read_up_to_this_point">%1$s +%2$d% more have read up to this point</string> | ||||||
| 	<string name="publish">Publish</string> | 	<string name="publish">Publish</string> | ||||||
| 	<string name="touch_to_choose_picture">Touch avatar to select picture from gallery</string> | 	<string name="touch_to_choose_picture">Touch avatar to select picture from gallery</string> | ||||||
| 	<string name="publish_avatar_explanation">Please note: Everyone subscribed to your presence updates will be allowed to see this picture.</string> | 	<string name="publish_avatar_explanation">Please note: Everyone subscribed to your presence updates will be allowed to see this picture.</string> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Daniel Gultsch
						Daniel Gultsch