use Java 17

This commit is contained in:
Daniel Gultsch 2023-03-05 15:23:46 +01:00
parent e4fb793769
commit cfaf6162e6
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
14 changed files with 208 additions and 188 deletions

View file

@ -30,8 +30,8 @@ android {
} }
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_17
} }
buildFeatures { buildFeatures {
dataBinding true dataBinding true
@ -65,7 +65,7 @@ android {
spotless { spotless {
java { java {
target '**/*.java' target '**/*.java'
googleJavaFormat('1.8').aosp().reflowLongStrings() googleJavaFormat().aosp().reflowLongStrings()
} }
} }

View file

@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 1, "version": 1,
"identityHash": "9620a1b63d595091a2b463e89b504eb7", "identityHash": "414be5ac9e68ecf9063dddbcc1cf993a",
"entities": [ "entities": [
{ {
"tableName": "account", "tableName": "account",
@ -1009,7 +1009,7 @@
}, },
{ {
"tableName": "chat", "tableName": "chat",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `address` TEXT NOT NULL, `type` TEXT, `archived` INTEGER NOT NULL, `mucState` TEXT, `errorCondition` TEXT, FOREIGN KEY(`accountId`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `address` TEXT NOT NULL, `type` TEXT NOT NULL, `archived` INTEGER NOT NULL, `mucState` TEXT, `errorCondition` TEXT, FOREIGN KEY(`accountId`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -1033,7 +1033,7 @@
"fieldPath": "type", "fieldPath": "type",
"columnName": "type", "columnName": "type",
"affinity": "TEXT", "affinity": "TEXT",
"notNull": false "notNull": true
}, },
{ {
"fieldPath": "archived", "fieldPath": "archived",
@ -2594,7 +2594,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9620a1b63d595091a2b463e89b504eb7')" "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '414be5ac9e68ecf9063dddbcc1cf993a')"
] ]
} }
} }

View file

@ -31,7 +31,7 @@ public class ChatEntity {
@NonNull public String address; @NonNull public String address;
public ChatType type; @NonNull public ChatType type;
public boolean archived; public boolean archived;

View file

@ -19,15 +19,13 @@ public final class Intents {
private Intents() {} private Intents() {}
public static Intent of(final ChatFilter chatFilter) { public static Intent of(final ChatFilter chatFilter) {
if (chatFilter instanceof AccountIdentifier) { if (chatFilter instanceof final AccountIdentifier account) {
final var account = (AccountIdentifier) chatFilter;
final var intent = new Intent(ACTION_FILTER_CHATS_BY_ACCOUNT); final var intent = new Intent(ACTION_FILTER_CHATS_BY_ACCOUNT);
intent.putExtra(EXTRA_ACCOUNT_ID, account.id); intent.putExtra(EXTRA_ACCOUNT_ID, account.id);
intent.putExtra(EXTRA_ACCOUNT_ADDRESS, account.address.toString()); intent.putExtra(EXTRA_ACCOUNT_ADDRESS, account.address.toString());
return intent; return intent;
} }
if (chatFilter instanceof GroupIdentifier) { if (chatFilter instanceof final GroupIdentifier group) {
final var group = (GroupIdentifier) chatFilter;
final var intent = new Intent(ACTION_FILTER_CHATS_BY_GROUP); final var intent = new Intent(ACTION_FILTER_CHATS_BY_GROUP);
intent.putExtra(EXTRA_GROUP_ID, group.id); intent.putExtra(EXTRA_GROUP_ID, group.id);
intent.putExtra(EXTRA_GROUP_NAME, group.name); intent.putExtra(EXTRA_GROUP_NAME, group.name);

View file

@ -21,8 +21,7 @@ public class InterfaceSettingsFragment extends PreferenceFragmentCompat {
} }
themePreference.setOnPreferenceChangeListener( themePreference.setOnPreferenceChangeListener(
(preference, newValue) -> { (preference, newValue) -> {
if (newValue instanceof String) { if (newValue instanceof final String theme) {
final String theme = (String) newValue;
final int desiredNightMode = Conversations.getDesiredNightMode(theme); final int desiredNightMode = Conversations.getDesiredNightMode(theme);
requireSettingsActivity().setDesiredNightMode(desiredNightMode); requireSettingsActivity().setDesiredNightMode(desiredNightMode);
} }

View file

@ -109,8 +109,7 @@ public class AxolotlManager extends AbstractManager implements AxolotlService.Po
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
return; return;
} }
if (throwable instanceof IqErrorException) { if (throwable instanceof final IqErrorException iqErrorException) {
final var iqErrorException = (IqErrorException) throwable;
final var error = iqErrorException.getError(); final var error = iqErrorException.getError();
final var condition = error == null ? null : error.getCondition(); final var condition = error == null ? null : error.getCondition();
if (condition != null) { if (condition != null) {

View file

@ -179,8 +179,7 @@ public class MultiUserChatManager extends AbstractManager {
@Override @Override
public void onFailure(@NonNull final Throwable throwable) { public void onFailure(@NonNull final Throwable throwable) {
final String errorCondition; final String errorCondition;
if (throwable instanceof IqErrorException) { if (throwable instanceof final IqErrorException iqErrorException) {
final var iqErrorException = (IqErrorException) throwable;
final Error error = iqErrorException.getError(); final Error error = iqErrorException.getError();
final Condition condition = error == null ? null : error.getCondition(); final Condition condition = error == null ? null : error.getCondition();
errorCondition = condition == null ? null : condition.getName(); errorCondition = condition == null ? null : condition.getName();

View file

@ -1,6 +1,9 @@
package im.conversations.android.xmpp.processor; package im.conversations.android.xmpp.processor;
import android.content.Context; import android.content.Context;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import im.conversations.android.xml.Namespace; import im.conversations.android.xml.Namespace;
import im.conversations.android.xmpp.Entity; import im.conversations.android.xmpp.Entity;
import im.conversations.android.xmpp.XmppConnection; import im.conversations.android.xmpp.XmppConnection;
@ -8,9 +11,11 @@ import im.conversations.android.xmpp.manager.AxolotlManager;
import im.conversations.android.xmpp.manager.BlockingManager; import im.conversations.android.xmpp.manager.BlockingManager;
import im.conversations.android.xmpp.manager.BookmarkManager; import im.conversations.android.xmpp.manager.BookmarkManager;
import im.conversations.android.xmpp.manager.DiscoManager; import im.conversations.android.xmpp.manager.DiscoManager;
import im.conversations.android.xmpp.manager.HttpUploadManager;
import im.conversations.android.xmpp.manager.PresenceManager; import im.conversations.android.xmpp.manager.PresenceManager;
import im.conversations.android.xmpp.manager.RosterManager; import im.conversations.android.xmpp.manager.RosterManager;
import java.util.function.Consumer; import java.util.function.Consumer;
import okhttp3.MediaType;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -28,7 +33,6 @@ public class BindProcessor extends XmppConnection.Delegate implements Consumer<J
final var account = getAccount(); final var account = getAccount();
final var database = getDatabase(); final var database = getDatabase();
// TODO reset errorCondition; mucState in chats
database.runInTransaction( database.runInTransaction(
() -> { () -> {
database.chatDao().resetMucStates(); database.chatDao().resetMucStates();
@ -53,5 +57,23 @@ public class BindProcessor extends XmppConnection.Delegate implements Consumer<J
getManager(AxolotlManager.class).publishIfNecessary(); getManager(AxolotlManager.class).publishIfNecessary();
getManager(PresenceManager.class).sendPresence(); getManager(PresenceManager.class).sendPresence();
final var future =
getManager(HttpUploadManager.class)
.request("foo.jpg", 123, MediaType.get("image/jpeg"));
Futures.addCallback(
future,
new FutureCallback<HttpUploadManager.Slot>() {
@Override
public void onSuccess(HttpUploadManager.Slot result) {
LOGGER.info("requested slot {}", result);
}
@Override
public void onFailure(Throwable t) {
LOGGER.info("could not request slot", t);
}
},
MoreExecutors.directExecutor());
} }
} }

View file

@ -23,15 +23,15 @@ public class EntityCapabilitiesTest {
@Test @Test
public void entityCaps() throws IOException { public void entityCaps() throws IOException {
final String xml = final String xml =
"<query xmlns='http://jabber.org/protocol/disco#info'\n" """
+ " " <query xmlns='http://jabber.org/protocol/disco#info'
+ " node='http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0='>\n" node='http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0='>
+ " <identity category='client' name='Exodus 0.9.1' type='pc'/>\n" <identity category='client' name='Exodus 0.9.1' type='pc'/>
+ " <feature var='http://jabber.org/protocol/caps'/>\n" <feature var='http://jabber.org/protocol/caps'/>
+ " <feature var='http://jabber.org/protocol/disco#items'/>\n" <feature var='http://jabber.org/protocol/disco#items'/>
+ " <feature var='http://jabber.org/protocol/disco#info'/>\n" <feature var='http://jabber.org/protocol/disco#info'/>
+ " <feature var='http://jabber.org/protocol/muc'/>\n" <feature var='http://jabber.org/protocol/muc'/>
+ " </query>"; </query>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(InfoQuery.class)); assertThat(element, instanceOf(InfoQuery.class));
final InfoQuery info = (InfoQuery) element; final InfoQuery info = (InfoQuery) element;
@ -42,36 +42,37 @@ public class EntityCapabilitiesTest {
@Test @Test
public void entityCapsComplexExample() throws IOException { public void entityCapsComplexExample() throws IOException {
final String xml = final String xml =
"<query xmlns='http://jabber.org/protocol/disco#info'\n" """
+ " node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>\n" <query xmlns='http://jabber.org/protocol/disco#info'
+ " <identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/>\n" node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>
+ " <identity xml:lang='el' category='client' name='Ψ 0.11' type='pc'/>\n" <identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/>
+ " <feature var='http://jabber.org/protocol/caps'/>\n" <identity xml:lang='el' category='client' name='Ψ 0.11' type='pc'/>
+ " <feature var='http://jabber.org/protocol/disco#info'/>\n" <feature var='http://jabber.org/protocol/caps'/>
+ " <feature var='http://jabber.org/protocol/disco#items'/>\n" <feature var='http://jabber.org/protocol/disco#info'/>
+ " <feature var='http://jabber.org/protocol/muc'/>\n" <feature var='http://jabber.org/protocol/disco#items'/>
+ " <x xmlns='jabber:x:data' type='result'>\n" <feature var='http://jabber.org/protocol/muc'/>
+ " <field var='FORM_TYPE' type='hidden'>\n" <x xmlns='jabber:x:data' type='result'>
+ " <value>urn:xmpp:dataforms:softwareinfo</value>\n" <field var='FORM_TYPE' type='hidden'>
+ " </field>\n" <value>urn:xmpp:dataforms:softwareinfo</value>
+ " <field var='ip_version' type='text-multi' >\n" </field>
+ " <value>ipv4</value>\n" <field var='ip_version' type='text-multi' >
+ " <value>ipv6</value>\n" <value>ipv4</value>
+ " </field>\n" <value>ipv6</value>
+ " <field var='os'>\n" </field>
+ " <value>Mac</value>\n" <field var='os'>
+ " </field>\n" <value>Mac</value>
+ " <field var='os_version'>\n" </field>
+ " <value>10.5.1</value>\n" <field var='os_version'>
+ " </field>\n" <value>10.5.1</value>
+ " <field var='software'>\n" </field>
+ " <value>Psi</value>\n" <field var='software'>
+ " </field>\n" <value>Psi</value>
+ " <field var='software_version'>\n" </field>
+ " <value>0.11</value>\n" <field var='software_version'>
+ " </field>\n" <value>0.11</value>
+ " </x>\n" </field>
+ " </query>"; </x>
</query>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(InfoQuery.class)); assertThat(element, instanceOf(InfoQuery.class));
final InfoQuery info = (InfoQuery) element; final InfoQuery info = (InfoQuery) element;
@ -82,26 +83,27 @@ public class EntityCapabilitiesTest {
@Test @Test
public void caps2() throws IOException { public void caps2() throws IOException {
final String xml = final String xml =
"<query xmlns=\"http://jabber.org/protocol/disco#info\">\n" """
+ " <identity category=\"client\" name=\"BombusMod\" type=\"mobile\"/>\n" <query xmlns="http://jabber.org/protocol/disco#info">
+ " <feature var=\"http://jabber.org/protocol/si\"/>\n" <identity category="client" name="BombusMod" type="mobile"/>
+ " <feature var=\"http://jabber.org/protocol/bytestreams\"/>\n" <feature var="http://jabber.org/protocol/si"/>
+ " <feature var=\"http://jabber.org/protocol/chatstates\"/>\n" <feature var="http://jabber.org/protocol/bytestreams"/>
+ " <feature var=\"http://jabber.org/protocol/disco#info\"/>\n" <feature var="http://jabber.org/protocol/chatstates"/>
+ " <feature var=\"http://jabber.org/protocol/disco#items\"/>\n" <feature var="http://jabber.org/protocol/disco#info"/>
+ " <feature var=\"urn:xmpp:ping\"/>\n" <feature var="http://jabber.org/protocol/disco#items"/>
+ " <feature var=\"jabber:iq:time\"/>\n" <feature var="urn:xmpp:ping"/>
+ " <feature var=\"jabber:iq:privacy\"/>\n" <feature var="jabber:iq:time"/>
+ " <feature var=\"jabber:iq:version\"/>\n" <feature var="jabber:iq:privacy"/>
+ " <feature var=\"http://jabber.org/protocol/rosterx\"/>\n" <feature var="jabber:iq:version"/>
+ " <feature var=\"urn:xmpp:time\"/>\n" <feature var="http://jabber.org/protocol/rosterx"/>
+ " <feature var=\"jabber:x:oob\"/>\n" <feature var="urn:xmpp:time"/>
+ " <feature var=\"http://jabber.org/protocol/ibb\"/>\n" <feature var="jabber:x:oob"/>
+ " <feature var=\"http://jabber.org/protocol/si/profile/file-transfer\"/>\n" <feature var="http://jabber.org/protocol/ibb"/>
+ " <feature var=\"urn:xmpp:receipts\"/>\n" <feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
+ " <feature var=\"jabber:iq:roster\"/>\n" <feature var="urn:xmpp:receipts"/>
+ " <feature var=\"jabber:iq:last\"/>\n" <feature var="jabber:iq:roster"/>
+ "</query>"; <feature var="jabber:iq:last"/>
</query>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(InfoQuery.class)); assertThat(element, instanceOf(InfoQuery.class));
final InfoQuery info = (InfoQuery) element; final InfoQuery info = (InfoQuery) element;
@ -112,72 +114,70 @@ public class EntityCapabilitiesTest {
@Test @Test
public void caps2complex() throws IOException { public void caps2complex() throws IOException {
final String xml = final String xml =
"<query xmlns=\"http://jabber.org/protocol/disco#info\">\n" """
+ " <identity category=\"client\" name=\"Tkabber\" type=\"pc\"" <query xmlns="http://jabber.org/protocol/disco#info">
+ " xml:lang=\"en\"/>\n" <identity category="client" name="Tkabber" type="pc" xml:lang="en"/>
+ " <identity category=\"client\" name=\"Ткаббер\" type=\"pc\"" <identity category="client" name="Ткаббер" type="pc" xml:lang="ru"/>
+ " xml:lang=\"ru\"/>\n" <feature var="games:board"/>
+ " <feature var=\"games:board\"/>\n" <feature var="http://jabber.org/protocol/activity"/>
+ " <feature var=\"http://jabber.org/protocol/activity\"/>\n" <feature var="http://jabber.org/protocol/activity+notify"/>
+ " <feature var=\"http://jabber.org/protocol/activity+notify\"/>\n" <feature var="http://jabber.org/protocol/bytestreams"/>
+ " <feature var=\"http://jabber.org/protocol/bytestreams\"/>\n" <feature var="http://jabber.org/protocol/chatstates"/>
+ " <feature var=\"http://jabber.org/protocol/chatstates\"/>\n" <feature var="http://jabber.org/protocol/commands"/>
+ " <feature var=\"http://jabber.org/protocol/commands\"/>\n" <feature var="http://jabber.org/protocol/disco#info"/>
+ " <feature var=\"http://jabber.org/protocol/disco#info\"/>\n" <feature var="http://jabber.org/protocol/disco#items"/>
+ " <feature var=\"http://jabber.org/protocol/disco#items\"/>\n" <feature var="http://jabber.org/protocol/evil"/>
+ " <feature var=\"http://jabber.org/protocol/evil\"/>\n" <feature var="http://jabber.org/protocol/feature-neg"/>
+ " <feature var=\"http://jabber.org/protocol/feature-neg\"/>\n" <feature var="http://jabber.org/protocol/geoloc"/>
+ " <feature var=\"http://jabber.org/protocol/geoloc\"/>\n" <feature var="http://jabber.org/protocol/geoloc+notify"/>
+ " <feature var=\"http://jabber.org/protocol/geoloc+notify\"/>\n" <feature var="http://jabber.org/protocol/ibb"/>
+ " <feature var=\"http://jabber.org/protocol/ibb\"/>\n" <feature var="http://jabber.org/protocol/iqibb"/>
+ " <feature var=\"http://jabber.org/protocol/iqibb\"/>\n" <feature var="http://jabber.org/protocol/mood"/>
+ " <feature var=\"http://jabber.org/protocol/mood\"/>\n" <feature var="http://jabber.org/protocol/mood+notify"/>
+ " <feature var=\"http://jabber.org/protocol/mood+notify\"/>\n" <feature var="http://jabber.org/protocol/rosterx"/>
+ " <feature var=\"http://jabber.org/protocol/rosterx\"/>\n" <feature var="http://jabber.org/protocol/si"/>
+ " <feature var=\"http://jabber.org/protocol/si\"/>\n" <feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
+ " <feature var=\"http://jabber.org/protocol/si/profile/file-transfer\"/>\n" <feature var="http://jabber.org/protocol/tune"/>
+ " <feature var=\"http://jabber.org/protocol/tune\"/>\n" <feature var="http://www.facebook.com/xmpp/messages"/>
+ " <feature var=\"http://www.facebook.com/xmpp/messages\"/>\n" <feature var="http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify"/>
+ " <feature" <feature var="jabber:iq:avatar"/>
+ " var=\"http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify\"/>\n" <feature var="jabber:iq:browse"/>
+ " <feature var=\"jabber:iq:avatar\"/>\n" <feature var="jabber:iq:dtcp"/>
+ " <feature var=\"jabber:iq:browse\"/>\n" <feature var="jabber:iq:filexfer"/>
+ " <feature var=\"jabber:iq:dtcp\"/>\n" <feature var="jabber:iq:ibb"/>
+ " <feature var=\"jabber:iq:filexfer\"/>\n" <feature var="jabber:iq:inband"/>
+ " <feature var=\"jabber:iq:ibb\"/>\n" <feature var="jabber:iq:jidlink"/>
+ " <feature var=\"jabber:iq:inband\"/>\n" <feature var="jabber:iq:last"/>
+ " <feature var=\"jabber:iq:jidlink\"/>\n" <feature var="jabber:iq:oob"/>
+ " <feature var=\"jabber:iq:last\"/>\n" <feature var="jabber:iq:privacy"/>
+ " <feature var=\"jabber:iq:oob\"/>\n" <feature var="jabber:iq:roster"/>
+ " <feature var=\"jabber:iq:privacy\"/>\n" <feature var="jabber:iq:time"/>
+ " <feature var=\"jabber:iq:roster\"/>\n" <feature var="jabber:iq:version"/>
+ " <feature var=\"jabber:iq:time\"/>\n" <feature var="jabber:x:data"/>
+ " <feature var=\"jabber:iq:version\"/>\n" <feature var="jabber:x:event"/>
+ " <feature var=\"jabber:x:data\"/>\n" <feature var="jabber:x:oob"/>
+ " <feature var=\"jabber:x:event\"/>\n" <feature var="urn:xmpp:avatar:metadata+notify"/>
+ " <feature var=\"jabber:x:oob\"/>\n" <feature var="urn:xmpp:ping"/>
+ " <feature var=\"urn:xmpp:avatar:metadata+notify\"/>\n" <feature var="urn:xmpp:receipts"/>
+ " <feature var=\"urn:xmpp:ping\"/>\n" <feature var="urn:xmpp:time"/>
+ " <feature var=\"urn:xmpp:receipts\"/>\n" <x xmlns="jabber:x:data" type="result">
+ " <feature var=\"urn:xmpp:time\"/>\n" <field type="hidden" var="FORM_TYPE">
+ " <x xmlns=\"jabber:x:data\" type=\"result\">\n" <value>urn:xmpp:dataforms:softwareinfo</value>
+ " <field type=\"hidden\" var=\"FORM_TYPE\">\n" </field>
+ " <value>urn:xmpp:dataforms:softwareinfo</value>\n" <field var="software">
+ " </field>\n" <value>Tkabber</value>
+ " <field var=\"software\">\n" </field>
+ " <value>Tkabber</value>\n" <field var="software_version">
+ " </field>\n" <value>0.11.1-svn-20111216-mod (Tcl/Tk 8.6b2)</value>
+ " <field var=\"software_version\">\n" </field>
+ " <value>0.11.1-svn-20111216-mod (Tcl/Tk 8.6b2)</value>\n" <field var="os">
+ " </field>\n" <value>Windows</value>
+ " <field var=\"os\">\n" </field>
+ " <value>Windows</value>\n" <field var="os_version">
+ " </field>\n" <value>XP</value>
+ " <field var=\"os_version\">\n" </field>
+ " <value>XP</value>\n" </x>
+ " </field>\n" </query>""";
+ " </x>\n"
+ "</query>";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(InfoQuery.class)); assertThat(element, instanceOf(InfoQuery.class));
final InfoQuery info = (InfoQuery) element; final InfoQuery info = (InfoQuery) element;

View file

@ -23,32 +23,32 @@ public class PubSubTest {
@Test @Test
public void parseBookmarkResult() throws IOException { public void parseBookmarkResult() throws IOException {
final String xml = final String xml =
"<iq type='result'\n" """
+ " to='juliet@capulet.lit/balcony'\n" <iq type='result'
+ " id='retrieve1' xmlns='jabber:client'>\n" to='juliet@capulet.lit/balcony'
+ " <pubsub xmlns='http://jabber.org/protocol/pubsub'>\n" id='retrieve1' xmlns='jabber:client'>
+ " <items node='urn:xmpp:bookmarks:1'>\n" <pubsub xmlns='http://jabber.org/protocol/pubsub'>
+ " <item id='theplay@conference.shakespeare.lit'>\n" <items node='urn:xmpp:bookmarks:1'>
+ " <conference xmlns='urn:xmpp:bookmarks:1'\n" <item id='theplay@conference.shakespeare.lit'>
+ " name='The Play&apos;s the Thing'\n" <conference xmlns='urn:xmpp:bookmarks:1'
+ " autojoin='true'>\n" name='The Play&apos;s the Thing'
+ " <nick>JC</nick>\n" autojoin='true'>
+ " </conference>\n" <nick>JC</nick>
+ " </item>\n" </conference>
+ " <item id='orchard@conference.shakespeare.lit'>\n" </item>
+ " <conference xmlns='urn:xmpp:bookmarks:1'\n" <item id='orchard@conference.shakespeare.lit'>
+ " name='The Orcard'\n" <conference xmlns='urn:xmpp:bookmarks:1'
+ " autojoin='1'>\n" name='The Orcard'
+ " <nick>JC</nick>\n" autojoin='1'>
+ " <extensions>\n" <nick>JC</nick>
+ " <state xmlns='http://myclient.example/bookmark/state'" <extensions>
+ " minimized='true'/>\n" <state xmlns='http://myclient.example/bookmark/state' minimized='true'/>
+ " </extensions>\n" </extensions>
+ " </conference>\n" </conference>
+ " </item>\n" </item>
+ " </items>\n" </items>
+ " </pubsub>\n" </pubsub>
+ "</iq>"; </iq>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(Iq.class)); assertThat(element, instanceOf(Iq.class));
final Iq iq = (Iq) element; final Iq iq = (Iq) element;

View file

@ -21,9 +21,10 @@ public class TimestampTest {
@Test @Test
public void testZuluNoMillis() throws IOException { public void testZuluNoMillis() throws IOException {
final String xml = final String xml =
"<delay xmlns='urn:xmpp:delay'\n" """
+ " from='capulet.com'\n" <delay xmlns='urn:xmpp:delay'
+ " stamp='2002-09-10T23:08:25Z'/>"; from='capulet.com'
stamp='2002-09-10T23:08:25Z'/>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(Delay.class)); assertThat(element, instanceOf(Delay.class));
final Delay delay = (Delay) element; final Delay delay = (Delay) element;
@ -33,9 +34,10 @@ public class TimestampTest {
@Test @Test
public void testZuluWithMillis() throws IOException { public void testZuluWithMillis() throws IOException {
final String xml = final String xml =
"<delay xmlns='urn:xmpp:delay'\n" """
+ " from='capulet.com'\n" <delay xmlns='urn:xmpp:delay'
+ " stamp='2002-09-10T23:08:25.023Z'/>"; from='capulet.com'
stamp='2002-09-10T23:08:25.023Z'/>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(Delay.class)); assertThat(element, instanceOf(Delay.class));
final Delay delay = (Delay) element; final Delay delay = (Delay) element;

View file

@ -37,16 +37,17 @@ public class XmlElementReaderTest {
public void readMessageError() throws IOException { public void readMessageError() throws IOException {
final String xml = final String xml =
"<message\n" """
+ " to='juliet@capulet.com/balcony'\n" <message
+ " from='romeo@montague.net/garden'\n" to='juliet@capulet.com/balcony'
+ " xmlns='jabber:client'\n" from='romeo@montague.net/garden'
+ " type='error'>\n" xmlns='jabber:client'
+ " <body>Wherefore art thou, Romeo?</body>\n" type='error'>
+ " <error code='404' type='cancel'>\n" <body>Wherefore art thou, Romeo?</body>
+ " <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" <error code='404' type='cancel'>
+ " </error>\n" <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+ "</message>"; </error>
</message>""";
final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8)); final Element element = XmlElementReader.read(xml.getBytes(StandardCharsets.UTF_8));
assertThat(element, instanceOf(Message.class)); assertThat(element, instanceOf(Message.class));
final Message message = (Message) element; final Message message = (Message) element;

View file

@ -18,7 +18,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.4.2' classpath 'com.android.tools.build:gradle:7.4.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navVersion" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navVersion"
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.13.0" classpath "com.diffplug.spotless:spotless-plugin-gradle:6.16.0"
} }
} }
allprojects { allprojects {

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-rc-2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip