From 30ccc4f3aa6da94f0bb8a01a880a6353b883b263 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Mon, 20 Mar 2017 20:40:36 +0000 Subject: Revert "Update AOSP Dialer source from internal google3 repository at cl/150622237" This reverts commit 06b6b56e9eaa91ebf757ea641e38a9c885fa40bd. Change-Id: Ida8c5ee67669524dc63b9adc60a6dd392cb9b9a6 --- java/com/android/incallui/InCallActivity.java | 6 +- java/com/android/incallui/InCallPresenter.java | 2 +- .../incallui/answer/bindings/AnswerBindings.java | 8 +- .../incallui/answer/impl/AnswerFragment.java | 19 +- .../answer/impl/FixedAspectSurfaceView.java | 86 ------- .../impl/SelfManagedAnswerVideoCallScreen.java | 268 --------------------- .../impl/res/layout/fragment_incoming_call.xml | 20 +- .../answer/impl/res/values-land/dimens.xml | 20 -- .../incallui/answer/impl/res/values/attrs.xml | 26 -- .../incallui/answer/impl/res/values/dimens.xml | 3 +- .../calllocation/CallLocationComponent.java | 20 +- .../incallui/calllocation/impl/HttpFetcher.java | 2 - .../calllocation/stub/StubCallLocationModule.java | 6 +- .../incallui/incall/impl/AndroidManifest.xml | 4 +- .../incallui/incall/impl/InCallFragment.java | 29 +-- .../incallui/incall/impl/InCallPaginator.java | 210 ---------------- .../incallui/incall/impl/LockableViewPager.java | 46 ---- .../incall/impl/res/layout/frag_incall_voice.xml | 20 +- .../incallui/incall/impl/res/values/dimens.xml | 5 - .../incallui/incall/impl/res/values/styles.xml | 3 - java/com/android/incallui/maps/MapsComponent.java | 21 +- .../android/incallui/maps/stub/StubMapsModule.java | 2 +- .../com/android/incallui/res/values-uz/strings.xml | 2 +- java/com/android/incallui/videotech/VideoTech.java | 6 - .../incallui/videotech/empty/EmptyVideoTech.java | 5 - .../incallui/videotech/ims/ImsVideoTech.java | 7 - .../incallui/videotech/rcs/RcsVideoShare.java | 5 - 27 files changed, 74 insertions(+), 777 deletions(-) delete mode 100644 java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java delete mode 100644 java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java delete mode 100644 java/com/android/incallui/answer/impl/res/values-land/dimens.xml delete mode 100644 java/com/android/incallui/answer/impl/res/values/attrs.xml delete mode 100644 java/com/android/incallui/incall/impl/InCallPaginator.java delete mode 100644 java/com/android/incallui/incall/impl/LockableViewPager.java (limited to 'java/com/android/incallui') diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index 395829b80..7c4394872 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -625,11 +625,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity // Show a new answer screen. AnswerScreen answerScreen = - AnswerBindings.createAnswerScreen( - call.getId(), - call.isVideoCall(), - isVideoUpgradeRequest, - call.getVideoTech().isSelfManagedCamera()); + AnswerBindings.createAnswerScreen(call.getId(), call.isVideoCall(), isVideoUpgradeRequest); transaction.add(R.id.main, answerScreen.getAnswerScreenFragment(), TAG_ANSWER_SCREEN); Logger.get(this).logScreenView(ScreenEvent.Type.INCOMING_CALL, this); diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index ea7bc9cc3..0f3982ce4 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -758,7 +758,7 @@ public class InCallPresenter implements CallList.Listener { } if (!call.getLogState().isIncoming && !mCallList.hasLiveCall()) { - PostCall.onCallDisconnected(mContext, call.getNumber(), call.getTimeAddedMs()); + PostCall.onCallDisconnected(mContext, call.getNumber(), call.getConnectTimeMillis()); } } diff --git a/java/com/android/incallui/answer/bindings/AnswerBindings.java b/java/com/android/incallui/answer/bindings/AnswerBindings.java index 8be283990..442e207a0 100644 --- a/java/com/android/incallui/answer/bindings/AnswerBindings.java +++ b/java/com/android/incallui/answer/bindings/AnswerBindings.java @@ -23,11 +23,7 @@ import com.android.incallui.answer.protocol.AnswerScreen; public class AnswerBindings { public static AnswerScreen createAnswerScreen( - String callId, - boolean isVideoCall, - boolean isVideoUpgradeRequest, - boolean isSelfManagedCamera) { - return AnswerFragment.newInstance( - callId, isVideoCall, isVideoUpgradeRequest, isSelfManagedCamera); + String callId, boolean isVideoCall, boolean isVideoUpgradeRequest) { + return AnswerFragment.newInstance(callId, isVideoCall, isVideoUpgradeRequest); } } diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index a6174686c..6874daea3 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -106,9 +106,6 @@ public class AnswerFragment extends Fragment @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) static final String ARG_IS_VIDEO_UPGRADE_REQUEST = "is_video_upgrade_request"; - @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) - static final String ARG_IS_SELF_MANAGED_CAMERA = "is_self_managed_camera"; - private static final String STATE_HAS_ANIMATED_ENTRY = "hasAnimated"; private static final int HINT_SECONDARY_SHOW_DURATION_MILLIS = 5000; @@ -291,15 +288,11 @@ public class AnswerFragment extends Fragment } public static AnswerFragment newInstance( - String callId, - boolean isVideoCall, - boolean isVideoUpgradeRequest, - boolean isSelfManagedCamera) { + String callId, boolean isVideoCall, boolean isVideoUpgradeRequest) { Bundle bundle = new Bundle(); bundle.putString(ARG_CALL_ID, Assert.isNotNull(callId)); bundle.putBoolean(ARG_IS_VIDEO_CALL, isVideoCall); bundle.putBoolean(ARG_IS_VIDEO_UPGRADE_REQUEST, isVideoUpgradeRequest); - bundle.putBoolean(ARG_IS_SELF_MANAGED_CAMERA, isSelfManagedCamera); AnswerFragment instance = new AnswerFragment(); instance.setArguments(bundle); @@ -627,11 +620,7 @@ public class AnswerFragment extends Fragment view.setSystemUiVisibility(flags); if (isVideoCall() || isVideoUpgradeRequest()) { if (VideoUtils.hasCameraPermissionAndAllowedByUser(getContext())) { - if (isSelfManagedCamera()) { - answerVideoCallScreen = new SelfManagedAnswerVideoCallScreen(getCallId(), this, view); - } else { - answerVideoCallScreen = new AnswerVideoCallScreen(getCallId(), this, view); - } + answerVideoCallScreen = new AnswerVideoCallScreen(getCallId(), this, view); } else { view.findViewById(R.id.videocall_video_off).setVisibility(View.VISIBLE); } @@ -729,10 +718,6 @@ public class AnswerFragment extends Fragment return getArguments().getBoolean(ARG_IS_VIDEO_CALL); } - public boolean isSelfManagedCamera() { - return getArguments().getBoolean(ARG_IS_SELF_MANAGED_CAMERA); - } - @Override public void onAnswerProgressUpdate(@FloatRange(from = -1f, to = 1f) float answerProgress) { // Don't fade the window background for call waiting or video upgrades. Fading the background diff --git a/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java b/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java deleted file mode 100644 index ad7d94d95..000000000 --- a/java/com/android/incallui/answer/impl/FixedAspectSurfaceView.java +++ /dev/null @@ -1,86 +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.answer.impl; - -import android.content.Context; -import android.content.res.TypedArray; -import android.util.AttributeSet; -import android.view.SurfaceView; -import android.view.View; -import com.android.dialer.common.Assert; - -/** - * A SurfaceView that maintains its aspect ratio to be a desired target value. - * - *

The FixedAspectSurfaceView will not be able to maintain the requested aspect ratio if both the - * width and the height are exactly determined by the layout. To avoid this, ensure that either the - * height or the width is adjustable by the view; for example, by setting the layout parameters to - * be WRAP_CONTENT for the dimension that is best adjusted to maintain the aspect ratio. - */ -public class FixedAspectSurfaceView extends SurfaceView { - - /** Desired width/height ratio */ - private float mAspectRatio; - - private final boolean scaleWidth; - private final boolean scaleHeight; - - public FixedAspectSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - - // Get initial aspect ratio from custom attributes - TypedArray a = - context.getTheme().obtainStyledAttributes(attrs, R.styleable.FixedAspectSurfaceView, 0, 0); - scaleHeight = a.getBoolean(R.styleable.FixedAspectSurfaceView_scaleHeight, false); - scaleWidth = a.getBoolean(R.styleable.FixedAspectSurfaceView_scaleWidth, false); - Assert.checkArgument(scaleHeight != scaleWidth, "Must either scale width or height"); - setAspectRatio(a.getFloat(R.styleable.FixedAspectSurfaceView_aspectRatio, 1.f)); - a.recycle(); - } - - /** - * Set the desired aspect ratio for this view. - * - * @param aspect the desired width/height ratio in the current UI orientation. Must be a positive - * value. - */ - public void setAspectRatio(float aspect) { - Assert.checkArgument(aspect >= 0, "Aspect ratio must be positive"); - mAspectRatio = aspect; - requestLayout(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = MeasureSpec.getSize(widthMeasureSpec); - int height = MeasureSpec.getSize(heightMeasureSpec); - - // Do the scaling - if (scaleWidth) { - width = (int) (height * mAspectRatio); - } else if (scaleHeight) { - height = (int) (width / mAspectRatio); - } - - // Override width/height if needed for EXACTLY and AT_MOST specs - width = View.resolveSizeAndState(width, widthMeasureSpec, 0); - height = View.resolveSizeAndState(height, heightMeasureSpec, 0); - - // Finally set the calculated dimensions - setMeasuredDimension(width, height); - } -} diff --git a/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java b/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java deleted file mode 100644 index 522d77235..000000000 --- a/java/com/android/incallui/answer/impl/SelfManagedAnswerVideoCallScreen.java +++ /dev/null @@ -1,268 +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.answer.impl; - -import android.content.Context; -import android.hardware.camera2.CameraAccessException; -import android.hardware.camera2.CameraCaptureSession; -import android.hardware.camera2.CameraCharacteristics; -import android.hardware.camera2.CameraDevice; -import android.hardware.camera2.CameraDevice.StateCallback; -import android.hardware.camera2.CameraManager; -import android.hardware.camera2.CameraMetadata; -import android.hardware.camera2.CaptureRequest; -import android.hardware.camera2.params.StreamConfigurationMap; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.util.Size; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import com.android.dialer.common.Assert; -import com.android.dialer.common.LogUtil; -import com.android.incallui.video.protocol.VideoCallScreen; -import java.util.Arrays; - -/** - * Shows the local preview for the incoming video call or video upgrade request. This class is used - * for RCS Video Share where we need to open the camera preview ourselves. For IMS Video the camera - * is managed by the modem, see {@link AnswerVideoCallScreen}. - */ -public class SelfManagedAnswerVideoCallScreen extends StateCallback implements VideoCallScreen { - - private static final int MAX_WIDTH = 1920; - private static final float ASPECT_TOLERANCE = 0.1f; - private static final float TARGET_ASPECT = 16.f / 9.f; - - @NonNull private final String callId; - @NonNull private final Fragment fragment; - @NonNull private final FixedAspectSurfaceView surfaceView; - private final Context context; - - private String cameraId; - private CameraDevice camera; - private CaptureRequest.Builder captureRequestBuilder; - - public SelfManagedAnswerVideoCallScreen( - @NonNull String callId, @NonNull Fragment fragment, @NonNull View view) { - this.callId = Assert.isNotNull(callId); - this.fragment = Assert.isNotNull(fragment); - this.context = Assert.isNotNull(fragment.getContext()); - - surfaceView = - Assert.isNotNull( - (FixedAspectSurfaceView) view.findViewById(R.id.incoming_preview_surface_view)); - surfaceView.setVisibility(View.VISIBLE); - view.findViewById(R.id.incoming_preview_texture_view_overlay).setVisibility(View.VISIBLE); - view.setBackgroundColor(0xff000000); - } - - @Override - public void onVideoScreenStart() { - openCamera(); - } - - @Override - public void onVideoScreenStop() { - closeCamera(); - } - - @Override - public void showVideoViews( - boolean shouldShowPreview, boolean shouldShowRemote, boolean isRemotelyHeld) {} - - @Override - public void onLocalVideoDimensionsChanged() {} - - @Override - public void onLocalVideoOrientationChanged() {} - - @Override - public void onRemoteVideoDimensionsChanged() {} - - @Override - public void updateFullscreenAndGreenScreenMode( - boolean shouldShowFullscreen, boolean shouldShowGreenScreen) {} - - @Override - public Fragment getVideoCallScreenFragment() { - return fragment; - } - - @Override - public String getCallId() { - return callId; - } - - /** - * Opens the first front facing camera on the device into a {@link SurfaceView} while preserving - * aspect ratio. - */ - private void openCamera() { - CameraManager manager = context.getSystemService(CameraManager.class); - - StreamConfigurationMap configMap = getFrontFacingCameraSizes(manager); - if (configMap == null) { - return; - } - - Size previewSize = getOptimalSize(configMap.getOutputSizes(SurfaceHolder.class)); - LogUtil.i("SelfManagedAnswerVideoCallScreen.openCamera", "Optimal size: " + previewSize); - float outputAspect = (float) previewSize.getWidth() / previewSize.getHeight(); - surfaceView.setAspectRatio(outputAspect); - surfaceView.getHolder().setFixedSize(previewSize.getWidth(), previewSize.getHeight()); - - try { - manager.openCamera(cameraId, this, null); - } catch (CameraAccessException e) { - LogUtil.e("SelfManagedAnswerVideoCallScreen.openCamera", "failed to open camera", e); - } - } - - @Nullable - private StreamConfigurationMap getFrontFacingCameraSizes(CameraManager manager) { - String[] cameraIds; - try { - cameraIds = manager.getCameraIdList(); - } catch (CameraAccessException e) { - LogUtil.e( - "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes", - "failed to get camera ids", - e); - return null; - } - - for (String cameraId : cameraIds) { - CameraCharacteristics characteristics; - try { - characteristics = manager.getCameraCharacteristics(cameraId); - } catch (CameraAccessException e) { - LogUtil.e( - "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes", - "failed to get camera characteristics", - e); - continue; - } - - if (characteristics.get(CameraCharacteristics.LENS_FACING) - != CameraCharacteristics.LENS_FACING_FRONT) { - continue; - } - - StreamConfigurationMap configMap = - characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); - if (configMap == null) { - continue; - } - - this.cameraId = cameraId; - return configMap; - } - LogUtil.e( - "SelfManagedAnswerVideoCallScreen.getFrontFacingCameraSizes", "No valid configurations."); - return null; - } - - /** - * Given an array of {@link Size}s, tries to find the largest Size such that the aspect ratio of - * the returned size is within {@code ASPECT_TOLERANCE} of {@code TARGET_ASPECT}. This is useful - * because it provides us with an adequate size/camera resolution that will experience the least - * stretching from our fullscreen UI that doesn't match any of the camera sizes. - */ - private static Size getOptimalSize(Size[] outputSizes) { - Size bestCandidateSize = outputSizes[0]; - float bestCandidateAspect = - (float) bestCandidateSize.getWidth() / bestCandidateSize.getHeight(); - - for (Size candidateSize : outputSizes) { - if (candidateSize.getWidth() < MAX_WIDTH) { - float candidateAspect = (float) candidateSize.getWidth() / candidateSize.getHeight(); - boolean isGoodCandidateAspect = - Math.abs(candidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE; - boolean isGoodOutputAspect = - Math.abs(bestCandidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE; - - if ((isGoodCandidateAspect && !isGoodOutputAspect) - || candidateSize.getWidth() > bestCandidateSize.getWidth()) { - bestCandidateSize = candidateSize; - bestCandidateAspect = candidateAspect; - } - } - } - return bestCandidateSize; - } - - @Override - public void onOpened(CameraDevice camera) { - LogUtil.i("SelfManagedAnswerVideoCallScreen.opOpened", "camera opened."); - this.camera = camera; - Surface surface = surfaceView.getHolder().getSurface(); - try { - captureRequestBuilder = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); - captureRequestBuilder.addTarget(surface); - camera.createCaptureSession(Arrays.asList(surface), new CaptureSessionCallback(), null); - } catch (CameraAccessException e) { - LogUtil.e( - "SelfManagedAnswerVideoCallScreen.createCameraPreview", "failed to create preview", e); - } - } - - @Override - public void onDisconnected(CameraDevice camera) { - closeCamera(); - } - - @Override - public void onError(CameraDevice camera, int error) { - closeCamera(); - } - - private void closeCamera() { - if (camera != null) { - camera.close(); - camera = null; - } - } - - private class CaptureSessionCallback extends CameraCaptureSession.StateCallback { - - @Override - public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) { - LogUtil.i( - "SelfManagedAnswerVideoCallScreen.onConfigured", "camera capture session configured."); - // The camera is already closed. - if (camera == null) { - return; - } - - // When the session is ready, we start displaying the preview. - captureRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO); - try { - cameraCaptureSession.setRepeatingRequest(captureRequestBuilder.build(), null, null); - } catch (CameraAccessException e) { - LogUtil.e("CaptureSessionCallback.onConfigured", "failed to configure", e); - } - } - - @Override - public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) { - LogUtil.e("CaptureSessionCallback.onConfigureFailed", "failed to configure"); - } - } -} diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml index 042e7b82f..aa153dd4b 100644 --- a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml +++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml @@ -14,6 +14,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> + - - + android:id="@+id/incoming_preview_texture_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:importantForAccessibility="no" + android:visibility="gone"/> - - - false - true - diff --git a/java/com/android/incallui/answer/impl/res/values/attrs.xml b/java/com/android/incallui/answer/impl/res/values/attrs.xml deleted file mode 100644 index 1086e1ca5..000000000 --- a/java/com/android/incallui/answer/impl/res/values/attrs.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - -1 - -2 - \ No newline at end of file diff --git a/java/com/android/incallui/answer/impl/res/values/dimens.xml b/java/com/android/incallui/answer/impl/res/values/dimens.xml index 50aec0328..8329707a6 100644 --- a/java/com/android/incallui/answer/impl/res/values/dimens.xml +++ b/java/com/android/incallui/answer/impl/res/values/dimens.xml @@ -14,6 +14,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> + 24sp 24sp @@ -21,7 +22,5 @@ 0dp 0dp false - true - false 1000 diff --git a/java/com/android/incallui/calllocation/CallLocationComponent.java b/java/com/android/incallui/calllocation/CallLocationComponent.java index 46ca669db..6b1faf299 100644 --- a/java/com/android/incallui/calllocation/CallLocationComponent.java +++ b/java/com/android/incallui/calllocation/CallLocationComponent.java @@ -17,18 +17,26 @@ package com.android.incallui.calllocation; import android.content.Context; -import com.android.dialer.inject.HasRootComponent; import dagger.Subcomponent; +import com.android.incallui.calllocation.stub.StubCallLocationModule; /** Subcomponent that can be used to access the call location implementation. */ -@Subcomponent -public abstract class CallLocationComponent { +public class CallLocationComponent { + private static CallLocationComponent instance; + private CallLocation callLocation; - public abstract CallLocation getCallLocation(); + public CallLocation getCallLocation(){ + if (callLocation == null) { + callLocation = new StubCallLocationModule.StubCallLocation(); + } + return callLocation; + } public static CallLocationComponent get(Context context) { - return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) - .callLocationComponent(); + if (instance == null) { + instance = new CallLocationComponent(); + } + return instance; } /** Used to refer to the root application component. */ diff --git a/java/com/android/incallui/calllocation/impl/HttpFetcher.java b/java/com/android/incallui/calllocation/impl/HttpFetcher.java index 7bfbaa6ef..c4aaa2257 100644 --- a/java/com/android/incallui/calllocation/impl/HttpFetcher.java +++ b/java/com/android/incallui/calllocation/impl/HttpFetcher.java @@ -223,8 +223,6 @@ public class HttpFetcher { /** * Lookup up url re-write rules from gServices and apply to the given url. * - *

https://wiki.corp.google.com/twiki/bin/view/Main/AndroidGservices#URL_Rewriting_Rules - * * @return The new url. */ private static URL reWriteUrl(Context context, String url) { diff --git a/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java b/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java index 20460699a..fc198c724 100644 --- a/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java +++ b/java/com/android/incallui/calllocation/stub/StubCallLocationModule.java @@ -32,9 +32,9 @@ public abstract class StubCallLocationModule { @Binds public abstract CallLocation bindCallLocation(StubCallLocation callLocation); - static class StubCallLocation implements CallLocation { + static public class StubCallLocation implements CallLocation { @Inject - StubCallLocation() {} + public StubCallLocation() {} @Override public boolean canGetLocation(@NonNull Context context) { @@ -44,7 +44,7 @@ public abstract class StubCallLocationModule { @Override @NonNull public Fragment getLocationFragment(@NonNull Context context) { - throw Assert.createUnsupportedOperationFailException(); + return null; } @Override diff --git a/java/com/android/incallui/incall/impl/AndroidManifest.xml b/java/com/android/incallui/incall/impl/AndroidManifest.xml index 3d646506d..a0e3110d8 100644 --- a/java/com/android/incallui/incall/impl/AndroidManifest.xml +++ b/java/com/android/incallui/incall/impl/AndroidManifest.xml @@ -1 +1,3 @@ - + + diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index 02e9b4add..b6ae4902a 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -25,9 +25,11 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; import android.telecom.CallAudioState; import android.telephony.TelephonyManager; import android.view.LayoutInflater; @@ -72,8 +74,8 @@ public class InCallFragment extends Fragment private List buttonControllers = new ArrayList<>(); private View endCallButton; - private InCallPaginator paginator; - private LockableViewPager pager; + private TabLayout tabLayout; + private ViewPager pager; private InCallPagerAdapter adapter; private ContactGridManager contactGridManager; private InCallScreenDelegate inCallScreenDelegate; @@ -132,8 +134,8 @@ public class InCallFragment extends Fragment getResources().getDimensionPixelSize(R.dimen.incall_avatar_size), true /* showAnonymousAvatar */); - paginator = (InCallPaginator) view.findViewById(R.id.incall_paginator); - pager = (LockableViewPager) view.findViewById(R.id.incall_pager); + tabLayout = (TabLayout) view.findViewById(R.id.incall_tab_dots); + pager = (ViewPager) view.findViewById(R.id.incall_pager); endCallButton = view.findViewById(R.id.incall_end_call); endCallButton.setOnClickListener(this); @@ -246,8 +248,8 @@ public class InCallFragment extends Fragment } if (adapter.getCount() > 1) { - paginator.setVisibility(View.VISIBLE); - paginator.setupWithViewPager(pager); + tabLayout.setVisibility(pager.getVisibility()); + tabLayout.setupWithViewPager(pager, true); if (!stateRestored) { new Handler() .postDelayed( @@ -261,9 +263,9 @@ public class InCallFragment extends Fragment } }, 2000); - } else { - paginator.setVisibility(View.GONE); } + } else { + tabLayout.setVisibility(View.GONE); } } @@ -426,15 +428,8 @@ public class InCallFragment extends Fragment int visibility = numVisibleButtons == 0 ? View.GONE : View.VISIBLE; pager.setVisibility(visibility); - if (adapter != null - && adapter.getCount() > 1 - && getResources().getInteger(R.integer.incall_num_rows) > 1) { - paginator.setVisibility(View.VISIBLE); - pager.setSwipingLocked(false); - } else { - paginator.setVisibility(View.GONE); - pager.setSwipingLocked(true); - pager.setCurrentItem(adapter.getButtonGridPosition()); + if (adapter != null && adapter.getCount() > 1) { + tabLayout.setVisibility(visibility); } } diff --git a/java/com/android/incallui/incall/impl/InCallPaginator.java b/java/com/android/incallui/incall/impl/InCallPaginator.java deleted file mode 100644 index 8ebbd76a2..000000000 --- a/java/com/android/incallui/incall/impl/InCallPaginator.java +++ /dev/null @@ -1,210 +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 android.animation.ValueAnimator; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Path; -import android.support.annotation.VisibleForTesting; -import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.util.AttributeSet; -import android.view.View; -import com.android.dialer.common.Assert; - -/** - * This is the view class for incall paginator visible when a user has EC data attached to their - * call. It contains animation methods when the swipe gesture is performed. - */ -public class InCallPaginator extends View implements OnPageChangeListener { - - private int dotRadius; - private int dotsSeparation; - - private Paint activeDotPaintPortrait; - private Paint inactiveDotPaintPortrait; - - private Path inactiveDotPath; - private ValueAnimator transitionAnimator; - private boolean useModeSwitchTransition; - - private float progress; - private boolean toFirstPage; - private boolean pageChanged; - - public InCallPaginator(Context context) { - super(context); - init(context); - } - - public InCallPaginator(Context context, AttributeSet attrs) { - super(context, attrs); - init(context); - } - - private void init(Context context) { - dotRadius = getResources().getDimensionPixelSize(R.dimen.paginator_dot_radius); - dotsSeparation = getResources().getDimensionPixelSize(R.dimen.paginator_dots_separation); - - int activeDotColor = context.getColor(R.color.paginator_dot); - int inactiveDotColor = context.getColor(R.color.paginator_path); - activeDotPaintPortrait = new Paint(Paint.ANTI_ALIAS_FLAG); - activeDotPaintPortrait.setColor(activeDotColor); - inactiveDotPaintPortrait = new Paint(Paint.ANTI_ALIAS_FLAG); - inactiveDotPaintPortrait.setColor(inactiveDotColor); - - inactiveDotPath = new Path(); - transitionAnimator = ValueAnimator.ofFloat(0f, 1f); - transitionAnimator.setInterpolator(null); - transitionAnimator.setCurrentFraction(0f); - transitionAnimator.addUpdateListener(animation -> invalidate()); - } - - @VisibleForTesting - public void setProgress(float progress, boolean toFirstPage) { - this.progress = progress; - this.toFirstPage = toFirstPage; - - // Ensure the dot transition keeps up with the swipe progress. - if (transitionAnimator.isStarted() && progress > transitionAnimator.getAnimatedFraction()) { - transitionAnimator.setCurrentFraction(progress); - } - - invalidate(); - } - - private void startTransition() { - if (transitionAnimator.getAnimatedFraction() < 1f) { - transitionAnimator.setCurrentFraction(progress); - useModeSwitchTransition = false; - transitionAnimator.cancel(); - transitionAnimator.start(); - } - } - - private void endTransition(boolean snapBack) { - if (transitionAnimator.getAnimatedFraction() > 0f) { - useModeSwitchTransition = !snapBack; - transitionAnimator.cancel(); - transitionAnimator.reverse(); - } - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - - int centerX = getWidth() / 2; - int centerY = getHeight() / 2; - - float transitionFraction = (float) transitionAnimator.getAnimatedValue(); - - // Draw the inactive "dots". - inactiveDotPath.reset(); - if (useModeSwitchTransition) { - float trackWidth = 2 * dotRadius + transitionFraction * (2 * dotRadius + dotsSeparation); - float indicatorRadius = dotRadius * (1f - 2f * Math.min(transitionFraction, 0.5f)); - float indicatorOffset = dotRadius + dotsSeparation / 2; - if (toFirstPage) { - float trackLeft = centerX - indicatorOffset - dotRadius; - inactiveDotPath.addRoundRect( - trackLeft, - centerY - dotRadius, - trackLeft + trackWidth, - centerY + dotRadius, - dotRadius, - dotRadius, - Path.Direction.CW); - inactiveDotPath.addCircle( - centerX + indicatorOffset, centerY, indicatorRadius, Path.Direction.CW); - } else { - float trackRight = centerX + indicatorOffset + dotRadius; - inactiveDotPath.addRoundRect( - trackRight - trackWidth, - centerY - dotRadius, - trackRight, - centerY + dotRadius, - dotRadius, - dotRadius, - Path.Direction.CW); - inactiveDotPath.addCircle( - centerX - indicatorOffset, centerY, indicatorRadius, Path.Direction.CW); - } - } else { - float centerOffset = dotsSeparation / 2f; - float innerOffset = centerOffset - transitionFraction * (dotRadius + centerOffset); - float outerOffset = 2f * dotRadius + centerOffset; - inactiveDotPath.addRoundRect( - centerX - outerOffset, - centerY - dotRadius, - centerX - innerOffset, - centerY + dotRadius, - dotRadius, - dotRadius, - Path.Direction.CW); - inactiveDotPath.addRoundRect( - centerX + innerOffset, - centerY - dotRadius, - centerX + outerOffset, - centerY + dotRadius, - dotRadius, - dotRadius, - Path.Direction.CW); - } - Paint inactivePaint = inactiveDotPaintPortrait; - canvas.drawPath(inactiveDotPath, inactivePaint); - - // Draw the white active dot. - float activeDotOffset = - (toFirstPage ? 1f - 2f * progress : 2f * progress - 1f) * (dotRadius + dotsSeparation / 2); - Paint activePaint = activeDotPaintPortrait; - canvas.drawCircle(centerX + activeDotOffset, centerY, dotRadius, activePaint); - } - - public void setupWithViewPager(ViewPager pager) { - Assert.checkArgument(pager.getAdapter().getCount() == 2, "Invalid page count."); - pager.addOnPageChangeListener(this); - } - - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - setProgress(positionOffset, position != 0); - } - - @Override - public void onPageSelected(int position) { - pageChanged = true; - } - - @Override - public void onPageScrollStateChanged(int state) { - switch (state) { - case ViewPager.SCROLL_STATE_IDLE: - endTransition(!pageChanged); - pageChanged = false; - break; - case ViewPager.SCROLL_STATE_DRAGGING: - startTransition(); - break; - case ViewPager.SCROLL_STATE_SETTLING: - default: - break; - } - } -} diff --git a/java/com/android/incallui/incall/impl/LockableViewPager.java b/java/com/android/incallui/incall/impl/LockableViewPager.java deleted file mode 100644 index 5b8b12609..000000000 --- a/java/com/android/incallui/incall/impl/LockableViewPager.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016 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.content.Context; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.view.MotionEvent; - -/** {@link ViewPager} useful for disabled swiping between pages. */ -public class LockableViewPager extends ViewPager { - - private boolean swipingLocked; - - public LockableViewPager(Context context, AttributeSet attributeSet) { - super(context, attributeSet); - } - - public void setSwipingLocked(boolean swipingLocked) { - this.swipingLocked = swipingLocked; - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent motionEvent) { - return !swipingLocked && super.onInterceptTouchEvent(motionEvent); - } - - @Override - public boolean onTouchEvent(MotionEvent motionEvent) { - return !swipingLocked && super.onTouchEvent(motionEvent); - } -} diff --git a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml index e4bc942bb..9b950462c 100644 --- a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml +++ b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml @@ -60,21 +60,23 @@ android:layout_height="match_parent"/> - - + false 0 - - 5dp - 8dp - 38dp - 72dp diff --git a/java/com/android/incallui/incall/impl/res/values/styles.xml b/java/com/android/incallui/incall/impl/res/values/styles.xml index a8cf2ddf1..2392574a3 100644 --- a/java/com/android/incallui/incall/impl/res/values/styles.xml +++ b/java/com/android/incallui/incall/impl/res/values/styles.xml @@ -17,9 +17,6 @@ - #FFF - #66FFFFFF - diff --git a/java/com/android/incallui/maps/MapsComponent.java b/java/com/android/incallui/maps/MapsComponent.java index 796abaa92..1ca17b781 100644 --- a/java/com/android/incallui/maps/MapsComponent.java +++ b/java/com/android/incallui/maps/MapsComponent.java @@ -19,18 +19,29 @@ package com.android.incallui.maps; import android.content.Context; import com.android.dialer.inject.HasRootComponent; import dagger.Subcomponent; +import com.android.incallui.maps.stub.StubMapsModule; /** Subcomponent that can be used to access the maps implementation. */ -@Subcomponent -public abstract class MapsComponent { +public class MapsComponent { - public abstract Maps getMaps(); + private static MapsComponent instance; + private Maps maps; + + public Maps getMaps() { + if (maps == null) { + maps = new StubMapsModule.StubMaps(); + } + return maps; + } public static MapsComponent get(Context context) { - return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) - .mapsComponent(); + if (instance == null) { + instance = new MapsComponent(); + } + return instance; } + /** Used to refer to the root application component. */ public interface HasComponent { MapsComponent mapsComponent(); diff --git a/java/com/android/incallui/maps/stub/StubMapsModule.java b/java/com/android/incallui/maps/stub/StubMapsModule.java index 3a193b15d..72678143c 100644 --- a/java/com/android/incallui/maps/stub/StubMapsModule.java +++ b/java/com/android/incallui/maps/stub/StubMapsModule.java @@ -34,7 +34,7 @@ public abstract class StubMapsModule { @Singleton public abstract Maps bindMaps(StubMaps maps); - static final class StubMaps implements Maps { + static public final class StubMaps implements Maps { @Inject public StubMaps() {} diff --git a/java/com/android/incallui/res/values-uz/strings.xml b/java/com/android/incallui/res/values-uz/strings.xml index 585f983ac..fcf221f38 100644 --- a/java/com/android/incallui/res/values-uz/strings.xml +++ b/java/com/android/incallui/res/values-uz/strings.xml @@ -30,7 +30,7 @@ "Konferensiya qo‘ng‘irog‘i %s" "Ovozli pochta raqami" "Raqam terilmoqda" - "%s chaqiruvi javobsiz qoldi" + "%s qo‘ng‘irog‘i javobsiz qoldirildi" "Joriy qo‘ng‘iroq" "Chiquvchi ishchi qo‘ng‘irog‘i" "Chiquvchi Wi-Fi qo‘ng‘irog‘i" diff --git a/java/com/android/incallui/videotech/VideoTech.java b/java/com/android/incallui/videotech/VideoTech.java index bd957b699..fb2641793 100644 --- a/java/com/android/incallui/videotech/VideoTech.java +++ b/java/com/android/incallui/videotech/VideoTech.java @@ -27,12 +27,6 @@ public interface VideoTech { boolean isTransmittingOrReceiving(); - /** - * Determines if the answer video UI should open the camera directly instead of letting the video - * tech manage the camera. - */ - boolean isSelfManagedCamera(); - void onCallStateChanged(int newState); @SessionModificationState diff --git a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java index c76043540..bc8db4c07 100644 --- a/java/com/android/incallui/videotech/empty/EmptyVideoTech.java +++ b/java/com/android/incallui/videotech/empty/EmptyVideoTech.java @@ -31,11 +31,6 @@ public class EmptyVideoTech implements VideoTech { return false; } - @Override - public boolean isSelfManagedCamera() { - return false; - } - @Override public void onCallStateChanged(int newState) {} diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java index a37500c3b..890e5c80c 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java @@ -57,13 +57,6 @@ public class ImsVideoTech implements VideoTech { return VideoProfile.isVideo(call.getDetails().getVideoState()); } - @Override - public boolean isSelfManagedCamera() { - // Return false to indicate that the answer UI shouldn't open the camera itself. - // For IMS Video the modem is responsible for opening the camera. - return false; - } - @Override public void onCallStateChanged(int newState) { if (!isAvailable()) { diff --git a/java/com/android/incallui/videotech/rcs/RcsVideoShare.java b/java/com/android/incallui/videotech/rcs/RcsVideoShare.java index 1e951408c..2cb43036f 100644 --- a/java/com/android/incallui/videotech/rcs/RcsVideoShare.java +++ b/java/com/android/incallui/videotech/rcs/RcsVideoShare.java @@ -64,11 +64,6 @@ public class RcsVideoShare implements VideoTech, CapabilitiesListener, VideoShar || receivingSessionId != Session.NO_SESSION_ID; } - @Override - public boolean isSelfManagedCamera() { - return true; - } - @Override public void onCallStateChanged(int newState) { if (newState == Call.STATE_DISCONNECTING) { -- cgit v1.2.3