add a new menu item for adding selected contacts to a group

This commit is contained in:
tibbi 2018-03-20 20:13:51 +01:00
parent c93cc3bd85
commit cd1a493ea8
12 changed files with 27 additions and 1 deletions

View File

@ -56,6 +56,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
findItem(R.id.cab_edit).isVisible = isOneItemSelected() findItem(R.id.cab_edit).isVisible = isOneItemSelected()
findItem(R.id.cab_remove).isVisible = location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS findItem(R.id.cab_remove).isVisible = location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
findItem(R.id.cab_add_to_favorites).isVisible = location == LOCATION_CONTACTS_TAB findItem(R.id.cab_add_to_favorites).isVisible = location == LOCATION_CONTACTS_TAB
findItem(R.id.cab_add_to_group).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB
findItem(R.id.cab_delete).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_GROUP_CONTACTS findItem(R.id.cab_delete).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_GROUP_CONTACTS
if (location == LOCATION_GROUP_CONTACTS) { if (location == LOCATION_GROUP_CONTACTS) {
@ -79,6 +80,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
R.id.cab_edit -> editContact() R.id.cab_edit -> editContact()
R.id.cab_select_all -> selectAll() R.id.cab_select_all -> selectAll()
R.id.cab_add_to_favorites -> addToFavorites() R.id.cab_add_to_favorites -> addToFavorites()
R.id.cab_add_to_group -> addToGroup()
R.id.cab_share -> shareContacts() R.id.cab_share -> shareContacts()
R.id.cab_remove -> removeContacts() R.id.cab_remove -> removeContacts()
R.id.cab_delete -> askConfirmDelete() R.id.cab_delete -> askConfirmDelete()
@ -168,12 +170,21 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
private fun addToFavorites() { private fun addToFavorites() {
val newFavorites = ArrayList<Contact>() val newFavorites = ArrayList<Contact>()
selectedPositions.forEach { newFavorites.add(contactItems[it]) } selectedPositions.forEach {
newFavorites.add(contactItems[it])
}
ContactsHelper(activity).addFavorites(newFavorites) ContactsHelper(activity).addFavorites(newFavorites)
refreshListener?.refreshContacts(FAVORITES_TAB_MASK) refreshListener?.refreshContacts(FAVORITES_TAB_MASK)
finishActMode() finishActMode()
} }
private fun addToGroup() {
val selectedContacts = ArrayList<Contact>()
selectedPositions.forEach {
selectedContacts.add(contactItems[it])
}
}
private fun shareContacts() { private fun shareContacts() {
val contactsIDs = ArrayList<Int>() val contactsIDs = ArrayList<Int>()
selectedPositions.forEach { selectedPositions.forEach {

View File

@ -16,6 +16,11 @@
android:icon="@drawable/ic_star_on" android:icon="@drawable/ic_star_on"
android:title="@string/add_to_favorites" android:title="@string/add_to_favorites"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_add_to_group"
android:icon="@drawable/ic_group"
android:title="@string/add_to_group"
app:showAsAction="ifRoom"/>
<item <item
android:id="@+id/cab_share" android:id="@+id/cab_share"
android:icon="@drawable/ic_share" android:icon="@drawable/ic_share"

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Foto machen</string> <string name="take_photo">Foto machen</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Prendre une photo</string> <string name="take_photo">Prendre une photo</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">사진 촬영</string> <string name="take_photo">사진 촬영</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Nufotografuoti</string> <string name="take_photo">Nufotografuoti</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Tirar foto</string> <string name="take_photo">Tirar foto</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Снять фото</string> <string name="take_photo">Снять фото</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Pridať kontakty</string> <string name="add_contacts">Pridať kontakty</string>
<string name="no_group_created">Nemáte v zariadení vytvorené žiadne skupiny kontaktov</string> <string name="no_group_created">Nemáte v zariadení vytvorené žiadne skupiny kontaktov</string>
<string name="create_group">Vytvoriť skupinu</string> <string name="create_group">Vytvoriť skupinu</string>
<string name="add_to_group">Pridať do skupiny</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Vytvoriť foto</string> <string name="take_photo">Vytvoriť foto</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Ta foto</string> <string name="take_photo">Ta foto</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">拍照</string> <string name="take_photo">拍照</string>

View File

@ -23,6 +23,7 @@
<string name="add_contacts">Add contacts</string> <string name="add_contacts">Add contacts</string>
<string name="no_group_created">There are no contact groups on the device</string> <string name="no_group_created">There are no contact groups on the device</string>
<string name="create_group">Create group</string> <string name="create_group">Create group</string>
<string name="add_to_group">Add to group</string>
<!-- Photo --> <!-- Photo -->
<string name="take_photo">Take photo</string> <string name="take_photo">Take photo</string>