lets create a new activity for displaying group contacts
This commit is contained in:
parent
45c0edc177
commit
2ce2b38ee1
|
@ -74,6 +74,10 @@
|
|||
android:label="@string/settings"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.GroupContactsActivity"
|
||||
android:parentActivityName=".activities.MainActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.ViewContactActivity"
|
||||
android:label="@string/details"
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.helpers.GROUP
|
||||
import com.simplemobiletools.contacts.models.Group
|
||||
import kotlinx.android.synthetic.main.activity_group_contacts.*
|
||||
|
||||
class GroupContactsActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_group_contacts)
|
||||
updateTextColors(group_contacts_coordinator)
|
||||
|
||||
val group = intent.extras.getSerializable(GROUP) as Group
|
||||
supportActionBar?.title = group.title
|
||||
}
|
||||
}
|
|
@ -1,24 +1,27 @@
|
|||
package com.simplemobiletools.contacts.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.support.design.widget.CoordinatorLayout
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.contacts.activities.GroupContactsActivity
|
||||
import com.simplemobiletools.contacts.activities.MainActivity
|
||||
import com.simplemobiletools.contacts.activities.SimpleActivity
|
||||
import com.simplemobiletools.contacts.adapters.GroupsAdapter
|
||||
import com.simplemobiletools.contacts.dialogs.CreateNewGroupDialog
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.helpers.GROUP
|
||||
import com.simplemobiletools.contacts.interfaces.FragmentInterface
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
import com.simplemobiletools.contacts.models.Group
|
||||
import kotlinx.android.synthetic.main.fragment_groups.view.*
|
||||
|
||||
class GroupsFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet), FragmentInterface {
|
||||
var activity: MainActivity? = null
|
||||
var lastContacts = ArrayList<Contact>()
|
||||
private var activity: MainActivity? = null
|
||||
private var lastContacts = ArrayList<Contact>()
|
||||
|
||||
override fun setupFragment(activity: MainActivity) {
|
||||
if (this.activity == null) {
|
||||
|
@ -63,8 +66,10 @@ class GroupsFragment(context: Context, attributeSet: AttributeSet) : Coordinator
|
|||
val currAdapter = groups_list.adapter
|
||||
if (currAdapter == null) {
|
||||
GroupsAdapter(activity as SimpleActivity, storedGroups, groups_list, groups_fastscroller) {
|
||||
val group = it as Group
|
||||
val groupContacts = contacts.filter { it.groups.map { it.id }.contains(group.id) }
|
||||
Intent(activity, GroupContactsActivity::class.java).apply {
|
||||
putExtra(GROUP, it as Group)
|
||||
activity!!.startActivity(this)
|
||||
}
|
||||
}.apply {
|
||||
setupDragListener(true)
|
||||
addVerticalDividers(true)
|
||||
|
|
|
@ -13,6 +13,7 @@ const val ON_CONTACT_CLICK = "on_contact_click"
|
|||
const val CONTACT_ID = "contact_id"
|
||||
const val SMT_PRIVATE = "smt_private" // used at the contact source of local contacts hidden from other apps
|
||||
const val IS_PRIVATE = "is_private"
|
||||
const val GROUP = "group"
|
||||
|
||||
// contact photo changes
|
||||
const val PHOTO_ADDED = 1
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package com.simplemobiletools.contacts.models
|
||||
|
||||
data class Group(var id: Long, var title: String, var contactsCount: Int = 0) {
|
||||
import java.io.Serializable
|
||||
|
||||
data class Group(var id: Long, var title: String, var contactsCount: Int = 0) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = -1384515348451345L
|
||||
}
|
||||
|
||||
fun addContact() = contactsCount++
|
||||
|
||||
fun getBubbleText() = title
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/group_contacts_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/group_contacts_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/group_contacts_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/group_contacts_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical"/>
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||
android:id="@+id/group_contacts_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_plus"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue