diff options
author | Evan Charlton <evanc@google.com> | 2014-03-07 18:23:17 -0800 |
---|---|---|
committer | Evan Charlton <evanc@google.com> | 2014-03-07 18:23:17 -0800 |
commit | c52ad65afa67bec7b083299714ee624cd94ecef3 (patch) | |
tree | 702c363690d1f06ee1142ce9326dc6a19141cde4 /InCallUI/src | |
parent | 227ca6c58b27f28d0cfe27a942088be6d6aa97e0 (diff) | |
parent | 5510dea8156517d56cf2104e113f9f9357d42b61 (diff) |
resolved conflicts for merge of a389ad35 to master-nova
Change-Id: I165b2592b7c6edc29e1ba49ddf293d9c3dfaa726
Diffstat (limited to 'InCallUI/src')
3 files changed, 180 insertions, 14 deletions
diff --git a/InCallUI/src/com/android/incallui/DialpadFragment.java b/InCallUI/src/com/android/incallui/DialpadFragment.java index 5087561e6..c6ec742af 100644 --- a/InCallUI/src/com/android/incallui/DialpadFragment.java +++ b/InCallUI/src/com/android/incallui/DialpadFragment.java @@ -17,16 +17,22 @@ package com.android.incallui; import android.content.Context; +import android.content.res.Resources; import android.os.Bundle; import android.text.Editable; import android.text.method.DialerKeyListener; +import android.util.AttributeSet; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityManager; import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TableRow; +import android.widget.TextView; import java.util.HashMap; @@ -37,6 +43,79 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese implements DialpadPresenter.DialpadUi, View.OnTouchListener, View.OnKeyListener, View.OnHoverListener, View.OnClickListener { + private static final float DIALPAD_SLIDE_FRACTION = 0.67f; + + /** + * LinearLayout with getter and setter methods for the translationY property using floats, + * for animation purposes. + */ + public static class DialpadSlidingLinearLayout extends LinearLayout { + + public DialpadSlidingLinearLayout(Context context) { + super(context); + } + + public DialpadSlidingLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public DialpadSlidingLinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public float getYFraction() { + final int height = getHeight(); + if (height == 0) return 0; + return getTranslationY() / height; + } + + public void setYFraction(float yFraction) { + setTranslationY(yFraction * getHeight()); + } + } + + /** + * LinearLayout that always returns true for onHoverEvent callbacks, to fix + * problems with accessibility due to the dialpad overlaying other fragments. + */ + public static class HoverIgnoringLinearLayout extends LinearLayout { + + public HoverIgnoringLinearLayout(Context context) { + super(context); + } + + public HoverIgnoringLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public HoverIgnoringLinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + public boolean onHoverEvent(MotionEvent event) { + return true; + } + } + + private class DismissListener implements View.OnClickListener, View.OnLongClickListener { + + @Override + public void onClick(View view) { + dismiss(); + } + + @Override + public boolean onLongClick(View view) { + dismiss(); + return true; + } + + private void dismiss() { + ((InCallActivity) getActivity()).getCallButtonFragment().displayDialpad(false); + } + } + private EditText mDtmfDialerField; /** Hash Map to map a view id to a character*/ @@ -382,6 +461,34 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese setupKeypad(parent); } + + final DismissListener dl = new DismissListener(); + final View spacer = parent.findViewById(R.id.dialpad_spacer); + spacer.setOnClickListener(dl); + spacer.setOnLongClickListener(dl); + + final ViewTreeObserver vto = parent.getViewTreeObserver(); + // Adjust the translation of the DialpadFragment in a preDrawListener instead of in + // DialtactsActivity, because at the point in time when the DialpadFragment is added, + // its views have not been laid out yet. + final ViewTreeObserver.OnPreDrawListener + preDrawListener = new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + if (isHidden()) return true; + if (parent.getTranslationY() == 0) { + ((DialpadSlidingLinearLayout) parent) + .setYFraction(DIALPAD_SLIDE_FRACTION); + } + final ViewTreeObserver vto = parent.getViewTreeObserver(); + vto.removeOnPreDrawListener(this); + return true; + } + + }; + + vto.addOnPreDrawListener(preDrawListener); + return parent; } @@ -440,21 +547,43 @@ public class DialpadFragment extends BaseFragment<DialpadPresenter, DialpadPrese } } - /** - * setup the keys on the dialer activity, using the keymaps. - */ - private void setupKeypad(View parent) { - // for each view id listed in the displaymap + private void setupKeypad(View fragmentView) { + final int[] buttonIds = 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}; + + 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 = getResources(); + View button; - for (int viewId : mDisplayMap.keySet()) { - // locate the view - button = parent.findViewById(viewId); - // Setup the listeners for the buttons + TextView numberView; + TextView lettersView; + + for (int i = 0; i < buttonIds.length; i++) { + button = fragmentView.findViewById(buttonIds[i]); button.setOnTouchListener(this); button.setClickable(true); button.setOnKeyListener(this); button.setOnHoverListener(this); button.setOnClickListener(this); + numberView = (TextView) button.findViewById(R.id.dialpad_key_number); + lettersView = (TextView) button.findViewById(R.id.dialpad_key_letters); + final String numberString = resources.getString(numberIds[i]); + numberView.setText(numberString); + button.setContentDescription(numberString); + if (lettersView != null) { + lettersView.setText(resources.getString(letterIds[i])); + } } } } diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 9c408a6f8..5a11b1885 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -21,6 +21,7 @@ import com.android.services.telephony.common.Call.State; import android.app.Activity; import android.app.AlertDialog; +import android.app.FragmentTransaction; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnCancelListener; @@ -308,6 +309,10 @@ public class InCallActivity extends Activity { InCallPresenter.getInstance().getProximitySensor().onConfigurationChanged(config); } + public CallButtonFragment getCallButtonFragment() { + return mCallButtonFragment; + } + private void internalResolveIntent(Intent intent) { final String action = intent.getAction(); @@ -365,7 +370,7 @@ public class InCallActivity extends Activity { if (mDialpadFragment == null) { mDialpadFragment = (DialpadFragment) getFragmentManager() .findFragmentById(R.id.dialpadFragment); - mDialpadFragment.getView().setVisibility(View.INVISIBLE); + getFragmentManager().beginTransaction().hide(mDialpadFragment).commit(); } if (mConferenceManagerFragment == null) { @@ -398,13 +403,15 @@ public class InCallActivity extends Activity { } public void displayDialpad(boolean showDialpad) { + final FragmentTransaction ft = getFragmentManager().beginTransaction(); if (showDialpad) { - mDialpadFragment.setVisible(true); - mCallCardFragment.setVisible(false); + ft.setCustomAnimations(R.anim.slide_in, 0); + ft.show(mDialpadFragment); } else { - mDialpadFragment.setVisible(false); - mCallCardFragment.setVisible(true); + ft.setCustomAnimations(0, R.anim.slide_out); + ft.hide(mDialpadFragment); } + ft.commit(); InCallPresenter.getInstance().getProximitySensor().onDialpadVisible(showDialpad); } diff --git a/InCallUI/src/com/android/incallui/NeededForReflection.java b/InCallUI/src/com/android/incallui/NeededForReflection.java new file mode 100644 index 000000000..363a0a548 --- /dev/null +++ b/InCallUI/src/com/android/incallui/NeededForReflection.java @@ -0,0 +1,30 @@ +/* + * 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.incallui; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Denotes that the class, constructor, method or field is used for reflection and therefore cannot + * be removed by tools like ProGuard. + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD}) +public @interface NeededForReflection {} |