summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-06-20 19:27:53 +0000
committerYorke Lee <yorkelee@google.com>2014-06-20 19:27:53 +0000
commit4aac9d221bd23ae582e44064ffcadc90d06b220d (patch)
tree99ba08066620c6cb6aba2c715cbf3eeb311cace2 /src
parentc4a7bd9be54759105c0a9ea235ac5bda2c1b3f8f (diff)
downloadandroid_packages_apps_PhoneCommon-4aac9d221bd23ae582e44064ffcadc90d06b220d.tar.gz
android_packages_apps_PhoneCommon-4aac9d221bd23ae582e44064ffcadc90d06b220d.tar.bz2
android_packages_apps_PhoneCommon-4aac9d221bd23ae582e44064ffcadc90d06b220d.zip
Revert "Update Emergency Dialer to match Dialer (5/5)."
This reverts commit c4a7bd9be54759105c0a9ea235ac5bda2c1b3f8f. Change-Id: I9a81515783de2ab534a611c777f10b9376ca3b7a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/phone/common/animation/AnimUtils.java108
-rw-r--r--src/com/android/phone/common/animation/AnimationListenerAdapter.java48
-rw-r--r--src/com/android/phone/common/dialpad/DialpadKeyButton.java229
-rw-r--r--src/com/android/phone/common/dialpad/DialpadTextView.java72
-rw-r--r--src/com/android/phone/common/dialpad/DialpadView.java259
-rw-r--r--src/com/android/phone/common/dialpad/DigitsEditText.java94
-rw-r--r--src/com/android/phone/common/util/ViewUtil.java97
7 files changed, 0 insertions, 907 deletions
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.
- * <p>
- * When touch exploration mode is enabled for accessibility, this class
- * implements the lift-to-type interaction model:
- * <ul>
- * <li>Hovering over the button will cause it to gain accessibility focus
- * <li>Removing the hover pointer while inside the bounds of the button will
- * perform a click action
- * <li>If long-click is supported, hovering over the button for a longer period
- * of time will switch to the long-click action
- * <li>Moving the hover pointer outside of the bounds of the button will restore
- * to the normal click action
- * <ul>
- */
-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);
- }
-}