Display operation hours when support is closed.

Bug: 29105266
Change-Id: Id451b1aa820961fad4ece07fde5782a5aecaee68
This commit is contained in:
Fan Zhang
2016-06-20 12:34:03 -07:00
parent a00e3b78de
commit 0bc42ab618
3 changed files with 53 additions and 37 deletions

View File

@@ -7511,16 +7511,21 @@
<string name="support_escalation_24_7_title">We\'re here for you 24/7</string> <string name="support_escalation_24_7_title">We\'re here for you 24/7</string>
<!-- Title text when customer support is closed [CHAR LIMIT=80]--> <!-- Title text when customer support is closed [CHAR LIMIT=80]-->
<string name="support_escalation_closed_title">Live support closed</string> <string name="support_escalation_closed_title">Support closed</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">Our support team is here to address any issues as soon as we can.</string> <string name="support_escalation_summary">Our support team is here to address any issues</string>
<!-- Summary text for connecting to 24/7 customer support [CHAR LIMIT=NONE]--> <!-- Summary text for connecting to 24/7 customer support [CHAR LIMIT=NONE]-->
<string name="support_escalation_24_7_summary">Our support team is here all day, every day.</string> <string name="support_escalation_24_7_summary">Our support team is here all day, every day</string>
<!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]--> <!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
<string name="support_escalation_closed_summary">Come back again during support hours.</string> <string name="support_escalation_closed_summary">Call us during support hours (local time)&lt;br&gt;&lt;b&gt;<xliff:g id="operation_hours">%s</xliff:g>&lt;/b&gt;</string>
<!-- Template for formatting support hours eg Mon - Fri, 8:00 AM - 19:30 PM. [CHAR LIMIT=NONE]-->
<string name="support_hour_format" translatable="false">
<xliff:g id="start_day">%s</xliff:g> - <xliff:g id="end_day">%s</xliff:g>, <xliff:g id="start_time">%s</xliff:g> - <xliff:g id="end_time">%s</xliff:g>&lt;br&gt;
</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>
@@ -7529,13 +7534,10 @@
<string name="support_offline_summary">To reach support, first connect to Wi-Fi or data.</string> <string name="support_offline_summary">To reach support, first connect to Wi-Fi or data.</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">Support call</string> <string name="support_escalation_by_phone">Phone</string>
<!-- Button label for contacting customer support by email [CHAR LIMIT=20]-->
<string name="support_escalation_by_email">Support email</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">Support chat</string> <string name="support_escalation_by_chat">Chat</string>
<!-- Button label for visiting the tips & tricks site [CHAR LIMIT=60]--> <!-- Button label for visiting the tips & tricks site [CHAR LIMIT=60]-->
<string name="support_tips_and_tricks_title">Tips &amp; tricks</string> <string name="support_tips_and_tricks_title">Tips &amp; tricks</string>

View File

