Skip to content

Commit e517981

Browse files
Shuo Qianandroid-build-merger
authored andcommitted
Merge "Introduce the new UX of call redirection dialog UX" into qt-dev am: 0fd0ebf
am: 323a61e Change-Id: I325f8c51b780a4655f5e4adeacd01859b6b0a29c
2 parents 579e30a + 323a61e commit e517981

File tree

8 files changed

+245
-72
lines changed

8 files changed

+245
-72
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2019 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="?android:attr/colorControlHighlight" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2019 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License
16+
-->
17+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
18+
<solid android:color="@android:color/white"/>
19+
<corners android:radius="15dp" />
20+
</shape>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2019 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License
16+
-->
17+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="match_parent"
19+
android:layout_height="match_parent"
20+
android:paddingTop="0dp"
21+
android:paddingBottom="0dp"
22+
android:background="@drawable/call_redirection_dialog_background"
23+
android:orientation="vertical">
24+
25+
<ImageView
26+
android:layout_width="match_parent"
27+
android:layout_height="match_parent"
28+
android:layout_gravity="center"
29+
android:paddingTop="@dimen/call_redirection_dialog_image_upper_margin"
30+
android:paddingBottom="@dimen/call_redirection_dialog_image_bottom_margin"
31+
android:tint="@color/call_redirection_dialog_icon_tint_color"
32+
android:src="@drawable/ic_phone"/>
33+
34+
<TextView
35+
android:layout_width="wrap_content"
36+
android:layout_height="wrap_content"
37+
android:layout_gravity="center"
38+
android:paddingBottom="@dimen/call_redirection_dialog_title_bottom_margin"
39+
android:text="@string/alert_redirect_outgoing_call_or_not"
40+
android:textColor="@color/call_redirection_dialog_text_color"
41+
android:textSize="@dimen/call_redirection_dialog_title_font_size"
42+
android:textStyle="bold"/>
43+
44+
<View
45+
android:layout_width="fill_parent"
46+
android:layout_height="1dp"
47+
android:background="@color/call_redirection_dialog_view_divider_color"/>
48+
49+
<Button
50+
android:id="@+id/buttonFirstLine"
51+
android:text="@string/alert_place_unredirect_outgoing_call"
52+
android:layout_width="fill_parent"
53+
android:layout_height="wrap_content"
54+
android:gravity="left"
55+
android:background="@drawable/call_redirection_button_ripple_effect"
56+
android:paddingTop="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
57+
android:paddingBottom="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
58+
android:paddingLeft="@dimen/call_redirection_dialog_button_text_left_margin"
59+
android:paddingRight="@dimen/call_redirection_dialog_button_text_left_margin"
60+
android:textColor="@color/call_redirection_dialog_text_color"
61+
android:textSize="@dimen/call_redirection_dialog_button_font_size"
62+
android:textAllCaps="false"/>
63+
64+
<View
65+
android:layout_width="fill_parent"
66+
android:layout_height="1dp"
67+
android:background="@color/call_redirection_dialog_view_divider_color"/>
68+
69+
<Button
70+
android:id="@+id/buttonSecondLine"
71+
android:text="@string/alert_place_outgoing_call_with_redirection"
72+
android:layout_width="fill_parent"
73+
android:layout_height="wrap_content"
74+
android:gravity="left"
75+
android:background="@drawable/call_redirection_button_ripple_effect"
76+
android:paddingTop="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
77+
android:paddingBottom="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
78+
android:paddingLeft="@dimen/call_redirection_dialog_button_text_left_margin"
79+
android:textColor="@color/call_redirection_dialog_text_color"
80+
android:textSize="@dimen/call_redirection_dialog_button_font_size"
81+
android:textAllCaps="false"/>
82+
83+
<View
84+
android:layout_width="fill_parent"
85+
android:layout_height="1dp"
86+
android:background="@color/call_redirection_dialog_view_divider_color"/>
87+
88+
<Button
89+
android:id="@+id/buttonThirdLine"
90+
android:text="@string/cancel"
91+
android:layout_width="fill_parent"
92+
android:layout_height="wrap_content"
93+
android:gravity="left"
94+
android:background="@drawable/call_redirection_button_ripple_effect"
95+
android:paddingTop="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
96+
android:paddingBottom="@dimen/call_redirection_dialog_button_text_upper_bottom_margin"
97+
android:paddingLeft="@dimen/call_redirection_dialog_button_text_left_margin"
98+
android:paddingRight="@dimen/call_redirection_dialog_button_text_left_margin"
99+
android:textColor="@color/call_redirection_dialog_text_color"
100+
android:textSize="@dimen/call_redirection_dialog_button_font_size"
101+
android:textAllCaps="false"/>
102+
103+
</LinearLayout>

