From 2884c6e01c02cdb40172a6941efa93a6a4a8799e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 24 Mar 2022 18:33:13 +0100 Subject: [PATCH] Migrate search models to kotlin Signed-off-by: Andy Scherzinger --- .../talk/jobs/ContactAddressBookWorker.kt | 2 +- .../json/search/ContactsByNumberOCS.java | 78 ------------------- .../models/json/search/ContactsByNumberOCS.kt | 39 ++++++++++ .../json/search/ContactsByNumberOverall.java | 74 ------------------ .../json/search/ContactsByNumberOverall.kt | 37 +++++++++ 5 files changed, 77 insertions(+), 153 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.kt delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.kt diff --git a/app/src/main/java/com/nextcloud/talk/jobs/ContactAddressBookWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/ContactAddressBookWorker.kt index c99d02f65..7c8843226 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/ContactAddressBookWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/ContactAddressBookWorker.kt @@ -143,7 +143,7 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar } override fun onNext(foundContacts: ContactsByNumberOverall) { - val contactsWithAssociatedPhoneNumbers = foundContacts.ocs.map + val contactsWithAssociatedPhoneNumbers = foundContacts.ocs!!.map deleteLinkedAccounts(contactsWithAssociatedPhoneNumbers) createLinkedAccounts(contactsWithAssociatedPhoneNumbers) } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.java b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.java deleted file mode 100644 index 6c3644377..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Tobias Kaminsky - * Copyright (C) 2020 Tobias Kaminsky - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.models.json.search; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; -import com.nextcloud.talk.models.json.generic.GenericOCS; - -import org.parceler.Parcel; - -import java.util.HashMap; -import java.util.Map; - -@Parcel -@JsonObject -public class ContactsByNumberOCS extends GenericOCS { - @JsonField(name = "data") - public Map map = new HashMap(); - - public Map getMap() { - return this.map; - } - - public void setMap(Map map) { - this.map = map; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof ContactsByNumberOCS)) { - return false; - } - final ContactsByNumberOCS other = (ContactsByNumberOCS) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$map = this.getMap(); - final Object other$map = other.getMap(); - - return this$map == null ? other$map == null : this$map.equals(other$map); - } - - protected boolean canEqual(final Object other) { - return other instanceof ContactsByNumberOCS; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $map = this.getMap(); - result = result * PRIME + ($map == null ? 43 : $map.hashCode()); - return result; - } - - public String toString() { - return "ContactsByNumberOCS(map=" + this.getMap() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.kt new file mode 100644 index 000000000..f2f4017c2 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOCS.kt @@ -0,0 +1,39 @@ +/* + * Nextcloud Talk application + * + * @author Tobias Kaminsky + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2020 Tobias Kaminsky + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.nextcloud.talk.models.json.search + +import android.os.Parcelable +import com.nextcloud.talk.models.json.generic.GenericOCS +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import java.util.HashMap +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject +data class ContactsByNumberOCS( + @JsonField(name = ["data"]) + var map: Map = HashMap() +) : GenericOCS(), Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(HashMap()) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.java b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.java deleted file mode 100644 index 7bdc7672e..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Tobias Kaminsky - * Copyright (C) 2020 Tobias Kaminsky - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.models.json.search; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -@Parcel -@JsonObject -public class ContactsByNumberOverall { - @JsonField(name = "ocs") - public ContactsByNumberOCS ocs; - - public ContactsByNumberOCS getOcs() { - return this.ocs; - } - - public void setOcs(ContactsByNumberOCS ocs) { - this.ocs = ocs; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof ContactsByNumberOverall)) { - return false; - } - final ContactsByNumberOverall other = (ContactsByNumberOverall) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$ocs = this.getOcs(); - final Object other$ocs = other.getOcs(); - - return this$ocs == null ? other$ocs == null : this$ocs.equals(other$ocs); - } - - protected boolean canEqual(final Object other) { - return other instanceof ContactsByNumberOverall; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $ocs = this.getOcs(); - result = result * PRIME + ($ocs == null ? 43 : $ocs.hashCode()); - return result; - } - - public String toString() { - return "ContactsByNumberOverall(ocs=" + this.getOcs() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.kt new file mode 100644 index 000000000..d9ab9acb0 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/search/ContactsByNumberOverall.kt @@ -0,0 +1,37 @@ +/* + * Nextcloud Talk application + * + * @author Tobias Kaminsky + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2020 Tobias Kaminsky + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.nextcloud.talk.models.json.search + +import android.os.Parcelable +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject +data class ContactsByNumberOverall( + @JsonField(name = ["ocs"]) + var ocs: ContactsByNumberOCS? +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) +}