From 4aac9d221bd23ae582e44064ffcadc90d06b220d Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 20 Jun 2014 19:27:53 +0000 Subject: Revert "Update Emergency Dialer to match Dialer (5/5)." This reverts commit c4a7bd9be54759105c0a9ea235ac5bda2c1b3f8f. Change-Id: I9a81515783de2ab534a611c777f10b9376ca3b7a --- Android.mk | 7 +- AndroidManifest.xml | 21 -- res/anim/dialpad_slide_in_bottom.xml | 20 -- res/anim/dialpad_slide_in_right.xml | 21 -- res/anim/dialpad_slide_out_bottom.xml | 20 -- res/anim/dialpad_slide_out_right.xml | 21 -- res/drawable-hdpi/ic_dialpad_delete.png | Bin 805 -> 0 bytes res/drawable-hdpi/ic_dialpad_vm.png | Bin 554 -> 0 bytes res/drawable-hdpi/ic_overflow_menu.png | Bin 503 -> 0 bytes res/drawable-mdpi/ic_dialpad_delete.png | Bin 669 -> 0 bytes res/drawable-mdpi/ic_dialpad_vm.png | Bin 450 -> 0 bytes res/drawable-mdpi/ic_overflow_menu.png | Bin 424 -> 0 bytes res/drawable-xhdpi/ic_dialpad_delete.png | Bin 1110 -> 0 bytes res/drawable-xhdpi/ic_dialpad_vm.png | Bin 672 -> 0 bytes res/drawable-xhdpi/ic_overflow_menu.png | Bin 550 -> 0 bytes res/drawable-xxhdpi/ic_dialpad_delete.png | Bin 1745 -> 0 bytes res/drawable-xxhdpi/ic_dialpad_vm.png | Bin 1502 -> 0 bytes res/drawable-xxhdpi/ic_overflow_menu.png | Bin 1384 -> 0 bytes res/drawable/btn_dialpad_key.xml | 18 -- res/layout-land/dialpad_key.xml | 43 ---- res/layout-land/dialpad_key_one.xml | 48 ---- res/layout/dialpad.xml | 111 --------- res/layout/dialpad_key.xml | 35 --- res/layout/dialpad_key_one.xml | 41 ---- res/layout/dialpad_view.xml | 94 -------- res/values-land/dimens.xml | 20 -- res/values/animation_constants.xml | 21 -- res/values/attrs.xml | 21 -- res/values/colors.xml | 26 --- res/values/dimens.xml | 55 ----- res/values/strings.xml | 84 ------- res/values/styles.xml | 83 ------- .../android/phone/common/animation/AnimUtils.java | 108 --------- .../common/animation/AnimationListenerAdapter.java | 48 ---- .../phone/common/dialpad/DialpadKeyButton.java | 229 ------------------ .../phone/common/dialpad/DialpadTextView.java | 72 ------ .../android/phone/common/dialpad/DialpadView.java | 259 --------------------- .../phone/common/dialpad/DigitsEditText.java | 94 -------- src/com/android/phone/common/util/ViewUtil.java | 97 -------- 39 files changed, 3 insertions(+), 1714 deletions(-) delete mode 100644 AndroidManifest.xml delete mode 100644 res/anim/dialpad_slide_in_bottom.xml delete mode 100644 res/anim/dialpad_slide_in_right.xml delete mode 100644 res/anim/dialpad_slide_out_bottom.xml delete mode 100644 res/anim/dialpad_slide_out_right.xml delete mode 100644 res/drawable-hdpi/ic_dialpad_delete.png delete mode 100644 res/drawable-hdpi/ic_dialpad_vm.png delete mode 100644 res/drawable-hdpi/ic_overflow_menu.png delete mode 100644 res/drawable-mdpi/ic_dialpad_delete.png delete mode 100644 res/drawable-mdpi/ic_dialpad_vm.png delete mode 100644 res/drawable-mdpi/ic_overflow_menu.png delete mode 100644 res/drawable-xhdpi/ic_dialpad_delete.png delete mode 100644 res/drawable-xhdpi/ic_dialpad_vm.png delete mode 100644 res/drawable-xhdpi/ic_overflow_menu.png delete mode 100644 res/drawable-xxhdpi/ic_dialpad_delete.png delete mode 100644 res/drawable-xxhdpi/ic_dialpad_vm.png delete mode 100644 res/drawable-xxhdpi/ic_overflow_menu.png delete mode 100644 res/drawable/btn_dialpad_key.xml delete mode 100644 res/layout-land/dialpad_key.xml delete mode 100644 res/layout-land/dialpad_key_one.xml delete mode 100644 res/layout/dialpad.xml delete mode 100644 res/layout/dialpad_key.xml delete mode 100644 res/layout/dialpad_key_one.xml delete mode 100644 res/layout/dialpad_view.xml delete mode 100644 res/values-land/dimens.xml delete mode 100644 res/values/animation_constants.xml delete mode 100644 res/values/attrs.xml delete mode 100644 res/values/colors.xml delete mode 100644 res/values/dimens.xml delete mode 100644 res/values/strings.xml delete mode 100644 res/values/styles.xml delete mode 100644 src/com/android/phone/common/animation/AnimUtils.java delete mode 100644 src/com/android/phone/common/animation/AnimationListenerAdapter.java delete mode 100644 src/com/android/phone/common/dialpad/DialpadKeyButton.java delete mode 100644 src/com/android/phone/common/dialpad/DialpadTextView.java delete mode 100644 src/com/android/phone/common/dialpad/DialpadView.java delete mode 100644 src/com/android/phone/common/dialpad/DigitsEditText.java delete mode 100644 src/com/android/phone/common/util/ViewUtil.java diff --git a/Android.mk b/Android.mk index 3d1bb08..f01263e 100644 --- a/Android.mk +++ b/Android.mk @@ -13,12 +13,11 @@ # limitations under the License. LOCAL_PATH:= $(call my-dir) + include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_RESOURCE_FILES := $(addprefix $(LOCAL_PATH)/, res) -LOCAL_PACKAGE_NAME := com.android.phone.common +LOCAL_MODULE := com.android.phone.shared -include $(BUILD_PACKAGE) -include $(CLEAR_VARS) +include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/AndroidManifest.xml b/AndroidManifest.xml deleted file mode 100644 index ff2935f..0000000 --- a/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - diff --git a/res/anim/dialpad_slide_in_bottom.xml b/res/anim/dialpad_slide_in_bottom.xml deleted file mode 100644 index 07748b5..0000000 --- a/res/anim/dialpad_slide_in_bottom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - diff --git a/res/anim/dialpad_slide_in_right.xml b/res/anim/dialpad_slide_in_right.xml deleted file mode 100644 index d87e82a..0000000 --- a/res/anim/dialpad_slide_in_right.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - diff --git a/res/anim/dialpad_slide_out_bottom.xml b/res/anim/dialpad_slide_out_bottom.xml deleted file mode 100644 index c80c8ed..0000000 --- a/res/anim/dialpad_slide_out_bottom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - diff --git a/res/anim/dialpad_slide_out_right.xml b/res/anim/dialpad_slide_out_right.xml deleted file mode 100644 index a29c1a0..0000000 --- a/res/anim/dialpad_slide_out_right.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - diff --git a/res/drawable-hdpi/ic_dialpad_delete.png b/res/drawable-hdpi/ic_dialpad_delete.png deleted file mode 100644 index e588d90..0000000 Binary files a/res/drawable-hdpi/ic_dialpad_delete.png and /dev/null differ diff --git a/res/drawable-hdpi/ic_dialpad_vm.png b/res/drawable-hdpi/ic_dialpad_vm.png deleted file mode 100644 index 9501300..0000000 Binary files a/res/drawable-hdpi/ic_dialpad_vm.png and /dev/null differ diff --git a/res/drawable-hdpi/ic_overflow_menu.png b/res/drawable-hdpi/ic_overflow_menu.png deleted file mode 100644 index 262e9df..0000000 Binary files a/res/drawable-hdpi/ic_overflow_menu.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_dialpad_delete.png b/res/drawable-mdpi/ic_dialpad_delete.png deleted file mode 100644 index 64a52d0..0000000 Binary files a/res/drawable-mdpi/ic_dialpad_delete.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_dialpad_vm.png b/res/drawable-mdpi/ic_dialpad_vm.png deleted file mode 100644 index f32d8bf..0000000 Binary files a/res/drawable-mdpi/ic_dialpad_vm.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_overflow_menu.png b/res/drawable-mdpi/ic_overflow_menu.png deleted file mode 100644 index 0e720dd..0000000 Binary files a/res/drawable-mdpi/ic_overflow_menu.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_dialpad_delete.png b/res/drawable-xhdpi/ic_dialpad_delete.png deleted file mode 100644 index 87bc113..0000000 Binary files a/res/drawable-xhdpi/ic_dialpad_delete.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_dialpad_vm.png b/res/drawable-xhdpi/ic_dialpad_vm.png deleted file mode 100644 index 5d87c50..0000000 Binary files a/res/drawable-xhdpi/ic_dialpad_vm.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_overflow_menu.png b/res/drawable-xhdpi/ic_overflow_menu.png deleted file mode 100644 index 9156076..0000000 Binary files a/res/drawable-xhdpi/ic_overflow_menu.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_dialpad_delete.png b/res/drawable-xxhdpi/ic_dialpad_delete.png deleted file mode 100644 index 186508a..0000000 Binary files a/res/drawable-xxhdpi/ic_dialpad_delete.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_dialpad_vm.png b/res/drawable-xxhdpi/ic_dialpad_vm.png deleted file mode 100644 index ac20fab..0000000 Binary files a/res/drawable-xxhdpi/ic_dialpad_vm.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_overflow_menu.png b/res/drawable-xxhdpi/ic_overflow_menu.png deleted file mode 100644 index 92526f5..0000000 Binary files a/res/drawable-xxhdpi/ic_overflow_menu.png and /dev/null differ diff --git a/res/drawable/btn_dialpad_key.xml b/res/drawable/btn_dialpad_key.xml deleted file mode 100644 index a4cb088..0000000 --- a/res/drawable/btn_dialpad_key.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/res/layout-land/dialpad_key.xml b/res/layout-land/dialpad_key.xml deleted file mode 100644 index 29e6bf1..0000000 --- a/res/layout-land/dialpad_key.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/layout-land/dialpad_key_one.xml b/res/layout-land/dialpad_key_one.xml deleted file mode 100644 index 2890fd1..0000000 --- a/res/layout-land/dialpad_key_one.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - diff --git a/res/layout/dialpad.xml b/res/layout/dialpad.xml deleted file mode 100644 index 1fc1f6c..0000000 --- a/res/layout/dialpad.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/layout/dialpad_key.xml b/res/layout/dialpad_key.xml deleted file mode 100644 index d5f47a4..0000000 --- a/res/layout/dialpad_key.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/layout/dialpad_key_one.xml b/res/layout/dialpad_key_one.xml deleted file mode 100644 index dfb444a..0000000 --- a/res/layout/dialpad_key_one.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - diff --git a/res/layout/dialpad_view.xml b/res/layout/dialpad_view.xml deleted file mode 100644 index 68de527..0000000 --- a/res/layout/dialpad_view.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml deleted file mode 100644 index 96547f0..0000000 --- a/res/values-land/dimens.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - 10dp - 25dp - diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml deleted file mode 100644 index f8523e3..0000000 --- a/res/values/animation_constants.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - 250 - 532 - 257 - diff --git a/res/values/attrs.xml b/res/values/attrs.xml deleted file mode 100644 index 09620a8..0000000 --- a/res/values/attrs.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/res/values/colors.xml b/res/values/colors.xml deleted file mode 100644 index d38428c..0000000 --- a/res/values/colors.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - #fcfcfc - #ececec - #26c6da - #999999 - #666666 - #dadada - #b3b3b3 - diff --git a/res/values/dimens.xml b/res/values/dimens.xml deleted file mode 100644 index d681d9d..0000000 --- a/res/values/dimens.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - 36sp - 8sp - 23sp - 28sp - 64dp - 2dp - 13dp - - 65dp - 18sp - 5dp - 36dp - 64dp - 16dp - 10dp - 3dp - 2dp - 2dp - 100dp - - 56dp - - 56dp - - 28dp - - 3dp - - 88dp - - 16dp - - 16dp - - 4dp - diff --git a/res/values/strings.xml b/res/values/strings.xml deleted file mode 100644 index bfa63a9..0000000 --- a/res/values/strings.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - * - - # - - - + - - - - ABC - - DEF - - GHI - - JKL - - MNO - - PQRS - - TUV - - WXYZ - - - - - - - More options - - - backspace - - - plus - - - voicemail - - diff --git a/res/values/styles.xml b/res/values/styles.xml deleted file mode 100644 index 5297aa1..0000000 --- a/res/values/styles.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/com/android/phone/common/animation/AnimUtils.java b/src/com/android/phone/common/animation/AnimUtils.java deleted file mode 100644 index 35ac107..0000000 --- a/src/com/android/phone/common/animation/AnimUtils.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.phone.common.animation; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.view.View; -import android.view.ViewPropertyAnimator; -import android.view.animation.Interpolator; -import android.view.animation.PathInterpolator; - -public class AnimUtils { - public static final int DEFAULT_DURATION = -1; - public static final Interpolator EASE_IN = new PathInterpolator(0.0f, 0.0f, 0.2f, 1.0f); - public static final Interpolator EASE_OUT = new PathInterpolator(0.4f, 0.0f, 1.0f, 1.0f); - public static final Interpolator EASE_OUT_EASE_IN = new PathInterpolator(0.4f, 0, 0.2f, 1); - - public static class AnimationCallback { - public void onAnimationEnd() {} - public void onAnimationCancel() {} - } - - public static void crossFadeViews(View fadeIn, View fadeOut, int duration) { - fadeIn(fadeIn, duration); - fadeOut(fadeOut, duration); - } - - public static void fadeOut(View fadeOut, int duration) { - fadeOut(fadeOut, duration, null); - } - - public static void fadeOut(final View fadeOut, int duration, final AnimationCallback callback) { - fadeOut.setAlpha(1); - final ViewPropertyAnimator animator = fadeOut.animate(); - animator.cancel(); - animator.alpha(0).withLayer().setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - fadeOut.setVisibility(View.GONE); - if (callback != null) { - callback.onAnimationEnd(); - } - } - - @Override - public void onAnimationCancel(Animator animation) { - fadeOut.setVisibility(View.GONE); - fadeOut.setAlpha(0); - if (callback != null) { - callback.onAnimationCancel(); - } - } - }); - if (duration != DEFAULT_DURATION) { - animator.setDuration(duration); - } - animator.start(); - } - - public static void fadeIn(View fadeIn, int duration) { - fadeIn(fadeIn, duration, null); - } - - public static void fadeIn(final View fadeIn, int duration, final AnimationCallback callback) { - fadeIn.setAlpha(0); - final ViewPropertyAnimator animator = fadeIn.animate(); - animator.cancel(); - animator.alpha(1).withLayer().setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - fadeIn.setVisibility(View.VISIBLE); - } - - @Override - public void onAnimationCancel(Animator animation) { - fadeIn.setAlpha(1); - if (callback != null) { - callback.onAnimationCancel(); - } - } - - @Override - public void onAnimationEnd(Animator animation) { - if (callback != null) { - callback.onAnimationEnd(); - } - } - }); - if (duration != DEFAULT_DURATION) { - animator.setDuration(duration); - } - animator.start(); - } -} diff --git a/src/com/android/phone/common/animation/AnimationListenerAdapter.java b/src/com/android/phone/common/animation/AnimationListenerAdapter.java deleted file mode 100644 index d8f3fa6..0000000 --- a/src/com/android/phone/common/animation/AnimationListenerAdapter.java +++ /dev/null @@ -1,48 +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.phone.common.animation; - -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; - -/** - * Provides empty implementations of the methods in {@link AnimationListener} - * for convenience reasons. - */ -public class AnimationListenerAdapter implements AnimationListener { - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationStart(Animation animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationEnd(Animation animation) { - } - - /** - * {@inheritDoc} - */ - @Override - public void onAnimationRepeat(Animation animation) { - } -} diff --git a/src/com/android/phone/common/dialpad/DialpadKeyButton.java b/src/com/android/phone/common/dialpad/DialpadKeyButton.java deleted file mode 100644 index 4e3781c..0000000 --- a/src/com/android/phone/common/dialpad/DialpadKeyButton.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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. - */ - -package com.android.phone.common.dialpad; - -import android.content.Context; -import android.graphics.Rect; -import android.os.Bundle; -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.widget.FrameLayout; - -/** - * Custom class for dialpad buttons. - *

