Merge "Fix for Talkback announcement of local contact photo in photo picker" into ub-contactsdialer-a-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e484fda..c694a64 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -260,7 +260,7 @@
 
         <activity
             android:name=".quickcontact.QuickContactActivity"
-            android:label="@string/launcherActivityLabel"
+            android:label="@string/quickContactActivityLabel"
             android:theme="@style/Theme.QuickContact"
             android:launchMode="singleTop"
             android:excludeFromRecents="true"
@@ -345,7 +345,7 @@
         <!-- Edit or create a contact with only the most important fields displayed initially. -->
         <activity
             android:name=".activities.CompactContactEditorActivity"
-            android:label="@string/launcherActivityLabel"
+            android:label="@string/editContactActivityLabel"
             android:theme="@style/EditorActivityTheme"
             android:windowSoftInputMode="stateHidden|adjustResize">
 
@@ -368,7 +368,7 @@
         <!-- Edit or create a contact with all fields displayed. -->
         <activity
             android:name=".activities.ContactEditorActivity"
-            android:label="@string/launcherActivityLabel"
+            android:label="@string/editContactActivityLabel"
             android:theme="@style/EditorActivityTheme"
             android:windowSoftInputMode="stateHidden|adjustResize"
             android:exported="false">
diff --git a/proguard.flags b/proguard.flags
index 05071df..feaa360 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -9,6 +9,8 @@
   public void *(android.view.MenuItem);
 }
 
+-keep class com.android.contacts.common.** { *;}
+
 # Any class or method annotated with NeededForTesting or NeededForReflection.
 -keep @com.android.contacts.common.testing.NeededForTesting class *
 -keep @com.android.contacts.test.NeededForReflection class *
diff --git a/res/layout/editor_account_selector.xml b/res/layout/editor_account_selector.xml
index 6ba18a9..a752ec5 100644
--- a/res/layout/editor_account_selector.xml
+++ b/res/layout/editor_account_selector.xml
@@ -51,17 +51,17 @@
             android:textSize="16sp"
             android:singleLine="true"
             android:textColor="@color/primary_text_color"
+            android:textAlignment="viewStart"
             android:ellipsize="end" />
 
         <TextView
              android:id="@+id/account_name_selector"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
-             android:paddingRight="8dip"
-             android:paddingEnd="8dip"
              android:textSize="14sp"
              android:singleLine="true"
              android:textColor="@color/secondary_text_color"
+             android:textAlignment="viewStart"
              android:ellipsize="end" />
 
     </LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cf5f798..1465d83 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -23,6 +23,12 @@
          used in the Launcher icon. -->
     <string name="launcherActivityLabel">Contacts</string>
 
+    <!-- Title for Quick Contact activity. -->
+    <string name="quickContactActivityLabel">View Contact</string>
+
+    <!-- Title for Edit Contact activity. -->
+    <string name="editContactActivityLabel">Edit Contact</string>
+
     <!-- Directory partition name -->
     <string name="contactsList">Contacts</string>
 
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index f862303..6fb07a6 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -139,6 +139,7 @@
         // Turn off the Spinner's own state management. We do this ourselves on rotation
         mLabel.setId(View.NO_ID);
         mLabel.setOnItemSelectedListener(mSpinnerListener);
+        ViewSelectedFilter.suppressViewSelectedEvent(mLabel);
         mLabel.setOnTouchListener(new OnTouchListener() {
             @Override
             public boolean onTouch(View v, MotionEvent event) {
diff --git a/src/com/android/contacts/editor/ViewSelectedFilter.java b/src/com/android/contacts/editor/ViewSelectedFilter.java
new file mode 100644
index 0000000..85b1a96
--- /dev/null
+++ b/src/com/android/contacts/editor/ViewSelectedFilter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.view.View;
+import android.view.View.AccessibilityDelegate;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
+
+/**
+ * This is an AccessibilityDelegate that filters out the TYPE_VIEW_SELECTED event.
+ */
+public class ViewSelectedFilter extends AccessibilityDelegate {
+    private View mView; //the view we don't want TYPE_VIEW_SELECTED event to fire.
+
+    private ViewSelectedFilter(View view) {
+        super();
+        mView = view;
+    }
+
+    /**
+     * AccessibilityEvent can only be suppressed at a view's parent, so this function adds the
+     * delegate to the view's parent.
+     * @param view the view whose TYPE_VIEW_SELECTED event should be suppressed.
+     */
+    public static void suppressViewSelectedEvent(View view) {
+        final View parent = (View) view.getParent();
+        parent.setAccessibilityDelegate(new ViewSelectedFilter(view));
+    }
+
+    @Override
+    public boolean onRequestSendAccessibilityEvent(
+            ViewGroup host, View child,AccessibilityEvent event) {
+        if (child == mView && event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED) {
+            return false;
+        }
+        return super.onRequestSendAccessibilityEvent(host, child, event);
+    }
+}