Merge commit 'dd2d8e27d8548893122c469bd1b68d5117fc5318' into manual_merge_dd2d8e2
Change-Id: I438cc9613c527bd0ca14caa8a08dbff6a7c0aa9d
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 12f6866..b087783 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,8 +16,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.contacts"
- android:versionCode="20002"
- android:versionName="2.0.2">
+ android:versionCode="20100"
+ android:versionName="2.1.0">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />
@@ -49,6 +49,8 @@
<uses-permission android:name="com.android.voicemail.permission.READ_VOICEMAIL" />
<!-- Following used for Contact metadata syncing -->
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+ <!-- Following used for getting the status of the contacts sync adapter -->
+ <uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
@@ -135,6 +137,13 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/person" />
<data android:mimeType="vnd.android.cursor.dir/contact" />
+ <data android:mimeType="vnd.android.cursor.item/group" />
+ </intent-filter>
+
+ <intent-filter>
+ <action android:name="android.intent.action.EDIT" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="vnd.android.cursor.item/group" />
</intent-filter>
<intent-filter>
@@ -266,23 +275,6 @@
</intent-filter>
</activity>
- <!-- Displays the members of a group in a list -->
- <activity android:name=".activities.GroupMembersActivity"
- android:theme="@style/GroupActivityTheme">
-
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.item/group" />
- </intent-filter>
-
- <intent-filter>
- <action android:name="android.intent.action.EDIT" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.item/group" />
- </intent-filter>
- </activity>
-
<activity
android:name=".quickcontact.QuickContactActivity"
android:theme="@style/Theme.QuickContact"
@@ -378,29 +370,6 @@
</intent-filter>
</activity>
- <!-- Edit or create a contact with all fields displayed. -->
- <activity
- android:name=".activities.ContactEditorActivity"
- android:theme="@style/EditorActivityTheme"
- android:windowSoftInputMode="stateHidden|adjustResize"
- android:exported="false">
-
- <intent-filter>
- <action android:name="com.android.contacts.action.FULL_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="com.android.contacts.action.FULL_INSERT" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.dir/person" />
- <data android:mimeType="vnd.android.cursor.dir/contact" />
- <data android:mimeType="vnd.android.cursor.dir/raw_contact" />
- </intent-filter>
- </activity>
-
<activity android:name=".common.test.FragmentTestActivity">
<intent-filter>
<category android:name="android.intent.category.TEST" />
diff --git a/proguard.flags b/proguard.flags
index d6e3755..1154abe 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -83,6 +83,7 @@
-keep class com.android.contacts.interactions.CallLogInteractionsLoader { *; }
-keep class com.android.contacts.interactions.ContactDeletionInteraction { *; }
-keep class com.android.contacts.interactions.ContactInteractionUtil { *; }
+-keep class com.android.contacts.util.SyncUtil { *; }
-keep class com.android.contacts.widget.CompositeListAdapter { *; }
-keep class com.google.common.base.Objects { *; }
-keep class com.google.common.base.Preconditions { *; }
diff --git a/res/color/tab_text_color.xml b/res/color/tab_text_color.xml
deleted file mode 100644
index 5ef1fe3..0000000
--- a/res/color/tab_text_color.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2014 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="@color/actionbar_text_color" android:state_selected="true"/>
- <item android:color="@color/actionbar_unselected_text_color" />
-</selector>
\ No newline at end of file
diff --git a/res/drawable-v21/view_pager_tab_background.xml b/res/drawable-v21/view_pager_tab_background.xml
deleted file mode 100644
index b9e0805..0000000
--- a/res/drawable-v21/view_pager_tab_background.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2016 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/tab_ripple_color">
- <item android:id="@android:id/mask">
- <color android:color="@android:color/white" />
- </item>
-</ripple>
diff --git a/res/drawable/unread_count_background.xml b/res/drawable/unread_count_background.xml
deleted file mode 100644
index f70f84a..0000000
--- a/res/drawable/unread_count_background.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<shape
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <corners android:radius="@dimen/tab_unread_count_background_radius"/>
- <solid android:color="@color/tab_unread_count_background_color" />
-</shape>
diff --git a/res/drawable/view_pager_tab_background.xml b/res/drawable/view_pager_tab_background.xml
deleted file mode 100644
index 9f59845..0000000
--- a/res/drawable/view_pager_tab_background.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2014 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:state_pressed="true"
- android:drawable="@color/tab_ripple_color"/>
-</selector>
\ No newline at end of file
diff --git a/res/layout-ldrtl/unread_count_tab.xml b/res/layout-ldrtl/unread_count_tab.xml
deleted file mode 100644
index b23ab57..0000000
--- a/res/layout-ldrtl/unread_count_tab.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- layoutDirection set to ltr as a workaround to a framework bug (b/22010411) causing view with
- layout_centerInParent inside a RelativeLayout to expand to screen width when RTL is active -->
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/view_pager_tab_background"
- android:layoutDirection="ltr">
- <!-- The tab icon -->
- <ImageView
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"/>
- <TextView
- android:id="@+id/count"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/tab_unread_count_background_size"
- android:layout_marginTop="@dimen/tab_unread_count_margin_top"
- android:layout_marginStart="@dimen/tab_unread_count_margin_left"
- android:layout_toStartOf="@id/icon"
- android:paddingLeft="@dimen/tab_unread_count_text_padding"
- android:paddingRight="@dimen/tab_unread_count_text_padding"
- android:background="@drawable/unread_count_background"
- android:fontFamily="sans-serif-medium"
- android:importantForAccessibility="no"
- android:minWidth="@dimen/tab_unread_count_background_size"
- android:textAlignment="center"
- android:textColor="@color/tab_accent_color"
- android:textSize="@dimen/tab_unread_count_text_size"
- android:layoutDirection="locale"/>
-</RelativeLayout>
-
diff --git a/res/layout-sw600dp-land/contact_editor_activity.xml b/res/layout-sw600dp-land/contact_editor_activity.xml
deleted file mode 100644
index 4eb2d0c..0000000
--- a/res/layout-sw600dp-land/contact_editor_activity.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- This should be kept in sync with layout-sw720dp/contact_editor_activity.xml -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:baselineAligned="false">
-
- <!-- Empty view to represent the left margin -->
- <View
- android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_space_layout_weight" />
-
- <fragment class="com.android.contacts.editor.ContactEditorFragment"
- android:id="@+id/contact_editor_fragment"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_card_layout_weight"
- android:layout_height="match_parent"/>
-
- <!-- Empty view to represent the right margin -->
- <View
- android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_space_layout_weight" />
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/res/layout-sw600dp/contact_editor_activity.xml b/res/layout-sw600dp/contact_editor_activity.xml
deleted file mode 100644
index 526fe2b..0000000
--- a/res/layout-sw600dp/contact_editor_activity.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true">
-
- <fragment class="com.android.contacts.editor.ContactEditorFragment"
- android:id="@+id/contact_editor_fragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
-</ScrollView>
diff --git a/res/layout-sw600dp/contact_editor_fragment.xml b/res/layout-sw600dp/contact_editor_fragment.xml
deleted file mode 100644
index be7723d..0000000
--- a/res/layout-sw600dp/contact_editor_fragment.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.android.contacts.widget.InterpolatingLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:ex="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/contact_all_list_background_color"
- android:elevation="@dimen/contact_list_card_elevation">
-
- <LinearLayout
- android:id="@+id/editors"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:fadingEdge="none"
- ex:layout_wideParentWidth="800dip"
- ex:layout_wideMarginLeft="128dip"
- ex:layout_wideMarginRight="128dip"
- ex:layout_narrowParentWidth="600dip"
- ex:layout_narrowMarginLeft="50dip"
- ex:layout_narrowMarginRight="50dip"/>
-
-</com.android.contacts.widget.InterpolatingLayout>
diff --git a/res/layout-sw720dp/contact_editor_activity.xml b/res/layout-sw720dp/contact_editor_activity.xml
deleted file mode 100644
index b31171f..0000000
--- a/res/layout-sw720dp/contact_editor_activity.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- This should be kept in sync with layout-sw600dp-land/contact_editor_activity.xml -->
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:baselineAligned="false">
-
- <!-- Empty view to represent the left margin -->
- <View
- android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_space_layout_weight" />
-
- <fragment class="com.android.contacts.editor.ContactEditorFragment"
- android:id="@+id/contact_editor_fragment"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_card_layout_weight"
- android:layout_height="match_parent"/>
-
- <!-- Empty view to represent the right margin -->
- <View
- android:layout_height="match_parent"
- android:layout_width="0dip"
- android:layout_weight="@integer/contact_list_space_layout_weight" />
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/res/layout/contact_editor_activity.xml b/res/layout/contact_editor_activity.xml
deleted file mode 100644
index 8c13629..0000000
--- a/res/layout/contact_editor_activity.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <fragment class="com.android.contacts.editor.ContactEditorFragment"
- android:id="@+id/contact_editor_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-</FrameLayout>
diff --git a/res/layout/contact_editor_fragment.xml b/res/layout/contact_editor_fragment.xml
deleted file mode 100644
index f174a3d..0000000
--- a/res/layout/contact_editor_fragment.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true"
- android:fadingEdge="none"
- android:background="@color/background_primary"
->
-
- <LinearLayout android:id="@+id/editors"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- />
-
-</ScrollView>
diff --git a/res/layout/contact_list_content.xml b/res/layout/contact_list_content.xml
index f18267d..8420b26 100644
--- a/res/layout/contact_list_content.xml
+++ b/res/layout/contact_list_content.xml
@@ -39,20 +39,29 @@
android:id="@+id/contact_list">
<include layout="@layout/contact_list_card"/>
- <view
- class="com.android.contacts.common.list.PinnedHeaderListView"
- android:id="@android:id/list"
+
+ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginLeft="?attr/contact_browser_list_padding_left"
- android:layout_marginRight="?attr/contact_browser_list_padding_right"
- android:layout_marginStart="?attr/contact_browser_list_padding_left"
- android:layout_marginEnd="?attr/contact_browser_list_padding_right"
- android:paddingTop="?attr/list_item_padding_top"
- android:clipToPadding="false"
- android:fastScrollEnabled="true"
- android:visibility="gone"
- android:fadingEdge="none" />
+ android:enabled="false" >
+
+ <view
+ class="com.android.contacts.common.list.PinnedHeaderListView"
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="?attr/contact_browser_list_padding_left"
+ android:layout_marginRight="?attr/contact_browser_list_padding_right"
+ android:layout_marginStart="?attr/contact_browser_list_padding_left"
+ android:layout_marginEnd="?attr/contact_browser_list_padding_right"
+ android:paddingTop="?attr/list_item_padding_top"
+ android:clipToPadding="false"
+ android:fastScrollEnabled="true"
+ android:visibility="gone"
+ android:fadingEdge="none" />
+ </android.support.v4.widget.SwipeRefreshLayout>
+
<ProgressBar
android:id="@+id/search_progress"
style="?android:attr/progressBarStyleLarge"
diff --git a/res/layout/nick_name_editor_view.xml b/res/layout/nick_name_editor_view.xml
deleted file mode 100644
index 3b91917..0000000
--- a/res/layout/nick_name_editor_view.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<com.android.contacts.editor.TextFieldsEditorView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="@dimen/editor_min_line_item_height"
- android:layout_marginStart="@dimen/editor_kind_icon_total_width"
- android:layout_marginEnd="@dimen/editor_delete_button_width">
-
- <!-- This isn't used in the nickname field. It is only included so that
- TextFieldsEditorView's base classes don't need extra null checks. -->
- <include
- android:id="@+id/spinner"
- layout="@layout/edit_spinner"
- android:visibility="gone" />
-
- <include
- android:id="@+id/editors"
- layout="@layout/edit_field_list" />
-
- <!-- This isn't used in the nickname field. It is only included so that
- TextFieldsEditorView doesn't need extra null checks. -->
- <include
- android:id="@+id/delete_button_container"
- layout="@layout/edit_delete_button"
- android:visibility="gone" />
-
-</com.android.contacts.editor.TextFieldsEditorView>
diff --git a/res/layout/people_activity.xml b/res/layout/people_activity.xml
index 9fd1a69..8810af0 100644
--- a/res/layout/people_activity.xml
+++ b/res/layout/people_activity.xml
@@ -20,37 +20,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/list_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <!--
- ViewPager for swiping between tabs. We put fragments at runtime.
-
- (Adding them directly as the children of this view is not recommended. ViewPager should
- be treated like a ListView, which doesn't expect children to be added from the layout.)
- -->
- <android.support.v4.view.ViewPager
- android:id="@+id/tab_pager"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:layout_below="@id/toolbar_parent"
- />
-
- <FrameLayout
- android:id="@+id/contacts_unavailable_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/toolbar_parent"
- android:visibility="gone">
- <FrameLayout
- android:id="@+id/contacts_unavailable_container"
- android:layout_height="match_parent"
- android:layout_width="match_parent" />
- </FrameLayout>
-
- </RelativeLayout>
+ <FrameLayout
+ android:id="@+id/contacts_list_container"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent" />
<include layout="@layout/floating_action_button" />
</android.support.design.widget.CoordinatorLayout>
diff --git a/res/layout/people_activity_tabs_lands.xml b/res/layout/people_activity_tabs_lands.xml
deleted file mode 100644
index 8d7b42b..0000000
--- a/res/layout/people_activity_tabs_lands.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.android.contacts.common.list.ViewPagerTabs
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/lists_pager_header"
- android:layout_width="@dimen/people_activity_landscape_tabs_width"
- android:layout_height="match_parent"
- android:textAllCaps="true"
- android:orientation="horizontal"
- android:layout_gravity="top"
- android:layout_weight="0"
- android:visibility="gone"
- android:textSize="@dimen/people_activity_landscape_tabs_text_size"
- style="@style/ContactsActionBarTabTextStyle" />
diff --git a/res/layout/people_activity_toolbar.xml b/res/layout/people_activity_toolbar.xml
index edca3ba..3599f0c 100644
--- a/res/layout/people_activity_toolbar.xml
+++ b/res/layout/people_activity_toolbar.xml
@@ -36,17 +36,4 @@
style="@style/ContactsToolbarStyle" />
</FrameLayout>
-
- <com.android.contacts.common.list.ViewPagerTabs
- android:id="@+id/lists_pager_header"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:textAllCaps="true"
- android:orientation="horizontal"
- android:layout_gravity="top"
- android:layout_weight="0"
- android:layout_below="@id/toolbar"
- android:visibility="gone"
- style="@style/ContactsActionBarTabTextStyle" />
-
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/raw_contact_editor_view.xml b/res/layout/raw_contact_editor_view.xml
deleted file mode 100644
index 004418d..0000000
--- a/res/layout/raw_contact_editor_view.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<com.android.contacts.editor.RawContactEditorView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/body"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <include
- layout="@layout/editor_account_header" />
-
- <LinearLayout
- android:id="@+id/collapsable_section"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <!-- Dummy view so the first input field is not initially focused. b/21644158 -->
- <View
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:focusable="true"
- android:focusableInTouchMode="true"/>
-
- <include
- android:id="@+id/edit_name"
- layout="@layout/structured_name_editor_view" />
-
- <include
- android:id="@+id/edit_phonetic_name"
- layout="@layout/phonetic_name_editor_view" />
-
- <include
- android:id="@+id/edit_nick_name"
- layout="@layout/nick_name_editor_view" />
-
- <include
- android:id="@+id/edit_photo"
- android:layout_marginRight="8dip"
- android:layout_marginEnd="8dip"
- layout="@layout/item_photo_editor" />
-
- <LinearLayout
- android:id="@+id/sect_fields"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_marginBottom="16dip"/>
-
- </LinearLayout>
-
- <View
- android:layout_width="match_parent"
- android:layout_height="@dimen/divider_line_height"
- android:background="@color/divider_line_color_light" />
-
-</com.android.contacts.editor.RawContactEditorView>
diff --git a/res/layout/unread_count_tab.xml b/res/layout/unread_count_tab.xml
deleted file mode 100644
index 783f1c1..0000000
--- a/res/layout/unread_count_tab.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/view_pager_tab_background">
- <!-- The tab icon -->
- <ImageView
- android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true" />
- <TextView
- android:id="@+id/count"
- android:background="@drawable/unread_count_background"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/tab_unread_count_background_size"
- android:gravity="center"
- android:minWidth="@dimen/tab_unread_count_background_size"
- android:layout_marginStart="@dimen/tab_unread_count_margin_left"
- android:layout_marginTop="@dimen/tab_unread_count_margin_top"
- android:layout_toEndOf="@id/icon"
- android:paddingLeft="@dimen/tab_unread_count_text_padding"
- android:paddingRight="@dimen/tab_unread_count_text_padding"
- android:textAlignment="center"
- android:textSize="@dimen/tab_unread_count_text_size"
- android:textColor="@color/tab_accent_color"
- android:fontFamily="sans-serif-medium"
- android:importantForAccessibility="no" />
-</RelativeLayout>
diff --git a/res/values-b+sr+Latn-sw600dp/strings.xml b/res/values-b+sr+Latn-sw600dp/strings.xml
new file mode 100644
index 0000000..f6727a7
--- /dev/null
+++ b/res/values-b+sr+Latn-sw600dp/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (C) 2012 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="account_phone" msgid="347665663520819575">"Uređaj"</string>
+ <string name="composer_has_no_exportable_contact" msgid="5998889616701036804">"Nema kontakata za izvoz. Ako imate kontakte na tabletu, neki dobavljači podataka možda neće dozvoliti izvoz kontakata sa tableta."</string>
+</resources>
diff --git a/res/values-b+sr+Latn/strings.xml b/res/values-b+sr+Latn/strings.xml
index 3078976..2f4c3fe 100644
--- a/res/values-b+sr+Latn/strings.xml
+++ b/res/values-b+sr+Latn/strings.xml
@@ -17,9 +17,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="applicationLabel" msgid="3906689777043645443">"Kontakti"</string>
- <string name="launcherActivityLabel" msgid="6497230399032392417">"Kontakti"</string>
- <string name="quickContactActivityLabel" msgid="7985456650689347268">"Prikaži kontakt"</string>
- <string name="editContactActivityLabel" msgid="1129944572070802839">"Izmeni kontakt"</string>
<string name="contactsList" msgid="8661624236494819731">"Kontakti"</string>
<string name="shortcutContact" msgid="749243779392912958">"Kontakt"</string>
<string name="shortcutDialContact" msgid="746622101599186779">"Direktno biranje"</string>
@@ -31,12 +28,7 @@
<string name="contactPickerActivityTitle" msgid="4301062192337417640">"Izaberite kontakt"</string>
<string name="groupMemberPickerActivityTitle" msgid="1431750793695262522">"Izaberite"</string>
<string name="header_entry_contact_list_adapter_header_title" msgid="2436981165830115659">"Napravi novi kontakt"</string>
- <string name="starredList" msgid="4817256136413959463">"Sa zvezdicom"</string>
- <string name="frequentList" msgid="7154768136473953056">"Česti"</string>
- <string name="strequentList" msgid="5640192862059373511">"Omiljeno"</string>
<string name="viewContactTitle" msgid="7989394521836644384">"Detalji o kontaktu"</string>
- <string name="editContactDescription" msgid="2947202828256214947">"Izmeni kontakt"</string>
- <string name="insertContactDescription" msgid="4709878105452681987">"Napravi kontakt"</string>
<string name="contactDetailAbout" msgid="5430408883907061400">"Osnovni podaci"</string>
<string name="contactDetailUpdates" msgid="3780588624763446941">"Ažuriranja"</string>
<string name="searchHint" msgid="8482945356247760701">"Pretraži kontakte"</string>
@@ -52,7 +44,7 @@
<string name="menu_call" msgid="3992595586042260618">"Pozovi kontakt"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Pošalji SMS kontaktu"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Razdvoji"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Izmeni"</string>
+ <string name="menu_editGroup" msgid="6696843438454341063">"Ukloni kontakte"</string>
<string name="menu_renameGroup" msgid="7169512355179757182">"Preimenuj oznaku"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Izbriši oznaku"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Dodaj kontakt"</string>
@@ -80,10 +72,15 @@
<item quantity="few">Kontakti su izbrisani</item>
<item quantity="other">Kontakti su izbrisani</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> kontakata</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> kontakt</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> kontakta</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> kontakata</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> kontakt · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> kontakta · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> kontakata · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"Sa Google-a"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"Sa <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -110,11 +107,13 @@
<string name="attach_photo_dialog_title" msgid="5599827035558557169">"Slika kontakta"</string>
<string name="customLabelPickerTitle" msgid="1081475101983255212">"Naziv prilagođene oznake"</string>
<string name="send_to_voicemail_checkbox" msgid="9001686764070676353">"Šalji pozive direktno u glasovnu poštu"</string>
- <string name="removePhoto" msgid="4898105274130284565">"Ukloni fotografiju"</string>
- <string name="noContacts" msgid="4955659076981974652">"Nema kontakata"</string>
+ <string name="removePhoto" msgid="4898105274130284565">"Ukloni sliku"</string>
+ <string name="noContacts" msgid="2228592924476426108">"Lista kontakata je prazna"</string>
<string name="noGroups" msgid="4607906327968232225">"Nema oznaka."</string>
<string name="noAccounts" msgid="7768267764545265909">"Morate da imate nalog da biste mogli da pravite grupe."</string>
<string name="emptyGroup" msgid="5102411903247859575">"Nema kontakata sa ovom oznakom"</string>
+ <string name="emptyAccount" msgid="6873962901497975964">"Nema kontakata na ovom nalogu"</string>
+ <string name="emptyMainList" msgid="2772242747899664460">"Lista kontakata je prazna"</string>
<string name="contactSavedToast" msgid="9171862279493213075">"Kontakt je sačuvan"</string>
<string name="contactUnlinkedToast" msgid="7122823195786012553">"Kontakti su razdvojeni"</string>
<string name="contactSavedErrorToast" msgid="3207250533172944892">"Nije moguće sačuvati izmene kontakata."</string>
@@ -131,6 +130,7 @@
<string name="groupMembersRemovedToast" msgid="3510563559799376603">"Uklonili smo iz oznake"</string>
<string name="groupMembersAddedToast" msgid="4824834898718972768">"Dodato je u oznaku"</string>
<string name="groupSavedErrorToast" msgid="8121032018490980184">"Čuvanje promena oznake nije uspelo."</string>
+ <string name="groupExistsErrorMessage" msgid="5196811283836946189">"Ta oznaka već postoji"</string>
<plurals name="listTotalPhoneContacts" formatted="false" msgid="3692277679143308755">
<item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt sa brojem telefona</item>
<item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta sa brojevima telefona</item>
@@ -153,7 +153,7 @@
<string name="callAgain" msgid="3197312117049874778">"Pozovi ponovo"</string>
<string name="returnCall" msgid="8171961914203617813">"Uzvrati poziv"</string>
<string name="add_contact_dlg_message_fmt" msgid="7986472669444326576">"Želite li da dodate imejl adresu „<xliff:g id="EMAIL">%s</xliff:g>“ u kontakte?"</string>
- <string name="description_contact_photo" msgid="3387458082667894062">"fotografija kontakta"</string>
+ <string name="description_contact_photo" msgid="3387458082667894062">"slika kontakta"</string>
<string name="description_plus_button" msgid="515164827856229880">"plus"</string>
<string name="exporting_contact_list_progress" msgid="560522409559101193">"<xliff:g id="CURRENT_NUMBER">%s</xliff:g> od <xliff:g id="TOTAL_NUMBER">%s</xliff:g> kontak(a)ta"</string>
<string name="search_settings_description" msgid="2675223022992445813">"Imena kontakata"</string>
@@ -184,8 +184,8 @@
<string name="google_account_type_format" msgid="5283997303922067997">"<xliff:g id="SOURCE">%1$s</xliff:g> nalog"</string>
<!-- no translation found for from_account_format (4469138575127580203) -->
<skip />
- <string name="take_photo" msgid="7496128293167402354">"Snimi fotografiju"</string>
- <string name="take_new_photo" msgid="7341354729436576304">"Napravi novu fotografiju"</string>
+ <string name="take_photo" msgid="7496128293167402354">"Slikaj"</string>
+ <string name="take_new_photo" msgid="7341354729436576304">"Slikaj novu sliku"</string>
<string name="pick_photo" msgid="2129509985223564942">"Izaberi sliku"</string>
<string name="pick_new_photo" msgid="9122450996263688237">"Izaberite novu sliku"</string>
<string name="upgrade_in_progress" msgid="474511436863451061">"Kontakt lista se ažurira."</string>
@@ -223,8 +223,7 @@
<string name="social_widget_loading" msgid="5327336597364074608">"Učitava se…"</string>
<string name="contacts_unavailable_create_contact" msgid="7014525713871959208">"Napravi novi kontakt"</string>
<string name="contacts_unavailable_add_account" msgid="4347232421410561500">"Dodajte nalog"</string>
- <string name="contacts_unavailable_import_contacts" msgid="4957393255392437529">"Uvezi kontakte"</string>
- <string name="create_group_dialog_title" msgid="5363404287877384473">"Napravite novu oznaku"</string>
+ <string name="contacts_unavailable_import_contacts" msgid="3182801738595937144">"Uvezi"</string>
<string name="create_group_item_label" msgid="3263064599743742865">"Napravi novu…"</string>
<string name="delete_group_dialog_message" msgid="335713829185261371">"Želite da izbrišete oznaku „<xliff:g id="GROUP_LABEL">%1$s</xliff:g>“? (Kontakti neće biti izbrisani.)"</string>
<string name="toast_join_with_empty_contact" msgid="1215465657839085613">"Unesite ime kontakta pre nego što ga objedinite sa drugim kontaktom."</string>
@@ -232,24 +231,23 @@
<string name="set_default" msgid="4417505153468300351">"Postavi na podrazumevano"</string>
<string name="clear_default" msgid="7193185801596678067">"Obriši podrazumevanu vrednost"</string>
<string name="toast_text_copied" msgid="5143776250008541719">"Tekst je kopiran"</string>
- <string name="cancel_confirmation_dialog_message" msgid="5058226498605989285">"Želite li da odbacite promene i prekinete sa izmenama?"</string>
+ <string name="cancel_confirmation_dialog_message" msgid="9008214737653278989">"Želite da odbacite promene?"</string>
<string name="cancel_confirmation_dialog_cancel_editing_button" msgid="3057023972074640671">"Odbaci"</string>
- <string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Nastavi izmene"</string>
+ <string name="cancel_confirmation_dialog_keep_editing_button" msgid="3316573928085916146">"Otkaži"</string>
+ <string name="leave_customize_confirmation_dialog_message" msgid="4277114551206032979">"Želite da odbacite prilagođavanja?"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Pretražite kontakte"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
- <skip />
+ <string name="title_edit_group" msgid="8602752287270586734">"Uklonite kontakte"</string>
<string name="local_profile_title" msgid="2021416826991393684">"Moj lokalni profil"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Moj <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g> profil"</string>
<string name="toast_displaying_all_contacts" msgid="2737388783898593875">"Prikazani su svi kontakti"</string>
<string name="generic_no_account_prompt" msgid="7218827704367325460">"Očuvajte bezbednost kontakata čak i ako izgubite telefon – sinhronizujte sa uslugom na mreži."</string>
<string name="generic_no_account_prompt_title" msgid="753783911899054860">"Dodavanje naloga"</string>
- <string name="contact_editor_prompt_zero_accounts" msgid="1785345895691886499">"Neće biti napravljena rezervna kopija novog kontakta. Želite li da dodate nalog koji pravi rezervnu kopiju kontakata onlajn?"</string>
+ <string name="contact_editor_prompt_zero_accounts" msgid="6648376557574360096">"Odvojte malo vremena da biste dodali nalog pomoću kog ćete napraviti rezervnu kopiju kontakata na Google-u."</string>
<string name="contact_editor_prompt_one_account" msgid="3087691056345099310">"Novi kontakti će biti sačuvani na nalogu <xliff:g id="ACCOUNT_NAME">%1$s</xliff:g>."</string>
<string name="contact_editor_prompt_multiple_accounts" msgid="8565761674283473549">"Izaberite podrazumevani nalog za nove kontakte:"</string>
<string name="contact_editor_title_new_contact" msgid="7192223018128934940">"Dodaj novi kontakt"</string>
<string name="contact_editor_title_existing_contact" msgid="4898475703683187798">"Izmeni kontakt"</string>
- <string name="keep_local" msgid="1258761699192993322">"Zadrži lokalno"</string>
<string name="add_account" msgid="8201790677994503186">"Dodaj nalog"</string>
<string name="add_new_account" msgid="5748627740680940264">"Dodaj novi nalog"</string>
<string name="menu_export_database" msgid="2659719297530170820">"Izvezi datoteke baze podataka"</string>
@@ -261,7 +259,6 @@
<string name="about_card_title" msgid="2920942314212825637">"Osnovni podaci"</string>
<string name="send_message" msgid="8938418965550543196">"Pošalji poruku"</string>
<string name="toast_making_personal_copy" msgid="288549957278065542">"Pravljenje lične kopije..."</string>
- <string name="yesterday" msgid="6840858548955018569">"Juče"</string>
<string name="tomorrow" msgid="6241969467795308581">"Sutra"</string>
<string name="today" msgid="8041090779381781781">"Danas"</string>
<string name="today_at_time_fmt" msgid="605665249491030460">"Danas u <xliff:g id="TIME_INTERVAL">%s</xliff:g>"</string>
@@ -346,4 +343,264 @@
<string name="permission_explanation_subheader_calendar_and_SMS" msgid="630115334220569184">"Događaji i poruke"</string>
<string name="permission_explanation_subheader_calendar" msgid="8785323496211704613">"Događaji"</string>
<string name="permission_explanation_subheader_SMS" msgid="1904552086449525567">"Poruke"</string>
+ <string name="hamburger_feature_highlight_header" msgid="7442308698936786415">"Organizujte listu"</string>
+ <string name="hamburger_feature_highlight_body" msgid="6268711111318172098">"Uklonite duplikate i grupišite kontakte prema oznaci"</string>
+ <string name="undo" msgid="1425165101664071422">"Opozovi"</string>
+ <string name="call_custom" msgid="6385303130912713318">"Pozovi <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_home" msgid="1990519474420545392">"Pozovi kućni telefon"</string>
+ <string name="call_mobile" msgid="7502236805487609178">"Pozovi mobilni telefon"</string>
+ <string name="call_work" msgid="5328785911463744028">"Pozovi poslovni telefon"</string>
+ <string name="call_fax_work" msgid="7467763592359059243">"Pozovi faks"</string>
+ <string name="call_fax_home" msgid="8342175628887571876">"Pozovi kućni faks"</string>
+ <string name="call_pager" msgid="9003902812293983281">"Pozovi pejdžer"</string>
+ <string name="call_other" msgid="8563753966926932052">"Pozovi"</string>
+ <string name="call_callback" msgid="1910165691349426858">"Pozovi za povratni poziv"</string>
+ <string name="call_car" msgid="3280537320306436445">"Pozovi telefon u automobilu"</string>
+ <string name="call_company_main" msgid="6105120947138711257">"Pozovi glavni telefon preduzeća"</string>
+ <string name="call_isdn" msgid="1541590690193403411">"Pozovi ISDN"</string>
+ <string name="call_main" msgid="6082900571803441339">"Pozovi glavni telefon"</string>
+ <string name="call_other_fax" msgid="5745314124619636674">"Pozovi faks"</string>
+ <string name="call_radio" msgid="8296755876398357063">"Pozovi mobilni telefon"</string>
+ <string name="call_telex" msgid="2223170774548648114">"Pozovi teleks"</string>
+ <string name="call_tty_tdd" msgid="8951266948204379604">"Pozovi TTY/TDD"</string>
+ <string name="call_work_mobile" msgid="8707874281430105394">"Pozovi poslovni mobilni telefon"</string>
+ <string name="call_work_pager" msgid="3419348514157949008">"Pozovi poslovni pejdžer"</string>
+ <string name="call_assistant" msgid="670941612175068337">"Pozovi <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_mms" msgid="6274041545876221437">"Pozovi MMS"</string>
+ <string name="call_by_shortcut" msgid="2566802538698913124">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (pozovi)"</string>
+ <string name="sms_custom" msgid="415060214233647603">"Pošalji SMS na <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="sms_home" msgid="7524332261493162995">"Pošalji SMS na kućni telefon"</string>
+ <string name="sms_mobile" msgid="5200107250451030769">"Pošalji SMS na mobilni telefon"</string>
+ <string name="sms_work" msgid="2269624156655267740">"Pošalji SMS na poslovni telefon"</string>
+ <string name="sms_fax_work" msgid="8028189067816907075">"Pošalji SMS na poslovni faks"</string>
+ <string name="sms_fax_home" msgid="9204042076306809634">"Pošalji SMS na kućni faks"</string>
+ <string name="sms_pager" msgid="7730404569637015192">"Pošalji SMS na pejdžer"</string>
+ <string name="sms_other" msgid="806127844607642331">"Tekst"</string>
+ <string name="sms_callback" msgid="5004824430094288752">"Pošalji SMS za povratni poziv"</string>
+ <string name="sms_car" msgid="7444227058437359641">"Pošalji SMS na telefon u automobilu"</string>
+ <string name="sms_company_main" msgid="118970873419678087">"Pošalji SMS na glavni broj telefona preduzeća"</string>
+ <string name="sms_isdn" msgid="8153785037515047845">"Pošalji SMS na ISDN"</string>
+ <string name="sms_main" msgid="8621625784504541679">"Pošalji SMS na glavni telefon"</string>
+ <string name="sms_other_fax" msgid="3888842199855843152">"Pošalji SMS na faks"</string>
+ <string name="sms_radio" msgid="3329166673433967820">"Pošalji SMS na mobilni telefon"</string>
+ <string name="sms_telex" msgid="9034802430065267848">"Pošalji SMS na teleks"</string>
+ <string name="sms_tty_tdd" msgid="6782284969132531532">"Pošalji SMS na TTY/TDD"</string>
+ <string name="sms_work_mobile" msgid="2459939960512702560">"Pošalji SMS na poslovni mobilni telefon"</string>
+ <string name="sms_work_pager" msgid="5566924423316960597">"Pošalji SMS na pejdžer"</string>
+ <string name="sms_assistant" msgid="2773424339923116234">"Pošalji SMS na <xliff:g id="ASSISTANT">%s</xliff:g>"</string>
+ <string name="sms_mms" msgid="4069352461380762677">"Pošalji SMS na MMS"</string>
+ <string name="sms_by_shortcut" msgid="7741770672976099517">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (pošalji SMS)"</string>
+ <string name="description_video_call" msgid="7120921378651700947">"Uputite video poziv"</string>
+ <string name="clearFrequentsConfirmation_title" msgid="766292372438450432">"Brisanje često kontaktiranih?"</string>
+ <string name="clearFrequentsConfirmation" msgid="2270554975938265734">"Obrisaćete listu često kontaktiranih u aplikacijama Kontakti i Telefon, pa će imejl aplikacije morati iz početka da prikupe informacije o adresiranju."</string>
+ <string name="clearFrequentsProgress_title" msgid="5157001637482794212">"Brisanje često kontaktiranih..."</string>
+ <string name="status_available" msgid="5586870015822828392">"Dostupan/na"</string>
+ <string name="status_away" msgid="1838861100379804730">"Odsutan/na"</string>
+ <string name="status_busy" msgid="9147992455450257136">"Zauzet/a"</string>
+ <string name="local_invisible_directory" msgid="6046691709127661065">"Drugi"</string>
+ <string name="directory_search_label" msgid="1887759056597975053">"Katalog"</string>
+ <string name="directory_search_label_work" msgid="8618292129829443176">"Katalog za Work"</string>
+ <string name="local_search_label" msgid="2551177578246113614">"Svi kontakti"</string>
+ <string name="foundTooManyContacts" msgid="5163335650920020220">"Pronađeno je više od <xliff:g id="COUNT">%d</xliff:g>."</string>
+ <string name="description_quick_contact_for" msgid="6737516415168327789">"Brzi kontakt za korisnika <xliff:g id="NAME">%1$s</xliff:g>"</string>
+ <string name="missing_name" msgid="8745511583852904385">"(Bez imena)"</string>
+ <string name="favoritesFrequentContacted" msgid="6184232487472425690">"Često kontaktirani"</string>
+ <string name="description_view_contact_detail" msgid="9133251213656414807">"Prikaži kontakt"</string>
+ <string name="list_filter_phones" msgid="735313795643493365">"Svi kontakti sa brojevima telefona"</string>
+ <string name="list_filter_phones_work" msgid="1470173699551475015">"Kontakti sa profila za Work"</string>
+ <string name="view_updates_from_group" msgid="1782685984905600034">"Prikaži ažuriranja"</string>
+ <string name="account_phone" msgid="7128032778471187553">"Uređaj"</string>
+ <string name="account_sim" msgid="6519016427905087952">"SIM"</string>
+ <string name="nameLabelsGroup" msgid="2034640839640477827">"Ime"</string>
+ <string name="nicknameLabelsGroup" msgid="2891682101053358010">"Nadimak"</string>
+ <string name="full_name" msgid="6602579550613988977">"Naziv"</string>
+ <string name="name_given" msgid="4280790853455320619">"Ime"</string>
+ <string name="name_family" msgid="7466985689626017037">"Prezime"</string>
+ <string name="name_prefix" msgid="59756378548779822">"Prefiks za ime"</string>
+ <string name="name_middle" msgid="8467433655992690326">"Srednje slovo"</string>
+ <string name="name_suffix" msgid="3855278445375651441">"Sufiks imena"</string>
+ <string name="name_phonetic" msgid="4259595234312430484">"Ime – fonetski"</string>
+ <string name="name_phonetic_given" msgid="8723179018384187631">"Ime – fonetski"</string>
+ <string name="name_phonetic_middle" msgid="8643721493320405200">"Srednje ime – fonetski"</string>
+ <string name="name_phonetic_family" msgid="2640133663656011626">"Prezime – fonetski"</string>
+ <string name="phoneLabelsGroup" msgid="6468091477851199285">"Telefon"</string>
+ <string name="emailLabelsGroup" msgid="8389931313045344406">"Pošalji imejlom"</string>
+ <string name="postalLabelsGroup" msgid="3487738141112589324">"Adresa"</string>
+ <string name="imLabelsGroup" msgid="3898238486262614027">"Razmena trenutnih poruka"</string>
+ <string name="organizationLabelsGroup" msgid="2478611760751832035">"Organizacija"</string>
+ <string name="relationLabelsGroup" msgid="1854373894284572781">"Odnos"</string>
+ <string name="eventLabelsGroup" msgid="7960408705307831289">"Poseban dan"</string>
+ <string name="sms" msgid="1756857139634224222">"Tekstualna poruka"</string>
+ <string name="postal_address" msgid="8765560217149624536">"Adresa"</string>
+ <string name="ghostData_company" msgid="5414421120553765775">"Preduzeće"</string>
+ <string name="ghostData_title" msgid="7496735200318496110">"Naslov"</string>
+ <string name="label_notes" msgid="8337354953278341042">"Beleške"</string>
+ <string name="label_custom_field" msgid="1994056912242214426">"Prilagođeno"</string>
+ <string name="label_sip_address" msgid="7252153678613978127">"SIP"</string>
+ <string name="websiteLabelsGroup" msgid="4202998982804009261">"Veb-sajt"</string>
+ <string name="groupsLabel" msgid="7000816729542098972">"Oznake"</string>
+ <string name="email_home" msgid="8573740658148184279">"Pošalji imejl na kućnu imejl adresu"</string>
+ <string name="email_mobile" msgid="2042889209787989814">"Pošalji imejl na broj mobilnog telefona"</string>
+ <string name="email_work" msgid="2807430017302722689">"Pošalji imejl na poslovni broj telefona"</string>
+ <string name="email_other" msgid="3454004077967657109">"Pošalji imejlom"</string>
+ <string name="email_custom" msgid="5536404237099078802">"Pošalji imejl na <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="email" msgid="5668400997660065897">"Pošalji imejlom"</string>
+ <string name="postal_street" msgid="8133143961580058972">"Ulica"</string>
+ <string name="postal_pobox" msgid="4431938829180269821">"Poštansko sanduče"</string>
+ <string name="postal_neighborhood" msgid="1450783874558956739">"Komšiluk"</string>
+ <string name="postal_city" msgid="6597491300084895548">"Grad"</string>
+ <string name="postal_region" msgid="6045263193478437672">"Država"</string>
+ <string name="postal_postcode" msgid="572136414136673751">"Poštanski broj"</string>
+ <string name="postal_country" msgid="7638264508416368690">"Zemlja"</string>
+ <string name="map_home" msgid="1243547733423343982">"Prikaži kućnu adresu"</string>
+ <string name="map_work" msgid="1360474076921878088">"Prikaži poslovnu adresu"</string>
+ <string name="map_other" msgid="3817820803587012641">"Prikaži adresu"</string>
+ <string name="map_custom" msgid="8761800628069473526">"Prikaži adresu <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="chat_aim" msgid="2588492205291249142">"Započni ćaskanje preko AIM-a"</string>
+ <string name="chat_msn" msgid="8041633440091073484">"Započni ćaskanje preko Windows Live-a"</string>
+ <string name="chat_yahoo" msgid="6629211142719943666">"Započni ćaskanje preko Yahoo-a"</string>
+ <string name="chat_skype" msgid="1210045020427480566">"Započni ćaskanje preko Skype-a"</string>
+ <string name="chat_qq" msgid="4294637812847719693">"Započni ćaskanje preko QQ-a"</string>
+ <string name="chat_gtalk" msgid="981575737258117697">"Ćaskaj preko Google Talk-a"</string>
+ <string name="chat_icq" msgid="8438405386153745775">"Započni ćaskanje preko ICQ-a"</string>
+ <string name="chat_jabber" msgid="7561444230307829609">"Započni ćaskanje preko Jabber-a"</string>
+ <string name="chat" msgid="9025361898797412245">"Ćaskanje"</string>
+ <string name="description_minus_button" msgid="6908099247930477551">"izbriši"</string>
+ <string name="expand_collapse_name_fields_description" msgid="8682630859539604311">"Proširivanje ili skupljanje polja za ime"</string>
+ <string name="expand_collapse_phonetic_name_fields_description" msgid="3306777588073354509">"Proširite ili skupite polja za fonetsko ime"</string>
+ <string name="list_filter_all_accounts" msgid="8908683398914322369">"Svi kontakti"</string>
+ <string name="list_filter_all_starred" msgid="5031734941601931356">"Sa zvezdicom"</string>
+ <string name="list_filter_customize" msgid="4789963356004169321">"Prilagodi"</string>
+ <string name="list_filter_single" msgid="5871400283515893087">"Kontakt"</string>
+ <string name="display_ungrouped" msgid="6885954210243119591">"Svi drugi kontakti"</string>
+ <string name="display_all_contacts" msgid="2031647544742889505">"Svi kontakti"</string>
+ <string name="menu_sync_remove" msgid="3266725887008450161">"Ukloni grupu za sinhronizaciju"</string>
+ <string name="dialog_sync_add" msgid="8267045393119375803">"Dodaj grupu za sinhronizaciju"</string>
+ <string name="display_more_groups" msgid="2682547080423434170">"Još grupa…"</string>
+ <string name="display_warn_remove_ungrouped" msgid="8872290721676651414">"Uklanjanjem grupe „<xliff:g id="GROUP">%s</xliff:g>“ sa liste za sinhronizaciju uklonićete i sve negrupisane kontakte sa te liste."</string>
+ <string name="savingDisplayGroups" msgid="2133152192716475939">"Čuvanje opcija prikaza je u toku..."</string>
+ <string name="menu_done" msgid="796017761764190697">"Gotovo"</string>
+ <string name="menu_doNotSave" msgid="58593876893538465">"Otkaži"</string>
+ <string name="listCustomView" msgid="1840624396582117590">"Prilagođeni prikaz"</string>
+ <string name="dialog_new_contact_account" msgid="4969619718062454756">"Sačuvajte uvezene kontakte na:"</string>
+ <string name="import_from_sim" msgid="3859272228033941659">"Uvezi sa SIM kartice"</string>
+ <string name="import_from_sim_summary" msgid="5815105584445743740">"Uvezi sa SIM kartice <xliff:g id="SIM_NAME">^1</xliff:g> – <xliff:g id="SIM_NUMBER">^2</xliff:g>"</string>
+ <string name="import_from_sim_summary_no_number" msgid="880612418352086012">"Uvezi sa SIM kartice <xliff:g id="SIM_NAME">%1$s</xliff:g>"</string>
+ <string name="import_from_vcf_file" product="default" msgid="5304572242183878086">"Uvezi iz .vcf datoteke"</string>
+ <string name="cancel_import_confirmation_message" msgid="3929951040347726757">"Želite li da otkažete uvoz datoteke <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_export_confirmation_message" msgid="1995462401949262638">"Želite li da otkažete izvoz datoteke <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_vcard_import_or_export_failed" msgid="6139900383366166706">"Nije moguće otkazati vCard uvoz/izvoz"</string>
+ <string name="fail_reason_unknown" msgid="1714092345030570863">"Nepoznata greška."</string>
+ <string name="fail_reason_could_not_open_file" msgid="2067725459821997463">"Nije moguće otvoriti datoteku „<xliff:g id="FILE_NAME">%s</xliff:g>“: <xliff:g id="EXACT_REASON">%s</xliff:g>"</string>
+ <string name="fail_reason_could_not_initialize_exporter" msgid="707260459259688510">"Nije moguće pokrenuti program za izvoz: „<xliff:g id="EXACT_REASON">%s</xliff:g>“"</string>
+ <string name="fail_reason_no_exportable_contact" msgid="8728506011371262065">"Nema kontakata za izvoz."</string>
+ <string name="missing_required_permission" msgid="5865884842972833120">"Onemogućili ste obaveznu dozvolu."</string>
+ <string name="fail_reason_error_occurred_during_export" msgid="3018855323913649063">"Došlo je do greške pri izvozu: „<xliff:g id="EXACT_REASON">%s</xliff:g>“"</string>
+ <string name="fail_reason_too_long_filename" msgid="3393764245254738333">"Zahtevani naziv datoteke je predugačak („<xliff:g id="FILENAME">%s</xliff:g>“)"</string>
+ <string name="fail_reason_io_error" msgid="6748358842976073255">"I/O greška"</string>
+ <string name="fail_reason_low_memory_during_import" msgid="875222757734882898">"Nema dovoljno memorije. Datoteka je možda prevelika."</string>
+ <string name="fail_reason_vcard_parse_error" msgid="888263542360355784">"Iz neočekivanog razloga nije bilo moguće raščlaniti vCard datoteku."</string>
+ <string name="fail_reason_not_supported" msgid="8219562769267148825">"Format nije podržan."</string>
+ <string name="fail_reason_failed_to_collect_vcard_meta_info" msgid="6427931733267328564">"Nije moguće prikupiti metapodatke datih vCard datoteka."</string>
+ <string name="fail_reason_failed_to_read_files" msgid="5823434810622484922">"Nije moguće uvesti jednu ili više datoteka (%s)."</string>
+ <string name="exporting_vcard_finished_title" msgid="4767045779458185251">"Izvoz datoteke <xliff:g id="FILENAME">%s</xliff:g> je završen."</string>
+ <string name="exporting_vcard_finished_title_fallback" msgid="6060472638008218274">"Izvoz kontakata je završen."</string>
+ <string name="exporting_vcard_finished_toast" msgid="1739055986856453882">"Izvoz kontakata je završen. Kliknite na obaveštenje da biste ih delili."</string>
+ <string name="touch_to_share_contacts" msgid="4882485525268469736">"Dodirnite da biste delili kontakte."</string>
+ <string name="exporting_vcard_canceled_title" msgid="2652222370493306887">"Izvoz datoteke <xliff:g id="FILENAME">%s</xliff:g> je otkazan"</string>
+ <string name="exporting_contact_list_title" msgid="9072240631534457415">"Izvoz podataka o kontaktima je u toku"</string>
+ <string name="exporting_contact_list_message" msgid="3367949209642931952">"Podaci o kontaktima se izvoze."</string>
+ <string name="composer_failed_to_get_database_infomation" msgid="1765944280846236723">"Nije moguće preuzeti informacije iz baze podataka"</string>
+ <string name="composer_has_no_exportable_contact" msgid="3296493229040294335">"Nema kontakata za izvoz. Ako imate kontakata na telefonu, neki dobavljači podataka možda neće dozvoliti da se kontakti izvoze sa telefona."</string>
+ <string name="composer_not_initialized" msgid="2321648986367005254">"Program za izradu vCard datoteka se nije ispravno pokrenuo."</string>
+ <string name="exporting_contact_failed_title" msgid="4892358112409576342">"Nije moguće izvesti"</string>
+ <string name="exporting_contact_failed_message" msgid="4938527850142003141">"Podaci o kontaktima nizu izvezeni.\nRazlog: „<xliff:g id="FAIL_REASON">%s</xliff:g>“"</string>
+ <string name="importing_vcard_description" msgid="4245275224298571351">"Uvoz <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="reading_vcard_failed_title" msgid="4251647443358422855">"Nije moguće čitati vCard podatke"</string>
+ <string name="reading_vcard_canceled_title" msgid="1925216585981542019">"Otkazano je čitanje podataka sa vCard datoteke"</string>
+ <string name="importing_vcard_finished_title" msgid="3341541727268747967">"Uvoz datoteke <xliff:g id="FILENAME">%s</xliff:g> je završen"</string>
+ <string name="importing_vcard_canceled_title" msgid="2147475978165599336">"Uvoz datoteke <xliff:g id="FILENAME">%s</xliff:g> je otkazan"</string>
+ <string name="vcard_import_will_start_message" msgid="2804911199145873396">"Datoteka <xliff:g id="FILENAME">%s</xliff:g> će uskoro biti uvezena."</string>
+ <string name="vcard_import_will_start_message_with_default_name" msgid="1022969530654129470">"Datoteka će uskoro biti uvezena."</string>
+ <string name="vcard_import_request_rejected_message" msgid="2890471184508516011">"Zahtev za izvoz vCard datoteke je odbijen. Pokušajte kasnije."</string>
+ <string name="vcard_export_will_start_message" msgid="2210241345252081463">"Datoteka <xliff:g id="FILENAME">%s</xliff:g> će uskoro biti izvezena."</string>
+ <string name="vcard_export_will_start_message_fallback" msgid="6553826997490909749">"Datoteka će uskoro biti izvezena."</string>
+ <string name="contacts_export_will_start_message" msgid="8538705791417534431">"Kontakti će uskoro biti izvezeni."</string>
+ <string name="vcard_export_request_rejected_message" msgid="2844874826431327531">"Zahtev za izvoz vCard datoteke je odbijen. Pokušajte kasnije."</string>
+ <string name="vcard_unknown_filename" msgid="7171709890959915954">"kontakt"</string>
+ <string name="caching_vcard_message" msgid="4926308675041506756">"Keširanje vCard datoteke u lokalnu privremenu memoriju. Uvoz će uskoro započeti."</string>
+ <string name="vcard_import_failed" msgid="5223531255894842406">"Nije moguće uvesti vCard datoteku."</string>
+ <string name="nfc_vcard_file_name" msgid="2823095213265993609">"Kontakt preko NFC-a"</string>
+ <string name="confirm_export_title" msgid="6834385377255286349">"Želite li da izvezete kontakte?"</string>
+ <string name="caching_vcard_title" msgid="1226272312940516605">"Keširanje..."</string>
+ <string name="progress_notifier_message" msgid="2311011466908220528">"Uvoz <xliff:g id="CURRENT_NUMBER">%s</xliff:g>/<xliff:g id="TOTAL_NUMBER">%s</xliff:g>: <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="export_to_vcf_file" product="default" msgid="4407527157056120858">"Izvezi u .vcf datoteku"</string>
+ <string name="display_options_sort_list_by" msgid="7028809117272018712">"Sortiraj prema"</string>
+ <string name="display_options_sort_by_given_name" msgid="2778421332815687873">"Ime"</string>
+ <string name="display_options_sort_by_family_name" msgid="2684905041926954793">"Prezime"</string>
+ <string name="display_options_view_names_as" msgid="6514632499276563482">"Format imena"</string>
+ <string name="display_options_view_given_name_first" msgid="3616004640258761473">"Prvo ime"</string>
+ <string name="display_options_view_family_name_first" msgid="956445100777296467">"Prvo prezime"</string>
+ <string name="settings_accounts" msgid="350219740670774576">"Nalozi"</string>
+ <string name="default_editor_account" msgid="699591683362420991">"Podrazumevani nalog za nove kontakte"</string>
+ <string name="sync_contact_metadata_title" msgid="6957956139306960211">"Sinhronizuj metapodatke kontakata [DOGFOOD]"</string>
+ <string name="sync_contact_metadata_dialog_title" msgid="6192335951588820553">"Sinhronizujte metapodatke kontakata"</string>
+ <string name="settings_my_info_title" msgid="1534272456405343119">"Moje informacije"</string>
+ <string name="set_up_profile" msgid="7370213843590143771">"Podesite profil"</string>
+ <string name="setting_about" msgid="7014388749752042863">"O Kontaktima"</string>
+ <string name="share_visible_contacts" msgid="890150378880783797">"Deli vidljive kontakte"</string>
+ <string name="share_visible_contacts_failure" msgid="7324717548166915560">"Deljenje vidljivih kontakata nije uspelo."</string>
+ <string name="share_favorite_contacts" msgid="4280926751003081042">"Deli omiljene kontakte"</string>
+ <string name="share_contacts" msgid="8109287987498711664">"Deli sve kontakte"</string>
+ <string name="share_contacts_failure" msgid="1216431977330560559">"Deljenje kontakata nije uspelo."</string>
+ <string name="dialog_import_export" msgid="4360648034889921624">"Uvoz/izvoz kontakata"</string>
+ <string name="dialog_import" msgid="2431698729761448759">"Uvoz kontakata"</string>
+ <string name="share_error" msgid="948429331673358107">"Ovaj kontakt ne može da se deli."</string>
+ <string name="no_contact_to_share" msgid="1276397530378323033">"Nema kontakata za deljenje."</string>
+ <string name="menu_search" msgid="9147752853603483719">"Pretraga"</string>
+ <string name="menu_contacts_filter" msgid="2165153460860262501">"Kontakti za prikaz"</string>
+ <string name="activity_title_contacts_filter" msgid="8275542497615516969">"Kontakti za prikaz"</string>
+ <string name="custom_list_filter" msgid="2105275443109077687">"Definišite prilagođeni prikaz"</string>
+ <string name="menu_custom_filter_save" msgid="2679793632208086460">"Sačuvaj"</string>
+ <string name="hint_findContacts" msgid="7128627979899070325">"Pretražite kontakte"</string>
+ <string name="contactsFavoritesLabel" msgid="8417039765586853670">"Omiljeno"</string>
+ <string name="listTotalAllContactsZero" msgid="5513001821794568211">"Nema kontakata."</string>
+ <string name="menu_clear_frequents" msgid="7688250191932838833">"Obriši često kontaktirane"</string>
+ <string name="menu_select_sim" msgid="3603578201960504010">"Izaberite SIM karticu"</string>
+ <string name="menu_accounts" msgid="1424330057450189074">"Upravljaj nalozima"</string>
+ <string name="menu_import_export" msgid="26217871113229507">"Uvoz/izvoz"</string>
+ <string name="menu_blocked_numbers" msgid="5272951629083025995">"Blokirani brojevi"</string>
+ <string name="contact_status_update_attribution" msgid="752179367353018597">"preko <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
+ <string name="contact_status_update_attribution_with_date" msgid="7358045508107825068">"<xliff:g id="DATE">%1$s</xliff:g> preko <xliff:g id="SOURCE">%2$s</xliff:g>"</string>
+ <string name="action_menu_back_from_search" msgid="8793348588949233348">"zaustavite pretraživanje"</string>
+ <string name="description_clear_search" msgid="688023606766232904">"Brisanje pretrage"</string>
+ <string name="settings_contact_display_options_title" msgid="4890258244494248687">"Opcije prikazivanja kontakata"</string>
+ <string name="select_account_dialog_title" msgid="5478489655696599219">"Nalog"</string>
+ <string name="set_default_account" msgid="4311613760725609801">"Uvek koristi ovo za pozive"</string>
+ <string name="select_phone_account_for_calls" msgid="3810607744451014540">"Pozovi pomoću"</string>
+ <string name="call_with_a_note" msgid="8389827628360791676">"Uputi poziv sa beleškom"</string>
+ <string name="call_subject_hint" msgid="3043028982108363572">"Unesite belešku koju ćete poslati uz poziv…"</string>
+ <string name="send_and_call_button" msgid="7740295432834590737">"POŠALJI I POZOVI"</string>
+ <string name="call_subject_limit" msgid="4545212901205397669">"<xliff:g id="COUNT">%1$s</xliff:g>/<xliff:g id="LIMIT">%2$s</xliff:g>"</string>
+ <string name="call_subject_type_and_number" msgid="7667188212129152558">"<xliff:g id="TYPE">%1$s</xliff:g> • <xliff:g id="NUMBER">%2$s</xliff:g>"</string>
+ <plurals name="tab_title_with_unread_items" formatted="false" msgid="7682024005130747825">
+ <item quantity="one"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitana stavka. </item>
+ <item quantity="few"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitane stavke. </item>
+ <item quantity="other"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitanih stavki. </item>
+ </plurals>
+ <string name="about_build_version" msgid="1765533099416999801">"Verzija"</string>
+ <string name="about_open_source_licenses" msgid="6479990452352919641">"Licence otvorenog koda"</string>
+ <string name="about_open_source_licenses_summary" msgid="57418386931763994">"Podaci o licenci za softver otvorenog koda"</string>
+ <string name="about_privacy_policy" msgid="3705518622499152626">"Politika privatnosti"</string>
+ <string name="about_terms_of_service" msgid="4642400812150296723">"Uslovi korišćenja usluge"</string>
+ <string name="activity_title_licenses" msgid="5467767062737708066">"Licence otvorenog koda"</string>
+ <string name="url_open_error_toast" msgid="452592089815420457">"Otvaranje URL-a nije uspelo."</string>
+ <string name="account_filter_view_checked" msgid="6696859503887762213">"Označeno: <xliff:g id="ACCOUNT_INFO">%s</xliff:g>"</string>
+ <string name="account_filter_view_not_checked" msgid="2248684521205038389">"Nije označeno: <xliff:g id="ACCOUNT_INFO">%s</xliff:g>"</string>
+ <string name="description_search_video_call" msgid="5841525580339803272">"Uputite video poziv"</string>
+ <string name="description_delete_contact" msgid="53835657343783663">"Izbrišite"</string>
+ <string name="description_no_name_header" msgid="8884991311595943271">"Tri tačke"</string>
+ <string name="callDurationSecondFormat" msgid="7067644915903528776">"<xliff:g id="SECONDS">%s</xliff:g> sek"</string>
+ <string name="callDurationMinuteFormat" msgid="4647095486747447674">"<xliff:g id="MINUTES">%s</xliff:g> min <xliff:g id="SECONDS">%s</xliff:g> sek"</string>
+ <string name="callDurationHourFormat" msgid="7392254193808506640">"<xliff:g id="MINUTES_0">%s</xliff:g> s <xliff:g id="MINUTES_1">%s</xliff:g> min <xliff:g id="SECONDS">%s</xliff:g> sek"</string>
</resources>
diff --git a/res/values-be-rBY-sw600dp/strings.xml b/res/values-be-rBY-sw600dp/strings.xml
new file mode 100644
index 0000000..8e0b10f
--- /dev/null
+++ b/res/values-be-rBY-sw600dp/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (C) 2012 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="account_phone" msgid="347665663520819575">"Прылада"</string>
+ <string name="composer_has_no_exportable_contact" msgid="5998889616701036804">"Няма кантактаў, якія можна экспартаваць. Калі ў вас ёсць кантакты на планшэце, некаторыя пастаўшчыкі даных могуць не дазваляць экспарт кантактаў з планшэта."</string>
+</resources>
diff --git a/res/values-be-rBY/strings.xml b/res/values-be-rBY/strings.xml
index 2eee399..ab999d1 100644
--- a/res/values-be-rBY/strings.xml
+++ b/res/values-be-rBY/strings.xml
@@ -17,9 +17,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="applicationLabel" msgid="3906689777043645443">"Кантакты"</string>
- <string name="launcherActivityLabel" msgid="6497230399032392417">"Кантакты"</string>
- <string name="quickContactActivityLabel" msgid="7985456650689347268">"Прагледзець кантакт"</string>
- <string name="editContactActivityLabel" msgid="1129944572070802839">"Рэдагаваць кантакт"</string>
<string name="contactsList" msgid="8661624236494819731">"Кантакты"</string>
<string name="shortcutContact" msgid="749243779392912958">"Кантакт"</string>
<string name="shortcutDialContact" msgid="746622101599186779">"Хуткі выклік"</string>
@@ -31,12 +28,7 @@
<string name="contactPickerActivityTitle" msgid="4301062192337417640">"Выберыце кантакт"</string>
<string name="groupMemberPickerActivityTitle" msgid="1431750793695262522">"Выбраць"</string>
<string name="header_entry_contact_list_adapter_header_title" msgid="2436981165830115659">"Стварыць новы кантакт"</string>
- <string name="starredList" msgid="4817256136413959463">"Пазначана"</string>
- <string name="frequentList" msgid="7154768136473953056">"Частыя"</string>
- <string name="strequentList" msgid="5640192862059373511">"Любімыя"</string>
<string name="viewContactTitle" msgid="7989394521836644384">"Дадзеныя кантакта"</string>
- <string name="editContactDescription" msgid="2947202828256214947">"Рэдагаваць кантакт"</string>
- <string name="insertContactDescription" msgid="4709878105452681987">"Стварыць кантакт"</string>
<string name="contactDetailAbout" msgid="5430408883907061400">"Інфармацыя"</string>
<string name="contactDetailUpdates" msgid="3780588624763446941">"Абнаўленні"</string>
<string name="searchHint" msgid="8482945356247760701">"Пошук кантактаў"</string>
@@ -52,7 +44,7 @@
<string name="menu_call" msgid="3992595586042260618">"Выклікаць кантакт"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Паведамленне кантакту"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Выдаліць сувязь"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Рэдагаваць"</string>
+ <string name="menu_editGroup" msgid="6696843438454341063">"Выдаліць кантакты"</string>
<string name="menu_renameGroup" msgid="7169512355179757182">"Перайменаваць метку"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Выдаліць метку"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Дадаць кантакт"</string>
@@ -81,11 +73,17 @@
<item quantity="many">Кантакты выдалены</item>
<item quantity="other">Кантакты выдалены</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> кантакт</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> кантакты</item>
- <item quantity="many"><xliff:g id="COUNT">%d</xliff:g> кантактаў</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> кантакту</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> кантакт</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> кантакты</item>
+ <item quantity="many"><xliff:g id="COUNT_1">%d</xliff:g> кантактаў</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> кантакту</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> кантакт · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> кантакты · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="many"><xliff:g id="COUNT_2">%d</xliff:g> кантактаў · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> кантакту · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"З Google"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"З <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -113,10 +111,12 @@
<string name="customLabelPickerTitle" msgid="1081475101983255212">"Імя карыстальніцкага цэтліка"</string>
<string name="send_to_voicemail_checkbox" msgid="9001686764070676353">"Адпраўляць выклікі непасрэдна на галасавую пошту"</string>
<string name="removePhoto" msgid="4898105274130284565">"Выдаліць фота"</string>
- <string name="noContacts" msgid="4955659076981974652">"Няма кантактаў"</string>
+ <string name="noContacts" msgid="2228592924476426108">"Ваш спіс кантактаў пусты"</string>
<string name="noGroups" msgid="4607906327968232225">"Метак няма."</string>
<string name="noAccounts" msgid="7768267764545265909">"Для стварэння групы патрабуецца ўліковы запіс."</string>
<string name="emptyGroup" msgid="5102411903247859575">"Няма кантактаў з гэтай меткай"</string>
+ <string name="emptyAccount" msgid="6873962901497975964">"Няма кантактаў у гэтым уліковым запісе"</string>
+ <string name="emptyMainList" msgid="2772242747899664460">"Ваш спіс кантактаў пусты"</string>
<string name="contactSavedToast" msgid="9171862279493213075">"Кантакт захаваны"</string>
<string name="contactUnlinkedToast" msgid="7122823195786012553">"Кантакты адлучаны"</string>
<string name="contactSavedErrorToast" msgid="3207250533172944892">"Немагчыма захаваць змены кантакта."</string>
@@ -133,6 +133,7 @@
<string name="groupMembersRemovedToast" msgid="3510563559799376603">"Выдалена з меткі"</string>
<string name="groupMembersAddedToast" msgid="4824834898718972768">"Дададзена да этыкеткі"</string>
<string name="groupSavedErrorToast" msgid="8121032018490980184">"Не ўдалося захаваць змяненні меткі."</string>
+ <string name="groupExistsErrorMessage" msgid="5196811283836946189">"Гэта пазнака ўжо існуе"</string>
<plurals name="listTotalPhoneContacts" formatted="false" msgid="3692277679143308755">
<item quantity="one"><xliff:g id="COUNT">%d</xliff:g> кантакт з нумарам(і) тэлефона(ў)</item>
<item quantity="few"><xliff:g id="COUNT">%d</xliff:g> кантакты з нумарамі тэлефонаў</item>
@@ -229,8 +230,7 @@
<string name="social_widget_loading" msgid="5327336597364074608">"Загрузка..."</string>
<string name="contacts_unavailable_create_contact" msgid="7014525713871959208">"Стварыць новы кантакт"</string>
<string name="contacts_unavailable_add_account" msgid="4347232421410561500">"Дадаць уліковы запіс"</string>
- <string name="contacts_unavailable_import_contacts" msgid="4957393255392437529">"Імпартаваць кантакты"</string>
- <string name="create_group_dialog_title" msgid="5363404287877384473">"Стварыць новую метку"</string>
+ <string name="contacts_unavailable_import_contacts" msgid="3182801738595937144">"Імпартаваць"</string>
<string name="create_group_item_label" msgid="3263064599743742865">"Стварыць новую..."</string>
<string name="delete_group_dialog_message" msgid="335713829185261371">"Выдаліць метку \"<xliff:g id="GROUP_LABEL">%1$s</xliff:g>\"? (Самі кантакты не будуць выдалены.)"</string>
<string name="toast_join_with_empty_contact" msgid="1215465657839085613">"Перад звязваннем кантакту з іншым увядзіце імя кантакту."</string>
@@ -238,24 +238,23 @@
<string name="set_default" msgid="4417505153468300351">"Усталяваць па змаўчанні"</string>
<string name="clear_default" msgid="7193185801596678067">"Скінуць налады па змаўчанні"</string>
<string name="toast_text_copied" msgid="5143776250008541719">"Тэкст скапіяваны"</string>
- <string name="cancel_confirmation_dialog_message" msgid="5058226498605989285">"Адхіліць змены і скончыць рэдагаванне?"</string>
+ <string name="cancel_confirmation_dialog_message" msgid="9008214737653278989">"Скасаваць змены?"</string>
<string name="cancel_confirmation_dialog_cancel_editing_button" msgid="3057023972074640671">"Адхіліць"</string>
- <string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Працягнуць рэдагаванне"</string>
+ <string name="cancel_confirmation_dialog_keep_editing_button" msgid="3316573928085916146">"Скасаваць"</string>
+ <string name="leave_customize_confirmation_dialog_message" msgid="4277114551206032979">"Скасаваць дапасаванні?"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Пошук кантактаў"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
- <skip />
+ <string name="title_edit_group" msgid="8602752287270586734">"Выдаліць кантакты"</string>
<string name="local_profile_title" msgid="2021416826991393684">"Мой лакальны профіль"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Мой профіль у <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g>"</string>
<string name="toast_displaying_all_contacts" msgid="2737388783898593875">"Адлюстраванне ўсіх кантактаў"</string>
<string name="generic_no_account_prompt" msgid="7218827704367325460">"Абаранiце свае кантакты, нават калі страціце тэлефон: сінхранізуйце iх з вэб-службай."</string>
<string name="generic_no_account_prompt_title" msgid="753783911899054860">"Дадаць уліковы запіс"</string>
- <string name="contact_editor_prompt_zero_accounts" msgid="1785345895691886499">"Рэзервовая копiя вашага новага кантакту не будзе створана. Дадаць улiковы запiс, у якiм будуць захоўвацца рэзервовыя копii кантактаў у Iнтэрнэце?"</string>
+ <string name="contact_editor_prompt_zero_accounts" msgid="6648376557574360096">"Знайдзіце хвілінку, каб дадаць уліковы запіс, які дазволіць стварыць рэзервовую копію вашых кантактаў у Google."</string>
<string name="contact_editor_prompt_one_account" msgid="3087691056345099310">"Новыя кантакты будуць захаваны ва ўліковы запіс <xliff:g id="ACCOUNT_NAME">%1$s</xliff:g>."</string>
<string name="contact_editor_prompt_multiple_accounts" msgid="8565761674283473549">"Выбраць уліковы запіс па змаўчанні для новых кантактаў:"</string>
<string name="contact_editor_title_new_contact" msgid="7192223018128934940">"Дадаць новы кантакт"</string>
<string name="contact_editor_title_existing_contact" msgid="4898475703683187798">"Рэдагаваць кантакт"</string>
- <string name="keep_local" msgid="1258761699192993322">"Захоўваць лакальна"</string>
<string name="add_account" msgid="8201790677994503186">"Дадаць уліковы запіс"</string>
<string name="add_new_account" msgid="5748627740680940264">"Дадаць новы ўліковы запіс"</string>
<string name="menu_export_database" msgid="2659719297530170820">"Экспарт базы дадзеных файлаў"</string>
@@ -267,7 +266,6 @@
<string name="about_card_title" msgid="2920942314212825637">"Інфармацыя"</string>
<string name="send_message" msgid="8938418965550543196">"Адправiць паведамленне"</string>
<string name="toast_making_personal_copy" msgid="288549957278065542">"Стварэнне асабістай копіі..."</string>
- <string name="yesterday" msgid="6840858548955018569">"Учора"</string>
<string name="tomorrow" msgid="6241969467795308581">"Заўтра"</string>
<string name="today" msgid="8041090779381781781">"Сёння"</string>
<string name="today_at_time_fmt" msgid="605665249491030460">"Сёння ў перыяд <xliff:g id="TIME_INTERVAL">%s</xliff:g>"</string>
@@ -356,4 +354,265 @@
<string name="permission_explanation_subheader_calendar_and_SMS" msgid="630115334220569184">"Падзеі і паведамленні"</string>
<string name="permission_explanation_subheader_calendar" msgid="8785323496211704613">"Падзеі"</string>
<string name="permission_explanation_subheader_SMS" msgid="1904552086449525567">"Паведамленні"</string>
+ <string name="hamburger_feature_highlight_header" msgid="7442308698936786415">"Арганізуйце свой спіс"</string>
+ <string name="hamburger_feature_highlight_body" msgid="6268711111318172098">"Выдаліце дублікаты і згрупуйце кантакты па метках"</string>
+ <string name="undo" msgid="1425165101664071422">"Адрабіць"</string>
+ <string name="call_custom" msgid="6385303130912713318">"Выклікаць <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_home" msgid="1990519474420545392">"Патэлефанаваць на хатні нумар"</string>
+ <string name="call_mobile" msgid="7502236805487609178">"Набраць нумар мабільнага тэлефону"</string>
+ <string name="call_work" msgid="5328785911463744028">"Выклікаць працоўны нумар тэлефона"</string>
+ <string name="call_fax_work" msgid="7467763592359059243">"Набраць нумар працоўнага факса"</string>
+ <string name="call_fax_home" msgid="8342175628887571876">"Патэлефанаваць на хатні факс"</string>
+ <string name="call_pager" msgid="9003902812293983281">"Выклікаць пэйджар"</string>
+ <string name="call_other" msgid="8563753966926932052">"Выклікаць"</string>
+ <string name="call_callback" msgid="1910165691349426858">"Зрабіць зваротны выклік"</string>
+ <string name="call_car" msgid="3280537320306436445">"Выклікаць нумар у машыне"</string>
+ <string name="call_company_main" msgid="6105120947138711257">"Выклікаць асноўны нумар кампаніі"</string>
+ <string name="call_isdn" msgid="1541590690193403411">"Выклік ISDN"</string>
+ <string name="call_main" msgid="6082900571803441339">"Выклікаць асноўны нумар"</string>
+ <string name="call_other_fax" msgid="5745314124619636674">"Выклік факса"</string>
+ <string name="call_radio" msgid="8296755876398357063">"Патэлефанаваць на радыётэлефон"</string>
+ <string name="call_telex" msgid="2223170774548648114">"Выклік на тэлекс"</string>
+ <string name="call_tty_tdd" msgid="8951266948204379604">"Выклікаць TTY/TDD"</string>
+ <string name="call_work_mobile" msgid="8707874281430105394">"Патэлефанаваць на працоўны мабільны"</string>
+ <string name="call_work_pager" msgid="3419348514157949008">"Выклікаць працоўны пэйджар"</string>
+ <string name="call_assistant" msgid="670941612175068337">"Выклікаць <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_mms" msgid="6274041545876221437">"Выклік MMS"</string>
+ <string name="call_by_shortcut" msgid="2566802538698913124">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (Выклікаць)"</string>
+ <string name="sms_custom" msgid="415060214233647603">"Адправіць SMS на <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="sms_home" msgid="7524332261493162995">"Тэкставае паведамленне на хатні тэлефон"</string>
+ <string name="sms_mobile" msgid="5200107250451030769">"Тэкставае паведамленне на мабільны тэлефон"</string>
+ <string name="sms_work" msgid="2269624156655267740">"Тэкставае паведамленне на працоўны тэлефон"</string>
+ <string name="sms_fax_work" msgid="8028189067816907075">"Тэкставае паведамленне на працоўны факс"</string>
+ <string name="sms_fax_home" msgid="9204042076306809634">"Тэкставае паведамленне на хатні факс"</string>
+ <string name="sms_pager" msgid="7730404569637015192">"Тэкставае паведамленне на пэйджар"</string>
+ <string name="sms_other" msgid="806127844607642331">"Тэкст"</string>
+ <string name="sms_callback" msgid="5004824430094288752">"Тэкст на нумар зваротнага выкліку"</string>
+ <string name="sms_car" msgid="7444227058437359641">"Тэкставае паведамленне ў аўтамабіль"</string>
+ <string name="sms_company_main" msgid="118970873419678087">"Паведамленне на асноўны нумар кампаніі"</string>
+ <string name="sms_isdn" msgid="8153785037515047845">"Тэкст ISDN"</string>
+ <string name="sms_main" msgid="8621625784504541679">"Паведамленне на асноўны нумар"</string>
+ <string name="sms_other_fax" msgid="3888842199855843152">"Тэкставае паведамленне на факс"</string>
+ <string name="sms_radio" msgid="3329166673433967820">"Тэкставае паведамленее на радыётэлефон"</string>
+ <string name="sms_telex" msgid="9034802430065267848">"Тэкставае паведамленне на тэлекс"</string>
+ <string name="sms_tty_tdd" msgid="6782284969132531532">"Тэкставае паведамленне на TTY/TDD"</string>
+ <string name="sms_work_mobile" msgid="2459939960512702560">"Тэкставае паведамленне на працоўны мабільны тэлефон"</string>
+ <string name="sms_work_pager" msgid="5566924423316960597">"Тэкставае паведамленне на працоўны пэйджар"</string>
+ <string name="sms_assistant" msgid="2773424339923116234">"Напiсаць тэкставае паведамленне: <xliff:g id="ASSISTANT">%s</xliff:g>"</string>
+ <string name="sms_mms" msgid="4069352461380762677">"Паведамленне MMS"</string>
+ <string name="sms_by_shortcut" msgid="7741770672976099517">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (Паведамленне)"</string>
+ <string name="description_video_call" msgid="7120921378651700947">"Зрабіць відэавыклік"</string>
+ <string name="clearFrequentsConfirmation_title" msgid="766292372438450432">"Выдалiць частыя кантакты?"</string>
+ <string name="clearFrequentsConfirmation" msgid="2270554975938265734">"Спіс найчасцей ужываных кантактаў праграм \"Кантакты\" i \"Тэлефон\" ачысціцца, а параметры адрасацыі паштовых праграм абнуляцца."</string>
+ <string name="clearFrequentsProgress_title" msgid="5157001637482794212">"Выдаленне частых кантактаў..."</string>
+ <string name="status_available" msgid="5586870015822828392">"Даступны"</string>
+ <string name="status_away" msgid="1838861100379804730">"Адсутнічае"</string>
+ <string name="status_busy" msgid="9147992455450257136">"Заняты"</string>
+ <string name="local_invisible_directory" msgid="6046691709127661065">"Іншае"</string>
+ <string name="directory_search_label" msgid="1887759056597975053">"Дырэкторыя"</string>
+ <string name="directory_search_label_work" msgid="8618292129829443176">"Працоўны каталог"</string>
+ <string name="local_search_label" msgid="2551177578246113614">"Усе кантакты"</string>
+ <string name="foundTooManyContacts" msgid="5163335650920020220">"Знойдзена вынікаў: больш за <xliff:g id="COUNT">%d</xliff:g>."</string>
+ <string name="description_quick_contact_for" msgid="6737516415168327789">"Хуткі кантакт для карыстальніка <xliff:g id="NAME">%1$s</xliff:g>"</string>
+ <string name="missing_name" msgid="8745511583852904385">"(Без назвы)"</string>
+ <string name="favoritesFrequentContacted" msgid="6184232487472425690">"Частая сувязь"</string>
+ <string name="description_view_contact_detail" msgid="9133251213656414807">"Прагледзець кантакт"</string>
+ <string name="list_filter_phones" msgid="735313795643493365">"Усе кантакты з нумарамі тэлефонаў"</string>
+ <string name="list_filter_phones_work" msgid="1470173699551475015">"Кантакты працоўнага профілю"</string>
+ <string name="view_updates_from_group" msgid="1782685984905600034">"Прагл. абнаўленняў"</string>
+ <string name="account_phone" msgid="7128032778471187553">"Прылада"</string>
+ <string name="account_sim" msgid="6519016427905087952">"SIM"</string>
+ <string name="nameLabelsGroup" msgid="2034640839640477827">"Імя"</string>
+ <string name="nicknameLabelsGroup" msgid="2891682101053358010">"Псеўданiм"</string>
+ <string name="full_name" msgid="6602579550613988977">"Iмя"</string>
+ <string name="name_given" msgid="4280790853455320619">"Імя"</string>
+ <string name="name_family" msgid="7466985689626017037">"Прозвішча"</string>
+ <string name="name_prefix" msgid="59756378548779822">"Прэфікс імені"</string>
+ <string name="name_middle" msgid="8467433655992690326">"Імя па бацьку"</string>
+ <string name="name_suffix" msgid="3855278445375651441">"Суфікс да імені"</string>
+ <string name="name_phonetic" msgid="4259595234312430484">"Фанетычны запіс імя"</string>
+ <string name="name_phonetic_given" msgid="8723179018384187631">"Вымаўленне імя"</string>
+ <string name="name_phonetic_middle" msgid="8643721493320405200">"Фанетычны запіс імя па бацьку"</string>
+ <string name="name_phonetic_family" msgid="2640133663656011626">"Вымаўленне прозвішча"</string>
+ <string name="phoneLabelsGroup" msgid="6468091477851199285">"Тэлефон"</string>
+ <string name="emailLabelsGroup" msgid="8389931313045344406">"Электронная пошта"</string>
+ <string name="postalLabelsGroup" msgid="3487738141112589324">"Адрас"</string>
+ <string name="imLabelsGroup" msgid="3898238486262614027">"ІМ"</string>
+ <string name="organizationLabelsGroup" msgid="2478611760751832035">"Арганізацыя"</string>
+ <string name="relationLabelsGroup" msgid="1854373894284572781">"Сувязі"</string>
+ <string name="eventLabelsGroup" msgid="7960408705307831289">"Асаблівая дата"</string>
+ <string name="sms" msgid="1756857139634224222">"Тэкставае паведамленне"</string>
+ <string name="postal_address" msgid="8765560217149624536">"Адрас"</string>
+ <string name="ghostData_company" msgid="5414421120553765775">"Кампанія"</string>
+ <string name="ghostData_title" msgid="7496735200318496110">"Назва"</string>
+ <string name="label_notes" msgid="8337354953278341042">"Нататкі"</string>
+ <string name="label_custom_field" msgid="1994056912242214426">"Карыстальніцкі"</string>
+ <string name="label_sip_address" msgid="7252153678613978127">"SIP"</string>
+ <string name="websiteLabelsGroup" msgid="4202998982804009261">"Вэб-старонка"</string>
+ <string name="groupsLabel" msgid="7000816729542098972">"Меткі"</string>
+ <string name="email_home" msgid="8573740658148184279">"Паведамленне на хатні адрас электроннай пошты"</string>
+ <string name="email_mobile" msgid="2042889209787989814">"Адправіць электронную пошту на мабільны адрас"</string>
+ <string name="email_work" msgid="2807430017302722689">"Паведамленне на працоўную электронную пошту"</string>
+ <string name="email_other" msgid="3454004077967657109">"Электронная пошта"</string>
+ <string name="email_custom" msgid="5536404237099078802">"Адправіць ліст на адрас <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="email" msgid="5668400997660065897">"Электронная пошта"</string>
+ <string name="postal_street" msgid="8133143961580058972">"Вуліца"</string>
+ <string name="postal_pobox" msgid="4431938829180269821">"Паштовая скрыня"</string>
+ <string name="postal_neighborhood" msgid="1450783874558956739">"Наваколле"</string>
+ <string name="postal_city" msgid="6597491300084895548">"Горад"</string>
+ <string name="postal_region" msgid="6045263193478437672">"Штат"</string>
+ <string name="postal_postcode" msgid="572136414136673751">"Паштовы індэкс"</string>
+ <string name="postal_country" msgid="7638264508416368690">"Краіна"</string>
+ <string name="map_home" msgid="1243547733423343982">"Прагледзець хатні адрас"</string>
+ <string name="map_work" msgid="1360474076921878088">"Паглядзець працоўны адрас"</string>
+ <string name="map_other" msgid="3817820803587012641">"Прагледзець адрас"</string>
+ <string name="map_custom" msgid="8761800628069473526">"Паглядзець адрас <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="chat_aim" msgid="2588492205291249142">"Чат у AIM"</string>
+ <string name="chat_msn" msgid="8041633440091073484">"Чат у Windows Live"</string>
+ <string name="chat_yahoo" msgid="6629211142719943666">"Чат праз Yahoo"</string>
+ <string name="chat_skype" msgid="1210045020427480566">"Чат у Skype"</string>
+ <string name="chat_qq" msgid="4294637812847719693">"Чат у QQ"</string>
+ <string name="chat_gtalk" msgid="981575737258117697">"Чат у Google Talk"</string>
+ <string name="chat_icq" msgid="8438405386153745775">"Чат праз ICQ"</string>
+ <string name="chat_jabber" msgid="7561444230307829609">"Чат у Jabber"</string>
+ <string name="chat" msgid="9025361898797412245">"Чат"</string>
+ <string name="description_minus_button" msgid="6908099247930477551">"выдаліць"</string>
+ <string name="expand_collapse_name_fields_description" msgid="8682630859539604311">"Разгарнуць ці згарнуць назвы палёў"</string>
+ <string name="expand_collapse_phonetic_name_fields_description" msgid="3306777588073354509">"Разгарнуць ці згарнуць палі вымаўлення імён"</string>
+ <string name="list_filter_all_accounts" msgid="8908683398914322369">"Усе кантакты"</string>
+ <string name="list_filter_all_starred" msgid="5031734941601931356">"Пазначана"</string>
+ <string name="list_filter_customize" msgid="4789963356004169321">"Карыстальнiцкi"</string>
+ <string name="list_filter_single" msgid="5871400283515893087">"Кантакт"</string>
+ <string name="display_ungrouped" msgid="6885954210243119591">"Усе кантакты з тэчкі \"Іншыя\""</string>
+ <string name="display_all_contacts" msgid="2031647544742889505">"Усе кантакты"</string>
+ <string name="menu_sync_remove" msgid="3266725887008450161">"Выдаліць групу сінхранізацыі"</string>
+ <string name="dialog_sync_add" msgid="8267045393119375803">"Дадаць групу сінхранізацыі"</string>
+ <string name="display_more_groups" msgid="2682547080423434170">"Больш груп..."</string>
+ <string name="display_warn_remove_ungrouped" msgid="8872290721676651414">"Выдаленне групы \"<xliff:g id="GROUP">%s</xliff:g>\" з сінхранізацыі таксама выдаліць любыя разгрупаваныя кантакты з сінхранізацыі."</string>
+ <string name="savingDisplayGroups" msgid="2133152192716475939">"Захаванне параметраў адлюстравання..."</string>
+ <string name="menu_done" msgid="796017761764190697">"Зроблена"</string>
+ <string name="menu_doNotSave" msgid="58593876893538465">"Адмена"</string>
+ <string name="listCustomView" msgid="1840624396582117590">"Карыстальніцкі выгляд"</string>
+ <string name="dialog_new_contact_account" msgid="4969619718062454756">"Захаваць імпартаваныя кантакты ў:"</string>
+ <string name="import_from_sim" msgid="3859272228033941659">"Імпарт з SIM-карты"</string>
+ <string name="import_from_sim_summary" msgid="5815105584445743740">"Імпартаваць з SIM-карты <xliff:g id="SIM_NAME">^1</xliff:g> – <xliff:g id="SIM_NUMBER">^2</xliff:g>"</string>
+ <string name="import_from_sim_summary_no_number" msgid="880612418352086012">"Імпартаваць з SIM-карты <xliff:g id="SIM_NAME">%1$s</xliff:g>"</string>
+ <string name="import_from_vcf_file" product="default" msgid="5304572242183878086">"Імпартаваць з файла .vcf"</string>
+ <string name="cancel_import_confirmation_message" msgid="3929951040347726757">"Адмянiць iмпарт файла <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_export_confirmation_message" msgid="1995462401949262638">"Адмянiць экспарт файла <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_vcard_import_or_export_failed" msgid="6139900383366166706">"Немагчыма адмяніць імпарт/экспарт vCard"</string>
+ <string name="fail_reason_unknown" msgid="1714092345030570863">"Невядомая памылка."</string>
+ <string name="fail_reason_could_not_open_file" msgid="2067725459821997463">"Немагчыма адкрыць файл \"<xliff:g id="FILE_NAME">%s</xliff:g>\": <xliff:g id="EXACT_REASON">%s</xliff:g>"</string>
+ <string name="fail_reason_could_not_initialize_exporter" msgid="707260459259688510">"Не атрымалася запусцiць экспарцёр: \"<xliff:g id="EXACT_REASON">%s</xliff:g>\"."</string>
+ <string name="fail_reason_no_exportable_contact" msgid="8728506011371262065">"Няма кантактаў для экспарту."</string>
+ <string name="missing_required_permission" msgid="5865884842972833120">"Вы адключылі дазвол, які патрабуецца."</string>
+ <string name="fail_reason_error_occurred_during_export" msgid="3018855323913649063">"Памылка экспарту: \"<xliff:g id="EXACT_REASON">%s</xliff:g>\"."</string>
+ <string name="fail_reason_too_long_filename" msgid="3393764245254738333">"Патрабаванае імя файла (\"<xliff:g id="FILENAME">%s</xliff:g>\") занадта доўгае."</string>
+ <string name="fail_reason_io_error" msgid="6748358842976073255">"Памылка ўводу/вываду"</string>
+ <string name="fail_reason_low_memory_during_import" msgid="875222757734882898">"Недастаткова памяці (магчыма, занадта вялікі файл)"</string>
+ <string name="fail_reason_vcard_parse_error" msgid="888263542360355784">"Немагчыма разабраць файл vCard па нечаканай прычыне."</string>
+ <string name="fail_reason_not_supported" msgid="8219562769267148825">"Фармат не падтрымліваецца."</string>
+ <string name="fail_reason_failed_to_collect_vcard_meta_info" msgid="6427931733267328564">"Немагчыма сабраць мета-інфармацыю з гэтых файлаў vCard."</string>
+ <string name="fail_reason_failed_to_read_files" msgid="5823434810622484922">"Адзін або некалькі файлаў не могуць быць імпартаваныя (%s)."</string>
+ <string name="exporting_vcard_finished_title" msgid="4767045779458185251">"Экспарт файла <xliff:g id="FILENAME">%s</xliff:g> завершаны."</string>
+ <string name="exporting_vcard_finished_title_fallback" msgid="6060472638008218274">"Экспартаванне кантактаў завершана."</string>
+ <string name="exporting_vcard_finished_toast" msgid="1739055986856453882">"Экспартаванне кантактаў завершана, націсніце на апавяшчэнне, каб абагуліць кантакты."</string>
+ <string name="touch_to_share_contacts" msgid="4882485525268469736">"Дакраніцеся, каб абагуліць кантакты."</string>
+ <string name="exporting_vcard_canceled_title" msgid="2652222370493306887">"Экспарт файла <xliff:g id="FILENAME">%s</xliff:g> адменены."</string>
+ <string name="exporting_contact_list_title" msgid="9072240631534457415">"Экспарт дадзеных кантакту"</string>
+ <string name="exporting_contact_list_message" msgid="3367949209642931952">"Кантактныя даныя экспартуюцца."</string>
+ <string name="composer_failed_to_get_database_infomation" msgid="1765944280846236723">"Немагчыма атрымаць інфармацыю з базы дадзеных."</string>
+ <string name="composer_has_no_exportable_contact" msgid="3296493229040294335">"Няма кантактаў, якiя можна экспартаваць. Калi ў вашым тэлефоне няма кантактаў, некаторыя пастаўшчыкi дадзеных могуць забараняць экспарт кантактаў з тэлефона."</string>
+ <string name="composer_not_initialized" msgid="2321648986367005254">"Памылка запуску складальнiка файлаў vCard."</string>
+ <string name="exporting_contact_failed_title" msgid="4892358112409576342">"Не атрымалася экспартаваць"</string>
+ <string name="exporting_contact_failed_message" msgid="4938527850142003141">"Памылка экспарта кантактных дадзеных. \nПрычына: \"<xliff:g id="FAIL_REASON">%s</xliff:g>\""</string>
+ <string name="importing_vcard_description" msgid="4245275224298571351">"Імпарт <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="reading_vcard_failed_title" msgid="4251647443358422855">"Немагчыма прачытаць дадзеныя vCard"</string>
+ <string name="reading_vcard_canceled_title" msgid="1925216585981542019">"Чытанне дадзеных з vCard адменена"</string>
+ <string name="importing_vcard_finished_title" msgid="3341541727268747967">"Заканчэнне імпартавання vCard <xliff:g id="FILENAME">%s</xliff:g>"</string>
+ <string name="importing_vcard_canceled_title" msgid="2147475978165599336">"Імпарт файла <xliff:g id="FILENAME">%s</xliff:g> адменены"</string>
+ <string name="vcard_import_will_start_message" msgid="2804911199145873396">"Файл <xliff:g id="FILENAME">%s</xliff:g> будзе імпартаваны ў бліжэйшы час."</string>
+ <string name="vcard_import_will_start_message_with_default_name" msgid="1022969530654129470">"Файл будзе імпартаваны ў бліжэйшы час."</string>
+ <string name="vcard_import_request_rejected_message" msgid="2890471184508516011">"Запыт экспарту vCard адхілены. Паспрабуйце пазней."</string>
+ <string name="vcard_export_will_start_message" msgid="2210241345252081463">"Файл <xliff:g id="FILENAME">%s</xliff:g> будзе экспартаваны ў бліжэйшы час."</string>
+ <string name="vcard_export_will_start_message_fallback" msgid="6553826997490909749">"Неўзабаве файл будзе экспартаваны."</string>
+ <string name="contacts_export_will_start_message" msgid="8538705791417534431">"Неўзабаве кантакты будуць экспартаваны."</string>
+ <string name="vcard_export_request_rejected_message" msgid="2844874826431327531">"Запыт экспарту vCard адхілены. Паспрабуйце пазней."</string>
+ <string name="vcard_unknown_filename" msgid="7171709890959915954">"кантакт"</string>
+ <string name="caching_vcard_message" msgid="4926308675041506756">"Кэшуе файлы vCard у лакальнае часовае сховішча. Фактычны імпарт пачнецца ў бліжэйшы час."</string>
+ <string name="vcard_import_failed" msgid="5223531255894842406">"Немагчыма імпартаваць vCard."</string>
+ <string name="nfc_vcard_file_name" msgid="2823095213265993609">"Кант. атр. праз NFC"</string>
+ <string name="confirm_export_title" msgid="6834385377255286349">"Экспартаваць кантакты?"</string>
+ <string name="caching_vcard_title" msgid="1226272312940516605">"Кэшаванне..."</string>
+ <string name="progress_notifier_message" msgid="2311011466908220528">"Імпарт <xliff:g id="CURRENT_NUMBER">%s</xliff:g>/<xliff:g id="TOTAL_NUMBER">%s</xliff:g>: <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="export_to_vcf_file" product="default" msgid="4407527157056120858">"Экспартаваць у файл .vcf"</string>
+ <string name="display_options_sort_list_by" msgid="7028809117272018712">"Сартаваць па"</string>
+ <string name="display_options_sort_by_given_name" msgid="2778421332815687873">"Імя"</string>
+ <string name="display_options_sort_by_family_name" msgid="2684905041926954793">"Прозвішча"</string>
+ <string name="display_options_view_names_as" msgid="6514632499276563482">"Фармат імя"</string>
+ <string name="display_options_view_given_name_first" msgid="3616004640258761473">"Спачатку імя"</string>
+ <string name="display_options_view_family_name_first" msgid="956445100777296467">"Спачатку прозвішча"</string>
+ <string name="settings_accounts" msgid="350219740670774576">"Уліковыя запісы"</string>
+ <string name="default_editor_account" msgid="699591683362420991">"Стандартны ўліковы запіс для новых кантактаў"</string>
+ <string name="sync_contact_metadata_title" msgid="6957956139306960211">"Сінхранізаваць метаданыя кантактаў [DOGFOOD]"</string>
+ <string name="sync_contact_metadata_dialog_title" msgid="6192335951588820553">"Сінхранізаваць метаданыя кантактаў"</string>
+ <string name="settings_my_info_title" msgid="1534272456405343119">"Мая інфармацыя"</string>
+ <string name="set_up_profile" msgid="7370213843590143771">"Наладзьце ваш профіль"</string>
+ <string name="setting_about" msgid="7014388749752042863">"Інфармацыя аб Кантактах"</string>
+ <string name="share_visible_contacts" msgid="890150378880783797">"Адкрыць бачныя кантакты"</string>
+ <string name="share_visible_contacts_failure" msgid="7324717548166915560">"Збой абагульвання бачных кантактаў."</string>
+ <string name="share_favorite_contacts" msgid="4280926751003081042">"Абагуліць улюбёныя кантакты"</string>
+ <string name="share_contacts" msgid="8109287987498711664">"Абагуліць усе кантакты"</string>
+ <string name="share_contacts_failure" msgid="1216431977330560559">"Збой абагульвання кантактаў."</string>
+ <string name="dialog_import_export" msgid="4360648034889921624">"Імпарт/экспарт кантактаў"</string>
+ <string name="dialog_import" msgid="2431698729761448759">"Імпартаваць кантакты"</string>
+ <string name="share_error" msgid="948429331673358107">"Нельга падзялiцца гэтым кантактам."</string>
+ <string name="no_contact_to_share" msgid="1276397530378323033">"Няма кантактаў, якія можна абагуліць."</string>
+ <string name="menu_search" msgid="9147752853603483719">"Пошук"</string>
+ <string name="menu_contacts_filter" msgid="2165153460860262501">"Паказаць кантакты"</string>
+ <string name="activity_title_contacts_filter" msgid="8275542497615516969">"Кантакты для адлюстр."</string>
+ <string name="custom_list_filter" msgid="2105275443109077687">"Вызначыце карыстальніцкі выгляд"</string>
+ <string name="menu_custom_filter_save" msgid="2679793632208086460">"Захаваць"</string>
+ <string name="hint_findContacts" msgid="7128627979899070325">"Шукаць у кантактах"</string>
+ <string name="contactsFavoritesLabel" msgid="8417039765586853670">"Выбранае"</string>
+ <string name="listTotalAllContactsZero" msgid="5513001821794568211">"Няма кантактаў."</string>
+ <string name="menu_clear_frequents" msgid="7688250191932838833">"Выдалiць частыя кантакты"</string>
+ <string name="menu_select_sim" msgid="3603578201960504010">"Выбраць SIM-карту"</string>
+ <string name="menu_accounts" msgid="1424330057450189074">"Кіраваць уліковымі запісамі"</string>
+ <string name="menu_import_export" msgid="26217871113229507">"Імпарт/экспарт"</string>
+ <string name="menu_blocked_numbers" msgid="5272951629083025995">"Заблакіраваныя нумары"</string>
+ <string name="contact_status_update_attribution" msgid="752179367353018597">"праз <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
+ <string name="contact_status_update_attribution_with_date" msgid="7358045508107825068">"<xliff:g id="DATE">%1$s</xliff:g> праз <xliff:g id="SOURCE">%2$s</xliff:g>"</string>
+ <string name="action_menu_back_from_search" msgid="8793348588949233348">"спыніць пошук"</string>
+ <string name="description_clear_search" msgid="688023606766232904">"Ачысціць пошук"</string>
+ <string name="settings_contact_display_options_title" msgid="4890258244494248687">"Параметры адлюстравання кантактаў"</string>
+ <string name="select_account_dialog_title" msgid="5478489655696599219">"Уліковы запіс"</string>
+ <string name="set_default_account" msgid="4311613760725609801">"Заўсёды ўжываць гэта для выклікаў"</string>
+ <string name="select_phone_account_for_calls" msgid="3810607744451014540">"Выклікаць праз"</string>
+ <string name="call_with_a_note" msgid="8389827628360791676">"Выклікаць з нататкай"</string>
+ <string name="call_subject_hint" msgid="3043028982108363572">"Увесці нататку для адпраўкі з выклікам…"</string>
+ <string name="send_and_call_button" msgid="7740295432834590737">"АДПРАВІЦЬ І ВЫКЛІКАЦЬ"</string>
+ <string name="call_subject_limit" msgid="4545212901205397669">"<xliff:g id="COUNT">%1$s</xliff:g> / <xliff:g id="LIMIT">%2$s</xliff:g>"</string>
+ <string name="call_subject_type_and_number" msgid="7667188212129152558">"<xliff:g id="TYPE">%1$s</xliff:g> • <xliff:g id="NUMBER">%2$s</xliff:g>"</string>
+ <plurals name="tab_title_with_unread_items" formatted="false" msgid="7682024005130747825">
+ <item quantity="one"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> непрачытаны элемент. </item>
+ <item quantity="few"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> непрачытаныя элементы. </item>
+ <item quantity="many"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> непрачытаных элементаў. </item>
+ <item quantity="other"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> непрачытанага элемента. </item>
+ </plurals>
+ <string name="about_build_version" msgid="1765533099416999801">"Версія зборкі"</string>
+ <string name="about_open_source_licenses" msgid="6479990452352919641">"Ліцэнзіі на ПЗ з адкрытым зыходным кодам"</string>
+ <string name="about_open_source_licenses_summary" msgid="57418386931763994">"Звесткі аб ліцэнзіі на праграмнае забеспячэнне з адкрытым зыходным кодам"</string>
+ <string name="about_privacy_policy" msgid="3705518622499152626">"Палітыка прыватнасці"</string>
+ <string name="about_terms_of_service" msgid="4642400812150296723">"Умовы абслугоўвання"</string>
+ <string name="activity_title_licenses" msgid="5467767062737708066">"Ліцэнзіі на ПЗ з адкрытым зыходным кодам"</string>
+ <string name="url_open_error_toast" msgid="452592089815420457">"Збой адкрыцця URL-адраса."</string>
+ <string name="account_filter_view_checked" msgid="6696859503887762213">"<xliff:g id="ACCOUNT_INFO">%s</xliff:g> - пазначана"</string>
+ <string name="account_filter_view_not_checked" msgid="2248684521205038389">"<xliff:g id="ACCOUNT_INFO">%s</xliff:g> - не пазначана"</string>
+ <string name="description_search_video_call" msgid="5841525580339803272">"Пачаць відэавыклік"</string>
+ <string name="description_delete_contact" msgid="53835657343783663">"Выдаліць"</string>
+ <string name="description_no_name_header" msgid="8884991311595943271">"Шматкроп\'е"</string>
+ <string name="callDurationSecondFormat" msgid="7067644915903528776">"<xliff:g id="SECONDS">%s</xliff:g> c"</string>
+ <string name="callDurationMinuteFormat" msgid="4647095486747447674">"<xliff:g id="MINUTES">%s</xliff:g> хв <xliff:g id="SECONDS">%s</xliff:g> с"</string>
+ <string name="callDurationHourFormat" msgid="7392254193808506640">"<xliff:g id="MINUTES_0">%s</xliff:g> гадз <xliff:g id="MINUTES_1">%s</xliff:g> хв <xliff:g id="SECONDS">%s</xliff:g> с"</string>
</resources>
diff --git a/res/values-bs-rBA-sw600dp/strings.xml b/res/values-bs-rBA-sw600dp/strings.xml
new file mode 100644
index 0000000..6b0ac29
--- /dev/null
+++ b/res/values-bs-rBA-sw600dp/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (C) 2012 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="account_phone" msgid="347665663520819575">"Uređaj"</string>
+ <string name="composer_has_no_exportable_contact" msgid="5998889616701036804">"Nema kontakata koji se mogu izvoziti. Ako imate kontakte na tabletu, neki dobavljači podataka možda ne dozvoljavaju izvoz kontakata s tableta."</string>
+</resources>
diff --git a/res/values-bs-rBA/strings.xml b/res/values-bs-rBA/strings.xml
index 67f5166..fe5aa8a 100644
--- a/res/values-bs-rBA/strings.xml
+++ b/res/values-bs-rBA/strings.xml
@@ -17,9 +17,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="applicationLabel" msgid="3906689777043645443">"Kontakti"</string>
- <string name="launcherActivityLabel" msgid="6497230399032392417">"Kontakti"</string>
- <string name="quickContactActivityLabel" msgid="7985456650689347268">"Prikaži kontakt"</string>
- <string name="editContactActivityLabel" msgid="1129944572070802839">"Uredi kontakt"</string>
<string name="contactsList" msgid="8661624236494819731">"Kontakti"</string>
<string name="shortcutContact" msgid="749243779392912958">"Kontakt"</string>
<string name="shortcutDialContact" msgid="746622101599186779">"Direktno biranje"</string>
@@ -31,12 +28,7 @@
<string name="contactPickerActivityTitle" msgid="4301062192337417640">"Izaberi kontakt"</string>
<string name="groupMemberPickerActivityTitle" msgid="1431750793695262522">"Odaberi"</string>
<string name="header_entry_contact_list_adapter_header_title" msgid="2436981165830115659">"Napravi novi kontakt"</string>
- <string name="starredList" msgid="4817256136413959463">"Označeno zvijezdom"</string>
- <string name="frequentList" msgid="7154768136473953056">"Često kontaktirani"</string>
- <string name="strequentList" msgid="5640192862059373511">"Favoriti"</string>
<string name="viewContactTitle" msgid="7989394521836644384">"Detalji o kontaktu"</string>
- <string name="editContactDescription" msgid="2947202828256214947">"Uredi kontakt"</string>
- <string name="insertContactDescription" msgid="4709878105452681987">"Napravi kontakt"</string>
<string name="contactDetailAbout" msgid="5430408883907061400">"O kontaktu"</string>
<string name="contactDetailUpdates" msgid="3780588624763446941">"Ažuriranja"</string>
<string name="searchHint" msgid="8482945356247760701">"Traži kontakte"</string>
@@ -52,7 +44,7 @@
<string name="menu_call" msgid="3992595586042260618">"Pozovi kontakt"</string>
<string name="menu_sendSMS" msgid="5535886767547006515">"Pošalji tekstualnu poruku kontaktu"</string>
<string name="menu_splitAggregate" msgid="2627252205317945563">"Razdvoji"</string>
- <string name="menu_editGroup" msgid="5062005185370983720">"Uredi"</string>
+ <string name="menu_editGroup" msgid="6696843438454341063">"Ukloni kontakte"</string>
<string name="menu_renameGroup" msgid="7169512355179757182">"Preimenuj oznaku"</string>
<string name="menu_deleteGroup" msgid="1126469629233412249">"Izbriši oznaku"</string>
<string name="menu_addToGroup" msgid="3267409983764370041">"Dodaj kontakt"</string>
@@ -80,10 +72,15 @@
<item quantity="few">Kontakti su izbrisani</item>
<item quantity="other">Kontakti su izbrisani</item>
</plurals>
- <plurals name="contacts_count" formatted="false" msgid="3287407967505649458">
- <item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt</item>
- <item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta</item>
- <item quantity="other"><xliff:g id="COUNT">%d</xliff:g> kontakata</item>
+ <plurals name="contacts_count" formatted="false" msgid="8696793457340503668">
+ <item quantity="one"><xliff:g id="COUNT_1">%d</xliff:g> kontakt</item>
+ <item quantity="few"><xliff:g id="COUNT_1">%d</xliff:g> kontakta</item>
+ <item quantity="other"><xliff:g id="COUNT_1">%d</xliff:g> kontakata</item>
+ </plurals>
+ <plurals name="contacts_count_with_account" formatted="false" msgid="7402583111980220575">
+ <item quantity="one"><xliff:g id="COUNT_2">%d</xliff:g> kontakt · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="few"><xliff:g id="COUNT_2">%d</xliff:g> kontakta · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
+ <item quantity="other"><xliff:g id="COUNT_2">%d</xliff:g> kontakata · <xliff:g id="ACCOUNT_3">%s</xliff:g></item>
</plurals>
<string name="title_from_google" msgid="4664084747121207202">"Sa Googlea"</string>
<string name="title_from_other_accounts" msgid="8307885412426754288">"Sa računa <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
@@ -111,10 +108,12 @@
<string name="customLabelPickerTitle" msgid="1081475101983255212">"Prilagođeni naziv oznake"</string>
<string name="send_to_voicemail_checkbox" msgid="9001686764070676353">"Pošalji pozive direktno na govornu poštu"</string>
<string name="removePhoto" msgid="4898105274130284565">"Ukloni fotografiju"</string>
- <string name="noContacts" msgid="4955659076981974652">"Nema kontakata"</string>
+ <string name="noContacts" msgid="2228592924476426108">"Spisak kontakata je prazan"</string>
<string name="noGroups" msgid="4607906327968232225">"Nema oznaka."</string>
<string name="noAccounts" msgid="7768267764545265909">"Potreban vam je račun da napravite grupe."</string>
<string name="emptyGroup" msgid="5102411903247859575">"Nema kontakata s ovom oznakom"</string>
+ <string name="emptyAccount" msgid="6873962901497975964">"Nema kontakata na ovom računu"</string>
+ <string name="emptyMainList" msgid="2772242747899664460">"Spisak kontakata je prazan"</string>
<string name="contactSavedToast" msgid="9171862279493213075">"Kontakt je sačuvan"</string>
<string name="contactUnlinkedToast" msgid="7122823195786012553">"Kontakti su razdvojeni"</string>
<string name="contactSavedErrorToast" msgid="3207250533172944892">"Nije moguće sačuvati promjene kontakta."</string>
@@ -131,6 +130,7 @@
<string name="groupMembersRemovedToast" msgid="3510563559799376603">"Uklonjeno iz oznake"</string>
<string name="groupMembersAddedToast" msgid="4824834898718972768">"Dodano oznaci"</string>
<string name="groupSavedErrorToast" msgid="8121032018490980184">"Nije moguće sačuvati promjene oznake."</string>
+ <string name="groupExistsErrorMessage" msgid="5196811283836946189">"Ta oznaka već postoji"</string>
<plurals name="listTotalPhoneContacts" formatted="false" msgid="3692277679143308755">
<item quantity="one"><xliff:g id="COUNT">%d</xliff:g> kontakt s brojem telefona</item>
<item quantity="few"><xliff:g id="COUNT">%d</xliff:g> kontakta s brojevima telefona</item>
@@ -223,8 +223,7 @@
<string name="social_widget_loading" msgid="5327336597364074608">"Učitavanje…"</string>
<string name="contacts_unavailable_create_contact" msgid="7014525713871959208">"Napravi novi kontakt"</string>
<string name="contacts_unavailable_add_account" msgid="4347232421410561500">"Dodaj račun"</string>
- <string name="contacts_unavailable_import_contacts" msgid="4957393255392437529">"Uvezi kontakte"</string>
- <string name="create_group_dialog_title" msgid="5363404287877384473">"Napravi novu oznaku"</string>
+ <string name="contacts_unavailable_import_contacts" msgid="3182801738595937144">"Uvezi"</string>
<string name="create_group_item_label" msgid="3263064599743742865">"Napravi novu…"</string>
<string name="delete_group_dialog_message" msgid="335713829185261371">"Izbrisati oznaku \"<xliff:g id="GROUP_LABEL">%1$s</xliff:g>\"? (Kontakti neće biti izbrisani.)"</string>
<string name="toast_join_with_empty_contact" msgid="1215465657839085613">"Upišite ime kontakta prije povezivanja s drugim kontaktom."</string>
@@ -232,24 +231,23 @@
<string name="set_default" msgid="4417505153468300351">"Postavi zadano"</string>
<string name="clear_default" msgid="7193185801596678067">"Obriši zadano"</string>
<string name="toast_text_copied" msgid="5143776250008541719">"Tekst je kopiran"</string>
- <string name="cancel_confirmation_dialog_message" msgid="5058226498605989285">"Želite li odbaciti napravljene promjene i prekinuti uređivanje?"</string>
+ <string name="cancel_confirmation_dialog_message" msgid="9008214737653278989">"Odbaciti promjene?"</string>
<string name="cancel_confirmation_dialog_cancel_editing_button" msgid="3057023972074640671">"Odbaci"</string>
- <string name="cancel_confirmation_dialog_keep_editing_button" msgid="7737724111972855348">"Nastavi uređivanje"</string>
+ <string name="cancel_confirmation_dialog_keep_editing_button" msgid="3316573928085916146">"Otkaži"</string>
+ <string name="leave_customize_confirmation_dialog_message" msgid="4277114551206032979">"Odbaciti prilagođavanja?"</string>
<string name="call_type_and_date" msgid="747163730039311423">"<xliff:g id="CALL_TYPE">%1$s</xliff:g> <xliff:g id="CALL_SHORT_DATE">%2$s</xliff:g>"</string>
<string name="enter_contact_name" msgid="4594274696120278368">"Traži kontakte"</string>
- <!-- no translation found for title_edit_group (1889302367574226969) -->
- <skip />
+ <string name="title_edit_group" msgid="8602752287270586734">"Ukloni kontakte"</string>
<string name="local_profile_title" msgid="2021416826991393684">"Moj lokalni profil"</string>
<string name="external_profile_title" msgid="8034998767621359438">"Moj profil <xliff:g id="EXTERNAL_SOURCE">%1$s</xliff:g>"</string>
<string name="toast_displaying_all_contacts" msgid="2737388783898593875">"Prikazuju se svi kontakti"</string>
<string name="generic_no_account_prompt" msgid="7218827704367325460">"Očuvajte sigurnost svojih kontakata čak i ako izgubite telefon: sinhronizirajte ih s mrežnom uslugom."</string>
<string name="generic_no_account_prompt_title" msgid="753783911899054860">"Dodajte račun"</string>
- <string name="contact_editor_prompt_zero_accounts" msgid="1785345895691886499">"Neće biti napravljena sigurnosna kopija novog računa. Dodati račun za pravljenje sigurnosnih kopija kontakata na mreži?"</string>
+ <string name="contact_editor_prompt_zero_accounts" msgid="6648376557574360096">"Odvojite trenutak da dodate račun putem kojeg će se kontakti sigurnosno kopirati na Google."</string>
<string name="contact_editor_prompt_one_account" msgid="3087691056345099310">"Novi kontakti će biti sačuvani na račun <xliff:g id="ACCOUNT_NAME">%1$s</xliff:g>."</string>
<string name="contact_editor_prompt_multiple_accounts" msgid="8565761674283473549">"Izaberite zadani račun za nove kontakte:"</string>
<string name="contact_editor_title_new_contact" msgid="7192223018128934940">"Dodaj novi kontakt"</string>
<string name="contact_editor_title_existing_contact" msgid="4898475703683187798">"Uredi kontakt"</string>
- <string name="keep_local" msgid="1258761699192993322">"Zadrži na uređaju"</string>
<string name="add_account" msgid="8201790677994503186">"Dodajte račun"</string>
<string name="add_new_account" msgid="5748627740680940264">"Dodaj novi račun"</string>
<string name="menu_export_database" msgid="2659719297530170820">"Izvezi fajlove baze podataka"</string>
@@ -261,7 +259,6 @@
<string name="about_card_title" msgid="2920942314212825637">"O kontaktu"</string>
<string name="send_message" msgid="8938418965550543196">"Pošalji poruku"</string>
<string name="toast_making_personal_copy" msgid="288549957278065542">"Izrađivanje lične kopije u toku…"</string>
- <string name="yesterday" msgid="6840858548955018569">"Jučer"</string>
<string name="tomorrow" msgid="6241969467795308581">"Sutra"</string>
<string name="today" msgid="8041090779381781781">"Danas"</string>
<string name="today_at_time_fmt" msgid="605665249491030460">"Danas u <xliff:g id="TIME_INTERVAL">%s</xliff:g>"</string>
@@ -346,4 +343,264 @@
<string name="permission_explanation_subheader_calendar_and_SMS" msgid="630115334220569184">"Događaji i poruke"</string>
<string name="permission_explanation_subheader_calendar" msgid="8785323496211704613">"Događaji"</string>
<string name="permission_explanation_subheader_SMS" msgid="1904552086449525567">"Poruke"</string>
+ <string name="hamburger_feature_highlight_header" msgid="7442308698936786415">"Organizirajte spisak"</string>
+ <string name="hamburger_feature_highlight_body" msgid="6268711111318172098">"Uklonite duplikate i grupirajte kontakte prema oznaci"</string>
+ <string name="undo" msgid="1425165101664071422">"Opozovi radnju"</string>
+ <string name="call_custom" msgid="6385303130912713318">"Pozovi <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_home" msgid="1990519474420545392">"Pozovi kuću"</string>
+ <string name="call_mobile" msgid="7502236805487609178">"Pozovi mobitel"</string>
+ <string name="call_work" msgid="5328785911463744028">"Pozovi posao"</string>
+ <string name="call_fax_work" msgid="7467763592359059243">"Pozovi poslovni faks"</string>
+ <string name="call_fax_home" msgid="8342175628887571876">"Pozovi kućni faks"</string>
+ <string name="call_pager" msgid="9003902812293983281">"Pozovi pejdžer"</string>
+ <string name="call_other" msgid="8563753966926932052">"Pozovi"</string>
+ <string name="call_callback" msgid="1910165691349426858">"Pozovi broj za uzvraćanje poziva"</string>
+ <string name="call_car" msgid="3280537320306436445">"Pozovi automobil"</string>
+ <string name="call_company_main" msgid="6105120947138711257">"Pozovi glavni broj kompanije"</string>
+ <string name="call_isdn" msgid="1541590690193403411">"Pozovi ISDN"</string>
+ <string name="call_main" msgid="6082900571803441339">"Pozovi glavni broj"</string>
+ <string name="call_other_fax" msgid="5745314124619636674">"Pozovi faks"</string>
+ <string name="call_radio" msgid="8296755876398357063">"Pozovi radio"</string>
+ <string name="call_telex" msgid="2223170774548648114">"Pozovi teleks"</string>
+ <string name="call_tty_tdd" msgid="8951266948204379604">"Pozovi TTY/TDD"</string>
+ <string name="call_work_mobile" msgid="8707874281430105394">"Pozovi poslovni mobitel"</string>
+ <string name="call_work_pager" msgid="3419348514157949008">"Pozovi poslovni pejdžer"</string>
+ <string name="call_assistant" msgid="670941612175068337">"Pozovi <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="call_mms" msgid="6274041545876221437">"Pozovi MMS"</string>
+ <string name="call_by_shortcut" msgid="2566802538698913124">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (Poziv)"</string>
+ <string name="sms_custom" msgid="415060214233647603">"Pošalji poruku na <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="sms_home" msgid="7524332261493162995">"Pošalji tekstualnu poruku na kućni broj"</string>
+ <string name="sms_mobile" msgid="5200107250451030769">"Pošalji tekstualnu poruku na mobilni"</string>
+ <string name="sms_work" msgid="2269624156655267740">"Pošalji tekstualnu poruku na poslovni broj"</string>
+ <string name="sms_fax_work" msgid="8028189067816907075">"Pošalji tekstualnu poruku na poslovni faks"</string>
+ <string name="sms_fax_home" msgid="9204042076306809634">"Pošalji tekstualnu poruku na kućni faks"</string>
+ <string name="sms_pager" msgid="7730404569637015192">"Pošalji tekstualnu poruku na pejdžer"</string>
+ <string name="sms_other" msgid="806127844607642331">"Tekst"</string>
+ <string name="sms_callback" msgid="5004824430094288752">"Pošalji tekstualnu poruku na broj za povratni poziv"</string>
+ <string name="sms_car" msgid="7444227058437359641">"Pošalji tekstualnu poruku na automobil"</string>
+ <string name="sms_company_main" msgid="118970873419678087">"Pošalji tekstualnu poruku na glavni broj kompanije"</string>
+ <string name="sms_isdn" msgid="8153785037515047845">"Pošalji tekstualnu poruku na ISDN"</string>
+ <string name="sms_main" msgid="8621625784504541679">"Pošalji tekstualnu poruku na glavni broj"</string>
+ <string name="sms_other_fax" msgid="3888842199855843152">"Pošalji tekstualnu poruku na faks"</string>
+ <string name="sms_radio" msgid="3329166673433967820">"Pošalji tekstualnu poruku na radio"</string>
+ <string name="sms_telex" msgid="9034802430065267848">"Pošalji tekstualnu poruku na teleks"</string>
+ <string name="sms_tty_tdd" msgid="6782284969132531532">"Pošalji tekstualnu poruku na TTY/TDD"</string>
+ <string name="sms_work_mobile" msgid="2459939960512702560">"Pošalji tekstualnu poruku na poslovni mobitel"</string>
+ <string name="sms_work_pager" msgid="5566924423316960597">"Pošalji tekstualnu poruku na poslovni pejdžer"</string>
+ <string name="sms_assistant" msgid="2773424339923116234">"Pošalji tekstualnu poruku <xliff:g id="ASSISTANT">%s</xliff:g>"</string>
+ <string name="sms_mms" msgid="4069352461380762677">"Pošalji tekstualnu poruku na MMS broj"</string>
+ <string name="sms_by_shortcut" msgid="7741770672976099517">"<xliff:g id="CONTACT_NAME">%s</xliff:g> (Poruka)"</string>
+ <string name="description_video_call" msgid="7120921378651700947">"Uputi videopoziv"</string>
+ <string name="clearFrequentsConfirmation_title" msgid="766292372438450432">"Obrisati često kontaktirane osobe?"</string>
+ <string name="clearFrequentsConfirmation" msgid="2270554975938265734">"Obrisat ćete listu često kontaktiranih osoba u aplikaciji Kontakti i Aplikaciji za telefon, pa će aplikacije za e-poštu morati ispočetka učiti vaše postavke adresa."</string>
+ <string name="clearFrequentsProgress_title" msgid="5157001637482794212">"Brisanje često kontaktiranih osoba…"</string>
+ <string name="status_available" msgid="5586870015822828392">"Dostupno"</string>
+ <string name="status_away" msgid="1838861100379804730">"Odsutan"</string>
+ <string name="status_busy" msgid="9147992455450257136">"Zauzeto"</string>
+ <string name="local_invisible_directory" msgid="6046691709127661065">"Ostali"</string>
+ <string name="directory_search_label" msgid="1887759056597975053">"Direktorij"</string>
+ <string name="directory_search_label_work" msgid="8618292129829443176">"Poslovni imenik"</string>
+ <string name="local_search_label" msgid="2551177578246113614">"Svi kontakti"</string>
+ <string name="foundTooManyContacts" msgid="5163335650920020220">"Pronađeno je više od <xliff:g id="COUNT">%d</xliff:g>."</string>
+ <string name="description_quick_contact_for" msgid="6737516415168327789">"Brzi kontakt za <xliff:g id="NAME">%1$s</xliff:g>"</string>
+ <string name="missing_name" msgid="8745511583852904385">"(Bez imena)"</string>
+ <string name="favoritesFrequentContacted" msgid="6184232487472425690">"Često kontaktirani"</string>
+ <string name="description_view_contact_detail" msgid="9133251213656414807">"Prikaži kontakt"</string>
+ <string name="list_filter_phones" msgid="735313795643493365">"Svi kontakti s brojevima telefona"</string>
+ <string name="list_filter_phones_work" msgid="1470173699551475015">"Kontakti radnog profila"</string>
+ <string name="view_updates_from_group" msgid="1782685984905600034">"Prikaži ažuriranja"</string>
+ <string name="account_phone" msgid="7128032778471187553">"Uređaj"</string>
+ <string name="account_sim" msgid="6519016427905087952">"SIM"</string>
+ <string name="nameLabelsGroup" msgid="2034640839640477827">"Ime"</string>
+ <string name="nicknameLabelsGroup" msgid="2891682101053358010">"Nadimak"</string>
+ <string name="full_name" msgid="6602579550613988977">"Ime"</string>
+ <string name="name_given" msgid="4280790853455320619">"Ime"</string>
+ <string name="name_family" msgid="7466985689626017037">"Prezime"</string>
+ <string name="name_prefix" msgid="59756378548779822">"Prefiks imena"</string>
+ <string name="name_middle" msgid="8467433655992690326">"Srednje ime"</string>
+ <string name="name_suffix" msgid="3855278445375651441">"Sufiks imena"</string>
+ <string name="name_phonetic" msgid="4259595234312430484">"Fonetsko ime"</string>
+ <string name="name_phonetic_given" msgid="8723179018384187631">"Fonetsko ime"</string>
+ <string name="name_phonetic_middle" msgid="8643721493320405200">"Fonetsko srednje ime"</string>
+ <string name="name_phonetic_family" msgid="2640133663656011626">"Fonetsko prezime"</string>
+ <string name="phoneLabelsGroup" msgid="6468091477851199285">"Telefoniraj"</string>
+ <string name="emailLabelsGroup" msgid="8389931313045344406">"E-pošta"</string>
+ <string name="postalLabelsGroup" msgid="3487738141112589324">"Adresa"</string>
+ <string name="imLabelsGroup" msgid="3898238486262614027">"IM"</string>
+ <string name="organizationLabelsGroup" msgid="2478611760751832035">"Organizacija"</string>
+ <string name="relationLabelsGroup" msgid="1854373894284572781">"Odnos"</string>
+ <string name="eventLabelsGroup" msgid="7960408705307831289">"Posebni datum"</string>
+ <string name="sms" msgid="1756857139634224222">"Tekstualna poruka"</string>
+ <string name="postal_address" msgid="8765560217149624536">"Adresa"</string>
+ <string name="ghostData_company" msgid="5414421120553765775">"Kompanija"</string>
+ <string name="ghostData_title" msgid="7496735200318496110">"Naslov"</string>
+ <string name="label_notes" msgid="8337354953278341042">"Bilješke"</string>
+ <string name="label_custom_field" msgid="1994056912242214426">"Prilagođeno"</string>
+ <string name="label_sip_address" msgid="7252153678613978127">"SIP"</string>
+ <string name="websiteLabelsGroup" msgid="4202998982804009261">"Web stranica"</string>
+ <string name="groupsLabel" msgid="7000816729542098972">"Oznake"</string>
+ <string name="email_home" msgid="8573740658148184279">"Pošalji poruku e-pošte na kućnu adresu e-pošte"</string>
+ <string name="email_mobile" msgid="2042889209787989814">"Mobilna e-pošta"</string>
+ <string name="email_work" msgid="2807430017302722689">"Pošalji poruku e-pošte na poslovnu adresu e-pošte"</string>
+ <string name="email_other" msgid="3454004077967657109">"E-pošta"</string>
+ <string name="email_custom" msgid="5536404237099078802">"Pošalji poruku e-pošte na <xliff:g id="CUSTOM_LABEL">%s</xliff:g>"</string>
+ <string name="email" msgid="5668400997660065897">"E-pošta"</string>
+ <string name="postal_street" msgid="8133143961580058972">"Ulica"</string>
+ <string name="postal_pobox" msgid="4431938829180269821">"Poštanski pretinac"</string>
+ <string name="postal_neighborhood" msgid="1450783874558956739">"Naselje"</string>
+ <string name="postal_city" msgid="6597491300084895548">"Grad"</string>
+ <string name="postal_region" msgid="6045263193478437672">"Država"</string>
+ <string name="postal_postcode" msgid="572136414136673751">"Poštanski broj"</string>
+ <string name="postal_country" msgid="7638264508416368690">"Država"</string>
+ <string name="map_home" msgid="1243547733423343982">"Prikaži kućnu adresu"</string>
+ <string name="map_work" msgid="1360474076921878088">"Prikaži poslovnu adresu"</string>
+ <string name="map_other" msgid="3817820803587012641">"Prikaži adresu"</string>
+ <string name="map_custom" msgid="8761800628069473526">"Prikaži <xliff:g id="CUSTOM_LABEL">%s</xliff:g> adresu"</string>
+ <string name="chat_aim" msgid="2588492205291249142">"Ćaskanje putem aplikacije AIM"</string>
+ <string name="chat_msn" msgid="8041633440091073484">"Ćaskanje putem aplikacije Windows Live"</string>
+ <string name="chat_yahoo" msgid="6629211142719943666">"Ćaskanje putem aplikacije Yahoo"</string>
+ <string name="chat_skype" msgid="1210045020427480566">"Ćaskanje putem aplikacije Skype"</string>
+ <string name="chat_qq" msgid="4294637812847719693">"Ćaskanje putem aplikacije QQ"</string>
+ <string name="chat_gtalk" msgid="981575737258117697">"Ćaskanje putem aplikacije Google Talk"</string>
+ <string name="chat_icq" msgid="8438405386153745775">"Ćaskanje putem aplikacije ICQ"</string>
+ <string name="chat_jabber" msgid="7561444230307829609">"Ćaskanje putem aplikacije Jabber"</string>
+ <string name="chat" msgid="9025361898797412245">"Ćaskanje"</string>
+ <string name="description_minus_button" msgid="6908099247930477551">"izbriši"</string>
+ <string name="expand_collapse_name_fields_description" msgid="8682630859539604311">"Proširi ili skupi polja za imena"</string>
+ <string name="expand_collapse_phonetic_name_fields_description" msgid="3306777588073354509">"Proširi ili skupi polja za fonetska imena"</string>
+ <string name="list_filter_all_accounts" msgid="8908683398914322369">"Svi kontakti"</string>
+ <string name="list_filter_all_starred" msgid="5031734941601931356">"Označeno zvijezdom"</string>
+ <string name="list_filter_customize" msgid="4789963356004169321">"Prilagodi"</string>
+ <string name="list_filter_single" msgid="5871400283515893087">"Kontakt"</string>
+ <string name="display_ungrouped" msgid="6885954210243119591">"Svi drugi kontakti"</string>
+ <string name="display_all_contacts" msgid="2031647544742889505">"Svi kontakti"</string>
+ <string name="menu_sync_remove" msgid="3266725887008450161">"Ukloni grupu za sinhronizaciju"</string>
+ <string name="dialog_sync_add" msgid="8267045393119375803">"Dodaj grupu za sinhronizaciju"</string>
+ <string name="display_more_groups" msgid="2682547080423434170">"Više grupa…"</string>
+ <string name="display_warn_remove_ungrouped" msgid="8872290721676651414">"Uklanjanje grupe \"<xliff:g id="GROUP">%s</xliff:g>\" iz sinhronizacije će također ukloniti sve negrupirane kontakte iz sinhronizacije."</string>
+ <string name="savingDisplayGroups" msgid="2133152192716475939">"Čuvanje opcija prikaza u toku…"</string>
+ <string name="menu_done" msgid="796017761764190697">"Gotovo"</string>
+ <string name="menu_doNotSave" msgid="58593876893538465">"Otkaži"</string>
+ <string name="listCustomView" msgid="1840624396582117590">"Prilagođeni prikaz"</string>
+ <string name="dialog_new_contact_account" msgid="4969619718062454756">"Sačuvaj uvezene kontakte na karticu:"</string>
+ <string name="import_from_sim" msgid="3859272228033941659">"Uvezi sa SIM kartice"</string>
+ <string name="import_from_sim_summary" msgid="5815105584445743740">"Uvezi sa SIM kartice <xliff:g id="SIM_NAME">^1</xliff:g> - <xliff:g id="SIM_NUMBER">^2</xliff:g>"</string>
+ <string name="import_from_sim_summary_no_number" msgid="880612418352086012">"Uvezi sa SIM kartice <xliff:g id="SIM_NAME">%1$s</xliff:g>"</string>
+ <string name="import_from_vcf_file" product="default" msgid="5304572242183878086">"Uvezi iz .vcf fajla"</string>
+ <string name="cancel_import_confirmation_message" msgid="3929951040347726757">"Otkazati uvoz fajla <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_export_confirmation_message" msgid="1995462401949262638">"Otkazati izvoz fajla <xliff:g id="FILENAME">%s</xliff:g>?"</string>
+ <string name="cancel_vcard_import_or_export_failed" msgid="6139900383366166706">"Nemoguće otkazati uvoz/izvoz vCard fajla"</string>
+ <string name="fail_reason_unknown" msgid="1714092345030570863">"Nepoznata greška."</string>
+ <string name="fail_reason_could_not_open_file" msgid="2067725459821997463">"Nije moguće otvoriti \"<xliff:g id="FILE_NAME">%s</xliff:g>\": <xliff:g id="EXACT_REASON">%s</xliff:g>."</string>
+ <string name="fail_reason_could_not_initialize_exporter" msgid="707260459259688510">"Nije moguće pokrenuti program za izvoz: \"<xliff:g id="EXACT_REASON">%s</xliff:g>\"."</string>
+ <string name="fail_reason_no_exportable_contact" msgid="8728506011371262065">"Nema sadržaja za izvoz."</string>
+ <string name="missing_required_permission" msgid="5865884842972833120">"Onemogućili ste potrebnu dozvolu."</string>
+ <string name="fail_reason_error_occurred_during_export" msgid="3018855323913649063">"Došlo je do greške prilikom izvoza: \"<xliff:g id="EXACT_REASON">%s</xliff:g>\"."</string>
+ <string name="fail_reason_too_long_filename" msgid="3393764245254738333">"Zahtijevano ime fajla je predugo (\"<xliff:g id="FILENAME">%s</xliff:g>\")."</string>
+ <string name="fail_reason_io_error" msgid="6748358842976073255">"I/O greška"</string>
+ <string name="fail_reason_low_memory_during_import" msgid="875222757734882898">"Nema dovoljno memorije. Možda je fajl prevelik."</string>
+ <string name="fail_reason_vcard_parse_error" msgid="888263542360355784">"Nije moguće raščlaniti vCard fajl iz neočekivanog razloga."</string>
+ <string name="fail_reason_not_supported" msgid="8219562769267148825">"Format nije podržan."</string>
+ <string name="fail_reason_failed_to_collect_vcard_meta_info" msgid="6427931733267328564">"Nije moguće otvoriti metapodatke vCard fajl(ov)a."</string>
+ <string name="fail_reason_failed_to_read_files" msgid="5823434810622484922">"Nije moguće uvesti jedan ili više fajlova (%s)."</string>
+ <string name="exporting_vcard_finished_title" msgid="4767045779458185251">"Izvoz fajla <xliff:g id="FILENAME">%s</xliff:g> je završen."</string>
+ <string name="exporting_vcard_finished_title_fallback" msgid="6060472638008218274">"Izvoz kontakata je završen."</string>
+ <string name="exporting_vcard_finished_toast" msgid="1739055986856453882">"Izvoz kontakata je završen. Kliknite obavještenje da podijelite kontakte."</string>
+ <string name="touch_to_share_contacts" msgid="4882485525268469736">"Dodirnite da podijelite kontakte."</string>
+ <string name="exporting_vcard_canceled_title" msgid="2652222370493306887">"Izvoz fajla <xliff:g id="FILENAME">%s</xliff:g> je otkazan."</string>
+ <string name="exporting_contact_list_title" msgid="9072240631534457415">"Izvoz podataka kontakta u toku"</string>
+ <string name="exporting_contact_list_message" msgid="3367949209642931952">"Podaci kontakta se izvoze."</string>
+ <string name="composer_failed_to_get_database_infomation" msgid="1765944280846236723">"Nije moguće preuzeti informacije iz baze podataka."</string>
+ <string name="composer_has_no_exportable_contact" msgid="3296493229040294335">"Nema kontakata koji se mogu izvoziti. Ako imate kontakte na telefonu, neki dobavljači podataka možda ne dozvoljavaju izvoz kontakata s telefona."</string>
+ <string name="composer_not_initialized" msgid="2321648986367005254">"Program za izradu kartica vCard nije pravilno pokrenut."</string>
+ <string name="exporting_contact_failed_title" msgid="4892358112409576342">"Izvoz nije uspio"</string>
+ <string name="exporting_contact_failed_message" msgid="4938527850142003141">"Podaci kontakta nisu izvezeni.\nRazlog: \"<xliff:g id="FAIL_REASON">%s</xliff:g>\""</string>
+ <string name="importing_vcard_description" msgid="4245275224298571351">"Uvozi se kontakt <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="reading_vcard_failed_title" msgid="4251647443358422855">"Čitanje podataka vCard nije uspjelo"</string>
+ <string name="reading_vcard_canceled_title" msgid="1925216585981542019">"Čitanje vCard podataka je otkazano"</string>
+ <string name="importing_vcard_finished_title" msgid="3341541727268747967">"Završen uvoz vCard fajla <xliff:g id="FILENAME">%s</xliff:g>"</string>
+ <string name="importing_vcard_canceled_title" msgid="2147475978165599336">"Uvoz fajla <xliff:g id="FILENAME">%s</xliff:g> je otkazan"</string>
+ <string name="vcard_import_will_start_message" msgid="2804911199145873396">"Fajl <xliff:g id="FILENAME">%s</xliff:g> će uskoro biti uvezen."</string>
+ <string name="vcard_import_will_start_message_with_default_name" msgid="1022969530654129470">"Fajl će uskoro biti uvezen."</string>
+ <string name="vcard_import_request_rejected_message" msgid="2890471184508516011">"Zahtjev za uvoz vCard fajla je odbijen. Pokušajte ponovo kasnije."</string>
+ <string name="vcard_export_will_start_message" msgid="2210241345252081463">"Fajl <xliff:g id="FILENAME">%s</xliff:g> će uskoro biti izvezen."</string>
+ <string name="vcard_export_will_start_message_fallback" msgid="6553826997490909749">"Fajl će uskoro biti izvezen."</string>
+ <string name="contacts_export_will_start_message" msgid="8538705791417534431">"Kontakti će uskoro biti izvezeni."</string>
+ <string name="vcard_export_request_rejected_message" msgid="2844874826431327531">"Zahtjev za izvoz vCard fajla je odbijen. Pokušajte ponovo kasnije."</string>
+ <string name="vcard_unknown_filename" msgid="7171709890959915954">"kontakt"</string>
+ <string name="caching_vcard_message" msgid="4926308675041506756">"Spremanje vCard fajlova u lokalnu privremenu pohranu. Uvoz će započeti uskoro."</string>
+ <string name="vcard_import_failed" msgid="5223531255894842406">"Uvoz vCard kartice nije uspio."</string>
+ <string name="nfc_vcard_file_name" msgid="2823095213265993609">"Kontakt NFC-om"</string>
+ <string name="confirm_export_title" msgid="6834385377255286349">"Izvesti kontakte?"</string>
+ <string name="caching_vcard_title" msgid="1226272312940516605">"Spremanje u privremenu pohranu u toku"</string>
+ <string name="progress_notifier_message" msgid="2311011466908220528">"Uvozi se <xliff:g id="CURRENT_NUMBER">%s</xliff:g>/<xliff:g id="TOTAL_NUMBER">%s</xliff:g>: <xliff:g id="NAME">%s</xliff:g>"</string>
+ <string name="export_to_vcf_file" product="default" msgid="4407527157056120858">"Izvezi u .vcf fajl"</string>
+ <string name="display_options_sort_list_by" msgid="7028809117272018712">"Poredaj po"</string>
+ <string name="display_options_sort_by_given_name" msgid="2778421332815687873">"Ime"</string>
+ <string name="display_options_sort_by_family_name" msgid="2684905041926954793">"Prezime"</string>
+ <string name="display_options_view_names_as" msgid="6514632499276563482">"Format imena"</string>
+ <string name="display_options_view_given_name_first" msgid="3616004640258761473">"Ime prvo"</string>
+ <string name="display_options_view_family_name_first" msgid="956445100777296467">"Prezime prvo"</string>
+ <string name="settings_accounts" msgid="350219740670774576">"Računi"</string>
+ <string name="default_editor_account" msgid="699591683362420991">"Zadani račun za nove kontakte"</string>
+ <string name="sync_contact_metadata_title" msgid="6957956139306960211">"Sinhroniziraj metapodatke kontakata [DOGFOOD]"</string>
+ <string name="sync_contact_metadata_dialog_title" msgid="6192335951588820553">"Sinhroniziraj metapodatke kontakata"</string>
+ <string name="settings_my_info_title" msgid="1534272456405343119">"Moje informacije"</string>
+ <string name="set_up_profile" msgid="7370213843590143771">"Postavite svoj profil"</string>
+ <string name="setting_about" msgid="7014388749752042863">"O kontaktima"</string>
+ <string name="share_visible_contacts" msgid="890150378880783797">"Podijeli vidljive kontakte"</string>
+ <string name="share_visible_contacts_failure" msgid="7324717548166915560">"Dijeljenje vidljivih kontakata nije uspjelo."</string>
+ <string name="share_favorite_contacts" msgid="4280926751003081042">"Dijeli omiljene kontakte"</string>
+ <string name="share_contacts" msgid="8109287987498711664">"Dijeli sve kontakte"</string>
+ <string name="share_contacts_failure" msgid="1216431977330560559">"Dijeljenje kontakata nije uspjelo."</string>
+ <string name="dialog_import_export" msgid="4360648034889921624">"Uvoz/izvoz kontakata"</string>
+ <string name="dialog_import" msgid="2431698729761448759">"Uvezi kontakte"</string>
+ <string name="share_error" msgid="948429331673358107">"Ovaj kontakt se ne može podijeliti."</string>
+ <string name="no_contact_to_share" msgid="1276397530378323033">"Nema kontakata za dijeljenje."</string>
+ <string name="menu_search" msgid="9147752853603483719">"Traži"</string>
+ <string name="menu_contacts_filter" msgid="2165153460860262501">"Kontakti za prikaz"</string>
+ <string name="activity_title_contacts_filter" msgid="8275542497615516969">"Kontakti za prikaz"</string>
+ <string name="custom_list_filter" msgid="2105275443109077687">"Definirajte prilagođeni prikaz"</string>
+ <string name="menu_custom_filter_save" msgid="2679793632208086460">"Sačuvaj"</string>
+ <string name="hint_findContacts" msgid="7128627979899070325">"Traži kontakte"</string>
+ <string name="contactsFavoritesLabel" msgid="8417039765586853670">"Favoriti"</string>
+ <string name="listTotalAllContactsZero" msgid="5513001821794568211">"Nema kontakata."</string>
+ <string name="menu_clear_frequents" msgid="7688250191932838833">"Obriši često kontaktirane"</string>
+ <string name="menu_select_sim" msgid="3603578201960504010">"Odaberi SIM karticu"</string>
+ <string name="menu_accounts" msgid="1424330057450189074">"Upravljaj računima"</string>
+ <string name="menu_import_export" msgid="26217871113229507">"Uvoz/izvoz"</string>
+ <string name="menu_blocked_numbers" msgid="5272951629083025995">"Blokirani brojevi"</string>
+ <string name="contact_status_update_attribution" msgid="752179367353018597">"putem <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
+ <string name="contact_status_update_attribution_with_date" msgid="7358045508107825068">"<xliff:g id="DATE">%1$s</xliff:g> putem <xliff:g id="SOURCE">%2$s</xliff:g>"</string>
+ <string name="action_menu_back_from_search" msgid="8793348588949233348">"zaustavi pretraživanje"</string>
+ <string name="description_clear_search" msgid="688023606766232904">"Obriši pretragu"</string>
+ <string name="settings_contact_display_options_title" msgid="4890258244494248687">"Opcije prikaza kontakata"</string>
+ <string name="select_account_dialog_title" msgid="5478489655696599219">"Račun"</string>
+ <string name="set_default_account" msgid="4311613760725609801">"Uvijek koristi ovu karticu za poziv"</string>
+ <string name="select_phone_account_for_calls" msgid="3810607744451014540">"Poziv putem"</string>
+ <string name="call_with_a_note" msgid="8389827628360791676">"Poziv s bilješkom"</string>
+ <string name="call_subject_hint" msgid="3043028982108363572">"Upišite bilješku koja će se poslati uz poziv…"</string>
+ <string name="send_and_call_button" msgid="7740295432834590737">"POŠALJI I POZOVI"</string>
+ <string name="call_subject_limit" msgid="4545212901205397669">"<xliff:g id="COUNT">%1$s</xliff:g> / <xliff:g id="LIMIT">%2$s</xliff:g>"</string>
+ <string name="call_subject_type_and_number" msgid="7667188212129152558">"<xliff:g id="TYPE">%1$s</xliff:g> • <xliff:g id="NUMBER">%2$s</xliff:g>"</string>
+ <plurals name="tab_title_with_unread_items" formatted="false" msgid="7682024005130747825">
+ <item quantity="one"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitana stavka. </item>
+ <item quantity="few"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitana stavka. </item>
+ <item quantity="other"> <xliff:g id="TITLE_2">%1$s</xliff:g>. <xliff:g id="COUNT_3">%2$d</xliff:g> nepročitana stavka. </item>
+ </plurals>
+ <string name="about_build_version" msgid="1765533099416999801">"Podverzija"</string>
+ <string name="about_open_source_licenses" msgid="6479990452352919641">"Licence otvorenog koda"</string>
+ <string name="about_open_source_licenses_summary" msgid="57418386931763994">"Detalji o licenci za softver otvorenog koda"</string>
+ <string name="about_privacy_policy" msgid="3705518622499152626">"Pravila o privatnosti"</string>
+ <string name="about_terms_of_service" msgid="4642400812150296723">"Uslovi pružanja usluge"</string>
+ <string name="activity_title_licenses" msgid="5467767062737708066">"Licence otvorenog koda"</string>
+ <string name="url_open_error_toast" msgid="452592089815420457">"Otvaranje URL-a nije uspjelo."</string>
+ <string name="account_filter_view_checked" msgid="6696859503887762213">"<xliff:g id="ACCOUNT_INFO">%s</xliff:g> je označen"</string>
+ <string name="account_filter_view_not_checked" msgid="2248684521205038389">"<xliff:g id="ACCOUNT_INFO">%s</xliff:g> nije označen"</string>
+ <string name="description_search_video_call" msgid="5841525580339803272">"Uputi videopoziv"</string>
+ <string name="description_delete_contact" msgid="53835657343783663">"Izbriši"</string>
+ <string name="description_no_name_header" msgid="8884991311595943271">"Elipsa"</string>
+ <string name="callDurationSecondFormat" msgid="7067644915903528776">"<xliff:g id="SECONDS">%s</xliff:g> sek."</string>
+ <string name="callDurationMinuteFormat" msgid="4647095486747447674">"<xliff:g id="MINUTES">%s</xliff:g> min. <xliff:g id="SECONDS">%s</xliff:g> sek."</string>
+ <string name="callDurationHourFormat" msgid="7392254193808506640">"<xliff:g id="MINUTES_0">%s</xliff:g> h <xliff:g id="MINUTES_1">%s</xliff:g> min. <xliff:g id="SECONDS">%s</xliff:g> sek."</string>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 6f6f4e1..8dd1ba9 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -28,10 +28,6 @@
<dimen name="contact_browser_list_top_margin">18dp</dimen>
<dimen name="quick_contact_photo_container_height">360dip</dimen>
- <!-- Height of the selection indicator of a tab. -->
- <dimen name="tab_selected_underline_height">3dp</dimen>
- <!-- Size of text in tabs. -->
- <dimen name="tab_text_size">16sp</dimen>
<!-- Because the "join" screen has the vertical scroll bar on right,
we cannot use @dimen/contact_browser_list_header_left_margin as is. -->
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index b89c2c1..baa8498 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -18,5 +18,4 @@
<dimen name="group_editor_side_padding">64dip</dimen>
<dimen name="contact_detail_list_top_padding">32dip</dimen>
<dimen name="detail_contact_photo_size">256dip</dimen>
- <dimen name="people_activity_landscape_tabs_text_size">16dp</dimen>
</resources>
diff --git a/res/values-w470dp/dimens.xml b/res/values-w470dp/dimens.xml
deleted file mode 100644
index 2c04e5d..0000000
--- a/res/values-w470dp/dimens.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
-
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 470dp is the height of a "normal" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">230dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">9dp</dimen>
-
-</resources>
\ No newline at end of file
diff --git a/res/values-w590dp/dimens.xml b/res/values-w590dp/dimens.xml
deleted file mode 100644
index 2fff6ca..0000000
--- a/res/values-w590dp/dimens.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
-
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 590dp is almost the height of a "large" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">350dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">14dp</dimen>
-
-</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 607b7a0..64c5e5b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -33,6 +33,7 @@
<color name="action_bar_button_text_color">#FFFFFF</color>
<color name="actionbar_background_color">@color/primary_color</color>
+ <color name="actionbar_background_color_dark">@color/primary_color_dark</color>
<color name="contextual_selection_bar_color">#f6f6f6</color>
<!-- Color of the status bar above the contextual selection bar. -->
@@ -41,9 +42,6 @@
<color name="primary_color_dark">#0277bd</color>
<color name="primary_color">#0288d1</color>
- <color name="group_primary_color_dark">#546E7A</color>
- <color name="group_primary_color">#607D8B</color>
-
<!-- Color of the selected tab underline -->
<color name="contacts_accent_color">#FFFFFF</color>
@@ -88,6 +86,12 @@
<!-- Color of background of all empty states. -->
<color name="empty_state_background">#efefef</color>
+ <!-- Colors of swipeRefreshLayout's spinning circle. -->
+ <color name="swipe_refresh_color1">#0f9d58</color>
+ <color name="swipe_refresh_color2">#dd4b37</color>
+ <color name="swipe_refresh_color3">#4285f4</color>
+ <color name="swipe_refresh_color4">#f4b400</color>
+
<!-- Color of hamburger icon in promo -->
<color name="hamburger_feature_highlight_inner_color">#00ffffff</color>
@@ -197,11 +201,6 @@
<!-- Color for icons in the actionbar -->
<color name="actionbar_icon_color">#ffffff</color>
- <color name="tab_ripple_color">@color/tab_accent_color</color>
- <color name="tab_accent_color">#ffffff</color>
- <color name="tab_selected_underline_color">@color/tab_accent_color</color>
- <color name="tab_unread_count_background_color">#700f4b70</color>
-
<!-- Color of the title to the Frequently Contacted section -->
<color name="frequently_contacted_title_color">@color/actionbar_background_color</color>
@@ -214,7 +213,6 @@
<color name="actionbar_text_color_black">#DF000000</color>
<!-- Solid grey for status bar overlay-->
<color name="actionbar_color_grey_solid">#777777</color>
- <color name="actionbar_unselected_text_color">#a6ffffff</color>
<!-- Text color of the search box text as entered by user -->
<color name="searchbox_text_color">#000000</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d355021..2eb4b22 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -238,16 +238,6 @@
<dimen name="quickcontact_expanding_button_section_height">48dp</dimen>
<dimen name="quickcontact_expanding_button_section_padding">8dp</dimen>
- <!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
- 426dp is the height of a "small" screen. We should leave 240dp for
- the title and menu items -->
- <dimen name="people_activity_landscape_tabs_width">186dip</dimen>
- <!-- The size of the text displayed in the ActionBar tabs in landscape mode.
- Text in the tabs should must be width dependent, otherwise it won't fit in the tabs.
- In portrait mode, the tabs look okay when overflowing their allocated space.
- We have to be more careful in landscape. -->
- <dimen name="people_activity_landscape_tabs_text_size">8dp</dimen>
-
<!-- Top margin of the text message when provider status is busy -->
<dimen name="update_contact_list_top_margin">188dp</dimen>
@@ -295,6 +285,9 @@
<!-- Minimum height for group name EditText -->
<dimen name="group_name_edit_text_min_height">48dp</dimen>
+ <!-- Distance to pull down before causing a refresh. -->
+ <dimen name="pull_to_refresh_distance">40dp</dimen>
+
<!-- Elevation of contact list header -->
<dimen name="contact_list_header_elevation">2dp</dimen>
@@ -428,17 +421,8 @@
<!-- Offset of bottom margin of the floating action button used when dialpad is up -->
<dimen name="floating_action_button_dialpad_margin_bottom_offset">4dp</dimen>
- <!-- Height of the selection indicator of a tab. -->
- <dimen name="tab_selected_underline_height">2dp</dimen>
<!-- Size of text in tabs. -->
- <dimen name="tab_text_size">14sp</dimen>
<dimen name="tab_elevation">2dp</dimen>
- <dimen name="tab_unread_count_background_size">16dp</dimen>
- <dimen name="tab_unread_count_background_radius">2dp</dimen>
- <dimen name="tab_unread_count_margin_left">10dp</dimen>
- <dimen name="tab_unread_count_margin_top">2dp</dimen>
- <dimen name="tab_unread_count_text_size">12sp</dimen>
- <dimen name="tab_unread_count_text_padding">2dp</dimen>
<!-- Padding around the icon in the search box. -->
<dimen name="search_box_icon_margin">4dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 04f2b0d..e87fe26 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -686,12 +686,12 @@
<!-- Message in the contact editor prompt that asks the user which account they want to save the newly created contact to. [CHAR LIMIT=NONE] -->
<string name="contact_editor_prompt_multiple_accounts">Choose a default account for new contacts:</string>
- <!-- Title of the ContactEditorActivity when creating a new contact. The char
+ <!-- Title of the editor activity when creating a new contact. The char
limit is short and cannot be increased, since this needs to be displayed in a single line
at a pre-determined text size. [CHAR LIMIT=20] -->
<string name="contact_editor_title_new_contact">Add new contact</string>
- <!-- Title of the ContactEditorActivity when editing a contact that already exists. The char
+ <!-- Title of the editor activity when editing a contact that already exists. The char
limit is short and cannot be increased, since this needs to be displayed in a single line
at a pre-determined text size. [CHAR LIMIT=20] -->
<string name="contact_editor_title_existing_contact">Edit contact</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 432f0a8..e7b6582 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -41,10 +41,6 @@
<style name="PeopleTheme" parent="@android:style/Theme.Material.Light">
<item name="android:actionBarStyle">@style/ContactsActionBarStyle</item>
- <!-- Style for the tab bar (for the divider between tabs) -->
- <item name="android:actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <!-- Style for the tab bar text (for text on tabs) -->
- <item name="android:actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
<!-- Drawable for the back button -->
<item name="android:homeAsUpIndicator">@drawable/ic_back_arrow</item>
<!-- Style for the overflow button in the actionbar. -->
@@ -103,21 +99,10 @@
<item name="android:listSelector">?android:attr/listChoiceBackgroundIndicator</item>
</style>
- <style name="GroupActivityTheme" parent="@style/PeopleActivityTheme">
- <item name="android:colorPrimaryDark">@color/group_primary_color_dark</item>
- <item name="colorPrimaryDark">@color/group_primary_color_dark</item>
- </style>
-
<style name="PeopleThemeAppCompat" parent="Theme.AppCompat.Light">
<!-- Styles that require AppCompat compatibility, remember to update both sets -->
<item name="android:actionBarStyle">@style/ContactsActionBarStyleAppCompat</item>
<item name="actionBarStyle">@style/ContactsActionBarStyleAppCompat</item>
- <!-- Style for the tab bar (for the divider between tabs) -->
- <item name="android:actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <item name="actionBarTabBarStyle">@style/ContactsActionBarTabBarStyle</item>
- <!-- Style for the tab bar text (for text on tabs) -->
- <item name="android:actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
- <item name="actionBarTabTextStyle">@style/ContactsActionBarTabTextStyle</item>
<item name="android:actionButtonStyle">@style/ContactsActionButtonStyle</item>
<item name="actionButtonStyle">@style/ContactsActionButtonStyle</item>
<!-- Drawable for the back button -->
@@ -249,22 +234,6 @@
<item name="android:textColor">@color/actionbar_text_color_black</item>
</style>
- <!-- Styling for the tab bar; handles styling of the divider line. -->
- <style name="ContactsActionBarTabBarStyle"
- parent="@android:style/Widget.Material.ActionBar.TabBar">
- <item name="android:showDividers">none</item>
- </style>
-
- <!-- Text style for tabs. -->
- <style name="ContactsActionBarTabTextStyle"
- parent="android:style/Widget.Material.Light.ActionBar.TabText">
- <item name="android:textColor">@color/tab_text_color</item>
- <item name="android:textSize">@dimen/tab_text_size</item>
- <item name="android:fontFamily">@string/tab_font_family</item>
- <item name="android:elevation">0dp</item>
- <item name="android:textStyle">bold</item>
- </style>
-
<!-- Action bar overflow menu icon. -->
<style name="ContactsActionBarOverflowQP"
parent="Widget.AppCompat.Light.ActionButton.Overflow">
diff --git a/src-bind/com/android/contactsbind/Assistants.java b/src-bind/com/android/contactsbind/Assistants.java
deleted file mode 100644
index 3fba91c..0000000
--- a/src-bind/com/android/contactsbind/Assistants.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.android.contactsbind;
-
-import android.content.Context;
-import android.content.Intent;
-
-/**
- * Creates default implementations of contacts assistants.
- */
-public final class Assistants {
-
- private Assistants() {
- }
-
- /**
- * Returns an Intent to start an Activity to clean up duplicate contacts or null
- * if it is not a supported feature.
- */
- public static Intent getDuplicatesActivityIntent(Context context) {
- return null;
- }
-}
diff --git a/src-bind/com/android/contactsbind/ObjectFactory.java b/src-bind/com/android/contactsbind/ObjectFactory.java
index ecdb967..772cf26 100644
--- a/src-bind/com/android/contactsbind/ObjectFactory.java
+++ b/src-bind/com/android/contactsbind/ObjectFactory.java
@@ -15,8 +15,10 @@
import com.android.contacts.common.logging.Logger;
import com.android.contacts.common.preference.PreferenceManager;
+import com.android.contactsbind.search.AutocompleteHelper;
import com.android.contacts.common.util.DeviceLocalAccountTypeFactory;
+import android.app.Fragment;
import android.content.Context;
/**
@@ -30,7 +32,19 @@
public static PreferenceManager getPreferenceManager(Context context) { return null; }
+ public static AutocompleteHelper getAutocompleteHelper(Context context) {
+ return null;
+ }
+
public static DeviceLocalAccountTypeFactory getDeviceLocalAccountTypeFactory(Context context) {
return new DeviceLocalAccountTypeFactory.Default(context);
}
+
+ public static Fragment getDuplicatesFragment() {
+ return null;
+ }
+
+ public static Fragment getDuplicatesUtilFragment() {
+ return null;
+ }
}
diff --git a/src-bind/com/android/contactsbind/experiments/Flags.java b/src-bind/com/android/contactsbind/experiments/Flags.java
index 5bf47e8..72cf481 100644
--- a/src-bind/com/android/contactsbind/experiments/Flags.java
+++ b/src-bind/com/android/contactsbind/experiments/Flags.java
@@ -17,8 +17,6 @@
import android.content.Context;
-import com.android.contacts.common.Experiments;
-
import java.util.HashMap;
import java.util.Map;
diff --git a/src-bind/com/android/contactsbind/search/AutocompleteHelper.java b/src-bind/com/android/contactsbind/search/AutocompleteHelper.java
new file mode 100644
index 0000000..c37a828
--- /dev/null
+++ b/src-bind/com/android/contactsbind/search/AutocompleteHelper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contactsbind.search;
+
+import android.database.Cursor;
+
+public final class AutocompleteHelper {
+
+ public static final String TAG = "Autocomplete";
+
+ public interface Listener {
+ void onAutocompletesAvailable(Cursor cursor);
+ }
+
+ private AutocompleteHelper() {
+ }
+
+ public void setListener(Listener listener) {
+ }
+
+ public void setProjection(String[] projection) {
+ }
+
+ public void setQuery(String query) {
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index b34f384..06ded9f 100755
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -51,7 +51,7 @@
import android.util.Log;
import android.widget.Toast;
-import com.android.contacts.activities.ContactEditorBaseActivity;
+import com.android.contacts.activities.CompactContactEditorActivity;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.database.ContactUpdateUtils;
import com.android.contacts.common.model.AccountTypeManager;
@@ -215,13 +215,13 @@
} catch (Exception exception) {
final int resId;
switch (saveMode) {
- case ContactEditorBaseActivity.ContactEditor.SaveMode.SPLIT:
+ case CompactContactEditorActivity.ContactEditor.SaveMode.SPLIT:
resId = R.string.contactUnlinkErrorToast;
break;
- case ContactEditorBaseActivity.ContactEditor.SaveMode.RELOAD:
+ case CompactContactEditorActivity.ContactEditor.SaveMode.RELOAD:
resId = R.string.contactJoinErrorToast;
break;
- case ContactEditorBaseActivity.ContactEditor.SaveMode.CLOSE:
+ case CompactContactEditorActivity.ContactEditor.SaveMode.CLOSE:
resId = R.string.contactSavedErrorToast;
break;
default:
@@ -743,7 +743,8 @@
ContentValues values = new ContentValues();
// TODO: Move this into the contact editor where it belongs. This needs to be integrated
- // with the way other intent extras that are passed to the {@link ContactEditorActivity}.
+ // with the way other intent extras that are passed to the
+ // {@link CompactContactEditorActivity}.
values.clear();
values.put(Data.MIMETYPE, GroupMembership.CONTENT_ITEM_TYPE);
values.put(GroupMembership.GROUP_ROW_ID, ContentUris.parseId(groupUri));
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index 4fc6976..2d7bb34 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -22,7 +22,6 @@
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
-import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Intents;
import android.support.annotation.LayoutRes;
@@ -32,10 +31,7 @@
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
-import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -46,10 +42,9 @@
import android.widget.LinearLayout;
import android.widget.Toast;
-import com.android.contacts.activities.GroupMembersActivity;
+import com.android.contacts.activities.ActionBarAdapter;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.compat.CompatUtils;
-import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.list.AccountFilterActivity;
import com.android.contacts.common.list.ContactListFilter;
import com.android.contacts.common.list.ContactListFilterController;
@@ -60,8 +55,10 @@
import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.util.ViewUtil;
-import com.android.contacts.editor.ContactEditorFragment;
+import com.android.contacts.editor.CompactContactEditorFragment;
+import com.android.contacts.editor.SelectAccountDialogFragment;
import com.android.contacts.group.GroupListItem;
+import com.android.contacts.group.GroupMembersFragment;
import com.android.contacts.group.GroupMetadata;
import com.android.contacts.group.GroupNameEditDialogFragment;
import com.android.contacts.group.GroupUtil;
@@ -69,12 +66,14 @@
import com.android.contacts.group.GroupsFragment.GroupsListener;
import com.android.contacts.interactions.AccountFiltersFragment;
import com.android.contacts.interactions.AccountFiltersFragment.AccountFiltersListener;
+import com.android.contacts.list.DefaultContactBrowseListFragment;
+import com.android.contacts.list.MultiSelectContactsListFragment;
import com.android.contacts.quickcontact.QuickContactActivity;
import com.android.contacts.common.model.account.AccountDisplayInfo;
import com.android.contacts.common.model.account.AccountDisplayInfoFactory;
import com.android.contacts.util.SharedPreferenceUtil;
-import com.android.contactsbind.Assistants;
import com.android.contactsbind.HelpUtils;
+import com.android.contactsbind.ObjectFactory;
import java.util.HashMap;
import java.util.Iterator;
@@ -91,6 +90,15 @@
NavigationView.OnNavigationItemSelectedListener,
SelectAccountDialogFragment.Listener {
+ /** Possible views of Contacts app. */
+ public enum ContactsView {
+ NONE,
+ ALL_CONTACTS,
+ DUPLICATES,
+ GROUP_VIEW,
+ ACCOUNT_VIEW,
+ }
+
protected static String TAG = "ContactsDrawerActivity";
private static final String TAG_GROUPS = "groups";
@@ -99,15 +107,9 @@
private static final String TAG_GROUP_NAME_EDIT_DIALOG = "groupNameEditDialog";
private static final String KEY_NEW_GROUP_ACCOUNT = "newGroupAccount";
+ private static final String KEY_CONTACTS_VIEW = "contactsView";
- protected static final String ACTION_CREATE_GROUP = "createGroup";
-
- // TODO(wenyiw): remove all the code related to these constants after switching to fragments.
- // Positions of "all contacts" and "duplicates" in navigation drawer.
- private static final int ALL_CONTACTS_POSITION = 1;
- private static final int DUPLICATES_POSITION = 2;
- // Gap between two menu groups, including a separator, a menu group header.
- private static final int GAP_BETWEEN_TWO_MENU_GROUPS = 2;
+ protected ContactsView mCurrentView;
private class ContactsActionBarDrawerToggle extends ActionBarDrawerToggle {
@@ -129,6 +131,33 @@
mMenuClickedBefore = true;
}
invalidateOptionsMenu();
+ // Stop search and selection mode like Gmail and Keep. Otherwise, if user switches to
+ // another fragment in navigation drawer, the current search/selection mode will be
+ // overlaid by the action bar of the newly-created fragment.
+ stopSearchAndSelection();
+ }
+
+ private void stopSearchAndSelection() {
+ final MultiSelectContactsListFragment listFragment;
+ if (isAllContactsView() || isAccountView()) {
+ listFragment = getAllFragment();
+ } else if (isGroupView()) {
+ listFragment = getGroupFragment();
+ } else {
+ listFragment = null;
+ }
+ if (listFragment == null) {
+ return;
+ }
+ final ActionBarAdapter actionBarAdapter = listFragment.getActionBarAdapter();
+ if (actionBarAdapter == null) {
+ return;
+ }
+ if (actionBarAdapter.isSearchMode()) {
+ actionBarAdapter.setSearchMode(false);
+ } else if (actionBarAdapter.isSelectionMode()) {
+ actionBarAdapter.setSelectionMode(false);
+ }
}
@Override
@@ -163,17 +192,15 @@
protected GroupsFragment mGroupsFragment;
protected AccountFiltersFragment mAccountFiltersFragment;
- // Checkable menu item lookup maps. Every map declared here should be added to
- // clearCheckedMenus() so that they can be cleared.
- // TODO find a better way to handle selected menu item state, when swicthing to fragments.
- protected Map<Long, MenuItem> mGroupMenuMap = new HashMap<>();
- protected Map<ContactListFilter, MenuItem> mFilterMenuMap = new HashMap<>();
- protected Map<Integer, MenuItem> mIdMenuMap = new HashMap<>();
-
// The account the new group will be created under.
private AccountWithDataSet mNewGroupAccount;
- private int mPositionOfLastGroup;
+ // Checkable menu item lookup maps. Every map declared here should be added to
+ // clearCheckedMenus() so that they can be cleared.
+ // TODO find a better way to handle selected menu item state, when switching to fragments.
+ protected Map<Long, MenuItem> mGroupMenuMap = new HashMap<>();
+ protected Map<ContactListFilter, MenuItem> mFilterMenuMap = new HashMap<>();
+ protected Map<Integer, MenuItem> mIdMenuMap = new HashMap<>();
@Override
protected void onCreate(Bundle savedState) {
@@ -198,57 +225,52 @@
mDrawer.setDrawerListener(mToggle);
mToggle.syncState();
+ // Set up navigation mode.
+ if (savedState != null) {
+ mCurrentView = ContactsView.values()[savedState.getInt(KEY_CONTACTS_VIEW)];
+ } else {
+ mCurrentView = ContactsView.ALL_CONTACTS;
+ }
+
// Set up hamburger menu items.
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
mNavigationView.setNavigationItemSelectedListener(this);
-
- final Menu menu = mNavigationView.getMenu();
-
- final MenuItem allContacts = menu.findItem(R.id.nav_all_contacts);
- mIdMenuMap.put(R.id.nav_all_contacts, allContacts);
-
- if (Assistants.getDuplicatesActivityIntent(this) == null) {
- menu.removeItem(R.id.nav_find_duplicates);
- } else {
- final MenuItem findDup = menu.findItem(R.id.nav_find_duplicates);
- mIdMenuMap.put(R.id.nav_find_duplicates, findDup);
- }
-
- if (!HelpUtils.isHelpAndFeedbackAvailable()) {
- menu.removeItem(R.id.nav_help);
- }
+ setUpMenu();
loadGroupsAndFilters();
- if (isDuplicatesActivity()) {
- clearCheckedMenus();
- mIdMenuMap.get(R.id.nav_find_duplicates).setCheckable(true);
- mIdMenuMap.get(R.id.nav_find_duplicates).setChecked(true);
- maybeUpdateScrollPosition(DUPLICATES_POSITION);
- }
-
if (savedState != null && savedState.containsKey(KEY_NEW_GROUP_ACCOUNT)) {
mNewGroupAccount = AccountWithDataSet.unstringify(
savedState.getString(KEY_NEW_GROUP_ACCOUNT));
}
}
- private void maybeUpdateScrollPosition(int position) {
- if (mDrawer.isDrawerOpen(GravityCompat.START)) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Don't scroll menu when drawer open");
- return;
+ private void setUpMenu() {
+ final Menu menu = mNavigationView.getMenu();
+
+ if (ObjectFactory.getDuplicatesFragment() == null) {
+ menu.removeItem(R.id.nav_find_duplicates);
+ } else {
+ final MenuItem findDupMenu = menu.findItem(R.id.nav_find_duplicates);
+ mIdMenuMap.put(R.id.nav_find_duplicates, findDupMenu);
+ if (isDuplicatesView()) {
+ updateMenuSelection(findDupMenu);
+ }
}
- final RecyclerView recyclerView = (RecyclerView) mNavigationView.getChildAt(0);
- final LinearLayoutManager layoutManager =
- (LinearLayoutManager) recyclerView.getLayoutManager();
- // Get screen height
- final DisplayMetrics metrics = getResources().getDisplayMetrics();
- final int height = metrics.heightPixels;
+ if (!HelpUtils.isHelpAndFeedbackAvailable()) {
+ menu.removeItem(R.id.nav_help);
+ }
- // Set 1/3 screen height as offset if possible.
- layoutManager.scrollToPositionWithOffset(position, height / 3);
- recyclerView.requestLayout();
+ final MenuItem allContactsMenu = menu.findItem(R.id.nav_all_contacts);
+ mIdMenuMap.put(R.id.nav_all_contacts, allContactsMenu);
+ if (isAllContactsView()) {
+ updateMenuSelection(allContactsMenu);
+ }
+ }
+
+ public Toolbar getToolbar() {
+ return mToolbar;
}
@Override
@@ -257,6 +279,7 @@
if (mNewGroupAccount != null) {
outState.putString(KEY_NEW_GROUP_ACCOUNT, mNewGroupAccount.stringify());
}
+ outState.putInt(KEY_CONTACTS_VIEW, mCurrentView.ordinal());
}
@Override
@@ -276,36 +299,6 @@
}
}
- @Override
- protected void onNewIntent(Intent newIntent) {
- if (ACTION_CREATE_GROUP.equals(newIntent.getAction())) {
- final Uri groupUri = newIntent.getData();
- if (groupUri == null) {
- Toast.makeText(this, R.string.groupSavedErrorToast, Toast.LENGTH_SHORT).show();
- return;
- }
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + groupUri);
- Toast.makeText(this, R.string.groupCreatedToast, Toast.LENGTH_SHORT).show();
- startActivity(GroupUtil.createViewGroupIntent(this, groupUri, /* title */ null));
- if (shouldFinish()) {
- // If we created a group while viewing the members of an existing group (i.e.
- // while on GroupMembersActivity), finish the current GroupMembersActivity so that
- // hitting back from the new GroupMembersActivity that was just stared will open
- // the all contacts list. See b/30047708.
- finish();
- }
- } else {
- super.onNewIntent(newIntent);
- }
- }
-
- /**
- * Returns true if child class is DuplicatesActivity
- */
- protected boolean isDuplicatesActivity() {
- return false;
- }
-
// Set up fragment manager to load groups and filters.
protected void loadGroupsAndFilters() {
final FragmentManager fragmentManager = getFragmentManager();
@@ -350,7 +343,7 @@
subMenu.removeGroup(R.id.nav_groups_items);
mGroupMenuMap = new HashMap<>();
- mPositionOfLastGroup = DUPLICATES_POSITION + GAP_BETWEEN_TWO_MENU_GROUPS;
+ final GroupMetadata groupMetaData = getGroupMetadata();
if (groupListItems != null) {
// Add each group
@@ -358,11 +351,14 @@
if (GroupUtil.isEmptyFFCGroup(groupListItem)) {
continue;
}
- mPositionOfLastGroup++;
final String title = groupListItem.getTitle();
final MenuItem menuItem =
- subMenu.add(R.id.nav_groups_items, Menu.NONE, mPositionOfLastGroup, title);
+ subMenu.add(R.id.nav_groups_items, Menu.NONE, Menu.NONE, title);
mGroupMenuMap.put(groupListItem.getGroupId(), menuItem);
+ if (isGroupView() && groupMetaData != null
+ && groupMetaData.groupId == groupListItem.getGroupId()) {
+ updateMenuSelection(menuItem);
+ }
menuItem.setIcon(R.drawable.ic_menu_label);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
@@ -372,6 +368,7 @@
public void run() {
onGroupMenuItemClicked(groupListItem.getGroupId(),
groupListItem.getTitle());
+ updateMenuSelection(menuItem);
}
});
mDrawer.closeDrawer(GravityCompat.START);
@@ -386,10 +383,9 @@
return;
}
- mPositionOfLastGroup++;
// Create a menu item in the sub menu to add new groups
final MenuItem menuItem = subMenu.add(R.id.nav_groups_items, Menu.NONE,
- mPositionOfLastGroup, getString(R.string.menu_new_group_action_bar));
+ Menu.NONE, getString(R.string.menu_new_group_action_bar));
menuItem.setIcon(R.drawable.ic_add);
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
@@ -405,36 +401,45 @@
}
});
- if (getGroupMetadata() != null) {
- updateGroupMenu(getGroupMetadata());
+ if (isGroupView() && groupMetaData != null) {
+ updateGroupMenu(groupMetaData);
}
}
- protected void updateGroupMenu(GroupMetadata groupMetadata) {
+ public void updateGroupMenu(GroupMetadata groupMetadata) {
clearCheckedMenus();
if (groupMetadata != null && mGroupMenuMap != null
&& mGroupMenuMap.get(groupMetadata.groupId) != null) {
- mGroupMenuMap.get(groupMetadata.groupId).setCheckable(true);
- mGroupMenuMap.get(groupMetadata.groupId).setChecked(true);
- maybeUpdateScrollPosition(mGroupMenuMap.get(groupMetadata.groupId).getOrder());
+ setMenuChecked(mGroupMenuMap.get(groupMetadata.groupId), true);
}
}
- /**
- * Returns group metadata if the child class is {@link GroupMembersActivity}, and null
- * otherwise.
- */
protected GroupMetadata getGroupMetadata() {
return null;
}
- protected void onGroupMenuItemClicked(long groupId, String title) {
- startActivity(GroupUtil.createViewGroupIntent(this, groupId, title));
- if (shouldFinish()) {
- finish();
- }
+ protected boolean isGroupView() {
+ return mCurrentView == ContactsView.GROUP_VIEW;
}
+ protected boolean isDuplicatesView() {
+ return mCurrentView == ContactsView.DUPLICATES;
+ }
+
+ protected boolean isAllContactsView() {
+ return mCurrentView == ContactsView.ALL_CONTACTS;
+ }
+
+ protected boolean isAccountView() {
+ return mCurrentView == ContactsView.ACCOUNT_VIEW;
+ }
+
+ public boolean isInSecondLevel() {
+ return isGroupView() || isDuplicatesView();
+ }
+
+ protected abstract void onGroupMenuItemClicked(long groupId, String title);
+
protected void onCreateGroupMenuItemClicked() {
// Select the account to create the group
final Bundle extras = getIntent().getExtras();
@@ -466,16 +471,17 @@
return;
}
- int positionOfLastFilter = mPositionOfLastGroup + GAP_BETWEEN_TWO_MENU_GROUPS;
for (int i = 0; i < accountFilterItems.size(); i++) {
- positionOfLastFilter++;
final ContactListFilter filter = accountFilterItems.get(i);
final AccountDisplayInfo displayableAccount =
accountDisplayFactory.getAccountDisplayInfoFor(filter);
final CharSequence menuName = displayableAccount.getNameLabel();
final MenuItem menuItem = subMenu.add(R.id.nav_filters_items, Menu.NONE,
- positionOfLastFilter, menuName);
+ Menu.NONE, menuName);
+ if (isAccountView() && filter == mContactListFilterController.getFilter()) {
+ updateMenuSelection(menuItem);
+ }
mFilterMenuMap.put(filter, menuItem);
final Intent intent = new Intent();
intent.putExtra(AccountFilterActivity.EXTRA_CONTACT_LIST_FILTER, filter);
@@ -485,12 +491,8 @@
mToggle.runWhenIdle(new Runnable() {
@Override
public void run() {
- AccountFilterUtil.handleAccountFilterResult(
- mContactListFilterController, AppCompatActivity.RESULT_OK,
- intent);
- if (shouldFinish()) {
- finish();
- }
+ onFilterMenuItemClicked(intent);
+ updateMenuSelection(menuItem);
}
});
mDrawer.closeDrawer(GravityCompat.START);
@@ -510,40 +512,29 @@
menuItem.setActionView(view);
}
- if (getContactListFilter() != null) {
- updateFilterMenu(getContactListFilter());
+ if (isAccountView()) {
+ updateFilterMenu(mContactListFilterController.getFilter());
}
}
- protected void updateFilterMenu(ContactListFilter filter) {
+ public void updateFilterMenu(ContactListFilter filter) {
clearCheckedMenus();
if (filter != null && filter.isContactsFilterType()) {
if (mIdMenuMap != null && mIdMenuMap.get(R.id.nav_all_contacts) != null) {
- mIdMenuMap.get(R.id.nav_all_contacts).setCheckable(true);
- mIdMenuMap.get(R.id.nav_all_contacts).setChecked(true);
- maybeUpdateScrollPosition(ALL_CONTACTS_POSITION);
+ setMenuChecked(mIdMenuMap.get(R.id.nav_all_contacts), true);
}
} else {
if (mFilterMenuMap != null && mFilterMenuMap.get(filter) != null) {
- mFilterMenuMap.get(filter).setCheckable(true);
- mFilterMenuMap.get(filter).setChecked(true);
- maybeUpdateScrollPosition(mFilterMenuMap.get(filter).getOrder());
+ setMenuChecked(mFilterMenuMap.get(filter), true);
}
}
}
- /**
- * Returns the current filter if the child class is PeopleActivity, and null otherwise.
- */
- protected ContactListFilter getContactListFilter() {
- return null;
+ protected void onFilterMenuItemClicked(Intent intent) {
+ AccountFilterUtil.handleAccountFilterResult(mContactListFilterController,
+ AppCompatActivity.RESULT_OK, intent);
}
- /**
- * Returns true if the child activity should finish after launching another activity.
- */
- protected abstract boolean shouldFinish();
-
@Override
public boolean onNavigationItemSelected(final MenuItem item) {
final int id = item.getItemId();
@@ -557,7 +548,10 @@
} else if (id == R.id.nav_all_contacts) {
switchToAllContacts();
} else if (id == R.id.nav_find_duplicates) {
- launchFindDuplicates();
+ if (!isDuplicatesView()) {
+ launchFindDuplicates();
+ updateMenuSelection(item);
+ }
} else if (item.getIntent() != null) {
ImplicitIntentsUtil.startActivityInApp(ContactsDrawerActivity.this,
item.getIntent());
@@ -574,7 +568,7 @@
private Intent createPreferenceIntent() {
final Intent intent = new Intent(this, ContactsPreferenceActivity.class);
intent.putExtra(ContactsPreferenceActivity.EXTRA_NEW_LOCAL_PROFILE,
- ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE);
+ CompactContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE);
intent.putExtra(ContactsPreferenceActivity.EXTRA_MODE_FULLY_EXPANDED,
QuickContactActivity.MODE_FULLY_EXPANDED);
intent.putExtra(ContactsPreferenceActivity.EXTRA_PREVIOUS_SCREEN_TYPE,
@@ -582,49 +576,51 @@
return intent;
}
- protected void switchToAllContacts() {
+ public void switchToAllContacts() {
+ resetFilter();
+
+ final Menu menu = mNavigationView.getMenu();
+ final MenuItem allContacts = menu.findItem(R.id.nav_all_contacts);
+ updateMenuSelection(allContacts);
+
+ setTitle(getString(R.string.contactsList));
+ }
+
+ protected void resetFilter() {
final Intent intent = new Intent();
- final ContactListFilter filter = createContactsFilter();
+ final ContactListFilter filter = AccountFilterUtil.createContactsFilter(this);
intent.putExtra(AccountFilterActivity.EXTRA_CONTACT_LIST_FILTER, filter);
AccountFilterUtil.handleAccountFilterResult(
mContactListFilterController, AppCompatActivity.RESULT_OK, intent);
- if (shouldFinish()) {
- finish();
- }
}
- protected void launchFindDuplicates() {
- ImplicitIntentsUtil.startActivityInAppIfPossible(this,
- Assistants.getDuplicatesActivityIntent(this));
- }
+ protected abstract void launchFindDuplicates();
- /**
- * Returns a {@link ContactListFilter} of type
- * {@link ContactListFilter#FILTER_TYPE_ALL_ACCOUNTS}, or if a custom "Contacts to display"
- * filter has been set, then one of type {@link ContactListFilter#FILTER_TYPE_CUSTOM}.
- */
- protected ContactListFilter createContactsFilter() {
- final int filterType =
- ContactListFilterController.getInstance(this).isCustomFilterPersisted()
- ? ContactListFilter.FILTER_TYPE_CUSTOM
- : ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS;
- return ContactListFilter.createFilterWithType(filterType);
- }
+ protected abstract DefaultContactBrowseListFragment getAllFragment();
+
+ protected abstract GroupMembersFragment getGroupFragment();
+
+ public abstract void showFabWithAnimation(boolean showFab);
private void clearCheckedMenus() {
clearCheckedMenu(mFilterMenuMap);
clearCheckedMenu(mGroupMenuMap);
clearCheckedMenu(mIdMenuMap);
}
+
private void clearCheckedMenu(Map<?, MenuItem> map) {
final Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
- Entry pair = (Entry)it.next();
- map.get(pair.getKey()).setCheckable(false);
- map.get(pair.getKey()).setChecked(false);
+ Entry pair = (Entry) it.next();
+ setMenuChecked(map.get(pair.getKey()), false);
}
}
+ private void setMenuChecked(MenuItem menuItem, boolean checked) {
+ menuItem.setCheckable(checked);
+ menuItem.setChecked(checked);
+ }
+
private void selectAccount() {
final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(this)
.getAccounts(/* writable */ true);
@@ -647,11 +643,17 @@
@Override
public void onAccountChosen(AccountWithDataSet account, Bundle extraArgs) {
mNewGroupAccount = account;
- GroupNameEditDialogFragment.newInstanceForCreation(mNewGroupAccount, ACTION_CREATE_GROUP)
+ GroupNameEditDialogFragment.newInstanceForCreation(
+ mNewGroupAccount, GroupUtil.ACTION_CREATE_GROUP)
.show(getFragmentManager(), TAG_GROUP_NAME_EDIT_DIALOG);
}
@Override
public void onAccountSelectorCancelled() {
}
+
+ private void updateMenuSelection(MenuItem menuItem) {
+ clearCheckedMenus();
+ setMenuChecked(menuItem, true);
+ }
}
diff --git a/src/com/android/contacts/GroupMetaDataLoader.java b/src/com/android/contacts/GroupMetaDataLoader.java
index 26cdb44..4c78c0c 100644
--- a/src/com/android/contacts/GroupMetaDataLoader.java
+++ b/src/com/android/contacts/GroupMetaDataLoader.java
@@ -64,7 +64,7 @@
if (groupUri == null) {
throw new IllegalArgumentException("Uri must not be null");
}
- if (!groupUri.toString().startsWith(Groups.CONTENT_URI.toString())) {
+ if (!GroupUtil.isGroupUri(groupUri)) {
throw new IllegalArgumentException("Invalid group Uri: " + groupUri);
}
return groupUri;
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index e046e71..824d4ea 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -20,11 +20,8 @@
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
@@ -69,41 +66,26 @@
void onAction(int action);
- /**
- * Called when the user selects a tab. The new tab can be obtained using
- * {@link #getCurrentTab}.
- */
- void onSelectedTabChanged();
-
void onUpButtonPressed();
}
private static final String EXTRA_KEY_SEARCH_MODE = "navBar.searchMode";
private static final String EXTRA_KEY_QUERY = "navBar.query";
- private static final String EXTRA_KEY_SELECTED_TAB = "navBar.selectedTab";
private static final String EXTRA_KEY_SELECTED_MODE = "navBar.selectionMode";
- private static final String PERSISTENT_LAST_TAB = "actionBarAdapter.lastTab";
-
private boolean mSelectionMode;
private boolean mSearchMode;
private String mQueryString;
private EditText mSearchView;
private View mClearSearchView;
- /** The view that represents tabs when we are in portrait mode **/
- private View mPortraitTabs;
- /** The view that represents tabs when we are in landscape mode **/
- private View mLandscapeTabs;
private View mSearchContainer;
private View mSelectionContainer;
- private int mMaxPortraitTabHeight;
private int mMaxToolbarContentInsetStart;
private int mActionBarAnimationDuration;
private final Activity mActivity;
- private final SharedPreferences mPrefs;
private Listener mListener;
@@ -122,29 +104,16 @@
private ValueAnimator mStatusBarAnimator;
- public interface TabState {
- public static int ALL = 0;
-
- public static int COUNT = 1;
- public static int DEFAULT = ALL;
- }
-
- private int mCurrentTab = TabState.DEFAULT;
-
public ActionBarAdapter(Activity activity, Listener listener, ActionBar actionBar,
- View portraitTabs, View landscapeTabs, Toolbar toolbar) {
- this(activity, listener, actionBar, portraitTabs, landscapeTabs, toolbar,
- R.string.hint_findContacts);
+ Toolbar toolbar) {
+ this(activity, listener, actionBar, toolbar, R.string.hint_findContacts);
}
public ActionBarAdapter(Activity activity, Listener listener, ActionBar actionBar,
- View portraitTabs, View landscapeTabs, Toolbar toolbar, int searchHintResId) {
+ Toolbar toolbar, int searchHintResId) {
mActivity = activity;
mListener = listener;
mActionBar = actionBar;
- mPrefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
- mPortraitTabs = portraitTabs;
- mLandscapeTabs = landscapeTabs;
mToolbar = toolbar;
mToolBarFrame = (FrameLayout) mToolbar.getParent();
mMaxToolbarContentInsetStart = mToolbar.getContentInsetStart();
@@ -153,7 +122,6 @@
mActivity.getResources().getInteger(R.integer.action_bar_animation_duration);
setupSearchAndSelectionViews();
- setupTabs(mActivity);
}
public void setShowHomeIcon(boolean showHomeIcon) {
@@ -164,22 +132,10 @@
mShowHomeAsUp = showHomeAsUp;
}
- public EditText getSearchView() {
- return mSearchView;
- }
-
public View getSelectionContainer() {
return mSelectionContainer;
}
- private void setupTabs(Context context) {
- final TypedArray attributeArray = context.obtainStyledAttributes(
- new int[]{android.R.attr.actionBarSize});
- mMaxPortraitTabHeight = attributeArray.getDimensionPixelSize(0, 0);
- // Hide tabs initially
- setPortraitTabHeight(0);
- }
-
private void setupSearchAndSelectionViews() {
final LayoutInflater inflater = (LayoutInflater) mToolbar.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
@@ -234,19 +190,11 @@
if (savedState == null) {
mSearchMode = request.isSearchMode();
mQueryString = request.getQueryString();
- mCurrentTab = loadLastTabPreference();
mSelectionMode = false;
} else {
mSearchMode = savedState.getBoolean(EXTRA_KEY_SEARCH_MODE);
mSelectionMode = savedState.getBoolean(EXTRA_KEY_SELECTED_MODE);
mQueryString = savedState.getString(EXTRA_KEY_QUERY);
-
- // Just set to the field here. The listener will be notified by update().
- mCurrentTab = savedState.getInt(EXTRA_KEY_SELECTED_TAB);
- }
- if (mCurrentTab >= TabState.COUNT || mCurrentTab < 0) {
- // Invalid tab index was saved (b/12938207). Restore the default.
- mCurrentTab = TabState.DEFAULT;
}
// Show tabs or the expanded {@link SearchView}, depending on whether or not we are in
// search mode.
@@ -289,30 +237,6 @@
}
/**
- * Save the current tab selection, and notify the listener.
- */
- public void setCurrentTab(int tab) {
- setCurrentTab(tab, true);
- }
-
- /**
- * Save the current tab selection.
- */
- public void setCurrentTab(int tab, boolean notifyListener) {
- if (tab == mCurrentTab) {
- return;
- }
- mCurrentTab = tab;
-
- if (notifyListener && mListener != null) mListener.onSelectedTabChanged();
- saveLastTabPreference(mCurrentTab);
- }
-
- public int getCurrentTab() {
- return mCurrentTab;
- }
-
- /**
* @return Whether in search mode, i.e. if the search view is visible/expanded.
*
* Note even if the action bar is in search mode, if the query is empty, the search fragment
@@ -448,18 +372,12 @@
// to adding the desired container.
if (skipAnimation || isSwitchingFromSearchToSelection) {
if (isTabHeightChanging || isSwitchingFromSearchToSelection) {
- mToolbar.removeView(mLandscapeTabs);
mToolbar.removeView(mSearchContainer);
mToolBarFrame.removeView(mSelectionContainer);
if (mSelectionMode) {
- setPortraitTabHeight(0);
addSelectionContainer();
} else if (mSearchMode) {
- setPortraitTabHeight(0);
addSearchContainer();
- } else {
- setPortraitTabHeight(mMaxPortraitTabHeight);
- addLandscapeViewPagerTabs();
}
updateDisplayOptions(isSearchModeChanging);
}
@@ -468,25 +386,21 @@
// Handle a switch to/from selection mode, due to UI interaction.
if (isSelectionModeChanging) {
- mToolbar.removeView(mLandscapeTabs);
if (mSelectionMode) {
addSelectionContainer();
mSelectionContainer.setAlpha(0);
mSelectionContainer.animate().alpha(1).setDuration(mActionBarAnimationDuration);
- animateTabHeightChange(mMaxPortraitTabHeight, 0);
updateDisplayOptions(isSearchModeChanging);
} else {
if (mListener != null) {
mListener.onAction(Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE);
}
mSelectionContainer.setAlpha(1);
- animateTabHeightChange(0, mMaxPortraitTabHeight);
mSelectionContainer.animate().alpha(0).setDuration(mActionBarAnimationDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
updateDisplayOptions(isSearchModeChanging);
- addLandscapeViewPagerTabs();
mToolBarFrame.removeView(mSelectionContainer);
}
});
@@ -495,22 +409,18 @@
// Handle a switch to/from search mode, due to UI interaction.
if (isSearchModeChanging) {
- mToolbar.removeView(mLandscapeTabs);
if (mSearchMode) {
addSearchContainer();
mSearchContainer.setAlpha(0);
mSearchContainer.animate().alpha(1).setDuration(mActionBarAnimationDuration);
- animateTabHeightChange(mMaxPortraitTabHeight, 0);
updateDisplayOptions(isSearchModeChanging);
} else {
mSearchContainer.setAlpha(1);
- animateTabHeightChange(0, mMaxPortraitTabHeight);
mSearchContainer.animate().alpha(0).setDuration(mActionBarAnimationDuration)
.withEndAction(new Runnable() {
@Override
public void run() {
updateDisplayOptions(isSearchModeChanging);
- addLandscapeViewPagerTabs();
mToolbar.removeView(mSearchContainer);
}
});
@@ -584,9 +494,8 @@
mActivity, R.color.contextual_selection_bar_status_bar_color);
runStatusBarAnimation(/* colorTo */ cabStatusBarColor);
} else {
- final int normalStatusBarColor = mActivity instanceof GroupMembersActivity
- ? ContextCompat.getColor(mActivity, R.color.group_primary_color_dark)
- : ContextCompat.getColor(mActivity, R.color.primary_color_dark);
+ final int normalStatusBarColor = ContextCompat.getColor(
+ mActivity, R.color.primary_color_dark);
if (shouldAnimate) {
runStatusBarAnimation(/* colorTo */ normalStatusBarColor);
} else {
@@ -618,13 +527,6 @@
}
}
- private void addLandscapeViewPagerTabs() {
- if (mLandscapeTabs != null) {
- mToolbar.removeView(mLandscapeTabs);
- mToolbar.addView(mLandscapeTabs);
- }
- }
-
private void addSearchContainer() {
mToolbar.removeView(mSearchContainer);
mToolbar.addView(mSearchContainer);
@@ -659,7 +561,6 @@
}
if (!mSearchMode && !mSelectionMode) {
mListener.onAction(Action.STOP_SEARCH_AND_SELECTION_MODE);
- mListener.onSelectedTabChanged();
}
}
updateDisplayOptionsInner();
@@ -675,7 +576,6 @@
outState.putBoolean(EXTRA_KEY_SEARCH_MODE, mSearchMode);
outState.putBoolean(EXTRA_KEY_SELECTED_MODE, mSelectionMode);
outState.putString(EXTRA_KEY_QUERY, mQueryString);
- outState.putInt(EXTRA_KEY_SELECTED_TAB, mCurrentTab);
}
public void setFocusOnSearchView() {
@@ -690,41 +590,4 @@
imm.showSoftInput(view, 0);
}
}
-
- private void saveLastTabPreference(int tab) {
- mPrefs.edit().putInt(PERSISTENT_LAST_TAB, tab).apply();
- }
-
- private int loadLastTabPreference() {
- try {
- return mPrefs.getInt(PERSISTENT_LAST_TAB, TabState.DEFAULT);
- } catch (IllegalArgumentException e) {
- // Preference is corrupt?
- return TabState.DEFAULT;
- }
- }
-
- private void animateTabHeightChange(int start, int end) {
- if (mPortraitTabs == null) {
- return;
- }
- final ValueAnimator animator = ValueAnimator.ofInt(start, end);
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- int value = (Integer) valueAnimator.getAnimatedValue();
- setPortraitTabHeight(value);
- }
- });
- animator.setDuration(100).start();
- }
-
- private void setPortraitTabHeight(int height) {
- if (mPortraitTabs == null) {
- return;
- }
- ViewGroup.LayoutParams layoutParams = mPortraitTabs.getLayoutParams();
- layoutParams.height = height;
- mPortraitTabs.setLayoutParams(layoutParams);
- }
}
diff --git a/src/com/android/contacts/activities/CompactContactEditorActivity.java b/src/com/android/contacts/activities/CompactContactEditorActivity.java
index dc16049..3778400 100644
--- a/src/com/android/contacts/activities/CompactContactEditorActivity.java
+++ b/src/com/android/contacts/activities/CompactContactEditorActivity.java
@@ -16,18 +16,35 @@
package com.android.contacts.activities;
+import com.android.contacts.ContactSaveService;
+import com.android.contacts.ContactsActivity;
import com.android.contacts.R;
import com.android.contacts.common.activity.RequestPermissionsActivity;
+import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.RawContactDeltaList;
+import com.android.contacts.common.model.account.AccountType;
+import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.detail.PhotoSelectionHandler;
import com.android.contacts.editor.CompactContactEditorFragment;
import com.android.contacts.editor.CompactPhotoSelectionFragment;
+import com.android.contacts.editor.EditorIntents;
import com.android.contacts.editor.PhotoSourceDialogFragment;
+import com.android.contacts.interactions.ContactDeletionInteraction;
+import com.android.contacts.util.DialogManager;
+import android.app.ActionBar;
+import android.app.Dialog;
import android.app.FragmentTransaction;
+import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.RawContacts;
+import android.util.Log;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
import java.io.FileNotFoundException;
import java.util.ArrayList;
@@ -35,8 +52,26 @@
/**
* Contact editor with only the most important fields displayed initially.
*/
-public class CompactContactEditorActivity extends ContactEditorBaseActivity implements
- PhotoSourceDialogFragment.Listener, CompactPhotoSelectionFragment.Listener {
+public class CompactContactEditorActivity extends ContactsActivity implements
+ PhotoSourceDialogFragment.Listener, CompactPhotoSelectionFragment.Listener,
+ DialogManager.DialogShowingViewActivity {
+ private static final String TAG = "ContactEditorActivity";
+
+ public static final String ACTION_JOIN_COMPLETED = "joinCompleted";
+ public static final String ACTION_SAVE_COMPLETED = "saveCompleted";
+
+ public static final int RESULT_CODE_SPLIT = 2;
+ // 3 used for ContactDeletionInteraction.RESULT_CODE_DELETED
+ public static final int RESULT_CODE_EDITED = 4;
+
+ /**
+ * The contact will be saved to the device local account when this is set for an insert. This
+ * is necessary because {@link android.accounts.Account} cannot be created with null values
+ * for the name and type and an Account is needed for
+ * {@link android.provider.ContactsContract.Intents.Insert#EXTRA_ACCOUNT}
+ */
+ public static final String EXTRA_SAVE_TO_DEVICE_FLAG =
+ "com.android.contacts.SAVE_TO_DEVICE_FLAG";
private static final String TAG_COMPACT_EDITOR = "compact_editor";
private static final String TAG_PHOTO_SELECTION = "photo_selector";
@@ -47,6 +82,123 @@
private static final String STATE_PHOTO_URI = "photo_uri";
/**
+ * Boolean intent key that specifies that this activity should finish itself
+ * (instead of launching a new view intent) after the editor changes have been
+ * saved.
+ */
+ public static final String INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED =
+ "finishActivityOnSaveCompleted";
+
+ /**
+ * Contract for contact editors Fragments that are managed by this Activity.
+ */
+ public interface ContactEditor {
+
+ /**
+ * Modes that specify what the AsyncTask has to perform after saving
+ */
+ interface SaveMode {
+ /**
+ * Close the editor after saving
+ */
+ int CLOSE = 0;
+
+ /**
+ * Reload the data so that the user can continue editing
+ */
+ int RELOAD = 1;
+
+ /**
+ * Split the contact after saving
+ */
+ int SPLIT = 2;
+
+ /**
+ * Join another contact after saving
+ */
+ int JOIN = 3;
+
+ /**
+ * Navigate to the compact editor view after saving.
+ */
+ int COMPACT = 4;
+ }
+
+ /**
+ * The status of the contact editor.
+ */
+ interface Status {
+ /**
+ * The loader is fetching data
+ */
+ int LOADING = 0;
+
+ /**
+ * Not currently busy. We are waiting for the user to enter data
+ */
+ int EDITING = 1;
+
+ /**
+ * The data is currently being saved. This is used to prevent more
+ * auto-saves (they shouldn't overlap)
+ */
+ int SAVING = 2;
+
+ /**
+ * Prevents any more saves. This is used if in the following cases:
+ * - After Save/Close
+ * - After Revert
+ * - After the user has accepted an edit suggestion
+ * - After the user chooses to expand the compact editor
+ */
+ int CLOSING = 3;
+
+ /**
+ * Prevents saving while running a child activity.
+ */
+ int SUB_ACTIVITY = 4;
+ }
+
+ /**
+ * Sets the hosting Activity that will receive callbacks from the contact editor.
+ */
+ void setListener(CompactContactEditorFragment.Listener listener);
+
+ /**
+ * Initialize the contact editor.
+ */
+ void load(String action, Uri lookupUri, Bundle intentExtras);
+
+ /**
+ * Applies extras from the hosting Activity to the first writable raw contact.
+ */
+ void setIntentExtras(Bundle extras);
+
+ /**
+ * Saves or creates the contact based on the mode, and if successful
+ * finishes the activity.
+ */
+ boolean save(int saveMode);
+
+ /**
+ * If there are no unsaved changes, just close the editor, otherwise the user is prompted
+ * before discarding unsaved changes.
+ */
+ boolean revert();
+
+ /**
+ * Invoked after the contact is saved.
+ */
+ void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
+ Uri contactLookupUri, Long joinContactId);
+
+ /**
+ * Invoked after the contact is joined.
+ */
+ void onJoinCompleted(Uri uri);
+ }
+
+ /**
* Displays a PopupWindow with photo edit options.
*/
private final class CompactPhotoSelectionHandler extends PhotoSelectionHandler {
@@ -118,12 +270,116 @@
}
}
+ private int mActionBarTitleResId;
+ private ContactEditor mFragment;
+ private boolean mFinishActivityOnSaveCompleted;
+ private DialogManager mDialogManager = new DialogManager(this);
+
private CompactPhotoSelectionFragment mPhotoSelectionFragment;
private CompactPhotoSelectionHandler mPhotoSelectionHandler;
private Uri mPhotoUri;
private int mPhotoMode;
private boolean mIsPhotoSelection;
+ private final CompactContactEditorFragment.Listener mFragmentListener =
+ new CompactContactEditorFragment.Listener() {
+
+ @Override
+ public void onDeleteRequested(Uri contactUri) {
+ ContactDeletionInteraction.start(
+ CompactContactEditorActivity.this, contactUri, true);
+ }
+
+ @Override
+ public void onReverted() {
+ finish();
+ }
+
+ @Override
+ public void onSaveFinished(Intent resultIntent) {
+ if (mFinishActivityOnSaveCompleted) {
+ setResult(resultIntent == null ? RESULT_CANCELED : RESULT_OK, resultIntent);
+ } else if (resultIntent != null) {
+ ImplicitIntentsUtil.startActivityInApp(
+ CompactContactEditorActivity.this, resultIntent);
+ }
+ finish();
+ }
+
+ @Override
+ public void onContactSplit(Uri newLookupUri) {
+ setResult(RESULT_CODE_SPLIT, /* data */ null);
+ finish();
+ }
+
+ @Override
+ public void onContactNotFound() {
+ finish();
+ }
+
+ @Override
+ public void onEditOtherContactRequested(
+ Uri contactLookupUri, ArrayList<ContentValues> values) {
+ final Intent intent = EditorIntents.createEditOtherContactIntent(
+ CompactContactEditorActivity.this, contactLookupUri, values);
+ ImplicitIntentsUtil.startActivityInApp(
+ CompactContactEditorActivity.this, intent);
+ finish();
+ }
+
+ @Override
+ public void onCustomCreateContactActivityRequested(AccountWithDataSet account,
+ Bundle intentExtras) {
+ final AccountTypeManager accountTypes =
+ AccountTypeManager.getInstance(CompactContactEditorActivity.this);
+ final AccountType accountType = accountTypes.getAccountType(
+ account.type, account.dataSet);
+
+ Intent intent = new Intent();
+ intent.setClassName(accountType.syncAdapterPackageName,
+ accountType.getCreateContactActivityClassName());
+ intent.setAction(Intent.ACTION_INSERT);
+ intent.setType(Contacts.CONTENT_ITEM_TYPE);
+ if (intentExtras != null) {
+ intent.putExtras(intentExtras);
+ }
+ intent.putExtra(RawContacts.ACCOUNT_NAME, account.name);
+ intent.putExtra(RawContacts.ACCOUNT_TYPE, account.type);
+ intent.putExtra(RawContacts.DATA_SET, account.dataSet);
+ intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
+ | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+ startActivity(intent);
+ finish();
+ }
+
+ @Override
+ public void onCustomEditContactActivityRequested(AccountWithDataSet account,
+ Uri rawContactUri, Bundle intentExtras, boolean redirect) {
+ final AccountTypeManager accountTypes =
+ AccountTypeManager.getInstance(CompactContactEditorActivity.this);
+ final AccountType accountType = accountTypes.getAccountType(
+ account.type, account.dataSet);
+
+ Intent intent = new Intent();
+ intent.setClassName(accountType.syncAdapterPackageName,
+ accountType.getEditContactActivityClassName());
+ intent.setAction(Intent.ACTION_EDIT);
+ intent.setData(rawContactUri);
+ if (intentExtras != null) {
+ intent.putExtras(intentExtras);
+ }
+
+ if (redirect) {
+ intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
+ | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+ startActivity(intent);
+ finish();
+ } else {
+ startActivity(intent);
+ }
+ }
+ };
+
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
@@ -132,6 +388,41 @@
return;
}
+ final Intent intent = getIntent();
+ final String action = intent.getAction();
+
+ // Determine whether or not this activity should be finished after the user is done
+ // editing the contact or if this activity should launch another activity to view the
+ // contact's details.
+ mFinishActivityOnSaveCompleted = intent.getBooleanExtra(
+ INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, false);
+
+ // The only situation where action could be ACTION_JOIN_COMPLETED is if the
+ // user joined the contact with another and closed the activity before
+ // the save operation was completed. The activity should remain closed then.
+ if (ACTION_JOIN_COMPLETED.equals(action)) {
+ finish();
+ return;
+ }
+
+ if (ACTION_SAVE_COMPLETED.equals(action)) {
+ finish();
+ return;
+ }
+
+ final ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ if (Intent.ACTION_EDIT.equals(action)) {
+ mActionBarTitleResId = R.string.contact_editor_title_existing_contact;
+ } else {
+ mActionBarTitleResId = R.string.contact_editor_title_new_contact;
+ }
+ actionBar.setTitle(getResources().getString(mActionBarTitleResId));
+ actionBar.setDisplayShowHomeEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeAsUpIndicator(R.drawable.ic_close_dk);
+ }
+
setContentView(R.layout.compact_contact_editor_activity);
if (savedState == null) {
@@ -171,11 +462,58 @@
mPhotoSelectionFragment.setListener(this);
// Load editor data (even if it's hidden)
- final String action = getIntent().getAction();
final Uri uri = Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
mFragment.load(action, uri, getIntent().getExtras());
}
+ @Override
+ protected void onPause() {
+ super.onPause();
+ final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
+ final View currentFocus = getCurrentFocus();
+ if (imm != null && currentFocus != null) {
+ imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
+ }
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+
+ if (mFragment == null) {
+ return;
+ }
+
+ final String action = intent.getAction();
+ if (Intent.ACTION_EDIT.equals(action)) {
+ mFragment.setIntentExtras(intent.getExtras());
+ } else if (ACTION_SAVE_COMPLETED.equals(action)) {
+ mFragment.onSaveCompleted(true,
+ intent.getIntExtra(CompactContactEditorFragment.SAVE_MODE_EXTRA_KEY,
+ ContactEditor.SaveMode.CLOSE),
+ intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
+ intent.getData(),
+ intent.getLongExtra(CompactContactEditorFragment.JOIN_CONTACT_ID_EXTRA_KEY, -1));
+ } else if (ACTION_JOIN_COMPLETED.equals(action)) {
+ mFragment.onJoinCompleted(intent.getData());
+ }
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id, Bundle args) {
+ if (DialogManager.isManagedId(id)) return mDialogManager.onCreateDialog(id, args);
+
+ // Nobody knows about the Dialog
+ Log.w(TAG, "Unknown dialog requested, id: " + id + ", args: " + args);
+ return null;
+ }
+
+ @Override
+ public DialogManager getDialogManager() {
+ return mDialogManager;
+ }
+
+ @Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
@@ -201,8 +539,8 @@
if (mIsPhotoSelection) {
mIsPhotoSelection = false;
showEditorFragment();
- } else {
- super.onBackPressed();
+ } else if (mFragment != null) {
+ mFragment.revert();
}
}
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
deleted file mode 100644
index 293e8c0..0000000
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.activities;
-
-import com.android.contacts.R;
-import com.android.contacts.common.activity.RequestPermissionsActivity;
-import com.android.contacts.editor.ContactEditorFragment;
-import com.android.contacts.util.DialogManager;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-
-/**
- * Contact editor with all fields displayed.
- */
-public class ContactEditorActivity extends ContactEditorBaseActivity
- implements DialogManager.DialogShowingViewActivity {
-
- @Override
- public void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- if (RequestPermissionsActivity.startPermissionActivity(this)) {
- return;
- }
-
- setContentView(R.layout.contact_editor_activity);
-
- mFragment = (ContactEditorFragment) getFragmentManager().findFragmentById(
- R.id.contact_editor_fragment);
- mFragment.setListener(mFragmentListener);
-
- final String action = getIntent().getAction();
- final Uri uri = ContactEditorBaseActivity.ACTION_EDIT.equals(action)
- || Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
- mFragment.load(action, uri, getIntent().getExtras());
- }
-}
diff --git a/src/com/android/contacts/activities/ContactEditorBaseActivity.java b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
deleted file mode 100644
index 55fcddb..0000000
--- a/src/com/android/contacts/activities/ContactEditorBaseActivity.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.activities;
-
-import android.app.ActionBar;
-import android.app.Dialog;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.RawContacts;
-import android.util.Log;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-
-import com.android.contacts.ContactSaveService;
-import com.android.contacts.ContactsActivity;
-import com.android.contacts.R;
-import com.android.contacts.common.model.AccountTypeManager;
-import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.common.util.ImplicitIntentsUtil;
-import com.android.contacts.editor.ContactEditorBaseFragment;
-import com.android.contacts.editor.ContactEditorFragment;
-import com.android.contacts.editor.EditorIntents;
-import com.android.contacts.interactions.ContactDeletionInteraction;
-import com.android.contacts.util.DialogManager;
-
-import java.util.ArrayList;
-
-/**
- * Base Activity for contact editors.
- */
-abstract public class ContactEditorBaseActivity extends ContactsActivity
- implements DialogManager.DialogShowingViewActivity {
- protected static final String TAG = "ContactEditorActivity";
-
- /**
- * Intent action to edit a contact with all available field inputs displayed.
- *
- * Only used to open the "fully expanded" editor -- {@link ContactEditorActivity}.
- */
- public static final String ACTION_EDIT = "com.android.contacts.action.FULL_EDIT";
-
- /**
- * Intent action to insert a new contact with all available field inputs displayed.
- *
- * Only used to open the "fully expanded" editor -- {@link ContactEditorActivity}.
- */
- public static final String ACTION_INSERT = "com.android.contacts.action.FULL_INSERT";
-
- public static final String ACTION_JOIN_COMPLETED = "joinCompleted";
- public static final String ACTION_SAVE_COMPLETED = "saveCompleted";
-
- public static final int RESULT_CODE_SPLIT = 2;
- // 3 used for ContactDeletionInteraction.RESULT_CODE_DELETED
- public static final int RESULT_CODE_EDITED = 4;
-
- /**
- * The contact will be saved to the device local account when this is set for an insert. This
- * is necessary because {@link android.accounts.Account} cannot be created with null values
- * for the name and type and an Account is needed for
- * {@link android.provider.ContactsContract.Intents.Insert#EXTRA_ACCOUNT}
- */
- public static final String EXTRA_SAVE_TO_DEVICE_FLAG =
- "com.android.contacts.SAVE_TO_DEVICE_FLAG";
-
-
- protected int mActionBarTitleResId;
-
- /**
- * Contract for contact editors Fragments that are managed by this Activity.
- */
- public interface ContactEditor {
-
- /**
- * Modes that specify what the AsyncTask has to perform after saving
- */
- public interface SaveMode {
- /**
- * Close the editor after saving
- */
- public static final int CLOSE = 0;
-
- /**
- * Reload the data so that the user can continue editing
- */
- public static final int RELOAD = 1;
-
- /**
- * Split the contact after saving
- */
- public static final int SPLIT = 2;
-
- /**
- * Join another contact after saving
- */
- public static final int JOIN = 3;
-
- /**
- * Navigate to the compact editor view after saving.
- */
- public static final int COMPACT = 4;
- }
-
- /**
- * The status of the contact editor.
- */
- public interface Status {
- /**
- * The loader is fetching data
- */
- public static final int LOADING = 0;
-
- /**
- * Not currently busy. We are waiting for the user to enter data
- */
- public static final int EDITING = 1;
-
- /**
- * The data is currently being saved. This is used to prevent more
- * auto-saves (they shouldn't overlap)
- */
- public static final int SAVING = 2;
-
- /**
- * Prevents any more saves. This is used if in the following cases:
- * - After Save/Close
- * - After Revert
- * - After the user has accepted an edit suggestion
- * - After the user chooses to expand the compact editor
- */
- public static final int CLOSING = 3;
-
- /**
- * Prevents saving while running a child activity.
- */
- public static final int SUB_ACTIVITY = 4;
- }
-
- /**
- * Sets the hosting Activity that will receive callbacks from the contact editor.
- */
- void setListener(ContactEditorBaseFragment.Listener listener);
-
- /**
- * Initialize the contact editor.
- */
- void load(String action, Uri lookupUri, Bundle intentExtras);
-
- /**
- * Applies extras from the hosting Activity to the first writable raw contact.
- */
- void setIntentExtras(Bundle extras);
-
- /**
- * Saves or creates the contact based on the mode, and if successful
- * finishes the activity.
- */
- boolean save(int saveMode);
-
- /**
- * If there are no unsaved changes, just close the editor, otherwise the user is prompted
- * before discarding unsaved changes.
- */
- boolean revert();
-
- /**
- * Invoked after the contact is saved.
- */
- void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
- Uri contactLookupUri, Long joinContactId);
-
- /**
- * Invoked after the contact is joined.
- */
- void onJoinCompleted(Uri uri);
- }
-
- /**
- * Boolean intent key that specifies that this activity should finish itself
- * (instead of launching a new view intent) after the editor changes have been
- * saved.
- */
- public static final String INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED =
- "finishActivityOnSaveCompleted";
-
- protected ContactEditor mFragment;
- private boolean mFinishActivityOnSaveCompleted;
-
- private DialogManager mDialogManager = new DialogManager(this);
-
- @Override
- public void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- final Intent intent = getIntent();
- final String action = intent.getAction();
-
- // Determine whether or not this activity should be finished after the user is done
- // editing the contact or if this activity should launch another activity to view the
- // contact's details.
- mFinishActivityOnSaveCompleted = intent.getBooleanExtra(
- INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, false);
-
- // The only situation where action could be ACTION_JOIN_COMPLETED is if the
- // user joined the contact with another and closed the activity before
- // the save operation was completed. The activity should remain closed then.
- if (ACTION_JOIN_COMPLETED.equals(action)) {
- finish();
- return;
- }
-
- if (ACTION_SAVE_COMPLETED.equals(action)) {
- finish();
- return;
- }
-
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- if (Intent.ACTION_EDIT.equals(action) || ACTION_EDIT.equals(action)) {
- mActionBarTitleResId = R.string.contact_editor_title_existing_contact;
- } else {
- mActionBarTitleResId = R.string.contact_editor_title_new_contact;
- }
- actionBar.setTitle(getResources().getString(mActionBarTitleResId));
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeAsUpIndicator(R.drawable.ic_close_dk);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
- final View currentFocus = getCurrentFocus();
- if (imm != null && currentFocus != null) {
- imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
- }
- }
-
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
-
- if (mFragment == null) {
- return;
- }
-
- String action = intent.getAction();
- if (Intent.ACTION_EDIT.equals(action) || ACTION_EDIT.equals(action)) {
- mFragment.setIntentExtras(intent.getExtras());
- } else if (ACTION_SAVE_COMPLETED.equals(action)) {
- mFragment.onSaveCompleted(true,
- intent.getIntExtra(ContactEditorFragment.SAVE_MODE_EXTRA_KEY,
- ContactEditor.SaveMode.CLOSE),
- intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
- intent.getData(),
- intent.getLongExtra(ContactEditorFragment.JOIN_CONTACT_ID_EXTRA_KEY, -1));
- } else if (ACTION_JOIN_COMPLETED.equals(action)) {
- mFragment.onJoinCompleted(intent.getData());
- }
- }
-
- @Override
- protected Dialog onCreateDialog(int id, Bundle args) {
- if (DialogManager.isManagedId(id)) return mDialogManager.onCreateDialog(id, args);
-
- // Nobody knows about the Dialog
- Log.w(TAG, "Unknown dialog requested, id: " + id + ", args: " + args);
- return null;
- }
-
- @Override
- public void onBackPressed() {
- if (mFragment != null) {
- mFragment.revert();
- }
- }
-
- protected final ContactEditorBaseFragment.Listener mFragmentListener =
- new ContactEditorBaseFragment.Listener() {
-
- @Override
- public void onDeleteRequested(Uri contactUri) {
- ContactDeletionInteraction.start(ContactEditorBaseActivity.this, contactUri, true);
- }
-
- @Override
- public void onReverted() {
- finish();
- }
-
- @Override
- public void onSaveFinished(Intent resultIntent) {
- if (mFinishActivityOnSaveCompleted) {
- setResult(resultIntent == null ? RESULT_CANCELED : RESULT_OK, resultIntent);
- } else if (resultIntent != null) {
- ImplicitIntentsUtil.startActivityInApp(ContactEditorBaseActivity.this,
- resultIntent);
- }
- finish();
- }
-
- @Override
- public void onContactSplit(Uri newLookupUri) {
- setResult(RESULT_CODE_SPLIT, /* data */ null);
- finish();
- }
-
- @Override
- public void onContactNotFound() {
- finish();
- }
-
- @Override
- public void onEditOtherContactRequested(
- Uri contactLookupUri, ArrayList<ContentValues> values) {
- final Intent intent = EditorIntents.createEditOtherContactIntent(
- ContactEditorBaseActivity.this, contactLookupUri, values);
- ImplicitIntentsUtil.startActivityInApp(ContactEditorBaseActivity.this, intent);
- finish();
- }
-
- @Override
- public void onCustomCreateContactActivityRequested(AccountWithDataSet account,
- Bundle intentExtras) {
- final AccountTypeManager accountTypes =
- AccountTypeManager.getInstance(ContactEditorBaseActivity.this);
- final AccountType accountType = accountTypes.getAccountType(
- account.type, account.dataSet);
-
- Intent intent = new Intent();
- intent.setClassName(accountType.syncAdapterPackageName,
- accountType.getCreateContactActivityClassName());
- intent.setAction(Intent.ACTION_INSERT);
- intent.setType(Contacts.CONTENT_ITEM_TYPE);
- if (intentExtras != null) {
- intent.putExtras(intentExtras);
- }
- intent.putExtra(RawContacts.ACCOUNT_NAME, account.name);
- intent.putExtra(RawContacts.ACCOUNT_TYPE, account.type);
- intent.putExtra(RawContacts.DATA_SET, account.dataSet);
- intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- startActivity(intent);
- finish();
- }
-
- @Override
- public void onCustomEditContactActivityRequested(AccountWithDataSet account,
- Uri rawContactUri, Bundle intentExtras, boolean redirect) {
- final AccountTypeManager accountTypes =
- AccountTypeManager.getInstance(ContactEditorBaseActivity.this);
- final AccountType accountType = accountTypes.getAccountType(
- account.type, account.dataSet);
-
- Intent intent = new Intent();
- intent.setClassName(accountType.syncAdapterPackageName,
- accountType.getEditContactActivityClassName());
- intent.setAction(Intent.ACTION_EDIT);
- intent.setData(rawContactUri);
- if (intentExtras != null) {
- intent.putExtras(intentExtras);
- }
-
- if (redirect) {
- intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- startActivity(intent);
- finish();
- } else {
- startActivity(intent);
- }
- }
- };
-
- @Override
- public DialogManager getDialogManager() {
- return mDialogManager;
- }
-}
diff --git a/src/com/android/contacts/activities/ContactSelectionActivity.java b/src/com/android/contacts/activities/ContactSelectionActivity.java
index 46e5d9c..d34ebc6 100644
--- a/src/com/android/contacts/activities/ContactSelectionActivity.java
+++ b/src/com/android/contacts/activities/ContactSelectionActivity.java
@@ -146,8 +146,7 @@
// Add a shadow under the toolbar.
ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());
- mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
- /* portraitTabs */ null, /* landscapeTabs */ null, mToolbar,
+ mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(), mToolbar,
R.string.enter_contact_name);
mActionBarAdapter.setShowHomeIcon(true);
mActionBarAdapter.setShowHomeAsUp(true);
@@ -436,10 +435,6 @@
}
@Override
- public void onSelectedTabChanged() {
- }
-
- @Override
public void onUpButtonPressed() {
onBackPressed();
}
@@ -493,7 +488,7 @@
@Override
public void onEditContactAction(Uri contactLookupUri) {
- startActivityAndForwardResult(EditorIntents.createEditContactIntent(
+ startActivityAndForwardResult(EditorIntents.createCompactEditContactIntent(
ContactSelectionActivity.this, contactLookupUri, /* materialPalette =*/ null,
/* photoId =*/ -1));
}
@@ -658,7 +653,8 @@
private void startCreateNewContactActivity() {
Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
- intent.putExtra(ContactEditorActivity.INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, true);
+ intent.putExtra(CompactContactEditorActivity.
+ INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, true);
startActivityAndForwardResult(intent);
}
diff --git a/src/com/android/contacts/activities/GroupMembersActivity.java b/src/com/android/contacts/activities/GroupMembersActivity.java
deleted file mode 100644
index 758481e..0000000
--- a/src/com/android/contacts/activities/GroupMembersActivity.java
+++ /dev/null
@@ -1,618 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.contacts.activities;
-
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.drawable.ColorDrawable;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.provider.ContactsContract.RawContacts;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.view.GravityCompat;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.FrameLayout;
-import android.widget.Toast;
-
-import com.android.contacts.ContactSaveService;
-import com.android.contacts.ContactsDrawerActivity;
-import com.android.contacts.R;
-import com.android.contacts.common.logging.ListEvent;
-import com.android.contacts.common.logging.Logger;
-import com.android.contacts.common.logging.ScreenEvent.ScreenType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.common.util.ImplicitIntentsUtil;
-import com.android.contacts.group.GroupMembersFragment;
-import com.android.contacts.group.GroupMetadata;
-import com.android.contacts.group.GroupNameEditDialogFragment;
-import com.android.contacts.group.GroupUtil;
-import com.android.contacts.interactions.GroupDeletionDialogFragment;
-import com.android.contacts.list.ContactsRequest;
-import com.android.contacts.list.MultiSelectContactsListFragment;
-import com.android.contacts.list.UiIntentActions;
-import com.android.contacts.quickcontact.QuickContactActivity;
-
-/**
- * Displays the members of a group and allows the user to edit it.
- */
-public class GroupMembersActivity extends ContactsDrawerActivity implements
- ActionBarAdapter.Listener,
- MultiSelectContactsListFragment.OnCheckBoxListActionListener,
- GroupMembersFragment.GroupMembersListener {
-
- private static final String TAG = "GroupMembers";
-
- private static final String KEY_GROUP_URI = "groupUri";
- private static final String KEY_GROUP_METADATA = "groupMetadata";
- private static final String KEY_IS_EDIT_MODE = "editMode";
-
- private static final String TAG_GROUP_MEMBERS = "groupMembers";
- private static final String TAG_GROUP_NAME_EDIT_DIALOG = "groupNameEditDialog";
-
- private static final String ACTION_DELETE_GROUP = "deleteGroup";
- private static final String ACTION_UPDATE_GROUP = "updateGroup";
- private static final String ACTION_ADD_TO_GROUP = "addToGroup";
- private static final String ACTION_REMOVE_FROM_GROUP = "removeFromGroup";
-
- private static final int RESULT_GROUP_ADD_MEMBER = 100;
-
- /**
- * Starts an Intent to add/remove the raw contacts for the given contact IDs to/from a group.
- * Only the raw contacts that belong to the specified account are added or removed.
- */
- private static class UpdateGroupMembersAsyncTask extends AsyncTask<Void, Void, Intent> {
-
- static final int TYPE_ADD = 0;
- static final int TYPE_REMOVE = 1;
-
- private final Context mContext;
- private final int mType;
- private final long[] mContactIds;
- private final long mGroupId;
- private final String mAccountName;
- private final String mAccountType;
-
- private UpdateGroupMembersAsyncTask(int type, Context context, long[] contactIds,
- long groupId, String accountName, String accountType) {
- mContext = context;
- mType = type;
- mContactIds = contactIds;
- mGroupId = groupId;
- mAccountName = accountName;
- mAccountType = accountType;
- }
-
- @Override
- protected Intent doInBackground(Void... params) {
- final long[] rawContactIds = getRawContactIds();
- if (rawContactIds.length == 0) {
- return null;
- }
- final long[] rawContactIdsToAdd;
- final long[] rawContactIdsToRemove;
- final String action;
- if (mType == TYPE_ADD) {
- rawContactIdsToAdd = rawContactIds;
- rawContactIdsToRemove = null;
- action = GroupMembersActivity.ACTION_ADD_TO_GROUP;
- } else if (mType == TYPE_REMOVE) {
- rawContactIdsToAdd = null;
- rawContactIdsToRemove = rawContactIds;
- action = GroupMembersActivity.ACTION_REMOVE_FROM_GROUP;
- } else {
- throw new IllegalStateException("Unrecognized type " + mType);
- }
- return ContactSaveService.createGroupUpdateIntent(
- mContext, mGroupId, /* newLabel */ null, rawContactIdsToAdd,
- rawContactIdsToRemove, GroupMembersActivity.class, action);
- }
-
- // TODO(wjang): prune raw contacts that are already in the group; ContactSaveService will
- // log a warning if the raw contact is already a member and keep going but it is not ideal.
- private long[] getRawContactIds() {
- final Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
- .appendQueryParameter(RawContacts.ACCOUNT_NAME, mAccountName)
- .appendQueryParameter(RawContacts.ACCOUNT_TYPE, mAccountType)
- .build();
- final String[] projection = new String[]{RawContacts._ID};
- final StringBuilder selection = new StringBuilder();
- final String[] selectionArgs = new String[mContactIds.length];
- for (int i = 0; i < mContactIds.length; i++) {
- if (i > 0) {
- selection.append(" OR ");
- }
- selection.append(RawContacts.CONTACT_ID).append("=?");
- selectionArgs[i] = Long.toString(mContactIds[i]);
- }
- final Cursor cursor = mContext.getContentResolver().query(
- rawContactUri, projection, selection.toString(), selectionArgs, null, null);
- final long[] rawContactIds = new long[cursor.getCount()];
- try {
- int i = 0;
- while (cursor.moveToNext()) {
- rawContactIds[i] = cursor.getLong(0);
- i++;
- }
- } finally {
- cursor.close();
- }
- return rawContactIds;
- }
-
- @Override
- protected void onPostExecute(Intent intent) {
- if (intent == null) {
- Toast.makeText(mContext, R.string.groupSavedErrorToast, Toast.LENGTH_SHORT).show();
- } else {
- mContext.startService(intent);
- }
- }
- }
-
- private ActionBarAdapter mActionBarAdapter;
-
- private GroupMembersFragment mMembersFragment;
-
- private Uri mGroupUri;
- private boolean mIsEditMode;
-
- private GroupMetadata mGroupMetadata;
-
- @Override
- public void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- // Parse the Intent
- if (savedState != null) {
- mGroupUri = savedState.getParcelable(KEY_GROUP_URI);
- mIsEditMode = savedState.getBoolean(KEY_IS_EDIT_MODE);
- mGroupMetadata = savedState.getParcelable(KEY_GROUP_METADATA);
- } else {
- mGroupUri = getIntent().getData();
- setTitle(getIntent().getStringExtra(GroupUtil.EXTRA_GROUP_NAME));
- }
- if (mGroupUri == null) {
- setResultCanceledAndFinish(R.string.groupLoadErrorToast);
- return;
- }
-
- // Set up the view
- setContentView(R.layout.group_members_activity);
-
- findViewById(R.id.toolbar_frame).setBackgroundColor(
- ContextCompat.getColor(this, R.color.group_primary_color));
-
- // Set up the action bar
- mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
- /* portraitTabs */ null, /* landscapeTabs */ null, mToolbar,
- R.string.enter_contact_name);
- mActionBarAdapter.setShowHomeIcon(true);
-
- // Add the members list fragment
- final FragmentManager fragmentManager = getFragmentManager();
- mMembersFragment = (GroupMembersFragment)
- fragmentManager.findFragmentByTag(TAG_GROUP_MEMBERS);
- if (mMembersFragment == null) {
- mMembersFragment = GroupMembersFragment.newInstance(getIntent().getData());
- fragmentManager.beginTransaction().replace(R.id.fragment_container_inner,
- mMembersFragment, TAG_GROUP_MEMBERS).commitAllowingStateLoss();
- }
- mMembersFragment.setListener(this);
- if (mGroupMetadata != null && mGroupMetadata.editable) {
- mMembersFragment.setCheckBoxListListener(this);
- }
-
- // Delay action bar initialization until after the fragment is added
- final ContactsRequest contactsRequest = new ContactsRequest();
- contactsRequest.setActionCode(ContactsRequest.ACTION_GROUP);
- mActionBarAdapter.initialize(savedState, contactsRequest);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- if (mActionBarAdapter != null) {
- mActionBarAdapter.onSaveInstanceState(outState);
- }
- outState.putParcelable(KEY_GROUP_URI, mGroupUri);
- outState.putBoolean(KEY_IS_EDIT_MODE, mIsEditMode);
- outState.putParcelable(KEY_GROUP_METADATA, mGroupMetadata);
- }
-
- // Invoked with results from the ContactSaveService
- @Override
- protected void onNewIntent(Intent newIntent) {
- if (ContactsDrawerActivity.ACTION_CREATE_GROUP.equals(newIntent.getAction())) {
- super.onNewIntent(newIntent);
- return;
- }
- if (isDeleteAction(newIntent.getAction())) {
- toast(R.string.groupDeletedToast);
- setResult(RESULT_OK);
- finish();
- } else if (isSaveAction(newIntent.getAction())) {
- final Uri groupUri = newIntent.getData();
- if (groupUri == null) {
- setResultCanceledAndFinish(R.string.groupSavedErrorToast);
- return;
- }
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + groupUri);
-
- mGroupUri = groupUri;
-
- toast(getToastMessageForSaveAction(newIntent.getAction()));
-
- if (mIsEditMode) {
- // If we're removing group members one at a time, don't reload the fragment so
- // the user can continue to remove group members one by one
- if (getGroupCount() == 1) {
- // If we're deleting the last group member, exit edit mode
- onBackPressed();
- }
- } else if (!ACTION_REMOVE_FROM_GROUP.equals(newIntent.getAction())) {
- replaceGroupMembersFragment();
- invalidateOptionsMenu();
- }
- }
- }
-
- private static boolean isDeleteAction(String action) {
- return ACTION_DELETE_GROUP.equals(action);
- }
-
- private static boolean isSaveAction(String action) {
- return ACTION_UPDATE_GROUP.equals(action)
- || ACTION_ADD_TO_GROUP.equals(action)
- || ACTION_REMOVE_FROM_GROUP.equals(action);
- }
-
- private static int getToastMessageForSaveAction(String action) {
- if (ACTION_UPDATE_GROUP.equals(action)) return R.string.groupUpdatedToast;
- if (ACTION_ADD_TO_GROUP.equals(action)) return R.string.groupMembersAddedToast;
- if (ACTION_REMOVE_FROM_GROUP.equals(action)) return R.string.groupMembersRemovedToast;
- throw new IllegalArgumentException("Unhanded contact save action " + action);
- }
-
- private int getGroupCount() {
- return mMembersFragment != null && mMembersFragment.getAdapter() != null
- ? mMembersFragment.getAdapter().getCount() : -1;
- }
-
- private void replaceGroupMembersFragment() {
- mMembersFragment = GroupMembersFragment.newInstance(mGroupUri);
- mMembersFragment.setListener(this);
- final FragmentTransaction transaction = getFragmentManager().beginTransaction();
- addGroupsAndFiltersFragments(transaction);
- transaction.replace(R.id.fragment_container_inner, mMembersFragment, TAG_GROUP_MEMBERS)
- .commitAllowingStateLoss();
- if (mGroupMetadata != null && mGroupMetadata.editable) {
- mMembersFragment.setCheckBoxListListener(this);
- }
- }
-
- @Override
- protected void onGroupMenuItemClicked(long groupId, String title) {
- if (mGroupMetadata.groupId != groupId) {
- super.onGroupMenuItemClicked(groupId, title);
- }
- }
-
- @Override
- protected boolean shouldFinish() {
- return true;
- }
-
- @Override
- protected void launchFindDuplicates() {
- super.launchFindDuplicates();
- finish();
- }
-
- public boolean isEditMode() {
- return mIsEditMode;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- if (mGroupMetadata == null) {
- // Hide menu options until metadata is fully loaded
- return false;
- }
- super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.view_group, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- final boolean isSelectionMode = mActionBarAdapter.isSelectionMode();
- final boolean isGroupEditable = mGroupMetadata != null && mGroupMetadata.editable;
- final boolean isGroupReadOnly = mGroupMetadata != null && mGroupMetadata.readOnly;
-
- setVisible(menu, R.id.menu_add, isGroupEditable && !isSelectionMode);
- setVisible(menu, R.id.menu_rename_group, !isGroupReadOnly && !isSelectionMode);
- setVisible(menu, R.id.menu_delete_group, !isGroupReadOnly && !isSelectionMode);
- setVisible(menu, R.id.menu_edit_group, isGroupEditable && !mIsEditMode && !isSelectionMode
- && !isGroupEmpty());
- setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode &&
- !mIsEditMode);
-
- return true;
- }
-
- private boolean isGroupEmpty() {
- return mMembersFragment != null && mMembersFragment.getAdapter() != null &&
- mMembersFragment.getAdapter().isEmpty();
- }
-
- private static void setVisible(Menu menu, int id, boolean visible) {
- final MenuItem menuItem = menu.findItem(id);
- if (menuItem != null) {
- menuItem.setVisible(visible);
- }
- }
-
- public void startGroupAddMemberActivity() {
- startActivityForResult(GroupUtil.createPickMemberIntent(this, mGroupMetadata,
- mMembersFragment.getMemberContactIds()), RESULT_GROUP_ADD_MEMBER);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home: {
- onBackPressed();
- return true;
- }
- case R.id.menu_add: {
- startGroupAddMemberActivity();
- return true;
- }
- case R.id.menu_rename_group: {
- GroupNameEditDialogFragment.newInstanceForUpdate(
- new AccountWithDataSet(mGroupMetadata.accountName,
- mGroupMetadata.accountType, mGroupMetadata.dataSet),
- ACTION_UPDATE_GROUP, mGroupMetadata.groupId, mGroupMetadata.groupName)
- .show(getFragmentManager(), TAG_GROUP_NAME_EDIT_DIALOG);
- return true;
- }
- case R.id.menu_delete_group: {
- deleteGroup();
- return true;
- }
- case R.id.menu_edit_group: {
- if (mMembersFragment == null) {
- return false;
- }
- mIsEditMode = true;
- mActionBarAdapter.setSelectionMode(true);
- mMembersFragment.displayDeleteButtons(true);
- return true;
- }
- case R.id.menu_remove_from_group: {
- if (mMembersFragment == null) {
- return false;
- }
- logListEvent();
- removeSelectedContacts();
- return true;
- }
- }
- return super.onOptionsItemSelected(item);
- }
-
- private void deleteGroup() {
- if (mMembersFragment.getMemberCount() == 0) {
- final Intent intent = ContactSaveService.createGroupDeletionIntent(this,
- mGroupMetadata.groupId);
- startService(intent);
- finish();
- } else {
- GroupDeletionDialogFragment.show(getFragmentManager(), mGroupMetadata.groupId,
- mGroupMetadata.groupName);
- }
- }
-
- private void logListEvent() {
- Logger.logListEvent(
- ListEvent.ActionType.REMOVE_LABEL,
- mMembersFragment.getListType(),
- mMembersFragment.getAdapter().getCount(),
- /* clickedIndex */ -1,
- mMembersFragment.getAdapter().getSelectedContactIdsArray().length);
- }
-
- private void removeSelectedContacts() {
- final long[] contactIds = mMembersFragment.getAdapter().getSelectedContactIdsArray();
- new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE,
- this, contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
- mGroupMetadata.accountType).execute();
-
- mActionBarAdapter.setSelectionMode(false);
- }
-
- @Override
- public void onBackPressed() {
- if (!isSafeToCommitTransactions()) {
- return;
- }
- if (mDrawer.isDrawerOpen(GravityCompat.START)) {
- mDrawer.closeDrawer(GravityCompat.START);
- } else if (mIsEditMode) {
- mIsEditMode = false;
- mActionBarAdapter.setSelectionMode(false);
- if (mMembersFragment != null) {
- mMembersFragment.displayDeleteButtons(false);
- }
- } else if (mActionBarAdapter.isSelectionMode()) {
- mActionBarAdapter.setSelectionMode(false);
- if (mMembersFragment != null) {
- mMembersFragment.displayCheckBoxes(false);
- }
- } else if (mActionBarAdapter.isSearchMode()) {
- mActionBarAdapter.setSearchMode(false);
- } else {
- switchToAllContacts();
- super.onBackPressed();
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == RESULT_GROUP_ADD_MEMBER && resultCode == RESULT_OK && data != null) {
- long[] contactIds = data.getLongArrayExtra(
- UiIntentActions.TARGET_CONTACT_IDS_EXTRA_KEY);
- if (contactIds == null) {
- final long contactId = data.getLongExtra(
- UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, -1);
- if (contactId > -1) {
- contactIds = new long[1];
- contactIds[0] = contactId;
- }
- }
- new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_ADD,
- this, contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
- mGroupMetadata.accountType).execute();
- }
- }
-
- private void setResultCanceledAndFinish(int resId) {
- toast(resId);
- setResult(RESULT_CANCELED);
- finish();
- }
-
- private void toast(int resId) {
- if (resId >= 0) {
- Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
- }
- }
-
- // ActionBarAdapter callbacks
-
- @Override
- public void onAction(int action) {
- switch (action) {
- case ActionBarAdapter.Listener.Action.START_SELECTION_MODE:
- if (mMembersFragment != null) {
- if (mIsEditMode) {
- mMembersFragment.displayDeleteButtons(true);
- mActionBarAdapter.setActionBarTitle(getString(R.string.title_edit_group));
- } else {
- mMembersFragment.displayCheckBoxes(true);
- }
- }
- invalidateOptionsMenu();
- showFabWithAnimation(/* showFabWithAnimation = */ false);
- break;
- case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE:
- mActionBarAdapter.setSearchMode(false);
- if (mMembersFragment != null) {
- if (mIsEditMode) {
- mMembersFragment.displayDeleteButtons(false);
- } else {
- mMembersFragment.displayCheckBoxes(false);
- }
- }
- invalidateOptionsMenu();
- showFabWithAnimation(/* showFabWithAnimation */ true);
- break;
- case ActionBarAdapter.Listener.Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE:
- showFabWithAnimation(/* showFabWithAnimation */ true);
- break;
- }
- }
-
- private void showFabWithAnimation(boolean showFab) {
- // TODO: b/28497108
- }
-
- @Override
- public void onSelectedTabChanged() {
- }
-
- @Override
- public void onUpButtonPressed() {
- onBackPressed();
- }
-
- // MultiSelect checkbox callbacks
-
- @Override
- public void onStartDisplayingCheckBoxes() {
- mActionBarAdapter.setSelectionMode(true);
- }
-
- @Override
- public void onSelectedContactIdsChanged() {
- if (mIsEditMode) {
- mActionBarAdapter.setActionBarTitle(getString(R.string.title_edit_group));
- } else {
- mActionBarAdapter.setSelectionCount(mMembersFragment.getSelectedContactIds().size());
- }
- }
-
- @Override
- public void onStopDisplayingCheckBoxes() {
- mActionBarAdapter.setSelectionMode(false);
- }
-
- // GroupMembersFragment callbacks
-
- @Override
- public void onGroupMetadataLoaded(GroupMetadata groupMetadata) {
- mGroupMetadata = groupMetadata;
- updateGroupMenu(mGroupMetadata);
- setTitle(mGroupMetadata.groupName);
- invalidateOptionsMenu();
- }
-
- @Override
- public void onGroupMetadataLoadFailed() {
- setResultCanceledAndFinish(R.string.groupLoadErrorToast);
- }
-
- @Override
- protected GroupMetadata getGroupMetadata() {
- return mGroupMetadata;
- }
-
- @Override
- public void onGroupMemberListItemClicked(int position, Uri contactLookupUri) {
- final int count = mMembersFragment.getAdapter().getCount();
- Logger.logListEvent(ListEvent.ActionType.CLICK, ListEvent.ListType.GROUP, count,
- /* clickedIndex */ position, /* numSelected */ 0);
- final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(this,
- contactLookupUri, QuickContactActivity.MODE_FULLY_EXPANDED);
- intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.LIST_GROUP);
- startActivity(intent);
- }
-
- @Override
- public void onGroupMemberListItemDeleted(int position, long contactId) {
- final long[] contactIds = new long[1];
- contactIds[0] = contactId;
- new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE,
- this, contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
- mGroupMetadata.accountType).execute();
- }
-}
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 7358fb7..726c288 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -20,115 +20,90 @@
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
-import android.content.ActivityNotFoundException;
+import android.content.ContentResolver;
import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
+import android.content.SyncStatusObserver;
import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
-import android.os.Parcelable;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Intents;
+import android.os.Handler;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.ProviderStatus;
-import android.provider.ContactsContract.QuickContact;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
-import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.GravityCompat;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.text.TextUtils;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageButton;
import android.widget.Toast;
-import com.android.contacts.common.model.account.AccountDisplayInfo;
-import com.android.contacts.common.model.account.AccountDisplayInfoFactory;
import com.android.contacts.ContactSaveService;
import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.R;
-import com.android.contacts.activities.ActionBarAdapter.TabState;
+import com.android.contacts.common.Experiments;
import com.android.contacts.common.activity.RequestPermissionsActivity;
-import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.interactions.ImportExportDialogFragment;
-import com.android.contacts.common.list.ContactEntryListFragment;
import com.android.contacts.common.list.ContactListFilter;
-import com.android.contacts.common.list.ContactListFilterController;
import com.android.contacts.common.list.DirectoryListLoader;
import com.android.contacts.common.list.ProviderStatusWatcher;
import com.android.contacts.common.list.ProviderStatusWatcher.ProviderStatusListener;
-import com.android.contacts.common.list.ViewPagerTabs;
-import com.android.contacts.common.logging.ListEvent;
import com.android.contacts.common.logging.Logger;
import com.android.contacts.common.logging.ScreenEvent.ScreenType;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.util.AccountFilterUtil;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.widget.FloatingActionButtonController;
import com.android.contacts.editor.EditorIntents;
-import com.android.contacts.interactions.ContactDeletionInteraction;
-import com.android.contacts.interactions.ContactMultiDeletionInteraction;
-import com.android.contacts.interactions.ContactMultiDeletionInteraction.MultiContactDeleteListener;
+import com.android.contacts.group.GroupMembersFragment;
+import com.android.contacts.group.GroupMetadata;
+import com.android.contacts.group.GroupUtil;
import com.android.contacts.list.ContactsIntentResolver;
import com.android.contacts.list.ContactsRequest;
import com.android.contacts.list.ContactsUnavailableFragment;
import com.android.contacts.list.DefaultContactBrowseListFragment;
-import com.android.contacts.list.MultiSelectContactsListFragment.OnCheckBoxListActionListener;
-import com.android.contacts.list.OnContactBrowserActionListener;
import com.android.contacts.list.OnContactsUnavailableActionListener;
import com.android.contacts.quickcontact.QuickContactActivity;
-import com.android.contacts.util.DialogManager;
-import com.android.contacts.util.SharedPreferenceUtil;
+import com.android.contacts.util.SyncUtil;
+import com.android.contactsbind.ObjectFactory;
+import com.android.contactsbind.experiments.Flags;
import com.android.contacts.widget.FloatingActionButtonBehavior;
-import com.android.contactsbind.FeatureHighlightHelper;
import java.util.List;
-import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Displays a list to browse contacts.
*/
-public class PeopleActivity extends ContactsDrawerActivity implements
- View.OnCreateContextMenuListener,
- View.OnClickListener,
- ActionBarAdapter.Listener,
- DialogManager.DialogShowingViewActivity,
- ContactListFilterController.ContactListFilterListener,
- ProviderStatusListener,
- MultiContactDeleteListener,
- DefaultContactBrowseListFragment.FeatureHighlightCallback {
+public class PeopleActivity extends ContactsDrawerActivity implements ProviderStatusListener {
private static final String TAG = "PeopleActivity";
+ private static final String TAG_ALL = "contacts-all";
+ private static final String TAG_UNAVAILABLE = "contacts-unavailable";
+ private static final String TAG_GROUP_VIEW = "contacts-groups";
+ private static final String TAG_DUPLICATES = "contacts-duplicates";
+ private static final String TAG_SECOND_LEVEL = "second-level";
+ // Tag for DuplicatesUtilFragment.java
+ public static final String TAG_DUPLICATES_UTIL = "DuplicatesUtilFragment";
- private static final String ENABLE_DEBUG_OPTIONS_HIDDEN_CODE = "debug debug!";
-
- private static final int ACTIVITY_REQUEST_CODE_SHARE = 0;
-
- private final DialogManager mDialogManager = new DialogManager(this);
+ private static final String KEY_GROUP_URI = "groupUri";
private ContactsIntentResolver mIntentResolver;
private ContactsRequest mRequest;
- private ActionBarAdapter mActionBarAdapter;
- private List<AccountWithDataSet> mWritableAccounts;
private FloatingActionButtonController mFloatingActionButtonController;
private View mFloatingActionButtonContainer;
private boolean wasLastFabAnimationScaleIn = false;
@@ -139,7 +114,7 @@
private BroadcastReceiver mSaveServiceListener;
- private boolean mOptionsMenuContactsAvailable;
+ private boolean mShouldSwitchToGroupView;
private CoordinatorLayout mLayoutRoot;
@@ -148,14 +123,8 @@
*/
private DefaultContactBrowseListFragment mAllFragment;
- /** ViewPager for swipe */
- private ViewPager mTabPager;
- private ViewPagerTabs mViewPagerTabs;
- private TabPagerAdapter mTabPagerAdapter;
- private String[] mTabTitles;
- private final TabPagerListener mTabPagerListener = new TabPagerListener();
-
- private boolean mEnableDebugMenuOptions;
+ private GroupMembersFragment mMembersFragment;
+ private Uri mGroupUri;
/**
* True if this activity instance is a re-created one. i.e. set true after orientation change.
@@ -171,15 +140,59 @@
*/
private boolean mFragmentInitialized;
- /**
- * This is to disable {@link #onOptionsItemSelected} when we trying to stop the activity.
- */
- private boolean mDisableOptionItemSelected;
-
/** Sequential ID assigned to each instance; used for logging */
private final int mInstanceId;
private static final AtomicInteger sNextInstanceId = new AtomicInteger();
+ private Object mStatusChangeListenerHandle;
+
+ private final Handler mHandler = new Handler();
+
+ private SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() {
+ public void onStatusChanged(int which) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ onSyncStateUpdated();
+ }
+ });
+ }
+ };
+
+ // Update sync status for accounts in current ContactListFilter
+ private void onSyncStateUpdated() {
+ if (mAllFragment.getActionBarAdapter().isSearchMode()
+ || mAllFragment.getActionBarAdapter().isSelectionMode()) {
+ return;
+ }
+
+ final ContactListFilter filter = mAllFragment.getFilter();
+ if (filter != null) {
+ final SwipeRefreshLayout swipeRefreshLayout = mAllFragment.getSwipeRefreshLayout();
+ if (swipeRefreshLayout == null) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Can not load swipeRefreshLayout, swipeRefreshLayout is null");
+ }
+ return;
+ }
+
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(this)
+ .getAccounts(/* contactsWritableOnly */ true);
+ final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
+ // If one of the accounts is active or pending, use spinning circle to indicate one of
+ // the syncs is in progress.
+ if (syncableAccounts != null && syncableAccounts.size() > 0) {
+ for (Account account: syncableAccounts) {
+ if (SyncUtil.isSyncStatusPendingOrActive(account)
+ || SyncUtil.isUnsyncableGoogleAccount(account)) {
+ swipeRefreshLayout.setRefreshing(true);
+ return;
+ }
+ }
+ }
+ swipeRefreshLayout.setRefreshing(false);
+ }
+ }
+
public PeopleActivity() {
mInstanceId = sNextInstanceId.getAndIncrement();
mIntentResolver = new ContactsIntentResolver(this);
@@ -192,7 +205,7 @@
return String.format("%s@%d", getClass().getSimpleName(), mInstanceId);
}
- public boolean areContactsAvailable() {
+ private boolean areContactsAvailable() {
return (mProviderStatus != null) && mProviderStatus.equals(ProviderStatus.STATUS_NORMAL);
}
@@ -200,7 +213,7 @@
* Initialize fragments that are (or may not be) in the layout.
*
* For the fragments that are in the layout, we initialize them in
- * {@link #createViewsAndFragments(Bundle)} after inflating the layout.
+ * {@link #createViewsAndFragments()} after inflating the layout.
*
* However, the {@link ContactsUnavailableFragment} is a special fragment which may not
* be in the layout, so we have to do the initialization here.
@@ -231,22 +244,16 @@
finish();
return;
}
- mContactListFilterController = ContactListFilterController.getInstance(this);
- mContactListFilterController.checkFilterValidity(false);
- mContactListFilterController.addListener(this);
mProviderStatusWatcher.addListener(this);
mIsRecreatedInstance = (savedState != null);
- // Use FILTER_TYPE_ALL_ACCOUNTS filter if the activity is not a re-created one.
- // This is useful when user upgrades app while an account filter or a custom filter was
- // stored in sharedPreference in a previous version of Contacts app.
- final ContactListFilter filter = mIsRecreatedInstance
- ? mContactListFilterController.getFilter() : createContactsFilter();
- persistFilterIfNeeded(filter);
+ if (mIsRecreatedInstance) {
+ mGroupUri = savedState.getParcelable(KEY_GROUP_URI);
+ }
- createViewsAndFragments(savedState);
+ createViewsAndFragments();
if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
Log.d(Constants.PERFORMANCE_TAG, "PeopleActivity.onCreate finish");
@@ -254,37 +261,77 @@
getWindow().setBackgroundDrawable(null);
}
- private void maybeShowHamburgerFeatureHighlight() {
- if (!mActionBarAdapter.isSearchMode() && !mActionBarAdapter.isSelectionMode()
- && SharedPreferenceUtil.getShouldShowHamburgerPromo(this)) {
- if (FeatureHighlightHelper.showHamburgerFeatureHighlight(this)) {
- SharedPreferenceUtil.setHamburgerPromoDisplayedBefore(this);
- }
- }
- }
-
@Override
protected void onNewIntent(Intent intent) {
- if (ContactsDrawerActivity.ACTION_CREATE_GROUP.equals(intent.getAction())) {
- super.onNewIntent(intent);
+ if (GroupUtil.ACTION_CREATE_GROUP.equals(intent.getAction())) {
+ mGroupUri = intent.getData();
+ if (mGroupUri == null) {
+ toast(R.string.groupSavedErrorToast);
+ return;
+ }
+ if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + mGroupUri);
+ switchToOrUpdateGroupView(intent.getAction());
return;
}
+ if (isGroupDeleteAction(intent.getAction())) {
+ toast(R.string.groupDeletedToast);
+ popSecondLevel();
+ mCurrentView = ContactsView.ALL_CONTACTS;
+ showFabWithAnimation(/* showFab */ true);
+ return;
+ }
+
+ if (isGroupSaveAction(intent.getAction())) {
+ mGroupUri = intent.getData();
+ if (mGroupUri == null) {
+ popSecondLevel();
+ toast(R.string.groupSavedErrorToast);
+ return;
+ }
+ if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "Received group URI " + mGroupUri);
+ switchToOrUpdateGroupView(intent.getAction());
+ }
+
setIntent(intent);
+
if (!processIntent(true)) {
finish();
return;
}
- mActionBarAdapter.initialize(null, mRequest);
mContactListFilterController.checkFilterValidity(false);
+ if (!isInSecondLevel()) {
+ // Re-initialize ActionBarAdapter because {@link #onNewIntent(Intent)} doesn't invoke
+ // {@link Fragment#onActivityCreated(Bundle)} where we initialize ActionBarAdapter
+ // initially.
+ mAllFragment.setContactsRequest(mRequest);
+ mAllFragment.initializeActionBarAdapter(null);
+ }
+
// Re-configure fragments.
configureFragments(true /* from request */);
initializeFabVisibility();
invalidateOptionsMenuIfNeeded();
}
+ private static boolean isGroupDeleteAction(String action) {
+ return GroupUtil.ACTION_DELETE_GROUP.equals(action);
+ }
+
+ private static boolean isGroupSaveAction(String action) {
+ return GroupUtil.ACTION_UPDATE_GROUP.equals(action)
+ || GroupUtil.ACTION_ADD_TO_GROUP.equals(action)
+ || GroupUtil.ACTION_REMOVE_FROM_GROUP.equals(action);
+ }
+
+ private void toast(int resId) {
+ if (resId >= 0) {
+ Toast.makeText(this, resId, Toast.LENGTH_SHORT).show();
+ }
+ }
+
/**
* Resolve the intent and initialize {@link #mRequest}, and launch another activity if redirect
* is needed.
@@ -319,79 +366,40 @@
onCreateGroupMenuItemClicked();
return true;
}
+ case ContactsRequest.ACTION_VIEW_GROUP:
+ case ContactsRequest.ACTION_EDIT_GROUP: {
+ mShouldSwitchToGroupView = true;
+ return true;
+ }
}
return true;
}
- private void createViewsAndFragments(Bundle savedState) {
+ private void createViewsAndFragments() {
setContentView(R.layout.people_activity);
final FragmentManager fragmentManager = getFragmentManager();
- // Hide all tabs (the current tab will later be reshown once a tab is selected)
- final FragmentTransaction transaction = fragmentManager.beginTransaction();
+ setUpAllFragment(fragmentManager);
- mTabTitles = new String[TabState.COUNT];
- mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label);
- mTabPager = getView(R.id.tab_pager);
- mTabPagerAdapter = new TabPagerAdapter();
- mTabPager.setAdapter(mTabPagerAdapter);
- mTabPager.setOnPageChangeListener(mTabPagerListener);
-
- // Configure toolbar and toolbar tabs. If in landscape mode, we configure tabs differently.
- final ViewPagerTabs portraitViewPagerTabs
- = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
- ViewPagerTabs landscapeViewPagerTabs = null;
- if (portraitViewPagerTabs == null) {
- landscapeViewPagerTabs = (ViewPagerTabs) getLayoutInflater().inflate(
- R.layout.people_activity_tabs_lands, mToolbar, /* attachToRoot = */ false);
- mViewPagerTabs = landscapeViewPagerTabs;
- } else {
- mViewPagerTabs = portraitViewPagerTabs;
+ if (isGroupView()) {
+ mMembersFragment = (GroupMembersFragment)
+ fragmentManager.findFragmentByTag(TAG_GROUP_VIEW);
}
- mViewPagerTabs.setViewPager(mTabPager);
-
- final String ALL_TAG = "tab-pager-all";
-
- // Create the fragments and add as children of the view pager.
- // The pager adapter will only change the visibility; it'll never create/destroy
- // fragments.
- // However, if it's after screen rotation, the fragments have been re-created by
- // the fragment manager, so first see if there're already the target fragments
- // existing.
- mAllFragment = (DefaultContactBrowseListFragment)
- fragmentManager.findFragmentByTag(ALL_TAG);
-
- if (mAllFragment == null) {
- mAllFragment = new DefaultContactBrowseListFragment();
- mAllFragment.setAnimateOnLoad(true);
- transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG);
- }
-
- mAllFragment.setFeatureHighlightCallback(this);
- mAllFragment.setOnContactListActionListener(new ContactBrowserActionListener());
- mAllFragment.setCheckBoxListListener(new CheckBoxListListener());
- mAllFragment.setListType(mContactListFilterController.getFilterListType());
-
- // Hide all fragments for now. We adjust visibility when we get onSelectedTabChanged()
- // from ActionBarAdapter.
- transaction.hide(mAllFragment);
-
- transaction.commitAllowingStateLoss();
- fragmentManager.executePendingTransactions();
-
- mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
- portraitViewPagerTabs, landscapeViewPagerTabs, mToolbar);
- mActionBarAdapter.initialize(savedState, mRequest);
// Configure floating action button
mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
final ImageButton floatingActionButton
= (ImageButton) findViewById(R.id.floating_action_button);
- floatingActionButton.setOnClickListener(this);
+ floatingActionButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ AccountFilterUtil.startEditorIntent(PeopleActivity.this, getIntent(),
+ mContactListFilterController.getFilter());
+ }
+ });
mFloatingActionButtonController = new FloatingActionButtonController(this,
mFloatingActionButtonContainer, floatingActionButton);
- initializeFabVisibility();
invalidateOptionsMenuIfNeeded();
@@ -405,11 +413,35 @@
fabParams.setBehavior(new FloatingActionButtonBehavior());
fabParams.gravity = Gravity.BOTTOM | Gravity.END;
mFloatingActionButtonContainer.setLayoutParams(fabParams);
+
+ if (mShouldSwitchToGroupView && !mIsRecreatedInstance) {
+ mGroupUri = mRequest.getContactUri();
+ switchToOrUpdateGroupView(GroupUtil.ACTION_SWITCH_GROUP);
+ mShouldSwitchToGroupView = false;
+ }
+ }
+
+ private void setUpAllFragment(FragmentManager fragmentManager) {
+ mAllFragment = (DefaultContactBrowseListFragment)
+ fragmentManager.findFragmentByTag(TAG_ALL);
+
+ if (mAllFragment == null) {
+ mAllFragment = new DefaultContactBrowseListFragment();
+ mAllFragment.setAnimateOnLoad(true);
+ fragmentManager.beginTransaction()
+ .add(R.id.contacts_list_container, mAllFragment, TAG_ALL)
+ .commit();
+ fragmentManager.executePendingTransactions();
+ }
+
+ mAllFragment.setContactsAvailable(areContactsAvailable());
+ mAllFragment.setListType();
+ mAllFragment.setContactsRequest(mRequest);
}
@Override
protected void onStart() {
- if (!mFragmentInitialized) {
+ if (!mFragmentInitialized && (!isInSecondLevel())) {
mFragmentInitialized = true;
/* Configure fragments if we haven't.
*
@@ -433,13 +465,16 @@
@Override
protected void onPause() {
- mOptionsMenuContactsAvailable = false;
mProviderStatusWatcher.stop();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mSaveServiceListener);
super.onPause();
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ ContentResolver.removeStatusChangeListener(mStatusChangeListenerHandle);
+ onSyncStateUpdated();
+ }
}
@Override
@@ -449,17 +484,18 @@
mProviderStatusWatcher.start();
updateViewConfiguration(true);
- // Re-register the listener, which may have been cleared when onSaveInstanceState was
- // called. See also: onSaveInstanceState
- mActionBarAdapter.setListener(this);
- mDisableOptionItemSelected = false;
- if (mTabPager != null) {
- mTabPager.setOnPageChangeListener(mTabPagerListener);
+ if (Flags.getInstance(this).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ mStatusChangeListenerHandle = ContentResolver.addStatusChangeListener(
+ ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE
+ | ContentResolver.SYNC_OBSERVER_TYPE_PENDING
+ | ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
+ mSyncStatusObserver);
+ onSyncStateUpdated();
}
- // Current tab may have changed since the last onSaveInstanceState(). Make sure
- // the actual contents match the tab.
- updateFragmentsVisibility();
- maybeShowHamburgerFeatureHighlight();
+ if (!isInSecondLevel()) {
+ mAllFragment.maybeShowHamburgerFeatureHighlight();
+ }
+ initializeFabVisibility();
mSaveServiceListener = new SaveServiceListener();
LocalBroadcastManager.getInstance(this).registerReceiver(mSaveServiceListener,
@@ -469,16 +505,6 @@
@Override
protected void onDestroy() {
mProviderStatusWatcher.removeListener(this);
-
- // Some of variables will be null if this Activity redirects Intent.
- // See also onCreate() or other methods called during the Activity's initialization.
- if (mActionBarAdapter != null) {
- mActionBarAdapter.setListener(null);
- }
- if (mContactListFilterController != null) {
- mContactListFilterController.removeListener(this);
- }
-
super.onDestroy();
}
@@ -487,36 +513,25 @@
ContactListFilter filter = null;
int actionCode = mRequest.getActionCode();
boolean searchMode = mRequest.isSearchMode();
- final int tabToOpen;
switch (actionCode) {
case ContactsRequest.ACTION_ALL_CONTACTS:
- filter = createContactsFilter();
- tabToOpen = TabState.ALL;
+ filter = AccountFilterUtil.createContactsFilter(this);
break;
case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
filter = ContactListFilter.createFilterWithType(
ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
- tabToOpen = TabState.ALL;
break;
case ContactsRequest.ACTION_FREQUENT:
case ContactsRequest.ACTION_STREQUENT:
case ContactsRequest.ACTION_STARRED:
- tabToOpen = TabState.ALL;
- break;
case ContactsRequest.ACTION_VIEW_CONTACT:
- tabToOpen = TabState.ALL;
- break;
default:
- tabToOpen = -1;
break;
}
- if (tabToOpen != -1) {
- mActionBarAdapter.setCurrentTab(tabToOpen);
- }
if (filter != null) {
- mContactListFilterController.setContactListFilter(filter, /* persistent */ false);
+ mAllFragment.setContactListFilter(filter);
searchMode = false;
}
@@ -524,39 +539,33 @@
searchMode = false;
}
- mActionBarAdapter.setSearchMode(searchMode);
- configureContactListFragmentForRequest();
+ if (!isInSecondLevel()) {
+ mAllFragment.getActionBarAdapter().setSearchMode(searchMode);
+ configureContactListFragmentForRequest();
+ }
}
- configureContactListFragment();
-
- invalidateOptionsMenuIfNeeded();
+ if (!isInSecondLevel()) {
+ mAllFragment.configureContactListFragment();
+ }
}
private void initializeFabVisibility() {
- final boolean hideFab = mActionBarAdapter.isSearchMode()
- || mActionBarAdapter.isSelectionMode()
- || !shouldShowFabForAccount();
- mFloatingActionButtonContainer.setVisibility(hideFab ? View.GONE : View.VISIBLE);
+ mFloatingActionButtonContainer.setVisibility(shouldHideFab() ? View.GONE : View.VISIBLE);
mFloatingActionButtonController.resetIn();
- wasLastFabAnimationScaleIn = !hideFab;
+ wasLastFabAnimationScaleIn = !shouldHideFab();
}
- private boolean shouldShowFabForAccount() {
- return isCurrentAccountFilterWritable()
- || isAllContactsFilter(mContactListFilterController.getFilter());
+ private boolean shouldHideFab() {
+ if (mAllFragment != null && mAllFragment.getActionBarAdapter() == null
+ || isInSecondLevel()) {
+ return true;
+ }
+ return mAllFragment.getActionBarAdapter().isSearchMode()
+ || mAllFragment.getActionBarAdapter().isSelectionMode();
}
- private boolean isCurrentAccountFilterWritable() {
- final ContactListFilter currentFilter = mContactListFilterController.getFilter();
- final AccountWithDataSet accountOfCurrentFilter = new AccountWithDataSet(
- currentFilter.accountName, currentFilter.accountType, currentFilter.dataSet);
- return accountOfCurrentFilter.isLocalAccount()
- || (mWritableAccounts != null
- && mWritableAccounts.contains(accountOfCurrentFilter));
- }
-
- private void showFabWithAnimation(boolean showFab) {
+ public void showFabWithAnimation(boolean showFab) {
if (mFloatingActionButtonContainer == null) {
return;
}
@@ -576,310 +585,6 @@
}
}
- @Override
- public void onContactListFilterChanged() {
- if (mAllFragment == null || !mAllFragment.isAdded()) {
- return;
- }
-
- setFilterAndUpdateTitle(mContactListFilterController.getFilter());
- // Scroll to top after filter is changed.
- mAllFragment.getListView().setSelection(0);
- showFabWithAnimation(shouldShowFabForAccount());
-
- invalidateOptionsMenuIfNeeded();
- }
-
- /**
- * Handler for action bar actions.
- */
- @Override
- public void onAction(int action) {
- switch (action) {
- case ActionBarAdapter.Listener.Action.START_SELECTION_MODE:
- mAllFragment.displayCheckBoxes(true);
- startSearchOrSelectionMode();
- break;
- case ActionBarAdapter.Listener.Action.START_SEARCH_MODE:
- if (!mIsRecreatedInstance) {
- Logger.logScreenView(this, ScreenType.SEARCH);
- }
- startSearchOrSelectionMode();
- break;
- case ActionBarAdapter.Listener.Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE:
- showFabWithAnimation(shouldShowFabForAccount());
- break;
- case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE:
- // If queryString is empty, fragment data will not be reloaded,
- // so hamburger promo should be checked now.
- // If not empty, promo should be checked and displayed after reloading. (b/30706521)
- if (TextUtils.isEmpty(mAllFragment.getQueryString())) {
- maybeShowHamburgerFeatureHighlight();
- }
- setQueryTextToFragment("");
- updateFragmentsVisibility();
- invalidateOptionsMenu();
- showFabWithAnimation(shouldShowFabForAccount());
- break;
- case ActionBarAdapter.Listener.Action.CHANGE_SEARCH_QUERY:
- final String queryString = mActionBarAdapter.getQueryString();
- setQueryTextToFragment(queryString);
- updateDebugOptionsVisibility(
- ENABLE_DEBUG_OPTIONS_HIDDEN_CODE.equals(queryString));
- break;
- default:
- throw new IllegalStateException("Unkonwn ActionBarAdapter action: " + action);
- }
- }
-
- private void startSearchOrSelectionMode() {
- configureFragments(false /* from request */);
- updateFragmentsVisibility();
- invalidateOptionsMenu();
- showFabWithAnimation(/* showFab */ false);
- if (!SharedPreferenceUtil.getHamburgerPromoTriggerActionHappenedBefore(this)) {
- SharedPreferenceUtil.setHamburgerPromoTriggerActionHappenedBefore(this);
- }
- }
-
- @Override
- public void onSelectedTabChanged() {
- updateFragmentsVisibility();
- }
-
- @Override
- public void onUpButtonPressed() {
- onBackPressed();
- }
-
- private void updateDebugOptionsVisibility(boolean visible) {
- if (mEnableDebugMenuOptions != visible) {
- mEnableDebugMenuOptions = visible;
- invalidateOptionsMenu();
- }
- }
-
- /**
- * Updates the fragment/view visibility according to the current mode, such as
- * {@link ActionBarAdapter#isSearchMode()} and {@link ActionBarAdapter#getCurrentTab()}.
- */
- private void updateFragmentsVisibility() {
- int tab = mActionBarAdapter.getCurrentTab();
-
- if (mActionBarAdapter.isSearchMode() || mActionBarAdapter.isSelectionMode()) {
- mTabPagerAdapter.setTabsHidden(true);
- } else {
- // No smooth scrolling if quitting from the search/selection mode.
- final boolean wereTabsHidden = mTabPagerAdapter.areTabsHidden()
- || mActionBarAdapter.isSelectionMode();
- mTabPagerAdapter.setTabsHidden(false);
- if (mTabPager.getCurrentItem() != tab) {
- mTabPager.setCurrentItem(tab, !wereTabsHidden);
- }
- }
- if (!mActionBarAdapter.isSelectionMode()) {
- mAllFragment.displayCheckBoxes(false);
- }
- invalidateOptionsMenu();
- showEmptyStateForTab(tab);
- }
-
- private void showEmptyStateForTab(int tab) {
- if (mContactsUnavailableFragment != null) {
- switch (getTabPositionForTextDirection(tab)) {
- case TabState.ALL:
- mContactsUnavailableFragment.setTabInfo(R.string.noContacts, TabState.ALL);
- break;
- }
- // When using the mContactsUnavailableFragment the ViewPager doesn't contain two views.
- // Therefore, we have to trick the ViewPagerTabs into thinking we have changed tabs
- // when the mContactsUnavailableFragment changes. Otherwise the tab strip won't move.
- mViewPagerTabs.onPageScrolled(tab, 0, 0);
- }
- }
-
- private class TabPagerListener implements ViewPager.OnPageChangeListener {
-
- // This package-protected constructor is here because of a possible compiler bug.
- // PeopleActivity$1.class should be generated due to the private outer/inner class access
- // needed here. But for some reason, PeopleActivity$1.class is missing.
- // Since $1 class is needed as a jvm work around to get access to the inner class,
- // changing the constructor to package-protected or public will solve the problem.
- // To verify whether $1 class is needed, javap PeopleActivity$TabPagerListener and look for
- // references to PeopleActivity$1.
- //
- // When the constructor is private and PeopleActivity$1.class is missing, proguard will
- // correctly catch this and throw warnings and error out the build on user/userdebug builds.
- //
- // All private inner classes below also need this fix.
- TabPagerListener() {}
-
- @Override
- public void onPageScrollStateChanged(int state) {
- if (!mTabPagerAdapter.areTabsHidden()) {
- mViewPagerTabs.onPageScrollStateChanged(state);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- if (!mTabPagerAdapter.areTabsHidden()) {
- mViewPagerTabs.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- @Override
- public void onPageSelected(int position) {
- // Make sure not in the search mode, in which case position != TabState.ordinal().
- if (!mTabPagerAdapter.areTabsHidden()) {
- mActionBarAdapter.setCurrentTab(position, false);
- mViewPagerTabs.onPageSelected(position);
- showEmptyStateForTab(position);
- invalidateOptionsMenu();
- }
- }
- }
-
- /**
- * Adapter for the {@link ViewPager}. Unlike {@link FragmentPagerAdapter},
- * {@link #instantiateItem} returns existing fragments, and {@link #instantiateItem}/
- * {@link #destroyItem} show/hide fragments instead of attaching/detaching.
- *
- * In search mode, we always show the "all" fragment, and disable the swipe. We change the
- * number of items to 1 to disable the swipe.
- *
- * TODO figure out a more straight way to disable swipe.
- */
- private class TabPagerAdapter extends PagerAdapter {
- private final FragmentManager mFragmentManager;
- private FragmentTransaction mCurTransaction = null;
-
- private boolean mAreTabsHiddenInTabPager;
-
- private Fragment mCurrentPrimaryItem;
-
- public TabPagerAdapter() {
- mFragmentManager = getFragmentManager();
- }
-
- public boolean areTabsHidden() {
- return mAreTabsHiddenInTabPager;
- }
-
- public void setTabsHidden(boolean hideTabs) {
- if (hideTabs == mAreTabsHiddenInTabPager) {
- return;
- }
- mAreTabsHiddenInTabPager = hideTabs;
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mAreTabsHiddenInTabPager ? 1 : TabState.COUNT;
- }
-
- /** Gets called when the number of items changes. */
- @Override
- public int getItemPosition(Object object) {
- if (mAreTabsHiddenInTabPager) {
- if (object == mAllFragment) {
- return 0; // Only 1 page in search mode
- }
- } else {
- if (object == mAllFragment) {
- return getTabPositionForTextDirection(TabState.ALL);
- }
- }
- return POSITION_NONE;
- }
-
- @Override
- public void startUpdate(ViewGroup container) {
- }
-
- private Fragment getFragment(int position) {
- position = getTabPositionForTextDirection(position);
- if (mAreTabsHiddenInTabPager) {
- if (position != 0) {
- // This has only been observed in monkey tests.
- // Let's log this issue, but not crash
- Log.w(TAG, "Request fragment at position=" + position + ", eventhough we " +
- "are in search mode");
- }
- return mAllFragment;
- } else {
- if (position == TabState.ALL) {
- return mAllFragment;
- }
- }
- throw new IllegalArgumentException("position: " + position);
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- if (mCurTransaction == null) {
- mCurTransaction = mFragmentManager.beginTransaction();
- }
- Fragment f = getFragment(position);
- mCurTransaction.show(f);
-
- // Non primary pages are not visible.
- f.setUserVisibleHint(f == mCurrentPrimaryItem);
- return f;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- if (mCurTransaction == null) {
- mCurTransaction = mFragmentManager.beginTransaction();
- }
- mCurTransaction.hide((Fragment) object);
- }
-
- @Override
- public void finishUpdate(ViewGroup container) {
- if (mCurTransaction != null) {
- mCurTransaction.commitAllowingStateLoss();
- mCurTransaction = null;
- mFragmentManager.executePendingTransactions();
- }
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return ((Fragment) object).getView() == view;
- }
-
- @Override
- public void setPrimaryItem(ViewGroup container, int position, Object object) {
- Fragment fragment = (Fragment) object;
- if (mCurrentPrimaryItem != fragment) {
- if (mCurrentPrimaryItem != null) {
- mCurrentPrimaryItem.setUserVisibleHint(false);
- }
- if (fragment != null) {
- fragment.setUserVisibleHint(true);
- }
- mCurrentPrimaryItem = fragment;
- }
- }
-
- @Override
- public Parcelable saveState() {
- return null;
- }
-
- @Override
- public void restoreState(Parcelable state, ClassLoader loader) {
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- return mTabTitles[position];
- }
- }
-
private void setQueryTextToFragment(String query) {
mAllFragment.setQueryString(query, true);
mAllFragment.setVisibleScrollbarEnabled(!mAllFragment.isSearchMode());
@@ -891,8 +596,7 @@
mAllFragment.setSelectedContactUri(contactUri);
}
- setFilterAndUpdateTitle(mContactListFilterController.getFilter());
- setQueryTextToFragment(mActionBarAdapter.getQueryString());
+ setQueryTextToFragment(mAllFragment.getActionBarAdapter().getQueryString());
if (mRequest.isDirectorySearchEnabled()) {
mAllFragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_DEFAULT);
@@ -901,31 +605,6 @@
}
}
- private void configureContactListFragment() {
- // Filter may be changed when this Activity is in background.
- setFilterAndUpdateTitle(mContactListFilterController.getFilter());
-
- mAllFragment.setVerticalScrollbarPosition(getScrollBarPosition());
- mAllFragment.setSelectionVisible(false);
- }
-
- private int getScrollBarPosition() {
- return isRTL() ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT;
- }
-
- private boolean isRTL() {
- final Locale locale = Locale.getDefault();
- return TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL;
- }
-
- @Override
- public void onFiltersLoaded(List<ContactListFilter> accountFilterItems) {
- super.onFiltersLoaded(accountFilterItems);
- mWritableAccounts =
- AccountTypeManager.getInstance(this).getAccounts(/* contactWritableOnly */ true);
- initializeFabVisibility();
- }
-
@Override
public void onProviderStatusChange() {
reloadGroupsAndFiltersIfNeeded();
@@ -952,51 +631,52 @@
&& (mProviderStatus.equals(providerStatus))) return;
mProviderStatus = providerStatus;
- View contactsUnavailableView = findViewById(R.id.contacts_unavailable_view);
+ final FragmentManager fragmentManager= getFragmentManager();
+ final FragmentTransaction transaction = fragmentManager.beginTransaction();
// Change in CP2's provider status may not take effect immediately, see b/30566908.
// So we need to handle the case where provider status is STATUS_EMPTY and there is
// actually at least one real account (not "local" account) on device.
- if ((mProviderStatus.equals(ProviderStatus.STATUS_EMPTY) && hasNonLocalAccount())
- || mProviderStatus.equals(ProviderStatus.STATUS_NORMAL)) {
- // Ensure that the mTabPager is visible; we may have made it invisible below.
- contactsUnavailableView.setVisibility(View.GONE);
- if (mTabPager != null) {
- mTabPager.setVisibility(View.VISIBLE);
- }
-
+ if (shouldShowList()) {
if (mAllFragment != null) {
+ transaction.show(mAllFragment);
+ mAllFragment.setContactsAvailable(areContactsAvailable());
mAllFragment.setEnabled(true);
}
+ if (mContactsUnavailableFragment != null) {
+ transaction.hide(mContactsUnavailableFragment);
+ }
} else {
// Setting up the page so that the user can still use the app
// even without an account.
if (mAllFragment != null) {
mAllFragment.setEnabled(false);
+ transaction.hide(mAllFragment);
}
if (mContactsUnavailableFragment == null) {
mContactsUnavailableFragment = new ContactsUnavailableFragment();
mContactsUnavailableFragment.setOnContactsUnavailableActionListener(
new ContactsUnavailableFragmentListener());
- getFragmentManager().beginTransaction()
- .replace(R.id.contacts_unavailable_container, mContactsUnavailableFragment)
- .commitAllowingStateLoss();
+ transaction.add(R.id.contacts_list_container, mContactsUnavailableFragment,
+ TAG_UNAVAILABLE);
}
+ transaction.show(mContactsUnavailableFragment);
mContactsUnavailableFragment.updateStatus(mProviderStatus);
-
- // Show the contactsUnavailableView, and hide the mTabPager so that we don't
- // see it sliding in underneath the contactsUnavailableView at the edges.
- contactsUnavailableView.setVisibility(View.VISIBLE);
- if (mTabPager != null) {
- mTabPager.setVisibility(View.GONE);
- }
-
- showEmptyStateForTab(mActionBarAdapter.getCurrentTab());
+ }
+ if (!transaction.isEmpty()) {
+ transaction.commit();
+ fragmentManager.executePendingTransactions();
}
invalidateOptionsMenuIfNeeded();
}
+ private boolean shouldShowList() {
+ return mProviderStatus != null
+ && ((mProviderStatus.equals(ProviderStatus.STATUS_EMPTY) && hasNonLocalAccount())
+ || mProviderStatus.equals(ProviderStatus.STATUS_NORMAL));
+ }
+
// Returns true if there are real accounts (not "local" account) in the list of accounts.
private boolean hasNonLocalAccount() {
final List<AccountWithDataSet> allAccounts =
@@ -1010,94 +690,6 @@
return !allAccounts.get(0).isLocalAccount();
}
- private final class ContactBrowserActionListener implements OnContactBrowserActionListener {
- ContactBrowserActionListener() {}
-
- @Override
- public void onSelectionChange() {
-
- }
-
- @Override
- public void onViewContactAction(int position, Uri contactLookupUri,
- boolean isEnterpriseContact) {
- if (isEnterpriseContact) {
- // No implicit intent as user may have a different contacts app in work profile.
- QuickContact.showQuickContact(PeopleActivity.this, new Rect(), contactLookupUri,
- QuickContactActivity.MODE_FULLY_EXPANDED, null);
- } else {
- final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(
- PeopleActivity.this, contactLookupUri,
- QuickContactActivity.MODE_FULLY_EXPANDED);
- final int previousScreen;
- if (mAllFragment.isSearchMode()) {
- previousScreen = ScreenType.SEARCH;
- } else {
- if (isAllContactsFilter(mContactListFilterController.getFilter())) {
- if (position < mAllFragment.getAdapter().getNumberOfFavorites()) {
- previousScreen = ScreenType.FAVORITES;
- } else {
- previousScreen = ScreenType.ALL_CONTACTS;
- }
- } else {
- previousScreen = ScreenType.LIST_ACCOUNT;
- }
- }
- Logger.logListEvent(ListEvent.ActionType.CLICK,
- /* listType */ getListTypeIncludingSearch(),
- /* count */ mAllFragment.getAdapter().getCount(),
- /* clickedIndex */ position, /* numSelected */ 0);
- intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, previousScreen);
- ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent);
- }
- }
-
- @Override
- public void onDeleteContactAction(Uri contactUri) {
- ContactDeletionInteraction.start(PeopleActivity.this, contactUri, false);
- }
-
- @Override
- public void onFinishAction() {
- onBackPressed();
- }
-
- @Override
- public void onInvalidSelection() {
- ContactListFilter filter;
- ContactListFilter currentFilter = mAllFragment.getFilter();
- if (currentFilter != null
- && currentFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
- filter = createContactsFilter();
- setFilterAndUpdateTitle(filter);
- } else {
- filter = ContactListFilter.createFilterWithType(
- ContactListFilter.FILTER_TYPE_SINGLE_CONTACT);
- setFilterAndUpdateTitle(filter, /* restoreSelectedUri */ false);
- }
- persistFilterIfNeeded(filter);
- }
- }
-
- private final class CheckBoxListListener implements OnCheckBoxListActionListener {
- @Override
- public void onStartDisplayingCheckBoxes() {
- mActionBarAdapter.setSelectionMode(true);
- invalidateOptionsMenu();
- }
-
- @Override
- public void onSelectedContactIdsChanged() {
- mActionBarAdapter.setSelectionCount(mAllFragment.getSelectedContactIds().size());
- invalidateOptionsMenu();
- }
-
- @Override
- public void onStopDisplayingCheckBoxes() {
- mActionBarAdapter.setSelectionMode(false);
- }
- }
-
private class ContactsUnavailableFragmentListener
implements OnContactsUnavailableActionListener {
ContactsUnavailableFragmentListener() {}
@@ -1120,232 +712,19 @@
}
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- if (!areContactsAvailable()) {
- // If contacts aren't available, hide all menu items.
- return false;
- }
- super.onCreateOptionsMenu(menu);
-
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.people_options, menu);
-
- return true;
- }
-
private void invalidateOptionsMenuIfNeeded() {
- if (isOptionsMenuChanged()) {
+ if (mAllFragment != null
+ && mAllFragment.getOptionsMenuContactsAvailable() != areContactsAvailable()) {
invalidateOptionsMenu();
}
}
- public boolean isOptionsMenuChanged() {
- if (mOptionsMenuContactsAvailable != areContactsAvailable()) {
- return true;
- }
-
- if (mAllFragment != null && mAllFragment.isOptionsMenuChanged()) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- mOptionsMenuContactsAvailable = areContactsAvailable();
- if (!mOptionsMenuContactsAvailable) {
- return false;
- }
-
- final boolean isSearchOrSelectionMode = mActionBarAdapter.isSearchMode()
- || mActionBarAdapter.isSelectionMode();
- makeMenuItemVisible(menu, R.id.menu_search, !isSearchOrSelectionMode);
-
- final boolean showSelectedContactOptions = mActionBarAdapter.isSelectionMode()
- && mAllFragment.getSelectedContactIds().size() != 0;
- makeMenuItemVisible(menu, R.id.menu_share, showSelectedContactOptions);
- makeMenuItemVisible(menu, R.id.menu_delete, showSelectedContactOptions);
- final boolean showLinkContactsOptions = mActionBarAdapter.isSelectionMode()
- && mAllFragment.getSelectedContactIds().size() > 1;
- makeMenuItemVisible(menu, R.id.menu_join, showLinkContactsOptions);
-
- // Debug options need to be visible even in search mode.
- makeMenuItemVisible(menu, R.id.export_database, mEnableDebugMenuOptions &&
- hasExportIntentHandler());
-
- return true;
- }
-
- private boolean hasExportIntentHandler() {
- final Intent intent = new Intent();
- intent.setAction("com.android.providers.contacts.DUMP_DATABASE");
- final List<ResolveInfo> receivers = getPackageManager().queryIntentActivities(intent,
- PackageManager.MATCH_DEFAULT_ONLY);
- return receivers != null && receivers.size() > 0;
- }
-
- private void makeMenuItemVisible(Menu menu, int itemId, boolean visible) {
- final MenuItem item = menu.findItem(itemId);
- if (item != null) {
- item.setVisible(visible);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (mDisableOptionItemSelected) {
- return false;
- }
-
- switch (item.getItemId()) {
- case android.R.id.home: {
- // The home icon on the action bar is pressed
- if (mActionBarAdapter.isUpShowing()) {
- // "UP" icon press -- should be treated as "back".
- onBackPressed();
- }
- return true;
- }
- case R.id.menu_search: {
- onSearchRequested();
- return true;
- }
- case R.id.menu_share: {
- shareSelectedContacts();
- return true;
- }
- case R.id.menu_join: {
- Logger.logListEvent(ListEvent.ActionType.LINK,
- /* listType */ getListTypeIncludingSearch(),
- /* count */ mAllFragment.getAdapter().getCount(), /* clickedIndex */ -1,
- /* numSelected */ mAllFragment.getAdapter().getSelectedContactIds().size());
- joinSelectedContacts();
- return true;
- }
- case R.id.menu_delete: {
- deleteSelectedContacts();
- return true;
- }
- case R.id.export_database: {
- final Intent intent = new Intent("com.android.providers.contacts.DUMP_DATABASE");
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- ImplicitIntentsUtil.startActivityOutsideApp(this, intent);
- return true;
- }
- }
- return super.onOptionsItemSelected(item);
- }
-
private void showImportExportDialogFragment(){
ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
PeopleActivity.class, ImportExportDialogFragment.EXPORT_MODE_ALL_CONTACTS);
}
@Override
- public boolean onSearchRequested() { // Search key pressed.
- if (!mActionBarAdapter.isSelectionMode()) {
- mActionBarAdapter.setSearchMode(true);
- }
- return true;
- }
-
- /**
- * Share all contacts that are currently selected in mAllFragment. This method is pretty
- * inefficient for handling large numbers of contacts. I don't expect this to be a problem.
- */
- private void shareSelectedContacts() {
- final StringBuilder uriListBuilder = new StringBuilder();
- for (Long contactId : mAllFragment.getSelectedContactIds()) {
- final Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
- final Uri lookupUri = Contacts.getLookupUri(getContentResolver(), contactUri);
- if (lookupUri == null) {
- continue;
- }
- final List<String> pathSegments = lookupUri.getPathSegments();
- if (pathSegments.size() < 2) {
- continue;
- }
- final String lookupKey = pathSegments.get(pathSegments.size() - 2);
- if (uriListBuilder.length() > 0) {
- uriListBuilder.append(':');
- }
- uriListBuilder.append(Uri.encode(lookupKey));
- }
- if (uriListBuilder.length() == 0) {
- return;
- }
- final Uri uri = Uri.withAppendedPath(
- Contacts.CONTENT_MULTI_VCARD_URI,
- Uri.encode(uriListBuilder.toString()));
- final Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType(Contacts.CONTENT_VCARD_TYPE);
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- try {
- startActivityForResult(Intent.createChooser(intent, getResources().getQuantityString(
- R.plurals.title_share_via,
- /* quantity */ mAllFragment.getSelectedContactIds().size()))
- , ACTIVITY_REQUEST_CODE_SHARE);
- } catch (final ActivityNotFoundException ex) {
- Toast.makeText(this, R.string.share_error, Toast.LENGTH_SHORT).show();
- }
- }
-
- private void joinSelectedContacts() {
- final Intent intent = ContactSaveService.createJoinSeveralContactsIntent(
- this, mAllFragment.getSelectedContactIdsArray());
- this.startService(intent);
-
- mActionBarAdapter.setSelectionMode(false);
- }
-
- private void deleteSelectedContacts() {
- ContactMultiDeletionInteraction.start(PeopleActivity.this,
- mAllFragment.getSelectedContactIds());
- }
-
- @Override
- public void onDeletionFinished() {
- // The parameters count and numSelected are both the number of contacts before deletion.
- Logger.logListEvent(ListEvent.ActionType.DELETE,
- /* listType */ getListTypeIncludingSearch(),
- /* count */ mAllFragment.getAdapter().getCount(), /* clickedIndex */ -1,
- /* numSelected */ mAllFragment.getSelectedContactIds().size());
- mActionBarAdapter.setSelectionMode(false);
- }
-
- private int getListTypeIncludingSearch() {
- return mAllFragment.isSearchMode()
- ? ListEvent.ListType.SEARCH_RESULT : mAllFragment.getListType();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- // TODO: Using the new startActivityWithResultFromFragment API this should not be needed
- // anymore
- case ContactEntryListFragment.ACTIVITY_REQUEST_CODE_PICKER:
- if (resultCode == RESULT_OK) {
- mAllFragment.onPickerResult(data);
- }
- case ACTIVITY_REQUEST_CODE_SHARE:
- Logger.logListEvent(ListEvent.ActionType.SHARE,
- /* listType */ getListTypeIncludingSearch(),
- /* count */ mAllFragment.getAdapter().getCount(), /* clickedIndex */ -1,
- /* numSelected */ mAllFragment.getAdapter().getSelectedContactIds().size());
-
-// TODO fix or remove multipicker code
-// else if (resultCode == RESULT_CANCELED && mMode == MODE_PICK_MULTIPLE_PHONES) {
-// // Finish the activity if the sub activity was canceled as back key is used
-// // to confirm user selection in MODE_PICK_MULTIPLE_PHONES.
-// finish();
-// }
-// break;
- }
- }
-
- @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO move to the fragment
@@ -1355,14 +734,14 @@
// If COMBINING_ACCENT is set, it's not a unicode character.
&& ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) == 0)
&& !Character.isWhitespace(unicodeChar)) {
- if (mActionBarAdapter.isSelectionMode()) {
+ if (mAllFragment.getActionBarAdapter().isSelectionMode()) {
// Ignore keyboard input when in selection mode.
return true;
}
String query = new String(new int[]{unicodeChar}, 0, 1);
- if (!mActionBarAdapter.isSearchMode()) {
- mActionBarAdapter.setSearchMode(true);
- mActionBarAdapter.setQueryString(query);
+ if (!mAllFragment.getActionBarAdapter().isSearchMode()) {
+ mAllFragment.getActionBarAdapter().setSearchMode(true);
+ mAllFragment.getActionBarAdapter().setQueryString(query);
return true;
}
}
@@ -1378,19 +757,34 @@
if (mDrawer.isDrawerOpen(GravityCompat.START)) {
mDrawer.closeDrawer(GravityCompat.START);
- } else if (mActionBarAdapter.isSelectionMode()) {
- mActionBarAdapter.setSelectionMode(false);
+ } else if (isGroupView()) {
+ if (mMembersFragment.isEditMode()) {
+ mMembersFragment.exitEditMode();
+ } else if (mMembersFragment.getActionBarAdapter().isSelectionMode()) {
+ mMembersFragment.getActionBarAdapter().setSelectionMode(false);
+ mMembersFragment.displayCheckBoxes(false);
+ } else if (mMembersFragment.getActionBarAdapter().isSearchMode()) {
+ mMembersFragment.getActionBarAdapter().setSearchMode(false);
+ } else {
+ switchToAllContacts();
+ }
+ } else if (isDuplicatesView()) {
+ switchToAllContacts();
+ } else if (mAllFragment.getActionBarAdapter().isSelectionMode()) {
+ mAllFragment.getActionBarAdapter().setSelectionMode(false);
mAllFragment.displayCheckBoxes(false);
- } else if (mActionBarAdapter.isSearchMode()) {
- mActionBarAdapter.setSearchMode(false);
-
+ } else if (mAllFragment.getActionBarAdapter().isSearchMode()) {
+ mAllFragment.getActionBarAdapter().setSearchMode(false);
if (mAllFragment.wasSearchResultClicked()) {
mAllFragment.resetSearchResultClicked();
} else {
Logger.logScreenView(this, ScreenType.SEARCH_EXIT);
Logger.logSearchEvent(mAllFragment.createSearchState());
}
- } else if (!isAllContactsFilter(mContactListFilterController.getFilter())) {
+ } else if (!AccountFilterUtil.isAllContactsFilter(mAllFragment.getFilter())
+ && !mAllFragment.isHidden()) {
+ // If mAllFragment is hidden, then mContactsUnavailableFragment is visible so we
+ // don't need to switch to all contacts.
switchToAllContacts();
} else {
super.onBackPressed();
@@ -1400,157 +794,18 @@
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- mActionBarAdapter.onSaveInstanceState(outState);
-
- // Clear the listener to make sure we don't get callbacks after onSaveInstanceState,
- // in order to avoid doing fragment transactions after it.
- // TODO Figure out a better way to deal with the issue.
- mDisableOptionItemSelected = true;
- mActionBarAdapter.setListener(null);
- if (mTabPager != null) {
- mTabPager.setOnPageChangeListener(null);
- }
+ outState.putParcelable(KEY_GROUP_URI, mGroupUri);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
- // In our own lifecycle, the focus is saved and restore but later taken away by the
- // ViewPager. As a hack, we force focus on the SearchView if we know that we are searching.
- // This fixes the keyboard going away on screen rotation
- if (mActionBarAdapter.isSearchMode()) {
- mActionBarAdapter.setFocusOnSearchView();
- }
- }
-
- @Override
- public DialogManager getDialogManager() {
- return mDialogManager;
- }
-
- @Override
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.floating_action_button:
- onFabClicked();
- break;
- default:
- Log.wtf(TAG, "Unexpected onClick event from " + view);
- }
- }
-
- public void onFabClicked() {
- final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
- // Copy our extras into the new intent.
- intent.putExtras(getIntent());
-
- final ContactListFilter filter = mContactListFilterController.getFilter();
- // If we are in account view, we pass the account explicitly in order to
- // create contact in the account. This will prevent the default account dialog
- // from being displayed.
- if (!isAllContactsFilter(filter) && filter.accountName != null &&
- filter.accountType != null) {
- final Account account = new Account(filter.accountName, filter.accountType);
- intent.putExtra(Intents.Insert.EXTRA_ACCOUNT, account);
- intent.putExtra(Intents.Insert.EXTRA_DATA_SET, filter.dataSet);
- } else if (isDeviceContactsFilter(filter)) {
- // It's OK to add this even though it's an implicit intent. If a different app
- // receives the intent it should just ignore the flag.
- intent.putExtra(CompactContactEditorActivity.EXTRA_SAVE_TO_DEVICE_FLAG, true);
- }
-
- try {
- ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent);
- } catch (ActivityNotFoundException ex) {
- Toast.makeText(PeopleActivity.this, R.string.missing_app,
- Toast.LENGTH_SHORT).show();
- }
- }
-
- /**
- * Returns the tab position adjusted for the text direction.
- */
- private int getTabPositionForTextDirection(int position) {
- if (isRTL()) {
- return TabState.COUNT - 1 - position;
- }
- return position;
- }
-
- private void setFilterAndUpdateTitle(ContactListFilter filter) {
- setFilterAndUpdateTitle(filter, true);
- }
-
- private void setFilterAndUpdateTitle(ContactListFilter filter, boolean restoreSelectedUri) {
- mAllFragment.setFilter(filter, restoreSelectedUri);
-
- mAllFragment.setListType(mContactListFilterController.getFilterListType());
-
- updateFilterMenu(filter);
-
- if (getSupportActionBar() != null) {
- String actionBarTitle;
- if (filter.filterType == ContactListFilter.FILTER_TYPE_DEVICE_CONTACTS) {
- actionBarTitle = getString(R.string.account_phone);
- } else if (!TextUtils.isEmpty(filter.accountName)) {
- actionBarTitle = getActionBarTitleForAccount(filter);
- } else {
- actionBarTitle = getString(R.string.contactsList);
- }
- getSupportActionBar().setTitle(actionBarTitle);
- if (CompatUtils.isNCompatible()) {
- this.setTitle(actionBarTitle);
- getWindow().getDecorView()
- .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
- }
- }
- }
-
- private String getActionBarTitleForAccount(ContactListFilter filter) {
- final AccountDisplayInfoFactory factory =
- AccountDisplayInfoFactory.forWritableAccounts(this);
- final AccountDisplayInfo displayableAccount = factory.getAccountDisplayInfoFor(filter);
- if (displayableAccount.hasGoogleAccountType()) {
- return getString(R.string.title_from_google);
- } else {
- return displayableAccount.withFormattedName(this, R.string.title_from_other_accounts)
- .getNameLabel().toString();
- }
- }
-
- // Persist filter only when it's of the type FILTER_TYPE_ALL_ACCOUNTS.
- private void persistFilterIfNeeded(ContactListFilter filter) {
- mContactListFilterController.setContactListFilter(filter,
- /* persistent */ isAllContactsFilter(filter));
- }
-
- private boolean isAllContactsFilter(ContactListFilter filter) {
- return filter != null && filter.isContactsFilterType();
- }
-
- private boolean isDeviceContactsFilter(ContactListFilter filter) {
- return filter.filterType == ContactListFilter.FILTER_TYPE_DEVICE_CONTACTS;
- }
-
- @Override
- protected boolean shouldFinish() {
- return false;
- }
-
- @Override
- protected ContactListFilter getContactListFilter() {
- return mContactListFilterController.getFilter();
- }
-
- @Override
- public void onLoadFinishedCallback() {
- maybeShowHamburgerFeatureHighlight();
+ mGroupUri = savedInstanceState.getParcelable(KEY_GROUP_URI);
}
private void onGroupDeleted(Intent intent) {
- if (!ContactSaveService.canUndo(intent)) {
- return;
- }
+ if (!ContactSaveService.canUndo(intent)) return;
+
Snackbar.make(mLayoutRoot, getString(R.string.groupDeletedToast), Snackbar.LENGTH_LONG)
.setAction(R.string.undo, new View.OnClickListener() {
@Override
@@ -1572,4 +827,101 @@
}
}
}
+
+ @Override
+ protected void onGroupMenuItemClicked(long groupId, String title) {
+ if (isGroupView() && mMembersFragment != null
+ && mMembersFragment.isCurrentGroup(groupId)) {
+ return;
+ }
+ mGroupUri = ContentUris.withAppendedId(ContactsContract.Groups.CONTENT_URI, groupId);
+ switchToOrUpdateGroupView(GroupUtil.ACTION_SWITCH_GROUP);
+ }
+
+ @Override
+ protected void onFilterMenuItemClicked(Intent intent) {
+ // We must pop second level first to "restart" mAllFragment, before changing filter.
+ if (isInSecondLevel()) {
+ popSecondLevel();
+ showFabWithAnimation(/* showFab */ true);
+ }
+ mCurrentView = ContactsView.ACCOUNT_VIEW;
+ super.onFilterMenuItemClicked(intent);
+ }
+
+ private void switchToOrUpdateGroupView(String action) {
+ if (mMembersFragment != null) {
+ mCurrentView = ContactsView.GROUP_VIEW;
+ mMembersFragment.updateDisplayedGroup(mGroupUri, action);
+ } else {
+ switchView(ContactsView.GROUP_VIEW);
+ }
+ }
+
+ @Override
+ protected void launchFindDuplicates() {
+ switchView(ContactsView.DUPLICATES);
+ }
+
+ private void switchView(ContactsView contactsView) {
+ mCurrentView = contactsView;
+ setUpNewFragment();
+ }
+
+ private void setUpNewFragment() {
+ final FragmentManager fragmentManager = getFragmentManager();
+ final FragmentTransaction transaction = fragmentManager.beginTransaction();
+ if (isGroupView()) {
+ mMembersFragment = GroupMembersFragment.newInstance(mGroupUri);
+ transaction.replace(
+ R.id.contacts_list_container, mMembersFragment, TAG_GROUP_VIEW);
+ } else if (isDuplicatesView()) {
+ final Fragment duplicatesFragment = ObjectFactory.getDuplicatesFragment();
+ final Fragment duplicatesUtilFragment = ObjectFactory.getDuplicatesUtilFragment();
+ if (duplicatesFragment != null && duplicatesUtilFragment != null) {
+ duplicatesUtilFragment.setTargetFragment(duplicatesFragment, /* requestCode */ 0);
+ transaction.replace(
+ R.id.contacts_list_container, duplicatesFragment, TAG_DUPLICATES);
+ transaction.add(duplicatesUtilFragment, TAG_DUPLICATES_UTIL);
+ }
+ }
+ transaction.addToBackStack(TAG_SECOND_LEVEL);
+ transaction.commit();
+ fragmentManager.executePendingTransactions();
+
+ resetFilter();
+ showFabWithAnimation(/* showFab */ false);
+ }
+
+ @Override
+ public void switchToAllContacts() {
+ if (isInSecondLevel()) {
+ popSecondLevel();
+ }
+ mCurrentView = ContactsView.ALL_CONTACTS;
+ showFabWithAnimation(/* showFab */ true);
+
+ super.switchToAllContacts();
+ }
+
+ private void popSecondLevel() {
+ getFragmentManager().popBackStackImmediate(
+ TAG_SECOND_LEVEL, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ mMembersFragment = null;
+ }
+
+ @Override
+ protected DefaultContactBrowseListFragment getAllFragment() {
+ return mAllFragment;
+ }
+
+ @Override
+ protected GroupMembersFragment getGroupFragment() {
+ return mMembersFragment;
+ }
+
+ @Override
+ protected GroupMetadata getGroupMetadata() {
+ return mMembersFragment == null ? null : mMembersFragment.getGroupMetadata();
+ }
}
diff --git a/src/com/android/contacts/common/Experiments.java b/src/com/android/contacts/common/Experiments.java
index c811e27..8932cac 100644
--- a/src/com/android/contacts/common/Experiments.java
+++ b/src/com/android/contacts/common/Experiments.java
@@ -20,6 +20,21 @@
*/
public final class Experiments {
+ /**
+ * Experiment to enable dynamic strequent shortcuts.
+ */
+ public static final String DYNAMIC_SHORTCUTS = "Shortcuts__dynamic_shortcuts";
+
+ /**
+ * Experiment to toggle contacts sync using the pull to refresh gesture.
+ */
+ public static final String PULL_TO_REFRESH = "PullToRefresh__pull_to_refresh";
+
+ /**
+ * Search study boolean indicating whether to inject yenta search results before CP2 results.
+ */
+ public static final String SEARCH_YENTA = "Search__yenta";
+
private Experiments() {
}
}
diff --git a/src/com/android/contacts/common/interactions/ImportExportDialogFragment.java b/src/com/android/contacts/common/interactions/ImportExportDialogFragment.java
index 7e1b487..0df0812 100644
--- a/src/com/android/contacts/common/interactions/ImportExportDialogFragment.java
+++ b/src/com/android/contacts/common/interactions/ImportExportDialogFragment.java
@@ -44,7 +44,6 @@
import com.android.contacts.common.R;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
-import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.AccountSelectionUtil;
@@ -53,7 +52,7 @@
import com.android.contacts.common.vcard.ExportVCardActivity;
import com.android.contacts.common.vcard.VCardCommonArguments;
import com.android.contacts.common.vcard.ShareVCardActivity;
-import com.android.contactsbind.analytics.AnalyticsUtil;
+import com.android.contacts.editor.SelectAccountDialogFragment;
import java.util.List;
diff --git a/src/com/android/contacts/common/list/ContactEntryListFragment.java b/src/com/android/contacts/common/list/ContactEntryListFragment.java
index 0c72d68..387b303 100644
--- a/src/com/android/contacts/common/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/common/list/ContactEntryListFragment.java
@@ -119,7 +119,7 @@
private boolean mEnabled = true;
private T mAdapter;
- private View mView;
+ protected View mView;
private ListView mListView;
/**
diff --git a/src/com/android/contacts/common/list/ContactListFilter.java b/src/com/android/contacts/common/list/ContactListFilter.java
index 4c8ca89..f7b90d3 100644
--- a/src/com/android/contacts/common/list/ContactListFilter.java
+++ b/src/com/android/contacts/common/list/ContactListFilter.java
@@ -16,6 +16,7 @@
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -26,6 +27,10 @@
import com.android.contacts.common.logging.ListEvent;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.model.account.GoogleAccountType;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* Contact list filter parameters.
@@ -379,4 +384,59 @@
return "(unknown)";
}
}
+
+ /**
+ * Returns true if this ContactListFilter contains at least one Google account.
+ * (see {@link #isGoogleAccountType)
+ */
+ public boolean isSyncable(List<AccountWithDataSet> accounts) {
+ // TODO(samchen): Check FILTER_TYPE_CUSTOM
+ if (isGoogleAccountType() && filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
+ return true;
+ }
+ if (filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS
+ || filterType == ContactListFilter.FILTER_TYPE_DEFAULT) {
+ if (accounts != null && accounts.size() > 0) {
+ // If we're showing all contacts and there is any Google account on the device then
+ // we're syncable.
+ for (AccountWithDataSet account : accounts) {
+ if (GoogleAccountType.ACCOUNT_TYPE.equals(account.type)
+ && account.dataSet == null) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the Google accounts (see {@link #isGoogleAccountType) for this ContactListFilter.
+ */
+ public List<Account> getSyncableAccounts(List<AccountWithDataSet> accounts) {
+ final List<Account> syncableAccounts = new ArrayList<>();
+ // TODO(samchen): Check FILTER_TYPE_CUSTOM
+ if (isGoogleAccountType() && filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
+ syncableAccounts.add(new Account(accountName, accountType));
+ } else if (filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS
+ || filterType == ContactListFilter.FILTER_TYPE_DEFAULT) {
+ if (accounts != null && accounts.size() > 0) {
+ for (AccountWithDataSet account : accounts) {
+ if (GoogleAccountType.ACCOUNT_TYPE.equals(account.type)
+ && account.dataSet == null) {
+ syncableAccounts.add(new Account(account.name, account.type));
+ }
+ }
+ }
+ }
+ return syncableAccounts;
+ }
+
+ /**
+ * Returns true if this ContactListFilter is Google account type. (i.e. where
+ * accountType = "com.google" and dataSet = null)
+ */
+ public boolean isGoogleAccountType() {
+ return GoogleAccountType.ACCOUNT_TYPE.equals(accountType) && dataSet == null;
+ }
}
diff --git a/src/com/android/contacts/common/list/DefaultContactListAdapter.java b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
index cf3f6f6..faade9e 100644
--- a/src/com/android/contacts/common/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
@@ -31,6 +31,7 @@
import android.text.TextUtils;
import android.view.View;
+import com.android.contacts.common.Experiments;
import com.android.contacts.common.compat.ContactsCompat;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.preference.ContactsPreferences;
@@ -115,6 +116,13 @@
loader.setUri(builder.build());
loader.setProjection(getProjection(true));
sortOrder = STREQUENT_SORT;
+ if (Flags.getInstance(getContext()).getBoolean(Experiments.SEARCH_YENTA)
+ && loader instanceof FavoritesAndContactsLoader
+ && directoryId == Directory.DEFAULT) {
+ final FavoritesAndContactsLoader favoritesAndContactsLoader =
+ (FavoritesAndContactsLoader) loader;
+ favoritesAndContactsLoader.setAutocompleteQuery(query);
+ }
}
} else {
final ContactListFilter filter = getFilter();
diff --git a/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java b/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
index d1ae911..c679110 100644
--- a/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
+++ b/src/com/android/contacts/common/list/FavoritesAndContactsLoader.java
@@ -19,29 +19,33 @@
import android.content.CursorLoader;
import android.database.Cursor;
import android.database.MergeCursor;
-import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
+import android.util.Log;
+import com.android.contactsbind.ObjectFactory;
+import com.android.contactsbind.search.AutocompleteHelper;
import com.google.common.collect.Lists;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* A loader for use in the default contact list, which will also query for favorite contacts
* if configured to do so.
*/
-public class FavoritesAndContactsLoader extends CursorLoader {
+public class FavoritesAndContactsLoader extends CursorLoader implements AutocompleteHelper.Listener {
+
+ private static final int AUTOCOMPLETE_TIMEOUT_MS = 1000;
private boolean mLoadFavorites;
private String[] mProjection;
- private Uri mExtraUri;
- private String[] mExtraProjection;
- private String mExtraSelection;
- private String[] mExtraSelectionArgs;
- private boolean mMergeExtraContactsAfterPrimary;
+ private String mAutocompleteQuery;
+ private CountDownLatch mAutocompleteLatch = new CountDownLatch(1);
+ private Cursor mAutocompleteCursor;
public FavoritesAndContactsLoader(Context context) {
super(context);
@@ -52,54 +56,51 @@
mLoadFavorites = flag;
}
+ public void setAutocompleteQuery(String autocompleteQuery) {
+ mAutocompleteQuery = autocompleteQuery;
+ }
+
public void setProjection(String[] projection) {
super.setProjection(projection);
mProjection = projection;
}
- /** Configure an extra query and merge results in before the primary results. */
- public void setLoadExtraContactsFirst(Uri uri, String[] projection) {
- mExtraUri = uri;
- mExtraProjection = projection;
- mMergeExtraContactsAfterPrimary = false;
- }
-
- /** Configure an extra query and merge results in after the primary results. */
- public void setLoadExtraContactsLast(Uri uri, String[] projection, String selection,
- String[] selectionArgs) {
- mExtraUri = uri;
- mExtraProjection = projection;
- mExtraSelection = selection;
- mExtraSelectionArgs = selectionArgs;
- mMergeExtraContactsAfterPrimary = true;
- }
-
- private boolean canLoadExtraContacts() {
- return mExtraUri != null && mExtraProjection != null;
- }
-
@Override
public Cursor loadInBackground() {
List<Cursor> cursors = Lists.newArrayList();
if (mLoadFavorites) {
cursors.add(loadFavoritesContacts());
}
- if (canLoadExtraContacts() && !mMergeExtraContactsAfterPrimary) {
- cursors.add(loadExtraContacts());
+
+ if (mAutocompleteQuery != null) {
+ final AutocompleteHelper autocompleteHelper =
+ ObjectFactory.getAutocompleteHelper(getContext());
+ if (autocompleteHelper != null) {
+ autocompleteHelper.setListener(this);
+ autocompleteHelper.setProjection(mProjection);
+ autocompleteHelper.setQuery(mAutocompleteQuery);
+ try {
+ if (!mAutocompleteLatch.await(AUTOCOMPLETE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+ logw("Timeout expired before receiving autocompletions");
+ }
+ } catch (InterruptedException e) {
+ logw("Interrupted while waiting for autocompletions");
+ }
+ if (mAutocompleteCursor != null) {
+ cursors.add(mAutocompleteCursor);
+ // TODO: exclude these results from the main loader results, see b/30742359
+ }
+ }
}
- // ContactsCursor.loadInBackground() can return null; MergeCursor
- // correctly handles null cursors.
- Cursor cursor = null;
- try {
- cursor = super.loadInBackground();
- } catch (NullPointerException | SecurityException e) {
- // Ignore NPEs and SecurityExceptions thrown by providers
+
+ // TODO: if the autocomplete experiment in on, only show those results even if they're empty
+ final Cursor contactsCursor = mAutocompleteQuery == null ? loadContacts() : null;
+ if (mAutocompleteQuery == null) {
+ cursors.add(contactsCursor);
}
- final Cursor contactsCursor = cursor;
- cursors.add(contactsCursor);
- if (canLoadExtraContacts() && mMergeExtraContactsAfterPrimary) {
- cursors.add(loadExtraContacts());
- }
+ // Guard against passing an empty array to the MergeCursor constructor
+ if (cursors.isEmpty()) cursors.add(null);
+
return new MergeCursor(cursors.toArray(new Cursor[cursors.size()])) {
@Override
public Bundle getExtras() {
@@ -109,9 +110,15 @@
};
}
- private Cursor loadExtraContacts() {
- return getContext().getContentResolver().query(
- mExtraUri, mExtraProjection, mExtraSelection, mExtraSelectionArgs, null);
+ private Cursor loadContacts() {
+ // ContactsCursor.loadInBackground() can return null; MergeCursor
+ // correctly handles null cursors.
+ try {
+ return super.loadInBackground();
+ } catch (NullPointerException | SecurityException e) {
+ // Ignore NPEs and SecurityExceptions thrown by providers
+ }
+ return null;
}
private Cursor loadFavoritesContacts() {
@@ -119,4 +126,20 @@
Contacts.CONTENT_URI, mProjection, Contacts.STARRED + "=?", new String[]{"1"},
getSortOrder());
}
+
+ @Override
+ public void onAutocompletesAvailable(Cursor cursor) {
+ if (cursor == null || cursor.getCount() == 0) {
+ logw("Ignoring null or empty autocompletions");
+ } else {
+ mAutocompleteCursor = cursor;
+ mAutocompleteLatch.countDown();
+ }
+ }
+
+ private static void logw(String message) {
+ if (Log.isLoggable(AutocompleteHelper.TAG, Log.WARN)) {
+ Log.w(AutocompleteHelper.TAG, message);
+ }
+ }
}
diff --git a/src/com/android/contacts/common/list/MultiSelectEntryContactListAdapter.java b/src/com/android/contacts/common/list/MultiSelectEntryContactListAdapter.java
index 9ab6e1c..dbfd70e 100644
--- a/src/com/android/contacts/common/list/MultiSelectEntryContactListAdapter.java
+++ b/src/com/android/contacts/common/list/MultiSelectEntryContactListAdapter.java
@@ -113,9 +113,6 @@
* Not guaranteed to work with all configurations of this adapter.
*/
public void setDisplayCheckBoxes(boolean showCheckBoxes) {
- if (!mDisplayCheckBoxes && showCheckBoxes) {
- setSelectedContactIds(new TreeSet<Long>());
- }
mDisplayCheckBoxes = showCheckBoxes;
notifyDataSetChanged();
if (mSelectedContactsListener != null) {
diff --git a/src/com/android/contacts/common/list/ViewPagerTabStrip.java b/src/com/android/contacts/common/list/ViewPagerTabStrip.java
deleted file mode 100644
index c8ae21a..0000000
--- a/src/com/android/contacts/common/list/ViewPagerTabStrip.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.common.list;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.android.contacts.common.R;
-
-public class ViewPagerTabStrip extends LinearLayout {
- private int mSelectedUnderlineThickness;
- private final Paint mSelectedUnderlinePaint;
-
- private int mIndexForSelection;
- private float mSelectionOffset;
-
- public ViewPagerTabStrip(Context context) {
- this(context, null);
- }
-
- public ViewPagerTabStrip(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- final Resources res = context.getResources();
-
- mSelectedUnderlineThickness =
- res.getDimensionPixelSize(R.dimen.tab_selected_underline_height);
- int underlineColor = res.getColor(R.color.tab_selected_underline_color);
- int backgroundColor = res.getColor(R.color.actionbar_background_color);
-
- mSelectedUnderlinePaint = new Paint();
- mSelectedUnderlinePaint.setColor(underlineColor);
-
- setBackgroundColor(backgroundColor);
- setWillNotDraw(false);
- }
-
- /**
- * Notifies this view that view pager has been scrolled. We save the tab index
- * and selection offset for interpolating the position and width of selection
- * underline.
- */
- void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- mIndexForSelection = position;
- mSelectionOffset = positionOffset;
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- int childCount = getChildCount();
-
- // Thick colored underline below the current selection
- if (childCount > 0) {
- View selectedTitle = getChildAt(mIndexForSelection);
-
- if (selectedTitle == null) {
- // The view pager's tab count changed but we weren't notified yet. Ignore this draw
- // pass, when we get a new selection we will update and draw the selection strip in
- // the correct place.
- return;
- }
- int selectedLeft = selectedTitle.getLeft();
- int selectedRight = selectedTitle.getRight();
- final boolean isRtl = isRtl();
- final boolean hasNextTab = isRtl ? mIndexForSelection > 0
- : (mIndexForSelection < (getChildCount() - 1));
- if ((mSelectionOffset > 0.0f) && hasNextTab) {
- // Draw the selection partway between the tabs
- View nextTitle = getChildAt(mIndexForSelection + (isRtl ? -1 : 1));
- int nextLeft = nextTitle.getLeft();
- int nextRight = nextTitle.getRight();
-
- selectedLeft = (int) (mSelectionOffset * nextLeft +
- (1.0f - mSelectionOffset) * selectedLeft);
- selectedRight = (int) (mSelectionOffset * nextRight +
- (1.0f - mSelectionOffset) * selectedRight);
- }
-
- int height = getHeight();
- canvas.drawRect(selectedLeft, height - mSelectedUnderlineThickness,
- selectedRight, height, mSelectedUnderlinePaint);
- }
- }
-
- private boolean isRtl() {
- return getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
- }
-}
\ No newline at end of file
diff --git a/src/com/android/contacts/common/list/ViewPagerTabs.java b/src/com/android/contacts/common/list/ViewPagerTabs.java
deleted file mode 100644
index 48de6af..0000000
--- a/src/com/android/contacts/common/list/ViewPagerTabs.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.contacts.common.list;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.Outline;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewOutlineProvider;
-import android.widget.FrameLayout;
-import android.widget.HorizontalScrollView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.android.contacts.common.R;
-import com.android.contacts.common.compat.CompatUtils;
-
-/**
- * Lightweight implementation of ViewPager tabs. This looks similar to traditional actionBar tabs,
- * but allows for the view containing the tabs to be placed anywhere on screen. Text-related
- * attributes can also be assigned in XML - these will get propogated to the child TextViews
- * automatically.
- */
-public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnPageChangeListener {
-
- ViewPager mPager;
- private ViewPagerTabStrip mTabStrip;
-
- /**
- * Linearlayout that will contain the TextViews serving as tabs. This is the only child
- * of the parent HorizontalScrollView.
- */
- final int mTextStyle;
- final ColorStateList mTextColor;
- final int mTextSize;
- final boolean mTextAllCaps;
- int mPrevSelected = -1;
- int mSidePadding;
-
- private int[] mTabIcons;
- // For displaying the unread count next to the tab icon.
- private int[] mUnreadCounts;
-
- private static final ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER;
- static {
- if (CompatUtils.isLollipopCompatible()) {
- VIEW_BOUNDS_OUTLINE_PROVIDER = new ViewOutlineProvider() {
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setRect(0, 0, view.getWidth(), view.getHeight());
- }
- };
- } else {
- VIEW_BOUNDS_OUTLINE_PROVIDER = null;
- }
- }
-
- private static final int TAB_SIDE_PADDING_IN_DPS = 10;
-
- // TODO: This should use <declare-styleable> in the future
- private static final int[] ATTRS = new int[] {
- android.R.attr.textSize,
- android.R.attr.textStyle,
- android.R.attr.textColor,
- android.R.attr.textAllCaps
- };
-
- /**
- * Simulates actionbar tab behavior by showing a toast with the tab title when long clicked.
- */
- private class OnTabLongClickListener implements OnLongClickListener {
- final int mPosition;
-
- public OnTabLongClickListener(int position) {
- mPosition = position;
- }
-
- @Override
- public boolean onLongClick(View v) {
- final int[] screenPos = new int[2];
- getLocationOnScreen(screenPos);
-
- final Context context = getContext();
- final int width = getWidth();
- final int height = getHeight();
- final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
-
- Toast toast = Toast.makeText(context, mPager.getAdapter().getPageTitle(mPosition),
- Toast.LENGTH_SHORT);
-
- // Show the toast under the tab
- toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL,
- (screenPos[0] + width / 2) - screenWidth / 2, screenPos[1] + height);
-
- toast.show();
- return true;
- }
- }
-
- public ViewPagerTabs(Context context) {
- this(context, null);
- }
-
- public ViewPagerTabs(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- setFillViewport(true);
-
- mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);
-
- final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
- mTextSize = a.getDimensionPixelSize(0, 0);
- mTextStyle = a.getInt(1, 0);
- mTextColor = a.getColorStateList(2);
- mTextAllCaps = a.getBoolean(3, false);
-
- mTabStrip = new ViewPagerTabStrip(context);
- addView(mTabStrip,
- new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
- a.recycle();
-
- if (CompatUtils.isLollipopCompatible()) {
- // enable shadow casting from view bounds
- setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
- }
- }
-
- public void setViewPager(ViewPager viewPager) {
- mPager = viewPager;
- addTabs(mPager.getAdapter());
- }
-
- /**
- * Set the tab icons and initialize an array for unread counts the same length as the icon
- * array.
- *
- * @param tabIcons An array representing the tab icons in order.
- */
- public void configureTabIcons(int[] tabIcons) {
- mTabIcons = tabIcons;
- mUnreadCounts = new int[tabIcons.length];
- }
-
- public void setUnreadCount(int count, int position) {
- if (mUnreadCounts == null || position >= mUnreadCounts.length) {
- return;
- }
- mUnreadCounts[position] = count;
- }
-
- private void addTabs(PagerAdapter adapter) {
- mTabStrip.removeAllViews();
-
- final int count = adapter.getCount();
- for (int i = 0; i < count; i++) {
- addTab(adapter.getPageTitle(i), i);
- }
- }
-
- private void addTab(CharSequence tabTitle, final int position) {
- View tabView;
- if (mTabIcons != null && position < mTabIcons.length) {
- View layout = LayoutInflater.from(getContext()).inflate(
- R.layout.unread_count_tab, null);
- View iconView = layout.findViewById(R.id.icon);
- iconView.setBackgroundResource(mTabIcons[position]);
- iconView.setContentDescription(tabTitle);
- TextView textView = (TextView) layout.findViewById(R.id.count);
- if (mUnreadCounts != null && mUnreadCounts[position] > 0) {
- textView.setText(Integer.toString(mUnreadCounts[position]));
- textView.setVisibility(View.VISIBLE);
- iconView.setContentDescription(getResources().getQuantityString(
- R.plurals.tab_title_with_unread_items,
- mUnreadCounts[position],
- tabTitle.toString(),
- mUnreadCounts[position]));
- } else {
- textView.setVisibility(View.INVISIBLE);
- iconView.setContentDescription(tabTitle);
- }
- tabView = layout;
- } else {
- final TextView textView = new TextView(getContext());
- textView.setText(tabTitle);
- textView.setBackgroundResource(R.drawable.view_pager_tab_background);
-
- // Assign various text appearance related attributes to child views.
- if (mTextStyle > 0) {
- textView.setTypeface(textView.getTypeface(), mTextStyle);
- }
- if (mTextSize > 0) {
- textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
- }
- if (mTextColor != null) {
- textView.setTextColor(mTextColor);
- }
- textView.setAllCaps(mTextAllCaps);
- textView.setGravity(Gravity.CENTER);
-
- tabView = textView;
- }
-
- tabView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mPager.setCurrentItem(getRtlPosition(position));
- }
- });
-
- tabView.setOnLongClickListener(new OnTabLongClickListener(position));
-
- tabView.setPadding(mSidePadding, 0, mSidePadding, 0);
-
- mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(
- LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
-
- // Default to the first child being selected
- if (position == 0) {
- mPrevSelected = 0;
- tabView.setSelected(true);
- }
- }
-
- /**
- * Remove a tab at a certain index.
- *
- * @param index The index of the tab view we wish to remove.
- */
- public void removeTab(int index) {
- View view = mTabStrip.getChildAt(index);
- if (view != null) {
- mTabStrip.removeView(view);
- }
- }
-
- /**
- * Refresh a tab at a certain index by removing it and reconstructing it.
- *
- * @param index The index of the tab view we wish to update.
- */
- public void updateTab(int index) {
- removeTab(index);
-
- if (index < mPager.getAdapter().getCount()) {
- addTab(mPager.getAdapter().getPageTitle(index), index);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- position = getRtlPosition(position);
- int tabStripChildCount = mTabStrip.getChildCount();
- if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
- return;
- }
-
- mTabStrip.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
-
- @Override
- public void onPageSelected(int position) {
- position = getRtlPosition(position);
- int tabStripChildCount = mTabStrip.getChildCount();
- if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
- return;
- }
-
- if (mPrevSelected >= 0 && mPrevSelected < tabStripChildCount) {
- mTabStrip.getChildAt(mPrevSelected).setSelected(false);
- }
- final View selectedChild = mTabStrip.getChildAt(position);
- selectedChild.setSelected(true);
-
- // Update scroll position
- final int scrollPos = selectedChild.getLeft() - (getWidth() - selectedChild.getWidth()) / 2;
- smoothScrollTo(scrollPos, 0);
- mPrevSelected = position;
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- }
-
- private int getRtlPosition(int position) {
- if (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
- return mTabStrip.getChildCount() - 1 - position;
- }
- return position;
- }
-}
-
diff --git a/src/com/android/contacts/common/model/AccountTypeManager.java b/src/com/android/contacts/common/model/AccountTypeManager.java
index c9f68d4..8ec6c2e 100644
--- a/src/com/android/contacts/common/model/AccountTypeManager.java
+++ b/src/com/android/contacts/common/model/AccountTypeManager.java
@@ -580,7 +580,7 @@
boolean syncable =
ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY) > 0;
- if (syncable) {
+ if (syncable || GoogleAccountType.ACCOUNT_TYPE.equals(account.type)) {
List<AccountType> accountTypes = accountTypesByType.get(account.type);
if (accountTypes != null) {
// Add an account-with-data-set entry for each account type that is
diff --git a/src/com/android/contacts/common/model/RawContactModifier.java b/src/com/android/contacts/common/model/RawContactModifier.java
index 3cd200c..be5f8f2 100644
--- a/src/com/android/contacts/common/model/RawContactModifier.java
+++ b/src/com/android/contacts/common/model/RawContactModifier.java
@@ -694,7 +694,7 @@
final Integer type = values.getAsInteger(Phone.TYPE);
// If the provided phone number provides a custom phone type but not a label,
// replace it with mobile (by default) to avoid the "Enter custom label" from
- // popping up immediately upon entering the ContactEditorFragment
+ // popping up immediately upon entering the CompactContactEditorFragment
if (type != null && type == Phone.TYPE_CUSTOM &&
TextUtils.isEmpty(values.getAsString(Phone.LABEL))) {
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
diff --git a/src/com/android/contacts/common/util/AccountFilterUtil.java b/src/com/android/contacts/common/util/AccountFilterUtil.java
index 2d59981..9db0e26 100644
--- a/src/com/android/contacts/common/util/AccountFilterUtil.java
+++ b/src/com/android/contacts/common/util/AccountFilterUtil.java
@@ -16,17 +16,23 @@
package com.android.contacts.common.util;
+import android.accounts.Account;
import android.app.Activity;
import android.app.Fragment;
+import android.content.ActivityNotFoundException;
import android.content.AsyncTaskLoader;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Intents;
import android.text.TextUtils;
import android.util.Log;
+import android.widget.Toast;
-import com.android.contacts.common.R;
+import com.android.contacts.R;
+import com.android.contacts.activities.CompactContactEditorActivity;
import com.android.contacts.common.list.AccountFilterActivity;
import com.android.contacts.common.list.ContactListFilter;
import com.android.contacts.common.list.ContactListFilterController;
@@ -161,4 +167,54 @@
return null;
}
}
+
+ /**
+ * Returns a {@link ContactListFilter} of type
+ * {@link ContactListFilter#FILTER_TYPE_ALL_ACCOUNTS}, or if a custom "Contacts to display"
+ * filter has been set, then one of type {@link ContactListFilter#FILTER_TYPE_CUSTOM}.
+ */
+ public static ContactListFilter createContactsFilter(Context context) {
+ final int filterType =
+ ContactListFilterController.getInstance(context).isCustomFilterPersisted()
+ ? ContactListFilter.FILTER_TYPE_CUSTOM
+ : ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS;
+ return ContactListFilter.createFilterWithType(filterType);
+ }
+
+ /**
+ * Start editor intent; and if filter is an account filter, we pass account info to editor so
+ * as to create a contact in that account.
+ */
+ public static void startEditorIntent(Context context, Intent src, ContactListFilter filter) {
+ final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
+ intent.putExtras(src);
+
+ // If we are in account view, we pass the account explicitly in order to
+ // create contact in the account. This will prevent the default account dialog
+ // from being displayed.
+ if (!isAllContactsFilter(filter) && filter.accountName != null
+ && filter.accountType != null) {
+ final Account account = new Account(filter.accountName, filter.accountType);
+ intent.putExtra(Intents.Insert.EXTRA_ACCOUNT, account);
+ intent.putExtra(Intents.Insert.EXTRA_DATA_SET, filter.dataSet);
+ } else if (isDeviceContactsFilter(filter)) {
+ // It's OK to add this even though it's an implicit intent. If a different app
+ // receives the intent it should just ignore the flag.
+ intent.putExtra(CompactContactEditorActivity.EXTRA_SAVE_TO_DEVICE_FLAG, true);
+ }
+
+ try {
+ ImplicitIntentsUtil.startActivityInApp(context, intent);
+ } catch (ActivityNotFoundException ex) {
+ Toast.makeText(context, R.string.missing_app, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ public static boolean isAllContactsFilter(ContactListFilter filter) {
+ return filter != null && filter.isContactsFilterType();
+ }
+
+ public static boolean isDeviceContactsFilter(ContactListFilter filter) {
+ return filter.filterType == ContactListFilter.FILTER_TYPE_DEVICE_CONTACTS;
+ }
}
diff --git a/src/com/android/contacts/common/util/DateUtils.java b/src/com/android/contacts/common/util/DateUtils.java
index c695ec6..097230c 100644
--- a/src/com/android/contacts/common/util/DateUtils.java
+++ b/src/com/android/contacts/common/util/DateUtils.java
@@ -18,8 +18,6 @@
import android.content.Context;
import android.text.format.DateFormat;
-import android.text.format.Time;
-
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@@ -269,23 +267,4 @@
}
return anniversary.getTime();
}
-
- /**
- * Determine the difference, in days between two dates. Uses similar logic as the
- * {@link android.text.format.DateUtils.getRelativeTimeSpanString} method.
- *
- * @param time Instance of time object to use for calculations.
- * @param date1 First date to check.
- * @param date2 Second date to check.
- * @return The absolute difference in days between the two dates.
- */
- public static int getDayDifference(Time time, long date1, long date2) {
- time.set(date1);
- int startDay = Time.getJulianDay(date1, time.gmtoff);
-
- time.set(date2);
- int currentDay = Time.getJulianDay(date2, time.gmtoff);
-
- return Math.abs(currentDay - startDay);
- }
}
diff --git a/src/com/android/contacts/common/vcard/NfcImportVCardActivity.java b/src/com/android/contacts/common/vcard/NfcImportVCardActivity.java
index 0634df4..6093405 100644
--- a/src/com/android/contacts/common/vcard/NfcImportVCardActivity.java
+++ b/src/com/android/contacts/common/vcard/NfcImportVCardActivity.java
@@ -17,6 +17,8 @@
package com.android.contacts.common.vcard;
import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -27,9 +29,11 @@
import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;
+import android.widget.Toast;
import com.android.contacts.common.R;
import com.android.contacts.common.activity.RequestPermissionsActivity;
@@ -59,6 +63,12 @@
private NdefRecord mRecord;
private AccountWithDataSet mAccount;
+ private Handler mHandler = new Handler();
+
+ /**
+ * Notification id used when error happened before sending an import request to VCardServer.
+ */
+ private static final int FAILURE_NOTIFICATION_ID = 1;
/* package */ class ImportTask extends AsyncTask<VCardService, Void, ImportRequest> {
@Override
@@ -81,6 +91,10 @@
@Override
public void onPostExecute(ImportRequest request) {
+ if (request == null) {
+ // Finish the activity in case of error so it doesn't stay in view.
+ finish();
+ }
unbindService(NfcImportVCardActivity.this);
}
}
@@ -111,6 +125,8 @@
parser.addInterpreter(detector);
parser.parse(is);
} catch (VCardVersionException e2) {
+ Log.e(TAG, "vCard with unsupported version.");
+ showFailureNotification(R.string.fail_reason_not_supported);
return null;
}
} finally {
@@ -120,14 +136,16 @@
}
}
} catch (IOException e) {
- Log.e(TAG, "Failed reading vcard data", e);
+ Log.e(TAG, "Failed reading vCard data", e);
+ showFailureNotification(R.string.fail_reason_io_error);
return null;
} catch (VCardNestedException e) {
Log.w(TAG, "Nested Exception is found (it may be false-positive).");
// Go through without throwing the Exception, as we may be able to detect the
// version before it
} catch (VCardException e) {
- Log.e(TAG, "Error parsing vcard", e);
+ Log.e(TAG, "Error parsing vCard", e);
+ showFailureNotification(R.string.fail_reason_not_supported);
return null;
}
@@ -242,7 +260,8 @@
Log.i(TAG, "Late import failure -- ignoring");
return;
}
- // TODO: report failure
+ showFailureNotification(R.string.vcard_import_request_rejected_message);
+ finish();
}
@Override
@@ -269,4 +288,22 @@
public void onComplete() {
// do nothing
}
+
+ /* package */ void showFailureNotification(int reasonId) {
+ final NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ final Notification notification =
+ NotificationImportExportListener.constructImportFailureNotification(
+ this,
+ getString(reasonId));
+ notificationManager.notify(NotificationImportExportListener.FAILURE_NOTIFICATION_TAG,
+ FAILURE_NOTIFICATION_ID, notification);
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(NfcImportVCardActivity.this,
+ getString(R.string.vcard_import_failed), Toast.LENGTH_LONG).show();
+ }
+ });
+ }
}
diff --git a/src/com/android/contacts/editor/CancelEditDialogFragment.java b/src/com/android/contacts/editor/CancelEditDialogFragment.java
index ba5f9fa..ec937a6 100644
--- a/src/com/android/contacts/editor/CancelEditDialogFragment.java
+++ b/src/com/android/contacts/editor/CancelEditDialogFragment.java
@@ -35,7 +35,7 @@
* Shows a {@link CancelEditDialogFragment} after setting the given Fragment as the
* target of the dialog.
*/
- public static void show(ContactEditorBaseFragment fragment) {
+ public static void show(CompactContactEditorFragment fragment) {
final CancelEditDialogFragment dialog = new CancelEditDialogFragment();
dialog.setTargetFragment(fragment, 0);
dialog.show(fragment.getFragmentManager(), TAG);
@@ -69,4 +69,4 @@
*/
void onCancelEditConfirmed();
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index 1d7fa46..838bafd 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -16,48 +16,539 @@
package com.android.contacts.editor;
-import com.android.contacts.ContactSaveService;
-import com.android.contacts.R;
-import com.android.contacts.activities.CompactContactEditorActivity;
-import com.android.contacts.common.model.RawContactDelta;
-import com.android.contacts.common.model.ValuesDelta;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.util.ContactPhotoUtils;
-
+import android.accounts.Account;
import android.app.Activity;
+import android.app.Fragment;
+import android.app.LoaderManager;
+import android.content.ActivityNotFoundException;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.CursorLoader;
import android.content.Intent;
+import android.content.Loader;
+import android.database.Cursor;
import android.graphics.Bitmap;
+import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
+import android.os.SystemClock;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Email;
+import android.provider.ContactsContract.CommonDataKinds.Event;
+import android.provider.ContactsContract.CommonDataKinds.Organization;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.StructuredName;
+import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
+import android.provider.ContactsContract.Intents;
+import android.provider.ContactsContract.RawContacts;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
import android.widget.LinearLayout;
+import android.widget.ListPopupWindow;
import android.widget.Toast;
+import com.android.contacts.ContactSaveService;
+import com.android.contacts.GroupMetaDataLoader;
+import com.android.contacts.R;
+import com.android.contacts.activities.CompactContactEditorActivity;
+import com.android.contacts.activities.CompactContactEditorActivity.ContactEditor;
+import com.android.contacts.activities.ContactEditorAccountsChangedActivity;
+import com.android.contacts.activities.ContactSelectionActivity;
+import com.android.contacts.common.logging.ScreenEvent.ScreenType;
+import com.android.contacts.common.model.AccountTypeManager;
+import com.android.contacts.common.model.Contact;
+import com.android.contacts.common.model.ContactLoader;
+import com.android.contacts.common.model.RawContact;
+import com.android.contacts.common.model.RawContactDelta;
+import com.android.contacts.common.model.RawContactDeltaList;
+import com.android.contacts.common.model.RawContactModifier;
+import com.android.contacts.common.model.ValuesDelta;
+import com.android.contacts.common.model.account.AccountType;
+import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
+import com.android.contacts.common.util.MaterialColorMapUtils;
+import com.android.contacts.editor.AggregationSuggestionEngine.Suggestion;
+import com.android.contacts.list.UiIntentActions;
+import com.android.contacts.quickcontact.QuickContactActivity;
+import com.android.contacts.util.ContactPhotoUtils;
+import com.android.contacts.util.HelpUtils;
+import com.android.contacts.util.PhoneCapabilityTester;
+import com.android.contacts.util.UiClosables;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
import java.io.FileNotFoundException;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
/**
* Contact editor with only the most important fields displayed initially.
*/
-public class CompactContactEditorFragment extends ContactEditorBaseFragment implements
+public class CompactContactEditorFragment extends Fragment implements
+ ContactEditor, SplitContactConfirmationDialogFragment.Listener,
+ JoinContactConfirmationDialogFragment.Listener,
+ AggregationSuggestionEngine.Listener, AggregationSuggestionView.Listener,
+ CancelEditDialogFragment.Listener,
CompactRawContactsEditorView.Listener, CompactPhotoEditorView.Listener {
+ static final String TAG = "ContactEditor";
+
+ private static final int LOADER_CONTACT = 1;
+ private static final int LOADER_GROUPS = 2;
+
private static final String KEY_PHOTO_RAW_CONTACT_ID = "photo_raw_contact_id";
private static final String KEY_UPDATED_PHOTOS = "updated_photos";
+ private static final List<String> VALID_INTENT_ACTIONS = new ArrayList<String>() {{
+ add(Intent.ACTION_EDIT);
+ add(Intent.ACTION_INSERT);
+ add(CompactContactEditorActivity.ACTION_SAVE_COMPLETED);
+ }};
+
+ private static final String KEY_ACTION = "action";
+ private static final String KEY_URI = "uri";
+ private static final String KEY_AUTO_ADD_TO_DEFAULT_GROUP = "autoAddToDefaultGroup";
+ private static final String KEY_DISABLE_DELETE_MENU_OPTION = "disableDeleteMenuOption";
+ private static final String KEY_NEW_LOCAL_PROFILE = "newLocalProfile";
+ private static final String KEY_MATERIAL_PALETTE = "materialPalette";
+ private static final String KEY_PHOTO_ID = "photoId";
+
+ private static final String KEY_VIEW_ID_GENERATOR = "viewidgenerator";
+
+ private static final String KEY_RAW_CONTACTS = "rawContacts";
+
+ private static final String KEY_EDIT_STATE = "state";
+ private static final String KEY_STATUS = "status";
+
+ private static final String KEY_HAS_NEW_CONTACT = "hasNewContact";
+ private static final String KEY_NEW_CONTACT_READY = "newContactDataReady";
+
+ private static final String KEY_IS_EDIT = "isEdit";
+ private static final String KEY_EXISTING_CONTACT_READY = "existingContactDataReady";
+
+ private static final String KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "isReadOnly";
+
+ // Phone option menus
+ private static final String KEY_SEND_TO_VOICE_MAIL_STATE = "sendToVoicemailState";
+ private static final String KEY_ARE_PHONE_OPTIONS_CHANGEABLE = "arePhoneOptionsChangable";
+ private static final String KEY_CUSTOM_RINGTONE = "customRingtone";
+
+ private static final String KEY_IS_USER_PROFILE = "isUserProfile";
+
+ private static final String KEY_ENABLED = "enabled";
+
+ // Aggregation PopupWindow
+ private static final String KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID =
+ "aggregationSuggestionsRawContactId";
+
+ // Join Activity
+ private static final String KEY_CONTACT_ID_FOR_JOIN = "contactidforjoin";
+
+ private static final String KEY_READ_ONLY_DISPLAY_NAME = "readOnlyDisplayName";
+
+ protected static final int REQUEST_CODE_JOIN = 0;
+ protected static final int REQUEST_CODE_ACCOUNTS_CHANGED = 1;
+ protected static final int REQUEST_CODE_PICK_RINGTONE = 2;
+
+ private static final int CURRENT_API_VERSION = android.os.Build.VERSION.SDK_INT;
+
+ /**
+ * An intent extra that forces the editor to add the edited contact
+ * to the default group (e.g. "My Contacts").
+ */
+ public static final String INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY = "addToDefaultDirectory";
+
+ public static final String INTENT_EXTRA_NEW_LOCAL_PROFILE = "newLocalProfile";
+
+ public static final String INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION =
+ "disableDeleteMenuOption";
+
+ /**
+ * Intent key to pass the photo palette primary color calculated by
+ * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between
+ * the compact and fully expanded editors.
+ */
+ public static final String INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR =
+ "material_palette_primary_color";
+
+ /**
+ * Intent key to pass the photo palette secondary color calculated by
+ * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between
+ * the compact and fully expanded editors.
+ */
+ public static final String INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR =
+ "material_palette_secondary_color";
+
+ /**
+ * Intent key to pass the ID of the photo to display on the editor.
+ */
+ public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";
+
+ /**
+ * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
+ * by itself.
+ */
+ public static final String INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE =
+ "raw_contact_id_to_display_alone";
+
+ /**
+ * Intent key to pass the boolean value of if the raw contact id that should be displayed
+ * in the full editor by itself is read-only.
+ */
+ public static final String INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY =
+ "raw_contact_display_alone_is_read_only";
+
+ /**
+ * Intent extra to specify a {@link ContactEditor.SaveMode}.
+ */
+ public static final String SAVE_MODE_EXTRA_KEY = "saveMode";
+
+ /**
+ * Intent extra key for the contact ID to join the current contact to after saving.
+ */
+ public static final String JOIN_CONTACT_ID_EXTRA_KEY = "joinContactId";
+
+ /**
+ * Callbacks for Activities that host contact editors Fragments.
+ */
+ public interface Listener {
+
+ /**
+ * Contact was not found, so somehow close this fragment. This is raised after a contact
+ * is removed via Menu/Delete
+ */
+ void onContactNotFound();
+
+ /**
+ * Contact was split, so we can close now.
+ *
+ * @param newLookupUri The lookup uri of the new contact that should be shown to the user.
+ * The editor tries best to chose the most natural contact here.
+ */
+ void onContactSplit(Uri newLookupUri);
+
+ /**
+ * User has tapped Revert, close the fragment now.
+ */
+ void onReverted();
+
+ /**
+ * Contact was saved and the Fragment can now be closed safely.
+ */
+ void onSaveFinished(Intent resultIntent);
+
+ /**
+ * User switched to editing a different contact (a suggestion from the
+ * aggregation engine).
+ */
+ void onEditOtherContactRequested(Uri contactLookupUri,
+ ArrayList<ContentValues> contentValues);
+
+ /**
+ * Contact is being created for an external account that provides its own
+ * new contact activity.
+ */
+ void onCustomCreateContactActivityRequested(AccountWithDataSet account,
+ Bundle intentExtras);
+
+ /**
+ * The edited raw contact belongs to an external account that provides
+ * its own edit activity.
+ *
+ * @param redirect indicates that the current editor should be closed
+ * before the custom editor is shown.
+ */
+ void onCustomEditContactActivityRequested(AccountWithDataSet account, Uri rawContactUri,
+ Bundle intentExtras, boolean redirect);
+
+ /**
+ * User has requested that contact be deleted.
+ */
+ void onDeleteRequested(Uri contactUri);
+ }
+
+ /**
+ * Adapter for aggregation suggestions displayed in a PopupWindow when
+ * editor fields change.
+ */
+ private static final class AggregationSuggestionAdapter extends BaseAdapter {
+ private final LayoutInflater mLayoutInflater;
+ private final boolean mSetNewContact;
+ private final AggregationSuggestionView.Listener mListener;
+ private final List<AggregationSuggestionEngine.Suggestion> mSuggestions;
+
+ public AggregationSuggestionAdapter(Activity activity, boolean setNewContact,
+ AggregationSuggestionView.Listener listener, List<Suggestion> suggestions) {
+ mLayoutInflater = activity.getLayoutInflater();
+ mSetNewContact = setNewContact;
+ mListener = listener;
+ mSuggestions = suggestions;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ final Suggestion suggestion = (Suggestion) getItem(position);
+ final AggregationSuggestionView suggestionView =
+ (AggregationSuggestionView) mLayoutInflater.inflate(
+ R.layout.aggregation_suggestions_item, null);
+ suggestionView.setNewContact(mSetNewContact);
+ suggestionView.setListener(mListener);
+ suggestionView.bindSuggestion(suggestion);
+ return suggestionView;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mSuggestions.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mSuggestions.size();
+ }
+ }
+
+ protected Context mContext;
+ protected Listener mListener;
+
+ //
+ // Views
+ //
+ protected LinearLayout mContent;
+ protected View mAggregationSuggestionView;
+ protected ListPopupWindow mAggregationSuggestionPopup;
+
+ //
+ // Parameters passed in on {@link #load}
+ //
+ protected String mAction;
+ protected Uri mLookupUri;
+ protected Bundle mIntentExtras;
+ protected boolean mAutoAddToDefaultGroup;
+ protected boolean mDisableDeleteMenuOption;
+ protected boolean mNewLocalProfile;
+ protected MaterialColorMapUtils.MaterialPalette mMaterialPalette;
+ protected long mPhotoId = -1;
+
+ //
+ // Helpers
+ //
+ protected ContactEditorUtils mEditorUtils;
+ protected RawContactDeltaComparator mComparator;
+ protected ViewIdGenerator mViewIdGenerator;
+ private AggregationSuggestionEngine mAggregationSuggestionEngine;
+
+ //
+ // Loaded data
+ //
+ // Used to store existing contact data so it can be re-applied during a rebind call,
+ // i.e. account switch.
+ protected ImmutableList<RawContact> mRawContacts;
+ protected Cursor mGroupMetaData;
+
+ //
+ // Editor state
+ //
+ protected RawContactDeltaList mState;
+ protected int mStatus;
+ protected long mRawContactIdToDisplayAlone = -1;
+ protected boolean mRawContactDisplayAloneIsReadOnly = false;
+
+ // Whether to show the new contact blank form and if it's corresponding delta is ready.
+ protected boolean mHasNewContact;
+ protected AccountWithDataSet mAccountWithDataSet;
+ protected boolean mNewContactDataReady;
+ protected boolean mNewContactAccountChanged;
+
+ // Whether it's an edit of existing contact and if it's corresponding delta is ready.
+ protected boolean mIsEdit;
+ protected boolean mExistingContactDataReady;
+
+ // Whether we are editing the "me" profile
+ protected boolean mIsUserProfile;
+
+ // Phone specific option menu items
+ private boolean mSendToVoicemailState;
+ private boolean mArePhoneOptionsChangable;
+ private String mCustomRingtone;
+
+ // Whether editor views and options menu items should be enabled
+ private boolean mEnabled = true;
+
+ // Aggregation PopupWindow
+ private long mAggregationSuggestionsRawContactId;
+
+ // Join Activity
+ protected long mContactIdForJoin;
+
+ // Used to pre-populate the editor with a display name when a user edits a read-only contact.
+ protected String mReadOnlyDisplayName;
+
+ //
+ // Not saved/restored on rotates
+ //
+
+ // The name editor view for the new raw contact that was created so that the user can
+ // edit a read-only contact (to which the new raw contact was joined)
+ protected StructuredNameEditorView mReadOnlyNameEditorView;
+
+ /**
+ * The contact data loader listener.
+ */
+ protected final LoaderManager.LoaderCallbacks<Contact> mContactLoaderListener =
+ new LoaderManager.LoaderCallbacks<Contact>() {
+
+ protected long mLoaderStartTime;
+
+ @Override
+ public Loader<Contact> onCreateLoader(int id, Bundle args) {
+ mLoaderStartTime = SystemClock.elapsedRealtime();
+ return new ContactLoader(mContext, mLookupUri, true);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Contact> loader, Contact contact) {
+ final long loaderCurrentTime = SystemClock.elapsedRealtime();
+ Log.v(TAG, "Time needed for loading: " + (loaderCurrentTime-mLoaderStartTime));
+ if (!contact.isLoaded()) {
+ // Item has been deleted. Close activity without saving again.
+ Log.i(TAG, "No contact found. Closing activity");
+ mStatus = Status.CLOSING;
+ if (mListener != null) mListener.onContactNotFound();
+ return;
+ }
+
+ mStatus = Status.EDITING;
+ mLookupUri = contact.getLookupUri();
+ final long setDataStartTime = SystemClock.elapsedRealtime();
+ setState(contact);
+ setStateForPhoneMenuItems(contact);
+ final long setDataEndTime = SystemClock.elapsedRealtime();
+
+ Log.v(TAG, "Time needed for setting UI: " + (setDataEndTime - setDataStartTime));
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Contact> loader) {
+ }
+ };
+
+ /**
+ * The groups meta data loader listener.
+ */
+ protected final LoaderManager.LoaderCallbacks<Cursor> mGroupsLoaderListener =
+ new LoaderManager.LoaderCallbacks<Cursor>() {
+
+ @Override
+ public CursorLoader onCreateLoader(int id, Bundle args) {
+ return new GroupMetaDataLoader(mContext, ContactsContract.Groups.CONTENT_URI);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ mGroupMetaData = data;
+ setGroupMetaData();
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ }
+ };
+
private long mPhotoRawContactId;
private Bundle mUpdatedPhotos = new Bundle();
@Override
+ public Context getContext() {
+ return getActivity();
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ mContext = activity;
+ mEditorUtils = ContactEditorUtils.getInstance(mContext);
+ mComparator = new RawContactDeltaComparator(mContext);
+ }
+
+ @Override
public void onCreate(Bundle savedState) {
+ if (savedState != null) {
+ // Restore mUri before calling super.onCreate so that onInitializeLoaders
+ // would already have a uri and an action to work with
+ mAction = savedState.getString(KEY_ACTION);
+ mLookupUri = savedState.getParcelable(KEY_URI);
+ }
+
super.onCreate(savedState);
- if (savedState != null) {
+ if (savedState == null) {
+ mViewIdGenerator = new ViewIdGenerator();
+
+ // mState can still be null because it may not have have finished loading before
+ // onSaveInstanceState was called.
+ mState = new RawContactDeltaList();
+ } else {
+ mViewIdGenerator = savedState.getParcelable(KEY_VIEW_ID_GENERATOR);
+
+ mAutoAddToDefaultGroup = savedState.getBoolean(KEY_AUTO_ADD_TO_DEFAULT_GROUP);
+ mDisableDeleteMenuOption = savedState.getBoolean(KEY_DISABLE_DELETE_MENU_OPTION);
+ mNewLocalProfile = savedState.getBoolean(KEY_NEW_LOCAL_PROFILE);
+ mMaterialPalette = savedState.getParcelable(KEY_MATERIAL_PALETTE);
+ mPhotoId = savedState.getLong(KEY_PHOTO_ID);
+
+ mRawContacts = ImmutableList.copyOf(savedState.<RawContact>getParcelableArrayList(
+ KEY_RAW_CONTACTS));
+ // NOTE: mGroupMetaData is not saved/restored
+
+ // Read state from savedState. No loading involved here
+ mState = savedState.<RawContactDeltaList> getParcelable(KEY_EDIT_STATE);
+ mStatus = savedState.getInt(KEY_STATUS);
+ mRawContactDisplayAloneIsReadOnly = savedState.getBoolean(
+ KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
+
+ mHasNewContact = savedState.getBoolean(KEY_HAS_NEW_CONTACT);
+ mNewContactDataReady = savedState.getBoolean(KEY_NEW_CONTACT_READY);
+
+ mIsEdit = savedState.getBoolean(KEY_IS_EDIT);
+ mExistingContactDataReady = savedState.getBoolean(KEY_EXISTING_CONTACT_READY);
+
+ mIsUserProfile = savedState.getBoolean(KEY_IS_USER_PROFILE);
+
+ // Phone specific options menus
+ mSendToVoicemailState = savedState.getBoolean(KEY_SEND_TO_VOICE_MAIL_STATE);
+ mArePhoneOptionsChangable = savedState.getBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE);
+ mCustomRingtone = savedState.getString(KEY_CUSTOM_RINGTONE);
+
+ mEnabled = savedState.getBoolean(KEY_ENABLED);
+
+ // Aggregation PopupWindow
+ mAggregationSuggestionsRawContactId = savedState.getLong(
+ KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID);
+
+ // Join Activity
+ mContactIdForJoin = savedState.getLong(KEY_CONTACT_ID_FOR_JOIN);
+
+ mReadOnlyDisplayName = savedState.getString(KEY_READ_ONLY_DISPLAY_NAME);
+
mPhotoRawContactId = savedState.getLong(KEY_PHOTO_RAW_CONTACT_ID);
mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
}
@@ -74,21 +565,812 @@
}
@Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ validateAction(mAction);
+
+ if (mState.isEmpty()) {
+ // The delta list may not have finished loading before orientation change happens.
+ // In this case, there will be a saved state but deltas will be missing. Reload from
+ // database.
+ if (Intent.ACTION_EDIT.equals(mAction)) {
+ // Either
+ // 1) orientation change but load never finished.
+ // 2) not an orientation change so data needs to be loaded for first time.
+ getLoaderManager().initLoader(LOADER_CONTACT, null, mContactLoaderListener);
+ getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
+ }
+ } else {
+ // Orientation change, we already have mState, it was loaded by onCreate
+ bindEditors();
+ }
+
+ // Handle initial actions only when existing state missing
+ if (savedInstanceState == null) {
+ final Account account = mIntentExtras == null ? null :
+ (Account) mIntentExtras.getParcelable(Intents.Insert.EXTRA_ACCOUNT);
+ final String dataSet = mIntentExtras == null ? null :
+ mIntentExtras.getString(Intents.Insert.EXTRA_DATA_SET);
+ if (account != null) {
+ mAccountWithDataSet = new AccountWithDataSet(account.name, account.type, dataSet);
+ }
+
+ if (Intent.ACTION_EDIT.equals(mAction)) {
+ mIsEdit = true;
+ } else if (Intent.ACTION_INSERT.equals(mAction)) {
+ mHasNewContact = true;
+ if (mAccountWithDataSet != null) {
+ createContact(mAccountWithDataSet);
+ } else if (mIntentExtras != null && mIntentExtras.getBoolean(
+ CompactContactEditorActivity.EXTRA_SAVE_TO_DEVICE_FLAG, false)) {
+ createContact(null);
+ } else {
+ // No Account specified. Let the user choose
+ // Load Accounts async so that we can present them
+ selectAccountAndCreateContact();
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if the requested action is valid.
+ *
+ * @param action The action to test.
+ * @throws IllegalArgumentException when the action is invalid.
+ */
+ private static void validateAction(String action) {
+ if (VALID_INTENT_ACTIONS.contains(action)) {
+ return;
+ }
+ throw new IllegalArgumentException(
+ "Unknown action " + action + "; Supported actions: " + VALID_INTENT_ACTIONS);
+ }
+
+ @Override
public void onSaveInstanceState(Bundle outState) {
+ outState.putString(KEY_ACTION, mAction);
+ outState.putParcelable(KEY_URI, mLookupUri);
+ outState.putBoolean(KEY_AUTO_ADD_TO_DEFAULT_GROUP, mAutoAddToDefaultGroup);
+ outState.putBoolean(KEY_DISABLE_DELETE_MENU_OPTION, mDisableDeleteMenuOption);
+ outState.putBoolean(KEY_NEW_LOCAL_PROFILE, mNewLocalProfile);
+ if (mMaterialPalette != null) {
+ outState.putParcelable(KEY_MATERIAL_PALETTE, mMaterialPalette);
+ }
+ outState.putLong(KEY_PHOTO_ID, mPhotoId);
+
+ outState.putParcelable(KEY_VIEW_ID_GENERATOR, mViewIdGenerator);
+
+ outState.putParcelableArrayList(KEY_RAW_CONTACTS, mRawContacts == null ?
+ Lists.<RawContact>newArrayList() : Lists.newArrayList(mRawContacts));
+ // NOTE: mGroupMetaData is not saved
+
+ if (hasValidState()) {
+ // Store entities with modifications
+ outState.putParcelable(KEY_EDIT_STATE, mState);
+ }
+ outState.putInt(KEY_STATUS, mStatus);
+ outState.putBoolean(KEY_HAS_NEW_CONTACT, mHasNewContact);
+ outState.putBoolean(KEY_NEW_CONTACT_READY, mNewContactDataReady);
+ outState.putBoolean(KEY_IS_EDIT, mIsEdit);
+ outState.putBoolean(KEY_EXISTING_CONTACT_READY, mExistingContactDataReady);
+ outState.putBoolean(KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY,
+ mRawContactDisplayAloneIsReadOnly);
+
+ outState.putBoolean(KEY_IS_USER_PROFILE, mIsUserProfile);
+
+ // Phone specific options
+ outState.putBoolean(KEY_SEND_TO_VOICE_MAIL_STATE, mSendToVoicemailState);
+ outState.putBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE, mArePhoneOptionsChangable);
+ outState.putString(KEY_CUSTOM_RINGTONE, mCustomRingtone);
+
+ outState.putBoolean(KEY_ENABLED, mEnabled);
+
+ // Aggregation PopupWindow
+ outState.putLong(KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID,
+ mAggregationSuggestionsRawContactId);
+
+ // Join Activity
+ outState.putLong(KEY_CONTACT_ID_FOR_JOIN, mContactIdForJoin);
+
+ outState.putString(KEY_READ_ONLY_DISPLAY_NAME, mReadOnlyDisplayName);
+
outState.putLong(KEY_PHOTO_RAW_CONTACT_ID, mPhotoRawContactId);
outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
super.onSaveInstanceState(outState);
}
@Override
+ public void onStop() {
+ super.onStop();
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (mAggregationSuggestionEngine != null) {
+ mAggregationSuggestionEngine.quit();
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case REQUEST_CODE_JOIN: {
+ // Ignore failed requests
+ if (resultCode != Activity.RESULT_OK) return;
+ if (data != null) {
+ final long contactId = ContentUris.parseId(data.getData());
+ if (hasPendingChanges()) {
+ // Ask the user if they want to save changes before doing the join
+ JoinContactConfirmationDialogFragment.show(this, contactId);
+ } else {
+ // Do the join immediately
+ joinAggregate(contactId);
+ }
+ }
+ break;
+ }
+ case REQUEST_CODE_ACCOUNTS_CHANGED: {
+ // Bail if the account selector was not successful.
+ if (resultCode != Activity.RESULT_OK) {
+ if (mListener != null) {
+ mListener.onReverted();
+ }
+ return;
+ }
+ // If there's an account specified, use it.
+ if (data != null) {
+ AccountWithDataSet account = data.getParcelableExtra(
+ Intents.Insert.EXTRA_ACCOUNT);
+ if (account != null) {
+ createContact(account);
+ return;
+ }
+ }
+ // If there isn't an account specified, then this is likely a phone-local
+ // contact, so we should continue setting up the editor by automatically selecting
+ // the most appropriate account.
+ createContact();
+ break;
+ }
+ case REQUEST_CODE_PICK_RINGTONE: {
+ if (data != null) {
+ final Uri pickedUri = data.getParcelableExtra(
+ RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
+ onRingtonePicked(pickedUri);
+ }
+ break;
+ }
+ }
+ }
+
+ private void onRingtonePicked(Uri pickedUri) {
+ mCustomRingtone = EditorUiUtils.getRingtoneStringFromUri(pickedUri, CURRENT_API_VERSION);
+ Intent intent = ContactSaveService.createSetRingtone(
+ mContext, mLookupUri, mCustomRingtone);
+ mContext.startService(intent);
+ }
+
+ //
+ // Options menu
+ //
+
+ private void setStateForPhoneMenuItems(Contact contact) {
+ if (contact != null) {
+ mSendToVoicemailState = contact.isSendToVoicemail();
+ mCustomRingtone = contact.getCustomRingtone();
+ mArePhoneOptionsChangable = !contact.isDirectoryEntry()
+ && PhoneCapabilityTester.isPhone(mContext);
+ }
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, final MenuInflater inflater) {
+ inflater.inflate(R.menu.edit_contact, menu);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ // This supports the keyboard shortcut to save changes to a contact but shouldn't be visible
+ // because the custom action bar contains the "save" button now (not the overflow menu).
+ // TODO: Find a better way to handle shortcuts, i.e. onKeyDown()?
+ final MenuItem saveMenu = menu.findItem(R.id.menu_save);
+ final MenuItem splitMenu = menu.findItem(R.id.menu_split);
+ final MenuItem joinMenu = menu.findItem(R.id.menu_join);
+ final MenuItem helpMenu = menu.findItem(R.id.menu_help);
+ final MenuItem sendToVoiceMailMenu = menu.findItem(R.id.menu_send_to_voicemail);
+ final MenuItem ringToneMenu = menu.findItem(R.id.menu_set_ringtone);
+ final MenuItem deleteMenu = menu.findItem(R.id.menu_delete);
+
+ // Set visibility of menus
+
+ // help menu depending on whether this is inserting or editing
+ if (Intent.ACTION_INSERT.equals(mAction) || mRawContactIdToDisplayAlone != -1) {
+ HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
+ splitMenu.setVisible(false);
+ joinMenu.setVisible(false);
+ deleteMenu.setVisible(false);
+ } else if (Intent.ACTION_EDIT.equals(mAction)) {
+ HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_edit);
+ splitMenu.setVisible(canUnlinkRawContacts());
+ // Cannot join a user profile
+ joinMenu.setVisible(!isEditingUserProfile());
+ deleteMenu.setVisible(!mDisableDeleteMenuOption && !isEditingUserProfile());
+ } else {
+ // something else, so don't show the help menu
+ helpMenu.setVisible(false);
+ }
+
+ // Save menu is invisible when there's only one read only contact in the editor.
+ saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly);
+ if (saveMenu.isVisible()) {
+ // Since we're using a custom action layout we have to manually hook up the handler.
+ saveMenu.getActionView().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onOptionsItemSelected(saveMenu);
+ }
+ });
+ }
+
+ if (mRawContactIdToDisplayAlone != -1 || mIsUserProfile) {
+ sendToVoiceMailMenu.setVisible(false);
+ ringToneMenu.setVisible(false);
+ } else {
+ // Hide telephony-related settings (ringtone, send to voicemail)
+ // if we don't have a telephone or are editing a new contact.
+ sendToVoiceMailMenu.setChecked(mSendToVoicemailState);
+ sendToVoiceMailMenu.setVisible(mArePhoneOptionsChangable);
+ ringToneMenu.setVisible(mArePhoneOptionsChangable);
+ }
+
+ int size = menu.size();
+ for (int i = 0; i < size; i++) {
+ menu.getItem(i).setEnabled(mEnabled);
+ }
+ }
+
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
return revert();
}
- return super.onOptionsItemSelected(item);
+
+ final Activity activity = getActivity();
+ if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
+ // If we no longer are attached to a running activity want to
+ // drain this event.
+ return true;
+ }
+
+ switch (item.getItemId()) {
+ case R.id.menu_save:
+ return save(SaveMode.CLOSE);
+ case R.id.menu_delete:
+ if (mListener != null) mListener.onDeleteRequested(mLookupUri);
+ return true;
+ case R.id.menu_split:
+ return doSplitContactAction();
+ case R.id.menu_join:
+ return doJoinContactAction();
+ case R.id.menu_set_ringtone:
+ doPickRingtone();
+ return true;
+ case R.id.menu_send_to_voicemail:
+ // Update state and save
+ mSendToVoicemailState = !mSendToVoicemailState;
+ item.setChecked(mSendToVoicemailState);
+ final Intent intent = ContactSaveService.createSetSendToVoicemail(
+ mContext, mLookupUri, mSendToVoicemailState);
+ mContext.startService(intent);
+ return true;
+ }
+
+ return false;
}
@Override
+ public boolean revert() {
+ if (mState.isEmpty() || !hasPendingChanges()) {
+ onCancelEditConfirmed();
+ } else {
+ CancelEditDialogFragment.show(this);
+ }
+ return true;
+ }
+
+ @Override
+ public void onCancelEditConfirmed() {
+ // When this Fragment is closed we don't want it to auto-save
+ mStatus = Status.CLOSING;
+ if (mListener != null) {
+ mListener.onReverted();
+ }
+ }
+
+ @Override
+ public void onSplitContactConfirmed(boolean hasPendingChanges) {
+ if (mState.isEmpty()) {
+ // This may happen when this Fragment is recreated by the system during users
+ // confirming the split action (and thus this method is called just before onCreate()),
+ // for example.
+ Log.e(TAG, "mState became null during the user's confirming split action. " +
+ "Cannot perform the save action.");
+ return;
+ }
+
+ if (!hasPendingChanges && mHasNewContact) {
+ // If the user didn't add anything new, we don't want to split out the newly created
+ // raw contact into a name-only contact so remove them.
+ final Iterator<RawContactDelta> iterator = mState.iterator();
+ while (iterator.hasNext()) {
+ final RawContactDelta rawContactDelta = iterator.next();
+ if (rawContactDelta.getRawContactId() < 0) {
+ iterator.remove();
+ }
+ }
+ }
+ mState.markRawContactsForSplitting();
+ save(SaveMode.SPLIT);
+ }
+
+ private boolean doSplitContactAction() {
+ if (!hasValidState()) return false;
+
+ SplitContactConfirmationDialogFragment.show(this, hasPendingChanges());
+ return true;
+ }
+
+ private boolean doJoinContactAction() {
+ if (!hasValidState() || mLookupUri == null) {
+ return false;
+ }
+
+ // If we just started creating a new contact and haven't added any data, it's too
+ // early to do a join
+ if (mState.size() == 1 && mState.get(0).isContactInsert()
+ && !hasPendingChanges()) {
+ Toast.makeText(mContext, R.string.toast_join_with_empty_contact,
+ Toast.LENGTH_LONG).show();
+ return true;
+ }
+
+ showJoinAggregateActivity(mLookupUri);
+ return true;
+ }
+
+ @Override
+ public void onJoinContactConfirmed(long joinContactId) {
+ doSaveAction(SaveMode.JOIN, joinContactId);
+ }
+
+ private void doPickRingtone() {
+ final Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
+ // Allow user to pick 'Default'
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
+ // Show only ringtones
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
+ // Allow the user to pick a silent ringtone
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
+
+ final Uri ringtoneUri = EditorUiUtils.getRingtoneUriFromString(mCustomRingtone,
+ CURRENT_API_VERSION);
+
+ // Put checkmark next to the current ringtone for this contact
+ intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneUri);
+
+ // Launch!
+ try {
+ startActivityForResult(intent, REQUEST_CODE_PICK_RINGTONE);
+ } catch (ActivityNotFoundException ex) {
+ Toast.makeText(mContext, R.string.missing_app, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public boolean save(int saveMode) {
+ if (!hasValidState() || mStatus != Status.EDITING) {
+ return false;
+ }
+
+ // If we are about to close the editor - there is no need to refresh the data
+ if (saveMode == SaveMode.CLOSE || saveMode == SaveMode.COMPACT
+ || saveMode == SaveMode.SPLIT) {
+ getLoaderManager().destroyLoader(LOADER_CONTACT);
+ }
+
+ mStatus = Status.SAVING;
+
+ if (!hasPendingChanges()) {
+ if (mLookupUri == null && saveMode == SaveMode.RELOAD) {
+ // We don't have anything to save and there isn't even an existing contact yet.
+ // Nothing to do, simply go back to editing mode
+ mStatus = Status.EDITING;
+ return true;
+ }
+ onSaveCompleted(/* hadChanges =*/ false, saveMode,
+ /* saveSucceeded =*/ mLookupUri != null, mLookupUri, /* joinContactId =*/ null);
+ return true;
+ }
+
+ setEnabled(false);
+
+ return doSaveAction(saveMode, /* joinContactId */ null);
+ }
+
+ //
+ // State accessor methods
+ //
+
+ /**
+ * Check if our internal {@link #mState} is valid, usually checked before
+ * performing user actions.
+ */
+ private boolean hasValidState() {
+ return mState.size() > 0;
+ }
+
+ private boolean isEditingUserProfile() {
+ return mNewLocalProfile || mIsUserProfile;
+ }
+
+ /**
+ * Whether the contact being edited spans multiple raw contacts.
+ * The may also span multiple accounts.
+ */
+ private boolean isEditingMultipleRawContacts() {
+ return mState.size() > 1;
+ }
+
+ /**
+ * Whether the contact being edited is composed of a single read-only raw contact
+ * aggregated with a newly created writable raw contact.
+ */
+ private boolean isEditingReadOnlyRawContactWithNewContact() {
+ return mHasNewContact && mState.size() == 2;
+ }
+
+ /**
+ * Return true if there are any edits to the current contact which need to
+ * be saved.
+ */
+ private boolean hasPendingRawContactChanges(Set<String> excludedMimeTypes) {
+ final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
+ return RawContactModifier.hasChanges(mState, accountTypes, excludedMimeTypes);
+ }
+
+ /**
+ * We allow unlinking only if there is more than one raw contact, it is not a user-profile,
+ * and unlinking won't result in an empty contact. For the empty contact case, we only guard
+ * against this when there is a single read-only contact in the aggregate. If the user
+ * has joined >1 read-only contacts together, we allow them to unlink it, even if they have
+ * never added their own information and unlinking will create a name only contact.
+ */
+ private boolean canUnlinkRawContacts() {
+ return isEditingMultipleRawContacts()
+ && !isEditingUserProfile()
+ && !isEditingReadOnlyRawContactWithNewContact();
+ }
+
+ /**
+ * Determines if changes were made in the editor that need to be saved, while taking into
+ * account that name changes are not real for read-only contacts.
+ * See go/editing-read-only-contacts
+ */
+ private boolean hasPendingChanges() {
+ if (mReadOnlyNameEditorView != null && mReadOnlyDisplayName != null) {
+ // We created a new raw contact delta with a default display name.
+ // We must test for pending changes while ignoring the default display name.
+ final String displayName = mReadOnlyNameEditorView.getDisplayName();
+ if (mReadOnlyDisplayName.equals(displayName)) {
+ final Set<String> excludedMimeTypes = new HashSet<>();
+ excludedMimeTypes.add(StructuredName.CONTENT_ITEM_TYPE);
+ return hasPendingRawContactChanges(excludedMimeTypes);
+ }
+ return true;
+ }
+ return hasPendingRawContactChanges(/* excludedMimeTypes =*/ null);
+ }
+
+ /**
+ * Whether editor inputs and the options menu should be enabled.
+ */
+ private boolean isEnabled() {
+ return mEnabled;
+ }
+
+ /**
+ * Returns the palette extra that was passed in.
+ */
+ private MaterialColorMapUtils.MaterialPalette getMaterialPalette() {
+ return mMaterialPalette;
+ }
+
+ //
+ // Account creation
+ //
+
+ private void selectAccountAndCreateContact() {
+ // If this is a local profile, then skip the logic about showing the accounts changed
+ // activity and create a phone-local contact.
+ if (mNewLocalProfile) {
+ createContact(null);
+ return;
+ }
+
+ // If there is no default account or the accounts have changed such that we need to
+ // prompt the user again, then launch the account prompt.
+ if (mEditorUtils.shouldShowAccountChangedNotification()) {
+ Intent intent = new Intent(mContext, ContactEditorAccountsChangedActivity.class);
+ // Prevent a second instance from being started on rotates
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mStatus = Status.SUB_ACTIVITY;
+ startActivityForResult(intent, REQUEST_CODE_ACCOUNTS_CHANGED);
+ } else {
+ // Otherwise, there should be a default account. Then either create a local contact
+ // (if default account is null) or create a contact with the specified account.
+ AccountWithDataSet defaultAccount = mEditorUtils.getDefaultAccount();
+ createContact(defaultAccount);
+ }
+ }
+
+ /**
+ * Create a contact by automatically selecting the first account. If there's no available
+ * account, a device-local contact should be created.
+ */
+ private void createContact() {
+ final List<AccountWithDataSet> accounts =
+ AccountTypeManager.getInstance(mContext).getAccounts(true);
+ // No Accounts available. Create a phone-local contact.
+ if (accounts.isEmpty()) {
+ createContact(null);
+ return;
+ }
+
+ // We have an account switcher in "create-account" screen, so don't need to ask a user to
+ // select an account here.
+ createContact(accounts.get(0));
+ }
+
+ /**
+ * Shows account creation screen associated with a given account.
+ *
+ * @param account may be null to signal a device-local contact should be created.
+ */
+ private void createContact(AccountWithDataSet account) {
+ final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
+ final AccountType accountType = accountTypes.getAccountTypeForAccount(account);
+
+ if (accountType.getCreateContactActivityClassName() != null) {
+ if (mListener != null) {
+ mListener.onCustomCreateContactActivityRequested(account, mIntentExtras);
+ }
+ } else {
+ setStateForNewContact(account, accountType, isEditingUserProfile());
+ }
+ }
+
+ //
+ // Data binding
+ //
+
+ private void setState(Contact contact) {
+ // If we have already loaded data, we do not want to change it here to not confuse the user
+ if (!mState.isEmpty()) {
+ Log.v(TAG, "Ignoring background change. This will have to be rebased later");
+ return;
+ }
+
+ // Prune raw contacts besides the one we want to edit
+ if (mRawContactIdToDisplayAlone > 0) {
+ final ImmutableList.Builder<RawContact> rawContactsBuilder =
+ new ImmutableList.Builder<>();
+ for (RawContact rawContact : contact.getRawContacts()) {
+ if (rawContact.getId() == mRawContactIdToDisplayAlone) {
+ rawContactsBuilder.add(rawContact);
+ break;
+ }
+ }
+ mRawContacts = rawContactsBuilder.build();
+ Log.v(TAG, "Raw contact deltas trimmed from " + contact.getRawContacts().size() +
+ " to " + mRawContacts.size());
+ } else {
+ mRawContacts = contact.getRawContacts();
+ }
+
+ // See if this edit operation needs to be redirected to a custom editor
+ if (mRawContacts.size() == 1) {
+ RawContact rawContact = mRawContacts.get(0);
+ String type = rawContact.getAccountTypeString();
+ String dataSet = rawContact.getDataSet();
+ AccountType accountType = rawContact.getAccountType(mContext);
+ if (accountType.getEditContactActivityClassName() != null &&
+ !accountType.areContactsWritable()) {
+ if (mListener != null) {
+ String name = rawContact.getAccountName();
+ long rawContactId = rawContact.getId();
+ mListener.onCustomEditContactActivityRequested(
+ new AccountWithDataSet(name, type, dataSet),
+ ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
+ mIntentExtras, true);
+ }
+ return;
+ }
+ }
+
+ String readOnlyDisplayName = null;
+ // Check for writable raw contacts. If there are none, then we need to create one so user
+ // can edit. For the user profile case, there is already an editable contact.
+ if (!contact.isUserProfile() && !contact.isWritableContact(mContext)) {
+ mHasNewContact = true;
+
+ // This is potentially an asynchronous call and will add deltas to list.
+ selectAccountAndCreateContact();
+
+ readOnlyDisplayName = contact.getDisplayName();
+ } else {
+ mHasNewContact = false;
+ }
+
+ // This also adds deltas to list. If readOnlyDisplayName is null at this point it is
+ // simply ignored later on by the editor.
+ setStateForExistingContact(readOnlyDisplayName, contact.isUserProfile(), mRawContacts);
+ }
+
+ /**
+ * Prepare {@link #mState} for a newly created phone-local contact.
+ */
+ private void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
+ boolean isUserProfile) {
+ setStateForNewContact(account, accountType, /* oldState =*/ null,
+ /* oldAccountType =*/ null, isUserProfile);
+ }
+
+ /**
+ * Prepare {@link #mState} for a newly created phone-local contact, migrating the state
+ * specified by oldState and oldAccountType.
+ */
+ private void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
+ RawContactDelta oldState, AccountType oldAccountType, boolean isUserProfile) {
+ mStatus = Status.EDITING;
+ mState.add(createNewRawContactDelta(account, accountType, oldState, oldAccountType));
+ mIsUserProfile = isUserProfile;
+ mNewContactDataReady = true;
+ bindEditors();
+ }
+
+ /**
+ * Returns a {@link RawContactDelta} for a new contact suitable for addition into
+ * {@link #mState}.
+ *
+ * If oldState and oldAccountType are specified, the state specified by those parameters
+ * is migrated to the result {@link RawContactDelta}.
+ */
+ private RawContactDelta createNewRawContactDelta(AccountWithDataSet account,
+ AccountType accountType, RawContactDelta oldState, AccountType oldAccountType) {
+ final RawContact rawContact = new RawContact();
+ if (account != null) {
+ rawContact.setAccount(account);
+ } else {
+ rawContact.setAccountToLocal();
+ }
+
+ final RawContactDelta result = new RawContactDelta(
+ ValuesDelta.fromAfter(rawContact.getValues()));
+ if (oldState == null) {
+ // Parse any values from incoming intent
+ RawContactModifier.parseExtras(mContext, accountType, result, mIntentExtras);
+ } else {
+ RawContactModifier.migrateStateForNewContact(
+ mContext, oldState, result, oldAccountType, accountType);
+ }
+
+ // Ensure we have some default fields (if the account type does not support a field,
+ // ensureKind will not add it, so it is safe to add e.g. Event)
+ RawContactModifier.ensureKindExists(result, accountType, Phone.CONTENT_ITEM_TYPE);
+ RawContactModifier.ensureKindExists(result, accountType, Email.CONTENT_ITEM_TYPE);
+ RawContactModifier.ensureKindExists(result, accountType, Organization.CONTENT_ITEM_TYPE);
+ RawContactModifier.ensureKindExists(result, accountType, Event.CONTENT_ITEM_TYPE);
+ RawContactModifier.ensureKindExists(result, accountType,
+ StructuredPostal.CONTENT_ITEM_TYPE);
+
+ // Set the correct URI for saving the contact as a profile
+ if (mNewLocalProfile) {
+ result.setProfileQueryUri();
+ }
+
+ return result;
+ }
+
+ /**
+ * Prepare {@link #mState} for an existing contact.
+ */
+ private void setStateForExistingContact(String readOnlyDisplayName, boolean isUserProfile,
+ ImmutableList<RawContact> rawContacts) {
+ setEnabled(true);
+ mReadOnlyDisplayName = readOnlyDisplayName;
+
+ mState.addAll(rawContacts.iterator());
+ setIntentExtras(mIntentExtras);
+ mIntentExtras = null;
+
+ // For user profile, change the contacts query URI
+ mIsUserProfile = isUserProfile;
+ boolean localProfileExists = false;
+
+ if (mIsUserProfile) {
+ for (RawContactDelta rawContactDelta : mState) {
+ // For profile contacts, we need a different query URI
+ rawContactDelta.setProfileQueryUri();
+ // Try to find a local profile contact
+ if (rawContactDelta.getValues().getAsString(RawContacts.ACCOUNT_TYPE) == null) {
+ localProfileExists = true;
+ }
+ }
+ // Editor should always present a local profile for editing
+ // TODO(wjang): Need to figure out when this case comes up. We can't do this if we're
+ // going to prune all but the one raw contact that we're trying to display by itself.
+ if (!localProfileExists && mRawContactIdToDisplayAlone <= 0) {
+ mState.add(createLocalRawContactDelta());
+ }
+ }
+ mExistingContactDataReady = true;
+ bindEditors();
+ }
+
+ /**
+ * Set the enabled state of editors.
+ */
+ private void setEnabled(boolean enabled) {
+ if (mEnabled != enabled) {
+ mEnabled = enabled;
+
+ // Enable/disable editors
+ if (mContent != null) {
+ int count = mContent.getChildCount();
+ for (int i = 0; i < count; i++) {
+ mContent.getChildAt(i).setEnabled(enabled);
+ }
+ }
+
+ // Enable/disable aggregation suggestion vies
+ if (mAggregationSuggestionView != null) {
+ LinearLayout itemList = (LinearLayout) mAggregationSuggestionView.findViewById(
+ R.id.aggregation_suggestions);
+ int count = itemList.getChildCount();
+ for (int i = 0; i < count; i++) {
+ itemList.getChildAt(i).setEnabled(enabled);
+ }
+ }
+
+ // Maybe invalidate the options menu
+ final Activity activity = getActivity();
+ if (activity != null) activity.invalidateOptionsMenu();
+ }
+ }
+
+ /**
+ * Returns a {@link RawContactDelta} for a local contact suitable for addition into
+ * {@link #mState}.
+ */
+ private static RawContactDelta createLocalRawContactDelta() {
+ final RawContact rawContact = new RawContact();
+ rawContact.setAccountToLocal();
+
+ final RawContactDelta result = new RawContactDelta(
+ ValuesDelta.fromAfter(rawContact.getValues()));
+ result.setProfileQueryUri();
+
+ return result;
+ }
+
+ /**
+ * Bind editors using {@link #mState} and other members initialized from the loaded (or new)
+ * Contact.
+ */
protected void bindEditors() {
if (!isReadyToBindEditors()) {
return;
@@ -98,7 +1380,9 @@
final CompactRawContactsEditorView editorView = getContent();
editorView.setListener(this);
editorView.setState(mState, getMaterialPalette(), mViewIdGenerator, mPhotoId,
- mHasNewContact, mIsUserProfile, mAccountWithDataSet);
+ mHasNewContact, mIsUserProfile, mAccountWithDataSet,
+ mRawContactIdToDisplayAlone, mRawContactDisplayAloneIsReadOnly,
+ isEditingReadOnlyRawContactWithNewContact());
if (mHasNewContact && !TextUtils.isEmpty(mReadOnlyDisplayName)) {
mReadOnlyNameEditorView = editorView.getPrimaryNameEditorView();
editorView.maybeSetReadOnlyDisplayNameAsPrimary(mReadOnlyDisplayName);
@@ -123,6 +1407,16 @@
invalidateOptionsMenu();
}
+ /**
+ * Invalidates the options menu if we are still associated with an Activity.
+ */
+ private void invalidateOptionsMenu() {
+ final Activity activity = getActivity();
+ if (activity != null) {
+ activity.invalidateOptionsMenu();
+ }
+ }
+
private boolean isReadyToBindEditors() {
if (mState.isEmpty()) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
@@ -145,19 +1439,339 @@
return true;
}
+ /**
+ * Removes a current editor ({@link #mState}) and rebinds new editor for a new account.
+ * Some of old data are reused with new restriction enforced by the new account.
+ *
+ * @param oldState Old data being edited.
+ * @param oldAccount Old account associated with oldState.
+ * @param newAccount New account to be used.
+ */
+ private void rebindEditorsForNewContact(
+ RawContactDelta oldState, AccountWithDataSet oldAccount,
+ AccountWithDataSet newAccount) {
+ AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
+ AccountType oldAccountType = accountTypes.getAccountTypeForAccount(oldAccount);
+ AccountType newAccountType = accountTypes.getAccountTypeForAccount(newAccount);
+
+ if (newAccountType.getCreateContactActivityClassName() != null) {
+ Log.w(TAG, "external activity called in rebind situation");
+ if (mListener != null) {
+ mListener.onCustomCreateContactActivityRequested(newAccount, mIntentExtras);
+ }
+ } else {
+ mExistingContactDataReady = false;
+ mNewContactDataReady = false;
+ mState = new RawContactDeltaList();
+ setStateForNewContact(newAccount, newAccountType, oldState, oldAccountType,
+ isEditingUserProfile());
+ if (mIsEdit) {
+ setStateForExistingContact(mReadOnlyDisplayName, isEditingUserProfile(),
+ mRawContacts);
+ }
+ }
+ }
+
+ //
+ // ContactEditor
+ //
+
@Override
+ public void setListener(Listener listener) {
+ mListener = listener;
+ }
+
+ @Override
+ public void load(String action, Uri lookupUri, Bundle intentExtras) {
+ mAction = action;
+ mLookupUri = lookupUri;
+ mIntentExtras = intentExtras;
+
+ if (mIntentExtras != null) {
+ mAutoAddToDefaultGroup =
+ mIntentExtras.containsKey(INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY);
+ mNewLocalProfile =
+ mIntentExtras.getBoolean(INTENT_EXTRA_NEW_LOCAL_PROFILE);
+ mDisableDeleteMenuOption =
+ mIntentExtras.getBoolean(INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION);
+ if (mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR)
+ && mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR)) {
+ mMaterialPalette = new MaterialColorMapUtils.MaterialPalette(
+ mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR),
+ mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR));
+ }
+ // If the user selected a different photo, don't restore the one from the Intent
+ if (mPhotoId < 0) {
+ mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID);
+ }
+ mRawContactIdToDisplayAlone = mIntentExtras.getLong(
+ INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, -1);
+ mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean(
+ INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
+ }
+ }
+
+ @Override
+ public void setIntentExtras(Bundle extras) {
+ if (extras == null || extras.size() == 0) {
+ return;
+ }
+
+ final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
+ for (RawContactDelta state : mState) {
+ final AccountType type = state.getAccountType(accountTypes);
+ if (type.areContactsWritable()) {
+ // Apply extras to the first writable raw contact only
+ RawContactModifier.parseExtras(mContext, type, state, extras);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void onJoinCompleted(Uri uri) {
+ onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri, /* joinContactId */ null);
+ }
+
+ @Override
+ public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
+ Uri contactLookupUri, Long joinContactId) {
+ if (hadChanges) {
+ if (saveSucceeded) {
+ switch (saveMode) {
+ case SaveMode.JOIN:
+ break;
+ case SaveMode.SPLIT:
+ Toast.makeText(mContext, R.string.contactUnlinkedToast, Toast.LENGTH_SHORT)
+ .show();
+ break;
+ default:
+ Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT)
+ .show();
+ }
+
+ } else {
+ Toast.makeText(mContext, R.string.contactSavedErrorToast, Toast.LENGTH_LONG).show();
+ }
+ }
+ switch (saveMode) {
+ case SaveMode.CLOSE: {
+ final Intent resultIntent;
+ if (saveSucceeded && contactLookupUri != null) {
+ final Uri lookupUri = ContactEditorUtils.maybeConvertToLegacyLookupUri(
+ mContext, contactLookupUri, mLookupUri);
+ resultIntent = ImplicitIntentsUtil.composeQuickContactIntent(mContext,
+ lookupUri, QuickContactActivity.MODE_FULLY_EXPANDED);
+ resultIntent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE,
+ ScreenType.EDITOR);
+ resultIntent.putExtra(QuickContactActivity.EXTRA_CONTACT_EDITED, true);
+ } else {
+ resultIntent = null;
+ }
+ // It is already saved, so prevent it from being saved again
+ mStatus = Status.CLOSING;
+ if (mListener != null) mListener.onSaveFinished(resultIntent);
+ break;
+ }
+ case SaveMode.COMPACT: {
+ // It is already saved, so prevent it from being saved again
+ mStatus = Status.CLOSING;
+ if (mListener != null) mListener.onSaveFinished(/* resultIntent= */ null);
+ break;
+ }
+ case SaveMode.JOIN:
+ if (saveSucceeded && contactLookupUri != null && joinContactId != null) {
+ joinAggregate(joinContactId);
+ }
+ break;
+ case SaveMode.RELOAD:
+ if (saveSucceeded && contactLookupUri != null) {
+ // If this was in INSERT, we are changing into an EDIT now.
+ // If it already was an EDIT, we are changing to the new Uri now
+ mState = new RawContactDeltaList();
+ load(Intent.ACTION_EDIT, contactLookupUri, null);
+ mStatus = Status.LOADING;
+ getLoaderManager().restartLoader(LOADER_CONTACT, null, mContactLoaderListener);
+ }
+ break;
+
+ case SaveMode.SPLIT:
+ mStatus = Status.CLOSING;
+ if (mListener != null) {
+ mListener.onContactSplit(contactLookupUri);
+ } else {
+ Log.d(TAG, "No listener registered, can not call onSplitFinished");
+ }
+ break;
+ }
+ }
+
+ /**
+ * Shows a list of aggregates that can be joined into the currently viewed aggregate.
+ *
+ * @param contactLookupUri the fresh URI for the currently edited contact (after saving it)
+ */
+ private void showJoinAggregateActivity(Uri contactLookupUri) {
+ if (contactLookupUri == null || !isAdded()) {
+ return;
+ }
+
+ mContactIdForJoin = ContentUris.parseId(contactLookupUri);
+ final Intent intent = new Intent(mContext, ContactSelectionActivity.class);
+ intent.setAction(UiIntentActions.PICK_JOIN_CONTACT_ACTION);
+ intent.putExtra(UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, mContactIdForJoin);
+ startActivityForResult(intent, REQUEST_CODE_JOIN);
+ }
+
+ //
+ // Aggregation PopupWindow
+ //
+
+ /**
+ * Triggers an asynchronous search for aggregation suggestions.
+ */
+ protected void acquireAggregationSuggestions(Context context,
+ long rawContactId, ValuesDelta valuesDelta) {
+ if (mAggregationSuggestionsRawContactId != rawContactId
+ && mAggregationSuggestionView != null) {
+ mAggregationSuggestionView.setVisibility(View.GONE);
+ mAggregationSuggestionView = null;
+ mAggregationSuggestionEngine.reset();
+ }
+
+ mAggregationSuggestionsRawContactId = rawContactId;
+
+ if (mAggregationSuggestionEngine == null) {
+ mAggregationSuggestionEngine = new AggregationSuggestionEngine(context);
+ mAggregationSuggestionEngine.setListener(this);
+ mAggregationSuggestionEngine.start();
+ }
+
+ mAggregationSuggestionEngine.setContactId(getContactId());
+
+ mAggregationSuggestionEngine.onNameChange(valuesDelta);
+ }
+
+ /**
+ * Returns the contact ID for the currently edited contact or 0 if the contact is new.
+ */
+ private long getContactId() {
+ for (RawContactDelta rawContact : mState) {
+ Long contactId = rawContact.getValues().getAsLong(RawContacts.CONTACT_ID);
+ if (contactId != null) {
+ return contactId;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public void onAggregationSuggestionChange() {
+ final Activity activity = getActivity();
+ if ((activity != null && activity.isFinishing())
+ || !isVisible() || mState.isEmpty() || mStatus != Status.EDITING) {
+ return;
+ }
+
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
+
+ if (mAggregationSuggestionEngine.getSuggestedContactCount() == 0) {
+ return;
+ }
+
+ final View anchorView = getAggregationAnchorView(mAggregationSuggestionsRawContactId);
+ if (anchorView == null) {
+ return; // Raw contact deleted?
+ }
+ mAggregationSuggestionPopup = new ListPopupWindow(mContext, null);
+ mAggregationSuggestionPopup.setAnchorView(anchorView);
+ mAggregationSuggestionPopup.setWidth(anchorView.getWidth());
+ mAggregationSuggestionPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
+ mAggregationSuggestionPopup.setAdapter(
+ new AggregationSuggestionAdapter(
+ getActivity(),
+ mState.size() == 1 && mState.get(0).isContactInsert(),
+ /* listener =*/ this,
+ mAggregationSuggestionEngine.getSuggestions()));
+ mAggregationSuggestionPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ final AggregationSuggestionView suggestionView = (AggregationSuggestionView) view;
+ suggestionView.handleItemClickEvent();
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
+ mAggregationSuggestionPopup = null;
+ }
+ });
+ mAggregationSuggestionPopup.show();
+ }
+
+ /**
+ * Returns the raw contact editor view for the given rawContactId that should be used as the
+ * anchor for aggregation suggestions.
+ */
protected View getAggregationAnchorView(long rawContactId) {
return getContent().getAggregationAnchorView();
}
@Override
+ public void onJoinAction(long contactId, List<Long> rawContactIdList) {
+ final long rawContactIds[] = new long[rawContactIdList.size()];
+ for (int i = 0; i < rawContactIds.length; i++) {
+ rawContactIds[i] = rawContactIdList.get(i);
+ }
+ try {
+ JoinSuggestedContactDialogFragment.show(this, rawContactIds);
+ } catch (Exception ignored) {
+ // No problem - the activity is no longer available to display the dialog
+ }
+ }
+
+ /**
+ * Joins the suggested contact (specified by the id's of constituent raw
+ * contacts), save all changes, and stay in the editor.
+ */
+ public void doJoinSuggestedContact(long[] rawContactIds) {
+ if (!hasValidState() || mStatus != Status.EDITING) {
+ return;
+ }
+
+ mState.setJoinWithRawContacts(rawContactIds);
+ save(SaveMode.RELOAD);
+ }
+
+ @Override
+ public void onEditAction(Uri contactLookupUri) {
+ SuggestionEditConfirmationDialogFragment.show(this, contactLookupUri);
+ }
+
+ /**
+ * Abandons the currently edited contact and switches to editing the suggested
+ * one, transferring all the data there
+ */
+ public void doEditSuggestedContact(Uri contactUri) {
+ if (mListener != null) {
+ // make sure we don't save this contact when closing down
+ mStatus = Status.CLOSING;
+ mListener.onEditOtherContactRequested(
+ contactUri, mState.get(0).getContentValues());
+ }
+ }
+
+ /**
+ * Sets group metadata on all bound editors.
+ */
protected void setGroupMetaData() {
if (mGroupMetaData != null) {
getContent().setGroupMetaData(mGroupMetaData);
}
}
- @Override
+ /**
+ * Persist the accumulated editor deltas.
+ *
+ * @param joinContactId the raw contact ID to join the contact being saved to after the save,
+ * may be null.
+ */
protected boolean doSaveAction(int saveMode, Long joinContactId) {
final Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
SAVE_MODE_EXTRA_KEY, saveMode, isEditingUserProfile(),
@@ -167,7 +1781,22 @@
return startSaveService(mContext, intent, saveMode);
}
- @Override
+ private boolean startSaveService(Context context, Intent intent, int saveMode) {
+ final boolean result = ContactSaveService.startService(
+ context, intent, saveMode);
+ if (!result) {
+ onCancelEditConfirmed();
+ }
+ return result;
+ }
+
+ //
+ // Join Activity
+ //
+
+ /**
+ * Performs aggregation with the contact selected by the user from suggestions or A-Z list.
+ */
protected void joinAggregate(final long contactId) {
final Intent intent = ContactSaveService.createJoinContactsIntent(
mContext, mContactIdForJoin, contactId, CompactContactEditorActivity.class,
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index f465167..bdf329d 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -331,6 +331,10 @@
private boolean mHasNewContact;
private boolean mIsUserProfile;
private AccountWithDataSet mPrimaryAccount;
+ private RawContactDeltaList mRawContactDeltas;
+ private long mRawContactIdToDisplayAlone = -1;
+ private boolean mRawContactDisplayAloneIsReadOnly;
+ private boolean mIsEditingReadOnlyRawContactWithNewContact;
private Map<String,KindSectionDataList> mKindSectionDataMap = new HashMap<>();
// Account header
@@ -616,12 +620,20 @@
public void setState(RawContactDeltaList rawContactDeltas,
MaterialColorMapUtils.MaterialPalette materialPalette, ViewIdGenerator viewIdGenerator,
long photoId, boolean hasNewContact, boolean isUserProfile,
- AccountWithDataSet primaryAccount) {
+ AccountWithDataSet primaryAccount, long rawContactIdToDisplayAlone,
+ boolean rawContactDisplayAloneIsReadOnly,
+ boolean isEditingReadOnlyRawContactWithNewContact) {
// Enable layout animations for new contacts. This looks nicer when switching to and from
// an account that doesn't support profile photos (e.g. SIM accounts).
if (hasNewContact && getLayoutTransition() == null) {
setLayoutTransition(new LayoutTransition());
}
+
+ mRawContactDeltas = rawContactDeltas;
+ mRawContactIdToDisplayAlone = rawContactIdToDisplayAlone;
+ mRawContactDisplayAloneIsReadOnly = rawContactDisplayAloneIsReadOnly;
+ mIsEditingReadOnlyRawContactWithNewContact = isEditingReadOnlyRawContactWithNewContact;
+
mKindSectionDataMap.clear();
mKindSectionViewsMap.clear();
mKindSectionViews.removeAllViews();
@@ -672,15 +684,49 @@
}
// Setup the view
- addAccountInfo(rawContactDeltas);
addPhotoView();
+ if (isSingleReadOnlyRawContact()) {
+ // We're want to display the inputs fields for a single read only raw contact
+ addReadOnlyRawContactEditorViews();
+ // Hide the "More fields" link
+ mMoreFields.setVisibility(View.GONE);
+ } else if (mIsEditingReadOnlyRawContactWithNewContact) {
+ // A new writable raw contact was created and joined with the read only contact
+ // that the user is trying to edit.
+ setupCompactEditorNormally();
+
+ // TODO: Hide the raw contact selector since it will just contain the read-only raw
+ // contact and clicking that will just open the exact same editor. When we clean up
+ // the whole account header, selector, and raw contact selector mess, we can prevent
+ // the selector from being displayed in a less hacky way.
+ mRawContactContainer.setVisibility(View.GONE);
+ } else if (mRawContactDeltas.size() > 1) {
+ // We're editing an aggregate composed of more than one writable raw contacts
+
+ // TODO: Don't render any input fields. Eventually we will show a list of account
+ // types and names but for now just show the account selector and hide the "More fields"
+ // link.
+ addAccountInfo(rawContactDeltas);
+ mMoreFields.setVisibility(View.GONE);
+ } else {
+ setupCompactEditorNormally();
+ }
+ if (mListener != null) mListener.onEditorsBound();
+ }
+
+ private void setupCompactEditorNormally() {
+ addAccountInfo(mRawContactDeltas);
addKindSectionViews();
mMoreFields.setVisibility(hasMoreFields() ? View.VISIBLE : View.GONE);
if (mIsExpanded) showAllFields();
+ }
- if (mListener != null) mListener.onEditorsBound();
+ private boolean isSingleReadOnlyRawContact() {
+ return mRawContactDeltas.size() == 1
+ && mRawContactDeltas.get(0).getRawContactId() == mRawContactIdToDisplayAlone
+ && mRawContactDisplayAloneIsReadOnly;
}
private void parseRawContactDeltas(RawContactDeltaList rawContactDeltas) {
@@ -697,8 +743,8 @@
vlog("parse: " + dataKindSize + " dataKinds(s)");
for (int i = 0; i < dataKindSize; i++) {
final DataKind dataKind = dataKinds.get(i);
- if (dataKind == null || !dataKind.editable) {
- vlog("parse: " + i + " " + dataKind.mimeType + " dropped read-only");
+ if (dataKind == null) {
+ vlog("parse: " + i + " " + dataKind.mimeType + " dropped null data kind");
continue;
}
final String mimeType = dataKind.mimeType;
@@ -734,6 +780,27 @@
return kindSectionDataList;
}
+ private void addReadOnlyRawContactEditorViews() {
+ final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ final AccountTypeManager accountTypes = AccountTypeManager.getInstance(
+ getContext());
+
+ for (int i = 0; i < mRawContactDeltas.size(); i++) {
+ final RawContactDelta rawContactDelta = mRawContactDeltas.get(i);
+ if (!rawContactDelta.isVisible()) continue;
+ final AccountType type = rawContactDelta.getAccountType(accountTypes);
+ if (type.areContactsWritable()) continue;
+
+ final BaseRawContactEditorView editor = (BaseRawContactEditorView) inflater.inflate(
+ R.layout.raw_contact_readonly_editor_view, mKindSectionViews, false);
+ editor.setCollapsed(false);
+ mKindSectionViews.addView(editor);
+ editor.setState(rawContactDelta, type, mViewIdGenerator, mIsUserProfile);
+ }
+ }
+
+ // TODO: we have mRawContactDeltas, we don't need to pass the RawContactDeltaList to this method
private void addAccountInfo(RawContactDeltaList rawContactDeltas) {
mAccountHeaderContainer.setVisibility(View.GONE);
mRawContactContainer.setVisibility(View.GONE);
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
deleted file mode 100644
index 05f6c47..0000000
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ /dev/null
@@ -1,1745 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.editor;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.content.ActivityNotFoundException;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.CursorLoader;
-import android.content.Intent;
-import android.content.Loader;
-import android.database.Cursor;
-import android.media.RingtoneManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.CommonDataKinds.Email;
-import android.provider.ContactsContract.CommonDataKinds.Event;
-import android.provider.ContactsContract.CommonDataKinds.Organization;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.CommonDataKinds.StructuredName;
-import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Intents;
-import android.provider.ContactsContract.RawContacts;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.LinearLayout;
-import android.widget.ListPopupWindow;
-import android.widget.Toast;
-
-import com.android.contacts.ContactSaveService;
-import com.android.contacts.GroupMetaDataLoader;
-import com.android.contacts.R;
-import com.android.contacts.activities.CompactContactEditorActivity;
-import com.android.contacts.activities.ContactEditorAccountsChangedActivity;
-import com.android.contacts.activities.ContactEditorBaseActivity;
-import com.android.contacts.activities.ContactEditorBaseActivity.ContactEditor;
-import com.android.contacts.activities.ContactSelectionActivity;
-import com.android.contacts.common.logging.ScreenEvent.ScreenType;
-import com.android.contacts.common.model.AccountTypeManager;
-import com.android.contacts.common.model.Contact;
-import com.android.contacts.common.model.ContactLoader;
-import com.android.contacts.common.model.RawContact;
-import com.android.contacts.common.model.RawContactDelta;
-import com.android.contacts.common.model.RawContactDeltaList;
-import com.android.contacts.common.model.RawContactModifier;
-import com.android.contacts.common.model.ValuesDelta;
-import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.common.util.ImplicitIntentsUtil;
-import com.android.contacts.common.util.MaterialColorMapUtils;
-import com.android.contacts.editor.AggregationSuggestionEngine.Suggestion;
-import com.android.contacts.list.UiIntentActions;
-import com.android.contacts.quickcontact.QuickContactActivity;
-import com.android.contacts.util.HelpUtils;
-import com.android.contacts.util.PhoneCapabilityTester;
-import com.android.contacts.util.UiClosables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Base Fragment for contact editors.
- */
-abstract public class ContactEditorBaseFragment extends Fragment implements
- ContactEditor, SplitContactConfirmationDialogFragment.Listener,
- JoinContactConfirmationDialogFragment.Listener,
- AggregationSuggestionEngine.Listener, AggregationSuggestionView.Listener,
- CancelEditDialogFragment.Listener {
-
- static final String TAG = "ContactEditor";
-
- protected static final int LOADER_CONTACT = 1;
- protected static final int LOADER_GROUPS = 2;
-
- private static final List<String> VALID_INTENT_ACTIONS = new ArrayList<String>() {{
- add(Intent.ACTION_EDIT);
- add(Intent.ACTION_INSERT);
- add(ContactEditorBaseActivity.ACTION_EDIT);
- add(ContactEditorBaseActivity.ACTION_INSERT);
- add(ContactEditorBaseActivity.ACTION_SAVE_COMPLETED);
- }};
-
- private static final String KEY_ACTION = "action";
- private static final String KEY_URI = "uri";
- private static final String KEY_AUTO_ADD_TO_DEFAULT_GROUP = "autoAddToDefaultGroup";
- private static final String KEY_DISABLE_DELETE_MENU_OPTION = "disableDeleteMenuOption";
- private static final String KEY_NEW_LOCAL_PROFILE = "newLocalProfile";
- private static final String KEY_MATERIAL_PALETTE = "materialPalette";
- private static final String KEY_PHOTO_ID = "photoId";
-
- private static final String KEY_VIEW_ID_GENERATOR = "viewidgenerator";
-
- private static final String KEY_RAW_CONTACTS = "rawContacts";
-
- private static final String KEY_EDIT_STATE = "state";
- private static final String KEY_STATUS = "status";
-
- private static final String KEY_HAS_NEW_CONTACT = "hasNewContact";
- private static final String KEY_NEW_CONTACT_READY = "newContactDataReady";
-
- private static final String KEY_IS_EDIT = "isEdit";
- private static final String KEY_EXISTING_CONTACT_READY = "existingContactDataReady";
-
- private static final String KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY = "isReadOnly";
-
- // Phone option menus
- private static final String KEY_SEND_TO_VOICE_MAIL_STATE = "sendToVoicemailState";
- private static final String KEY_ARE_PHONE_OPTIONS_CHANGEABLE = "arePhoneOptionsChangable";
- private static final String KEY_CUSTOM_RINGTONE = "customRingtone";
-
- private static final String KEY_IS_USER_PROFILE = "isUserProfile";
-
- private static final String KEY_ENABLED = "enabled";
-
- // Aggregation PopupWindow
- private static final String KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID =
- "aggregationSuggestionsRawContactId";
-
- // Join Activity
- private static final String KEY_CONTACT_ID_FOR_JOIN = "contactidforjoin";
-
- private static final String KEY_READ_ONLY_DISPLAY_NAME = "readOnlyDisplayName";
-
- protected static final int REQUEST_CODE_JOIN = 0;
- protected static final int REQUEST_CODE_ACCOUNTS_CHANGED = 1;
- protected static final int REQUEST_CODE_PICK_RINGTONE = 2;
-
- private static final int CURRENT_API_VERSION = android.os.Build.VERSION.SDK_INT;
-
- /**
- * An intent extra that forces the editor to add the edited contact
- * to the default group (e.g. "My Contacts").
- */
- public static final String INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY = "addToDefaultDirectory";
-
- public static final String INTENT_EXTRA_NEW_LOCAL_PROFILE = "newLocalProfile";
-
- public static final String INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION =
- "disableDeleteMenuOption";
-
- /**
- * Intent key to pass the photo palette primary color calculated by
- * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between
- * the compact and fully expanded editors.
- */
- public static final String INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR =
- "material_palette_primary_color";
-
- /**
- * Intent key to pass the photo palette secondary color calculated by
- * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between
- * the compact and fully expanded editors.
- */
- public static final String INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR =
- "material_palette_secondary_color";
-
- /**
- * Intent key to pass the ID of the photo to display on the editor.
- */
- public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";
-
- /**
- * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
- * by itself.
- */
- public static final String INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE =
- "raw_contact_id_to_display_alone";
-
- /**
- * Intent key to pass the boolean value of if the raw contact id that should be displayed
- * in the full editor by itself is read-only.
- */
- public static final String INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY =
- "raw_contact_display_alone_is_read_only";
-
- /**
- * Intent extra to specify a {@link ContactEditor.SaveMode}.
- */
- public static final String SAVE_MODE_EXTRA_KEY = "saveMode";
-
- /**
- * Intent extra key for the contact ID to join the current contact to after saving.
- */
- public static final String JOIN_CONTACT_ID_EXTRA_KEY = "joinContactId";
-
- /**
- * Callbacks for Activities that host contact editors Fragments.
- */
- public interface Listener {
-
- /**
- * Contact was not found, so somehow close this fragment. This is raised after a contact
- * is removed via Menu/Delete
- */
- void onContactNotFound();
-
- /**
- * Contact was split, so we can close now.
- *
- * @param newLookupUri The lookup uri of the new contact that should be shown to the user.
- * The editor tries best to chose the most natural contact here.
- */
- void onContactSplit(Uri newLookupUri);
-
- /**
- * User has tapped Revert, close the fragment now.
- */
- void onReverted();
-
- /**
- * Contact was saved and the Fragment can now be closed safely.
- */
- void onSaveFinished(Intent resultIntent);
-
- /**
- * User switched to editing a different contact (a suggestion from the
- * aggregation engine).
- */
- void onEditOtherContactRequested(Uri contactLookupUri,
- ArrayList<ContentValues> contentValues);
-
- /**
- * Contact is being created for an external account that provides its own
- * new contact activity.
- */
- void onCustomCreateContactActivityRequested(AccountWithDataSet account,
- Bundle intentExtras);
-
- /**
- * The edited raw contact belongs to an external account that provides
- * its own edit activity.
- *
- * @param redirect indicates that the current editor should be closed
- * before the custom editor is shown.
- */
- void onCustomEditContactActivityRequested(AccountWithDataSet account, Uri rawContactUri,
- Bundle intentExtras, boolean redirect);
-
- /**
- * User has requested that contact be deleted.
- */
- void onDeleteRequested(Uri contactUri);
- }
-
- /**
- * Adapter for aggregation suggestions displayed in a PopupWindow when
- * editor fields change.
- */
- protected static final class AggregationSuggestionAdapter extends BaseAdapter {
- private final LayoutInflater mLayoutInflater;
- private final boolean mSetNewContact;
- private final AggregationSuggestionView.Listener mListener;
- private final List<AggregationSuggestionEngine.Suggestion> mSuggestions;
-
- public AggregationSuggestionAdapter(Activity activity, boolean setNewContact,
- AggregationSuggestionView.Listener listener, List<Suggestion> suggestions) {
- mLayoutInflater = activity.getLayoutInflater();
- mSetNewContact = setNewContact;
- mListener = listener;
- mSuggestions = suggestions;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final Suggestion suggestion = (Suggestion) getItem(position);
- final AggregationSuggestionView suggestionView =
- (AggregationSuggestionView) mLayoutInflater.inflate(
- R.layout.aggregation_suggestions_item, null);
- suggestionView.setNewContact(mSetNewContact);
- suggestionView.setListener(mListener);
- suggestionView.bindSuggestion(suggestion);
- return suggestionView;
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public Object getItem(int position) {
- return mSuggestions.get(position);
- }
-
- @Override
- public int getCount() {
- return mSuggestions.size();
- }
- }
-
- protected Context mContext;
- protected Listener mListener;
-
- //
- // Views
- //
- protected LinearLayout mContent;
- protected View mAggregationSuggestionView;
- protected ListPopupWindow mAggregationSuggestionPopup;
-
- //
- // Parameters passed in on {@link #load}
- //
- protected String mAction;
- protected Uri mLookupUri;
- protected Bundle mIntentExtras;
- protected boolean mAutoAddToDefaultGroup;
- protected boolean mDisableDeleteMenuOption;
- protected boolean mNewLocalProfile;
- protected MaterialColorMapUtils.MaterialPalette mMaterialPalette;
- protected long mPhotoId = -1;
-
- //
- // Helpers
- //
- protected ContactEditorUtils mEditorUtils;
- protected RawContactDeltaComparator mComparator;
- protected ViewIdGenerator mViewIdGenerator;
- private AggregationSuggestionEngine mAggregationSuggestionEngine;
-
- //
- // Loaded data
- //
- // Used to store existing contact data so it can be re-applied during a rebind call,
- // i.e. account switch. Only used in {@link ContactEditorFragment}.
- protected ImmutableList<RawContact> mRawContacts;
- protected Cursor mGroupMetaData;
-
- //
- // Editor state
- //
- protected RawContactDeltaList mState;
- protected int mStatus;
- protected long mRawContactIdToDisplayAlone = -1;
- protected boolean mRawContactDisplayAloneIsReadOnly = false;
-
- // Whether to show the new contact blank form and if it's corresponding delta is ready.
- protected boolean mHasNewContact;
- protected AccountWithDataSet mAccountWithDataSet;
- protected boolean mNewContactDataReady;
- protected boolean mNewContactAccountChanged;
-
- // Whether it's an edit of existing contact and if it's corresponding delta is ready.
- protected boolean mIsEdit;
- protected boolean mExistingContactDataReady;
-
- // Whether we are editing the "me" profile
- protected boolean mIsUserProfile;
-
- // Phone specific option menu items
- private boolean mSendToVoicemailState;
- private boolean mArePhoneOptionsChangable;
- private String mCustomRingtone;
-
- // Whether editor views and options menu items should be enabled
- private boolean mEnabled = true;
-
- // Aggregation PopupWindow
- private long mAggregationSuggestionsRawContactId;
-
- // Join Activity
- protected long mContactIdForJoin;
-
- // Used to pre-populate the editor with a display name when a user edits a read-only contact.
- protected String mReadOnlyDisplayName;
-
- //
- // Not saved/restored on rotates
- //
-
- // The name editor view for the new raw contact that was created so that the user can
- // edit a read-only contact (to which the new raw contact was joined)
- protected StructuredNameEditorView mReadOnlyNameEditorView;
-
- /**
- * The contact data loader listener.
- */
- protected final LoaderManager.LoaderCallbacks<Contact> mContactLoaderListener =
- new LoaderManager.LoaderCallbacks<Contact>() {
-
- protected long mLoaderStartTime;
-
- @Override
- public Loader<Contact> onCreateLoader(int id, Bundle args) {
- mLoaderStartTime = SystemClock.elapsedRealtime();
- return new ContactLoader(mContext, mLookupUri, true);
- }
-
- @Override
- public void onLoadFinished(Loader<Contact> loader, Contact contact) {
- final long loaderCurrentTime = SystemClock.elapsedRealtime();
- Log.v(TAG, "Time needed for loading: " + (loaderCurrentTime-mLoaderStartTime));
- if (!contact.isLoaded()) {
- // Item has been deleted. Close activity without saving again.
- Log.i(TAG, "No contact found. Closing activity");
- mStatus = Status.CLOSING;
- if (mListener != null) mListener.onContactNotFound();
- return;
- }
-
- mStatus = Status.EDITING;
- mLookupUri = contact.getLookupUri();
- final long setDataStartTime = SystemClock.elapsedRealtime();
- setState(contact);
- setStateForPhoneMenuItems(contact);
- final long setDataEndTime = SystemClock.elapsedRealtime();
-
- Log.v(TAG, "Time needed for setting UI: " + (setDataEndTime - setDataStartTime));
- }
-
- @Override
- public void onLoaderReset(Loader<Contact> loader) {
- }
- };
-
- /**
- * The groups meta data loader listener.
- */
- protected final LoaderManager.LoaderCallbacks<Cursor> mGroupsLoaderListener =
- new LoaderManager.LoaderCallbacks<Cursor>() {
-
- @Override
- public CursorLoader onCreateLoader(int id, Bundle args) {
- return new GroupMetaDataLoader(mContext, ContactsContract.Groups.CONTENT_URI);
- }
-
- @Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- mGroupMetaData = data;
- setGroupMetaData();
- }
-
- @Override
- public void onLoaderReset(Loader<Cursor> loader) {
- }
- };
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- mContext = activity;
- mEditorUtils = ContactEditorUtils.getInstance(mContext);
- mComparator = new RawContactDeltaComparator(mContext);
- }
-
- @Override
- public void onCreate(Bundle savedState) {
- if (savedState != null) {
- // Restore mUri before calling super.onCreate so that onInitializeLoaders
- // would already have a uri and an action to work with
- mAction = savedState.getString(KEY_ACTION);
- mLookupUri = savedState.getParcelable(KEY_URI);
- }
-
- super.onCreate(savedState);
-
- if (savedState == null) {
- mViewIdGenerator = new ViewIdGenerator();
- } else {
- mViewIdGenerator = savedState.getParcelable(KEY_VIEW_ID_GENERATOR);
-
- mAutoAddToDefaultGroup = savedState.getBoolean(KEY_AUTO_ADD_TO_DEFAULT_GROUP);
- mDisableDeleteMenuOption = savedState.getBoolean(KEY_DISABLE_DELETE_MENU_OPTION);
- mNewLocalProfile = savedState.getBoolean(KEY_NEW_LOCAL_PROFILE);
- mMaterialPalette = savedState.getParcelable(KEY_MATERIAL_PALETTE);
- mPhotoId = savedState.getLong(KEY_PHOTO_ID);
-
- mRawContacts = ImmutableList.copyOf(savedState.<RawContact>getParcelableArrayList(
- KEY_RAW_CONTACTS));
- // NOTE: mGroupMetaData is not saved/restored
-
- // Read state from savedState. No loading involved here
- mState = savedState.<RawContactDeltaList> getParcelable(KEY_EDIT_STATE);
- mStatus = savedState.getInt(KEY_STATUS);
- mRawContactDisplayAloneIsReadOnly = savedState.getBoolean(
- KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
-
- mHasNewContact = savedState.getBoolean(KEY_HAS_NEW_CONTACT);
- mNewContactDataReady = savedState.getBoolean(KEY_NEW_CONTACT_READY);
-
- mIsEdit = savedState.getBoolean(KEY_IS_EDIT);
- mExistingContactDataReady = savedState.getBoolean(KEY_EXISTING_CONTACT_READY);
-
- mIsUserProfile = savedState.getBoolean(KEY_IS_USER_PROFILE);
-
- // Phone specific options menus
- mSendToVoicemailState = savedState.getBoolean(KEY_SEND_TO_VOICE_MAIL_STATE);
- mArePhoneOptionsChangable = savedState.getBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE);
- mCustomRingtone = savedState.getString(KEY_CUSTOM_RINGTONE);
-
- mEnabled = savedState.getBoolean(KEY_ENABLED);
-
- // Aggregation PopupWindow
- mAggregationSuggestionsRawContactId = savedState.getLong(
- KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID);
-
- // Join Activity
- mContactIdForJoin = savedState.getLong(KEY_CONTACT_ID_FOR_JOIN);
-
- mReadOnlyDisplayName = savedState.getString(KEY_READ_ONLY_DISPLAY_NAME);
- }
-
- // mState can still be null because it may not have have finished loading before
- // onSaveInstanceState was called.
- if (mState == null) {
- mState = new RawContactDeltaList();
- }
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- validateAction(mAction);
-
- if (mState.isEmpty()) {
- // The delta list may not have finished loading before orientation change happens.
- // In this case, there will be a saved state but deltas will be missing. Reload from
- // database.
- if (Intent.ACTION_EDIT.equals(mAction) ||
- ContactEditorBaseActivity.ACTION_EDIT.equals(mAction)) {
- // Either
- // 1) orientation change but load never finished.
- // 2) not an orientation change so data needs to be loaded for first time.
- getLoaderManager().initLoader(LOADER_CONTACT, null, mContactLoaderListener);
- getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
- }
- } else {
- // Orientation change, we already have mState, it was loaded by onCreate
- bindEditors();
- }
-
- // Handle initial actions only when existing state missing
- if (savedInstanceState == null) {
- final Account account = mIntentExtras == null ? null :
- (Account) mIntentExtras.getParcelable(Intents.Insert.EXTRA_ACCOUNT);
- final String dataSet = mIntentExtras == null ? null :
- mIntentExtras.getString(Intents.Insert.EXTRA_DATA_SET);
- if (account != null) {
- mAccountWithDataSet = new AccountWithDataSet(account.name, account.type, dataSet);
- }
-
- if (Intent.ACTION_EDIT.equals(mAction) ||
- ContactEditorBaseActivity.ACTION_EDIT.equals(mAction)) {
- mIsEdit = true;
- } else if (Intent.ACTION_INSERT.equals(mAction) ||
- ContactEditorBaseActivity.ACTION_INSERT.equals(mAction)) {
- mHasNewContact = true;
- if (mAccountWithDataSet != null) {
- createContact(mAccountWithDataSet);
- } else if (mIntentExtras != null && mIntentExtras.getBoolean(
- ContactEditorBaseActivity.EXTRA_SAVE_TO_DEVICE_FLAG, false)) {
- createContact(null);
- } else {
- // No Account specified. Let the user choose
- // Load Accounts async so that we can present them
- selectAccountAndCreateContact();
- }
- }
- }
- }
-
- /**
- * Checks if the requested action is valid.
- *
- * @param action The action to test.
- * @throws IllegalArgumentException when the action is invalid.
- */
- private static void validateAction(String action) {
- if (VALID_INTENT_ACTIONS.contains(action)) {
- return;
- }
- throw new IllegalArgumentException(
- "Unknown action " + action + "; Supported actions: " + VALID_INTENT_ACTIONS);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- outState.putString(KEY_ACTION, mAction);
- outState.putParcelable(KEY_URI, mLookupUri);
- outState.putBoolean(KEY_AUTO_ADD_TO_DEFAULT_GROUP, mAutoAddToDefaultGroup);
- outState.putBoolean(KEY_DISABLE_DELETE_MENU_OPTION, mDisableDeleteMenuOption);
- outState.putBoolean(KEY_NEW_LOCAL_PROFILE, mNewLocalProfile);
- if (mMaterialPalette != null) {
- outState.putParcelable(KEY_MATERIAL_PALETTE, mMaterialPalette);
- }
- outState.putLong(KEY_PHOTO_ID, mPhotoId);
-
- outState.putParcelable(KEY_VIEW_ID_GENERATOR, mViewIdGenerator);
-
- outState.putParcelableArrayList(KEY_RAW_CONTACTS, mRawContacts == null ?
- Lists.<RawContact>newArrayList() : Lists.newArrayList(mRawContacts));
- // NOTE: mGroupMetaData is not saved
-
- if (hasValidState()) {
- // Store entities with modifications
- outState.putParcelable(KEY_EDIT_STATE, mState);
- }
- outState.putInt(KEY_STATUS, mStatus);
- outState.putBoolean(KEY_HAS_NEW_CONTACT, mHasNewContact);
- outState.putBoolean(KEY_NEW_CONTACT_READY, mNewContactDataReady);
- outState.putBoolean(KEY_IS_EDIT, mIsEdit);
- outState.putBoolean(KEY_EXISTING_CONTACT_READY, mExistingContactDataReady);
- outState.putBoolean(KEY_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY,
- mRawContactDisplayAloneIsReadOnly);
-
- outState.putBoolean(KEY_IS_USER_PROFILE, mIsUserProfile);
-
- // Phone specific options
- outState.putBoolean(KEY_SEND_TO_VOICE_MAIL_STATE, mSendToVoicemailState);
- outState.putBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE, mArePhoneOptionsChangable);
- outState.putString(KEY_CUSTOM_RINGTONE, mCustomRingtone);
-
- outState.putBoolean(KEY_ENABLED, mEnabled);
-
- // Aggregation PopupWindow
- outState.putLong(KEY_AGGREGATION_SUGGESTIONS_RAW_CONTACT_ID,
- mAggregationSuggestionsRawContactId);
-
- // Join Activity
- outState.putLong(KEY_CONTACT_ID_FOR_JOIN, mContactIdForJoin);
-
- outState.putString(KEY_READ_ONLY_DISPLAY_NAME, mReadOnlyDisplayName);
-
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public void onStop() {
- super.onStop();
- UiClosables.closeQuietly(mAggregationSuggestionPopup);
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (mAggregationSuggestionEngine != null) {
- mAggregationSuggestionEngine.quit();
- }
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_CODE_JOIN: {
- // Ignore failed requests
- if (resultCode != Activity.RESULT_OK) return;
- if (data != null) {
- final long contactId = ContentUris.parseId(data.getData());
- if (hasPendingChanges()) {
- // Ask the user if they want to save changes before doing the join
- JoinContactConfirmationDialogFragment.show(this, contactId);
- } else {
- // Do the join immediately
- joinAggregate(contactId);
- }
- }
- break;
- }
- case REQUEST_CODE_ACCOUNTS_CHANGED: {
- // Bail if the account selector was not successful.
- if (resultCode != Activity.RESULT_OK) {
- if (mListener != null) {
- mListener.onReverted();
- }
- return;
- }
- // If there's an account specified, use it.
- if (data != null) {
- AccountWithDataSet account = data.getParcelableExtra(
- Intents.Insert.EXTRA_ACCOUNT);
- if (account != null) {
- createContact(account);
- return;
- }
- }
- // If there isn't an account specified, then this is likely a phone-local
- // contact, so we should continue setting up the editor by automatically selecting
- // the most appropriate account.
- createContact();
- break;
- }
- case REQUEST_CODE_PICK_RINGTONE: {
- if (data != null) {
- final Uri pickedUri = data.getParcelableExtra(
- RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
- onRingtonePicked(pickedUri);
- }
- break;
- }
- }
- }
-
- private void onRingtonePicked(Uri pickedUri) {
- mCustomRingtone = EditorUiUtils.getRingtoneStringFromUri(pickedUri, CURRENT_API_VERSION);
- Intent intent = ContactSaveService.createSetRingtone(
- mContext, mLookupUri, mCustomRingtone);
- mContext.startService(intent);
- }
-
- //
- // Options menu
- //
-
- private void setStateForPhoneMenuItems(Contact contact) {
- if (contact != null) {
- mSendToVoicemailState = contact.isSendToVoicemail();
- mCustomRingtone = contact.getCustomRingtone();
- mArePhoneOptionsChangable = !contact.isDirectoryEntry()
- && PhoneCapabilityTester.isPhone(mContext);
- }
- }
-
- /**
- * Invalidates the options menu if we are still associated with an Activity.
- */
- protected void invalidateOptionsMenu() {
- final Activity activity = getActivity();
- if (activity != null) {
- activity.invalidateOptionsMenu();
- }
- }
-
- @Override
- public Context getContext() {
- return getActivity();
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, final MenuInflater inflater) {
- inflater.inflate(R.menu.edit_contact, menu);
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- // This supports the keyboard shortcut to save changes to a contact but shouldn't be visible
- // because the custom action bar contains the "save" button now (not the overflow menu).
- // TODO: Find a better way to handle shortcuts, i.e. onKeyDown()?
- final MenuItem saveMenu = menu.findItem(R.id.menu_save);
- final MenuItem splitMenu = menu.findItem(R.id.menu_split);
- final MenuItem joinMenu = menu.findItem(R.id.menu_join);
- final MenuItem helpMenu = menu.findItem(R.id.menu_help);
- final MenuItem sendToVoiceMailMenu = menu.findItem(R.id.menu_send_to_voicemail);
- final MenuItem ringToneMenu = menu.findItem(R.id.menu_set_ringtone);
- final MenuItem deleteMenu = menu.findItem(R.id.menu_delete);
-
- // Set visibility of menus
-
- // help menu depending on whether this is inserting or editing
- if (isInsert(mAction) || mRawContactIdToDisplayAlone != -1) {
- HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
- splitMenu.setVisible(false);
- joinMenu.setVisible(false);
- deleteMenu.setVisible(false);
- } else if (isEdit(mAction)) {
- HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_edit);
- splitMenu.setVisible(canUnlinkRawContacts());
- // Cannot join a user profile
- joinMenu.setVisible(!isEditingUserProfile());
- deleteMenu.setVisible(!mDisableDeleteMenuOption && !isEditingUserProfile());
- } else {
- // something else, so don't show the help menu
- helpMenu.setVisible(false);
- }
-
- // Save menu is invisible when there's only one read only contact in the editor.
- saveMenu.setVisible(!mRawContactDisplayAloneIsReadOnly);
- if (saveMenu.isVisible()) {
- // Since we're using a custom action layout we have to manually hook up the handler.
- saveMenu.getActionView().setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onOptionsItemSelected(saveMenu);
- }
- });
- }
-
- if (mRawContactIdToDisplayAlone != -1 || mIsUserProfile) {
- sendToVoiceMailMenu.setVisible(false);
- ringToneMenu.setVisible(false);
- } else {
- // Hide telephony-related settings (ringtone, send to voicemail)
- // if we don't have a telephone or are editing a new contact.
- sendToVoiceMailMenu.setChecked(mSendToVoicemailState);
- sendToVoiceMailMenu.setVisible(mArePhoneOptionsChangable);
- ringToneMenu.setVisible(mArePhoneOptionsChangable);
- }
-
- int size = menu.size();
- for (int i = 0; i < size; i++) {
- menu.getItem(i).setEnabled(mEnabled);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- final Activity activity = getActivity();
- if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
- // If we no longer are attached to a running activity want to
- // drain this event.
- return true;
- }
-
- switch (item.getItemId()) {
- case R.id.menu_save:
- return save(SaveMode.CLOSE);
- case R.id.menu_delete:
- if (mListener != null) mListener.onDeleteRequested(mLookupUri);
- return true;
- case R.id.menu_split:
- return doSplitContactAction();
- case R.id.menu_join:
- return doJoinContactAction();
- case R.id.menu_set_ringtone:
- doPickRingtone();
- return true;
- case R.id.menu_send_to_voicemail:
- // Update state and save
- mSendToVoicemailState = !mSendToVoicemailState;
- item.setChecked(mSendToVoicemailState);
- final Intent intent = ContactSaveService.createSetSendToVoicemail(
- mContext, mLookupUri, mSendToVoicemailState);
- mContext.startService(intent);
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean revert() {
- if (mState.isEmpty() || !hasPendingChanges()) {
- onCancelEditConfirmed();
- } else {
- CancelEditDialogFragment.show(this);
- }
- return true;
- }
-
- @Override
- public void onCancelEditConfirmed() {
- // When this Fragment is closed we don't want it to auto-save
- mStatus = Status.CLOSING;
- if (mListener != null) {
- mListener.onReverted();
- }
- }
-
- @Override
- public void onSplitContactConfirmed(boolean hasPendingChanges) {
- if (mState.isEmpty()) {
- // This may happen when this Fragment is recreated by the system during users
- // confirming the split action (and thus this method is called just before onCreate()),
- // for example.
- Log.e(TAG, "mState became null during the user's confirming split action. " +
- "Cannot perform the save action.");
- return;
- }
-
- if (!hasPendingChanges && mHasNewContact) {
- // If the user didn't add anything new, we don't want to split out the newly created
- // raw contact into a name-only contact so remove them.
- final Iterator<RawContactDelta> iterator = mState.iterator();
- while (iterator.hasNext()) {
- final RawContactDelta rawContactDelta = iterator.next();
- if (rawContactDelta.getRawContactId() < 0) {
- iterator.remove();
- }
- }
- }
- mState.markRawContactsForSplitting();
- save(SaveMode.SPLIT);
- }
-
- private boolean doSplitContactAction() {
- if (!hasValidState()) return false;
-
- SplitContactConfirmationDialogFragment.show(this, hasPendingChanges());
- return true;
- }
-
- private boolean doJoinContactAction() {
- if (!hasValidState() || mLookupUri == null) {
- return false;
- }
-
- // If we just started creating a new contact and haven't added any data, it's too
- // early to do a join
- if (mState.size() == 1 && mState.get(0).isContactInsert()
- && !hasPendingChanges()) {
- Toast.makeText(mContext, R.string.toast_join_with_empty_contact,
- Toast.LENGTH_LONG).show();
- return true;
- }
-
- showJoinAggregateActivity(mLookupUri);
- return true;
- }
-
- @Override
- public void onJoinContactConfirmed(long joinContactId) {
- doSaveAction(SaveMode.JOIN, joinContactId);
- }
-
- private void doPickRingtone() {
- final Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
- // Allow user to pick 'Default'
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
- // Show only ringtones
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
- // Allow the user to pick a silent ringtone
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
-
- final Uri ringtoneUri = EditorUiUtils.getRingtoneUriFromString(mCustomRingtone,
- CURRENT_API_VERSION);
-
- // Put checkmark next to the current ringtone for this contact
- intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneUri);
-
- // Launch!
- try {
- startActivityForResult(intent, REQUEST_CODE_PICK_RINGTONE);
- } catch (ActivityNotFoundException ex) {
- Toast.makeText(mContext, R.string.missing_app, Toast.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public boolean save(int saveMode) {
- if (!hasValidState() || mStatus != Status.EDITING) {
- return false;
- }
-
- // If we are about to close the editor - there is no need to refresh the data
- if (saveMode == SaveMode.CLOSE || saveMode == SaveMode.COMPACT
- || saveMode == SaveMode.SPLIT) {
- getLoaderManager().destroyLoader(LOADER_CONTACT);
- }
-
- mStatus = Status.SAVING;
-
- if (!hasPendingChanges()) {
- if (mLookupUri == null && saveMode == SaveMode.RELOAD) {
- // We don't have anything to save and there isn't even an existing contact yet.
- // Nothing to do, simply go back to editing mode
- mStatus = Status.EDITING;
- return true;
- }
- onSaveCompleted(/* hadChanges =*/ false, saveMode,
- /* saveSucceeded =*/ mLookupUri != null, mLookupUri, /* joinContactId =*/ null);
- return true;
- }
-
- setEnabled(false);
-
- return doSaveAction(saveMode, /* joinContactId */ null);
- }
-
- /**
- * Persist the accumulated editor deltas.
- *
- * @param joinContactId the raw contact ID to join the contact being saved to after the save,
- * may be null.
- */
- abstract protected boolean doSaveAction(int saveMode, Long joinContactId);
-
- protected boolean startSaveService(Context context, Intent intent, int saveMode) {
- final boolean result = ContactSaveService.startService(
- context, intent, saveMode);
- if (!result) {
- onCancelEditConfirmed();
- }
- return result;
- }
-
- //
- // State accessor methods
- //
-
- /**
- * Check if our internal {@link #mState} is valid, usually checked before
- * performing user actions.
- */
- protected boolean hasValidState() {
- return mState.size() > 0;
- }
-
- protected boolean isEditingUserProfile() {
- return mNewLocalProfile || mIsUserProfile;
- }
-
- /**
- * Whether the contact being edited spans multiple raw contacts.
- * The may also span multiple accounts.
- */
- public boolean isEditingMultipleRawContacts() {
- return mState.size() > 1;
- }
-
- /**
- * Whether the contact being edited is composed of a single read-only raw contact
- * aggregated with a newly created writable raw contact.
- */
- protected boolean isEditingReadOnlyRawContactWithNewContact() {
- return mHasNewContact && mState.size() == 2;
- }
-
- /**
- * Return true if there are any edits to the current contact which need to
- * be saved.
- */
- protected boolean hasPendingRawContactChanges(Set<String> excludedMimeTypes) {
- final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- return RawContactModifier.hasChanges(mState, accountTypes, excludedMimeTypes);
- }
-
- /**
- * We allow unlinking only if there is more than one raw contact, it is not a user-profile,
- * and unlinking won't result in an empty contact. For the empty contact case, we only guard
- * against this when there is a single read-only contact in the aggregate. If the user
- * has joined >1 read-only contacts together, we allow them to unlink it, even if they have
- * never added their own information and unlinking will create a name only contact.
- */
- protected boolean canUnlinkRawContacts() {
- return isEditingMultipleRawContacts()
- && !isEditingUserProfile()
- && !isEditingReadOnlyRawContactWithNewContact();
- }
-
- /**
- * Determines if changes were made in the editor that need to be saved, while taking into
- * account that name changes are not real for read-only contacts.
- * See go/editing-read-only-contacts
- */
- protected boolean hasPendingChanges() {
- if (mReadOnlyNameEditorView != null && mReadOnlyDisplayName != null) {
- // We created a new raw contact delta with a default display name.
- // We must test for pending changes while ignoring the default display name.
- final String displayName = mReadOnlyNameEditorView.getDisplayName();
- if (mReadOnlyDisplayName.equals(displayName)) {
- final Set<String> excludedMimeTypes = new HashSet<>();
- excludedMimeTypes.add(StructuredName.CONTENT_ITEM_TYPE);
- return hasPendingRawContactChanges(excludedMimeTypes);
- }
- return true;
- }
- return hasPendingRawContactChanges(/* excludedMimeTypes =*/ null);
- }
-
- /**
- * Whether editor inputs and the options menu should be enabled.
- */
- protected boolean isEnabled() {
- return mEnabled;
- }
-
- /**
- * Returns the palette extra that was passed in.
- */
- protected MaterialColorMapUtils.MaterialPalette getMaterialPalette() {
- return mMaterialPalette;
- }
-
- //
- // Account creation
- //
-
- private void selectAccountAndCreateContact() {
- // If this is a local profile, then skip the logic about showing the accounts changed
- // activity and create a phone-local contact.
- if (mNewLocalProfile) {
- createContact(null);
- return;
- }
-
- // If there is no default account or the accounts have changed such that we need to
- // prompt the user again, then launch the account prompt.
- if (mEditorUtils.shouldShowAccountChangedNotification()) {
- Intent intent = new Intent(mContext, ContactEditorAccountsChangedActivity.class);
- // Prevent a second instance from being started on rotates
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mStatus = Status.SUB_ACTIVITY;
- startActivityForResult(intent, REQUEST_CODE_ACCOUNTS_CHANGED);
- } else {
- // Otherwise, there should be a default account. Then either create a local contact
- // (if default account is null) or create a contact with the specified account.
- AccountWithDataSet defaultAccount = mEditorUtils.getDefaultAccount();
- createContact(defaultAccount);
- }
- }
-
- /**
- * Create a contact by automatically selecting the first account. If there's no available
- * account, a device-local contact should be created.
- */
- protected void createContact() {
- final List<AccountWithDataSet> accounts =
- AccountTypeManager.getInstance(mContext).getAccounts(true);
- // No Accounts available. Create a phone-local contact.
- if (accounts.isEmpty()) {
- createContact(null);
- return;
- }
-
- // We have an account switcher in "create-account" screen, so don't need to ask a user to
- // select an account here.
- createContact(accounts.get(0));
- }
-
- /**
- * Shows account creation screen associated with a given account.
- *
- * @param account may be null to signal a device-local contact should be created.
- */
- protected void createContact(AccountWithDataSet account) {
- final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- final AccountType accountType = accountTypes.getAccountTypeForAccount(account);
-
- if (accountType.getCreateContactActivityClassName() != null) {
- if (mListener != null) {
- mListener.onCustomCreateContactActivityRequested(account, mIntentExtras);
- }
- } else {
- setStateForNewContact(account, accountType, isEditingUserProfile());
- }
- }
-
- //
- // Data binding
- //
-
- private void setState(Contact contact) {
- // If we have already loaded data, we do not want to change it here to not confuse the user
- if (!mState.isEmpty()) {
- Log.v(TAG, "Ignoring background change. This will have to be rebased later");
- return;
- }
-
- // See if this edit operation needs to be redirected to a custom editor
- mRawContacts = contact.getRawContacts();
- if (mRawContacts.size() == 1) {
- RawContact rawContact = mRawContacts.get(0);
- String type = rawContact.getAccountTypeString();
- String dataSet = rawContact.getDataSet();
- AccountType accountType = rawContact.getAccountType(mContext);
- if (accountType.getEditContactActivityClassName() != null &&
- !accountType.areContactsWritable()) {
- if (mListener != null) {
- String name = rawContact.getAccountName();
- long rawContactId = rawContact.getId();
- mListener.onCustomEditContactActivityRequested(
- new AccountWithDataSet(name, type, dataSet),
- ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
- mIntentExtras, true);
- }
- return;
- }
- }
-
- String readOnlyDisplayName = null;
- // Check for writable raw contacts. If there are none, then we need to create one so user
- // can edit. For the user profile case, there is already an editable contact.
- if (!contact.isUserProfile() && !contact.isWritableContact(mContext)) {
- mHasNewContact = true;
-
- // This is potentially an asynchronous call and will add deltas to list.
- selectAccountAndCreateContact();
-
- readOnlyDisplayName = contact.getDisplayName();
- } else {
- mHasNewContact = false;
- }
-
- // This also adds deltas to list. If readOnlyDisplayName is null at this point it is
- // simply ignored later on by the editor.
- setStateForExistingContact(readOnlyDisplayName, contact.isUserProfile(), mRawContacts);
- }
-
- /**
- * Prepare {@link #mState} for a newly created phone-local contact.
- */
- private void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
- boolean isUserProfile) {
- setStateForNewContact(account, accountType, /* oldState =*/ null,
- /* oldAccountType =*/ null, isUserProfile);
- }
-
- /**
- * Prepare {@link #mState} for a newly created phone-local contact, migrating the state
- * specified by oldState and oldAccountType.
- */
- protected void setStateForNewContact(AccountWithDataSet account, AccountType accountType,
- RawContactDelta oldState, AccountType oldAccountType, boolean isUserProfile) {
- mStatus = Status.EDITING;
- mState.add(createNewRawContactDelta(account, accountType, oldState, oldAccountType));
- mIsUserProfile = isUserProfile;
- mNewContactDataReady = true;
- bindEditors();
- }
-
- /**
- * Returns a {@link RawContactDelta} for a new contact suitable for addition into
- * {@link #mState}.
- *
- * If oldState and oldAccountType are specified, the state specified by those parameters
- * is migrated to the result {@link RawContactDelta}.
- */
- private RawContactDelta createNewRawContactDelta(AccountWithDataSet account,
- AccountType accountType, RawContactDelta oldState, AccountType oldAccountType) {
- final RawContact rawContact = new RawContact();
- if (account != null) {
- rawContact.setAccount(account);
- } else {
- rawContact.setAccountToLocal();
- }
-
- final RawContactDelta result = new RawContactDelta(
- ValuesDelta.fromAfter(rawContact.getValues()));
- if (oldState == null) {
- // Parse any values from incoming intent
- RawContactModifier.parseExtras(mContext, accountType, result, mIntentExtras);
- } else {
- RawContactModifier.migrateStateForNewContact(
- mContext, oldState, result, oldAccountType, accountType);
- }
-
- // Ensure we have some default fields (if the account type does not support a field,
- // ensureKind will not add it, so it is safe to add e.g. Event)
- RawContactModifier.ensureKindExists(result, accountType, Phone.CONTENT_ITEM_TYPE);
- RawContactModifier.ensureKindExists(result, accountType, Email.CONTENT_ITEM_TYPE);
- RawContactModifier.ensureKindExists(result, accountType, Organization.CONTENT_ITEM_TYPE);
- RawContactModifier.ensureKindExists(result, accountType, Event.CONTENT_ITEM_TYPE);
- RawContactModifier.ensureKindExists(result, accountType,
- StructuredPostal.CONTENT_ITEM_TYPE);
-
- // Set the correct URI for saving the contact as a profile
- if (mNewLocalProfile) {
- result.setProfileQueryUri();
- }
-
- return result;
- }
-
- /**
- * Prepare {@link #mState} for an existing contact.
- */
- protected void setStateForExistingContact(String readOnlyDisplayName, boolean isUserProfile,
- ImmutableList<RawContact> rawContacts) {
- setEnabled(true);
- mReadOnlyDisplayName = readOnlyDisplayName;
-
- mState.addAll(rawContacts.iterator());
- setIntentExtras(mIntentExtras);
- mIntentExtras = null;
-
- // For user profile, change the contacts query URI
- mIsUserProfile = isUserProfile;
- boolean localProfileExists = false;
-
- if (mIsUserProfile) {
- for (RawContactDelta rawContactDelta : mState) {
- // For profile contacts, we need a different query URI
- rawContactDelta.setProfileQueryUri();
- // Try to find a local profile contact
- if (rawContactDelta.getValues().getAsString(RawContacts.ACCOUNT_TYPE) == null) {
- localProfileExists = true;
- }
- }
- // Editor should always present a local profile for editing
- if (!localProfileExists) {
- mState.add(createLocalRawContactDelta());
- }
- }
- mExistingContactDataReady = true;
- bindEditors();
- }
-
- /**
- * Returns a {@link RawContactDelta} for a local contact suitable for addition into
- * {@link #mState}.
- */
- private static RawContactDelta createLocalRawContactDelta() {
- final RawContact rawContact = new RawContact();
- rawContact.setAccountToLocal();
-
- final RawContactDelta result = new RawContactDelta(
- ValuesDelta.fromAfter(rawContact.getValues()));
- result.setProfileQueryUri();
-
- return result;
- }
-
- /**
- * Sets group metadata on all bound editors.
- */
- abstract protected void setGroupMetaData();
-
- /**
- * Bind editors using {@link #mState} and other members initialized from the loaded (or new)
- * Contact.
- */
- abstract protected void bindEditors();
-
- /**
- * Set the enabled state of editors.
- */
- private void setEnabled(boolean enabled) {
- if (mEnabled != enabled) {
- mEnabled = enabled;
-
- // Enable/disable editors
- if (mContent != null) {
- int count = mContent.getChildCount();
- for (int i = 0; i < count; i++) {
- mContent.getChildAt(i).setEnabled(enabled);
- }
- }
-
- // Enable/disable aggregation suggestion vies
- if (mAggregationSuggestionView != null) {
- LinearLayout itemList = (LinearLayout) mAggregationSuggestionView.findViewById(
- R.id.aggregation_suggestions);
- int count = itemList.getChildCount();
- for (int i = 0; i < count; i++) {
- itemList.getChildAt(i).setEnabled(enabled);
- }
- }
-
- // Maybe invalidate the options menu
- final Activity activity = getActivity();
- if (activity != null) activity.invalidateOptionsMenu();
- }
- }
-
- /**
- * Removes a current editor ({@link #mState}) and rebinds new editor for a new account.
- * Some of old data are reused with new restriction enforced by the new account.
- *
- * @param oldState Old data being edited.
- * @param oldAccount Old account associated with oldState.
- * @param newAccount New account to be used.
- */
- protected void rebindEditorsForNewContact(
- RawContactDelta oldState, AccountWithDataSet oldAccount,
- AccountWithDataSet newAccount) {
- AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- AccountType oldAccountType = accountTypes.getAccountTypeForAccount(oldAccount);
- AccountType newAccountType = accountTypes.getAccountTypeForAccount(newAccount);
-
- if (newAccountType.getCreateContactActivityClassName() != null) {
- Log.w(TAG, "external activity called in rebind situation");
- if (mListener != null) {
- mListener.onCustomCreateContactActivityRequested(newAccount, mIntentExtras);
- }
- } else {
- mExistingContactDataReady = false;
- mNewContactDataReady = false;
- mState = new RawContactDeltaList();
- setStateForNewContact(newAccount, newAccountType, oldState, oldAccountType,
- isEditingUserProfile());
- if (mIsEdit) {
- setStateForExistingContact(mReadOnlyDisplayName, isEditingUserProfile(),
- mRawContacts);
- }
- }
- }
-
- //
- // ContactEditor
- //
-
- @Override
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- @Override
- public void load(String action, Uri lookupUri, Bundle intentExtras) {
- mAction = action;
- mLookupUri = lookupUri;
- mIntentExtras = intentExtras;
-
- if (mIntentExtras != null) {
- mAutoAddToDefaultGroup =
- mIntentExtras.containsKey(INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY);
- mNewLocalProfile =
- mIntentExtras.getBoolean(INTENT_EXTRA_NEW_LOCAL_PROFILE);
- mDisableDeleteMenuOption =
- mIntentExtras.getBoolean(INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION);
- if (mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR)
- && mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR)) {
- mMaterialPalette = new MaterialColorMapUtils.MaterialPalette(
- mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR),
- mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR));
- }
- // If the user selected a different photo, don't restore the one from the Intent
- if (mPhotoId < 0) {
- mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID);
- }
- mRawContactIdToDisplayAlone = mIntentExtras.getLong(
- INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, -1);
- mRawContactDisplayAloneIsReadOnly = mIntentExtras.getBoolean(
- INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY);
- }
- }
-
- @Override
- public void setIntentExtras(Bundle extras) {
- if (extras == null || extras.size() == 0) {
- return;
- }
-
- final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- for (RawContactDelta state : mState) {
- final AccountType type = state.getAccountType(accountTypes);
- if (type.areContactsWritable()) {
- // Apply extras to the first writable raw contact only
- RawContactModifier.parseExtras(mContext, type, state, extras);
- break;
- }
- }
- }
-
- @Override
- public void onJoinCompleted(Uri uri) {
- onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri, /* joinContactId */ null);
- }
-
- @Override
- public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
- Uri contactLookupUri, Long joinContactId) {
- if (hadChanges) {
- if (saveSucceeded) {
- switch (saveMode) {
- case SaveMode.JOIN:
- break;
- case SaveMode.SPLIT:
- Toast.makeText(mContext, R.string.contactUnlinkedToast, Toast.LENGTH_SHORT)
- .show();
- break;
- default:
- Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT)
- .show();
- }
-
- } else {
- Toast.makeText(mContext, R.string.contactSavedErrorToast, Toast.LENGTH_LONG).show();
- }
- }
- switch (saveMode) {
- case SaveMode.CLOSE: {
- final Intent resultIntent;
- if (saveSucceeded && contactLookupUri != null) {
- final Uri lookupUri = maybeConvertToLegacyLookupUri(
- mContext, contactLookupUri, mLookupUri);
- resultIntent = ImplicitIntentsUtil.composeQuickContactIntent(mContext,
- lookupUri, QuickContactActivity.MODE_FULLY_EXPANDED);
- resultIntent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE,
- ScreenType.EDITOR);
- resultIntent.putExtra(QuickContactActivity.EXTRA_CONTACT_EDITED, true);
- } else {
- resultIntent = null;
- }
- // It is already saved, so prevent it from being saved again
- mStatus = Status.CLOSING;
- if (mListener != null) mListener.onSaveFinished(resultIntent);
- break;
- }
- case SaveMode.COMPACT: {
- // It is already saved, so prevent it from being saved again
- mStatus = Status.CLOSING;
- if (mListener != null) mListener.onSaveFinished(/* resultIntent= */ null);
- break;
- }
- case SaveMode.JOIN:
- if (saveSucceeded && contactLookupUri != null && joinContactId != null) {
- joinAggregate(joinContactId);
- }
- break;
- case SaveMode.RELOAD:
- if (saveSucceeded && contactLookupUri != null) {
- // If this was in INSERT, we are changing into an EDIT now.
- // If it already was an EDIT, we are changing to the new Uri now
- mState = new RawContactDeltaList();
- load(Intent.ACTION_EDIT, contactLookupUri, null);
- mStatus = Status.LOADING;
- getLoaderManager().restartLoader(LOADER_CONTACT, null, mContactLoaderListener);
- }
- break;
-
- case SaveMode.SPLIT:
- mStatus = Status.CLOSING;
- if (mListener != null) {
- mListener.onContactSplit(contactLookupUri);
- } else {
- Log.d(TAG, "No listener registered, can not call onSplitFinished");
- }
- break;
- }
- }
-
- /**
- * Shows a list of aggregates that can be joined into the currently viewed aggregate.
- *
- * @param contactLookupUri the fresh URI for the currently edited contact (after saving it)
- */
- private void showJoinAggregateActivity(Uri contactLookupUri) {
- if (contactLookupUri == null || !isAdded()) {
- return;
- }
-
- mContactIdForJoin = ContentUris.parseId(contactLookupUri);
- final Intent intent = new Intent(mContext, ContactSelectionActivity.class);
- intent.setAction(UiIntentActions.PICK_JOIN_CONTACT_ACTION);
- intent.putExtra(UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, mContactIdForJoin);
- startActivityForResult(intent, REQUEST_CODE_JOIN);
- }
-
- //
- // Aggregation PopupWindow
- //
-
- /**
- * Triggers an asynchronous search for aggregation suggestions.
- */
- protected void acquireAggregationSuggestions(Context context,
- long rawContactId, ValuesDelta valuesDelta) {
- if (mAggregationSuggestionsRawContactId != rawContactId
- && mAggregationSuggestionView != null) {
- mAggregationSuggestionView.setVisibility(View.GONE);
- mAggregationSuggestionView = null;
- mAggregationSuggestionEngine.reset();
- }
-
- mAggregationSuggestionsRawContactId = rawContactId;
-
- if (mAggregationSuggestionEngine == null) {
- mAggregationSuggestionEngine = new AggregationSuggestionEngine(context);
- mAggregationSuggestionEngine.setListener(this);
- mAggregationSuggestionEngine.start();
- }
-
- mAggregationSuggestionEngine.setContactId(getContactId());
-
- mAggregationSuggestionEngine.onNameChange(valuesDelta);
- }
-
- /**
- * Returns the contact ID for the currently edited contact or 0 if the contact is new.
- */
- private long getContactId() {
- for (RawContactDelta rawContact : mState) {
- Long contactId = rawContact.getValues().getAsLong(RawContacts.CONTACT_ID);
- if (contactId != null) {
- return contactId;
- }
- }
- return 0;
- }
-
- @Override
- public void onAggregationSuggestionChange() {
- final Activity activity = getActivity();
- if ((activity != null && activity.isFinishing())
- || !isVisible() || mState.isEmpty() || mStatus != Status.EDITING) {
- return;
- }
-
- UiClosables.closeQuietly(mAggregationSuggestionPopup);
-
- if (mAggregationSuggestionEngine.getSuggestedContactCount() == 0) {
- return;
- }
-
- final View anchorView = getAggregationAnchorView(mAggregationSuggestionsRawContactId);
- if (anchorView == null) {
- return; // Raw contact deleted?
- }
- mAggregationSuggestionPopup = new ListPopupWindow(mContext, null);
- mAggregationSuggestionPopup.setAnchorView(anchorView);
- mAggregationSuggestionPopup.setWidth(anchorView.getWidth());
- mAggregationSuggestionPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
- mAggregationSuggestionPopup.setAdapter(
- new AggregationSuggestionAdapter(
- getActivity(),
- mState.size() == 1 && mState.get(0).isContactInsert(),
- /* listener =*/ this,
- mAggregationSuggestionEngine.getSuggestions()));
- mAggregationSuggestionPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- final AggregationSuggestionView suggestionView = (AggregationSuggestionView) view;
- suggestionView.handleItemClickEvent();
- UiClosables.closeQuietly(mAggregationSuggestionPopup);
- mAggregationSuggestionPopup = null;
- }
- });
- mAggregationSuggestionPopup.show();
- }
-
- /**
- * Returns the raw contact editor view for the given rawContactId that should be used as the
- * anchor for aggregation suggestions.
- */
- abstract protected View getAggregationAnchorView(long rawContactId);
-
- /**
- * Whether the given raw contact ID matches the one used to last load aggregation
- * suggestions.
- */
- protected boolean isAggregationSuggestionRawContactId(long rawContactId) {
- return mAggregationSuggestionsRawContactId == rawContactId;
- }
-
- @Override
- public void onJoinAction(long contactId, List<Long> rawContactIdList) {
- final long rawContactIds[] = new long[rawContactIdList.size()];
- for (int i = 0; i < rawContactIds.length; i++) {
- rawContactIds[i] = rawContactIdList.get(i);
- }
- try {
- JoinSuggestedContactDialogFragment.show(this, rawContactIds);
- } catch (Exception ignored) {
- // No problem - the activity is no longer available to display the dialog
- }
- }
-
- /**
- * Joins the suggested contact (specified by the id's of constituent raw
- * contacts), save all changes, and stay in the editor.
- */
- protected void doJoinSuggestedContact(long[] rawContactIds) {
- if (!hasValidState() || mStatus != Status.EDITING) {
- return;
- }
-
- mState.setJoinWithRawContacts(rawContactIds);
- save(SaveMode.RELOAD);
- }
-
- @Override
- public void onEditAction(Uri contactLookupUri) {
- SuggestionEditConfirmationDialogFragment.show(this, contactLookupUri);
- }
-
- /**
- * Abandons the currently edited contact and switches to editing the suggested
- * one, transferring all the data there
- */
- protected void doEditSuggestedContact(Uri contactUri) {
- if (mListener != null) {
- // make sure we don't save this contact when closing down
- mStatus = Status.CLOSING;
- mListener.onEditOtherContactRequested(
- contactUri, mState.get(0).getContentValues());
- }
- }
-
- //
- // Join Activity
- //
-
- /**
- * Performs aggregation with the contact selected by the user from suggestions or A-Z list.
- */
- abstract protected void joinAggregate(long contactId);
-
- //
- // Utility methods
- //
-
- /**
- * Returns a legacy version of the given contactLookupUri if a legacy Uri was originally
- * passed to the contact editor.
- *
- * @param contactLookupUri The Uri to possibly convert to legacy format.
- * @param requestLookupUri The lookup Uri originally passed to the contact editor
- * (via Intent data), may be null.
- */
- protected static Uri maybeConvertToLegacyLookupUri(Context context, Uri contactLookupUri,
- Uri requestLookupUri) {
- final String legacyAuthority = "contacts";
- final String requestAuthority = requestLookupUri == null
- ? null : requestLookupUri.getAuthority();
- if (legacyAuthority.equals(requestAuthority)) {
- // Build a legacy Uri if that is what was requested by caller
- final long contactId = ContentUris.parseId(Contacts.lookupContact(
- context.getContentResolver(), contactLookupUri));
- final Uri legacyContentUri = Uri.parse("content://contacts/people");
- return ContentUris.withAppendedId(legacyContentUri, contactId);
- }
- // Otherwise pass back a lookup-style Uri
- return contactLookupUri;
- }
-
- /**
- * Whether the argument Intent requested a contact insert action or not.
- */
- protected static boolean isInsert(Intent intent) {
- return intent == null ? false : isInsert(intent.getAction());
- }
-
- protected static boolean isInsert(String action) {
- return Intent.ACTION_INSERT.equals(action)
- || ContactEditorBaseActivity.ACTION_INSERT.equals(action);
- }
-
- protected static boolean isEdit(String action) {
- return Intent.ACTION_EDIT.equals(action)
- || ContactEditorBaseActivity.ACTION_EDIT.equals(action);
- }
-}
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
deleted file mode 100644
index f10120c..0000000
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.editor;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.ContactsContract.CommonDataKinds.Photo;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import com.android.contacts.ContactSaveService;
-import com.android.contacts.R;
-import com.android.contacts.activities.ContactEditorActivity;
-import com.android.contacts.common.model.AccountTypeManager;
-import com.android.contacts.common.model.RawContactDelta;
-import com.android.contacts.common.model.RawContactDeltaList;
-import com.android.contacts.common.model.ValuesDelta;
-import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.detail.PhotoSelectionHandler;
-import com.android.contacts.editor.Editor.EditorListener;
-import com.android.contacts.util.ContactPhotoUtils;
-
-import java.io.FileNotFoundException;
-import java.util.Collections;
-import java.util.HashMap;
-
-/**
- * Contact editor with all fields displayed.
- */
-public class ContactEditorFragment extends ContactEditorBaseFragment implements
- RawContactReadOnlyEditorView.Listener {
-
- private static final String KEY_EXPANDED_EDITORS = "expandedEditors";
-
- private static final String KEY_RAW_CONTACT_ID_REQUESTING_PHOTO = "photorequester";
- private static final String KEY_CURRENT_PHOTO_URI = "currentphotouri";
- private static final String KEY_UPDATED_PHOTOS = "updatedPhotos";
-
- // Used to store which raw contact editors have been expanded. Keyed on raw contact ids.
- private HashMap<Long, Boolean> mExpandedEditors = new HashMap<Long, Boolean>();
-
- /**
- * The raw contact for which we started "take photo" or "choose photo from gallery" most
- * recently. Used to restore {@link #mCurrentPhotoHandler} after orientation change.
- */
- private long mRawContactIdRequestingPhoto;
-
- /**
- * The {@link PhotoHandler} for the photo editor for the {@link #mRawContactIdRequestingPhoto}
- * raw contact.
- *
- * A {@link PhotoHandler} is created for each photo editor in {@link #bindPhotoHandler}, but
- * the only "active" one should get the activity result. This member represents the active
- * one.
- */
- private PhotoHandler mCurrentPhotoHandler;
- private Uri mCurrentPhotoUri;
- private Bundle mUpdatedPhotos = new Bundle();
-
- public ContactEditorFragment() {
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
- final View view = inflater.inflate(R.layout.contact_editor_fragment, container, false);
-
- mContent = (LinearLayout) view.findViewById(R.id.editors);
-
- setHasOptionsMenu(true);
-
- return view;
- }
-
- @Override
- public void onCreate(Bundle savedState) {
- super.onCreate(savedState);
-
- if (savedState != null) {
- mExpandedEditors = (HashMap<Long, Boolean>)
- savedState.getSerializable(KEY_EXPANDED_EDITORS);
- mRawContactIdRequestingPhoto = savedState.getLong(
- KEY_RAW_CONTACT_ID_REQUESTING_PHOTO);
- mCurrentPhotoUri = savedState.getParcelable(KEY_CURRENT_PHOTO_URI);
- mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
- mRawContactIdToDisplayAlone = savedState.getLong(
- ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, -1);
- }
- }
-
- @Override
- public void load(String action, Uri lookupUri, Bundle intentExtras) {
- super.load(action, lookupUri, intentExtras);
- if (intentExtras != null) {
- mRawContactIdToDisplayAlone = intentExtras.getLong(
- ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE, -1);
- }
- }
-
- @Override
- public void onStart() {
- getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
- super.onStart();
- }
-
- @Override
- public void onExternalEditorRequest(AccountWithDataSet account, Uri uri) {
- if (mListener != null) {
- mListener.onCustomEditContactActivityRequested(account, uri, null, false);
- }
- }
-
- @Override
- public void onEditorExpansionChanged() {
- updatedExpandedEditorsMap();
- }
-
- @Override
- protected void setGroupMetaData() {
- if (mGroupMetaData == null) {
- return;
- }
- int editorCount = mContent.getChildCount();
- for (int i = 0; i < editorCount; i++) {
- BaseRawContactEditorView editor = (BaseRawContactEditorView) mContent.getChildAt(i);
- editor.setGroupMetaData(mGroupMetaData);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- return revert();
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void bindEditors() {
- // bindEditors() can only bind views if there is data in mState, so immediately return
- // if mState is null
- if (mState.isEmpty()) {
- return;
- }
-
- // Check if delta list is ready. Delta list is populated from existing data and when
- // editing an read-only contact, it's also populated with newly created data for the
- // blank form. When the data is not ready, skip. This method will be called multiple times.
- if ((mIsEdit && !mExistingContactDataReady) || (mHasNewContact && !mNewContactDataReady)) {
- return;
- }
-
- // Sort the editors
- Collections.sort(mState, mComparator);
-
- // Remove any existing editors and rebuild any visible
- mContent.removeAllViews();
-
- final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
- int numRawContacts = mState.size();
-
- for (int i = 0; i < numRawContacts; i++) {
- // TODO ensure proper ordering of entities in the list
- final RawContactDelta rawContactDelta = mState.get(i);
- if (!rawContactDelta.isVisible()) continue;
-
- final AccountType type = rawContactDelta.getAccountType(accountTypes);
- final long rawContactId = rawContactDelta.getRawContactId();
-
- if (mRawContactIdToDisplayAlone != -1 && mRawContactIdToDisplayAlone != rawContactId) {
- continue;
- }
-
- final BaseRawContactEditorView editor;
- if (!type.areContactsWritable()) {
- editor = (BaseRawContactEditorView) inflater.inflate(
- R.layout.raw_contact_readonly_editor_view, mContent, false);
- } else {
- editor = (RawContactEditorView) inflater.inflate(R.layout.raw_contact_editor_view,
- mContent, false);
- }
- editor.setListener(this);
- editor.setEnabled(isEnabled());
-
- if (mRawContactIdToDisplayAlone != -1) {
- editor.setCollapsed(false);
- } else if (mExpandedEditors.containsKey(rawContactId)) {
- editor.setCollapsed(mExpandedEditors.get(rawContactId));
- } else {
- // By default, only the first editor will be expanded.
- editor.setCollapsed(i != 0);
- }
-
- mContent.addView(editor);
-
- editor.setState(rawContactDelta, type, mViewIdGenerator, isEditingUserProfile());
- if (mRawContactIdToDisplayAlone != -1) {
- editor.setCollapsible(false);
- } else {
- editor.setCollapsible(numRawContacts > 1);
- }
-
- // Set up the photo handler.
- bindPhotoHandler(editor, type, mState);
-
- // If a new photo was chosen but not yet saved, we need to update the UI to
- // reflect this.
- final Uri photoUri = updatedPhotoUriForRawContact(rawContactId);
- if (photoUri != null) editor.setFullSizedPhoto(photoUri);
-
- if (editor instanceof RawContactEditorView) {
- final Activity activity = getActivity();
- final RawContactEditorView rawContactEditor = (RawContactEditorView) editor;
- final ValuesDelta nameValuesDelta = rawContactEditor.getNameEditor().getValues();
- final EditorListener structuredNameListener = new EditorListener() {
-
- @Override
- public void onRequest(int request) {
- // Make sure the activity is running
- if (activity.isFinishing()) {
- return;
- }
- if (!isEditingUserProfile()) {
- if (request == EditorListener.FIELD_CHANGED) {
- if (!nameValuesDelta.isSuperPrimary()) {
- unsetSuperPrimaryForAllNameEditors();
- nameValuesDelta.setSuperPrimary(true);
- }
- acquireAggregationSuggestions(activity,
- rawContactEditor.getNameEditor().getRawContactId(),
- rawContactEditor.getNameEditor().getValues());
- } else if (request == EditorListener.FIELD_TURNED_EMPTY) {
- if (nameValuesDelta.isSuperPrimary()) {
- nameValuesDelta.setSuperPrimary(false);
- }
- }
- }
- }
-
- @Override
- public void onDeleteRequested(Editor removedEditor) {
- }
- };
-
- final StructuredNameEditorView nameEditor = rawContactEditor.getNameEditor();
- nameEditor.setEditorListener(structuredNameListener);
-
- rawContactEditor.setAutoAddToDefaultGroup(mAutoAddToDefaultGroup);
-
- if (!isEditingUserProfile() && isAggregationSuggestionRawContactId(rawContactId)) {
- acquireAggregationSuggestions(activity,
- rawContactEditor.getNameEditor().getRawContactId(),
- rawContactEditor.getNameEditor().getValues());
- }
- }
- }
-
- setGroupMetaData();
-
- // Show editor now that we've loaded state
- mContent.setVisibility(View.VISIBLE);
-
- // Refresh Action Bar as the visibility of the join command
- // Activity can be null if we have been detached from the Activity
- invalidateOptionsMenu();
-
- updatedExpandedEditorsMap();
- }
-
- private void unsetSuperPrimaryForAllNameEditors() {
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View view = mContent.getChildAt(i);
- if (view instanceof RawContactEditorView) {
- final RawContactEditorView rawContactEditorView = (RawContactEditorView) view;
- final StructuredNameEditorView nameEditorView =
- rawContactEditorView.getNameEditor();
- if (nameEditorView != null) {
- final ValuesDelta valuesDelta = nameEditorView.getValues();
- if (valuesDelta != null) {
- valuesDelta.setSuperPrimary(false);
- }
- }
- }
- }
- }
-
- /**
- * Update the values in {@link #mExpandedEditors}.
- */
- private void updatedExpandedEditorsMap() {
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View childView = mContent.getChildAt(i);
- if (childView instanceof BaseRawContactEditorView) {
- BaseRawContactEditorView childEditor = (BaseRawContactEditorView) childView;
- mExpandedEditors.put(childEditor.getRawContactId(), childEditor.isCollapsed());
- }
- }
- }
-
- /**
- * If we've stashed a temporary file containing a contact's new photo, return its URI.
- * @param rawContactId identifies the raw-contact whose Bitmap we'll try to return.
- * @return Uru of photo for specified raw-contact, or null
- */
- private Uri updatedPhotoUriForRawContact(long rawContactId) {
- return (Uri) mUpdatedPhotos.get(String.valueOf(rawContactId));
- }
-
- private void bindPhotoHandler(BaseRawContactEditorView editor, AccountType type,
- RawContactDeltaList state) {
- final int mode;
- boolean showIsPrimaryOption;
- if (type.areContactsWritable()) {
- if (editor.hasSetPhoto()) {
- mode = PhotoActionPopup.Modes.WRITE_ABLE_PHOTO;
- showIsPrimaryOption = hasMoreThanOnePhoto();
- } else {
- mode = PhotoActionPopup.Modes.NO_PHOTO;
- showIsPrimaryOption = false;
- }
- } else if (editor.hasSetPhoto() && hasMoreThanOnePhoto()) {
- mode = PhotoActionPopup.Modes.READ_ONLY_PHOTO;
- showIsPrimaryOption = true;
- } else {
- // Read-only and either no photo or the only photo ==> no options
- editor.getPhotoEditor().setEditorListener(null);
- editor.getPhotoEditor().setShowPrimary(false);
- return;
- }
- if (mRawContactIdToDisplayAlone != -1) {
- showIsPrimaryOption = false;
- }
- final PhotoHandler photoHandler = new PhotoHandler(mContext, editor, mode, state);
- editor.getPhotoEditor().setEditorListener(
- (PhotoHandler.PhotoEditorListener) photoHandler.getListener());
- editor.getPhotoEditor().setShowPrimary(showIsPrimaryOption);
-
- // Note a newly created raw contact gets some random negative ID, so any value is valid
- // here. (i.e. don't check against -1 or anything.)
- if (mRawContactIdRequestingPhoto == editor.getRawContactId()) {
- mCurrentPhotoHandler = photoHandler;
- }
- }
-
- @Override
- protected boolean doSaveAction(int saveMode, Long joinContactId) {
- final Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
- SAVE_MODE_EXTRA_KEY, saveMode, isEditingUserProfile(),
- ((Activity) mContext).getClass(), ContactEditorActivity.ACTION_SAVE_COMPLETED,
- mUpdatedPhotos, JOIN_CONTACT_ID_EXTRA_KEY, joinContactId);
- return startSaveService(mContext, intent, saveMode);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- outState.putSerializable(KEY_EXPANDED_EDITORS, mExpandedEditors);
- outState.putLong(KEY_RAW_CONTACT_ID_REQUESTING_PHOTO, mRawContactIdRequestingPhoto);
- outState.putParcelable(KEY_CURRENT_PHOTO_URI, mCurrentPhotoUri);
- outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
- outState.putLong(ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE,
- mRawContactIdToDisplayAlone);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (mStatus == Status.SUB_ACTIVITY) {
- mStatus = Status.EDITING;
- }
-
- // See if the photo selection handler handles this result.
- if (mCurrentPhotoHandler != null && mCurrentPhotoHandler.handlePhotoActivityResult(
- requestCode, resultCode, data)) {
- return;
- }
-
- super.onActivityResult(requestCode, resultCode, data);
- }
-
- @Override
- protected void joinAggregate(final long contactId) {
- final Intent intent = ContactSaveService.createJoinContactsIntent(
- mContext, mContactIdForJoin, contactId, ContactEditorActivity.class,
- ContactEditorActivity.ACTION_JOIN_COMPLETED);
- mContext.startService(intent);
- }
-
- /**
- * Sets the photo stored in mPhoto and writes it to the RawContact with the given id
- */
- private void setPhoto(long rawContact, Bitmap photo, Uri photoUri) {
- BaseRawContactEditorView requestingEditor = getRawContactEditorView(rawContact);
-
- if (photo == null || photo.getHeight() <= 0 || photo.getWidth() <= 0) {
- // This is unexpected.
- Log.w(TAG, "Invalid bitmap passed to setPhoto()");
- }
-
- if (requestingEditor != null) {
- requestingEditor.setPhotoEntry(photo);
- // Immediately set all other photos as non-primary. Otherwise the UI can display
- // multiple photos as "Primary photo".
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View childView = mContent.getChildAt(i);
- if (childView instanceof BaseRawContactEditorView
- && childView != requestingEditor) {
- final BaseRawContactEditorView rawContactEditor
- = (BaseRawContactEditorView) childView;
- rawContactEditor.getPhotoEditor().setSuperPrimary(false);
- }
- }
- } else {
- Log.w(TAG, "The contact that requested the photo is no longer present.");
- }
-
- mUpdatedPhotos.putParcelable(String.valueOf(rawContact), photoUri);
- }
-
- /**
- * Finds raw contact editor view for the given rawContactId.
- */
- @Override
- protected View getAggregationAnchorView(long rawContactId) {
- BaseRawContactEditorView editorView = getRawContactEditorView(rawContactId);
- return editorView == null ? null : editorView.findViewById(R.id.anchor_view);
- }
-
- public BaseRawContactEditorView getRawContactEditorView(long rawContactId) {
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View childView = mContent.getChildAt(i);
- if (childView instanceof BaseRawContactEditorView) {
- final BaseRawContactEditorView editor = (BaseRawContactEditorView) childView;
- if (editor.getRawContactId() == rawContactId) {
- return editor;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns true if there is currently more than one photo on screen.
- */
- private boolean hasMoreThanOnePhoto() {
- int countWithPicture = 0;
- final int numEntities = mState.size();
- for (int i = 0; i < numEntities; i++) {
- final RawContactDelta entity = mState.get(i);
- if (entity.isVisible()) {
- final ValuesDelta primary = entity.getPrimaryEntry(Photo.CONTENT_ITEM_TYPE);
- if (primary != null && primary.getPhoto() != null) {
- countWithPicture++;
- } else {
- final long rawContactId = entity.getRawContactId();
- final Uri uri = mUpdatedPhotos.getParcelable(String.valueOf(rawContactId));
- if (uri != null) {
- try {
- mContext.getContentResolver().openInputStream(uri);
- countWithPicture++;
- } catch (FileNotFoundException e) {
- }
- }
- }
-
- if (countWithPicture > 1) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Custom photo handler for the editor. The inner listener that this creates also has a
- * reference to the editor and acts as an {@link EditorListener}, and uses that editor to hold
- * state information in several of the listener methods.
- */
- private final class PhotoHandler extends PhotoSelectionHandler {
-
- final long mRawContactId;
- private final BaseRawContactEditorView mEditor;
- private final PhotoActionListener mPhotoEditorListener;
-
- public PhotoHandler(Context context, BaseRawContactEditorView editor, int photoMode,
- RawContactDeltaList state) {
- super(context, editor.getPhotoEditor().getChangeAnchorView(), photoMode, false, state);
- mEditor = editor;
- mRawContactId = editor.getRawContactId();
- mPhotoEditorListener = new PhotoEditorListener();
- }
-
- @Override
- public PhotoActionListener getListener() {
- return mPhotoEditorListener;
- }
-
- @Override
- public void startPhotoActivity(Intent intent, int requestCode, Uri photoUri) {
- if (getActivity() == null) {
- return;
- }
- mRawContactIdRequestingPhoto = mEditor.getRawContactId();
- mCurrentPhotoHandler = this;
- mStatus = Status.SUB_ACTIVITY;
- mCurrentPhotoUri = photoUri;
- ContactEditorFragment.this.startActivityForResult(intent, requestCode);
- }
-
- private final class PhotoEditorListener extends PhotoSelectionHandler.PhotoActionListener
- implements EditorListener {
-
- @Override
- public void onRequest(int request) {
- if (!hasValidState()) return;
-
- if (request == EditorListener.REQUEST_PICK_PHOTO) {
- onClick(mEditor.getPhotoEditor());
- }
- if (request == EditorListener.REQUEST_PICK_PRIMARY_PHOTO) {
- useAsPrimaryChosen();
- }
- }
-
- @Override
- public void onDeleteRequested(Editor removedEditor) {
- // The picture cannot be deleted, it can only be removed, which is handled by
- // onRemovePictureChosen()
- }
-
- /**
- * User has chosen to set the selected photo as the (super) primary photo
- */
- public void useAsPrimaryChosen() {
- // Set the IsSuperPrimary for each editor
- int count = mContent.getChildCount();
- for (int i = 0; i < count; i++) {
- final View childView = mContent.getChildAt(i);
- if (childView instanceof BaseRawContactEditorView) {
- final BaseRawContactEditorView editor =
- (BaseRawContactEditorView) childView;
- final PhotoEditorView photoEditor = editor.getPhotoEditor();
- photoEditor.setSuperPrimary(editor == mEditor);
- }
- }
- bindEditors();
- }
-
- /**
- * User has chosen to remove a picture
- */
- @Override
- public void onRemovePictureChosen() {
- mEditor.setPhotoEntry(null);
-
- // Prevent bitmap from being restored if rotate the device.
- // (only if we first chose a new photo before removing it)
- mUpdatedPhotos.remove(String.valueOf(mRawContactId));
- bindEditors();
- }
-
- @Override
- public void onPhotoSelected(Uri uri) throws FileNotFoundException {
- final Bitmap bitmap = ContactPhotoUtils.getBitmapFromUri(mContext, uri);
- setPhoto(mRawContactId, bitmap, uri);
- mCurrentPhotoHandler = null;
- bindEditors();
- }
-
- @Override
- public Uri getCurrentPhotoUri() {
- return mCurrentPhotoUri;
- }
-
- @Override
- public void onPhotoSelectionDismissed() {
- // Nothing to do.
- }
- }
- }
-}
diff --git a/src/com/android/contacts/editor/ContactEditorUtils.java b/src/com/android/contacts/editor/ContactEditorUtils.java
index b976456..24c6c26 100644
--- a/src/com/android/contacts/editor/ContactEditorUtils.java
+++ b/src/com/android/contacts/editor/ContactEditorUtils.java
@@ -19,9 +19,12 @@
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
+import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.net.Uri;
+import android.provider.ContactsContract;
import android.text.TextUtils;
import android.util.Log;
@@ -78,6 +81,30 @@
return sInstance;
}
+ /**
+ * Returns a legacy version of the given contactLookupUri if a legacy Uri was originally
+ * passed to the contact editor.
+ *
+ * @param contactLookupUri The Uri to possibly convert to legacy format.
+ * @param requestLookupUri The lookup Uri originally passed to the contact editor
+ * (via Intent data), may be null.
+ */
+ static Uri maybeConvertToLegacyLookupUri(Context context, Uri contactLookupUri,
+ Uri requestLookupUri) {
+ final String legacyAuthority = "contacts";
+ final String requestAuthority = requestLookupUri == null
+ ? null : requestLookupUri.getAuthority();
+ if (legacyAuthority.equals(requestAuthority)) {
+ // Build a legacy Uri if that is what was requested by caller
+ final long contactId = ContentUris.parseId(ContactsContract.Contacts.lookupContact(
+ context.getContentResolver(), contactLookupUri));
+ final Uri legacyContentUri = Uri.parse("content://contacts/people");
+ return ContentUris.withAppendedId(legacyContentUri, contactId);
+ }
+ // Otherwise pass back a lookup-style Uri
+ return contactLookupUri;
+ }
+
void cleanupForTest() {
mPrefs.edit().remove(mDefaultAccountKey).remove(KEY_KNOWN_ACCOUNTS)
.remove(mAnythingSavedKey).apply();
diff --git a/src/com/android/contacts/editor/EditorIntents.java b/src/com/android/contacts/editor/EditorIntents.java
index 14476c8..af6ef77 100644
--- a/src/com/android/contacts/editor/EditorIntents.java
+++ b/src/com/android/contacts/editor/EditorIntents.java
@@ -24,8 +24,6 @@
import android.text.TextUtils;
import com.android.contacts.activities.CompactContactEditorActivity;
-import com.android.contacts.activities.ContactEditorActivity;
-import com.android.contacts.activities.ContactEditorBaseActivity;
import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
@@ -70,7 +68,8 @@
/* Bundle updatedPhotos, */ boolean isNewLocalProfile) {
final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI,
context, CompactContactEditorActivity.class);
- intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
+ intent.putExtra(
+ CompactContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
if (rawContactDeltaList != null || displayName != null || phoneticName != null) {
putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
}
@@ -78,16 +77,16 @@
}
/**
- * Returns an Intent to edit a different contact (in the fully expaned editor) with whatever
+ * Returns an Intent to edit a different contact in the compact editor with whatever
* values were already entered on the currently displayed contact editor.
*/
public static Intent createEditOtherContactIntent(Context context, Uri contactLookupUri,
ArrayList<ContentValues> contentValues) {
final Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri, context,
- ContactEditorActivity.class);
+ CompactContactEditorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- intent.putExtra(ContactEditorFragment.INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY, "");
+ intent.putExtra(CompactContactEditorFragment.INTENT_EXTRA_ADD_TO_DEFAULT_DIRECTORY, "");
// Pass on all the data that has been entered so far
if (contentValues != null && contentValues.size() != 0) {
@@ -97,67 +96,34 @@
}
/**
- * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for an
- * existing contact.
- */
- public static Intent createEditContactIntent(Context context, Uri contactLookupUri,
- MaterialPalette materialPalette, long photoId) {
- final Intent intent = new Intent(ContactEditorBaseActivity.ACTION_EDIT, contactLookupUri,
- context, ContactEditorActivity.class);
- addContactIntentFlags(intent);
- putMaterialPalette(intent, materialPalette);
- putPhotoId(intent, photoId);
- return intent;
- }
-
- /**
- * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for a
- * new contact.
- */
- public static Intent createInsertContactIntent(Context context,
- RawContactDeltaList rawContactDeltaList, String displayName, String phoneticName,
- boolean isNewLocalProfile) {
- final Intent intent = new Intent(ContactEditorBaseActivity.ACTION_INSERT,
- Contacts.CONTENT_URI, context, ContactEditorActivity.class);
- intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
- addContactIntentFlags(intent);
- putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
- return intent;
- }
-
- /**
- * Returns an Intent to start the full editor for the given raw contact. The full editor will
- * only display this one raw contact.
+ * Returns an Intent to start the compact editor for the given raw contact.
*/
public static Intent createEditContactIntentForRawContact(Context context,
- Uri rawContactUri, long rawContactId, boolean isReadOnly) {
- final Intent intent = new Intent(ContactEditorBaseActivity.ACTION_EDIT, rawContactUri,
- context, ContactEditorActivity.class);
- intent.putExtra(ContactEditorFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE,
+ Uri contactLookupUri, long rawContactId, boolean isReadOnly) {
+ final Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri, context,
+ CompactContactEditorActivity.class);
+ intent.putExtra(CompactContactEditorFragment.INTENT_EXTRA_RAW_CONTACT_ID_TO_DISPLAY_ALONE,
rawContactId);
intent.putExtra(
- ContactEditorBaseFragment.INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY,
+ CompactContactEditorFragment.INTENT_EXTRA_RAW_CONTACT_DISPLAY_ALONE_IS_READ_ONLY,
isReadOnly);
return intent;
}
- private static void addContactIntentFlags(Intent intent) {
- intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- }
-
private static void putMaterialPalette(Intent intent, MaterialPalette materialPalette) {
if (materialPalette != null) {
- intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR,
+ intent.putExtra(
+ CompactContactEditorFragment.INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR,
materialPalette.mPrimaryColor);
- intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR,
+ intent.putExtra(
+ CompactContactEditorFragment.INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR,
materialPalette.mSecondaryColor);
}
}
private static void putPhotoId(Intent intent, long photoId) {
if (photoId >= 0) {
- intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_ID, photoId);
+ intent.putExtra(CompactContactEditorFragment.INTENT_EXTRA_PHOTO_ID, photoId);
}
}
diff --git a/src/com/android/contacts/editor/EditorUiUtils.java b/src/com/android/contacts/editor/EditorUiUtils.java
index 89d830b..83c59df 100644
--- a/src/com/android/contacts/editor/EditorUiUtils.java
+++ b/src/com/android/contacts/editor/EditorUiUtils.java
@@ -270,4 +270,5 @@
bitmap, size, size, /* filter =*/ false);
return ContactPhotoUtils.compressBitmap(bitmapScaled);
}
+
}
diff --git a/src/com/android/contacts/editor/JoinContactConfirmationDialogFragment.java b/src/com/android/contacts/editor/JoinContactConfirmationDialogFragment.java
index 55a066e..dab7085 100644
--- a/src/com/android/contacts/editor/JoinContactConfirmationDialogFragment.java
+++ b/src/com/android/contacts/editor/JoinContactConfirmationDialogFragment.java
@@ -48,7 +48,7 @@
/**
* @param joinContactId The raw contact ID of the contact to join to after confirmation.
*/
- public static void show(ContactEditorBaseFragment fragment, long joinContactId) {
+ public static void show(CompactContactEditorFragment fragment, long joinContactId) {
final Bundle args = new Bundle();
args.putLong(ARG_JOIN_CONTACT_ID, joinContactId);
diff --git a/src/com/android/contacts/editor/JoinSuggestedContactDialogFragment.java b/src/com/android/contacts/editor/JoinSuggestedContactDialogFragment.java
index 4d35332..a057a5b 100644
--- a/src/com/android/contacts/editor/JoinSuggestedContactDialogFragment.java
+++ b/src/com/android/contacts/editor/JoinSuggestedContactDialogFragment.java
@@ -28,7 +28,7 @@
private static final String ARG_RAW_CONTACT_IDS = "rawContactIds";
- public static void show(ContactEditorBaseFragment fragment, long[] rawContactIds) {
+ public static void show(CompactContactEditorFragment fragment, long[] rawContactIds) {
final Bundle args = new Bundle();
args.putLongArray(ARG_RAW_CONTACT_IDS, rawContactIds);
@@ -47,8 +47,8 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
- ContactEditorBaseFragment targetFragment =
- (ContactEditorBaseFragment) getTargetFragment();
+ CompactContactEditorFragment targetFragment =
+ (CompactContactEditorFragment) getTargetFragment();
long rawContactIds[] =
getArguments().getLongArray(ARG_RAW_CONTACT_IDS);
targetFragment.doJoinSuggestedContact(rawContactIds);
@@ -58,4 +58,4 @@
.setNegativeButton(android.R.string.no, null)
.create();
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index 947f35e..8b29b7e 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -303,13 +303,13 @@
mEntry.getAsString(mType.customColumn),
getContext().getString(mKind.titleRes)));
} else {
- if (mType != null) {
+ if (mType != null && mType.labelRes > 0 && mKind.titleRes > 0) {
mLabel.setSelection(mEditTypeAdapter.getPosition(mType));
mDeleteContainer.setContentDescription(
getContext().getString(R.string.editor_delete_view_description,
getContext().getString(mType.labelRes),
getContext().getString(mKind.titleRes)));
- } else {
+ } else if (mKind.titleRes > 0) {
mDeleteContainer.setContentDescription(
getContext().getString(R.string.editor_delete_view_description_short,
getContext().getString(mKind.titleRes)));
@@ -409,8 +409,9 @@
final boolean hasTypes = RawContactModifier.hasEditTypes(kind);
setupLabelButton(hasTypes);
mLabel.setEnabled(!readOnly && isEnabled());
- mLabel.setContentDescription(getContext().getResources().getString(mKind.titleRes));
-
+ if (mKind.titleRes > 0) {
+ mLabel.setContentDescription(getContext().getResources().getString(mKind.titleRes));
+ }
mType = RawContactModifier.getCurrentType(entry, kind);
rebuildLabel();
}
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
deleted file mode 100644
index 6d8c5ad..0000000
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.contacts.editor;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
-import android.provider.ContactsContract.CommonDataKinds.Nickname;
-import android.provider.ContactsContract.CommonDataKinds.Photo;
-import android.provider.ContactsContract.CommonDataKinds.StructuredName;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Data;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.contacts.common.model.account.AccountDisplayInfo;
-import com.android.contacts.common.model.account.AccountDisplayInfoFactory;
-import com.android.contacts.GroupMetaDataLoader;
-import com.android.contacts.R;
-import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountType.EditType;
-import com.android.contacts.common.model.dataitem.DataKind;
-import com.android.contacts.common.model.RawContactDelta;
-import com.android.contacts.common.model.ValuesDelta;
-import com.android.contacts.common.model.RawContactModifier;
-
-import com.google.common.base.Objects;
-
-import java.util.ArrayList;
-
-/**
- * Custom view that provides all the editor interaction for a specific
- * {@link Contacts} represented through an {@link RawContactDelta}. Callers can
- * reuse this view and quickly rebuild its contents through
- * {@link #setState(RawContactDelta, AccountType, ViewIdGenerator)}.
- * <p>
- * Internal updates are performed against {@link ValuesDelta} so that the
- * source {@link RawContact} can be swapped out. Any state-based changes, such as
- * adding {@link Data} rows or changing {@link EditType}, are performed through
- * {@link RawContactModifier} to ensure that {@link AccountType} are enforced.
- */
-public class RawContactEditorView extends BaseRawContactEditorView {
- private static final String KEY_SUPER_INSTANCE_STATE = "superInstanceState";
-
- private LayoutInflater mInflater;
-
- private StructuredNameEditorView mName;
- private PhoneticNameEditorView mPhoneticName;
- private TextFieldsEditorView mNickName;
-
- private GroupMembershipView mGroupMembershipView;
-
- private ViewGroup mFields;
-
- private TextView mAccountHeaderTypeTextView;
- private TextView mAccountHeaderNameTextView;
- private ImageView mAccountIconImageView;
-
- private long mRawContactId = -1;
- private boolean mAutoAddToDefaultGroup = true;
- private Cursor mGroupMetaData;
- private DataKind mGroupMembershipKind;
- private RawContactDelta mState;
-
- private AccountDisplayInfoFactory mAccountDisplayInfoFactory;
-
- public RawContactEditorView(Context context) {
- super(context);
- }
-
- public RawContactEditorView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
-
- View view = getPhotoEditor();
- if (view != null) {
- view.setEnabled(enabled);
- }
-
- if (mName != null) {
- mName.setEnabled(enabled);
- }
-
- if (mPhoneticName != null) {
- mPhoneticName.setEnabled(enabled);
- }
-
- if (mFields != null) {
- int count = mFields.getChildCount();
- for (int i = 0; i < count; i++) {
- mFields.getChildAt(i).setEnabled(enabled);
- }
- }
-
- if (mGroupMembershipView != null) {
- mGroupMembershipView.setEnabled(enabled);
- }
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mInflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- mName = (StructuredNameEditorView)findViewById(R.id.edit_name);
- mName.setDeletable(false);
-
- mPhoneticName = (PhoneticNameEditorView)findViewById(R.id.edit_phonetic_name);
- mPhoneticName.setDeletable(false);
-
- mNickName = (TextFieldsEditorView)findViewById(R.id.edit_nick_name);
-
- mFields = (ViewGroup)findViewById(R.id.sect_fields);
-
- mAccountHeaderTypeTextView = (TextView) findViewById(R.id.account_type);
- mAccountHeaderNameTextView = (TextView) findViewById(R.id.account_name);
- mAccountIconImageView = (ImageView) findViewById(R.id.account_type_icon);
-
- mAccountDisplayInfoFactory = AccountDisplayInfoFactory.forAllAccounts(getContext());
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- Bundle bundle = new Bundle();
- // super implementation of onSaveInstanceState returns null
- bundle.putParcelable(KEY_SUPER_INSTANCE_STATE, super.onSaveInstanceState());
- return bundle;
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- if (state instanceof Bundle) {
- Bundle bundle = (Bundle) state;
- super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_INSTANCE_STATE));
- return;
- }
- super.onRestoreInstanceState(state);
- }
-
- /**
- * Set the internal state for this view, given a current
- * {@link RawContactDelta} state and the {@link AccountType} that
- * apply to that state.
- */
- @Override
- public void setState(RawContactDelta state, AccountType type, ViewIdGenerator vig,
- boolean isProfile) {
-
- mState = state;
-
- // Remove any existing sections
- mFields.removeAllViews();
-
- // Bail if invalid state or account type
- if (state == null || type == null) return;
-
- setId(vig.getId(state, null, null, ViewIdGenerator.NO_VIEW_INDEX));
-
- // Make sure we have a StructuredName
- RawContactModifier.ensureKindExists(state, type, StructuredName.CONTENT_ITEM_TYPE);
-
- mRawContactId = state.getRawContactId();
-
- final AccountDisplayInfo account = mAccountDisplayInfoFactory
- .getAccountDisplayInfoFor(state);
-
- final String accountTypeLabel;
- final String accountNameLabel;
- if (isProfile) {
- accountTypeLabel = EditorUiUtils.getAccountHeaderLabelForMyProfile(
- getContext(), account);
- accountNameLabel = account.getNameLabel().toString();
- } else {
- accountTypeLabel = account.getTypeLabel().toString();
- accountNameLabel = account.getNameLabel().toString();
- }
-
- if (!account.hasDistinctName()) {
- // Hide this view so the other view will be centered vertically
- mAccountHeaderNameTextView.setVisibility(View.GONE);
- } else {
- mAccountHeaderNameTextView.setVisibility(View.VISIBLE);
- mAccountHeaderNameTextView.setText(accountNameLabel);
- }
- mAccountHeaderTypeTextView.setText(accountTypeLabel);
- updateAccountHeaderContentDescription();
-
- mAccountIconImageView.setImageDrawable(state.getRawContactAccountType(getContext())
- .getDisplayIcon(getContext()));
-
- // Show photo editor when supported
- RawContactModifier.ensureKindExists(state, type, Photo.CONTENT_ITEM_TYPE);
- setHasPhotoEditor((type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null));
- getPhotoEditor().setEnabled(isEnabled());
- mName.setEnabled(isEnabled());
-
- mPhoneticName.setEnabled(isEnabled());
-
- // Show and hide the appropriate views
- mFields.setVisibility(View.VISIBLE);
- mName.setVisibility(View.VISIBLE);
- mPhoneticName.setVisibility(View.VISIBLE);
-
- mGroupMembershipKind = type.getKindForMimetype(GroupMembership.CONTENT_ITEM_TYPE);
- if (mGroupMembershipKind != null) {
- mGroupMembershipView = (GroupMembershipView)mInflater.inflate(
- R.layout.item_group_membership, mFields, false);
- mGroupMembershipView.setKind(mGroupMembershipKind);
- mGroupMembershipView.setEnabled(isEnabled());
- }
-
- // Create editor sections for each possible data kind
- for (DataKind kind : type.getSortedDataKinds()) {
- // Skip kind of not editable
- if (!kind.editable) continue;
-
- final String mimeType = kind.mimeType;
- if (StructuredName.CONTENT_ITEM_TYPE.equals(mimeType)) {
- // Handle special case editor for structured name
- final ValuesDelta primary = state.getPrimaryEntry(mimeType);
- mName.setValues(
- type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME),
- primary, state, false, vig);
- mPhoneticName.setValues(
- type.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME),
- primary, state, false, vig);
- // It is useful to use Nickname outside of a KindSectionView so that we can treat it
- // as a part of StructuredName's fake KindSectionView, even though it uses a
- // different CP2 mime-type. We do a bit of extra work below to make this possible.
- final DataKind nickNameKind = type.getKindForMimetype(Nickname.CONTENT_ITEM_TYPE);
- if (nickNameKind != null) {
- ValuesDelta primaryNickNameEntry = state.getPrimaryEntry(nickNameKind.mimeType);
- if (primaryNickNameEntry == null) {
- primaryNickNameEntry = RawContactModifier.insertChild(state, nickNameKind);
- }
- mNickName.setValues(nickNameKind, primaryNickNameEntry, state, false, vig);
- mNickName.setDeletable(false);
- } else {
- mPhoneticName.setPadding(0, 0, 0, (int) getResources().getDimension(
- R.dimen.editor_padding_between_editor_views));
- mNickName.setVisibility(View.GONE);
- }
- } else if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) {
- // Handle special case editor for photos
- final ValuesDelta primary = state.getPrimaryEntry(mimeType);
- getPhotoEditor().setValues(kind, primary, state, false, vig);
- } else if (GroupMembership.CONTENT_ITEM_TYPE.equals(mimeType)) {
- if (mGroupMembershipView != null) {
- mGroupMembershipView.setState(state);
- mFields.addView(mGroupMembershipView);
- }
- } else if (DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME.equals(mimeType)
- || DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME.equals(mimeType)
- || Nickname.CONTENT_ITEM_TYPE.equals(mimeType)) {
- // Don't create fields for each of these mime-types. They are handled specially.
- continue;
- } else {
- // Otherwise use generic section-based editors
- if (kind.fieldList == null) continue;
- final KindSectionView section = (KindSectionView)mInflater.inflate(
- R.layout.item_kind_section, mFields, false);
- section.setEnabled(isEnabled());
- section.setState(kind, state, /* readOnly =*/ false, vig);
- mFields.addView(section);
- }
- }
-
- addToDefaultGroupIfNeeded();
- }
-
- @Override
- public void setGroupMetaData(Cursor groupMetaData) {
- mGroupMetaData = groupMetaData;
- addToDefaultGroupIfNeeded();
- if (mGroupMembershipView != null) {
- mGroupMembershipView.setGroupMetaData(groupMetaData);
- }
- }
-
- public void setAutoAddToDefaultGroup(boolean flag) {
- this.mAutoAddToDefaultGroup = flag;
- }
-
- /**
- * If automatic addition to the default group was requested (see
- * {@link #setAutoAddToDefaultGroup}, checks if the raw contact is in any
- * group and if it is not adds it to the default group (in case of Google
- * contacts that's "My Contacts").
- */
- private void addToDefaultGroupIfNeeded() {
- if (!mAutoAddToDefaultGroup || mGroupMetaData == null || mGroupMetaData.isClosed()
- || mState == null) {
- return;
- }
-
- boolean hasGroupMembership = false;
- ArrayList<ValuesDelta> entries = mState.getMimeEntries(GroupMembership.CONTENT_ITEM_TYPE);
- if (entries != null) {
- for (ValuesDelta values : entries) {
- Long id = values.getGroupRowId();
- if (id != null && id.longValue() != 0) {
- hasGroupMembership = true;
- break;
- }
- }
- }
-
- if (!hasGroupMembership) {
- long defaultGroupId = getDefaultGroupId();
- if (defaultGroupId != -1) {
- ValuesDelta entry = RawContactModifier.insertChild(mState, mGroupMembershipKind);
- if (entry != null) {
- entry.setGroupRowId(defaultGroupId);
- }
- }
- }
- }
-
- /**
- * Returns the default group (e.g. "My Contacts") for the current raw contact's
- * account. Returns -1 if there is no such group.
- */
- private long getDefaultGroupId() {
- String accountType = mState.getAccountType();
- String accountName = mState.getAccountName();
- String accountDataSet = mState.getDataSet();
- mGroupMetaData.moveToPosition(-1);
- while (mGroupMetaData.moveToNext()) {
- String name = mGroupMetaData.getString(GroupMetaDataLoader.ACCOUNT_NAME);
- String type = mGroupMetaData.getString(GroupMetaDataLoader.ACCOUNT_TYPE);
- String dataSet = mGroupMetaData.getString(GroupMetaDataLoader.DATA_SET);
- if (name.equals(accountName) && type.equals(accountType)
- && Objects.equal(dataSet, accountDataSet)) {
- long groupId = mGroupMetaData.getLong(GroupMetaDataLoader.GROUP_ID);
- if (!mGroupMetaData.isNull(GroupMetaDataLoader.AUTO_ADD)
- && mGroupMetaData.getInt(GroupMetaDataLoader.AUTO_ADD) != 0) {
- return groupId;
- }
- }
- }
- return -1;
- }
-
- public StructuredNameEditorView getNameEditor() {
- return mName;
- }
-
- public TextFieldsEditorView getPhoneticNameEditor() {
- return mPhoneticName;
- }
-
- public TextFieldsEditorView getNickNameEditor() {
- return mNickName;
- }
-
- @Override
- public long getRawContactId() {
- return mRawContactId;
- }
-}
diff --git a/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java b/src/com/android/contacts/editor/SelectAccountDialogFragment.java
similarity index 97%
rename from src/com/android/contacts/common/editor/SelectAccountDialogFragment.java
rename to src/com/android/contacts/editor/SelectAccountDialogFragment.java
index 96da89a..34fac4f 100644
--- a/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java
+++ b/src/com/android/contacts/editor/SelectAccountDialogFragment.java
@@ -14,7 +14,7 @@
* limitations under the License
*/
-package com.android.contacts.common.editor;
+package com.android.contacts.editor;
import android.app.Activity;
import android.app.AlertDialog;
@@ -44,9 +44,6 @@
private static final String KEY_LIST_FILTER = "list_filter";
private static final String KEY_EXTRA_ARGS = "extra_args";
- public SelectAccountDialogFragment() { // All fragments must have a public default constructor.
- }
-
/**
* Show the dialog.
*
diff --git a/src/com/android/contacts/editor/SplitContactConfirmationDialogFragment.java b/src/com/android/contacts/editor/SplitContactConfirmationDialogFragment.java
index f3d0ef4..41d45a1 100644
--- a/src/com/android/contacts/editor/SplitContactConfirmationDialogFragment.java
+++ b/src/com/android/contacts/editor/SplitContactConfirmationDialogFragment.java
@@ -49,7 +49,7 @@
void onSplitContactConfirmed(boolean hasPendingChanges);
}
- public static void show(ContactEditorBaseFragment fragment, boolean hasPendingChanges) {
+ public static void show(CompactContactEditorFragment fragment, boolean hasPendingChanges) {
final Bundle args = new Bundle();
args.putBoolean(ARG_HAS_PENDING_CHANGES, hasPendingChanges);
diff --git a/src/com/android/contacts/editor/SuggestionEditConfirmationDialogFragment.java b/src/com/android/contacts/editor/SuggestionEditConfirmationDialogFragment.java
index c13d5ea..31437b4 100644
--- a/src/com/android/contacts/editor/SuggestionEditConfirmationDialogFragment.java
+++ b/src/com/android/contacts/editor/SuggestionEditConfirmationDialogFragment.java
@@ -29,7 +29,7 @@
private static final String ARG_CONTACT_URI = "contactUri";
- public static void show(ContactEditorBaseFragment fragment, Uri contactUri) {
+ public static void show(CompactContactEditorFragment fragment, Uri contactUri) {
final Bundle args = new Bundle();
args.putParcelable(ARG_CONTACT_URI, contactUri);
@@ -49,8 +49,8 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
- final ContactEditorBaseFragment targetFragment =
- (ContactEditorBaseFragment) getTargetFragment();
+ final CompactContactEditorFragment targetFragment =
+ (CompactContactEditorFragment) getTargetFragment();
final Uri contactUri =
getArguments().getParcelable(ARG_CONTACT_URI);
targetFragment.doEditSuggestedContact(contactUri);
diff --git a/src/com/android/contacts/group/GroupMembersFragment.java b/src/com/android/contacts/group/GroupMembersFragment.java
index 48dccfe..26560d6 100644
--- a/src/com/android/contacts/group/GroupMembersFragment.java
+++ b/src/com/android/contacts/group/GroupMembersFragment.java
@@ -18,33 +18,49 @@
import android.app.Activity;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.CursorLoader;
+import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
+import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.Toast;
+import com.android.contacts.ContactSaveService;
+import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.GroupMetaDataLoader;
import com.android.contacts.R;
-import com.android.contacts.activities.GroupMembersActivity;
+import com.android.contacts.activities.ActionBarAdapter;
import com.android.contacts.common.list.ContactsSectionIndexer;
-import com.android.contacts.common.list.MultiSelectEntryContactListAdapter;
+import com.android.contacts.common.list.MultiSelectEntryContactListAdapter.DeleteContactListener;
+import com.android.contacts.common.logging.ListEvent;
import com.android.contacts.common.logging.ListEvent.ListType;
+import com.android.contacts.common.logging.Logger;
+import com.android.contacts.common.logging.ScreenEvent;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.group.GroupMembersAdapter.GroupMembersQuery;
+import com.android.contacts.interactions.GroupDeletionDialogFragment;
+import com.android.contacts.list.ContactsRequest;
import com.android.contacts.list.MultiSelectContactsListFragment;
+import com.android.contacts.list.UiIntentActions;
+import com.android.contacts.quickcontact.QuickContactActivity;
import java.util.ArrayList;
import java.util.HashSet;
@@ -52,33 +68,20 @@
import java.util.Set;
/** Displays the members of a group. */
-public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupMembersAdapter>
- implements MultiSelectEntryContactListAdapter.DeleteContactListener {
+public class GroupMembersFragment extends MultiSelectContactsListFragment<GroupMembersAdapter> {
private static final String TAG = "GroupMembers";
+ private static final String KEY_IS_EDIT_MODE = "editMode";
private static final String KEY_GROUP_URI = "groupUri";
private static final String KEY_GROUP_METADATA = "groupMetadata";
+ public static final String TAG_GROUP_NAME_EDIT_DIALOG = "groupNameEditDialog";
+
private static final String ARG_GROUP_URI = "groupUri";
private static final int LOADER_GROUP_METADATA = 0;
-
- /** Callbacks for hosts of {@link GroupMembersFragment}. */
- public interface GroupMembersListener {
-
- /** Invoked after group metadata for the passed in group URI has loaded. */
- void onGroupMetadataLoaded(GroupMetadata groupMetadata);
-
- /** Invoked if group metadata can't be loaded for the passed in group URI. */
- void onGroupMetadataLoadFailed();
-
- /** Invoked when a group member in the list is clicked. */
- void onGroupMemberListItemClicked(int position, Uri contactLookupUri);
-
- /** Invoked when a the delete button for a group member in the list is clicked. */
- void onGroupMemberListItemDeleted(int position, long contactId);
- }
+ private static final int RESULT_GROUP_ADD_MEMBER = 100;
/** Filters out duplicate contacts. */
private class FilterCursorWrapper extends CursorWrapper {
@@ -184,16 +187,17 @@
@Override
public CursorLoader onCreateLoader(int id, Bundle args) {
- return new GroupMetaDataLoader(getActivity(), mGroupUri);
+ return new GroupMetaDataLoader(mActivity, mGroupUri);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
if (cursor == null || cursor.isClosed() || !cursor.moveToNext()) {
Log.e(TAG, "Failed to load group metadata for " + mGroupUri);
- if (mListener != null) {
- mListener.onGroupMetadataLoadFailed();
- }
+ Toast.makeText(getContext(), R.string.groupLoadErrorToast, Toast.LENGTH_SHORT)
+ .show();
+ mActivity.setResult(AppCompatActivity.RESULT_CANCELED);
+ mActivity.finish();
return;
}
mGroupMetadata = new GroupMetadata();
@@ -206,7 +210,7 @@
mGroupMetadata.readOnly = cursor.getInt(GroupMetaDataLoader.IS_READ_ONLY) == 1;
final AccountTypeManager accountTypeManager =
- AccountTypeManager.getInstance(getActivity());
+ AccountTypeManager.getInstance(mActivity);
final AccountType accountType = accountTypeManager.getAccountType(
mGroupMetadata.accountType, mGroupMetadata.dataSet);
mGroupMetadata.editable = accountType.isGroupMembershipEditable();
@@ -218,9 +222,13 @@
public void onLoaderReset(Loader<Cursor> loader) {}
};
+ private ActionBarAdapter mActionBarAdapter;
+
+ private ContactsDrawerActivity mActivity;
+
private Uri mGroupUri;
- private GroupMembersListener mListener;
+ private boolean mIsEditMode;
private GroupMetadata mGroupMetadata;
@@ -239,12 +247,218 @@
setPhotoLoaderEnabled(true);
setSectionHeaderDisplayEnabled(true);
setHasOptionsMenu(true);
-
setListType(ListType.GROUP);
}
- public void setListener(GroupMembersListener listener) {
- mListener = listener;
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (mGroupMetadata == null) {
+ // Hide menu options until metadata is fully loaded
+ return;
+ }
+ inflater.inflate(R.menu.view_group, menu);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ final boolean isSelectionMode = mActionBarAdapter.isSelectionMode();
+ final boolean isGroupEditable = mGroupMetadata != null && mGroupMetadata.editable;
+ final boolean isGroupReadOnly = mGroupMetadata != null && mGroupMetadata.readOnly;
+
+ setVisible(menu, R.id.menu_add, isGroupEditable && !isSelectionMode);
+ setVisible(menu, R.id.menu_rename_group, !isGroupReadOnly && !isSelectionMode);
+ setVisible(menu, R.id.menu_delete_group, !isGroupReadOnly && !isSelectionMode);
+ setVisible(menu, R.id.menu_edit_group, isGroupEditable && !mIsEditMode && !isSelectionMode
+ && !isGroupEmpty());
+ setVisible(menu, R.id.menu_remove_from_group, isGroupEditable && isSelectionMode &&
+ !mIsEditMode);
+ }
+
+ private boolean isGroupEmpty() {
+ return getAdapter() != null && getAdapter().isEmpty();
+ }
+
+ private static void setVisible(Menu menu, int id, boolean visible) {
+ final MenuItem menuItem = menu.findItem(id);
+ if (menuItem != null) {
+ menuItem.setVisible(visible);
+ }
+ }
+
+ private void startGroupAddMemberActivity() {
+ startActivityForResult(GroupUtil.createPickMemberIntent(getContext(), mGroupMetadata,
+ getMemberContactIds()), RESULT_GROUP_ADD_MEMBER);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home: {
+ mActivity.onBackPressed();
+ return true;
+ }
+ case R.id.menu_add: {
+ startGroupAddMemberActivity();
+ return true;
+ }
+ case R.id.menu_rename_group: {
+ GroupNameEditDialogFragment.newInstanceForUpdate(
+ new AccountWithDataSet(mGroupMetadata.accountName,
+ mGroupMetadata.accountType, mGroupMetadata.dataSet),
+ GroupUtil.ACTION_UPDATE_GROUP, mGroupMetadata.groupId,
+ mGroupMetadata.groupName).show(getFragmentManager(),
+ TAG_GROUP_NAME_EDIT_DIALOG);
+ return true;
+ }
+ case R.id.menu_delete_group: {
+ deleteGroup();
+ return true;
+ }
+ case R.id.menu_edit_group: {
+ mIsEditMode = true;
+ mActionBarAdapter.setSelectionMode(true);
+ displayDeleteButtons(true);
+ return true;
+ }
+ case R.id.menu_remove_from_group: {
+ logListEvent();
+ removeSelectedContacts();
+ return true;
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void removeSelectedContacts() {
+ final long[] contactIds = getAdapter().getSelectedContactIdsArray();
+ new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE,
+ getContext(), contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
+ mGroupMetadata.accountType).execute();
+
+ mActionBarAdapter.setSelectionMode(false);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == RESULT_GROUP_ADD_MEMBER && resultCode ==
+ Activity.RESULT_OK && data != null) {
+ long[] contactIds = data.getLongArrayExtra(
+ UiIntentActions.TARGET_CONTACT_IDS_EXTRA_KEY);
+ if (contactIds == null) {
+ final long contactId = data.getLongExtra(
+ UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, -1);
+ if (contactId > -1) {
+ contactIds = new long[1];
+ contactIds[0] = contactId;
+ }
+ }
+ new UpdateGroupMembersAsyncTask(
+ UpdateGroupMembersAsyncTask.TYPE_ADD,
+ getContext(), contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
+ mGroupMetadata.accountType).execute();
+ }
+ }
+
+ private final ActionBarAdapter.Listener mActionBarListener = new ActionBarAdapter.Listener() {
+ @Override
+ public void onAction(int action) {
+ switch (action) {
+ case ActionBarAdapter.Listener.Action.START_SELECTION_MODE:
+ if (mIsEditMode) {
+ displayDeleteButtons(true);
+ mActionBarAdapter.setActionBarTitle(getString(R.string.title_edit_group));
+ } else {
+ displayCheckBoxes(true);
+ }
+ mActivity.invalidateOptionsMenu();
+ break;
+ case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE:
+ mActionBarAdapter.setSearchMode(false);
+ if (mIsEditMode) {
+ displayDeleteButtons(false);
+ } else {
+ displayCheckBoxes(false);
+ }
+ mActivity.invalidateOptionsMenu();
+ break;
+ case ActionBarAdapter.Listener.Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE:
+ break;
+ }
+ }
+
+ @Override
+ public void onUpButtonPressed() {
+ mActivity.onBackPressed();
+ }
+ };
+
+ private final OnCheckBoxListActionListener mCheckBoxListener =
+ new OnCheckBoxListActionListener() {
+ @Override
+ public void onStartDisplayingCheckBoxes() {
+ mActionBarAdapter.setSelectionMode(true);
+ }
+
+ @Override
+ public void onSelectedContactIdsChanged() {
+ if (mActionBarAdapter == null) {
+ return;
+ }
+ if (mIsEditMode) {
+ mActionBarAdapter.setActionBarTitle(getString(R.string.title_edit_group));
+ } else {
+ mActionBarAdapter.setSelectionCount(getSelectedContactIds().size());
+ }
+ }
+
+ @Override
+ public void onStopDisplayingCheckBoxes() {
+ mActionBarAdapter.setSelectionMode(false);
+ }
+ };
+
+ private void logListEvent() {
+ Logger.logListEvent(
+ ListEvent.ActionType.REMOVE_LABEL,
+ getListType(),
+ getAdapter().getCount(),
+ /* clickedIndex */ -1,
+ getAdapter().getSelectedContactIdsArray().length);
+ }
+
+ private void deleteGroup() {
+ if (getMemberCount() == 0) {
+ final Intent intent = ContactSaveService.createGroupDeletionIntent(
+ getContext(), mGroupMetadata.groupId);
+ getContext().startService(intent);
+ mActivity.switchToAllContacts();
+ } else {
+ GroupDeletionDialogFragment.show(getFragmentManager(), mGroupMetadata.groupId,
+ mGroupMetadata.groupName);
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ mActivity = (ContactsDrawerActivity) getActivity();
+ mActionBarAdapter = new ActionBarAdapter(mActivity, mActionBarListener,
+ mActivity.getSupportActionBar(), mActivity.getToolbar(), R.string.enter_contact_name);
+ mActionBarAdapter.setShowHomeIcon(true);
+ final ContactsRequest contactsRequest = new ContactsRequest();
+ contactsRequest.setActionCode(ContactsRequest.ACTION_GROUP);
+ mActionBarAdapter.initialize(savedInstanceState, contactsRequest);
+ if (mGroupMetadata != null) {
+ mActivity.setTitle(mGroupMetadata.groupName);
+ if (mGroupMetadata.editable) {
+ setCheckBoxListListener(mCheckBoxListener);
+ }
+ }
+ }
+
+ @Override
+ public ActionBarAdapter getActionBarAdapter() {
+ return mActionBarAdapter;
}
public void displayDeleteButtons(boolean displayDeleteButtons) {
@@ -259,15 +473,29 @@
return mGroupMemberContactIds.size();
}
+ public boolean isEditMode() {
+ return mIsEditMode;
+ }
+
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
if (savedState == null) {
mGroupUri = getArguments().getParcelable(ARG_GROUP_URI);
} else {
+ mIsEditMode = savedState.getBoolean(KEY_IS_EDIT_MODE);
mGroupUri = savedState.getParcelable(KEY_GROUP_URI);
mGroupMetadata = savedState.getParcelable(KEY_GROUP_METADATA);
}
+ maybeAttachCheckBoxListener();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // Re-register the listener, which may have been cleared when onSaveInstanceState was
+ // called. See also: onSaveInstanceState
+ mActionBarAdapter.setListener(mActionBarListener);
}
@Override
@@ -289,7 +517,7 @@
bindMembersCount(cursorWrapper.getCount());
super.onLoadFinished(loader, cursorWrapper);
// Update state of menu items (e.g. "Remove contacts") based on number of group members.
- getActivity().invalidateOptionsMenu();
+ mActivity.invalidateOptionsMenu();
}
}
@@ -312,6 +540,11 @@
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
+ if (mActionBarAdapter != null) {
+ mActionBarAdapter.setListener(null);
+ mActionBarAdapter.onSaveInstanceState(outState);
+ }
+ outState.putBoolean(KEY_IS_EDIT_MODE, mIsEditMode);
outState.putParcelable(KEY_GROUP_URI, mGroupUri);
outState.putParcelable(KEY_GROUP_METADATA, mGroupMetadata);
}
@@ -321,9 +554,9 @@
maybeAttachCheckBoxListener();
- if (mListener != null) {
- mListener.onGroupMetadataLoaded(mGroupMetadata);
- }
+ mActivity.setTitle(mGroupMetadata.groupName);
+ mActivity.updateGroupMenu(mGroupMetadata);
+ mActivity.invalidateOptionsMenu();
// Start loading the group members
super.startLoading();
@@ -332,12 +565,7 @@
private void maybeAttachCheckBoxListener() {
// Don't attach the multi select check box listener if we can't edit the group
if (mGroupMetadata != null && mGroupMetadata.editable) {
- try {
- setCheckBoxListListener((OnCheckBoxListActionListener) getActivity());
- } catch (ClassCastException e) {
- throw new ClassCastException(getActivity() + " must implement " +
- OnCheckBoxListActionListener.class.getSimpleName());
- }
+ setCheckBoxListListener(mCheckBoxListener);
}
}
@@ -346,7 +574,7 @@
final GroupMembersAdapter adapter = new GroupMembersAdapter(getContext());
adapter.setSectionHeaderDisplayEnabled(true);
adapter.setDisplayPhotos(true);
- adapter.setDeleteContactListener(this);
+ adapter.setDeleteContactListener(new DeletionListener());
return adapter;
}
@@ -380,7 +608,8 @@
addContactsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ((GroupMembersActivity) getActivity()).startGroupAddMemberActivity();
+ startActivityForResult(GroupUtil.createPickMemberIntent(getContext(),
+ mGroupMetadata, getMemberContactIds()), RESULT_GROUP_ADD_MEMBER);
}
});
return view;
@@ -396,25 +625,96 @@
super.onItemClick(position, id);
return;
}
- if (mListener != null) {
- mListener.onGroupMemberListItemClicked(position, uri);
- }
+ final int count = getAdapter().getCount();
+ Logger.logListEvent(ListEvent.ActionType.CLICK, ListEvent.ListType.GROUP, count,
+ /* clickedIndex */ position, /* numSelected */ 0);
+ final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(
+ getContext(), uri, QuickContactActivity.MODE_FULLY_EXPANDED);
+ intent.putExtra(
+ QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenEvent.ScreenType.LIST_GROUP);
+ startActivity(intent);
}
@Override
protected boolean onItemLongClick(int position, long id) {
- final Activity activity = getActivity();
- if (activity != null && activity instanceof GroupMembersActivity) {
- if (((GroupMembersActivity) activity).isEditMode()) {
- return true;
- }
+ if (mActivity != null && mIsEditMode) {
+ return true;
}
return super.onItemLongClick(position, id);
}
+ private final class DeletionListener implements DeleteContactListener {
+ @Override
+ public void onContactDeleteClicked(int position) {
+ final long contactId = getAdapter().getContactId(position);
+ final long[] contactIds = new long[1];
+ contactIds[0] = contactId;
+ new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_REMOVE,
+ getContext(), contactIds, mGroupMetadata.groupId, mGroupMetadata.accountName,
+ mGroupMetadata.accountType).execute();
+ }
+ }
+
+ public GroupMetadata getGroupMetadata() {
+ return mGroupMetadata;
+ }
+
+ public boolean isCurrentGroup(long groupId) {
+ return mGroupMetadata != null && mGroupMetadata.groupId == groupId;
+ }
+
@Override
- public void onContactDeleteClicked(int position) {
- final long contactId = getAdapter().getContactId(position);
- mListener.onGroupMemberListItemDeleted(position, contactId);
+ public void onDestroy() {
+ if (mActionBarAdapter != null) {
+ mActionBarAdapter.setListener(null);
+ }
+ super.onDestroy();
+ }
+
+ public void updateDisplayedGroup(Uri newGroupUri, String action) {
+ if (!GroupUtil.ACTION_SWITCH_GROUP.equals(action)) {
+ toast(getToastMessageForSaveAction(action));
+ }
+
+ if (isEditMode() && getGroupCount() == 1) {
+ // If we're deleting the last group member, exit edit mode
+ exitEditMode();
+ } else if (!GroupUtil.ACTION_REMOVE_FROM_GROUP.equals(action)) {
+ mGroupUri = newGroupUri;
+ mGroupMetadata = null; // Clear mGroupMetadata to trigger a new load.
+ reloadData();
+ mActivity.invalidateOptionsMenu();
+ }
+ }
+
+ private static int getToastMessageForSaveAction(String action) {
+ switch(action) {
+ case GroupUtil.ACTION_UPDATE_GROUP:
+ return R.string.groupUpdatedToast;
+ case GroupUtil.ACTION_ADD_TO_GROUP:
+ return R.string.groupMembersAddedToast;
+ case GroupUtil.ACTION_REMOVE_FROM_GROUP:
+ return R.string.groupMembersRemovedToast;
+ case GroupUtil.ACTION_CREATE_GROUP:
+ return R.string.groupCreatedToast;
+ default:
+ throw new IllegalArgumentException("Unhandled contact save action " + action);
+ }
+ }
+
+ private void toast(int resId) {
+ if (resId >= 0) {
+ Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ private int getGroupCount() {
+ return getAdapter() != null ? getAdapter().getCount() : -1;
+ }
+
+ public void exitEditMode() {
+ mIsEditMode = false;
+ mActionBarAdapter.setSelectionMode(false);
+ displayDeleteButtons(false);
}
}
diff --git a/src/com/android/contacts/group/GroupUtil.java b/src/com/android/contacts/group/GroupUtil.java
index d1780e1..e01cc30 100644
--- a/src/com/android/contacts/group/GroupUtil.java
+++ b/src/com/android/contacts/group/GroupUtil.java
@@ -16,7 +16,6 @@
package com.android.contacts.group;
-import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
@@ -28,7 +27,6 @@
import com.android.contacts.GroupListLoader;
import com.android.contacts.activities.ContactSelectionActivity;
-import com.android.contacts.activities.GroupMembersActivity;
import com.android.contacts.common.list.ContactsSectionIndexer;
import com.android.contacts.common.model.account.GoogleAccountType;
import com.android.contacts.list.UiIntentActions;
@@ -44,12 +42,17 @@
*/
public final class GroupUtil {
+ public static final String ACTION_ADD_TO_GROUP = "addToGroup";
+ public static final String ACTION_CREATE_GROUP = "createGroup";
+ public static final String ACTION_DELETE_GROUP = "deleteGroup";
+ public static final String ACTION_REMOVE_FROM_GROUP = "removeFromGroup";
+ public static final String ACTION_SWITCH_GROUP = "switchGroup";
+ public static final String ACTION_UPDATE_GROUP = "updateGroup";
+
// System IDs of FFC groups in Google accounts
private static final Set<String> FFC_GROUPS =
new HashSet(Arrays.asList("Friends", "Family", "Coworkers"));
- public static final String EXTRA_GROUP_NAME = "groupName";
-
private GroupUtil() {
}
@@ -88,21 +91,6 @@
isFirstGroupInAccount, memberCount, isReadOnly, systemId);
}
- /** Returns an Intent to view the details of the group identified by the given URI. */
- public static Intent createViewGroupIntent(Context context, Uri groupUri, String title) {
- final Intent intent = new Intent(context, GroupMembersActivity.class);
- intent.setAction(Intent.ACTION_VIEW);
- intent.setData(groupUri);
- intent.putExtra(EXTRA_GROUP_NAME, title);
- return intent;
- }
-
- /** Returns an Intent to view the details of the group identified by the given ID. */
- public static Intent createViewGroupIntent(Context context, long groupId, String title) {
- return createViewGroupIntent(context,
- ContentUris.withAppendedId(Groups.CONTENT_URI, groupId), title);
- }
-
/** Returns an Intent to pick contacts to add to a group. */
public static Intent createPickMemberIntent(Context context,
GroupMetadata groupMetadata, ArrayList<String> memberContactIds) {
@@ -131,6 +119,13 @@
}
/**
+ * Returns true the URI is a group URI.
+ */
+ public static boolean isGroupUri(Uri uri) {
+ return uri != null && uri.toString().startsWith(Groups.CONTENT_URI.toString());
+ }
+
+ /**
* Sort groups alphabetically and in a localized way.
*/
public static String getGroupsSortOrder() {
diff --git a/src/com/android/contacts/group/UpdateGroupMembersAsyncTask.java b/src/com/android/contacts/group/UpdateGroupMembersAsyncTask.java
new file mode 100644
index 0000000..46aa674
--- /dev/null
+++ b/src/com/android/contacts/group/UpdateGroupMembersAsyncTask.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.contacts.group;
+
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.provider.ContactsContract;
+import android.widget.Toast;
+
+import com.android.contacts.ContactSaveService;
+import com.android.contacts.R;
+import com.android.contacts.activities.PeopleActivity;
+
+/**
+ * Starts an Intent to add/remove the raw contacts for the given contact IDs to/from a group.
+ * Only the raw contacts that belong to the specified account are added or removed.
+ */
+public class UpdateGroupMembersAsyncTask extends AsyncTask<Void, Void, Intent> {
+ static final int TYPE_ADD = 0;
+ static final int TYPE_REMOVE = 1;
+
+ private final Context mContext;
+ private final int mType;
+ private final long[] mContactIds;
+ private final long mGroupId;
+ private final String mAccountName;
+ private final String mAccountType;
+
+ public UpdateGroupMembersAsyncTask(int type, Context context, long[] contactIds,
+ long groupId, String accountName, String accountType) {
+ mContext = context;
+ mType = type;
+ mContactIds = contactIds;
+ mGroupId = groupId;
+ mAccountName = accountName;
+ mAccountType = accountType;
+ }
+
+ @Override
+ protected Intent doInBackground(Void... params) {
+ final long[] rawContactIds = getRawContactIds();
+ if (rawContactIds.length == 0) {
+ return null;
+ }
+ final long[] rawContactIdsToAdd;
+ final long[] rawContactIdsToRemove;
+ final String action;
+ if (mType == TYPE_ADD) {
+ rawContactIdsToAdd = rawContactIds;
+ rawContactIdsToRemove = null;
+ action = GroupUtil.ACTION_ADD_TO_GROUP;
+ } else if (mType == TYPE_REMOVE) {
+ rawContactIdsToAdd = null;
+ rawContactIdsToRemove = rawContactIds;
+ action = GroupUtil.ACTION_REMOVE_FROM_GROUP;
+ } else {
+ throw new IllegalStateException("Unrecognized type " + mType);
+ }
+ return ContactSaveService.createGroupUpdateIntent(
+ mContext, mGroupId, /* newLabel */ null, rawContactIdsToAdd,
+ rawContactIdsToRemove, PeopleActivity.class, action);
+ }
+
+ // TODO(wjang): prune raw contacts that are already in the group; ContactSaveService will
+ // log a warning if the raw contact is already a member and keep going but it is not ideal.
+ private long[] getRawContactIds() {
+ final Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon()
+ .appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, mAccountName)
+ .appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_TYPE, mAccountType)
+ .build();
+ final String[] projection = new String[]{ContactsContract.RawContacts._ID};
+ final StringBuilder selection = new StringBuilder();
+ final String[] selectionArgs = new String[mContactIds.length];
+ for (int i = 0; i < mContactIds.length; i++) {
+ if (i > 0) {
+ selection.append(" OR ");
+ }
+ selection.append(ContactsContract.RawContacts.CONTACT_ID).append("=?");
+ selectionArgs[i] = Long.toString(mContactIds[i]);
+ }
+ final Cursor cursor = mContext.getContentResolver().query(
+ rawContactUri, projection, selection.toString(), selectionArgs, null, null);
+ final long[] rawContactIds = new long[cursor.getCount()];
+ try {
+ int i = 0;
+ while (cursor.moveToNext()) {
+ rawContactIds[i] = cursor.getLong(0);
+ i++;
+ }
+ } finally {
+ cursor.close();
+ }
+ return rawContactIds;
+ }
+
+ @Override
+ protected void onPostExecute(Intent intent) {
+ if (intent == null) {
+ Toast.makeText(mContext, R.string.groupSavedErrorToast, Toast.LENGTH_SHORT).show();
+ } else {
+ mContext.startService(intent);
+ }
+ }
+}
diff --git a/src/com/android/contacts/interactions/ContactMultiDeletionInteraction.java b/src/com/android/contacts/interactions/ContactMultiDeletionInteraction.java
index 173f66e..ff0d978 100644
--- a/src/com/android/contacts/interactions/ContactMultiDeletionInteraction.java
+++ b/src/com/android/contacts/interactions/ContactMultiDeletionInteraction.java
@@ -75,21 +75,22 @@
private TreeSet<Long> mContactIds;
private Context mContext;
private AlertDialog mDialog;
+ private MultiContactDeleteListener mListener;
/**
* Starts the interaction.
*
- * @param activity the activity within which to start the interaction
+ * @param hostFragment the fragment within which to start the interaction
* @param contactIds the IDs of contacts to be deleted
* @return the newly created interaction
*/
public static ContactMultiDeletionInteraction start(
- Activity activity, TreeSet<Long> contactIds) {
+ Fragment hostFragment, TreeSet<Long> contactIds) {
if (contactIds == null) {
return null;
}
- final FragmentManager fragmentManager = activity.getFragmentManager();
+ final FragmentManager fragmentManager = hostFragment.getFragmentManager();
ContactMultiDeletionInteraction fragment =
(ContactMultiDeletionInteraction) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (fragment == null) {
@@ -291,13 +292,10 @@
protected void doDeleteContact(long[] contactIds) {
mContext.startService(ContactSaveService.createDeleteMultipleContactsIntent(mContext,
contactIds));
- notifyListenerActivity();
+ mListener.onDeletionFinished();
}
- private void notifyListenerActivity() {
- if (getActivity() instanceof MultiContactDeleteListener) {
- final MultiContactDeleteListener listener = (MultiContactDeleteListener) getActivity();
- listener.onDeletionFinished();
- }
+ public void setListener(MultiContactDeleteListener listener) {
+ mListener = listener;
}
}
diff --git a/src/com/android/contacts/interactions/GroupDeletionDialogFragment.java b/src/com/android/contacts/interactions/GroupDeletionDialogFragment.java
index e247536..5c5609d 100644
--- a/src/com/android/contacts/interactions/GroupDeletionDialogFragment.java
+++ b/src/com/android/contacts/interactions/GroupDeletionDialogFragment.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import com.android.contacts.ContactSaveService;
+import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.R;
/**
@@ -64,8 +65,9 @@
protected void deleteGroup() {
final long groupId = getArguments().getLong(ARG_GROUP_ID);
- getActivity().startService(ContactSaveService.createGroupDeletionIntent(
+ final ContactsDrawerActivity activity = ((ContactsDrawerActivity) getActivity());
+ activity.startService(ContactSaveService.createGroupDeletionIntent(
getActivity(), groupId));
- getActivity().finish();
+ activity.switchToAllContacts();
}
}
diff --git a/src/com/android/contacts/list/ContactBrowseListFragment.java b/src/com/android/contacts/list/ContactBrowseListFragment.java
index 752201b..fdbed54 100644
--- a/src/com/android/contacts/list/ContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/ContactBrowseListFragment.java
@@ -92,7 +92,7 @@
private boolean mSelectionVerified;
private int mLastSelectedPosition = -1;
private boolean mRefreshingContactUri;
- private ContactListFilter mFilter;
+ protected ContactListFilter mFilter;
private String mPersistentSelectionPrefix = PERSISTENT_SELECTION_PREFIX;
protected OnContactBrowserActionListener mListener;
@@ -679,9 +679,4 @@
return mPersistentSelectionPrefix + "-" + mFilter.getId();
}
}
-
- public boolean isOptionsMenuChanged() {
- // This fragment does not have an option menu of its own
- return false;
- }
}
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index 354ea3a..8e93baf 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -35,6 +35,7 @@
import android.util.Log;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.group.GroupUtil;
/**
* Parses a Contacts intent, extracting all relevant parts and packaging them
@@ -150,11 +151,19 @@
if (ContactsContract.Contacts.CONTENT_TYPE.equals(resolvedType)
|| android.provider.Contacts.People.CONTENT_TYPE.equals(resolvedType)) {
request.setActionCode(ContactsRequest.ACTION_ALL_CONTACTS);
- } else {
+ } else if (!GroupUtil.isGroupUri(intent.getData())){
request.setActionCode(ContactsRequest.ACTION_VIEW_CONTACT);
request.setContactUri(intent.getData());
intent.setAction(Intent.ACTION_DEFAULT);
intent.setData(null);
+ } else {
+ request.setActionCode(ContactsRequest.ACTION_VIEW_GROUP);
+ request.setContactUri(intent.getData());
+ }
+ } else if (Intent.ACTION_EDIT.equals(action)) {
+ if (GroupUtil.isGroupUri(intent.getData())){
+ request.setActionCode(ContactsRequest.ACTION_EDIT_GROUP);
+ request.setContactUri(intent.getData());
}
// Since this is the filter activity it receives all intents
// dispatched from the SearchManager for security reasons
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index e9b3a86..de6a4ba 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -45,6 +45,12 @@
/** Create a new group */
public static final int ACTION_INSERT_GROUP = 22;
+ /** View a group */
+ public static final int ACTION_VIEW_GROUP = 23;
+
+ /** Edit a group */
+ public static final int ACTION_EDIT_GROUP = 24;
+
/** Show all starred contacts */
public static final int ACTION_STARRED = 30;
diff --git a/src/com/android/contacts/list/ContactsUnavailableFragment.java b/src/com/android/contacts/list/ContactsUnavailableFragment.java
index 1b122cc..aa08a32 100644
--- a/src/com/android/contacts/list/ContactsUnavailableFragment.java
+++ b/src/com/android/contacts/list/ContactsUnavailableFragment.java
@@ -33,7 +33,6 @@
import android.widget.TextView;
import com.android.contacts.R;
-import com.android.contacts.activities.ActionBarAdapter.TabState;
import com.android.contacts.common.compat.ProviderStatusCompat;
/**
@@ -50,7 +49,6 @@
private ProgressBar mProgress;
private View mButtonsContainer;
private int mNoContactsMsgResId = -1;
- private int mLastTab = -1;
private OnContactsUnavailableActionListener mListener;
@@ -125,10 +123,6 @@
* Update views in the fragment when provider status is empty.
*/
private void updateViewsForEmptyStatus() {
- setTabInfo(mNoContactsMsgResId, mLastTab);
- if (mLastTab == TabState.ALL) {
- updateButtonVisibilty(View.VISIBLE);
- }
mProgress.setVisibility(View.GONE);
}
@@ -167,29 +161,6 @@
}
}
- /**
- * Set the message to be shown if no data is available for the selected tab
- *
- * @param resId - String resource ID of the message , -1 means view will not be visible
- */
- public void setTabInfo(int resId, int callerTab) {
- mNoContactsMsgResId = resId;
- mLastTab = callerTab;
- if ((mMessageView != null) && (mProviderStatus != null) &&
- mProviderStatus.equals(ProviderStatusCompat.STATUS_EMPTY)) {
- if (resId != -1) {
- mMessageView.setText(mNoContactsMsgResId);
- mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
- mMessageView.setVisibility(View.VISIBLE);
- if (callerTab == TabState.ALL) {
- updateButtonVisibilty(View.VISIBLE);
- }
- } else {
- mMessageView.setVisibility(View.GONE);
- }
- }
- }
-
private void updateButtonVisibilty(int visibility) {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
mAddAccountButton.setVisibility(visibility);
diff --git a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
index afaafb7..d877195 100644
--- a/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
@@ -15,15 +15,31 @@
*/
package com.android.contacts.list;
+import android.accounts.Account;
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
+import android.content.ContentResolver;
+import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
+import android.content.Intent;
import android.content.Loader;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.database.Cursor;
+import android.graphics.Rect;
import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.Directory;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.text.TextUtils;
+import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
@@ -32,32 +48,178 @@
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
+import android.widget.Toast;
+import com.android.contacts.ContactSaveService;
+import com.android.contacts.ContactsDrawerActivity;
import com.android.contacts.R;
-import com.android.contacts.activities.PeopleActivity;
+import com.android.contacts.activities.ActionBarAdapter;
+import com.android.contacts.common.Experiments;
+import com.android.contacts.common.compat.CompatUtils;
+import com.android.contacts.common.list.ContactEntryListFragment;
import com.android.contacts.common.list.ContactListAdapter;
import com.android.contacts.common.list.ContactListFilter;
+import com.android.contacts.common.list.ContactListFilterController;
+import com.android.contacts.common.list.ContactListFilterController.ContactListFilterListener;
import com.android.contacts.common.list.ContactListItemView;
import com.android.contacts.common.list.DefaultContactListAdapter;
import com.android.contacts.common.list.FavoritesAndContactsLoader;
+import com.android.contacts.common.logging.ListEvent;
+import com.android.contacts.common.logging.Logger;
+import com.android.contacts.common.logging.ScreenEvent;
+import com.android.contacts.common.model.AccountTypeManager;
+import com.android.contacts.common.model.account.AccountDisplayInfo;
+import com.android.contacts.common.model.account.AccountDisplayInfoFactory;
import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.util.AccountFilterUtil;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
+import com.android.contacts.interactions.ContactDeletionInteraction;
+import com.android.contacts.interactions.ContactMultiDeletionInteraction;
+import com.android.contacts.interactions.ContactMultiDeletionInteraction.MultiContactDeleteListener;
+import com.android.contacts.quickcontact.QuickContactActivity;
+import com.android.contacts.util.SharedPreferenceUtil;
+import com.android.contacts.util.SyncUtil;
+import com.android.contactsbind.experiments.Flags;
+import com.android.contactsbind.FeatureHighlightHelper;
+
+import java.util.List;
+import java.util.Locale;
/**
* Fragment containing a contact list used for browsing (as compared to
* picking a contact with one of the PICK intents).
*/
public class DefaultContactBrowseListFragment extends ContactBrowseListFragment {
+
+ private static final String TAG = "DefaultListFragment";
+ private static final String ENABLE_DEBUG_OPTIONS_HIDDEN_CODE = "debug debug!";
+ private static final String KEY_DELETION_IN_PROGRESS = "deletionInProgress";
+
+ private static final int ACTIVITY_REQUEST_CODE_SHARE = 0;
+
private View mSearchHeaderView;
private View mSearchProgress;
private View mEmptyAccountView;
private View mEmptyHomeView;
private View mAccountFilterContainer;
private TextView mSearchProgressText;
- private FeatureHighlightCallback mCallback;
+ private SwipeRefreshLayout mSwipeRefreshLayout;
- public interface FeatureHighlightCallback {
- void onLoadFinishedCallback();
- }
+ private boolean mContactsAvailable;
+ private boolean mEnableDebugMenuOptions;
+ private boolean mIsRecreatedInstance;
+ private boolean mOptionsMenuContactsAvailable;
+
+ /**
+ * This is to tell whether we need to restart ContactMultiDeletionInteraction and set listener.
+ * if screen is rotated while deletion dialog is shown.
+ */
+ private boolean mIsDeletionInProgress;
+
+ /**
+ * This is to disable {@link #onOptionsItemSelected} when we trying to stop the
+ * activity/fragment.
+ */
+ private boolean mDisableOptionItemSelected;
+
+ private ActionBarAdapter mActionBarAdapter;
+ private ContactsDrawerActivity mActivity;
+ private ContactsRequest mContactsRequest;
+ private ContactListFilterController mContactListFilterController;
+
+ private final ContactListFilterListener mFilterListener = new ContactListFilterListener() {
+ @Override
+ public void onContactListFilterChanged() {
+ final ContactListFilter filter = mContactListFilterController.getFilter();
+ setFilterAndUpdateTitle(filter);
+
+ // Scroll to top after filter is changed.
+ getListView().setSelection(0);
+
+ mActivity.invalidateOptionsMenu();
+ }
+ };
+
+ private final ActionBarAdapter.Listener mActionBarListener = new ActionBarAdapter.Listener() {
+ @Override
+ public void onAction(int action) {
+ switch (action) {
+ case ActionBarAdapter.Listener.Action.START_SELECTION_MODE:
+ displayCheckBoxes(true);
+ startSearchOrSelectionMode();
+ break;
+ case ActionBarAdapter.Listener.Action.START_SEARCH_MODE:
+ if (!mIsRecreatedInstance) {
+ Logger.logScreenView(mActivity, ScreenEvent.ScreenType.SEARCH);
+ }
+ startSearchOrSelectionMode();
+ break;
+ case ActionBarAdapter.Listener.Action.BEGIN_STOPPING_SEARCH_AND_SELECTION_MODE:
+ mActivity.showFabWithAnimation(/* showFab */ true);
+ break;
+ case ActionBarAdapter.Listener.Action.STOP_SEARCH_AND_SELECTION_MODE:
+ // If queryString is empty, fragment data will not be reloaded,
+ // so hamburger promo should be checked now.
+ // Otherwise, promo should be checked and displayed after reloading, b/30706521.
+ if (TextUtils.isEmpty(getQueryString())) {
+ maybeShowHamburgerFeatureHighlight();
+ }
+ setQueryTextToFragment("");
+ maybeHideCheckBoxes();
+ mActivity.invalidateOptionsMenu();
+ mActivity.showFabWithAnimation(/* showFab */ true);
+ // Determine whether the account has pullToRefresh feature
+ if (Flags.getInstance(getContext()).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ setSwipeRefreshLayoutEnabledOrNot(getFilter());
+ }
+ break;
+ case ActionBarAdapter.Listener.Action.CHANGE_SEARCH_QUERY:
+ final String queryString = mActionBarAdapter.getQueryString();
+ setQueryTextToFragment(queryString);
+ updateDebugOptionsVisibility(
+ ENABLE_DEBUG_OPTIONS_HIDDEN_CODE.equals(queryString));
+ break;
+ default:
+ throw new IllegalStateException("Unknown ActionBarAdapter action: " + action);
+ }
+ }
+
+ private void startSearchOrSelectionMode() {
+ configureContactListFragment();
+ maybeHideCheckBoxes();
+ mActivity.invalidateOptionsMenu();
+ mActivity.showFabWithAnimation(/* showFab */ false);
+
+ final Context context = getContext();
+ if (!SharedPreferenceUtil.getHamburgerPromoTriggerActionHappenedBefore(context)) {
+ SharedPreferenceUtil.setHamburgerPromoTriggerActionHappenedBefore(context);
+ }
+ }
+
+ private void updateDebugOptionsVisibility(boolean visible) {
+ if (mEnableDebugMenuOptions != visible) {
+ mEnableDebugMenuOptions = visible;
+ mActivity.invalidateOptionsMenu();
+ }
+ }
+
+ private void setQueryTextToFragment(String query) {
+ setQueryString(query, true);
+ setVisibleScrollbarEnabled(!isSearchMode());
+ }
+
+ @Override
+ public void onUpButtonPressed() {
+ mActivity.onBackPressed();
+ }
+ };
+
+ private final View.OnClickListener mAddContactListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ AccountFilterUtil.startEditorIntent(getContext(), mActivity.getIntent(), getFilter());
+ }
+ };
public DefaultContactBrowseListFragment() {
setPhotoLoaderEnabled(true);
@@ -67,10 +229,7 @@
setSectionHeaderDisplayEnabled(true);
setVisibleScrollbarEnabled(true);
setDisplayDirectoryHeader(false);
- }
-
- public void setFeatureHighlightCallback(FeatureHighlightCallback callback) {
- mCallback = callback;
+ setHasOptionsMenu(true);
}
@Override
@@ -84,14 +243,26 @@
bindListHeader(data.getCount());
}
super.onLoadFinished(loader, data);
- if (!isSearchMode() && mCallback != null) {
- mCallback.onLoadFinishedCallback();
+ if (!isSearchMode()) {
+ maybeShowHamburgerFeatureHighlight();
+ }
+ }
+
+ public void maybeShowHamburgerFeatureHighlight() {
+ if (mActionBarAdapter!= null && !mActionBarAdapter.isSearchMode()
+ && !mActionBarAdapter.isSelectionMode()
+ && SharedPreferenceUtil.getShouldShowHamburgerPromo(getContext())) {
+ if (FeatureHighlightHelper.showHamburgerFeatureHighlight(mActivity)) {
+ SharedPreferenceUtil.setHamburgerPromoDisplayedBefore(getContext());
+ }
}
}
private void bindListHeader(int numberOfContacts) {
final ContactListFilter filter = getFilter();
- if (!isSearchMode() && numberOfContacts <= 0) {
+ // If the phone has at least one Google account whose sync status is unsyncable or pending
+ // or active, we have to make mAccountFilterContainer visible.
+ if (!isSearchMode() && numberOfContacts <= 0 && shouldShowEmptyView(filter)) {
if (filter != null && filter.isContactsFilterType()) {
makeViewVisible(mEmptyHomeView);
} else {
@@ -114,6 +285,38 @@
}
}
+ /**
+ * If at least one Google account is unsyncable or its sync status is pending or active, we
+ * should not show empty view even if the number of contacts is 0. We should show sync status
+ * with empty list instead.
+ */
+ private boolean shouldShowEmptyView(ContactListFilter filter) {
+ if (filter == null) {
+ return true;
+ }
+ // TODO(samchen) : Check ContactListFilter.FILTER_TYPE_CUSTOM
+ if (ContactListFilter.FILTER_TYPE_DEFAULT == filter.filterType
+ || ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS == filter.filterType) {
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(getContext())
+ .getAccounts(/* contactsWritableOnly */ true);
+ final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
+
+ if (syncableAccounts != null && syncableAccounts.size() > 0) {
+ for (Account account : syncableAccounts) {
+ if (SyncUtil.isSyncStatusPendingOrActive(account)
+ || SyncUtil.isUnsyncableGoogleAccount(account)) {
+ return false;
+ }
+ }
+ }
+ } else if (ContactListFilter.FILTER_TYPE_ACCOUNT == filter.filterType) {
+ final Account account = new Account(filter.accountName, filter.accountType);
+ return !(SyncUtil.isSyncStatusPendingOrActive(account)
+ || SyncUtil.isUnsyncableGoogleAccount(account));
+ }
+ return true;
+ }
+
// Show the view that's specified by id and hide the other two.
private void makeViewVisible(View view) {
mEmptyAccountView.setVisibility(view == mEmptyAccountView ? View.VISIBLE : View.GONE);
@@ -176,12 +379,7 @@
// Set up add contact button.
final Button addContactButton =
(Button) emptyHomeView.findViewById(R.id.add_contact_button);
- addContactButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ((PeopleActivity) getActivity()).onFabClicked();
- }
- });
+ addContactButton.setOnClickListener(mAddContactListener);
return emptyHomeView;
}
@@ -202,22 +400,36 @@
// Set up add contact button.
final Button addContactButton =
(Button) emptyAccountView.findViewById(R.id.add_contact_button);
- addContactButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ((PeopleActivity) getActivity()).onFabClicked();
- }
- });
+ addContactButton.setOnClickListener(mAddContactListener);
return emptyAccountView;
}
@Override
+ public void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+ mIsRecreatedInstance = (savedState != null);
+ mContactListFilterController = ContactListFilterController.getInstance(getContext());
+ mContactListFilterController.checkFilterValidity(false);
+ mContactListFilterController.addListener(mFilterListener);
+ // Use FILTER_TYPE_ALL_ACCOUNTS filter if the instance is not a re-created one.
+ // This is useful when user upgrades app while an account filter or a custom filter was
+ // stored in sharedPreference in a previous version of Contacts app.
+ final ContactListFilter filter = mIsRecreatedInstance
+ ? mContactListFilterController.getFilter()
+ : AccountFilterUtil.createContactsFilter(getContext());
+ setContactListFilter(filter);
+ }
+
+ @Override
protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
super.onCreateView(inflater, container);
+ if (Flags.getInstance(getContext()).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ initSwipeRefreshLayout();
+ }
// Putting the header view inside a container will allow us to make
// it invisible later. See checkHeaderViewVisibility()
- FrameLayout headerContainer = new FrameLayout(inflater.getContext());
+ final FrameLayout headerContainer = new FrameLayout(inflater.getContext());
mSearchHeaderView = inflater.inflate(R.layout.search_header, null, false);
headerContainer.addView(mSearchHeaderView);
getListView().addHeaderView(headerContainer, null, false);
@@ -227,6 +439,102 @@
mSearchProgressText = (TextView) mSearchHeaderView.findViewById(R.id.totalContactsText);
}
+ private void initSwipeRefreshLayout() {
+ mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_refresh);
+ if (mSwipeRefreshLayout == null) {
+ return;
+ }
+
+ mSwipeRefreshLayout.setEnabled(true);
+ // Request sync contacts
+ mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ syncContacts(mFilter);
+ }
+ });
+ mSwipeRefreshLayout.setColorSchemeResources(
+ R.color.swipe_refresh_color1,
+ R.color.swipe_refresh_color2,
+ R.color.swipe_refresh_color3,
+ R.color.swipe_refresh_color4);
+ mSwipeRefreshLayout.setDistanceToTriggerSync(
+ (int) getResources().getDimension(R.dimen.pull_to_refresh_distance));
+ }
+
+ /**
+ * Request sync for the Google accounts (not include Google+ accounts) specified by the given
+ * filter.
+ */
+ private void syncContacts(ContactListFilter filter) {
+ if (filter == null) {
+ return;
+ }
+ final Bundle bundle = new Bundle();
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(
+ getContext()).getAccounts(/* contactsWritableOnly */ true);
+ final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
+ if (syncableAccounts != null && syncableAccounts.size() > 0) {
+ for (Account account : syncableAccounts) {
+ // We can prioritize Contacts sync if sync is not initialized yet.
+ if (!SyncUtil.isSyncStatusPendingOrActive(account)
+ || SyncUtil.isUnsyncableGoogleAccount(account)) {
+ ContentResolver.requestSync(account, ContactsContract.AUTHORITY, bundle);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ mActivity = (ContactsDrawerActivity) getActivity();
+ mActionBarAdapter = new ActionBarAdapter(mActivity, mActionBarListener,
+ mActivity.getSupportActionBar(), mActivity.getToolbar(),
+ R.string.enter_contact_name);
+ mActionBarAdapter.setShowHomeIcon(true);
+ initializeActionBarAdapter(savedInstanceState);
+ if (isSearchMode()) {
+ mActionBarAdapter.setFocusOnSearchView();
+ }
+
+ setCheckBoxListListener(new CheckBoxListListener());
+ setOnContactListActionListener(new ContactBrowserActionListener());
+ if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_DELETION_IN_PROGRESS)) {
+ deleteSelectedContacts();
+ }
+ }
+
+ public void initializeActionBarAdapter(Bundle savedInstanceState) {
+ if (mActionBarAdapter != null) {
+ mActionBarAdapter.initialize(savedInstanceState, mContactsRequest);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // Re-register the listener, which may have been cleared when onSaveInstanceState was
+ // called. See also: onSaveInstanceState
+ mActionBarAdapter.setListener(mActionBarListener);
+ mDisableOptionItemSelected = false;
+ maybeHideCheckBoxes();
+ }
+
+ private void maybeHideCheckBoxes() {
+ if (!mActionBarAdapter.isSelectionMode()) {
+ displayCheckBoxes(false);
+ }
+ }
+
+ public ActionBarAdapter getActionBarAdapter(){
+ return mActionBarAdapter;
+ }
+
@Override
protected void setSearchMode(boolean flag) {
super.setSearchMode(flag);
@@ -275,4 +583,430 @@
}
}
}
-}
\ No newline at end of file
+
+ public SwipeRefreshLayout getSwipeRefreshLayout() {
+ return mSwipeRefreshLayout;
+ }
+
+ private final class CheckBoxListListener implements OnCheckBoxListActionListener {
+ @Override
+ public void onStartDisplayingCheckBoxes() {
+ mActionBarAdapter.setSelectionMode(true);
+ mActivity.invalidateOptionsMenu();
+ }
+
+ @Override
+ public void onSelectedContactIdsChanged() {
+ mActionBarAdapter.setSelectionCount(getSelectedContactIds().size());
+ mActivity.invalidateOptionsMenu();
+ }
+
+ @Override
+ public void onStopDisplayingCheckBoxes() {
+ mActionBarAdapter.setSelectionMode(false);
+ }
+ }
+
+ private void setFilterAndUpdateTitle(ContactListFilter filter) {
+ setFilterAndUpdateTitle(filter, true);
+ }
+
+ private void setFilterAndUpdateTitle(ContactListFilter filter, boolean restoreSelectedUri) {
+ setFilter(filter, restoreSelectedUri);
+ setListType(mContactListFilterController.getFilterListType());
+
+ final String actionBarTitle;
+ if (filter.filterType == ContactListFilter.FILTER_TYPE_DEVICE_CONTACTS) {
+ actionBarTitle = getString(R.string.account_phone);
+ } else if (!TextUtils.isEmpty(filter.accountName)) {
+ actionBarTitle = getActionBarTitleForAccount(filter);
+ } else {
+ actionBarTitle = getString(R.string.contactsList);
+ }
+ mActivity.setTitle(actionBarTitle);
+ mActivity.updateFilterMenu(filter);
+
+ if (CompatUtils.isNCompatible()) {
+ mActivity.getWindow().getDecorView()
+ .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+ }
+
+ // Determine whether the account has pullToRefresh feature
+ if (Flags.getInstance(getContext()).getBoolean(Experiments.PULL_TO_REFRESH)) {
+ setSwipeRefreshLayoutEnabledOrNot(filter);
+ }
+ }
+
+ private String getActionBarTitleForAccount(ContactListFilter filter) {
+ final AccountDisplayInfoFactory factory = AccountDisplayInfoFactory
+ .forAllAccounts(getContext());
+ final AccountDisplayInfo account = factory.getAccountDisplayInfoFor(filter);
+ if (account.hasGoogleAccountType()) {
+ return getString(R.string.title_from_google);
+ }
+ return account.withFormattedName(getContext(), R.string.title_from_other_accounts)
+ .getNameLabel().toString();
+ }
+
+ public void setSwipeRefreshLayoutEnabledOrNot(ContactListFilter filter) {
+ final SwipeRefreshLayout swipeRefreshLayout = getSwipeRefreshLayout();
+ if (swipeRefreshLayout == null) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Can not load swipeRefreshLayout, swipeRefreshLayout is null");
+ }
+ return;
+ }
+
+ swipeRefreshLayout.setRefreshing(false);
+ swipeRefreshLayout.setEnabled(false);
+
+ if (filter != null && !mActionBarAdapter.isSearchMode()
+ && !mActionBarAdapter.isSelectionMode()) {
+ final List<AccountWithDataSet> accounts = AccountTypeManager.getInstance(getContext())
+ .getAccounts(/* contactsWritableOnly */ true);
+ if (filter.isSyncable(accounts)) {
+ swipeRefreshLayout.setEnabled(true);
+ }
+ }
+ }
+
+ public void configureContactListFragment() {
+ // Filter may be changed when activity is in background.
+ setFilterAndUpdateTitle(getFilter());
+ setVerticalScrollbarPosition(getScrollBarPosition());
+ setSelectionVisible(false);
+ mActivity.invalidateOptionsMenu();
+ }
+
+ private int getScrollBarPosition() {
+ final Locale locale = Locale.getDefault();
+ final boolean isRTL =
+ TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL;
+ return isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT;
+ }
+
+ private final class ContactBrowserActionListener implements OnContactBrowserActionListener {
+ ContactBrowserActionListener() {}
+
+ @Override
+ public void onSelectionChange() {
+
+ }
+
+ @Override
+ public void onViewContactAction(int position, Uri contactLookupUri,
+ boolean isEnterpriseContact) {
+ if (isEnterpriseContact) {
+ // No implicit intent as user may have a different contacts app in work profile.
+ ContactsContract.QuickContact.showQuickContact(getContext(), new Rect(),
+ contactLookupUri, QuickContactActivity.MODE_FULLY_EXPANDED, null);
+ } else {
+ final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(
+ getContext(), contactLookupUri, QuickContactActivity.MODE_FULLY_EXPANDED);
+ final int previousScreen;
+ if (isSearchMode()) {
+ previousScreen = ScreenEvent.ScreenType.SEARCH;
+ } else {
+ if (isAllContactsFilter(mContactListFilterController.getFilter())) {
+ if (position < getAdapter().getNumberOfFavorites()) {
+ previousScreen = ScreenEvent.ScreenType.FAVORITES;
+ } else {
+ previousScreen = ScreenEvent.ScreenType.ALL_CONTACTS;
+ }
+ } else {
+ previousScreen = ScreenEvent.ScreenType.LIST_ACCOUNT;
+ }
+ }
+ Logger.logListEvent(ListEvent.ActionType.CLICK,
+ /* listType */ getListTypeIncludingSearch(),
+ /* count */ getAdapter().getCount(),
+ /* clickedIndex */ position, /* numSelected */ 0);
+ intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, previousScreen);
+ ImplicitIntentsUtil.startActivityInApp(getContext(), intent);
+ }
+ }
+
+ @Override
+ public void onDeleteContactAction(Uri contactUri) {
+ ContactDeletionInteraction.start(mActivity, contactUri, false);
+ }
+
+ @Override
+ public void onFinishAction() {
+ mActivity.onBackPressed();
+ }
+
+ @Override
+ public void onInvalidSelection() {
+ ContactListFilter filter;
+ ContactListFilter currentFilter = getFilter();
+ if (currentFilter != null
+ && currentFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
+ filter = AccountFilterUtil.createContactsFilter(getContext());
+ setFilterAndUpdateTitle(filter);
+ } else {
+ filter = ContactListFilter.createFilterWithType(
+ ContactListFilter.FILTER_TYPE_SINGLE_CONTACT);
+ setFilterAndUpdateTitle(filter, /* restoreSelectedUri */ false);
+ }
+ setContactListFilter(filter);
+ }
+ }
+
+ private boolean isAllContactsFilter(ContactListFilter filter) {
+ return filter != null && filter.isContactsFilterType();
+ }
+
+ public void setContactsAvailable(boolean contactsAvailable) {
+ mContactsAvailable = contactsAvailable;
+ }
+
+ /**
+ * Set filter via ContactListFilterController
+ */
+ public void setContactListFilter(ContactListFilter filter) {
+ mContactListFilterController.setContactListFilter(filter,
+ /* persistent */ isAllContactsFilter(filter));
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (!mContactsAvailable || mActivity.isInSecondLevel()) {
+ // If contacts aren't available or this fragment is not visible, hide all menu items.
+ return;
+ }
+ super.onCreateOptionsMenu(menu, inflater);
+ inflater.inflate(R.menu.people_options, menu);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ mOptionsMenuContactsAvailable = mContactsAvailable;
+ if (!mOptionsMenuContactsAvailable) {
+ return;
+ }
+
+ final boolean isSearchOrSelectionMode = mActionBarAdapter.isSearchMode()
+ || mActionBarAdapter.isSelectionMode();
+ makeMenuItemVisible(menu, R.id.menu_search, !isSearchOrSelectionMode);
+
+ final boolean showSelectedContactOptions = mActionBarAdapter.isSelectionMode()
+ && getSelectedContactIds().size() != 0;
+ makeMenuItemVisible(menu, R.id.menu_share, showSelectedContactOptions);
+ makeMenuItemVisible(menu, R.id.menu_delete, showSelectedContactOptions);
+ final boolean showLinkContactsOptions = mActionBarAdapter.isSelectionMode()
+ && getSelectedContactIds().size() > 1;
+ makeMenuItemVisible(menu, R.id.menu_join, showLinkContactsOptions);
+
+ // Debug options need to be visible even in search mode.
+ makeMenuItemVisible(menu, R.id.export_database, mEnableDebugMenuOptions &&
+ hasExportIntentHandler());
+ }
+
+ private void makeMenuItemVisible(Menu menu, int itemId, boolean visible) {
+ final MenuItem item = menu.findItem(itemId);
+ if (item != null) {
+ item.setVisible(visible);
+ }
+ }
+
+ private boolean hasExportIntentHandler() {
+ final Intent intent = new Intent();
+ intent.setAction("com.android.providers.contacts.DUMP_DATABASE");
+ final List<ResolveInfo> receivers =
+ getContext().getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ return receivers != null && receivers.size() > 0;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (mDisableOptionItemSelected) {
+ return false;
+ }
+
+ switch (item.getItemId()) {
+ case android.R.id.home: {
+ // The home icon on the action bar is pressed
+ if (mActionBarAdapter.isUpShowing()) {
+ // "UP" icon press -- should be treated as "back".
+ mActivity.onBackPressed();
+ }
+ return true;
+ }
+ case R.id.menu_search: {
+ if (!mActionBarAdapter.isSelectionMode()) {
+ mActionBarAdapter.setSearchMode(true);
+ }
+ return true;
+ }
+ case R.id.menu_share: {
+ shareSelectedContacts();
+ return true;
+ }
+ case R.id.menu_join: {
+ Logger.logListEvent(ListEvent.ActionType.LINK,
+ /* listType */ getListTypeIncludingSearch(),
+ /* count */ getAdapter().getCount(), /* clickedIndex */ -1,
+ /* numSelected */ getAdapter().getSelectedContactIds().size());
+ joinSelectedContacts();
+ return true;
+ }
+ case R.id.menu_delete: {
+ deleteSelectedContacts();
+ return true;
+ }
+ case R.id.export_database: {
+ final Intent intent = new Intent("com.android.providers.contacts.DUMP_DATABASE");
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+ ImplicitIntentsUtil.startActivityOutsideApp(getContext(), intent);
+ return true;
+ }
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * Share all contacts that are currently selected in mAllFragment. This method is pretty
+ * inefficient for handling large numbers of contacts. I don't expect this to be a problem.
+ */
+ private void shareSelectedContacts() {
+ final StringBuilder uriListBuilder = new StringBuilder();
+ for (Long contactId : getSelectedContactIds()) {
+ final Uri contactUri = ContentUris.withAppendedId(
+ ContactsContract.Contacts.CONTENT_URI, contactId);
+ final Uri lookupUri = ContactsContract.Contacts.getLookupUri(
+ getContext().getContentResolver(), contactUri);
+ if (lookupUri == null) {
+ continue;
+ }
+ final List<String> pathSegments = lookupUri.getPathSegments();
+ if (pathSegments.size() < 2) {
+ continue;
+ }
+ final String lookupKey = pathSegments.get(pathSegments.size() - 2);
+ if (uriListBuilder.length() > 0) {
+ uriListBuilder.append(':');
+ }
+ uriListBuilder.append(Uri.encode(lookupKey));
+ }
+ if (uriListBuilder.length() == 0) {
+ return;
+ }
+ final Uri uri = Uri.withAppendedPath(
+ ContactsContract.Contacts.CONTENT_MULTI_VCARD_URI,
+ Uri.encode(uriListBuilder.toString()));
+ final Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
+ intent.putExtra(Intent.EXTRA_STREAM, uri);
+ try {
+ startActivityForResult(Intent.createChooser(intent, getResources().getQuantityString(
+ R.plurals.title_share_via,/* quantity */ getSelectedContactIds().size()))
+ , ACTIVITY_REQUEST_CODE_SHARE);
+ } catch (final ActivityNotFoundException ex) {
+ Toast.makeText(getContext(), R.string.share_error, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ private void joinSelectedContacts() {
+ final Context context = getContext();
+ final Intent intent = ContactSaveService.createJoinSeveralContactsIntent(
+ context, getSelectedContactIdsArray());
+ context.startService(intent);
+
+ mActionBarAdapter.setSelectionMode(false);
+ }
+
+ private void deleteSelectedContacts() {
+ final ContactMultiDeletionInteraction multiDeletionInteraction =
+ ContactMultiDeletionInteraction.start(this, getSelectedContactIds());
+ multiDeletionInteraction.setListener(new MultiDeleteListener());
+ mIsDeletionInProgress = true;
+ }
+
+ private final class MultiDeleteListener implements MultiContactDeleteListener {
+ @Override
+ public void onDeletionFinished() {
+ // The parameters count and numSelected are both the number of contacts before deletion.
+ Logger.logListEvent(ListEvent.ActionType.DELETE,
+ /* listType */ getListTypeIncludingSearch(),
+ /* count */ getAdapter().getCount(), /* clickedIndex */ -1,
+ /* numSelected */ getSelectedContactIds().size());
+ mActionBarAdapter.setSelectionMode(false);
+ mIsDeletionInProgress = false;
+ }
+ }
+
+ private int getListTypeIncludingSearch() {
+ return isSearchMode() ? ListEvent.ListType.SEARCH_RESULT : getListType();
+ }
+
+ public void setListType() {
+ mContactListFilterController = ContactListFilterController.getInstance(getContext());
+ setListType(mContactListFilterController.getFilterListType());
+ }
+
+ public void setContactsRequest(ContactsRequest contactsRequest) {
+ mContactsRequest = contactsRequest;
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ // TODO: Using the new startActivityWithResultFromFragment API this should not be needed
+ // anymore
+ case ContactEntryListFragment.ACTIVITY_REQUEST_CODE_PICKER:
+ if (resultCode == Activity.RESULT_OK) {
+ onPickerResult(data);
+ }
+ case ACTIVITY_REQUEST_CODE_SHARE:
+ Logger.logListEvent(ListEvent.ActionType.SHARE,
+ /* listType */ getListTypeIncludingSearch(),
+ /* count */ getAdapter().getCount(), /* clickedIndex */ -1,
+ /* numSelected */ getAdapter().getSelectedContactIds().size());
+
+// TODO fix or remove multipicker code: ag/54762
+// else if (resultCode == RESULT_CANCELED && mMode == MODE_PICK_MULTIPLE_PHONES) {
+// // Finish the activity if the sub activity was canceled as back key is used
+// // to confirm user selection in MODE_PICK_MULTIPLE_PHONES.
+// finish();
+// }
+// break;
+ }
+ }
+
+ public boolean getOptionsMenuContactsAvailable() {
+ return mOptionsMenuContactsAvailable;
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ // Clear the listener to make sure we don't get callbacks after onSaveInstanceState,
+ // in order to avoid doing fragment transactions after it.
+ // TODO Figure out a better way to deal with the issue (ag/120686).
+ if (mActionBarAdapter != null) {
+ mActionBarAdapter.setListener(null);
+ mActionBarAdapter.onSaveInstanceState(outState);
+ }
+ mDisableOptionItemSelected = true;
+ outState.putBoolean(KEY_DELETION_IN_PROGRESS, mIsDeletionInProgress);
+ }
+
+ @Override
+ public void onPause() {
+ mOptionsMenuContactsAvailable = false;
+ super.onPause();
+ }
+
+ @Override
+ public void onDestroy() {
+ if (mActionBarAdapter != null) {
+ mActionBarAdapter.setListener(null);
+ }
+ if (mContactListFilterController != null) {
+ mContactListFilterController.removeListener(mFilterListener);
+ }
+ super.onDestroy();
+ }
+}
diff --git a/src/com/android/contacts/list/MultiSelectContactsListFragment.java b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
index f5c6d34..41fd11e 100644
--- a/src/com/android/contacts/list/MultiSelectContactsListFragment.java
+++ b/src/com/android/contacts/list/MultiSelectContactsListFragment.java
@@ -34,6 +34,7 @@
import android.widget.TextView;
import com.android.contacts.R;
+import com.android.contacts.activities.ActionBarAdapter;
import com.android.contacts.common.list.ContactEntryListFragment;
import com.android.contacts.common.list.MultiSelectEntryContactListAdapter;
import com.android.contacts.common.list.MultiSelectEntryContactListAdapter.SelectedContactsListener;
@@ -129,13 +130,18 @@
final TreeSet<Long> selectedContactIds = (TreeSet<Long>)
savedInstanceState.getSerializable(EXTRA_KEY_SELECTED_CONTACTS);
getAdapter().setSelectedContactIds(selectedContactIds);
- if (mCheckBoxListListener != null) {
- mCheckBoxListListener.onSelectedContactIdsChanged();
- }
mSearchResultClicked = savedInstanceState.getBoolean(KEY_SEARCH_RESULT_CLICKED);
}
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ if (mCheckBoxListListener != null) {
+ mCheckBoxListListener.onSelectedContactIdsChanged();
+ }
+ }
+
public TreeSet<Long> getSelectedContactIds() {
return getAdapter().getSelectedContactIds();
}
@@ -453,4 +459,10 @@
listView.getPaddingBottom());
}
+ /**
+ * Returns the {@link ActionBarAdapter} object associated with list fragment.
+ */
+ public ActionBarAdapter getActionBarAdapter() {
+ return null;
+ }
}
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 40bcd55..7c60b70 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -22,7 +22,6 @@
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.app.Activity;
-import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
@@ -64,9 +63,9 @@
import android.provider.ContactsContract.CommonDataKinds.Website;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
+import android.provider.ContactsContract.DataUsageFeedback;
import android.provider.ContactsContract.Directory;
import android.provider.ContactsContract.DisplayNameSources;
-import android.provider.ContactsContract.DataUsageFeedback;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.QuickContact;
import android.provider.ContactsContract.RawContacts;
@@ -107,7 +106,7 @@
import com.android.contacts.ContactsActivity;
import com.android.contacts.NfcHandler;
import com.android.contacts.R;
-import com.android.contacts.activities.ContactEditorBaseActivity;
+import com.android.contacts.activities.CompactContactEditorActivity;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.ClipboardUtils;
import com.android.contacts.common.Collapser;
@@ -119,7 +118,6 @@
import com.android.contacts.common.compat.EventCompat;
import com.android.contacts.common.compat.MultiWindowCompat;
import com.android.contacts.common.dialog.CallSubjectDialog;
-import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.interactions.TouchPointManager;
import com.android.contacts.common.lettertiles.LetterTileDrawable;
import com.android.contacts.common.list.ShortcutIntentBuilder;
@@ -133,8 +131,9 @@
import com.android.contacts.common.model.Contact;
import com.android.contacts.common.model.ContactLoader;
import com.android.contacts.common.model.RawContact;
+import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
-import com.android.contacts.common.model.account.AccountWithDataSet;
+import com.android.contacts.common.model.dataitem.CustomDataItem;
import com.android.contacts.common.model.dataitem.DataItem;
import com.android.contacts.common.model.dataitem.DataKind;
import com.android.contacts.common.model.dataitem.EmailDataItem;
@@ -149,10 +148,8 @@
import com.android.contacts.common.model.dataitem.StructuredNameDataItem;
import com.android.contacts.common.model.dataitem.StructuredPostalDataItem;
import com.android.contacts.common.model.dataitem.WebsiteDataItem;
-import com.android.contacts.common.model.dataitem.CustomDataItem;
-import com.android.contacts.common.model.ValuesDelta;
-import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.util.DateUtils;
+import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.common.util.MaterialColorMapUtils;
import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.contacts.common.util.PermissionsUtil;
@@ -161,7 +158,7 @@
import com.android.contacts.detail.ContactDisplayUtils;
import com.android.contacts.editor.AggregationSuggestionEngine;
import com.android.contacts.editor.AggregationSuggestionEngine.Suggestion;
-import com.android.contacts.editor.ContactEditorFragment;
+import com.android.contacts.editor.CompactContactEditorFragment;
import com.android.contacts.editor.EditorIntents;
import com.android.contacts.interactions.CalendarInteractionsLoader;
import com.android.contacts.interactions.CallLogInteractionsLoader;
@@ -185,7 +182,6 @@
import com.google.common.collect.Lists;
-import java.lang.SecurityException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -307,7 +303,6 @@
private String mPermissionExplanationCardSubHeader = "";
private MultiShrinkScroller mScroller;
- private SelectAccountDialogFragmentListener mSelectAccountFragmentListener;
private AsyncTask<Void, Void, Cp2DataCardModel> mEntriesAndActionsTask;
private AsyncTask<Void, Void, Void> mRecentDataTask;
@@ -799,36 +794,6 @@
}
}
- /**
- * Headless fragment used to handle account selection callbacks invoked from
- * {@link DirectoryContactUtil}.
- */
- public static class SelectAccountDialogFragmentListener extends Fragment
- implements SelectAccountDialogFragment.Listener {
-
- private QuickContactActivity mQuickContactActivity;
-
- public SelectAccountDialogFragmentListener() {}
-
- @Override
- public void onAccountChosen(AccountWithDataSet account, Bundle extraArgs) {
- DirectoryContactUtil.createCopy(mQuickContactActivity.mContactData.getContentValues(),
- account, mQuickContactActivity);
- }
-
- @Override
- public void onAccountSelectorCancelled() {}
-
- /**
- * Set the parent activity. Since rotation can cause this fragment to be used across
- * more than one activity instance, we need to explicitly set this value instead
- * of making this class non-static.
- */
- public void setQuickContactActivity(QuickContactActivity quickContactActivity) {
- mQuickContactActivity = quickContactActivity;
- }
- }
-
final MultiShrinkScrollerListener mMultiShrinkScrollerListener
= new MultiShrinkScrollerListener() {
@Override
@@ -1150,16 +1115,6 @@
setHeaderNameText(R.string.missing_name);
- mSelectAccountFragmentListener= (SelectAccountDialogFragmentListener) getFragmentManager()
- .findFragmentByTag(FRAGMENT_TAG_SELECT_ACCOUNT);
- if (mSelectAccountFragmentListener == null) {
- mSelectAccountFragmentListener = new SelectAccountDialogFragmentListener();
- getFragmentManager().beginTransaction().add(0, mSelectAccountFragmentListener,
- FRAGMENT_TAG_SELECT_ACCOUNT).commit();
- mSelectAccountFragmentListener.setRetainInstance(true);
- }
- mSelectAccountFragmentListener.setQuickContactActivity(this);
-
SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ true,
new Runnable() {
@Override
@@ -1210,7 +1165,7 @@
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
final boolean deletedOrSplit = requestCode == REQUEST_CODE_CONTACT_EDITOR_ACTIVITY &&
(resultCode == ContactDeletionInteraction.RESULT_CODE_DELETED ||
- resultCode == ContactEditorBaseActivity.RESULT_CODE_SPLIT);
+ resultCode == CompactContactEditorActivity.RESULT_CODE_SPLIT);
setResult(resultCode, data);
if (deletedOrSplit) {
finish();
@@ -1250,7 +1205,7 @@
}
Uri lookupUri = intent.getData();
if (intent.getBooleanExtra(EXTRA_CONTACT_EDITED, false)) {
- setResult(ContactEditorBaseActivity.RESULT_CODE_EDITED);
+ setResult(CompactContactEditorActivity.RESULT_CODE_EDITED);
}
// Check to see whether it comes from the old version.
@@ -3084,8 +3039,8 @@
intent.putExtra(Intents.Insert.DATA, values);
// If the contact can only export to the same account, add it to the intent.
- // Otherwise the ContactEditorFragment will show a dialog for selecting an
- // account.
+ // Otherwise the CompactContactEditorFragment will show a dialog for selecting
+ // an account.
if (mContactData.getDirectoryExportSupport() ==
Directory.EXPORT_SUPPORT_SAME_ACCOUNT_ONLY) {
intent.putExtra(Intents.Insert.EXTRA_ACCOUNT,
@@ -3097,7 +3052,8 @@
// Add this flag to disable the delete menu option on directory contact joins
// with local contacts. The delete option is ambiguous when joining contacts.
- intent.putExtra(ContactEditorFragment.INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION,
+ intent.putExtra(
+ CompactContactEditorFragment.INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION,
true);
intent.setPackage(getPackageName());
diff --git a/src/com/android/contacts/util/SyncUtil.java b/src/com/android/contacts/util/SyncUtil.java
new file mode 100644
index 0000000..cef2223
--- /dev/null
+++ b/src/com/android/contacts/util/SyncUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts.util;
+
+import android.accounts.Account;
+import android.content.ContentResolver;
+import android.provider.ContactsContract;
+
+import com.android.contacts.common.model.account.GoogleAccountType;
+
+import java.util.List;
+
+/**
+ * Utilities related to sync.
+ */
+public final class SyncUtil {
+ private static final String TAG = "SyncUtil";
+
+ private SyncUtil() {
+ }
+
+ public static final boolean isSyncStatusPendingOrActive(Account account) {
+ if (account == null) {
+ return false;
+ }
+ return ContentResolver.isSyncPending(account, ContactsContract.AUTHORITY)
+ || ContentResolver.isSyncActive(account, ContactsContract.AUTHORITY);
+ }
+
+ /**
+ * Returns true if the given Google account is not syncable.
+ */
+ public static final boolean isUnsyncableGoogleAccount(Account account) {
+ if (account == null || !GoogleAccountType.ACCOUNT_TYPE.equals(account.type)) {
+ return false;
+ }
+ return ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY) <= 0;
+ }
+}
diff --git a/tests/Android.mk b/tests/Android.mk
index 48a00f4..82276de 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -5,8 +5,6 @@
LOCAL_MODULE_TAGS := tests
LOCAL_CERTIFICATE := shared
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, res)
diff --git a/tests/src/com/android/contacts/common/util/DateUtilTests.java b/tests/src/com/android/contacts/common/util/DateUtilTests.java
deleted file mode 100644
index f460289..0000000
--- a/tests/src/com/android/contacts/common/util/DateUtilTests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.contacts.common.util;
-
-import junit.framework.TestCase;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.format.Time;
-
-/**
- * Unit tests for {@link com.android.contacts.common.util.DateUtils}.
- */
-@SmallTest
-public class DateUtilTests extends TestCase {
-
- /**
- * Test date differences which are in the same day.
- */
- public void testDayDiffNone() {
- Time time = new Time();
- long date1 = System.currentTimeMillis();
- long date2 = System.currentTimeMillis() + android.text.format.DateUtils.HOUR_IN_MILLIS;
- assertEquals(0, DateUtils.getDayDifference(time, date1, date2));
- assertEquals(0, DateUtils.getDayDifference(time, date2, date1));
- }
-
- /**
- * Test date differences which are a day apart.
- */
- public void testDayDiffOne() {
- Time time = new Time();
- long date1 = System.currentTimeMillis();
- long date2 = date1 + android.text.format.DateUtils.DAY_IN_MILLIS;
- assertEquals(1, DateUtils.getDayDifference(time, date1, date2));
- assertEquals(1, DateUtils.getDayDifference(time, date2, date1));
- }
-
- /**
- * Test date differences which are two days apart.
- */
- public void testDayDiffTwo() {
- Time time = new Time();
- long date1 = System.currentTimeMillis();
- long date2 = date1 + 2*android.text.format.DateUtils.DAY_IN_MILLIS;
- assertEquals(2, DateUtils.getDayDifference(time, date1, date2));
- assertEquals(2, DateUtils.getDayDifference(time, date2, date1));
- }
-}
diff --git a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
index 4a93364..73b09c6 100644
--- a/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
+++ b/tests/src/com/android/contacts/tests/allintents/AllIntentsActivity.java
@@ -578,7 +578,7 @@
intent.setData(ContentUris.withAppendedId(Groups.CONTENT_URI, groupId));
// TODO: ContactsProvider2#getType does handle the group mimetype
intent.setClassName("com.google.android.contacts",
- "com.android.contacts.activities.GroupMembersActivity");
+ "com.android.contacts.activities.PeopleActivity");
return intent;
}
diff --git a/tests/src/com/android/contacts/util/SyncUtilTests.java b/tests/src/com/android/contacts/util/SyncUtilTests.java
new file mode 100644
index 0000000..372a652
--- /dev/null
+++ b/tests/src/com/android/contacts/util/SyncUtilTests.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts.util;
+
+import android.accounts.Account;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests for SyncUtil.
+ */
+@SmallTest
+public class SyncUtilTests extends AndroidTestCase {
+ private static final String TAG = "SyncUtilTests";
+
+ private static final String GOOGLE_TYPE = "com.google";
+ private static final String NOT_GOOGLE_TYPE = "com.abc";
+ private static final String ACCOUNT_NAME = "ACCOUNT_NAME";
+
+ private final Account mGoogleAccount;
+ private final Account mOtherAccount;
+
+ public SyncUtilTests() {
+ mGoogleAccount = new Account(ACCOUNT_NAME, GOOGLE_TYPE);
+ mOtherAccount = new Account(ACCOUNT_NAME, NOT_GOOGLE_TYPE);
+ }
+
+ public void testIsUnsyncableGoogleAccount() throws Exception {
+ // The account names of mGoogleAccount and mOtherAccount are not valid, so both accounts
+ // are not syncable.
+ assertTrue(SyncUtil.isUnsyncableGoogleAccount(mGoogleAccount));
+ assertFalse(SyncUtil.isUnsyncableGoogleAccount(mOtherAccount));
+ assertFalse(SyncUtil.isUnsyncableGoogleAccount(null));
+ }
+}