aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/Config.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java11
5 files changed, 28 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index 644b0af82..e2914f9d3 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -88,8 +88,6 @@ public final class Config {
public static final Bitmap.CompressFormat IMAGE_FORMAT = Bitmap.CompressFormat.JPEG;
public static final int IMAGE_QUALITY = 75;
- public static final boolean QUICK_SHARE_ATTACHMENT_CHOICE = true; // set to true to use attachment choice instead of quick share for send button
-
public static final int DEFAULT_ZOOM = 15; //for locations
public final static long LOCATION_FIX_TIME_DELTA = 1000 * 10; // ms
public final static float LOCATION_FIX_SPACE_DELTA = 10; // m
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 71d61dc55..f4e0bf877 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -924,6 +924,10 @@ public class XmppConnectionService extends Service {
}
}
+ public boolean getAttachmentChoicePreference() {
+ return getBooleanPreference(SettingsActivity.QUICK_SHARE_ATTACHMENT_CHOICE, R.bool.quick_share_attachment_choice);
+ }
+
private Presence.Status getTargetPresence() {
if (dndOnSilentMode() && isPhoneSilenced()) {
return Presence.Status.DND;
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 504fae76c..ec9dcf8f0 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -126,6 +126,7 @@ import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.ui.XmppActivity.EXTRA_ACCOUNT;
import static de.pixart.messenger.ui.XmppActivity.REQUEST_INVITE_TO_CONVERSATION;
+import static de.pixart.messenger.ui.util.SendButtonAction.TEXT;
import static de.pixart.messenger.ui.util.SoftKeyboardUtils.hideSoftKeyboard;
import static de.pixart.messenger.xmpp.Patches.ENCRYPTION_EXCEPTIONS;
@@ -1186,7 +1187,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
menuNeedHelp.setVisible(true);
menuSearchUpdates.setVisible(false);
- ConversationMenuConfigurator.configureAttachmentMenu(conversation, menu, Config.QUICK_SHARE_ATTACHMENT_CHOICE);
+ ConversationMenuConfigurator.configureAttachmentMenu(conversation, menu, activity.xmppConnectionService.getAttachmentChoicePreference());
ConversationMenuConfigurator.configureEncryptionMenu(conversation, menu);
} else {
menuNeedHelp.setVisible(false);
@@ -2557,7 +2558,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
final Conversation c = this.conversation;
final Presence.Status status;
final String text = this.binding.textinput == null ? "" : this.binding.textinput.getText().toString();
- final SendButtonAction action = SendButtonTool.getAction(getActivity(), c, text);
+ SendButtonAction action = SendButtonTool.getAction(getActivity(), c, text);
if (useSendButtonToIndicateStatus && c.getAccount().getStatus() == Account.State.ONLINE) {
if (activity.xmppConnectionService != null && activity.xmppConnectionService.getMessageArchiveService().isCatchingUp(c)) {
status = Presence.Status.OFFLINE;
@@ -2569,6 +2570,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} else {
status = Presence.Status.OFFLINE;
}
+ if (action.toString().equals("CHOOSE_ATTACHMENT") && !activity.xmppConnectionService.getAttachmentChoicePreference()) {
+ action = TEXT;
+ }
this.binding.textSendButton.setTag(action);
this.binding.textSendButton.setImageResource(SendButtonTool.getSendButtonImageResource(getActivity(), action, status));
}
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index 9ee11bd0b..1ace03e5e 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -58,12 +58,15 @@ public class SettingsActivity extends XmppActivity implements
public static final String SHOW_FOREGROUND_SERVICE = "show_foreground_service";
public static final String USE_BUNDLED_EMOJIS = "use_bundled_emoji";
public static final String USE_MULTI_ACCOUNTS = "use_multi_accounts";
+ public static final String QUICK_SHARE_ATTACHMENT_CHOICE = "quick_share_attachment_choice";
public static final int REQUEST_WRITE_LOGS = 0xbf8701;
Preference multiAccountPreference;
Preference BundledEmojiPreference;
+ Preference QuickShareAttachmentChoicePreference;
boolean isMultiAccountChecked = false;
boolean isBundledEmojiChecked;
+ boolean isQuickShareAttachmentChoiceChecked = false;
private SettingsFragment mSettingsFragment;
@Override
@@ -105,6 +108,15 @@ public class SettingsActivity extends XmppActivity implements
isBundledEmojiChecked = ((CheckBoxPreference) BundledEmojiPreference).isChecked();
}
+ QuickShareAttachmentChoicePreference = mSettingsFragment.findPreference("quick_share_attachment_choice");
+ if (QuickShareAttachmentChoicePreference != null) {
+ QuickShareAttachmentChoicePreference.setOnPreferenceChangeListener((preference, newValue) -> {
+ recreate();
+ return true;
+ });
+ isQuickShareAttachmentChoiceChecked = ((CheckBoxPreference) QuickShareAttachmentChoicePreference).isChecked();
+ }
+
changeOmemoSettingSummary();
if (Config.FORCE_ORBOT) {
@@ -173,7 +185,7 @@ public class SettingsActivity extends XmppActivity implements
quickAction.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
}
- if (Config.QUICK_SHARE_ATTACHMENT_CHOICE) {
+ if (isQuickShareAttachmentChoiceChecked) {
if (UIPreferenceScreen != null && quickAction != null) {
UIPreferenceScreen.removePreference(quickAction);
}
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 291edb822..b4b0ecc28 100644
--- a/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java
+++ b/src/main/java/de/pixart/messenger/ui/util/SendButtonTool.java
@@ -38,10 +38,9 @@ import de.pixart.messenger.R;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Presence;
import de.pixart.messenger.ui.ConversationFragment;
+import de.pixart.messenger.ui.SettingsActivity;
import de.pixart.messenger.utils.UIHelper;
-import static de.pixart.messenger.Config.QUICK_SHARE_ATTACHMENT_CHOICE;
-
public class SendButtonTool {
public static SendButtonAction getAction(Activity activity, Conversation c, String text) {
@@ -61,12 +60,13 @@ public class SendButtonTool {
if (conference && c.getNextCounterpart() != null) {
return SendButtonAction.CANCEL;
} else {
- if (QUICK_SHARE_ATTACHMENT_CHOICE && AttachmentsVisible(c)) {
+ 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)) {
return SendButtonAction.CHOOSE_ATTACHMENT;
- } else if (QUICK_SHARE_ATTACHMENT_CHOICE && !AttachmentsVisible(c)) {
+ } else if (quickShareChoice && !AttachmentsVisible(c)) {
return SendButtonAction.TEXT;
} else {
- String setting = preferences.getString("quick_action", activity.getResources().getString(R.string.quick_action));
if (!setting.equals("none") && UIHelper.receivedLocationQuestion(c.getLatestMessage())) {
return SendButtonAction.SEND_LOCATION;
} else {
@@ -198,5 +198,4 @@ public class SendButtonTool {
return res;
}
-
} \ No newline at end of file