summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/android/dialer/app/MainComponent.java2
-rw-r--r--java/com/android/dialer/dialpadview/DialpadFragment.java9
-rw-r--r--java/com/android/dialer/dialpadview/DialpadKeyButton.java76
-rw-r--r--java/com/android/dialer/dialpadview/DialpadView.java3
-rw-r--r--java/com/android/dialer/dialpadview/res/values/strings.xml4
-rw-r--r--java/com/android/dialer/main/impl/MainSearchController.java8
-rw-r--r--java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml203
7 files changed, 136 insertions, 169 deletions
diff --git a/java/com/android/dialer/app/MainComponent.java b/java/com/android/dialer/app/MainComponent.java
index c223723c6..ec3fc3fa6 100644
--- a/java/com/android/dialer/app/MainComponent.java
+++ b/java/com/android/dialer/app/MainComponent.java
@@ -56,6 +56,6 @@ public class MainComponent {
}
private static String getComponentName() {
- return "com.android.dialer.main.impl.MainActivity";
+ return "com.android.dialer.app.DialtactsActivity";
}
}
diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java
index 6f8d677e8..9d88d8e0f 100644
--- a/java/com/android/dialer/dialpadview/DialpadFragment.java
+++ b/java/com/android/dialer/dialpadview/DialpadFragment.java
@@ -1050,9 +1050,15 @@ public class DialpadFragment extends Fragment
digits.clear();
return true;
} else if (id == R.id.one) {
- if (isDigitsEmpty() || TextUtils.equals(this.digits.getText(), "1")) {
+ // For non-talkback users: check for empty
+ // For linear navigation users: check for "1"
+ // For explore by touch users: check for "11"
+ if (isDigitsEmpty()
+ || TextUtils.equals(this.digits.getText(), "1")
+ || TextUtils.equals(this.digits.getText(), "11")) {
// We'll try to initiate voicemail and thus we want to remove irrelevant string.
removePreviousDigitIfPossible('1');
+ removePreviousDigitIfPossible('1');
List<PhoneAccountHandle> subscriptionAccountHandles =
TelecomUtil.getSubscriptionPhoneAccounts(getActivity());
@@ -1094,6 +1100,7 @@ public class DialpadFragment extends Fragment
// (and not via other means like certain accessibility input methods).
// Remove the '0' that was input when the key was first pressed.
removePreviousDigitIfPossible('0');
+ removePreviousDigitIfPossible('0');
}
keyPressed(KeyEvent.KEYCODE_PLUS);
stopTone();
diff --git a/java/com/android/dialer/dialpadview/DialpadKeyButton.java b/java/com/android/dialer/dialpadview/DialpadKeyButton.java
index 84aca14f2..47553b6f9 100644
--- a/java/com/android/dialer/dialpadview/DialpadKeyButton.java
+++ b/java/com/android/dialer/dialpadview/DialpadKeyButton.java
@@ -19,13 +19,14 @@ package com.android.dialer.dialpadview;
import android.content.Context;
import android.graphics.RectF;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.FrameLayout;
/**
@@ -45,33 +46,21 @@ import android.widget.FrameLayout;
*/
public class DialpadKeyButton extends FrameLayout {
- /** Timeout before switching to long-click accessibility mode. */
- private static final int LONG_HOVER_TIMEOUT = ViewConfiguration.getLongPressTimeout() * 2;
-
/** Accessibility manager instance used to check touch exploration state. */
private AccessibilityManager accessibilityManager;
/** Bounds used to filter HOVER_EXIT events. */
private RectF hoverBounds = new RectF();
- /** Whether this view is currently in the long-hover state. */
- private boolean longHovered;
-
/** Alternate content description for long-hover state. */
private CharSequence longHoverContentDesc;
- /** Backup of standard content description. Used for accessibility. */
- private CharSequence backupContentDesc;
-
/** Backup of clickable property. Used for accessibility. */
private boolean wasClickable;
/** Backup of long-clickable property. Used for accessibility. */
private boolean wasLongClickable;
- /** Runnable used to trigger long-click mode for accessibility. */
- private Runnable longHoverRunnable;
-
private OnPressedListener onPressedListener;
public DialpadKeyButton(Context context, AttributeSet attrs) {
@@ -95,19 +84,6 @@ public class DialpadKeyButton extends FrameLayout {
public void setLongHoverContentDescription(CharSequence contentDescription) {
longHoverContentDesc = contentDescription;
-
- if (longHovered) {
- super.setContentDescription(longHoverContentDesc);
- }
- }
-
- @Override
- public void setContentDescription(CharSequence contentDescription) {
- if (longHovered) {
- backupContentDesc = contentDescription;
- } else {
- super.setContentDescription(contentDescription);
- }
}
@Override
@@ -139,6 +115,18 @@ public class DialpadKeyButton extends FrameLayout {
}
@Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ // If the button has a long hover description, ask talkback to announce the action follow by
+ // the description (for example "double tap and hold to call voicemail").
+ if (!TextUtils.isEmpty(longHoverContentDesc)) {
+ AccessibilityAction longClickAction =
+ new AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, longHoverContentDesc);
+ info.addAction(longClickAction);
+ }
+ }
+
+ @Override
public boolean onHoverEvent(MotionEvent event) {
// When touch exploration is turned on, lifting a finger while inside
// the button's hover target bounds should perform a click action.
@@ -148,20 +136,6 @@ public class DialpadKeyButton extends FrameLayout {
// Lift-to-type temporarily disables double-tap activation.
wasClickable = isClickable();
wasLongClickable = isLongClickable();
- if (wasLongClickable && longHoverContentDesc != null) {
- if (longHoverRunnable == null) {
- longHoverRunnable =
- new Runnable() {
- @Override
- public void run() {
- setLongHovered(true);
- announceForAccessibility(longHoverContentDesc);
- }
- };
- }
- postDelayed(longHoverRunnable, LONG_HOVER_TIMEOUT);
- }
-
setClickable(false);
setLongClickable(false);
break;
@@ -170,7 +144,6 @@ public class DialpadKeyButton extends FrameLayout {
simulateClickForAccessibility();
}
- cancelLongHover();
setClickable(wasClickable);
setLongClickable(wasLongClickable);
break;
@@ -201,27 +174,6 @@ public class DialpadKeyButton extends FrameLayout {
setPressed(false);
}
- private void setLongHovered(boolean enabled) {
- if (longHovered != enabled) {
- longHovered = enabled;
-
- // Switch between normal and alternate description, if available.
- if (enabled) {
- backupContentDesc = getContentDescription();
- super.setContentDescription(longHoverContentDesc);
- } else {
- super.setContentDescription(backupContentDesc);
- }
- }
- }
-
- private void cancelLongHover() {
- if (longHoverRunnable != null) {
- removeCallbacks(longHoverRunnable);
- }
- setLongHovered(false);
- }
-
public interface OnPressedListener {
void onPressed(View view, boolean pressed);
diff --git a/java/com/android/dialer/dialpadview/DialpadView.java b/java/com/android/dialer/dialpadview/DialpadView.java
index 0369b40ca..6d538f3d2 100644
--- a/java/com/android/dialer/dialpadview/DialpadView.java
+++ b/java/com/android/dialer/dialpadview/DialpadView.java
@@ -171,6 +171,9 @@ public class DialpadView extends LinearLayout {
} else if (BUTTON_IDS[i] == R.id.star) {
numberString = resources.getString(R.string.dialpad_star_number);
numberContentDescription = numberString;
+ } else if (BUTTON_IDS[i] == R.id.zero) {
+ numberString = numberFormat.format(i);
+ numberContentDescription = numberString;
} else {
numberString = numberFormat.format(i);
// The content description is used for Talkback key presses. The number is
diff --git a/java/com/android/dialer/dialpadview/res/values/strings.xml b/java/com/android/dialer/dialpadview/res/values/strings.xml
index 5d8d8e6a5..eb5c04f9c 100644
--- a/java/com/android/dialer/dialpadview/res/values/strings.xml
+++ b/java/com/android/dialer/dialpadview/res/values/strings.xml
@@ -30,12 +30,12 @@
<string name="description_delete_button">backspace</string>
<!-- String describing the button used to add a plus (+) symbol to the dialpad -->
- <string name="description_image_button_plus">plus</string>
+ <string name="description_image_button_plus">dial plus</string>
<!-- String describing the Voicemail ImageButton.
Used by AccessibilityService to announce the purpose of the button.
-->
- <string name="description_voicemail_button">voicemail</string>
+ <string name="description_voicemail_button">call voicemail</string>
<!-- String describing the Dial ImageButton
diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java
index 2279d56a7..b04e7b11b 100644
--- a/java/com/android/dialer/main/impl/MainSearchController.java
+++ b/java/com/android/dialer/main/impl/MainSearchController.java
@@ -50,6 +50,7 @@ import com.android.dialer.main.impl.toolbar.SearchBarListener;
import com.android.dialer.searchfragment.list.NewSearchFragment;
import com.android.dialer.searchfragment.list.NewSearchFragment.SearchFragmentListener;
import com.android.dialer.smartdial.util.SmartDialNameMatcher;
+import com.android.dialer.util.TransactionSafeActivity;
import com.google.common.base.Optional;
import java.util.ArrayList;
import java.util.List;
@@ -78,7 +79,7 @@ public class MainSearchController implements SearchBarListener {
private static final String DIALPAD_FRAGMENT_TAG = "dialpad_fragment_tag";
private static final String SEARCH_FRAGMENT_TAG = "search_fragment_tag";
- private final AppCompatActivity activity;
+ private final TransactionSafeActivity activity;
private final BottomNavBar bottomNav;
private final FloatingActionButton fab;
private final MainToolbar toolbar;
@@ -97,7 +98,7 @@ public class MainSearchController implements SearchBarListener {
private boolean requestingPermission;
public MainSearchController(
- AppCompatActivity activity,
+ TransactionSafeActivity activity,
BottomNavBar bottomNav,
FloatingActionButton fab,
MainToolbar toolbar,
@@ -201,7 +202,8 @@ public class MainSearchController implements SearchBarListener {
@Override
public void onAnimationEnd(Animation animation) {
- if (!(activity.isFinishing() || activity.isDestroyed())) {
+ if (activity.isSafeToCommitTransactions()
+ && !(activity.isFinishing() || activity.isDestroyed())) {
activity.getFragmentManager().beginTransaction().hide(dialpadFragment).commit();
}
}
diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
index c7c37d0ac..d63fdfe2f 100644
--- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
+++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
@@ -19,116 +19,119 @@
android:layout_width="match_parent"
android:layout_height="@dimen/expanded_search_bar_height"
android:background="@color/dialer_theme_color"
- app:contentInsetStart="0dp"
- app:contentInsetEnd="0dp">
-
- <com.android.dialer.main.impl.toolbar.SearchBarView
- android:id="@+id/search_view_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/search_bar_margin"
- android:minHeight="@dimen/collapsed_search_bar_height"
- android:background="@drawable/search_bar_background_rounded_corners"
- android:elevation="4dp">
-
- <RelativeLayout
- android:id="@+id/search_box_collapsed"
+ app:contentInsetEnd="0dp"
+ app:contentInsetStart="0dp">
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:background="?android:selectableItemBackground"
- android:gravity="center_vertical">
-
- <ImageView
- android:id="@+id/search_magnifying_glass"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_marginStart="8dp"
- android:layout_centerVertical="true"
- android:importantForAccessibility="no"
- android:scaleType="center"
- android:src="@drawable/quantum_ic_search_vd_theme_24"
- android:tint="@color/dialer_secondary_text_color"/>
+ android:layout_height="match_parent">
+ <com.android.dialer.main.impl.toolbar.SearchBarView
+ android:id="@+id/search_view_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/search_bar_margin"
+ android:background="@drawable/search_bar_background_rounded_corners"
+ android:elevation="4dp"
+ android:minHeight="@dimen/collapsed_search_bar_height">
- <TextView
- android:id="@+id/search_box_start_search"
- android:layout_width="wrap_content"
+ <RelativeLayout
+ android:id="@+id/search_box_collapsed"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_toEndOf="@+id/search_magnifying_glass"
- android:layout_toStartOf="@+id/voice_search_button"
- android:layout_marginStart="8dp"
- android:layout_centerVertical="true"
- android:fontFamily="sans-serif"
- android:text="@string/dialer_hint_find_contact"
- android:textColor="@color/dialer_secondary_text_color"
- android:textSize="16dp"/>
+ android:layout_gravity="center_vertical"
+ android:background="?android:selectableItemBackground"
+ android:gravity="center_vertical">
- <ImageView
- android:id="@+id/voice_search_button"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_toStartOf="@+id/main_options_menu_button"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:contentDescription="@string/description_start_voice_search"
- android:scaleType="center"
- android:src="@drawable/quantum_ic_mic_vd_theme_24"
- android:tint="@color/dialer_secondary_text_color"/>
+ <ImageView
+ android:id="@+id/search_magnifying_glass"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_marginStart="8dp"
+ android:layout_centerVertical="true"
+ android:importantForAccessibility="no"
+ android:scaleType="center"
+ android:src="@drawable/quantum_ic_search_vd_theme_24"
+ android:tint="@color/dialer_secondary_text_color"/>
- <ImageButton
- android:id="@+id/main_options_menu_button"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:layout_alignParentEnd="true"
- android:background="?android:attr/selectableItemBackgroundBorderless"
- android:contentDescription="@string/action_menu_overflow_description"
- android:scaleType="center"
- android:src="@drawable/quantum_ic_more_vert_vd_theme_24"
- android:tint="@color/dialer_secondary_text_color"/>
- </RelativeLayout>
+ <TextView
+ android:id="@+id/search_box_start_search"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_centerVertical="true"
+ android:layout_toEndOf="@+id/search_magnifying_glass"
+ android:layout_toStartOf="@+id/voice_search_button"
+ android:fontFamily="sans-serif"
+ android:text="@string/dialer_hint_find_contact"
+ android:textColor="@color/dialer_secondary_text_color"
+ android:textSize="16dp"/>
- <include layout="@layout/expanded_search_bar"/>
- </com.android.dialer.main.impl.toolbar.SearchBarView>
+ <ImageView
+ android:id="@+id/voice_search_button"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_toStartOf="@+id/main_options_menu_button"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:contentDescription="@string/description_start_voice_search"
+ android:scaleType="center"
+ android:src="@drawable/quantum_ic_mic_vd_theme_24"
+ android:tint="@color/dialer_secondary_text_color"/>
- <!-- Sets android:importantForAccessibility="no" to avoid being announced when navigating with
- talkback enabled. It will still be announced when user drag or drop contact onto it.
- This is required since drag and drop event is only sent to views are visible when drag
- starts. -->
- <com.android.dialer.app.list.RemoveView
- android:id="@+id/remove_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center_vertical"
- android:layout_margin="@dimen/search_bar_margin"
- android:contentDescription="@string/main_remove_contact"
- android:importantForAccessibility="no">
+ <ImageButton
+ android:id="@+id/main_options_menu_button"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_alignParentEnd="true"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:contentDescription="@string/action_menu_overflow_description"
+ android:scaleType="center"
+ android:src="@drawable/quantum_ic_more_vert_vd_theme_24"
+ android:tint="@color/dialer_secondary_text_color"/>
+ </RelativeLayout>
+
+ <include layout="@layout/expanded_search_bar"/>
+ </com.android.dialer.main.impl.toolbar.SearchBarView>
- <!-- We set this view's visibility to gone instead of the parent because if we hide remove
- view, it won't receive drag and accessibility events. -->
- <LinearLayout
- android:id="@+id/remove_view_content"
+ <!-- Sets android:importantForAccessibility="no" to avoid being announced when navigating with
+ talkback enabled. It will still be announced when user drag or drop contact onto it.
+ This is required since drag and drop event is only sent to views are visible when drag
+ starts. -->
+ <com.android.dialer.app.list.RemoveView
+ android:id="@+id/remove_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/dialer_theme_color"
- android:gravity="center"
- android:orientation="horizontal"
- android:visibility="gone">
+ android:layout_margin="@dimen/search_bar_margin"
+ android:layout_gravity="center_vertical"
+ android:contentDescription="@string/main_remove_contact"
+ android:importantForAccessibility="no">
- <ImageView
- android:id="@+id/remove_view_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:layout_marginBottom="8dp"
- android:src="@drawable/quantum_ic_close_vd_theme_24"
- android:tint="@color/dialer_primary_text_color_white"/>
+ <!-- We set this view's visibility to gone instead of the parent because if we hide remove
+ view, it won't receive drag and accessibility events. -->
+ <LinearLayout
+ android:id="@+id/remove_view_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/dialer_theme_color"
+ android:gravity="center"
+ android:orientation="horizontal"
+ android:visibility="gone">
- <TextView
- android:id="@+id/remove_view_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/main_remove_contact"
- android:textColor="@color/dialer_primary_text_color_white"
- android:textSize="16sp"/>
- </LinearLayout>
- </com.android.dialer.app.list.RemoveView>
+ <ImageView
+ android:id="@+id/remove_view_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:src="@drawable/quantum_ic_close_vd_theme_24"
+ android:tint="@color/dialer_primary_text_color_white"/>
+
+ <TextView
+ android:id="@+id/remove_view_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/main_remove_contact"
+ android:textColor="@color/dialer_primary_text_color_white"
+ android:textSize="16sp"/>
+ </LinearLayout>
+ </com.android.dialer.app.list.RemoveView>
+ </FrameLayout>
</com.android.dialer.main.impl.toolbar.MainToolbar>