mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-03-18 12:10:16 +01:00
create a new activity for handling ACTION_INSERT_OR_EDIT intent
This commit is contained in:
parent
282594c125
commit
eb914ddfdf
@ -118,15 +118,6 @@
|
||||
android:name=".activities.EditContactActivity"
|
||||
android:parentActivityName=".activities.MainActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.INSERT_OR_EDIT"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.item/person"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/contact"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/raw_contact"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.EDIT"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
@ -163,6 +154,21 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.InsertOrEditContactActivity"
|
||||
android:label="@string/select_contact"
|
||||
android:parentActivityName=".activities.MainActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.INSERT_OR_EDIT"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<data android:mimeType="vnd.android.cursor.item/person"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/contact"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/raw_contact"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.simplemobiletools.commons.activities.AboutActivity"
|
||||
android:label="@string/about"
|
||||
|
@ -58,7 +58,7 @@ class EditContactActivity : ContactActivity() {
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
||||
|
||||
val action = intent.action
|
||||
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT
|
||||
isThirdPartyIntent = action == Intent.ACTION_EDIT || action == Intent.ACTION_INSERT
|
||||
val isFromSimpleContacts = intent.getBooleanExtra(IS_FROM_SIMPLE_CONTACTS, false)
|
||||
if (isThirdPartyIntent && !isFromSimpleContacts) {
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
@ -149,7 +149,7 @@ class EditContactActivity : ContactActivity() {
|
||||
setupEditContact()
|
||||
}
|
||||
|
||||
if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && (action == Intent.ACTION_INSERT_OR_EDIT || action == Intent.ACTION_INSERT)) {
|
||||
if (contact!!.id == 0 && intent.extras?.containsKey(KEY_PHONE) == true && action == Intent.ACTION_INSERT) {
|
||||
val phoneNumber = intent.extras.get(KEY_PHONE)?.toString() ?: ""
|
||||
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, ""))
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.contacts.R
|
||||
|
||||
class InsertOrEditContactActivity : ContactActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_insert_edit_contact)
|
||||
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
// we do not really care about the permission request result. Even if it was denied, load private contacts
|
||||
|
||||
}
|
||||
}
|
||||
}
|
8
app/src/main/res/layout/activity_insert_edit_contact.xml
Normal file
8
app/src/main/res/layout/activity_insert_edit_contact.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/insert_edit_contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user