- * When touch exploration mode is enabled for accessibility, this class - * implements the lift-to-type interaction model: - *

    - *
  • Hovering over the button will cause it to gain accessibility focus - *
  • Removing the hover pointer while inside the bounds of the button will - * perform a click action - *
  • If long-click is supported, hovering over the button for a longer period - * of time will switch to the long-click action - *
  • Moving the hover pointer outside of the bounds of the button will restore - * to the normal click action - *
      - */ -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 mAccessibilityManager; - - /** Bounds used to filter HOVER_EXIT events. */ - private Rect mHoverBounds = new Rect(); - - /** Whether this view is currently in the long-hover state. */ - private boolean mLongHovered; - - /** Alternate content description for long-hover state. */ - private CharSequence mLongHoverContentDesc; - - /** Backup of standard content description. Used for accessibility. */ - private CharSequence mBackupContentDesc; - - /** Backup of clickable property. Used for accessibility. */ - private boolean mWasClickable; - - /** Backup of long-clickable property. Used for accessibility. */ - private boolean mWasLongClickable; - - /** Runnable used to trigger long-click mode for accessibility. */ - private Runnable mLongHoverRunnable; - - public interface OnPressedListener { - public void onPressed(View view, boolean pressed); - } - - private OnPressedListener mOnPressedListener; - - public void setOnPressedListener(OnPressedListener onPressedListener) { - mOnPressedListener = onPressedListener; - } - - public DialpadKeyButton(Context context, AttributeSet attrs) { - super(context, attrs); - initForAccessibility(context); - } - - public DialpadKeyButton(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - initForAccessibility(context); - } - - private void initForAccessibility(Context context) { - mAccessibilityManager = (AccessibilityManager) context.getSystemService( - Context.ACCESSIBILITY_SERVICE); - } - - public void setLongHoverContentDescription(CharSequence contentDescription) { - mLongHoverContentDesc = contentDescription; - - if (mLongHovered) { - super.setContentDescription(mLongHoverContentDesc); - } - } - - @Override - public void setContentDescription(CharSequence contentDescription) { - if (mLongHovered) { - mBackupContentDesc = contentDescription; - } else { - super.setContentDescription(contentDescription); - } - } - - @Override - public void setPressed(boolean pressed) { - super.setPressed(pressed); - if (mOnPressedListener != null) { - mOnPressedListener.onPressed(this, pressed); - } - } - - @Override - public void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - - mHoverBounds.left = getPaddingLeft(); - mHoverBounds.right = w - getPaddingRight(); - mHoverBounds.top = getPaddingTop(); - mHoverBounds.bottom = h - getPaddingBottom(); - } - - @Override - public boolean performAccessibilityAction(int action, Bundle arguments) { - if (action == AccessibilityNodeInfo.ACTION_CLICK) { - simulateClickForAccessibility(); - return true; - } - - return super.performAccessibilityAction(action, arguments); - } - - @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. - if (mAccessibilityManager.isEnabled() - && mAccessibilityManager.isTouchExplorationEnabled()) { - switch (event.getActionMasked()) { - case MotionEvent.ACTION_HOVER_ENTER: - // Lift-to-type temporarily disables double-tap activation. - mWasClickable = isClickable(); - mWasLongClickable = isLongClickable(); - if (mWasLongClickable && mLongHoverContentDesc != null) { - if (mLongHoverRunnable == null) { - mLongHoverRunnable = new Runnable() { - @Override - public void run() { - setLongHovered(true); - announceForAccessibility(mLongHoverContentDesc); - } - }; - } - postDelayed(mLongHoverRunnable, LONG_HOVER_TIMEOUT); - } - - setClickable(false); - setLongClickable(false); - break; - case MotionEvent.ACTION_HOVER_EXIT: - if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) { - if (mLongHovered) { - performLongClick(); - } else { - simulateClickForAccessibility(); - } - } - - cancelLongHover(); - setClickable(mWasClickable); - setLongClickable(mWasLongClickable); - break; - } - } - - return super.onHoverEvent(event); - } - - /** - * When accessibility is on, simulate press and release to preserve the - * semantic meaning of performClick(). Required for Braille support. - */ - private void simulateClickForAccessibility() { - // Checking the press state prevents double activation. - if (isPressed()) { - return; - } - - setPressed(true); - - // Stay consistent with performClick() by sending the event after - // setting the pressed state but before performing the action. - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); - - setPressed(false); - } - - private void setLongHovered(boolean enabled) { - if (mLongHovered != enabled) { - mLongHovered = enabled; - - // Switch between normal and alternate description, if available. - if (enabled) { - mBackupContentDesc = getContentDescription(); - super.setContentDescription(mLongHoverContentDesc); - } else { - super.setContentDescription(mBackupContentDesc); - } - } - } - - private void cancelLongHover() { - if (mLongHoverRunnable != null) { - removeCallbacks(mLongHoverRunnable); - } - setLongHovered(false); - } -} diff --git a/src/com/android/phone/common/dialpad/DialpadTextView.java b/src/com/android/phone/common/dialpad/DialpadTextView.java deleted file mode 100644 index 2802b32..0000000 --- a/src/com/android/phone/common/dialpad/DialpadTextView.java +++ /dev/null @@ -1,72 +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.phone.common.dialpad; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.widget.TextView; - -/** - * This is a custom text view intended only for rendering the numerals (and star and pound) on the - * dialpad. TextView has built in top/bottom padding to help account for ascenders/descenders. - * - * Since vertical space is at a premium on the dialpad, particularly if the font size is scaled to - * a larger default, for the dialpad we use this class to more precisely render characters according - * to the precise amount of space they need. - */ -public class DialpadTextView extends TextView { - private Rect mTextBounds = new Rect(); - private String mTextStr; - - public DialpadTextView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - /** - * Draw the text to fit within the height/width which have been specified during measurement. - */ - @Override - public void draw(Canvas canvas) { - Paint paint = getPaint(); - - // Without this, the draw does not respect the style's specified text color. - paint.setColor(getCurrentTextColor()); - - // The text bounds values are relative and can be negative,, so rather than specifying a - // standard origin such as 0, 0, we need to use negative of the left/top bounds. - // For example, the bounds may be: Left: 11, Right: 37, Top: -77, Bottom: 0 - canvas.drawText(mTextStr, -mTextBounds.left, -mTextBounds.top, paint); - } - - /** - * Calculate the pixel-accurate bounds of the text when rendered, and use that to specify the - * height and width. - */ - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - mTextStr = getText().toString(); - getPaint().getTextBounds(mTextStr, 0, mTextStr.length(), mTextBounds); - - int width = resolveSize(mTextBounds.width(), widthMeasureSpec); - int height = resolveSize(mTextBounds.height(), heightMeasureSpec); - setMeasuredDimension(width, height); - } -} diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java deleted file mode 100644 index 6f9dd41..0000000 --- a/src/com/android/phone/common/dialpad/DialpadView.java +++ /dev/null @@ -1,259 +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.phone.common.dialpad; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.content.Context; -import android.content.res.ColorStateList; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.PorterDuff; -import android.graphics.drawable.RippleDrawable; -import android.util.AttributeSet; -import android.util.Log; -import android.view.MotionEvent; -import android.view.View; -import android.widget.EditText; -import android.widget.ImageButton; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.android.phone.common.R; -import com.android.phone.common.animation.AnimUtils; - -/** - * View that displays a twelve-key phone dialpad. - */ -public class DialpadView extends LinearLayout { - private static final String TAG = DialpadView.class.getSimpleName(); - - private static final double DELAY_MULTIPLIER = 0.66; - private static final double DURATION_MULTIPLIER = 0.8; - - private EditText mDigits; - private ImageButton mDelete; - private View mOverflowMenuButton; - private ColorStateList mRippleColor; - - private boolean mCanDigitsBeEdited; - - private final int[] mButtonIds = new int[] {R.id.zero, R.id.one, R.id.two, R.id.three, - R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine, R.id.star, - R.id.pound}; - - // For animation. - private static final int KEY_FRAME_DURATION = 33; - - private int mTranslateDistance; - - public DialpadView(Context context) { - this(context, null); - } - - public DialpadView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public DialpadView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Dialpad); - mRippleColor = a.getColorStateList(R.styleable.Dialpad_dialpad_key_button_touch_tint); - a.recycle(); - - mTranslateDistance = getResources().getDimensionPixelSize( - R.dimen.dialpad_key_button_translate_y); - } - - @Override - protected void onFinishInflate() { - setupKeypad(); - mDigits = (EditText) findViewById(R.id.digits); - mDelete = (ImageButton) findViewById(R.id.deleteButton); - mOverflowMenuButton = findViewById(R.id.dialpad_overflow); - } - - private void setupKeypad() { - final int[] numberIds = new int[] {R.string.dialpad_0_number, R.string.dialpad_1_number, - R.string.dialpad_2_number, R.string.dialpad_3_number, R.string.dialpad_4_number, - R.string.dialpad_5_number, R.string.dialpad_6_number, R.string.dialpad_7_number, - R.string.dialpad_8_number, R.string.dialpad_9_number, R.string.dialpad_star_number, - R.string.dialpad_pound_number}; - - final int[] letterIds = new int[] {R.string.dialpad_0_letters, R.string.dialpad_1_letters, - R.string.dialpad_2_letters, R.string.dialpad_3_letters, R.string.dialpad_4_letters, - R.string.dialpad_5_letters, R.string.dialpad_6_letters, R.string.dialpad_7_letters, - R.string.dialpad_8_letters, R.string.dialpad_9_letters, - R.string.dialpad_star_letters, R.string.dialpad_pound_letters}; - - final Resources resources = getContext().getResources(); - - DialpadKeyButton dialpadKey; - TextView numberView; - TextView lettersView; - - for (int i = 0; i < mButtonIds.length; i++) { - dialpadKey = (DialpadKeyButton) findViewById(mButtonIds[i]); - numberView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_number); - lettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters); - final String numberString = resources.getString(numberIds[i]); - final RippleDrawable rippleBackground = - (RippleDrawable) resources.getDrawable(R.drawable.btn_dialpad_key); - if (mRippleColor != null) { - rippleBackground.setColor(mRippleColor); - } - - numberView.setText(numberString); - numberView.setElegantTextHeight(false); - dialpadKey.setContentDescription(numberString); - dialpadKey.setBackground(rippleBackground); - - if (lettersView != null) { - lettersView.setText(resources.getString(letterIds[i])); - } - } - - final DialpadKeyButton one = (DialpadKeyButton) findViewById(R.id.one); - one.setLongHoverContentDescription( - resources.getText(R.string.description_voicemail_button)); - - final DialpadKeyButton zero = (DialpadKeyButton) findViewById(R.id.zero); - zero.setLongHoverContentDescription( - resources.getText(R.string.description_image_button_plus)); - - } - - public void setShowVoicemailButton(boolean show) { - View view = findViewById(R.id.dialpad_key_voicemail); - if (view != null) { - view.setVisibility(show ? View.VISIBLE : View.INVISIBLE); - } - } - - /** - * Whether or not the digits above the dialer can be edited. - * - * @param canBeEdited If true, the backspace button will be shown and the digits EditText - * will be configured to allow text manipulation. - */ - public void setCanDigitsBeEdited(boolean canBeEdited) { - View deleteButton = findViewById(R.id.deleteButton); - deleteButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE); - View overflowMenuButton = findViewById(R.id.dialpad_overflow); - overflowMenuButton.setVisibility(canBeEdited ? View.VISIBLE : View.GONE); - - EditText digits = (EditText) findViewById(R.id.digits); - digits.setClickable(canBeEdited); - digits.setLongClickable(canBeEdited); - digits.setFocusableInTouchMode(canBeEdited); - digits.setCursorVisible(false); - - mCanDigitsBeEdited = canBeEdited; - } - - public boolean canDigitsBeEdited() { - return mCanDigitsBeEdited; - } - - /** - * Always returns true for onHoverEvent callbacks, to fix problems with accessibility due to - * the dialpad overlaying other fragments. - */ - @Override - public boolean onHoverEvent(MotionEvent event) { - return true; - } - - public void animateShow() { - // This is a hack; without this, the setTranslationY is delayed in being applied, and the - // numbers appear at their original position (0) momentarily before animating. - final AnimatorListenerAdapter showListener = new AnimatorListenerAdapter() {}; - - for (int i = 0; i < mButtonIds.length; i++) { - int delay = (int)(getKeyButtonAnimationDelay(mButtonIds[i]) * DELAY_MULTIPLIER); - int duration = - (int)(getKeyButtonAnimationDuration(mButtonIds[i]) * DURATION_MULTIPLIER); - final DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(mButtonIds[i]); - - dialpadKey.setTranslationY(mTranslateDistance); - dialpadKey.animate() - .translationY(0) - .setInterpolator(AnimUtils.EASE_OUT_EASE_IN) - .setStartDelay(delay) - .setDuration(duration) - .setListener(showListener) - .start(); - } - } - - public EditText getDigits() { - return mDigits; - } - - public ImageButton getDeleteButton() { - return mDelete; - } - - public View getOverflowMenuButton() { - return mOverflowMenuButton; - } - - private int getKeyButtonAnimationDelay(int buttonId) { - switch(buttonId) { - case R.id.one: return KEY_FRAME_DURATION * 1; - case R.id.two: return KEY_FRAME_DURATION * 2; - case R.id.three: return KEY_FRAME_DURATION * 3; - case R.id.four: return KEY_FRAME_DURATION * 4; - case R.id.five: return KEY_FRAME_DURATION * 5; - case R.id.six: return KEY_FRAME_DURATION * 6; - case R.id.seven: return KEY_FRAME_DURATION * 7; - case R.id.eight: return KEY_FRAME_DURATION * 8; - case R.id.nine: return KEY_FRAME_DURATION * 9; - case R.id.star: return KEY_FRAME_DURATION * 10; - case R.id.zero: - case R.id.pound: - return KEY_FRAME_DURATION * 11; - } - - Log.wtf(TAG, "Attempted to get animation delay for invalid key button id."); - return 0; - } - - private int getKeyButtonAnimationDuration(int buttonId) { - switch(buttonId) { - case R.id.one: - case R.id.two: - case R.id.three: - case R.id.four: - case R.id.five: - case R.id.six: - return KEY_FRAME_DURATION * 10; - case R.id.seven: - case R.id.eight: - case R.id.nine: - return KEY_FRAME_DURATION * 9; - case R.id.star: - case R.id.zero: - case R.id.pound: - return KEY_FRAME_DURATION * 8; - } - - Log.wtf(TAG, "Attempted to get animation duration for invalid key button id."); - return 0; - } -} diff --git a/src/com/android/phone/common/dialpad/DigitsEditText.java b/src/com/android/phone/common/dialpad/DigitsEditText.java deleted file mode 100644 index b2022aa..0000000 --- a/src/com/android/phone/common/dialpad/DigitsEditText.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - */ - -package com.android.phone.common.dialpad; - -import android.content.Context; -import android.graphics.Paint; -import android.graphics.Rect; -import android.text.InputType; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.MotionEvent; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import com.android.phone.common.R; - -/** - * EditText which suppresses IME show up. - */ -public class DigitsEditText extends EditText { - // Only scale the text down to 66% smaller at most. - private static final float MIN_TEXT_RESIZE_RATIO = 0.66f; - private final float mOriginalTextSize; - - public DigitsEditText(Context context, AttributeSet attrs) { - super(context, attrs); - mOriginalTextSize = getTextSize(); - setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - setShowSoftInputOnFocus(false); - } - - @Override - protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { - super.onFocusChanged(focused, direction, previouslyFocusedRect); - final InputMethodManager imm = ((InputMethodManager) getContext() - .getSystemService(Context.INPUT_METHOD_SERVICE)); - if (imm != null && imm.isActive(this)) { - imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0); - } - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - final boolean ret = super.onTouchEvent(event); - // Must be done after super.onTouchEvent() - final InputMethodManager imm = ((InputMethodManager) getContext() - .getSystemService(Context.INPUT_METHOD_SERVICE)); - if (imm != null && imm.isActive(this)) { - imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0); - } - return ret; - } - - @Override - protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { - super.onTextChanged(text, start, lengthBefore, lengthAfter); - resizeText(getWidth()); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - resizeText(w); - } - - private void resizeText(int width) { - if (width == 0) { - return; - } - final Paint paint = getPaint(); - setTextSize(TypedValue.COMPLEX_UNIT_PX, mOriginalTextSize); - - float ratio = width / paint.measureText(getText().toString()); - if (ratio <= 1.0f) { - setTextSize(TypedValue.COMPLEX_UNIT_PX, - mOriginalTextSize * Math.max(MIN_TEXT_RESIZE_RATIO, ratio)); - } - } -} diff --git a/src/com/android/phone/common/util/ViewUtil.java b/src/com/android/phone/common/util/ViewUtil.java deleted file mode 100644 index 171eee0..0000000 --- a/src/com/android/phone/common/util/ViewUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - */ - -package com.android.phone.common.util; - -import android.content.res.Resources; -import android.graphics.Outline; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import com.android.phone.common.R; - -/** - * Provides static functions to work with views - */ -public class ViewUtil { - private ViewUtil() {} - - /** - * Returns the width as specified in the LayoutParams - * @throws IllegalStateException Thrown if the view's width is unknown before a layout pass - * s - */ - public static int getConstantPreLayoutWidth(View view) { - // We haven't been layed out yet, so get the size from the LayoutParams - final ViewGroup.LayoutParams p = view.getLayoutParams(); - if (p.width < 0) { - throw new IllegalStateException("Expecting view's width to be a constant rather " + - "than a result of the layout pass"); - } - return p.width; - } - - /** - * Returns a boolean indicating whether or not the view's layout direction is RTL - * - * @param view - A valid view - * @return True if the view's layout direction is RTL - */ - public static boolean isViewLayoutRtl(View view) { - return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; - } - - /** - * Configures the floating action button, clipping it to a circle and setting its translation z. - * @param view The float action button's view. - * @param res The resources file. - */ - public static void setupFloatingActionButton(View view, Resources res) { - // Once layout is complete and the floating action button has been assigned a width and - // height, assign the outline. - view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom) { - final Outline outline = new Outline(); - final int minDimension = Math.min(right - left, bottom - top); - if (minDimension <= 0) { - return; - } - outline.setRoundRect(0, 0, right - left, bottom - top, minDimension / 2); - v.setOutline(outline); - } - }); - view.setTranslationZ( - res.getDimensionPixelSize(R.dimen.floating_action_button_translation_z)); - } - - /** - * Adds padding to the bottom of the given {@link ListView} so that the floating action button - * does not obscure any content. - * - * @param listView to add the padding to - * @param res valid resources object - */ - public static void addBottomPaddingToListViewForFab(ListView listView, Resources res) { - final int fabPadding = res.getDimensionPixelSize( - R.dimen.floating_action_button_list_bottom_padding); - listView.setPaddingRelative(listView.getPaddingStart(), listView.getPaddingTop(), - listView.getPaddingEnd(), listView.getPaddingBottom() + fabPadding); - listView.setClipToPadding(false); - } -} -- cgit v1.2.3