redesigning some remaining screens

This commit is contained in:
tibbi 2022-07-23 10:06:44 +02:00
parent d62355bc24
commit 384918ed84
5 changed files with 196 additions and 158 deletions

View File

@ -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<Uri>(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<Uri>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) ?: return
try {
setRingtoneOnSelected(uri)
} catch (e: Exception) {
showErrorToast(e)
}
}
}
return true
}
private fun fabClicked() {

View File

@ -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()
}
}
})

View File

@ -5,62 +5,85 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/group_contacts_wrapper"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/settings_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/group_contacts_placeholder"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/group_contacts_toolbar"
android:layout_width="match_parent"
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" />
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_group"
app:title=""
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/group_contacts_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/group_contacts_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/add_contacts"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
</com.google.android.material.appbar.AppBarLayout>
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/group_contacts_fastscroller"
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/group_contacts_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<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"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/group_contacts_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layoutAnimation="@anim/layout_animation"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
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" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/group_contacts_placeholder_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/group_contacts_placeholder"
android:layout_centerHorizontal="true"
android:background="@drawable/ripple_all_corners"
android:gravity="center"
android:padding="@dimen/activity_margin"
android:text="@string/add_contacts"
android:textSize="@dimen/bigger_text_size"
android:visibility="gone" />
<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_vector" />
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
android:id="@+id/group_contacts_fastscroller"
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:layoutAnimation="@anim/layout_animation"
android:scrollbars="none"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
</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_vector" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,70 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/insert_edit_contact_holder"
android:id="@+id/insert_edit_coordinator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/insert_edit_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/insert_edit_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:menu="@menu/menu_insert_or_edit"
app:title="@string/select_contact"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/new_contact_holder"
android:id="@+id/insert_edit_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"
android:visibility="gone">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<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_add_person_vector" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/new_contact_name"
<RelativeLayout
android:id="@+id/new_contact_holder"
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" />
android:background="?attr/selectableItemBackground"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/medium_margin"
android:visibility="gone">
<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_add_person_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"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/insert_or_edit_tabs_holder"
android:layout_below="@+id/select_contact_label" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/insert_or_edit_tabs_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:tabIndicator="@null"
app:tabMinWidth="150dp"
app:tabRippleColor="@null" />
</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"
android:visibility="gone" />
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/insert_or_edit_tabs_holder"
android:layout_below="@+id/select_contact_label" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/insert_or_edit_tabs_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:tabIndicator="@null"
app:tabMinWidth="150dp"
app:tabRippleColor="@null" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/assign_ringtone_to_group"
android:icon="@drawable/ic_bell_vector"
android:title="@string/ringtone"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item
android:id="@+id/send_sms_to_group"
android:icon="@drawable/ic_sms_vector"
android:title="@string/send_sms_to_group"
app:showAsAction="ifRoom"/>
app:showAsAction="always" />
<item
android:id="@+id/send_email_to_group"
android:icon="@drawable/ic_mail_vector"
android:title="@string/send_email_to_group"
app:showAsAction="ifRoom"/>
app:showAsAction="always" />
</menu>