set up the new Menu at Edit screen
This commit is contained in:
parent
61f17de7f4
commit
d7f4dcd656
2 changed files with 67 additions and 29 deletions
|
@ -12,9 +12,12 @@ import android.os.Bundle
|
||||||
import android.provider.ContactsContract.CommonDataKinds
|
import android.provider.ContactsContract.CommonDataKinds
|
||||||
import android.provider.ContactsContract.CommonDataKinds.*
|
import android.provider.ContactsContract.CommonDataKinds.*
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.view.*
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.WindowManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.RelativeLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
@ -69,6 +72,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
|
|
||||||
contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
contact_wrapper.background = ColorDrawable(config.backgroundColor)
|
contact_wrapper.background = ColorDrawable(config.backgroundColor)
|
||||||
|
setupMenu()
|
||||||
|
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT || action == ADD_NEW_CONTACT_NUMBER
|
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT || action == ADD_NEW_CONTACT_NUMBER
|
||||||
|
@ -99,33 +103,6 @@ class EditContactActivity : ContactActivity() {
|
||||||
window.statusBarColor = Color.TRANSPARENT
|
window.statusBarColor = Color.TRANSPARENT
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
|
||||||
menuInflater.inflate(R.menu.menu_edit_contact, menu)
|
|
||||||
if (wasActivityInitialized) {
|
|
||||||
menu.findItem(R.id.delete).isVisible = contact?.id != 0
|
|
||||||
menu.findItem(R.id.share).isVisible = contact?.id != 0
|
|
||||||
menu.findItem(R.id.open_with).isVisible = contact?.id != 0 && contact?.isPrivate() == false
|
|
||||||
}
|
|
||||||
|
|
||||||
updateMenuItemColors(menu, true)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
if (contact == null) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.save -> saveContact()
|
|
||||||
R.id.share -> shareContact(contact!!)
|
|
||||||
R.id.open_with -> openWith()
|
|
||||||
R.id.delete -> deleteContact()
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, resultData)
|
super.onActivityResult(requestCode, resultCode, resultData)
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
@ -267,7 +244,41 @@ class EditContactActivity : ContactActivity() {
|
||||||
numberViewToColor?.setTextColor(adjustedPrimaryColor)
|
numberViewToColor?.setTextColor(adjustedPrimaryColor)
|
||||||
emailViewToColor?.setTextColor(adjustedPrimaryColor)
|
emailViewToColor?.setTextColor(adjustedPrimaryColor)
|
||||||
wasActivityInitialized = true
|
wasActivityInitialized = true
|
||||||
invalidateOptionsMenu()
|
|
||||||
|
contact_toolbar.menu.apply {
|
||||||
|
findItem(R.id.delete).isVisible = contact?.id != 0
|
||||||
|
findItem(R.id.share).isVisible = contact?.id != 0
|
||||||
|
findItem(R.id.open_with).isVisible = contact?.id != 0 && contact?.isPrivate() == false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupMenu() {
|
||||||
|
(contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
|
contact_toolbar.menu.apply {
|
||||||
|
findItem(R.id.save).setOnMenuItemClickListener {
|
||||||
|
saveContact()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
findItem(R.id.share).setOnMenuItemClickListener {
|
||||||
|
shareContact(contact!!)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
findItem(R.id.open_with).setOnMenuItemClickListener {
|
||||||
|
openWith()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
findItem(R.id.delete).setOnMenuItemClickListener {
|
||||||
|
deleteContact()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contact_toolbar.setNavigationOnClickListener {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openWith() {
|
private fun openWith() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/contact_wrapper"
|
android:id="@+id/contact_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -542,4 +543,30 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/contact_photo_top_shadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/top_shadow_height"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="@drawable/gradient_background_flipped"
|
||||||
|
android:contentDescription="@null" />
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/contact_appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:elevation="0dp"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/contact_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:menu="@menu/menu_edit_contact"
|
||||||
|
app:navigationIcon="@drawable/ic_arrow_left_vector" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue