~singpolyma/cheogram-android

8a987f23f64b192c8a35128d01bd440a4a0bbd8a — Daniel Gultsch 5 years ago 6c27d07
code clean up in contact details presence handling
M build.gradle => build.gradle +1 -1
@@ 35,7 35,7 @@ dependencies {
        exclude group: 'com.google.firebase', module: 'firebase-core'
    }
    implementation 'org.sufficientlysecure:openpgp-api:10.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
    implementation "com.android.support:support-v13:$supportLibVersion"
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:cardview-v7:$supportLibVersion"

M src/main/java/eu/siacs/conversations/entities/Contact.java => src/main/java/eu/siacs/conversations/entities/Contact.java +4 -1
@@ 340,7 340,10 @@ public class Contact implements ListItem, Blockable {
		String ask = item.getAttribute("ask");
		String subscription = item.getAttribute("subscription");

		if (subscription != null) {
		if (subscription == null) {
			this.resetOption(Options.FROM);
			this.resetOption(Options.TO);
		} else {
			switch (subscription) {
				case "to":
					this.resetOption(Options.FROM);

M src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java => src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +7 -19
@@ 61,39 61,27 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
	private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView,
		                             boolean isChecked) {
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if (isChecked) {
				if (contact
						.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
					xmppConnectionService.sendPresencePacket(contact
									.getAccount(),
							xmppConnectionService.getPresenceGenerator()
									.sendPresenceUpdatesTo(contact));
				if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
					xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().sendPresenceUpdatesTo(contact));
				} else {
					contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
				}
			} else {
				contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
				xmppConnectionService.sendPresencePacket(contact.getAccount(),
						xmppConnectionService.getPresenceGenerator()
								.stopPresenceUpdatesTo(contact));
				xmppConnectionService.sendPresencePacket(contact.getAccount(),xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesTo(contact));
			}
		}
	};
	private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() {

		@Override
		public void onCheckedChanged(CompoundButton buttonView,
		                             boolean isChecked) {
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if (isChecked) {
				xmppConnectionService.sendPresencePacket(contact.getAccount(),
						xmppConnectionService.getPresenceGenerator()
								.requestPresenceUpdatesFrom(contact));
				xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().requestPresenceUpdatesFrom(contact));
			} else {
				xmppConnectionService.sendPresencePacket(contact.getAccount(),
						xmppConnectionService.getPresenceGenerator()
								.stopPresenceUpdatesFrom(contact));
				xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().stopPresenceUpdatesFrom(contact));
			}
		}
	};