Bring escalation options UI closer to mock.

Bug: 28141203
Change-Id: Ia6d50d7d6f3010695c62fc1e8bd07f858715e455
This commit is contained in:
Fan Zhang
2016-04-28 15:20:09 -07:00
parent bc25322de8
commit cd09151224
10 changed files with 102 additions and 180 deletions

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFF"
android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27
0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55
-0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1
0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"/>
</vector>

View File

@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFF"
android:pathData="M20,2H4c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2V4c0,-1.1
-0.9,-2 -2,-2zM6,9h12v2H6V9zm8,5H6v-2h8v2zm4,-6H6V6h12v2z"/>
</vector>

View File

@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M20,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9
2,-2V6c0,-1.1 -0.9,-2 -2,-2zm0,4l-8,5 -8,-5V6l8,5 8,-5v2z"/>
</vector>

View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
android:layout_width="@dimen/dashboard_tile_image_size"
android:layout_height="@dimen/dashboard_tile_image_size"
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
android:scaleType="centerInside"/>
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.TileTitle"/>
</LinearLayout>
</android.support.v7.widget.CardView>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingStart="56dp"
android:paddingEnd="56dp">
<Button
android:id="@android:id/text1"
style="@style/SupportPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
<Button
android:id="@android:id/text2"
style="@style/SupportPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
</LinearLayout>

View File

@@ -19,22 +19,22 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:paddingTop="32dp"
android:paddingBottom="32dp"
android:paddingStart="56dp"
android:paddingEnd="56dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@android:id/text1" android:id="@android:id/text1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:textAppearance="@style/TextAppearance.SupportTitle"/> android:textAppearance="@style/TextAppearance.SupportTitle"/>
<TextView <TextView
android:id="@android:id/text2" android:id="@android:id/text2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:textAppearance="@style/TextAppearance.CategoryTitle"/> android:textAppearance="@style/TextAppearance.Small"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout> </LinearLayout>

View File

@@ -19,6 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/support_escalation_background"
android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
<Button <Button
android:id="@android:id/text1" android:id="@android:id/text1"

View File

@@ -131,4 +131,6 @@
<color name="usage_graph_dots">#B0BEC5</color> <color name="usage_graph_dots">#B0BEC5</color>
<color name="support_escalation_background">#eeeeee</color>
</resources> </resources>

View File

@@ -7486,10 +7486,10 @@
<string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string> <string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string>
<!-- Title text for connecting to customer support [CHAR LIMIT=80]--> <!-- Title text for connecting to customer support [CHAR LIMIT=80]-->
<string name="support_escalation_title">Around the clock help</string> <string name="support_escalation_title">Around-the-clock help</string>
<!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]--> <!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
<string name="support_escalation_summary">Call or email us and we\'ll get your issue solved right away. No muss, no fuss.</string> <string name="support_escalation_summary">You can request a support call or chat and we\'ll get back to you with a quickness</string>
<!-- Title text that indicates there is not internet connection. [CHAR LIMIT=80]--> <!-- Title text that indicates there is not internet connection. [CHAR LIMIT=80]-->
<string name="support_offline_title">You\'re offline</string> <string name="support_offline_title">You\'re offline</string>
@@ -7501,13 +7501,10 @@
<string name="support_more_help_title">More help</string> <string name="support_more_help_title">More help</string>
<!-- Button label for contacting customer support by phone [CHAR LIMIT=20]--> <!-- Button label for contacting customer support by phone [CHAR LIMIT=20]-->
<string name="support_escalation_by_phone">Phone</string> <string name="support_escalation_by_phone">Support call</string>
<!-- Button label for contacting customer support by phone [CHAR LIMIT=20]-->
<string name="support_escalation_by_phone_offline">Phone</string>
<!-- Button label for contacting customer support by email [CHAR LIMIT=20]--> <!-- Button label for contacting customer support by email [CHAR LIMIT=20]-->
<string name="support_escalation_by_email">Email</string> <string name="support_escalation_by_email">Support chat</string>
<!-- Button label for contacting customer support by chat [CHAR LIMIT=20]--> <!-- Button label for contacting customer support by chat [CHAR LIMIT=20]-->
<string name="support_escalation_by_chat">Chat</string> <string name="support_escalation_by_chat">Chat</string>
@@ -7522,7 +7519,7 @@
<string name="support_feedback_title">Send feedback</string> <string name="support_feedback_title">Send feedback</string>
<!-- Title text that indicates user needs to sign in to get customer support. [CHAR LIMIT=80]--> <!-- Title text that indicates user needs to sign in to get customer support. [CHAR LIMIT=80]-->
<string name="support_sign_in_required_title">Need assistance now?</string> <string name="support_sign_in_required_title">Sign in for support</string>
<!-- Summary text that indicates user needs to sign-in to get real time customer support. [CHAR LIMIT=NONE]--> <!-- Summary text that indicates user needs to sign-in to get real time customer support. [CHAR LIMIT=NONE]-->
<string name="support_sign_in_required_summary" translatable="false"></string> <string name="support_sign_in_required_summary" translatable="false"></string>

