summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/video
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-03-06 16:51:38 -0800
committerCopybara-Service <copybara-piper@google.com>2018-03-06 16:54:07 -0800
commitda410d32f17dd823dba772181271ff55ee8e3eaf (patch)
tree454b1b7cfa72d077b125d9351a8a2fdd0272fd75 /java/com/android/incallui/video
parenta05ee285f99e06efa130453eac12f02161cd3a64 (diff)
Show a warning dialog about charges when user starts a video call
The user starts a video call a warning dialog shall be presented. If the user presses "OK" with the "Do not show again" box selected, the dialog shall not be presented anymore. Test: manual - Verified that a warning dialog about charges is shown when a video call is started if KEY_SHOW_VIDEO_CALL_CHARGES_ALERT_DIALOG_BOOL is true. This is an upstream change from: https://android-review.googlesource.com/c/platform/packages/apps/Dialer/+/518977/8 Bug: 67832837 Test: partner manual test PiperOrigin-RevId: 188103414 Change-Id: I62628a32557297acaef096db90d2ddf049ef5017
Diffstat (limited to 'java/com/android/incallui/video')
-rw-r--r--java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java3
-rw-r--r--java/com/android/incallui/video/impl/VideoCallFragment.java29
-rw-r--r--java/com/android/incallui/video/impl/VideoChargesAlertDialogFragment.java141
-rw-r--r--java/com/android/incallui/video/impl/res/layout/frag_video_charges_alert_dialog.xml51
-rw-r--r--java/com/android/incallui/video/impl/res/values/strings.xml6
-rw-r--r--java/com/android/incallui/video/protocol/VideoCallScreen.java2
6 files changed, 232 insertions, 0 deletions
diff --git a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
index 28ee774ba..b97d2eb16 100644
--- a/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/SurfaceViewVideoCallFragment.java
@@ -725,6 +725,9 @@ public class SurfaceViewVideoCallFragment extends Fragment
}
@Override
+ public void onHandoverFromWiFiToLte() {}
+
+ @Override
public void showButton(@InCallButtonIds int buttonId, boolean show) {
LogUtil.v(
"SurfaceViewVideoCallFragment.showButton",
diff --git a/java/com/android/incallui/video/impl/VideoCallFragment.java b/java/com/android/incallui/video/impl/VideoCallFragment.java
index 6b5a9797f..2a810cfcd 100644
--- a/java/com/android/incallui/video/impl/VideoCallFragment.java
+++ b/java/com/android/incallui/video/impl/VideoCallFragment.java
@@ -99,6 +99,8 @@ public class VideoCallFragment extends Fragment
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
static final String ARG_CALL_ID = "call_id";
+ private static final String TAG_VIDEO_CHARGES_ALERT = "tag_video_charges_alert";
+
@VisibleForTesting static final float BLUR_PREVIEW_RADIUS = 16.0f;
@VisibleForTesting static final float BLUR_PREVIEW_SCALE_FACTOR = 1.0f;
private static final float BLUR_REMOTE_RADIUS = 25.0f;
@@ -108,6 +110,7 @@ public class VideoCallFragment extends Fragment
private static final int CAMERA_PERMISSION_REQUEST_CODE = 1;
private static final long CAMERA_PERMISSION_DIALOG_DELAY_IN_MILLIS = 2000L;
private static final long VIDEO_OFF_VIEW_FADE_OUT_DELAY_IN_MILLIS = 2000L;
+ private static final long VIDEO_CHARGES_ALERT_DIALOG_DELAY_IN_MILLIS = 500L;
private final ViewOutlineProvider circleOutlineProvider =
new ViewOutlineProvider() {
@@ -162,6 +165,24 @@ public class VideoCallFragment extends Fragment
}
};
+ private final Runnable videoChargesAlertDialogRunnable =
+ () -> {
+ VideoChargesAlertDialogFragment existingVideoChargesAlertFragment =
+ (VideoChargesAlertDialogFragment)
+ getChildFragmentManager().findFragmentByTag(TAG_VIDEO_CHARGES_ALERT);
+ if (existingVideoChargesAlertFragment != null) {
+ LogUtil.i(
+ "VideoCallFragment.videoChargesAlertDialogRunnable", "already shown for this call");
+ return;
+ }
+
+ if (VideoChargesAlertDialogFragment.shouldShow(getContext(), getCallId())) {
+ LogUtil.i("VideoCallFragment.videoChargesAlertDialogRunnable", "showing dialog");
+ VideoChargesAlertDialogFragment.newInstance(getCallId())
+ .show(getChildFragmentManager(), TAG_VIDEO_CHARGES_ALERT);
+ }
+ };
+
public static VideoCallFragment newInstance(String callId) {
Bundle bundle = new Bundle();
bundle.putString(ARG_CALL_ID, Assert.isNotNull(callId));
@@ -352,6 +373,8 @@ public class VideoCallFragment extends Fragment
inCallButtonUiDelegate.refreshMuteState();
videoCallScreenDelegate.onVideoCallScreenUiReady();
getView().postDelayed(cameraPermissionDialogRunnable, CAMERA_PERMISSION_DIALOG_DELAY_IN_MILLIS);
+ getView()
+ .postDelayed(videoChargesAlertDialogRunnable, VIDEO_CHARGES_ALERT_DIALOG_DELAY_IN_MILLIS);
}
@Override
@@ -377,6 +400,7 @@ public class VideoCallFragment extends Fragment
@Override
public void onVideoScreenStop() {
+ getView().removeCallbacks(videoChargesAlertDialogRunnable);
getView().removeCallbacks(cameraPermissionDialogRunnable);
videoCallScreenDelegate.onVideoCallScreenUiUnready();
}
@@ -768,6 +792,11 @@ public class VideoCallFragment extends Fragment
}
@Override
+ public void onHandoverFromWiFiToLte() {
+ getView().post(videoChargesAlertDialogRunnable);
+ }
+
+ @Override
public void showButton(@InCallButtonIds int buttonId, boolean show) {
LogUtil.v(
"VideoCallFragment.showButton",
diff --git a/java/com/android/incallui/video/impl/VideoChargesAlertDialogFragment.java b/java/com/android/incallui/video/impl/VideoChargesAlertDialogFragment.java
new file mode 100644
index 000000000..6762a9d22
--- /dev/null
+++ b/java/com/android/incallui/video/impl/VideoChargesAlertDialogFragment.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2018 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.video.impl;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.os.UserManagerCompat;
+import android.telecom.Call.Details;
+import android.view.View;
+import android.widget.CheckBox;
+import com.android.dialer.common.Assert;
+import com.android.dialer.common.LogUtil;
+import com.android.incallui.call.CallList;
+import com.android.incallui.call.DialerCall;
+
+/** Alert dialog for video charges. */
+public class VideoChargesAlertDialogFragment extends DialogFragment {
+
+ /** Preference key for whether to show the alert dialog for video charges next time. */
+ @VisibleForTesting
+ static final String KEY_DO_NOT_SHOW_VIDEO_CHARGES_ALERT = "key_do_not_show_video_charges_alert";
+
+ /** Key in the arguments bundle for call id. */
+ private static final String ARG_CALL_ID = "call_id";
+
+ /**
+ * Returns {@code true} if an {@link VideoChargesAlertDialogFragment} should be shown.
+ *
+ * <p>Attempting to show an VideoChargesAlertDialogFragment when this method returns {@code false}
+ * will result in an {@link IllegalStateException}.
+ */
+ public static boolean shouldShow(@NonNull Context context, String callId) {
+ DialerCall call = CallList.getInstance().getCallById(callId);
+ if (call == null) {
+ LogUtil.i("VideoChargesAlertDialogFragment.shouldShow", "null call");
+ return false;
+ }
+
+ if (call.hasProperty(Details.PROPERTY_WIFI)) {
+ return false;
+ }
+
+ if (call.didDismissVideoChargesAlertDialog()) {
+ LogUtil.i(
+ "VideoChargesAlertDialogFragment.shouldShow", "The dialog has been dismissed by user");
+ return false;
+ }
+
+ if (!call.showVideoChargesAlertDialog()) {
+ return false;
+ }
+
+ if (!UserManagerCompat.isUserUnlocked(context)) {
+ LogUtil.i("VideoChargesAlertDialogFragment.shouldShow", "user locked, returning false");
+ return false;
+ }
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ if (preferences.getBoolean(KEY_DO_NOT_SHOW_VIDEO_CHARGES_ALERT, false)) {
+ LogUtil.i(
+ "VideoChargesAlertDialogFragment.shouldShow",
+ "Video charges alert has been disabled by user, returning false");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns a new instance of {@link VideoChargesAlertDialogFragment}
+ *
+ * <p>Prefer this method over the default constructor.
+ */
+ public static VideoChargesAlertDialogFragment newInstance(@NonNull String callId) {
+ VideoChargesAlertDialogFragment fragment = new VideoChargesAlertDialogFragment();
+ Bundle args = new Bundle();
+ args.putString(ARG_CALL_ID, Assert.isNotNull(callId));
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle bundle) {
+ super.onCreateDialog(bundle);
+
+ if (!VideoChargesAlertDialogFragment.shouldShow(
+ getActivity(), getArguments().getString(ARG_CALL_ID))) {
+ throw new IllegalStateException(
+ "shouldShow indicated VideoChargesAlertDialogFragment should not have showed");
+ }
+
+ View dialogView = View.inflate(getActivity(), R.layout.frag_video_charges_alert_dialog, null);
+
+ CheckBox alertCheckBox = dialogView.findViewById(R.id.do_not_show);
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ AlertDialog alertDialog =
+ new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
+ .setView(dialogView)
+ .setPositiveButton(
+ android.R.string.ok,
+ (dialog, which) -> onPositiveButtonClicked(preferences, alertCheckBox.isChecked()))
+ .create();
+ this.setCancelable(false);
+ return alertDialog;
+ }
+
+ private void onPositiveButtonClicked(@NonNull SharedPreferences preferences, boolean isChecked) {
+ LogUtil.i(
+ "VideoChargesAlertDialogFragment.onPositiveButtonClicked", "isChecked: %b", isChecked);
+ preferences.edit().putBoolean(KEY_DO_NOT_SHOW_VIDEO_CHARGES_ALERT, isChecked).apply();
+
+ DialerCall dialerCall =
+ CallList.getInstance().getCallById(getArguments().getString(ARG_CALL_ID));
+ if (dialerCall != null) {
+ dialerCall.setDidDismissVideoChargesAlertDialog(true);
+ }
+ }
+}
diff --git a/java/com/android/incallui/video/impl/res/layout/frag_video_charges_alert_dialog.xml b/java/com/android/incallui/video/impl/res/layout/frag_video_charges_alert_dialog.xml
new file mode 100644
index 000000000..a547c7d69
--- /dev/null
+++ b/java/com/android/incallui/video/impl/res/layout/frag_video_charges_alert_dialog.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="24dp"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingBottom="4dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:text="@string/videocall_charges_alert_dialog_description"
+ android:textColor="@color/dialer_primary_text_color"
+ android:textSize="16sp"/>
+
+ <CheckBox
+ android:id="@+id/do_not_show"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:buttonTint="@color/dialer_theme_color"
+ android:focusable="true"
+ android:clickable="true"
+ android:text="@string/do_not_show_again"
+ android:textColor="@color/dialer_primary_text_color"
+ android:textSize="14sp"/>
+ </LinearLayout>
+</ScrollView> \ No newline at end of file
diff --git a/java/com/android/incallui/video/impl/res/values/strings.xml b/java/com/android/incallui/video/impl/res/values/strings.xml
index 58ea8bde7..6c90af5f3 100644
--- a/java/com/android/incallui/video/impl/res/values/strings.xml
+++ b/java/com/android/incallui/video/impl/res/values/strings.xml
@@ -29,4 +29,10 @@
<!-- Text indicates the call is resumed from held by remote party. [CHAR LIMIT=20] -->
<string name="videocall_remotely_resumed">Call resumed</string>
+ <!-- Instruction text to notify user that charges may apply on video calling. [CHAR LIMIT=NONE] -->
+ <string name="videocall_charges_alert_dialog_description">Video calls made over the mobile network use both data and voice minutes. Charges may apply.</string>
+
+ <!-- Option to hide the popup dialog if it is not necessary for the user. [CHAR LIMIT=40] -->
+ <string name="do_not_show_again">Do not show again</string>
+
</resources>
diff --git a/java/com/android/incallui/video/protocol/VideoCallScreen.java b/java/com/android/incallui/video/protocol/VideoCallScreen.java
index bad050cd1..582d4c64b 100644
--- a/java/com/android/incallui/video/protocol/VideoCallScreen.java
+++ b/java/com/android/incallui/video/protocol/VideoCallScreen.java
@@ -39,4 +39,6 @@ public interface VideoCallScreen {
Fragment getVideoCallScreenFragment();
String getCallId();
+
+ void onHandoverFromWiFiToLte();
}