diff options
Diffstat (limited to '')
6 files changed, 26 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 137fca339..5f66c4200 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -171,6 +171,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private Conversation conversation; private Toast messageLoaderToast; private ConversationsActivity activity; + private Menu mOptionsMenu; protected OnClickListener clickToVerify = new OnClickListener() { @Override public void onClick(View v) { @@ -1068,6 +1069,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke boolean hasAttachments = mediaPreviewAdapter.hasAttachments(); binding.textinput.setVisibility(hasAttachments ? View.GONE : View.VISIBLE); binding.mediaPreview.setVisibility(hasAttachments ? View.VISIBLE : View.GONE); + ConversationMenuConfigurator.configureAttachmentMenu(conversation, mOptionsMenu, activity.xmppConnectionService.getAttachmentChoicePreference(), hasAttachments); updateSendButton(); } @@ -1117,6 +1119,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { + mOptionsMenu = menu; + boolean hasAttachments = mediaPreviewAdapter != null && mediaPreviewAdapter.hasAttachments(); menuInflater.inflate(R.menu.fragment_conversation, menu); final MenuItem menuInviteContact = menu.findItem(R.id.action_invite); final MenuItem menuNeedHelp = menu.findItem(R.id.action_create_issue); @@ -1139,7 +1143,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } menuNeedHelp.setVisible(true); menuSearchUpdates.setVisible(false); - ConversationMenuConfigurator.configureAttachmentMenu(conversation, menu, activity.xmppConnectionService.getAttachmentChoicePreference()); + ConversationMenuConfigurator.configureAttachmentMenu(conversation, menu, activity.xmppConnectionService.getAttachmentChoicePreference(), hasAttachments); ConversationMenuConfigurator.configureEncryptionMenu(conversation, menu); } else { menuNeedHelp.setVisible(false); @@ -1159,7 +1163,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke binding.textinput.addTextChangedListener(new StylingHelper.MessageEditorStyler(binding.textinput)); binding.textinput.setOnEditorActionListener(mEditorActionListener); binding.textinput.setRichContentListener(new String[]{"image/*"}, mEditorContentListener); - binding.textinput.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_blue_dark : R.drawable.message_bubble_sent_blue); + binding.textinput.setBackgroundResource(messageInputBubble()); binding.textSendButton.setOnClickListener(this.mSendButtonListener); binding.textSendButton.setOnLongClickListener(this.mSendButtonLongListener); @@ -1170,6 +1174,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke binding.messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); mediaPreviewAdapter = new MediaPreviewAdapter(this); binding.mediaPreview.setAdapter(mediaPreviewAdapter); + binding.mediaPreview.setBackgroundResource(messageInputBubble()); messageListAdapter = new MessageAdapter((XmppActivity) getActivity(), this.messageList); messageListAdapter.setOnContactPictureClicked(message -> { String fingerprint; @@ -3072,6 +3077,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } + private int messageInputBubble() { + return activity.isDarkTheme() ? R.drawable.message_bubble_sent_blue_dark : R.drawable.message_bubble_sent_blue; + } public Conversation getConversation() { return conversation; diff --git a/src/main/java/de/pixart/messenger/ui/SearchActivity.java b/src/main/java/de/pixart/messenger/ui/SearchActivity.java index 9ea9e7592..e9ba1d426 100644 --- a/src/main/java/de/pixart/messenger/ui/SearchActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SearchActivity.java @@ -56,12 +56,11 @@ import de.pixart.messenger.services.MessageSearchTask; import de.pixart.messenger.ui.adapter.MessageAdapter; import de.pixart.messenger.ui.interfaces.OnSearchResultsAvailable; import de.pixart.messenger.ui.util.ChangeWatcher; -import de.pixart.messenger.ui.util.StyledAttributes; import de.pixart.messenger.ui.util.DateSeparator; -import de.pixart.messenger.ui.util.Drawable; import de.pixart.messenger.ui.util.ListViewUtils; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.ui.util.ShareUtil; +import de.pixart.messenger.ui.util.StyledAttributes; import de.pixart.messenger.utils.FtsUtils; import de.pixart.messenger.utils.MessageUtils; diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index c9c6006de..1c0992cf1 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -38,6 +38,7 @@ import de.pixart.messenger.crypto.OmemoSetting; import de.pixart.messenger.entities.Account; import de.pixart.messenger.services.ExportLogsService; import de.pixart.messenger.services.MemorizingTrustManager; +import de.pixart.messenger.ui.util.StyledAttributes; import de.pixart.messenger.utils.TimeframeUtils; import rocks.xmpp.addr.Jid; diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java index 1f1b2877e..17479cf99 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ListItemAdapter.java @@ -105,16 +105,16 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { } } if (offline) { - viewHolder.name.setTextColor(StyledAttributes.get(activity, R.attr.text_Color_Main)); + viewHolder.name.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main)); viewHolder.name.setAlpha(INACTIVE_ALPHA); viewHolder.jid.setAlpha(INACTIVE_ALPHA); viewHolder.avatar.setAlpha(INACTIVE_ALPHA); viewHolder.tags.setAlpha(INACTIVE_ALPHA); } else { if (ShowPresenceColoredNames()) { - viewHolder.name.setTextColor(color != 0 ? color : StyledAttributes.get(activity, R.attr.text_Color_Main)); + viewHolder.name.setTextColor(color != 0 ? color : StyledAttributes.getColor(activity, R.attr.text_Color_Main)); } else { - viewHolder.name.setTextColor(StyledAttributes.get(activity, R.attr.text_Color_Main)); + viewHolder.name.setTextColor(StyledAttributes.getColor(activity, R.attr.text_Color_Main)); } viewHolder.name.setAlpha(ACTIVE_ALPHA); viewHolder.jid.setAlpha(ACTIVE_ALPHA); diff --git a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java index 5c86b4a1b..edca88f78 100644 --- a/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java +++ b/src/main/java/de/pixart/messenger/ui/util/ConversationMenuConfigurator.java @@ -65,12 +65,13 @@ public class ConversationMenuConfigurator { menu.findItem(R.id.attach_location).setVisible(locationAvailable); } - public static void configureAttachmentMenu(@NonNull Conversation conversation, Menu menu, Boolean Quick_share_attachment_choice) { + public static void configureAttachmentMenu(@NonNull Conversation conversation, Menu menu, Boolean Quick_share_attachment_choice, boolean hasAttachments) { final MenuItem menuAttach = menu.findItem(R.id.action_attach_file); - if (Quick_share_attachment_choice) { + if (Quick_share_attachment_choice && !hasAttachments) { menuAttach.setVisible(false); return; } + final boolean visible; if (conversation.getMode() == Conversation.MODE_MULTI) { visible = conversation.getAccount().httpUploadAvailable() && conversation.getMucOptions().participating(); diff --git a/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java b/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java index b4b0ecc28..67cd48b6a 100644 --- a/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java +++ b/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java @@ -44,7 +44,6 @@ import de.pixart.messenger.utils.UIHelper; public class SendButtonTool { public static SendButtonAction getAction(Activity activity, Conversation c, String text) { - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final boolean empty = text.length() == 0; final boolean conference = c.getMode() == Conversation.MODE_MULTI; if (c.getCorrectingMessage() != null && (empty || text.equals(c.getCorrectingMessage().getBody()))) { @@ -57,14 +56,14 @@ public class SendButtonTool { } } else { if (empty) { + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); if (conference && c.getNextCounterpart() != null) { return SendButtonAction.CANCEL; } else { - boolean quickShareChoice = preferences.getBoolean(SettingsActivity.QUICK_SHARE_ATTACHMENT_CHOICE, activity.getResources().getBoolean(R.bool.quick_share_attachment_choice)); String setting = preferences.getString("quick_action", activity.getResources().getString(R.string.quick_action)); - if (quickShareChoice && AttachmentsVisible(c)) { + if (quickShareChoice(activity) && AttachmentsVisible(c)) { return SendButtonAction.CHOOSE_ATTACHMENT; - } else if (quickShareChoice && !AttachmentsVisible(c)) { + } else if (quickShareChoice(activity) && !AttachmentsVisible(c)) { return SendButtonAction.TEXT; } else { if (!setting.equals("none") && UIHelper.receivedLocationQuestion(c.getLatestMessage())) { @@ -198,4 +197,9 @@ public class SendButtonTool { return res; } + + public static boolean quickShareChoice(Activity activity) { + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); + return preferences.getBoolean(SettingsActivity.QUICK_SHARE_ATTACHMENT_CHOICE, activity.getResources().getBoolean(R.bool.quick_share_attachment_choice)); + } }
\ No newline at end of file |