From ac22007e286a19cdc68d07593dd1f04cc4a952a9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 27 Feb 2018 21:11:00 +0100 Subject: [PATCH] removed 'preemptive grant' setting --- .../conversations/services/XmppConnectionService.java | 3 +-- .../eu/siacs/conversations/ui/ConversationFragment.java | 6 +++--- .../java/eu/siacs/conversations/ui/SettingsActivity.java | 7 +++++++ .../conversations/ui/StartConversationActivity.java | 2 +- .../java/eu/siacs/conversations/ui/XmppActivity.java | 8 +------- src/main/res/values/defaults.xml | 1 - src/main/res/values/strings.xml | 2 -- src/main/res/xml/preferences.xml | 9 +++------ 8 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 19cdf9466..f672d495d 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2724,8 +2724,7 @@ public class XmppConnectionService extends Service { } } - public void createContact(Contact contact) { - boolean autoGrant = getBooleanPreference("grant_new_contacts", R.bool.grant_new_contacts); + public void createContact(Contact contact, boolean autoGrant) { if (autoGrant) { contact.setOption(Contact.Options.PREEMPTIVE_GRANT); contact.setOption(Contact.Options.ASKING); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 2c6ec41d2..1951fb6cb 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -309,7 +309,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public void onClick(View v) { final Contact contact = conversation == null ? null : conversation.getContact(); if (contact != null) { - activity.xmppConnectionService.createContact(contact); + activity.xmppConnectionService.createContact(contact,true); activity.switchToContactDetails(contact); } } @@ -1701,6 +1701,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke setupIme(); + final boolean scrolledToBottomAndNoPending = this.scrolledToBottom() && pendingScrollState.peek() == null; + this.binding.textSendButton.setContentDescription(activity.getString(R.string.send_message_to_x, conversation.getName())); this.binding.textinput.setKeyboardListener(null); this.binding.textinput.setText(""); @@ -1710,8 +1712,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke refresh(false); this.conversation.messagesLoaded.set(true); - final boolean scrolledToBottomAndNoPending = this.scrolledToBottom() && pendingScrollState.peek() == null; - Log.d(Config.LOGTAG,"scrolledToBottomAndNoPending="+Boolean.toString(scrolledToBottomAndNoPending)); if (hasExtras || scrolledToBottomAndNoPending) { diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index ad0cb58f6..7150c87f2 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -91,6 +91,8 @@ public class SettingsActivity extends XmppActivity implements } } + PreferenceScreen mainPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("main_screen"); + //this feature is only available on Huawei Android 6. PreferenceScreen huaweiPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("huawei"); if (huaweiPreferenceScreen != null) { @@ -99,6 +101,11 @@ public class SettingsActivity extends XmppActivity implements if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) { PreferenceCategory generalCategory = (PreferenceCategory) mSettingsFragment.findPreference("general"); generalCategory.removePreference(huaweiPreferenceScreen); + if (generalCategory.getPreferenceCount() == 0) { + if (mainPreferenceScreen != null) { + mainPreferenceScreen.removePreference(generalCategory); + } + } } } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index c12c0c4a8..a13d3f402 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -474,7 +474,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } else if (contact.showInRoster()) { throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists)); } else { - xmppConnectionService.createContact(contact); + xmppConnectionService.createContact(contact,true); if (invite != null && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints()); } diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 42cf18872..cf3db9380 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -683,13 +683,7 @@ public abstract class XmppActivity extends AppCompatActivity { builder.setTitle(contact.getJid().toString()); builder.setMessage(getString(R.string.not_in_roster)); builder.setNegativeButton(getString(R.string.cancel), null); - builder.setPositiveButton(getString(R.string.add_contact), - (dialog, which) -> { - final Jid jid = contact.getJid(); - Account account = contact.getAccount(); - Contact contact1 = account.getRoster().getContact(jid); - xmppConnectionService.createContact(contact1); - }); + builder.setPositiveButton(getString(R.string.add_contact), (dialog, which) -> xmppConnectionService.createContact(contact,true)); builder.create().show(); } diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 92ffb21f1..bb0096a39 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -7,7 +7,6 @@ false false false - true true false false diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d00bd968a..e6f1ce20d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -125,8 +125,6 @@ OpenKeychain reported an error Accept An error has occurred - Grant presence updates - Preemptively grant and request presence subscriptions for contacts you have created Your account Send presence updates Receive presence updates diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 460f71dbf..012d8b370 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -1,14 +1,11 @@ - -