View File

@@ -36,7 +36,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.CHAT; import static com.android.settings.overlay.SupportFeatureProvider.SupportType.CHAT;
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.EMAIL;
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.PHONE; import static com.android.settings.overlay.SupportFeatureProvider.SupportType.PHONE;
/** /**
@@ -46,12 +45,12 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
private static final int TYPE_TITLE = R.layout.support_item_title; private static final int TYPE_TITLE = R.layout.support_item_title;
private static final int TYPE_SUBTITLE = R.layout.support_item_subtitle; private static final int TYPE_SUBTITLE = R.layout.support_item_subtitle;
private static final int TYPE_ESCALATION_CARD = R.layout.support_escalation_card; private static final int TYPE_ESCALATION_OPTIONS = R.layout.support_escalation_options;
private static final int TYPE_SUPPORT_TILE = R.layout.support_tile; private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
private static final int TYPE_SIGN_IN_BUTTON = R.layout.support_sign_in_button; private static final int TYPE_SIGN_IN_BUTTON = R.layout.support_sign_in_button;
private final Activity mActivity; private final Activity mActivity;
private final SignInPromoClickListener mSignInPromoClickListener; private final EscalationClickListener mEscalationClickListener;
private final SupportFeatureProvider mSupportFeatureProvider; private final SupportFeatureProvider mSupportFeatureProvider;
private final View.OnClickListener mItemClickListener; private final View.OnClickListener mItemClickListener;
private final List<SupportData> mSupportData; private final List<SupportData> mSupportData;
@@ -64,7 +63,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
mActivity = activity; mActivity = activity;
mSupportFeatureProvider = supportFeatureProvider; mSupportFeatureProvider = supportFeatureProvider;
mItemClickListener = itemClickListener; mItemClickListener = itemClickListener;
mSignInPromoClickListener = new SignInPromoClickListener(); mEscalationClickListener = new EscalationClickListener();
mSupportData = new ArrayList<>(); mSupportData = new ArrayList<>();
// Optimistically assume we have Internet access. It will be updated later to correct value. // Optimistically assume we have Internet access. It will be updated later to correct value.
mHasInternet = true; mHasInternet = true;
@@ -85,6 +84,9 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
case TYPE_SIGN_IN_BUTTON: case TYPE_SIGN_IN_BUTTON:
bindSignInPromoTile(holder, data); bindSignInPromoTile(holder, data);
break; break;
case TYPE_ESCALATION_OPTIONS:
bindEscalationOptions(holder, data);
break;
default: default:
bindSupportTile(holder, data); bindSupportTile(holder, data);
break; break;
@@ -152,21 +154,12 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
R.string.support_offline_title, R.string.support_offline_summary, R.string.support_offline_title, R.string.support_offline_summary,
null /* intent */)); null /* intent */));
} }
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) { final int phoneSupportText = mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_call_24dp, ? R.string.support_escalation_by_phone : 0;
R.string.support_escalation_by_phone, 0 /* summary */, final int chatSupportText = mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT)
mSupportFeatureProvider.getSupportIntent(mActivity, mAccount, PHONE))); ? R.string.support_escalation_by_chat : 0;
} mSupportData.add(new SupportData(TYPE_ESCALATION_OPTIONS, 0 /* icon */,
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, EMAIL)) { phoneSupportText, chatSupportText, null /* intent */));
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_mail_24dp,
R.string.support_escalation_by_email, 0 /* summary */,
mSupportFeatureProvider.getSupportIntent(mActivity, mAccount, EMAIL)));
}
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT)) {
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_chat_24dp,
R.string.support_escalation_by_chat, 0 /* summary */,
mSupportFeatureProvider.getSupportIntent(mActivity, mAccount, CHAT)));
}
} }
private void addSignInPromo() { private void addSignInPromo() {
@@ -191,11 +184,30 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
R.string.support_feedback_title, 0 /* summary */, null /*intent */)); R.string.support_feedback_title, 0 /* summary */, null /*intent */));
} }
private void bindEscalationOptions(ViewHolder holder, SupportData data) {
if (data.text1 == 0) {
holder.text1View.setVisibility(View.GONE);
} else {
holder.text1View.setText(data.text1);
holder.text1View.setOnClickListener(mEscalationClickListener);
holder.text1View.setEnabled(mHasInternet);
holder.text1View.setVisibility(View.VISIBLE);
}
if (data.text2 == 0) {
holder.text2View.setVisibility(View.GONE);
} else {
holder.text2View.setText(data.text2);
holder.text2View.setOnClickListener(mEscalationClickListener);
holder.text2View.setEnabled(mHasInternet);
holder.text2View.setVisibility(View.VISIBLE);
}
}
private void bindSignInPromoTile(ViewHolder holder, SupportData data) { private void bindSignInPromoTile(ViewHolder holder, SupportData data) {
holder.text1View.setText(data.text1); holder.text1View.setText(data.text1);
holder.text2View.setText(data.text2); holder.text2View.setText(data.text2);
holder.text1View.setOnClickListener(mSignInPromoClickListener); holder.text1View.setOnClickListener(mEscalationClickListener);
holder.text2View.setOnClickListener(mSignInPromoClickListener); holder.text2View.setOnClickListener(mEscalationClickListener);
} }
private void bindSupportTile(ViewHolder holder, SupportData data) { private void bindSupportTile(ViewHolder holder, SupportData data) {
@@ -212,24 +224,29 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
} }
/** /**
* Click handler for sign-in promo. * Click handler for starting escalation options.
*/ */
private final class SignInPromoClickListener implements View.OnClickListener { private final class EscalationClickListener implements View.OnClickListener {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case android.R.id.text1: case android.R.id.text1: {
mActivity.startActivityForResult( final Intent intent = mAccount == null
mSupportFeatureProvider.getAccountLoginIntent(), 0 /* requestCode */); ? mSupportFeatureProvider.getAccountLoginIntent()
: mSupportFeatureProvider.getSupportIntent(mActivity, mAccount, PHONE);
mActivity.startActivityForResult(intent, 0 /* requestCode */);
break; break;
case android.R.id.text2: }
mActivity.startActivityForResult( case android.R.id.text2: {
mSupportFeatureProvider.getSignInHelpIntent(mActivity), final Intent intent = mAccount == null
0 /* requestCode */); ? mSupportFeatureProvider.getSignInHelpIntent(mActivity)
: mSupportFeatureProvider.getSupportIntent(mActivity, mAccount, CHAT);
mActivity.startActivityForResult(intent, 0 /* requestCode */);
break; break;
} }
} }
} }
}
/** /**
* {@link RecyclerView.ViewHolder} for support items. * {@link RecyclerView.ViewHolder} for support items.