From 9a2a3f3b6df11f70aebd3baa9dae40d5330d7514 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 23 Mar 2022 19:14:39 +0100 Subject: [PATCH] migrate userprofile to kotlin and align icon work with latest server Signed-off-by: Andy Scherzinger --- .../AccountVerificationController.kt | 10 +- .../talk/controllers/ProfileController.kt | 33 +- .../json/converters/ScopeConverter.java | 2 +- .../models/json/statuses/StatusesOverall.kt | 1 - .../json/userprofile/{Scope.java => Scope.kt} | 19 +- .../json/userprofile/UserProfileData.java | 348 ------------------ .../json/userprofile/UserProfileData.kt | 102 +++++ .../userprofile/UserProfileFieldsOCS.java | 80 ---- .../json/userprofile/UserProfileFieldsOCS.kt | 39 ++ .../userprofile/UserProfileFieldsOverall.java | 74 ---- .../userprofile/UserProfileFieldsOverall.kt | 37 ++ .../json/userprofile/UserProfileOCS.java | 75 ---- .../models/json/userprofile/UserProfileOCS.kt | 38 ++ .../json/userprofile/UserProfileOverall.java | 74 ---- .../json/userprofile/UserProfileOverall.kt | 37 ++ .../main/res/drawable-night/ic_cellphone.xml | 25 ++ app/src/main/res/drawable/ic_cellphone.xml | 25 ++ app/src/main/res/layout/dialog_scope.xml | 4 +- 18 files changed, 333 insertions(+), 690 deletions(-) rename app/src/main/java/com/nextcloud/talk/models/json/userprofile/{Scope.java => Scope.kt} (77%) delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.kt delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.kt delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.kt delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.kt delete mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.java create mode 100644 app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.kt create mode 100644 app/src/main/res/drawable-night/ic_cellphone.xml create mode 100644 app/src/main/res/drawable/ic_cellphone.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt b/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt index 1bad9970f..a0cc4cc18 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt @@ -307,13 +307,13 @@ class AccountVerificationController(args: Bundle? = null) : @SuppressLint("SetTextI18n") override fun onNext(userProfileOverall: UserProfileOverall) { var displayName: String? = null - if (!TextUtils.isEmpty(userProfileOverall.ocs.data.displayName)) { - displayName = userProfileOverall.ocs.data.displayName - } else if (!TextUtils.isEmpty(userProfileOverall.ocs.data.displayNameAlt)) { - displayName = userProfileOverall.ocs.data.displayNameAlt + if (!TextUtils.isEmpty(userProfileOverall.ocs!!.data!!.displayName)) { + displayName = userProfileOverall.ocs!!.data!!.displayName + } else if (!TextUtils.isEmpty(userProfileOverall.ocs!!.data!!.displayNameAlt)) { + displayName = userProfileOverall.ocs!!.data!!.displayNameAlt } if (!TextUtils.isEmpty(displayName)) { - storeProfile(displayName, userProfileOverall.ocs.data.userId) + storeProfile(displayName, userProfileOverall.ocs!!.data!!.userId!!) } else { if (activity != null) { activity!!.runOnUiThread { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt index c6ee6e012..241bc3efa 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt @@ -165,7 +165,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { } override fun onNext(userProfileFieldsOverall: UserProfileFieldsOverall) { - editableFields = userProfileFieldsOverall.ocs.data + editableFields = userProfileFieldsOverall.ocs!!.data!! adapter!!.notifyDataSetChanged() } @@ -241,7 +241,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { } override fun onNext(userProfileOverall: UserProfileOverall) { - userInfo = userProfileOverall.ocs.data + userInfo = userProfileOverall.ocs!!.data showUserProfile() } @@ -284,12 +284,12 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { adapter!!.setData(createUserInfoDetails(userInfo)) if (isAllEmpty( arrayOf( - userInfo!!.displayName, - userInfo!!.phone, - userInfo!!.email, - userInfo!!.address, - userInfo!!.twitter, - userInfo!!.website + userInfo!!.displayName!!, + userInfo!!.phone!!, + userInfo!!.email!!, + userInfo!!.address!!, + userInfo!!.twitter!!, + userInfo!!.website!! ) ) ) { @@ -320,7 +320,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { } override fun onNext(userProfileFieldsOverall: UserProfileFieldsOverall) { - editableFields = userProfileFieldsOverall.ocs.data + editableFields = userProfileFieldsOverall.ocs!!.data!! activity!!.invalidateOptionsMenu() adapter!!.notifyDataSetChanged() } @@ -355,7 +355,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { result.add( UserInfoDetailsItem( R.drawable.ic_user, - userInfo!!.displayName, + userInfo!!.displayName!!, resources!!.getString(R.string.user_info_displayname), Field.DISPLAYNAME, userInfo.displayNameScope @@ -364,7 +364,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { result.add( UserInfoDetailsItem( R.drawable.ic_phone, - userInfo.phone, + userInfo.phone!!, resources!!.getString(R.string.user_info_phone), Field.PHONE, userInfo.phoneScope @@ -373,7 +373,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { result.add( UserInfoDetailsItem( R.drawable.ic_email, - userInfo.email, + userInfo.email!!, resources!!.getString(R.string.user_info_email), Field.EMAIL, userInfo.emailScope @@ -382,7 +382,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { result.add( UserInfoDetailsItem( R.drawable.ic_map_marker, - userInfo.address, + userInfo.address!!, resources!!.getString(R.string.user_info_address), Field.ADDRESS, userInfo.addressScope @@ -436,7 +436,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { } override fun onError(e: Throwable) { - item.text = userInfo!!.getValueByField(item.field) + item.text = userInfo!!.getValueByField(item.field)!! Toast.makeText( applicationContext, String.format( @@ -595,7 +595,7 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { credentials, ApiUtils.getUrlForUserData(currentUser!!.baseUrl, currentUser!!.userId), item.field.scopeName, - item.scope!!.getName() + item.scope!!.name ) .retry(DEFAULT_RETRIES) .subscribeOn(Schedulers.io()) @@ -755,7 +755,8 @@ class ProfileController : NewBaseController(R.layout.controller_profile) { } else { holder.binding.scope.visibility = View.VISIBLE when (item.scope) { - Scope.PRIVATE, Scope.LOCAL -> holder.binding.scope.setImageResource(R.drawable.ic_password) + Scope.PRIVATE -> holder.binding.scope.setImageResource(R.drawable.ic_cellphone) + Scope.LOCAL -> holder.binding.scope.setImageResource(R.drawable.ic_password) Scope.FEDERATED -> holder.binding.scope.setImageResource(R.drawable.ic_contacts) Scope.PUBLISHED -> holder.binding.scope.setImageResource(R.drawable.ic_link) } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/ScopeConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/ScopeConverter.java index fc2bbd23f..0d8dc5256 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/converters/ScopeConverter.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/ScopeConverter.java @@ -42,6 +42,6 @@ public class ScopeConverter extends StringBasedTypeConverter { @Override public String convertToString(Scope scope) { - return scope.getName(); + return scope.getId(); } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/statuses/StatusesOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/statuses/StatusesOverall.kt index 866178635..061ca3686 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/statuses/StatusesOverall.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/statuses/StatusesOverall.kt @@ -1,5 +1,4 @@ /* - * * Nextcloud Talk application * * @author Tim Krüger diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.kt similarity index 77% rename from app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.java rename to app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.kt index 04bd2fa28..207d469b2 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/Scope.kt @@ -2,6 +2,8 @@ * Nextcloud Talk application * * @author Tobias Kaminsky + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger * Copyright (C) 2021 Tobias Kaminsky * * This program is free software: you can redistribute it and/or modify @@ -17,22 +19,11 @@ * 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.userprofile -package com.nextcloud.talk.models.json.userprofile; - -public enum Scope { +enum class Scope(val id: String) { PRIVATE("v2-private"), LOCAL("v2-local"), FEDERATED("v2-federated"), - PUBLISHED("v2-published"); - - private final String name; - - Scope(String name) { - this.name = name; - } - - public String getName() { - return name; - } + PUBLISHED("v2-published") } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.java deleted file mode 100644 index 5f02e9f6e..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.java +++ /dev/null @@ -1,348 +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.userprofile; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; -import com.nextcloud.talk.controllers.ProfileController; -import com.nextcloud.talk.models.json.converters.ScopeConverter; - -import org.parceler.Parcel; - -@Parcel -@JsonObject() -public class UserProfileData { - @JsonField(name = "display-name") - String displayName; - - @JsonField(name = "displaynameScope", typeConverter = ScopeConverter.class) - Scope displayNameScope; - - @JsonField(name = "displayname") - String displayNameAlt; - - @JsonField(name = "id") - String userId; - - @JsonField(name = "phone") - String phone; - - @JsonField(name = "phoneScope", typeConverter = ScopeConverter.class) - Scope phoneScope; - - @JsonField(name = "email") - String email; - - @JsonField(name = "emailScope", typeConverter = ScopeConverter.class) - Scope emailScope; - - @JsonField(name = "address") - String address; - - @JsonField(name = "addressScope", typeConverter = ScopeConverter.class) - Scope addressScope; - - @JsonField(name = "twitter") - String twitter; - - @JsonField(name = "twitterScope", typeConverter = ScopeConverter.class) - Scope twitterScope; - - @JsonField(name = "website") - String website; - - @JsonField(name = "websiteScope", typeConverter = ScopeConverter.class) - Scope websiteScope; - - public String getValueByField(ProfileController.Field field) { - switch (field) { - case EMAIL: - return email; - case DISPLAYNAME: - return displayName; - case PHONE: - return phone; - case ADDRESS: - return address; - case WEBSITE: - return website; - case TWITTER: - return twitter; - default: - return ""; - } - } - - public Scope getScopeByField(ProfileController.Field field) { - switch (field) { - case EMAIL: - return emailScope; - case DISPLAYNAME: - return displayNameScope; - case PHONE: - return phoneScope; - case ADDRESS: - return addressScope; - case WEBSITE: - return websiteScope; - case TWITTER: - return twitterScope; - default: - return null; - } - } - - public String getDisplayName() { - return this.displayName; - } - - public Scope getDisplayNameScope() { - return this.displayNameScope; - } - - public String getDisplayNameAlt() { - return this.displayNameAlt; - } - - public String getUserId() { - return this.userId; - } - - public String getPhone() { - return this.phone; - } - - public Scope getPhoneScope() { - return this.phoneScope; - } - - public String getEmail() { - return this.email; - } - - public Scope getEmailScope() { - return this.emailScope; - } - - public String getAddress() { - return this.address; - } - - public Scope getAddressScope() { - return this.addressScope; - } - - public String getTwitter() { - return this.twitter; - } - - public Scope getTwitterScope() { - return this.twitterScope; - } - - public String getWebsite() { - return this.website; - } - - public Scope getWebsiteScope() { - return this.websiteScope; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public void setDisplayNameScope(Scope displayNameScope) { - this.displayNameScope = displayNameScope; - } - - public void setDisplayNameAlt(String displayNameAlt) { - this.displayNameAlt = displayNameAlt; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public void setPhoneScope(Scope phoneScope) { - this.phoneScope = phoneScope; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setEmailScope(Scope emailScope) { - this.emailScope = emailScope; - } - - public void setAddress(String address) { - this.address = address; - } - - public void setAddressScope(Scope addressScope) { - this.addressScope = addressScope; - } - - public void setTwitter(String twitter) { - this.twitter = twitter; - } - - public void setTwitterScope(Scope twitterScope) { - this.twitterScope = twitterScope; - } - - public void setWebsite(String website) { - this.website = website; - } - - public void setWebsiteScope(Scope websiteScope) { - this.websiteScope = websiteScope; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof UserProfileData)) { - return false; - } - final UserProfileData other = (UserProfileData) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$displayName = this.getDisplayName(); - final Object other$displayName = other.getDisplayName(); - if (this$displayName == null ? other$displayName != null : !this$displayName.equals(other$displayName)) { - return false; - } - final Object this$displayNameScope = this.getDisplayNameScope(); - final Object other$displayNameScope = other.getDisplayNameScope(); - if (this$displayNameScope == null ? other$displayNameScope != null : !this$displayNameScope.equals(other$displayNameScope)) { - return false; - } - final Object this$displayNameAlt = this.getDisplayNameAlt(); - final Object other$displayNameAlt = other.getDisplayNameAlt(); - if (this$displayNameAlt == null ? other$displayNameAlt != null : !this$displayNameAlt.equals(other$displayNameAlt)) { - return false; - } - final Object this$userId = this.getUserId(); - final Object other$userId = other.getUserId(); - if (this$userId == null ? other$userId != null : !this$userId.equals(other$userId)) { - return false; - } - final Object this$phone = this.getPhone(); - final Object other$phone = other.getPhone(); - if (this$phone == null ? other$phone != null : !this$phone.equals(other$phone)) { - return false; - } - final Object this$phoneScope = this.getPhoneScope(); - final Object other$phoneScope = other.getPhoneScope(); - if (this$phoneScope == null ? other$phoneScope != null : !this$phoneScope.equals(other$phoneScope)) { - return false; - } - final Object this$email = this.getEmail(); - final Object other$email = other.getEmail(); - if (this$email == null ? other$email != null : !this$email.equals(other$email)) { - return false; - } - final Object this$emailScope = this.getEmailScope(); - final Object other$emailScope = other.getEmailScope(); - if (this$emailScope == null ? other$emailScope != null : !this$emailScope.equals(other$emailScope)) { - return false; - } - final Object this$address = this.getAddress(); - final Object other$address = other.getAddress(); - if (this$address == null ? other$address != null : !this$address.equals(other$address)) { - return false; - } - final Object this$addressScope = this.getAddressScope(); - final Object other$addressScope = other.getAddressScope(); - if (this$addressScope == null ? other$addressScope != null : !this$addressScope.equals(other$addressScope)) { - return false; - } - final Object this$twitter = this.getTwitter(); - final Object other$twitter = other.getTwitter(); - if (this$twitter == null ? other$twitter != null : !this$twitter.equals(other$twitter)) { - return false; - } - final Object this$twitterScope = this.getTwitterScope(); - final Object other$twitterScope = other.getTwitterScope(); - if (this$twitterScope == null ? other$twitterScope != null : !this$twitterScope.equals(other$twitterScope)) { - return false; - } - final Object this$website = this.getWebsite(); - final Object other$website = other.getWebsite(); - if (this$website == null ? other$website != null : !this$website.equals(other$website)) { - return false; - } - final Object this$websiteScope = this.getWebsiteScope(); - final Object other$websiteScope = other.getWebsiteScope(); - - return this$websiteScope == null ? other$websiteScope == null : this$websiteScope.equals(other$websiteScope); - } - - protected boolean canEqual(final Object other) { - return other instanceof UserProfileData; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $displayName = this.getDisplayName(); - result = result * PRIME + ($displayName == null ? 43 : $displayName.hashCode()); - final Object $displayNameScope = this.getDisplayNameScope(); - result = result * PRIME + ($displayNameScope == null ? 43 : $displayNameScope.hashCode()); - final Object $displayNameAlt = this.getDisplayNameAlt(); - result = result * PRIME + ($displayNameAlt == null ? 43 : $displayNameAlt.hashCode()); - final Object $userId = this.getUserId(); - result = result * PRIME + ($userId == null ? 43 : $userId.hashCode()); - final Object $phone = this.getPhone(); - result = result * PRIME + ($phone == null ? 43 : $phone.hashCode()); - final Object $phoneScope = this.getPhoneScope(); - result = result * PRIME + ($phoneScope == null ? 43 : $phoneScope.hashCode()); - final Object $email = this.getEmail(); - result = result * PRIME + ($email == null ? 43 : $email.hashCode()); - final Object $emailScope = this.getEmailScope(); - result = result * PRIME + ($emailScope == null ? 43 : $emailScope.hashCode()); - final Object $address = this.getAddress(); - result = result * PRIME + ($address == null ? 43 : $address.hashCode()); - final Object $addressScope = this.getAddressScope(); - result = result * PRIME + ($addressScope == null ? 43 : $addressScope.hashCode()); - final Object $twitter = this.getTwitter(); - result = result * PRIME + ($twitter == null ? 43 : $twitter.hashCode()); - final Object $twitterScope = this.getTwitterScope(); - result = result * PRIME + ($twitterScope == null ? 43 : $twitterScope.hashCode()); - final Object $website = this.getWebsite(); - result = result * PRIME + ($website == null ? 43 : $website.hashCode()); - final Object $websiteScope = this.getWebsiteScope(); - result = result * PRIME + ($websiteScope == null ? 43 : $websiteScope.hashCode()); - return result; - } - - public String toString() { - return "UserProfileData(displayName=" + this.getDisplayName() + ", displayNameScope=" + this.getDisplayNameScope() + ", displayNameAlt=" + this.getDisplayNameAlt() + ", userId=" + this.getUserId() + ", phone=" + this.getPhone() + ", phoneScope=" + this.getPhoneScope() + ", email=" + this.getEmail() + ", emailScope=" + this.getEmailScope() + ", address=" + this.getAddress() + ", addressScope=" + this.getAddressScope() + ", twitter=" + this.getTwitter() + ", twitterScope=" + this.getTwitterScope() + ", website=" + this.getWebsite() + ", websiteScope=" + this.getWebsiteScope() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.kt b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.kt new file mode 100644 index 000000000..d4ab48b2a --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileData.kt @@ -0,0 +1,102 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2017 Mario Danic + * + * 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.userprofile + +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import com.nextcloud.talk.controllers.ProfileController +import com.nextcloud.talk.models.json.converters.ScopeConverter +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject +data class UserProfileData( + @JsonField(name = ["display-name"]) + var displayName: String?, + + @JsonField(name = ["displaynameScope"], typeConverter = ScopeConverter::class) + var displayNameScope: Scope?, + + @JsonField(name = ["displayname"]) + var displayNameAlt: String?, + + @JsonField(name = ["id"]) + var userId: String?, + + @JsonField(name = ["phone"]) + var phone: String?, + + @JsonField(name = ["phoneScope"], typeConverter = ScopeConverter::class) + var phoneScope: Scope?, + + @JsonField(name = ["email"]) + var email: String?, + + @JsonField(name = ["emailScope"], typeConverter = ScopeConverter::class) + var emailScope: Scope?, + + @JsonField(name = ["address"]) + var address: String?, + + @JsonField(name = ["addressScope"], typeConverter = ScopeConverter::class) + var addressScope: Scope?, + + @JsonField(name = ["twitter"]) + var twitter: String?, + + @JsonField(name = ["twitterScope"], typeConverter = ScopeConverter::class) + var twitterScope: Scope?, + + @JsonField(name = ["website"]) + var website: String?, + + @JsonField(name = ["websiteScope"], typeConverter = ScopeConverter::class) + var websiteScope: Scope? +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null, null, null, null, null, null, null, null, null, null, null, null, null, null) + + fun getValueByField(field: ProfileController.Field?): String? { + return when (field) { + ProfileController.Field.EMAIL -> email + ProfileController.Field.DISPLAYNAME -> displayName + ProfileController.Field.PHONE -> phone + ProfileController.Field.ADDRESS -> address + ProfileController.Field.WEBSITE -> website + ProfileController.Field.TWITTER -> twitter + else -> "" + } + } + + fun getScopeByField(field: ProfileController.Field?): Scope? { + return when (field) { + ProfileController.Field.EMAIL -> emailScope + ProfileController.Field.DISPLAYNAME -> displayNameScope + ProfileController.Field.PHONE -> phoneScope + ProfileController.Field.ADDRESS -> addressScope + ProfileController.Field.WEBSITE -> websiteScope + ProfileController.Field.TWITTER -> twitterScope + else -> null + } + } +} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.java deleted file mode 100644 index db7573cb2..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tobias Kaminsky - * Copyright (C) 2021 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.userprofile; - -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.ArrayList; - -@Parcel -@JsonObject -public class UserProfileFieldsOCS extends GenericOCS { - @JsonField(name = "data") - ArrayList data; - - public ArrayList getData() { - return this.data; - } - - public void setData(ArrayList data) { - this.data = data; - } - - public String toString() { - return "UserProfileFieldsOCS(data=" + this.getData() + ")"; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof UserProfileFieldsOCS)) { - return false; - } - final UserProfileFieldsOCS other = (UserProfileFieldsOCS) o; - if (!other.canEqual((Object) this)) { - return false; - } - if (!super.equals(o)) { - return false; - } - final Object this$data = this.getData(); - final Object other$data = other.getData(); - - return this$data == null ? other$data == null : this$data.equals(other$data); - } - - protected boolean canEqual(final Object other) { - return other instanceof UserProfileFieldsOCS; - } - - public int hashCode() { - final int PRIME = 59; - int result = super.hashCode(); - final Object $data = this.getData(); - result = result * PRIME + ($data == null ? 43 : $data.hashCode()); - return result; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.kt new file mode 100644 index 000000000..7b52a22bc --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOCS.kt @@ -0,0 +1,39 @@ +/* + * Nextcloud Talk application + * + * @author Tobias Kaminsky + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2021 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.userprofile + +import android.os.Parcelable +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import com.nextcloud.talk.models.json.generic.GenericOCS +import kotlinx.android.parcel.Parcelize +import java.util.ArrayList + +@Parcelize +@JsonObject +data class UserProfileFieldsOCS ( + @JsonField(name = ["data"]) + var data: ArrayList? = null +) : GenericOCS(), Parcelable { + // 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/userprofile/UserProfileFieldsOverall.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.java deleted file mode 100644 index 6bb09c35d..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Nextcloud Talk application - * - * @author Tobias Kaminsky - * Copyright (C) 2021 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.userprofile; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -@Parcel -@JsonObject -public class UserProfileFieldsOverall { - @JsonField(name = "ocs") - UserProfileFieldsOCS ocs; - - public UserProfileFieldsOCS getOcs() { - return this.ocs; - } - - public void setOcs(UserProfileFieldsOCS ocs) { - this.ocs = ocs; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof UserProfileFieldsOverall)) { - return false; - } - final UserProfileFieldsOverall other = (UserProfileFieldsOverall) 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 UserProfileFieldsOverall; - } - - 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 "UserProfileFieldsOverall(ocs=" + this.getOcs() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.kt new file mode 100644 index 000000000..25f45bb78 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileFieldsOverall.kt @@ -0,0 +1,37 @@ +/* + * Nextcloud Talk application + * + * @author Tobias Kaminsky + * @author Andy Scherzinger + * Copyright (C) 2022 Andy Scherzinger + * Copyright (C) 2021 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.userprofile + +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 UserProfileFieldsOverall ( + @JsonField(name = ["ocs"]) + var ocs: UserProfileFieldsOCS? +) : Parcelable { + // 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/userprofile/UserProfileOCS.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.java deleted file mode 100644 index a9eaf1ec2..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.java +++ /dev/null @@ -1,75 +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.userprofile; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; -import com.nextcloud.talk.models.json.generic.GenericOCS; - -import org.parceler.Parcel; - -@Parcel -@JsonObject -public class UserProfileOCS extends GenericOCS { - @JsonField(name = "data") - UserProfileData data; - - public UserProfileData getData() { - return this.data; - } - - public void setData(UserProfileData data) { - this.data = data; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof UserProfileOCS)) { - return false; - } - final UserProfileOCS other = (UserProfileOCS) o; - if (!other.canEqual((Object) this)) { - return false; - } - final Object this$data = this.getData(); - final Object other$data = other.getData(); - - return this$data == null ? other$data == null : this$data.equals(other$data); - } - - protected boolean canEqual(final Object other) { - return other instanceof UserProfileOCS; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - final Object $data = this.getData(); - result = result * PRIME + ($data == null ? 43 : $data.hashCode()); - return result; - } - - public String toString() { - return "UserProfileOCS(data=" + this.getData() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.kt b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.kt new file mode 100644 index 000000000..8b5ded051 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOCS.kt @@ -0,0 +1,38 @@ +/* + * 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.userprofile + +import android.os.Parcelable +import com.bluelinelabs.logansquare.annotation.JsonField +import com.bluelinelabs.logansquare.annotation.JsonObject +import com.nextcloud.talk.models.json.generic.GenericOCS +import kotlinx.android.parcel.Parcelize + +@Parcelize +@JsonObject +data class UserProfileOCS ( + @JsonField(name = ["data"]) + var data: UserProfileData? +) : GenericOCS(), Parcelable { + // 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/userprofile/UserProfileOverall.java b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.java deleted file mode 100644 index 78a86d5ae..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.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.userprofile; - -import com.bluelinelabs.logansquare.annotation.JsonField; -import com.bluelinelabs.logansquare.annotation.JsonObject; - -import org.parceler.Parcel; - -@Parcel -@JsonObject -public class UserProfileOverall { - @JsonField(name = "ocs") - UserProfileOCS ocs; - - public UserProfileOCS getOcs() { - return this.ocs; - } - - public void setOcs(UserProfileOCS ocs) { - this.ocs = ocs; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof UserProfileOverall)) { - return false; - } - final UserProfileOverall other = (UserProfileOverall) 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 UserProfileOverall; - } - - 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 "UserProfileOverall(ocs=" + this.getOcs() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.kt b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.kt new file mode 100644 index 000000000..29087b710 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/userprofile/UserProfileOverall.kt @@ -0,0 +1,37 @@ +/* + * 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.userprofile + +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 UserProfileOverall ( + @JsonField(name = ["ocs"]) + var ocs: UserProfileOCS? = null +) : Parcelable { + // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' + constructor() : this(null) +} diff --git a/app/src/main/res/drawable-night/ic_cellphone.xml b/app/src/main/res/drawable-night/ic_cellphone.xml new file mode 100644 index 000000000..a7b5c12d0 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_cellphone.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_cellphone.xml b/app/src/main/res/drawable/ic_cellphone.xml new file mode 100644 index 000000000..12d964ff7 --- /dev/null +++ b/app/src/main/res/drawable/ic_cellphone.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/layout/dialog_scope.xml b/app/src/main/res/layout/dialog_scope.xml index 23fe1051c..ee3acc3fb 100644 --- a/app/src/main/res/layout/dialog_scope.xml +++ b/app/src/main/res/layout/dialog_scope.xml @@ -40,11 +40,11 @@ android:paddingBottom="@dimen/standard_half_padding"> + app:srcCompat="@drawable/ic_cellphone" />