diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt index dcace5fa..5aa085ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt @@ -5,9 +5,8 @@ import android.content.Intent import android.media.RingtoneManager import android.net.Uri import android.os.Bundle -import android.view.Menu -import android.view.MenuItem import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter @@ -32,28 +31,14 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh protected var contact: Contact? = null - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - super.onActivityResult(requestCode, resultCode, resultData) - if (requestCode == INTENT_SELECT_RINGTONE && resultCode == Activity.RESULT_OK && resultData != null) { - val extras = resultData.extras - if (extras?.containsKey(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) == true) { - val uri = extras.getParcelable(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) ?: return - try { - setRingtoneOnSelected(uri) - } catch (e: Exception) { - showErrorToast(e) - } - } - } - } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_group_contacts) updateTextColors(group_contacts_coordinator) + setupOptionsMenu() group = intent.extras?.getSerializable(GROUP) as Group - supportActionBar?.title = group.title + group_contacts_toolbar.title = group.title group_contacts_fab.setOnClickListener { if (wasInit) { @@ -74,22 +59,34 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh override fun onResume() { super.onResume() refreshContacts() + setupToolbar(group_contacts_toolbar, NavigationIcon.Arrow) } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_group, menu) - updateMenuItemColors(menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.send_sms_to_group -> sendSMSToGroup() - R.id.send_email_to_group -> sendEmailToGroup() - R.id.assign_ringtone_to_group -> assignRingtoneToGroup() - else -> return super.onOptionsItemSelected(item) + private fun setupOptionsMenu() { + group_contacts_toolbar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.send_sms_to_group -> sendSMSToGroup() + R.id.send_email_to_group -> sendEmailToGroup() + R.id.assign_ringtone_to_group -> assignRingtoneToGroup() + else -> return@setOnMenuItemClickListener false + } + return@setOnMenuItemClickListener true + } + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + super.onActivityResult(requestCode, resultCode, resultData) + if (requestCode == INTENT_SELECT_RINGTONE && resultCode == Activity.RESULT_OK && resultData != null) { + val extras = resultData.extras + if (extras?.containsKey(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) == true) { + val uri = extras.getParcelable(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) ?: return + try { + setRingtoneOnSelected(uri) + } catch (e: Exception) { + showErrorToast(e) + } + } } - return true } private fun fabClicked() { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt index 4b83cc78..62745d15 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt @@ -53,6 +53,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_insert_edit_contact) + setupOptionsMenu() isSelectContactIntent = intent.action == Intent.ACTION_PICK if (isSelectContactIntent) { @@ -89,6 +90,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { override fun onResume() { super.onResume() setupTabColors() + setupToolbar(insert_edit_toolbar, NavigationIcon.None, searchMenuItem = searchMenuItem) } override fun onStop() { @@ -96,20 +98,16 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { searchMenuItem?.collapseActionView() } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_insert_or_edit, menu) - setupSearch(menu) - updateMenuItemColors(menu) - return super.onCreateOptionsMenu(menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.sort -> showSortingDialog() - R.id.filter -> showFilterDialog() - else -> return super.onOptionsItemSelected(item) + private fun setupOptionsMenu() { + setupSearch(insert_edit_toolbar.menu) + insert_edit_toolbar.setOnMenuItemClickListener { menuItem -> + when (menuItem.itemId) { + R.id.sort -> showSortingDialog() + R.id.filter -> showFilterDialog() + else -> return@setOnMenuItemClickListener false + } + return@setOnMenuItemClickListener true } - return true } override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { @@ -122,18 +120,15 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { private fun initFragments() { view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrollStateChanged(state: Int) { - if (isSearchOpen) { - getCurrentFragment()?.onSearchQueryChanged("") - searchMenuItem?.collapseActionView() - } - } + override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { insert_or_edit_tabs_holder.getTabAt(position)?.select() - invalidateOptionsMenu() + getAllFragments().forEach { + it?.finishActMode() + } } }) diff --git a/app/src/main/res/layout/activity_group_contacts.xml b/app/src/main/res/layout/activity_group_contacts.xml index 4823da50..73fdbb73 100644 --- a/app/src/main/res/layout/activity_group_contacts.xml +++ b/app/src/main/res/layout/activity_group_contacts.xml @@ -5,62 +5,85 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + android:layout_height="?attr/actionBarSize" + android:background="@color/color_primary" + app:menu="@menu/menu_group" + app:title="" + app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" /> - + - + + - + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:alpha="0.8" + android:gravity="center" + android:paddingStart="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" + android:paddingEnd="@dimen/activity_margin" + android:text="@string/no_group_participants" + android:textSize="@dimen/bigger_text_size" + android:textStyle="italic" + android:visibility="gone" /> - - + - + + + + + + + + + diff --git a/app/src/main/res/layout/activity_insert_edit_contact.xml b/app/src/main/res/layout/activity_insert_edit_contact.xml index 6702c5e0..4f5d0cd7 100644 --- a/app/src/main/res/layout/activity_insert_edit_contact.xml +++ b/app/src/main/res/layout/activity_insert_edit_contact.xml @@ -1,70 +1,93 @@ - + android:layout_height="match_parent"> + + + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - + android:background="?attr/selectableItemBackground" + android:paddingTop="@dimen/medium_margin" + android:paddingEnd="@dimen/activity_margin" + android:paddingBottom="@dimen/medium_margin" + android:visibility="gone"> + + + + + + + + + + + + - - - - - - - - + diff --git a/app/src/main/res/menu/menu_group.xml b/app/src/main/res/menu/menu_group.xml index bdc6b6a2..b2adc9f1 100644 --- a/app/src/main/res/menu/menu_group.xml +++ b/app/src/main/res/menu/menu_group.xml @@ -1,19 +1,19 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="always" /> + app:showAsAction="always" /> + app:showAsAction="always" />