Skip to content
Snippets Groups Projects
Commit a935402e authored by Amirhossein Naghshzan's avatar Amirhossein Naghshzan Committed by Adrien Béraud
Browse files

ContactDetailsActivity: fix swarm profile bugs

Change-Id: I146a54cf5e3b45154661065ef81fbd31b65b53a9
parent b3bade5e
No related branches found
Tags android/release_271
No related merge requests found
Showing with 75 additions and 54 deletions
......@@ -94,25 +94,9 @@ class RenameSwarmDialog : DialogFragment() {
super.onDestroy()
}
private fun checkInput(input: String): Boolean {
if (input.isEmpty()) {
binding?.apply {
titleTxtBox.isErrorEnabled = true
titleTxtBox.error = getString(R.string.rename_error)
}
return false
} else {
binding?.apply {
titleTxtBox.isErrorEnabled = false
titleTxtBox.error = null
}
}
return true
}
private fun validate(): Boolean {
val input = binding!!.titleTxt.text.toString().trim { it <= ' ' }
if (checkInput(input) && mListener != null) {
if (mListener != null) {
mListener!!.onSwarmRename(key!!, input)
return true
}
......
......@@ -23,7 +23,7 @@ import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import cx.ring.databinding.ItemSmartlistBinding
import cx.ring.databinding.ItemContactBinding
import cx.ring.viewholders.ContactPickerViewHolder
import cx.ring.viewholders.ContactPickerViewHolder.ContactPickerListeners
import net.jami.smartlist.ConversationItemViewModel
......@@ -36,7 +36,7 @@ class ContactPickerAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactPickerViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
return ContactPickerViewHolder(ItemSmartlistBinding.inflate(layoutInflater, parent, false))
return ContactPickerViewHolder(ItemContactBinding.inflate(layoutInflater, parent, false))
}
override fun onViewRecycled(holder: ContactPickerViewHolder) {
......
......@@ -132,7 +132,10 @@ class ContactDetailsActivity : AppCompatActivity(), TabLayout.OnTabSelectedListe
.withCircleCrop(true)
.build(this))
binding.title.text = vm.title
if (conversation.getDescription() != null) binding.description.text = conversation.getDescription()
if (conversation.getDescription().isNullOrBlank())
binding.description.text = getString(R.string.swarm_description)
else
binding.description.text = conversation.getDescription()
}) { e ->
Log.e(TAG, "e", e)
finish()
......@@ -148,27 +151,32 @@ class ContactDetailsActivity : AppCompatActivity(), TabLayout.OnTabSelectedListe
binding.description.isVisible = true
binding.addMember.setOnClickListener { ContactPickerFragment().show(supportFragmentManager, ContactPickerFragment.TAG) }
binding.title.setOnClickListener {
val title = getString(R.string.dialogtitle_title)
val hint = getString(R.string.dialog_hint_title)
RenameSwarmDialog().apply {
arguments = Bundle().apply { putString(RenameSwarmDialog.KEY, RenameSwarmDialog.KEY_TITLE) }
setTitle(getString(R.string.dialogtitle_title))
setHint(getString(R.string.dialog_hint_title))
setText(binding.title.text.toString())
setTitle(title)
setHint(hint)
setText(conversation.getTitle())
setListener(this@ContactDetailsActivity)
}.show(supportFragmentManager, TAG)
}
binding.description.setOnClickListener {
val title = getString(R.string.dialogtitle_description)
val hint = getString(R.string.dialog_hint_description)
RenameSwarmDialog().apply {
arguments = Bundle().apply { putString(RenameSwarmDialog.KEY, RenameSwarmDialog.KEY_DESCRIPTION) }
setTitle(getString(R.string.dialogtitle_description))
setHint(getString(R.string.dialog_hint_description))
setTitle(title)
setHint(hint)
setText(conversation.getDescription())
setListener(this@ContactDetailsActivity)
}.show(supportFragmentManager, TAG)
}
} else {
binding.tabLayout.removeTabAt(TAB_MEMBER)
}
mPagerAdapter = ScreenSlidePagerAdapter(this, conversation.accountId, conversation.uri)
mPagerAdapter = ScreenSlidePagerAdapter(this, conversation)
binding.pager.adapter = mPagerAdapter
binding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
......@@ -246,11 +254,19 @@ class ContactDetailsActivity : AppCompatActivity(), TabLayout.OnTabSelectedListe
mAccountService.updateConversationInfo(path!!.accountId, path!!.conversationUri.host, map)
}
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity, accountId: String, conversationId: Uri) : FragmentStateAdapter(fa) {
val fragments: List<Fragment> = listOf(
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity, conversation: Conversation) : FragmentStateAdapter(fa) {
val accountId = conversation.accountId
val conversationId = conversation.uri
val isGroup = conversation.isGroup()
val fragments: List<Fragment> = if (isGroup) listOf(
ConversationActionsFragment.newInstance(accountId, conversationId),
ConversationMembersFragment.newInstance(accountId, conversationId),
ConversationGalleryFragment.newInstance(accountId, conversationId))
else listOf(
ConversationActionsFragment.newInstance(accountId, conversationId),
ConversationGalleryFragment.newInstance(accountId, conversationId))
override fun getItemCount(): Int = fragments.size
......
......@@ -21,15 +21,16 @@ package cx.ring.viewholders
import android.view.animation.AlphaAnimation
import android.view.animation.DecelerateInterpolator
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import cx.ring.databinding.ItemSmartlistBinding
import cx.ring.databinding.ItemContactBinding
import cx.ring.views.AvatarDrawable
import net.jami.model.*
import net.jami.smartlist.ConversationItemViewModel
class ContactPickerViewHolder(b: ItemSmartlistBinding) :
class ContactPickerViewHolder(b: ItemContactBinding) :
RecyclerView.ViewHolder(b.root) {
private val binding: ItemSmartlistBinding = b
private val binding: ItemContactBinding = b
private var currentUri: Uri? = null
private fun fadeIn() = AlphaAnimation(0f, 1f).apply {
......@@ -40,9 +41,7 @@ class ContactPickerViewHolder(b: ItemSmartlistBinding) :
fun bind(clickListener: ContactPickerListeners, conversation: ConversationItemViewModel) {
if (conversation.uri != currentUri) {
currentUri = conversation.uri
binding.convLastItem.text = ""
binding.convLastTime.text = ""
binding.convParticipant.text = ""
binding.quickCall.isVisible = false
binding.photo.setImageDrawable(null)
}
......@@ -52,7 +51,7 @@ class ContactPickerViewHolder(b: ItemSmartlistBinding) :
true
}
binding.convParticipant.text = conversation.title
binding.displayName.text = conversation.title
val fade = binding.photo.drawable !is AvatarDrawable
binding.photo.setImageDrawable(AvatarDrawable.Builder()
.withViewModel(conversation)
......
......@@ -50,10 +50,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/contact_image"
android:layout_centerHorizontal="true"
android:layout_marginStart="22dp"
android:layout_marginTop="22dp"
android:layout_marginEnd="22dp"
android:layout_marginBottom="22dp"
android:layout_margin="15dp"
android:padding="5dp"
android:ellipsize="end"
android:fontFamily="@font/ubuntu_medium"
android:maxLines="1"
......
......@@ -39,6 +39,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
app:title="@string/menu_item_about" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -306,6 +312,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -28,6 +28,12 @@
android:layout_below="@id/toolbar" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
android:layout_width="wrap_content"
......@@ -41,5 +47,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
......@@ -41,6 +41,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
......@@ -780,4 +786,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -59,6 +59,7 @@ class Conversation : ConversationHistory {
private set
private val mMode: Subject<Mode>
private var description: String? = null
private var title: String? = null
private val profileSubject: Subject<Single<Profile>> = BehaviorSubject.createDefault(Profile.EMPTY_PROFILE_SINGLE)
val profile: Observable<Profile> = profileSubject.switchMapSingle { single -> single }
......@@ -640,7 +641,7 @@ class Conversation : ConversationHistory {
fun getSymbol(): Observable<CharSequence> = symbol
fun updateInfo(info: Map<String, String>) {
//title = info["title"]
title = info["title"]
//avatar = info["avatar"]
setProfile(Profile(info["title"], info["avatar"]))
description = info["description"]
......@@ -651,7 +652,7 @@ class Conversation : ConversationHistory {
preferences["symbol"]?.let { symbol.onNext(it) }
}
//fun getTitle() = title
fun getTitle() = title
fun getDescription() = description
fun isGroup(): Boolean = isSwarm && contacts.size > 2
@Synchronized
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment