summaryrefslogtreecommitdiffstats
path: root/java/com/android/incallui/incall/impl
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-03-15 14:41:07 -0700
committerEric Erfanian <erfanian@google.com>2017-03-15 16:24:23 -0700
commitd5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 (patch)
treeb54abbb51fb7d66e7755a1fbb5db023ff601090b /java/com/android/incallui/incall/impl
parent30436e7e6d3f2c8755a91b2b6222b74d465a9e87 (diff)
downloadandroid_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.tar.gz
android_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.tar.bz2
android_packages_apps_Dialer-d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9.zip
Update Dialer source from latest green build.
* Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942
Diffstat (limited to 'java/com/android/incallui/incall/impl')
-rw-r--r--java/com/android/incallui/incall/impl/AutoValue_MappedButtonConfig_MappingInfo.java135
-rw-r--r--java/com/android/incallui/incall/impl/FakeDragAnimation.java62
-rw-r--r--java/com/android/incallui/incall/impl/InCallFragment.java57
-rw-r--r--java/com/android/incallui/incall/impl/InCallPagerAdapter.java25
-rw-r--r--java/com/android/incallui/incall/impl/MappedButtonConfig.java6
5 files changed, 121 insertions, 164 deletions
diff --git a/java/com/android/incallui/incall/impl/AutoValue_MappedButtonConfig_MappingInfo.java b/java/com/android/incallui/incall/impl/AutoValue_MappedButtonConfig_MappingInfo.java
deleted file mode 100644
index addebc484..000000000
--- a/java/com/android/incallui/incall/impl/AutoValue_MappedButtonConfig_MappingInfo.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2017 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.incall.impl;
-
-import javax.annotation.Generated;
-
-@Generated("com.google.auto.value.processor.AutoValueProcessor")
- final class AutoValue_MappedButtonConfig_MappingInfo extends MappedButtonConfig.MappingInfo {
-
- private final int slot;
- private final int slotOrder;
- private final int conflictOrder;
-
- private AutoValue_MappedButtonConfig_MappingInfo(
- int slot,
- int slotOrder,
- int conflictOrder) {
- this.slot = slot;
- this.slotOrder = slotOrder;
- this.conflictOrder = conflictOrder;
- }
-
- @Override
- public int getSlot() {
- return slot;
- }
-
- @Override
- public int getSlotOrder() {
- return slotOrder;
- }
-
- @Override
- public int getConflictOrder() {
- return conflictOrder;
- }
-
- @Override
- public String toString() {
- return "MappingInfo{"
- + "slot=" + slot + ", "
- + "slotOrder=" + slotOrder + ", "
- + "conflictOrder=" + conflictOrder
- + "}";
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (o instanceof MappedButtonConfig.MappingInfo) {
- MappedButtonConfig.MappingInfo that = (MappedButtonConfig.MappingInfo) o;
- return (this.slot == that.getSlot())
- && (this.slotOrder == that.getSlotOrder())
- && (this.conflictOrder == that.getConflictOrder());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int h = 1;
- h *= 1000003;
- h ^= this.slot;
- h *= 1000003;
- h ^= this.slotOrder;
- h *= 1000003;
- h ^= this.conflictOrder;
- return h;
- }
-
- static final class Builder extends MappedButtonConfig.MappingInfo.Builder {
- private Integer slot;
- private Integer slotOrder;
- private Integer conflictOrder;
- Builder() {
- }
- private Builder(MappedButtonConfig.MappingInfo source) {
- this.slot = source.getSlot();
- this.slotOrder = source.getSlotOrder();
- this.conflictOrder = source.getConflictOrder();
- }
- @Override
- public MappedButtonConfig.MappingInfo.Builder setSlot(int slot) {
- this.slot = slot;
- return this;
- }
- @Override
- public MappedButtonConfig.MappingInfo.Builder setSlotOrder(int slotOrder) {
- this.slotOrder = slotOrder;
- return this;
- }
- @Override
- public MappedButtonConfig.MappingInfo.Builder setConflictOrder(int conflictOrder) {
- this.conflictOrder = conflictOrder;
- return this;
- }
- @Override
- public MappedButtonConfig.MappingInfo build() {
- String missing = "";
- if (this.slot == null) {
- missing += " slot";
- }
- if (this.slotOrder == null) {
- missing += " slotOrder";
- }
- if (this.conflictOrder == null) {
- missing += " conflictOrder";
- }
- if (!missing.isEmpty()) {
- throw new IllegalStateException("Missing required properties:" + missing);
- }
- return new AutoValue_MappedButtonConfig_MappingInfo(
- this.slot,
- this.slotOrder,
- this.conflictOrder);
- }
- }
-
-}
diff --git a/java/com/android/incallui/incall/impl/FakeDragAnimation.java b/java/com/android/incallui/incall/impl/FakeDragAnimation.java
new file mode 100644
index 000000000..c84c3c409
--- /dev/null
+++ b/java/com/android/incallui/incall/impl/FakeDragAnimation.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 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.incall.impl;
+
+import android.animation.ValueAnimator;
+import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.support.v4.view.ViewPager;
+import android.support.v4.view.animation.FastOutSlowInInterpolator;
+
+/**
+ * An animation that controls the fake drag of a {@link ViewPager}. See {@link
+ * ViewPager#fakeDragBy(float)} for more details.
+ */
+public class FakeDragAnimation implements AnimatorUpdateListener {
+
+ /** The view to animate. */
+ private final ViewPager pager;
+
+ private final ValueAnimator animator;
+ private int oldDragPosition;
+
+ public FakeDragAnimation(ViewPager pager) {
+ this.pager = pager;
+ animator = ValueAnimator.ofInt(0, pager.getWidth());
+ animator.addUpdateListener(this);
+ animator.setInterpolator(new FastOutSlowInInterpolator());
+ animator.setDuration(600);
+ }
+
+ public void start() {
+ animator.start();
+ }
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ if (!pager.isFakeDragging()) {
+ pager.beginFakeDrag();
+ }
+ int dragPosition = (Integer) animation.getAnimatedValue();
+ int dragOffset = dragPosition - oldDragPosition;
+ oldDragPosition = dragPosition;
+ pager.fakeDragBy(-dragOffset);
+
+ if (animation.getAnimatedFraction() == 1) {
+ pager.endFakeDrag();
+ }
+ }
+}
diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java
index ef8a1edd8..3f31651a0 100644
--- a/java/com/android/incallui/incall/impl/InCallFragment.java
+++ b/java/com/android/incallui/incall/impl/InCallFragment.java
@@ -213,9 +213,7 @@ public class InCallFragment extends Fragment
@Override
public void setPrimary(@NonNull PrimaryInfo primaryInfo) {
LogUtil.i("InCallFragment.setPrimary", primaryInfo.toString());
- if (adapter == null) {
- initAdapter(primaryInfo.multimediaData);
- }
+ setAdapterMedia(primaryInfo.multimediaData);
contactGridManager.setPrimary(primaryInfo);
if (primaryInfo.shouldShowLocation) {
@@ -241,9 +239,13 @@ public class InCallFragment extends Fragment
}
}
- private void initAdapter(MultimediaData multimediaData) {
- adapter = new InCallPagerAdapter(getChildFragmentManager(), multimediaData);
- pager.setAdapter(adapter);
+ private void setAdapterMedia(MultimediaData multimediaData) {
+ if (adapter == null) {
+ adapter = new InCallPagerAdapter(getChildFragmentManager(), multimediaData);
+ pager.setAdapter(adapter);
+ } else {
+ adapter.setAttachments(multimediaData);
+ }
if (adapter.getCount() > 1) {
tabLayout.setVisibility(pager.getVisibility());
@@ -251,16 +253,13 @@ public class InCallFragment extends Fragment
if (!stateRestored) {
new Handler()
.postDelayed(
- new Runnable() {
- @Override
- public void run() {
- // In order to prevent user confusion and educate the user on our UI, we animate
- // the view pager to the button grid after 2 seconds show them when the UI is
- // that they are more familiar with.
- pager.setCurrentItem(adapter.getButtonGridPosition());
- }
+ () -> {
+ // In order to prevent user confusion and educate the user on our UI, we animate
+ // the view pager to the button grid after a short period to show them where the
+ // UI that they are more familiar with is located.
+ new FakeDragAnimation(pager).start();
},
- 2000);
+ 333);
}
} else {
tabLayout.setVisibility(View.GONE);
@@ -479,23 +478,39 @@ public class InCallFragment extends Fragment
@Override
public boolean isShowingLocationUi() {
- Fragment fragment = getChildFragmentManager().findFragmentById(R.id.incall_location_holder);
+ Fragment fragment = getLocationFragment();
return fragment != null && fragment.isVisible();
}
@Override
public void showLocationUi(@Nullable Fragment locationUi) {
- boolean isShowing = isShowingLocationUi();
- if (!isShowing && locationUi != null) {
+ boolean isVisible = isShowingLocationUi();
+ if (locationUi != null && !isVisible) {
// Show the location fragment.
getChildFragmentManager()
.beginTransaction()
.replace(R.id.incall_location_holder, locationUi)
.commitAllowingStateLoss();
- } else if (isShowing && locationUi == null) {
+ } else if (locationUi == null && isVisible) {
// Hide the location fragment
- Fragment fragment = getChildFragmentManager().findFragmentById(R.id.incall_location_holder);
- getChildFragmentManager().beginTransaction().remove(fragment).commitAllowingStateLoss();
+ getChildFragmentManager()
+ .beginTransaction()
+ .remove(getLocationFragment())
+ .commitAllowingStateLoss();
}
}
+
+ @Override
+ public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
+ super.onMultiWindowModeChanged(isInMultiWindowMode);
+ if (isInMultiWindowMode == isShowingLocationUi()) {
+ LogUtil.i("InCallFragment.onMultiWindowModeChanged", "hide = " + isInMultiWindowMode);
+ // Need to show or hide location
+ showLocationUi(isInMultiWindowMode ? null : getLocationFragment());
+ }
+ }
+
+ private Fragment getLocationFragment() {
+ return getChildFragmentManager().findFragmentById(R.id.incall_location_holder);
+ }
}
diff --git a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java
index 50eb4c8c3..2e2183565 100644
--- a/java/com/android/incallui/incall/impl/InCallPagerAdapter.java
+++ b/java/com/android/incallui/incall/impl/InCallPagerAdapter.java
@@ -19,17 +19,18 @@ package com.android.incallui.incall.impl;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.view.PagerAdapter;
import android.text.TextUtils;
import com.android.dialer.multimedia.MultimediaData;
import com.android.incallui.sessiondata.MultimediaFragment;
/** View pager adapter for in call ui. */
-public class InCallPagerAdapter extends FragmentPagerAdapter {
+public class InCallPagerAdapter extends FragmentStatePagerAdapter {
- @Nullable private final MultimediaData attachments;
+ @Nullable private MultimediaData attachments;
- public InCallPagerAdapter(FragmentManager fragmentManager, MultimediaData attachments) {
+ public InCallPagerAdapter(FragmentManager fragmentManager, @Nullable MultimediaData attachments) {
super(fragmentManager);
this.attachments = attachments;
}
@@ -47,13 +48,27 @@ public class InCallPagerAdapter extends FragmentPagerAdapter {
@Override
public int getCount() {
if (attachments != null
- && (!TextUtils.isEmpty(attachments.getSubject()) || attachments.hasImageData())) {
+ && (!TextUtils.isEmpty(attachments.getText()) || attachments.hasImageData())) {
return 2;
}
return 1;
}
+ public void setAttachments(@Nullable MultimediaData attachments) {
+ if (this.attachments != attachments) {
+ this.attachments = attachments;
+ notifyDataSetChanged();
+ }
+ }
+
public int getButtonGridPosition() {
return getCount() - 1;
}
+
+ //this is called when notifyDataSetChanged() is called
+ @Override
+ public int getItemPosition(Object object) {
+ // refresh all fragments when data set changed
+ return PagerAdapter.POSITION_NONE;
+ }
}
diff --git a/java/com/android/incallui/incall/impl/MappedButtonConfig.java b/java/com/android/incallui/incall/impl/MappedButtonConfig.java
index ecdb5dfea..722983796 100644
--- a/java/com/android/incallui/incall/impl/MappedButtonConfig.java
+++ b/java/com/android/incallui/incall/impl/MappedButtonConfig.java
@@ -22,7 +22,7 @@ import android.util.ArraySet;
import com.android.dialer.common.Assert;
import com.android.incallui.incall.protocol.InCallButtonIds;
import com.android.incallui.incall.protocol.InCallButtonIdsExtension;
-
+import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -151,7 +151,7 @@ final class MappedButtonConfig {
}
/** Holds information about button mapping. */
-
+ @AutoValue
abstract static class MappingInfo {
/** The Ui slot into which a given button desires to be placed. */
@@ -179,7 +179,7 @@ final class MappedButtonConfig {
}
/** Class used to build instances of {@link MappingInfo}. */
-
+ @AutoValue.Builder
abstract static class Builder {
public abstract Builder setSlot(int slot);