diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.java b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.java deleted file mode 100644 index 9a98cd870..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tim Krüger - * Copyright (C) 2021 Tim Krüger - * - * 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.hovercard; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -import java.util.List; -import java.util.Objects; - -@Parcel -@JsonObject -public class HoverCard { - - @JsonField(name = "userId") - public String userId; - - @JsonField(name = "displayName") - public String displayName; - - @JsonField(name = "actions") - public List actions; - - - public String getUserId() { - return this.userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public List getActions() { - return actions; - } - - public void setActions(List actions) { - this.actions = actions; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HoverCard hoverCard = (HoverCard) o; - return Objects.equals(userId, hoverCard.userId) && - Objects.equals(displayName, hoverCard.displayName) && - Objects.equals(actions, hoverCard.actions); - } - - @Override - public int hashCode() { - return Objects.hash(userId, displayName, actions); - } - - @Override - public String toString() { - return "HoverCard{" + - "userId='" + userId + '\'' + - ", displayName='" + displayName + '\'' + - ", actions=" + actions + - '}'; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.kt b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.kt new file mode 100644 index 000000000..cc349a599 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCard.kt @@ -0,0 +1,40 @@ +/* + * + * Nextcloud Talk application + * + * @author Tim Krüger + * Copyright (C) 2021-2022 Tim Krüger + * + * 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.hovercard + +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 HoverCard( + @JsonField(name = ["userId"]) + var userId: String?, + @JsonField(name = ["displayName"]) + var displayName: String?, + @JsonField(name = ["actions"]) + var actions: List? +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null, null, null) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.java b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.java deleted file mode 100644 index 4153ef8e1..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tim Krüger - * Copyright (C) 2021 Tim Krüger - * - * 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.hovercard; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -import java.util.Objects; - -@Parcel -@JsonObject -public class HoverCardAction { - - @JsonField(name = "title") - public String title; - - @JsonField(name = "icon") - public String icon; - - @JsonField(name = "hyperlink") - public String hyperlink; - - @JsonField(name = "appId") - public String appId; - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getHyperlink() { - return hyperlink; - } - - public void setHyperlink(String hyperlink) { - this.hyperlink = hyperlink; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HoverCardAction that = (HoverCardAction) o; - return Objects.equals(title, that.title) && - Objects.equals(icon, that.icon) && - Objects.equals(hyperlink, that.hyperlink) && - Objects.equals(appId, that.appId); - } - - @Override - public int hashCode() { - return Objects.hash(title, icon, hyperlink, appId); - } - - @Override - public String toString() { - return "HoverCardAction{" + - "title='" + title + '\'' + - ", icon='" + icon + '\'' + - ", hyper='" + hyperlink + '\'' + - ", appId='" + appId + '\'' + - '}'; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.kt b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.kt new file mode 100644 index 000000000..e1af7ed92 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardAction.kt @@ -0,0 +1,42 @@ +/* + * + * Nextcloud Talk application + * + * @author Tim Krüger + * Copyright (C) 2021-2022 Tim Krüger + * + * 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.hovercard + +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 HoverCardAction( + @JsonField(name = ["title"]) + var title: String?, + @JsonField(name = ["icon"]) + var icon: String?, + @JsonField(name = ["hyperlink"]) + var hyperlink: String?, + @JsonField(name = ["appId"]) + var appId: String? +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null, null, null, null) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.java b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.java deleted file mode 100644 index cafc659a4..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tim Krüger - * Copyright (C) 2021 Tim Krüger - * - * 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.hovercard; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; -import com.nextcloud.talk.models.json.generic.GenericOCS; - -import java.util.Objects; - -@JsonObject -public class HoverCardOCS extends GenericOCS { - @JsonField(name = "data") - public HoverCard data; - - public HoverCard getData() { - return this.data; - } - - public void setData(HoverCard data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - if (!super.equals(o)) { - return false; - } - HoverCardOCS that = (HoverCardOCS) o; - return Objects.equals(data, that.data); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), data); - } - - @Override - public String toString() { - return "HoverCardOCS{" + - "data=" + data + - '}'; - } - -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.kt new file mode 100644 index 000000000..0b9d16393 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOCS.kt @@ -0,0 +1,34 @@ +/* + * + * Nextcloud Talk application + * + * @author Tim Krüger + * Copyright (C) 2021-2022 Tim Krüger + * + * 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.hovercard + +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import com.nextcloud.talk.models.json.generic.GenericOCS + +@JsonObject +data class HoverCardOCS( + @JsonField(name = ["data"]) + var data: HoverCard? +) : GenericOCS() { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.java b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.java deleted file mode 100644 index c73bebe94..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tim Krüger - * Copyright (C) 2021 Tim Krüger - * - * 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.hovercard; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import java.util.Objects; - -@JsonObject -public class HoverCardOverall { - @JsonField(name = "ocs") - public HoverCardOCS ocs; - - public HoverCardOCS getOcs() { - return this.ocs; - } - - public void setOcs(HoverCardOCS ocs) { - this.ocs = ocs; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HoverCardOverall that = (HoverCardOverall) o; - return Objects.equals(ocs, that.ocs); - } - - @Override - public int hashCode() { - return Objects.hash(ocs); - } - - @Override - public String toString() { - return "HoverCardOverall{" + - "ocs=" + ocs + - '}'; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.kt new file mode 100644 index 000000000..ed69c02a7 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/hovercard/HoverCardOverall.kt @@ -0,0 +1,33 @@ +/* + * + * Nextcloud Talk application + * + * @author Tim Krüger + * Copyright (C) 2021-2022 Tim Krüger + * + * 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.hovercard + +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject + +@JsonObject +data class HoverCardOverall( + @JsonField(name = ["ocs"]) + var ocs: HoverCardOCS? +) { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) +} diff --git a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt index 54c0611c9..ff230522e 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt @@ -67,7 +67,11 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route } override fun onNext(hoverCardOverall: HoverCardOverall) { - bottomSheet(hoverCardOverall.ocs.data.actions, hoverCardOverall.ocs.data.displayName, user, context) + bottomSheet( + hoverCardOverall.ocs!!.data!!.actions!!, hoverCardOverall.ocs!!.data!!.displayName!!, + user, + context + ) } override fun onError(e: Throwable) { @@ -94,8 +98,8 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route val action = filteredActions[index] when (AllowedAppIds.createFor(action)) { - PROFILE -> openProfile(action.hyperlink, context) - EMAIL -> composeEmail(action.title, context) + PROFILE -> openProfile(action.hyperlink!!, context) + EMAIL -> composeEmail(action.title!!, context) SPREED -> talkTo(userId) } } @@ -112,7 +116,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route return BasicListItemWithImage( drawable, - action.title + action.title!! ) } @@ -213,7 +217,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route EMAIL("email"); companion object { - fun createFor(action: HoverCardAction): AllowedAppIds = valueOf(action.appId.uppercase()) + fun createFor(action: HoverCardAction): AllowedAppIds = valueOf(action.appId!!.uppercase()) } } }