create a separate layout for the Select Contact contacts fragment
This commit is contained in:
parent
9319c934e0
commit
21cd58f0bb
|
@ -17,8 +17,8 @@ import com.simplemobiletools.contacts.pro.helpers.FAVORITES_TAB_MASK
|
|||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
||||
import kotlinx.android.synthetic.main.fragment_contacts.*
|
||||
import kotlinx.android.synthetic.main.fragment_favorites.*
|
||||
import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.*
|
||||
|
||||
class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
private val START_INSERT_ACTIVITY = 1
|
||||
|
@ -110,7 +110,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||
}
|
||||
|
||||
if (viewpager.adapter == null) {
|
||||
val fragments = arrayListOf(R.layout.fragment_contacts, R.layout.fragment_favorites)
|
||||
val fragments = arrayListOf(R.layout.fragment_insert_or_edit_contacts, R.layout.fragment_favorites)
|
||||
viewpager.adapter = ViewPagerAdapter(this, contactsFavoritesList, CONTACTS_TAB_MASK or FAVORITES_TAB_MASK, fragments)
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||
}
|
||||
|
||||
if (refreshTabsMask and CONTACTS_TAB_MASK != 0) {
|
||||
contacts_fragment?.refreshContacts(contacts)
|
||||
insert_or_edit_contacts_fragment?.refreshContacts(contacts)
|
||||
}
|
||||
|
||||
if (refreshTabsMask and FAVORITES_TAB_MASK != 0) {
|
||||
|
|
|
@ -16,4 +16,6 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||
override fun placeholderClicked() {
|
||||
(activity as? MainActivity)?.showFilterDialog()
|
||||
}
|
||||
|
||||
override fun viewSetup() {}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,6 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
(activity as? MainActivity)?.refreshContacts(FAVORITES_TAB_MASK)
|
||||
}
|
||||
}
|
||||
|
||||
override fun viewSetup() {}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,6 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
(activity as? MainActivity)?.refreshContacts(GROUPS_TAB_MASK)
|
||||
}
|
||||
}
|
||||
|
||||
override fun viewSetup() {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.simplemobiletools.contacts.pro.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.extensions.config
|
||||
import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.view.*
|
||||
|
||||
class InsertOrEditContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun fabClicked() {}
|
||||
|
||||
override fun placeholderClicked() {}
|
||||
|
||||
override fun viewSetup() {
|
||||
select_contact_label.setTextColor(context.getAdjustedPrimaryColor())
|
||||
new_contact_tmb.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_new_contact_vector, context.config.textColor))
|
||||
new_contact_holder.setOnClickListener {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,15 +39,15 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
config = activity.config
|
||||
if (this.activity == null) {
|
||||
this.activity = activity
|
||||
fragment_fab.setOnClickListener {
|
||||
fragment_fab?.setOnClickListener {
|
||||
fabClicked()
|
||||
}
|
||||
|
||||
fragment_placeholder_2.setOnClickListener {
|
||||
fragment_placeholder_2?.setOnClickListener {
|
||||
placeholderClicked()
|
||||
}
|
||||
|
||||
fragment_placeholder_2.underlineText()
|
||||
fragment_placeholder_2?.underlineText()
|
||||
updateViewStuff()
|
||||
|
||||
when {
|
||||
|
@ -298,16 +298,19 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
context.updateTextColors(fragment_wrapper.parent as ViewGroup)
|
||||
fragment_fastscroller.updateBubbleColors()
|
||||
fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
fragment_placeholder_2.setTextColor(context.getAdjustedPrimaryColor())
|
||||
fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor())
|
||||
viewSetup()
|
||||
}
|
||||
|
||||
private fun setupViewVisibility(hasItemsToShow: Boolean) {
|
||||
fragment_placeholder_2.beVisibleIf(!hasItemsToShow)
|
||||
fragment_placeholder.beVisibleIf(!hasItemsToShow)
|
||||
fragment_placeholder_2?.beVisibleIf(!hasItemsToShow)
|
||||
fragment_placeholder?.beVisibleIf(!hasItemsToShow)
|
||||
fragment_list.beVisibleIf(hasItemsToShow)
|
||||
}
|
||||
|
||||
abstract fun fabClicked()
|
||||
|
||||
abstract fun placeholderClicked()
|
||||
|
||||
abstract fun viewSetup()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.contacts.pro.fragments.InsertOrEditContactsFragment
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/insert_or_edit_contacts_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/fragment_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/new_contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_contact_tmb"
|
||||
android:layout_width="@dimen/normal_icon_size"
|
||||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_new_contact_vector" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/new_contact_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/new_contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:text="@string/create_new_contact"
|
||||
android:textSize="@dimen/big_text_size" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_contact_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/new_contact_holder"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:text="@string/add_to_existing_contact"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/fragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/select_contact_label"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/fragment_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/select_contact_label"
|
||||
android:layout_alignTop="@+id/select_contact_list"
|
||||
android:layout_alignBottom="@+id/fragment_list"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</RelativeLayout>
|
||||
</com.simplemobiletools.contacts.pro.fragments.InsertOrEditContactsFragment>
|
Loading…
Reference in New Issue