res/values/colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@
2727
<!--follows dialer color-->
2828
<color name="notification_action_answer">#097138</color>
2929
<color name="notification_action_decline">#A52714</color>
30+
31+
<color name="call_redirection_dialog_icon_tint_color">#4089F4</color>
32+
<color name="call_redirection_dialog_text_color">#212121</color>
33+
<color name="call_redirection_dialog_view_divider_color">#B8B8B8</color>
34+
3035
</resources>

res/values/dimens.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@
3333
<dimen name="blocked_numbers_line_spacing">8sp</dimen>
3434
<dimen name="blocked_numbers_secondary_line_spacing">6sp</dimen>
3535
<dimen name="blocked_numbers_divider_stroke">1dp</dimen>
36+
37+
<dimen name="call_redirection_dialog_title_font_size">18sp</dimen>
38+
<dimen name="call_redirection_dialog_button_font_size">16sp</dimen>
39+
<dimen name="call_redirection_dialog_image_upper_margin">16dp</dimen>
40+
<dimen name="call_redirection_dialog_image_bottom_margin">10dp</dimen>
41+
<dimen name="call_redirection_dialog_title_bottom_margin">26dp</dimen>
42+
<dimen name="call_redirection_dialog_button_text_upper_bottom_margin">15dp</dimen>
43+
<dimen name="call_redirection_dialog_button_text_left_margin">15dp</dimen>
44+
3645
</resources>

res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,13 @@
282282
<string name="alert_outgoing_call">Placing this call will end your <xliff:g id="other_app">%1$s</xliff:g> call.</string>
283283

284284
<!-- Alert dialog content used to ask the user to confirm if they want to place a new outgoing call redirected by the app "other_app". -->
285-
<string name="alert_redirect_outgoing_call">Allow <xliff:g id="other_app">%1$s</xliff:g> to place call using a different number?</string>
285+
<string name="alert_redirect_outgoing_call_or_not">Choose how to place this call</string>
286286

287287
<!-- A button in the alert dialog "alert_redirect_outgoing_call" to place the call with the redirected number provided by App. -->
288-
<string name="alert_place_redirect_outgoing_call">Call with <xliff:g id="other_app">%1$s</xliff:g></string>
288+
<string name="alert_place_outgoing_call_with_redirection">Redirect call using <xliff:g id="other_app">%1$s</xliff:g></string>
289289

290290
<!-- A button in the alert dialog "alert_redirect_outgoing_call" to place the call without the redirected number provided by App. -->
291-
<string name="alert_place_unredirect_outgoing_call">Call without <xliff:g id="other_app">%1$s</xliff:g></string>
291+
<string name="alert_place_unredirect_outgoing_call">Call using my phone number</string>
292292

293293
<!-- Alert dialog content used to tell the user the call is canceled because no response from the call redirection app "other_app". -->
294294
<string name="alert_redirect_outgoing_call_timeout">Call can\'t be placed by <xliff:g id="other_app">%1$s</xliff:g>. Try using a different call redirecting app or contacting the developer for help.</string>

src/com/android/server/telecom/ui/CallRedirectionConfirmDialogActivity.java

