aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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
-rw-r--r--src/main/res/values/defaults.xml1
-rw-r--r--src/main/res/values/strings.xml2
-rw-r--r--src/main/res/xml/preferences.xml5
8 files changed, 36 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
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index 98509a48e..214dbe642 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -108,6 +108,7 @@
<string name="default_font_size">small</string>
<bool name="start_searching">false</bool>
<bool name="show_record_voice_btn">true</bool>
+ <bool name="quick_share_attachment_choice">true</bool>
<string-array name="domains">
<item>pix-art.de</item>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 47a01d3c9..f5dabc615 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -810,4 +810,6 @@
<string name="no_location_permission">Pix-Art Messenger needs access to location services</string>
<string name="pref_show_record_voice_btn_summary">Show record voice button in chats as quick action</string>
<string name="pref_show_record_voice_btn">Show record voice button</string>
+ <string name="pref_use_quick_share_attachment_choice_summary">Replace send button with attachment choice if no message is typed. Otherwise show quick actions, which can be cofigured in the following setting.</string>
+ <string name="pref_quick_share_attachment_choice">Attachment choice</string>
</resources>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 31ca6158b..b4edb7a34 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -38,6 +38,11 @@
android:key="presence_colored_names"
android:summary="@string/pref_use_colored_names_to_indicate_status_summary"
android:title="@string/pref_use_colored_names_to_indicate_status" />
+ <CheckBoxPreference
+ android:defaultValue="@bool/quick_share_attachment_choice"
+ android:key="quick_share_attachment_choice"
+ android:summary="@string/pref_use_quick_share_attachment_choice_summary"
+ android:title="@string/pref_quick_share_attachment_choice" />
<ListPreference
android:defaultValue="@string/quick_action"
android:dialogTitle="@string/choose_quick_action"