@@ -21,8 +21,10 @@ import android.annotation.LayoutRes;
import android.annotation.StringRes; import android.annotation.StringRes;
import android.app.Activity; import android.app.Activity;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -153,30 +155,31 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
private void addEscalationCards() { private void addEscalationCards() {
if (mHasInternet) { if (mHasInternet) {
if (mSupportFeatureProvider.isAlwaysOperating(PHONE) if (mSupportFeatureProvider.isAlwaysOperating(PHONE)
|| mSupportFeatureProvider.isAlwaysOperating(CHAT)) { || mSupportFeatureProvider.isAlwaysOperating(CHAT)) {
mSupportData.add(new SupportData.Builder(TYPE_TITLE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
.setText1(R.string.support_escalation_24_7_title) .setText1(R.string.support_escalation_24_7_title)
.setText2(R.string.support_escalation_24_7_summary) .setText2(mActivity.getString(R.string.support_escalation_24_7_summary))
.build()); .build());
} else if (mSupportFeatureProvider.isOperatingNow(PHONE) } else if (mSupportFeatureProvider.isOperatingNow(PHONE)
|| mSupportFeatureProvider.isOperatingNow(CHAT)) { || mSupportFeatureProvider.isOperatingNow(CHAT)) {
mSupportData.add(new SupportData.Builder(TYPE_TITLE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
.setText1(R.string.support_escalation_title) .setText1(R.string.support_escalation_title)
.setText2(R.string.support_escalation_summary) .setText2(R.string.support_escalation_summary)
.build()); .build());
} else { } else {
mSupportData.add(new SupportData.Builder(TYPE_TITLE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
.setText1(R.string.support_escalation_closed_title) .setText1(R.string.support_escalation_closed_title)
.setText2(R.string.support_escalation_closed_summary) .setText2(mSupportFeatureProvider.getOperationHours(mActivity, PHONE))
.build()); .build());
} }
} else { } else {
mSupportData.add(new SupportData.Builder(TYPE_TITLE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
.setText1(R.string.support_offline_title) .setText1(R.string.support_offline_title)
.setText2(R.string.support_offline_summary) .setText2(R.string.support_offline_summary)
.build()); .build());
} }
final SupportData.Builder builder = new SupportData.Builder(TYPE_ESCALATION_OPTIONS); final SupportData.Builder builder =
new SupportData.Builder(mActivity, TYPE_ESCALATION_OPTIONS);
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) { if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) {
builder.setText1(R.string.support_escalation_by_phone); builder.setText1(R.string.support_escalation_by_phone);
builder.setSummary1(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, PHONE)); builder.setSummary1(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, PHONE));
@@ -191,24 +194,24 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
} }
private void addSignInPromo() { private void addSignInPromo() {
mSupportData.add(new SupportData.Builder(TYPE_TITLE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
.setText1(R.string.support_sign_in_required_title) .setText1(R.string.support_sign_in_required_title)
.setText2(R.string.support_sign_in_required_summary) .setText2(R.string.support_sign_in_required_summary)
.build()); .build());
mSupportData.add(new SupportData.Builder(TYPE_SIGN_IN_BUTTON) mSupportData.add(new SupportData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
.setText1(R.string.support_sign_in_button_text) .setText1(R.string.support_sign_in_button_text)
.setText2(R.string.support_sign_in_required_help) .setText2(R.string.support_sign_in_required_help)
.build()); .build());
} }
private void addMoreHelpItems() { private void addMoreHelpItems() {
mSupportData.add(new SupportData.Builder(TYPE_SUPPORT_TILE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE)
.setIcon(R.drawable.ic_lightbulb_outline_24) .setIcon(R.drawable.ic_lightbulb_outline_24)
.setText1(R.string.support_tips_and_tricks_title) .setText1(R.string.support_tips_and_tricks_title)
.setIntent(mSupportFeatureProvider.getTipsAndTricksIntent(mActivity)) .setIntent(mSupportFeatureProvider.getTipsAndTricksIntent(mActivity))
.setMetricsEvent(MetricsProto.MetricsEvent.ACTION_SUPPORT_TIPS_AND_TRICKS) .setMetricsEvent(MetricsProto.MetricsEvent.ACTION_SUPPORT_TIPS_AND_TRICKS)
.build()); .build());
mSupportData.add(new SupportData.Builder(TYPE_SUPPORT_TILE) mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE)
.setIcon(R.drawable.ic_help_24dp) .setIcon(R.drawable.ic_help_24dp)
.setText1(R.string.help_feedback_label) .setText1(R.string.help_feedback_label)
.setIntent(mSupportFeatureProvider.getHelpIntent(mActivity)) .setIntent(mSupportFeatureProvider.getHelpIntent(mActivity))
@@ -225,7 +228,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
holder.text1View.setEnabled(data.enabled1 && mHasInternet); holder.text1View.setEnabled(data.enabled1 && mHasInternet);
holder.text1View.setVisibility(View.VISIBLE); holder.text1View.setVisibility(View.VISIBLE);
} }
if (data.text2 == 0) { if (TextUtils.isEmpty(data.text2)) {
holder.text2View.setVisibility(View.GONE); holder.text2View.setVisibility(View.GONE);
} else { } else {
holder.text2View.setText(data.text2); holder.text2View.setText(data.text2);
@@ -347,12 +350,11 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
final int icon; final int icon;
@StringRes @StringRes
final int text1; final int text1;
@StringRes final CharSequence text2;
final int text2;
final boolean enabled1; final boolean enabled1;
final boolean enabled2; final boolean enabled2;
final String summary1; final CharSequence summary1;
final String summary2; final CharSequence summary2;
private SupportData(Builder builder) { private SupportData(Builder builder) {
this.type = builder.mType; this.type = builder.mType;
@@ -368,6 +370,8 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
} }
static final class Builder { static final class Builder {
private final Context mContext;
@LayoutRes @LayoutRes
private final int mType; private final int mType;
@DrawableRes @DrawableRes
@@ -376,14 +380,14 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
private boolean mEnabled2; private boolean mEnabled2;
@StringRes @StringRes
private int mText1; private int mText1;
@StringRes private CharSequence mText2;
private int mText2; private CharSequence mSummary1;
private String mSummary1; private CharSequence mSummary2;
private String mSummary2;
private Intent mIntent; private Intent mIntent;
private int mMetricsEvent = -1; private int mMetricsEvent = -1;
Builder(@LayoutRes int type) { Builder(Context context, @LayoutRes int type) {
mContext = context;
mType = type; mType = type;
} }
@@ -402,6 +406,16 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
return this; return this;
} }
Builder setText2(@StringRes int text2) {
mText2 = mContext.getString(text2);
return this;
}
Builder setText2(CharSequence text2) {
mText2 = text2;
return this;
}
Builder setSummary1(String summary1) { Builder setSummary1(String summary1) {
mSummary1 = summary1; mSummary1 = summary1;
return this; return this;
@@ -412,11 +426,6 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
return this; return this;
} }
Builder setText2(@StringRes int text2) {
mText2 = text2;
return this;
}
Builder setSummary2(String summary2) { Builder setSummary2(String summary2) {
mSummary2 = summary2; mSummary2 = summary2;
return this; return this;

View File

@@ -58,6 +58,11 @@ public interface SupportFeatureProvider {
*/ */
boolean isOperatingNow(@SupportType int type); boolean isOperatingNow(@SupportType int type);
/**
* Returns localized string for operation hours.
*/
CharSequence getOperationHours(Context context, @SupportType int type);
/** /**
* Returns a localized string indicating estimated wait time for a support time. * Returns a localized string indicating estimated wait time for a support time.
*/ */