Lines changed: 83 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@
2424
import android.app.AlertDialog;
2525
import android.content.DialogInterface;
2626
import android.content.Intent;
27+
import android.graphics.Color;
28+
import android.graphics.drawable.ColorDrawable;
2729
import android.os.Bundle;
2830
import android.telecom.Log;
31+
import android.view.LayoutInflater;
32+
import android.view.View.OnClickListener;
33+
import android.view.View;
34+
import android.widget.Button;
2935

3036
/**
3137
* Dialog activity used when there is an ongoing call redirected by the call redirection service.
@@ -48,73 +54,83 @@ protected void onCreate(Bundle savedInstanceState) {
4854

4955
private void showDialog(final CharSequence redirectionAppName) {
5056
Log.i(this, "showDialog: confirming redirection with %s", redirectionAppName);
51-
CharSequence message = getString(
52-
R.string.alert_redirect_outgoing_call, redirectionAppName);
53-
final AlertDialog confirmDialog = new AlertDialog.Builder(this)
54-
.setMessage(message)
55-
.setPositiveButton(getString(R.string.alert_place_redirect_outgoing_call,
56-
redirectionAppName), new DialogInterface.OnClickListener() {
57-
@Override
58-
public void onClick(DialogInterface dialog, int which) {
59-
Intent proceedWithRedirectedCall = new Intent(
60-
TelecomBroadcastIntentProcessor
61-
.ACTION_PLACE_REDIRECTED_CALL, null,
62-
CallRedirectionConfirmDialogActivity.this,
63-
TelecomBroadcastReceiver.class);
64-
proceedWithRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
65-
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
66-
sendBroadcast(proceedWithRedirectedCall);
67-
dialog.dismiss();
68-
finish();
69-
}
70-
})
71-
.setNegativeButton(getString(R.string.alert_place_unredirect_outgoing_call,
72-
redirectionAppName), new DialogInterface.OnClickListener() {
73-
@Override
74-
public void onClick(DialogInterface dialog, int which) {
75-
Intent proceedWithoutRedirectedCall = new Intent(
76-
TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL,
77-
null, CallRedirectionConfirmDialogActivity.this,
78-
TelecomBroadcastReceiver.class);
79-
proceedWithoutRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
80-
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
81-
sendBroadcast(proceedWithoutRedirectedCall);
82-
dialog.dismiss();
83-
finish();
84-
}
85-
})
86-
.setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
87-
@Override
88-
public void onClick(DialogInterface dialog, int which) {
89-
Intent cancelRedirectedCall = new Intent(
90-
TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
91-
null, CallRedirectionConfirmDialogActivity.this,
92-
TelecomBroadcastReceiver.class);
93-
cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
94-
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
95-
sendBroadcast(cancelRedirectedCall);
96-
dialog.dismiss();
97-
finish();
98-
}
99-
})
100-
.setOnCancelListener(new DialogInterface.OnCancelListener() {
101-
@Override
102-
public void onCancel(DialogInterface dialog) {
103-
Intent cancelRedirectedCall = new Intent(
104-
TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
105-
null, CallRedirectionConfirmDialogActivity.this,
106-
TelecomBroadcastReceiver.class);
107-
cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
108-
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
109-
sendBroadcast(cancelRedirectedCall);
110-
dialog.dismiss();
111-
finish();
112-
}
113-
})
114-
.create();
57+
58+
final AlertDialog confirmDialog = new AlertDialog.Builder(this).create();
59+
LayoutInflater layoutInflater = LayoutInflater.from(this);
60+
View dialogView = layoutInflater.inflate(R.layout.call_redirection_confirm_dialog, null);
61+
62+
Button buttonFirstLine = (Button) dialogView.findViewById(R.id.buttonFirstLine);
63+
buttonFirstLine.setOnClickListener(new OnClickListener() {
64+
@Override
65+
public void onClick(View v) {
66+
Intent proceedWithoutRedirectedCall = new Intent(
67+
TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL,
68+
null, CallRedirectionConfirmDialogActivity.this,
69+
TelecomBroadcastReceiver.class);
70+
proceedWithoutRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
71+
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
72+
sendBroadcast(proceedWithoutRedirectedCall);
73+
confirmDialog.dismiss();
74+
finish();
75+
}
76+
});
77+
78+
Button buttonSecondLine = (Button) dialogView.findViewById(R.id.buttonSecondLine);
79+
buttonSecondLine.setText(getString(R.string.alert_place_outgoing_call_with_redirection,
80+
redirectionAppName));
81+
buttonSecondLine.setOnClickListener(new OnClickListener() {
82+
@Override
83+
public void onClick(View v) {
84+
Intent proceedWithRedirectedCall = new Intent(
85+
TelecomBroadcastIntentProcessor
86+
.ACTION_PLACE_REDIRECTED_CALL, null,
87+
CallRedirectionConfirmDialogActivity.this,
88+
TelecomBroadcastReceiver.class);
89+
proceedWithRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
90+
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
91+
sendBroadcast(proceedWithRedirectedCall);
92+
confirmDialog.dismiss();
93+
finish();
94+
}
95+
});
96+
97+
Button buttonThirdLine = (Button) dialogView.findViewById(R.id.buttonThirdLine);
98+
buttonThirdLine.setOnClickListener(new OnClickListener() {
99+
public void onClick(View v) {
100+
Intent cancelRedirectedCall = new Intent(
101+
TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
102+
null, CallRedirectionConfirmDialogActivity.this,
103+
TelecomBroadcastReceiver.class);
104+
cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
105+
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
106+
sendBroadcast(cancelRedirectedCall);
107+
confirmDialog.dismiss();
108+
finish();
109+
}
110+
});
111+
112+
confirmDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
113+
@Override
114+
public void onCancel(DialogInterface dialog) {
115+
Intent cancelRedirectedCall = new Intent(
116+
TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
117+
null, CallRedirectionConfirmDialogActivity.this,
118+
TelecomBroadcastReceiver.class);
119+
cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
120+
getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
121+
sendBroadcast(cancelRedirectedCall);
122+
dialog.dismiss();
123+
finish();
124+
}
125+
});
126+
127+
confirmDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
128+
129+
confirmDialog.setCancelable(false);
130+
confirmDialog.setCanceledOnTouchOutside(false);
131+
132+
confirmDialog.setView(dialogView);
133+
115134
confirmDialog.show();
116-
confirmDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setAllCaps(false);
117-
confirmDialog.getButton(DialogInterface.BUTTON_POSITIVE).setAllCaps(false);
118-
confirmDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setAllCaps(false);
119135
}
120136
}

testapps/src/com/android/server/telecom/testapps/TestCallRedirectionService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static TestCallRedirectionService getInstance() {
4141
"com.android.server.telecom.testapps.TestCallRedirectionService"),
4242
"TELECOM_TEST_APP_PHONE_ACCOUNT_ID");
4343

44+
private PhoneAccountHandle mDestinationPhoneAccount = SAMPLE_PHONE_ACCOUNT;
45+
4446
/**
4547
* Handles request from the system to redirect an outgoing call.
4648
*/
@@ -49,14 +51,14 @@ public void onPlaceCall(@NonNull Uri handle, @NonNull PhoneAccountHandle initial
4951
boolean allowInteractiveResponse) {
5052
Log.i(this, "onPlaceCall: received call %s", handle);
5153
sTestCallRedirectionService = this;
52-
54+
mDestinationPhoneAccount = initialPhoneAccount;
5355
Intent intent = new Intent(this, CallRedirectionActivity.class);
5456
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
5557
startActivity(intent);
5658
}
5759

5860
public void tryRedirectCallAndAskToConfirm() {
5961
// Provide call identification
60-
redirectCall(SAMPLE_HANDLE, SAMPLE_PHONE_ACCOUNT, true);
62+
redirectCall(SAMPLE_HANDLE, mDestinationPhoneAccount, true);
6163
}
6264
}

0 commit comments

Comments
 (0)