diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java index 112284224..d48e8fe53 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java @@ -968,7 +968,7 @@ public class SettingsController extends BaseController { @Override public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) { - int statusCode = genericOverall.ocs.meta.statusCode; + int statusCode = Objects.requireNonNull(genericOverall.getMeta()).getStatusCode(); if (statusCode == 200) { dialog.dismiss(); Toast.makeText(context, context.getResources().getString( diff --git a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java index c9b0ea931..3eb0ea2a3 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java @@ -55,6 +55,7 @@ import javax.inject.Inject; import java.io.IOException; import java.net.CookieManager; import java.util.HashMap; +import java.util.Objects; import java.util.zip.CRC32; @AutoInjector(NextcloudTalkApplication.class) @@ -104,13 +105,13 @@ public class AccountRemovalWorker extends Worker { .blockingSubscribe(new Observer() { @Override public void onSubscribe(@NotNull Disposable d) { - + // unused atm } @Override public void onNext(@NotNull GenericOverall genericOverall) { - if (genericOverall.getOcs().getMeta().getStatusCode() == 200 - || genericOverall.getOcs().getMeta().getStatusCode() == 202) { + if (Objects.requireNonNull(genericOverall.getMeta()).getStatusCode() == 200 || + genericOverall.getMeta().getStatusCode() == 202) { HashMap queryMap = new HashMap<>(); queryMap.put("deviceIdentifier", finalPushConfigurationState.getDeviceIdentifier()); @@ -128,7 +129,7 @@ public class AccountRemovalWorker extends Worker { @Override public void onComplete() { - + // unused atm } }); } else { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.java b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.java deleted file mode 100644 index bca1ca26f..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) - * - * 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.generic; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -@Parcel -@JsonObject(serializeNullObjects = true) -public class GenericMeta { - @JsonField(name = "status") - public String status; - - @JsonField(name = "statuscode") - public int statusCode; - - @JsonField(name = "message") - public String message; - - public String getStatus() { - return this.status; - } - - public int getStatusCode() { - return this.statusCode; - } - - public String getMessage() { - return this.message; - } - - public void setStatus(String status) { - this.status = status; - } - - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } - - public void setMessage(String message) { - this.message = message; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof GenericMeta)) { - return false; - } - final GenericMeta other = (GenericMeta) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$status = this.getStatus(); - final Object other$status = other.getStatus(); - if (this$status == null ? other$status != null : !this$status.equals(other$status)) { - return false; - } - if (this.getStatusCode() != other.getStatusCode()) { - return false; - } - final Object this$message = this.getMessage(); - final Object other$message = other.getMessage(); - - return this$message == null ? other$message == null : this$message.equals(other$message); - } - - protected boolean canEqual(final Object other) { - return other instanceof GenericMeta; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $status = this.getStatus(); - result = result * PRIME + ($status == null ? 43 : $status.hashCode()); - result = result * PRIME + this.getStatusCode(); - final Object $message = this.getMessage(); - result = result * PRIME + ($message == null ? 43 : $message.hashCode()); - return result; - } - - public String toString() { - return "GenericMeta(status=" + this.getStatus() + ", statusCode=" + this.getStatusCode() + ", message=" + this.getMessage() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.kt b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.kt new file mode 100644 index 000000000..8ec5c0f9e --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericMeta.kt @@ -0,0 +1,41 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) + * + * 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.generic + +import android.os.Parcelable +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject(serializeNullObjects = true) +data class GenericMeta( + @JsonField(name = ["status"]) + var status: String? = null, + @JsonField(name = ["statuscode"]) + var statusCode: Int = 0, + @JsonField(name = ["message"]) + var message: String? = null +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null, 0, null) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.java b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.java index c4273a5af..c17a7a3ad 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOCS.java @@ -30,45 +30,4 @@ import org.parceler.Parcel; public class GenericOCS { @JsonField(name = "meta") public GenericMeta meta; - - public GenericMeta getMeta() { - return this.meta; - } - - public void setMeta(GenericMeta meta) { - this.meta = meta; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof GenericOCS)) { - return false; - } - final GenericOCS other = (GenericOCS) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$meta = this.getMeta(); - final Object other$meta = other.getMeta(); - - return this$meta == null ? other$meta == null : this$meta.equals(other$meta); - } - - protected boolean canEqual(final Object other) { - return other instanceof GenericOCS; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $meta = this.getMeta(); - result = result * PRIME + ($meta == null ? 43 : $meta.hashCode()); - return result; - } - - public String toString() { - return "GenericOCS(meta=" + this.getMeta() + ")"; - } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.java b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.java deleted file mode 100644 index 012542b0e..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) - * - * 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.generic; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -@Parcel -@JsonObject -public class GenericOverall { - @JsonField(name = "ocs") - public GenericOCS ocs; - - public GenericOCS getOcs() { - return this.ocs; - } - - public void setOcs(GenericOCS ocs) { - this.ocs = ocs; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof GenericOverall)) { - return false; - } - final GenericOverall other = (GenericOverall) 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 GenericOverall; - } - - 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 "GenericOverall(ocs=" + this.getOcs() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt new file mode 100644 index 000000000..23135f07d --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/GenericOverall.kt @@ -0,0 +1,40 @@ +/* + * + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) + * + * 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.generic + +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 GenericOverall( + @JsonField(name = ["meta"]) + var meta: GenericMeta? = null +) : IGenericOCS, Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) + + override fun getGenericMeta(): GenericMeta? { + return meta + } +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/generic/IGenericOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/generic/IGenericOCS.kt new file mode 100644 index 000000000..fc147be49 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/generic/IGenericOCS.kt @@ -0,0 +1,24 @@ +/* + * Nextcloud Talk application + * + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * + * 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.generic + +interface IGenericOCS { + fun getGenericMeta(): GenericMeta? +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/notifications/NotificationOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/notifications/NotificationOCS.kt index 999073a55..bcd9320a0 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/notifications/NotificationOCS.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/notifications/NotificationOCS.kt @@ -24,15 +24,23 @@ package com.nextcloud.talk.models.json.notifications import android.os.Parcelable import com.bluelinelabs.logansquare.annotation.JsonField import com.bluelinelabs.logansquare.annotation.JsonObject +import com.nextcloud.talk.models.json.generic.GenericMeta import com.nextcloud.talk.models.json.generic.GenericOCS +import com.nextcloud.talk.models.json.generic.IGenericOCS import kotlinx.android.parcel.Parcelize @Parcelize @JsonObject data class NotificationOCS( + @JsonField(name = ["meta"]) + var meta: GenericMeta?, @JsonField(name = ["data"]) var notification: Notification? -) : GenericOCS(), Parcelable { +) : IGenericOCS, Parcelable { // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' - constructor() : this(null) + constructor() : this(null, null) + + override fun getGenericMeta(): GenericMeta? { + return meta + } } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt index 31bdacf75..e3edd0e4e 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MessageActionsDialog.kt @@ -318,7 +318,7 @@ class MessageActionsDialog( } override fun onNext(@NonNull genericOverall: GenericOverall) { - val statusCode = genericOverall.ocs.meta.statusCode + val statusCode = genericOverall.meta?.statusCode if (statusCode == HTTP_CREATED) { chatController.updateAdapterAfterSendReaction(message, emoji) }