mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-04-03 04:51:15 +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 {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:dea77e0130'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:ac7e52249a'
|
||||
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.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
||||
import com.simplemobiletools.dialer.fragments.FavoritesFragment
|
||||
import com.simplemobiletools.dialer.fragments.MyViewPagerFragment
|
||||
import com.simplemobiletools.dialer.helpers.OPEN_DIAL_PAD_AT_LAUNCH
|
||||
@ -122,6 +123,7 @@ class MainActivity : SimpleActivity() {
|
||||
menu.apply {
|
||||
findItem(R.id.clear_call_history).isVisible = getCurrentFragment() == recents_fragment
|
||||
findItem(R.id.sort).isVisible = getCurrentFragment() != recents_fragment
|
||||
findItem(R.id.create_new_contact).isVisible = getCurrentFragment() == contacts_fragment
|
||||
|
||||
setupSearch(this)
|
||||
updateMenuItemColors(this)
|
||||
@ -132,9 +134,10 @@ class MainActivity : SimpleActivity() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
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.about -> launchAbout()
|
||||
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
@ -250,8 +253,9 @@ class MainActivity : SimpleActivity() {
|
||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
||||
updateNavigationBarColor(bottomBarColor)
|
||||
} else {
|
||||
main_tabs_holder.setBackgroundColor(getProperBackgroundColor())
|
||||
updateNavigationBarColor(config.navigationBarColor)
|
||||
val bottomBarColor = config.backgroundColor.lightenColor(4)
|
||||
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) {
|
||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||
val wantedSimIndex = if (useMainSIM) 0 else 1
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.simplemobiletools.dialer.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.ContactsContract
|
||||
import android.util.AttributeSet
|
||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||
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.SimpleActivity
|
||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent
|
||||
import com.simplemobiletools.dialer.extensions.startContactDetailsIntent
|
||||
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
||||
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)
|
||||
|
||||
val placeholderActionResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||
R.string.create_new
|
||||
R.string.create_new_contact
|
||||
} else {
|
||||
R.string.request_access
|
||||
}
|
||||
@ -43,16 +42,12 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||
underlineText()
|
||||
setOnClickListener {
|
||||
if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||
launchCreateNewIntent()
|
||||
activity?.launchCreateNewContactIntent()
|
||||
} else {
|
||||
requestReadContactsPermission()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment_fab.setOnClickListener {
|
||||
launchCreateNewIntent()
|
||||
}
|
||||
}
|
||||
|
||||
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.textColor = properPrimaryColor.getContrastColor()
|
||||
letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList()
|
||||
|
||||
fragment_fab.setColors(
|
||||
textColor,
|
||||
properPrimaryColor,
|
||||
properPrimaryColor.getContrastColor()
|
||||
)
|
||||
}
|
||||
|
||||
override fun refreshItems(callback: (() -> Unit)?) {
|
||||
@ -159,11 +148,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||
activity?.handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
if (it) {
|
||||
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
||||
fragment_placeholder_2.text = context.getString(R.string.create_new)
|
||||
fragment_placeholder_2.setOnClickListener {
|
||||
launchCreateNewIntent()
|
||||
}
|
||||
|
||||
fragment_placeholder_2.text = context.getString(R.string.create_new_contact)
|
||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
||||
activity?.runOnUiThread {
|
||||
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_fab.beGone()
|
||||
fragment_placeholder_2.beGone()
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/fragment_placeholder"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="@drawable/ripple_all_corners"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:text="@string/create_new"
|
||||
android:text="@string/create_new_contact"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
@ -62,16 +62,4 @@
|
||||
android:layout_toStartOf="@+id/letter_fastscroller" />
|
||||
|
||||
</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>
|
||||
|
@ -12,6 +12,10 @@
|
||||
android:icon="@drawable/ic_sort_vector"
|
||||
android:title="@string/sort_by"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/create_new_contact"
|
||||
android:title="@string/create_new_contact"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/clear_call_history"
|
||||
android:icon="@drawable/ic_delete_vector"
|
||||
|
Loading…
x
Reference in New Issue
Block a user