removed 'preemptive grant' setting

This commit is contained in:
Daniel Gultsch 2018-02-27 21:11:00 +01:00
parent b393f54a03
commit ac22007e28
8 changed files with 16 additions and 22 deletions

View file

@ -2724,8 +2724,7 @@ public class XmppConnectionService extends Service {
} }
} }
public void createContact(Contact contact) { public void createContact(Contact contact, boolean autoGrant) {
boolean autoGrant = getBooleanPreference("grant_new_contacts", R.bool.grant_new_contacts);
if (autoGrant) { if (autoGrant) {
contact.setOption(Contact.Options.PREEMPTIVE_GRANT); contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
contact.setOption(Contact.Options.ASKING); contact.setOption(Contact.Options.ASKING);

View file

@ -309,7 +309,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
public void onClick(View v) { public void onClick(View v) {
final Contact contact = conversation == null ? null : conversation.getContact(); final Contact contact = conversation == null ? null : conversation.getContact();
if (contact != null) { if (contact != null) {
activity.xmppConnectionService.createContact(contact); activity.xmppConnectionService.createContact(contact,true);
activity.switchToContactDetails(contact); activity.switchToContactDetails(contact);
} }
} }
@ -1701,6 +1701,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
setupIme(); 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.textSendButton.setContentDescription(activity.getString(R.string.send_message_to_x, conversation.getName()));
this.binding.textinput.setKeyboardListener(null); this.binding.textinput.setKeyboardListener(null);
this.binding.textinput.setText(""); this.binding.textinput.setText("");
@ -1710,8 +1712,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
refresh(false); refresh(false);
this.conversation.messagesLoaded.set(true); this.conversation.messagesLoaded.set(true);
final boolean scrolledToBottomAndNoPending = this.scrolledToBottom() && pendingScrollState.peek() == null;
Log.d(Config.LOGTAG,"scrolledToBottomAndNoPending="+Boolean.toString(scrolledToBottomAndNoPending)); Log.d(Config.LOGTAG,"scrolledToBottomAndNoPending="+Boolean.toString(scrolledToBottomAndNoPending));
if (hasExtras || scrolledToBottomAndNoPending) { if (hasExtras || scrolledToBottomAndNoPending) {

View file

@ -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. //this feature is only available on Huawei Android 6.
PreferenceScreen huaweiPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("huawei"); PreferenceScreen huaweiPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("huawei");
if (huaweiPreferenceScreen != null) { if (huaweiPreferenceScreen != null) {
@ -99,6 +101,11 @@ public class SettingsActivity extends XmppActivity implements
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) {
PreferenceCategory generalCategory = (PreferenceCategory) mSettingsFragment.findPreference("general"); PreferenceCategory generalCategory = (PreferenceCategory) mSettingsFragment.findPreference("general");
generalCategory.removePreference(huaweiPreferenceScreen); generalCategory.removePreference(huaweiPreferenceScreen);
if (generalCategory.getPreferenceCount() == 0) {
if (mainPreferenceScreen != null) {
mainPreferenceScreen.removePreference(generalCategory);
}
}
} }
} }

View file

@ -474,7 +474,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} else if (contact.showInRoster()) { } else if (contact.showInRoster()) {
throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists)); throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists));
} else { } else {
xmppConnectionService.createContact(contact); xmppConnectionService.createContact(contact,true);
if (invite != null && invite.hasFingerprints()) { if (invite != null && invite.hasFingerprints()) {
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints()); xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
} }

View file

@ -683,13 +683,7 @@ public abstract class XmppActivity extends AppCompatActivity {
builder.setTitle(contact.getJid().toString()); builder.setTitle(contact.getJid().toString());
builder.setMessage(getString(R.string.not_in_roster)); builder.setMessage(getString(R.string.not_in_roster));
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.add_contact), builder.setPositiveButton(getString(R.string.add_contact), (dialog, which) -> xmppConnectionService.createContact(contact,true));
(dialog, which) -> {
final Jid jid = contact.getJid();
Account account = contact.getAccount();
Contact contact1 = account.getRoster().getContact(jid);
xmppConnectionService.createContact(contact1);
});
builder.create().show(); builder.create().show();
} }

View file

@ -7,7 +7,6 @@
<bool name="headsup_notifications">false</bool> <bool name="headsup_notifications">false</bool>
<bool name="dnd_on_silent_mode">false</bool> <bool name="dnd_on_silent_mode">false</bool>
<bool name="treat_vibrate_as_silent">false</bool> <bool name="treat_vibrate_as_silent">false</bool>
<bool name="grant_new_contacts">true</bool>
<bool name="confirm_messages">true</bool> <bool name="confirm_messages">true</bool>
<bool name="chat_states">false</bool> <bool name="chat_states">false</bool>
<bool name="last_activity">false</bool> <bool name="last_activity">false</bool>

View file

@ -125,8 +125,6 @@
<string name="openpgp_error">OpenKeychain reported an error</string> <string name="openpgp_error">OpenKeychain reported an error</string>
<string name="accept">Accept</string> <string name="accept">Accept</string>
<string name="error">An error has occurred</string> <string name="error">An error has occurred</string>
<string name="pref_grant_presence_updates">Grant presence updates</string>
<string name="pref_grant_presence_updates_summary">Preemptively grant and request presence subscriptions for contacts you have created</string>
<string name="your_account">Your account</string> <string name="your_account">Your account</string>
<string name="send_presence_updates">Send presence updates</string> <string name="send_presence_updates">Send presence updates</string>
<string name="receive_presence_updates">Receive presence updates</string> <string name="receive_presence_updates">Receive presence updates</string>

View file

@ -1,14 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen
android:key="main_screen"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="?attr/color_background_secondary"> android:background="?attr/color_background_secondary">
<PreferenceCategory android:title="@string/pref_general" <PreferenceCategory android:title="@string/pref_general"
android:key="general"> android:key="general">
<CheckBoxPreference
android:defaultValue="@bool/grant_new_contacts"
android:key="grant_new_contacts"
android:summary="@string/pref_grant_presence_updates_summary"
android:title="@string/pref_grant_presence_updates"/>
<PreferenceScreen <PreferenceScreen
android:key="huawei" android:key="huawei"
android:title="@string/huawei_protected_apps" android:title="@string/huawei_protected_apps"