mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-04-06 14:31:37 +02:00
replacing a new contact FAB with a top menu button
This commit is contained in:
parent
150e61b688
commit
e594ae5ec2
@ -61,6 +61,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:dea77e0130'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:ac7e52249a'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import com.simplemobiletools.dialer.R
|
|||||||
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
||||||
import com.simplemobiletools.dialer.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.dialer.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.dialer.extensions.config
|
import com.simplemobiletools.dialer.extensions.config
|
||||||
|
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
||||||
import com.simplemobiletools.dialer.fragments.FavoritesFragment
|
import com.simplemobiletools.dialer.fragments.FavoritesFragment
|
||||||
import com.simplemobiletools.dialer.fragments.MyViewPagerFragment
|
import com.simplemobiletools.dialer.fragments.MyViewPagerFragment
|
||||||
import com.simplemobiletools.dialer.helpers.OPEN_DIAL_PAD_AT_LAUNCH
|
import com.simplemobiletools.dialer.helpers.OPEN_DIAL_PAD_AT_LAUNCH
|
||||||
@ -122,6 +123,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.clear_call_history).isVisible = getCurrentFragment() == recents_fragment
|
findItem(R.id.clear_call_history).isVisible = getCurrentFragment() == recents_fragment
|
||||||
findItem(R.id.sort).isVisible = getCurrentFragment() != recents_fragment
|
findItem(R.id.sort).isVisible = getCurrentFragment() != recents_fragment
|
||||||
|
findItem(R.id.create_new_contact).isVisible = getCurrentFragment() == contacts_fragment
|
||||||
|
|
||||||
setupSearch(this)
|
setupSearch(this)
|
||||||
updateMenuItemColors(this)
|
updateMenuItemColors(this)
|
||||||
@ -132,9 +134,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.clear_call_history -> clearCallHistory()
|
R.id.clear_call_history -> clearCallHistory()
|
||||||
|
R.id.create_new_contact -> launchCreateNewContactIntent()
|
||||||
|
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
||||||
R.id.settings -> launchSettings()
|
R.id.settings -> launchSettings()
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -250,8 +253,9 @@ class MainActivity : SimpleActivity() {
|
|||||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
} else {
|
} else {
|
||||||
main_tabs_holder.setBackgroundColor(getProperBackgroundColor())
|
val bottomBarColor = config.backgroundColor.lightenColor(4)
|
||||||
updateNavigationBarColor(config.navigationBarColor)
|
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
||||||
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,14 @@ fun SimpleActivity.startCallIntent(recipient: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SimpleActivity.launchCreateNewContactIntent() {
|
||||||
|
Intent().apply {
|
||||||
|
action = Intent.ACTION_INSERT
|
||||||
|
data = ContactsContract.Contacts.CONTENT_URI
|
||||||
|
launchActivityIntent(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun BaseSimpleActivity.callContactWithSim(recipient: String, useMainSIM: Boolean) {
|
fun BaseSimpleActivity.callContactWithSim(recipient: String, useMainSIM: Boolean) {
|
||||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||||
val wantedSimIndex = if (useMainSIM) 0 else 1
|
val wantedSimIndex = if (useMainSIM) 0 else 1
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.simplemobiletools.dialer.fragments
|
package com.simplemobiletools.dialer.fragments
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.provider.ContactsContract
|
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
@ -15,6 +13,7 @@ import com.simplemobiletools.dialer.R
|
|||||||
import com.simplemobiletools.dialer.activities.MainActivity
|
import com.simplemobiletools.dialer.activities.MainActivity
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
||||||
import com.simplemobiletools.dialer.extensions.startContactDetailsIntent
|
import com.simplemobiletools.dialer.extensions.startContactDetailsIntent
|
||||||
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
||||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
||||||
@ -33,7 +32,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
fragment_placeholder.text = context.getString(placeholderResId)
|
fragment_placeholder.text = context.getString(placeholderResId)
|
||||||
|
|
||||||
val placeholderActionResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
val placeholderActionResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
R.string.create_new
|
R.string.create_new_contact
|
||||||
} else {
|
} else {
|
||||||
R.string.request_access
|
R.string.request_access
|
||||||
}
|
}
|
||||||
@ -43,16 +42,12 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
underlineText()
|
underlineText()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
launchCreateNewIntent()
|
activity?.launchCreateNewContactIntent()
|
||||||
} else {
|
} else {
|
||||||
requestReadContactsPermission()
|
requestReadContactsPermission()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_fab.setOnClickListener {
|
|
||||||
launchCreateNewIntent()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int) {
|
override fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int) {
|
||||||
@ -65,12 +60,6 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
||||||
letter_fastscroller_thumb.textColor = properPrimaryColor.getContrastColor()
|
letter_fastscroller_thumb.textColor = properPrimaryColor.getContrastColor()
|
||||||
letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList()
|
letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList()
|
||||||
|
|
||||||
fragment_fab.setColors(
|
|
||||||
textColor,
|
|
||||||
properPrimaryColor,
|
|
||||||
properPrimaryColor.getContrastColor()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshItems(callback: (() -> Unit)?) {
|
override fun refreshItems(callback: (() -> Unit)?) {
|
||||||
@ -159,11 +148,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
activity?.handlePermission(PERMISSION_READ_CONTACTS) {
|
activity?.handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
||||||
fragment_placeholder_2.text = context.getString(R.string.create_new)
|
fragment_placeholder_2.text = context.getString(R.string.create_new_contact)
|
||||||
fragment_placeholder_2.setOnClickListener {
|
|
||||||
launchCreateNewIntent()
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
gotContacts(contacts)
|
gotContacts(contacts)
|
||||||
@ -172,12 +157,4 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchCreateNewIntent() {
|
|
||||||
Intent().apply {
|
|
||||||
action = Intent.ACTION_INSERT
|
|
||||||
data = ContactsContract.Contacts.CONTENT_URI
|
|
||||||
context.launchActivityIntent(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder.text = context.getString(placeholderResId)
|
fragment_placeholder.text = context.getString(placeholderResId)
|
||||||
fragment_fab.beGone()
|
|
||||||
fragment_placeholder_2.beGone()
|
fragment_placeholder_2.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/fragment_placeholder"
|
android:layout_below="@+id/fragment_placeholder"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="@drawable/ripple_all_corners"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="@dimen/activity_margin"
|
android:padding="@dimen/activity_margin"
|
||||||
android:text="@string/create_new"
|
android:text="@string/create_new_contact"
|
||||||
android:textSize="@dimen/bigger_text_size"
|
android:textSize="@dimen/bigger_text_size"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
@ -62,16 +62,4 @@
|
|||||||
android:layout_toStartOf="@+id/letter_fastscroller" />
|
android:layout_toStartOf="@+id/letter_fastscroller" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyFloatingActionButton
|
|
||||||
android:id="@+id/fragment_fab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="@dimen/activity_margin"
|
|
||||||
android:src="@drawable/ic_plus_vector"
|
|
||||||
app:elevation="0dp" />
|
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
android:icon="@drawable/ic_sort_vector"
|
android:icon="@drawable/ic_sort_vector"
|
||||||
android:title="@string/sort_by"
|
android:title="@string/sort_by"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/create_new_contact"
|
||||||
|
android:title="@string/create_new_contact"
|
||||||
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/clear_call_history"
|
android:id="@+id/clear_call_history"
|
||||||
android:icon="@drawable/ic_delete_vector"
|
android:icon="@drawable/ic_delete_vector"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user