Merge "Enable/disable support buttons based on operation hours." into nyc-mr1-dev

This commit is contained in:
Fan Zhang
2016-06-21 17:21:07 +00:00
committed by Android (Google) Code Review
3 changed files with 62 additions and 8 deletions

View File

@@ -7505,10 +7505,22 @@
<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]-->
<string name="support_escalation_title">Around-the-clock support</string>
<string name="support_escalation_title">We\'re here to help</string>
<!-- Title text for connecting to 24/7 available customer support [CHAR LIMIT=80]-->
<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]-->
<string name="support_escalation_closed_title">Live support closed</string>
<!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
<string name="support_escalation_summary">You can request a support call or chat and we\'ll get back to you with a quickness</string>
<string name="support_escalation_summary">Our support team is here to address any issues as soon as we can.</string>
<!-- 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>
<!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
<string name="support_escalation_closed_summary">Come back again during support hours.</string>
<!-- Title text that indicates there is not internet connection. [CHAR LIMIT=80]-->
<string name="support_offline_title">You\'re offline</string>

View File

@@ -152,10 +152,24 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
private void addEscalationCards() {
if (mHasInternet) {
if (mSupportFeatureProvider.isAlwaysOperating(PHONE)
|| mSupportFeatureProvider.isAlwaysOperating(CHAT)) {
mSupportData.add(new SupportData.Builder(TYPE_TITLE)
.setText1(R.string.support_escalation_24_7_title)
.setText2(R.string.support_escalation_24_7_summary)
.build());
} else if (mSupportFeatureProvider.isOperatingNow(PHONE)
|| mSupportFeatureProvider.isOperatingNow(CHAT)) {
mSupportData.add(new SupportData.Builder(TYPE_TITLE)
.setText1(R.string.support_escalation_title)
.setText2(R.string.support_escalation_summary)
.build());
} else {
mSupportData.add(new SupportData.Builder(TYPE_TITLE)
.setText1(R.string.support_escalation_closed_title)
.setText2(R.string.support_escalation_closed_summary)
.build());
}
} else {
mSupportData.add(new SupportData.Builder(TYPE_TITLE)
.setText1(R.string.support_offline_title)
@@ -166,10 +180,12 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) {
builder.setText1(R.string.support_escalation_by_phone);
builder.setSummary1(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, PHONE));
builder.setEnabled1(mSupportFeatureProvider.isOperatingNow(PHONE));
}
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT)) {
builder.setText2(R.string.support_escalation_by_chat);
builder.setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT));
builder.setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
}
mSupportData.add(builder.build());
}
@@ -206,7 +222,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
} else {
holder.text1View.setText(data.text1);
holder.text1View.setOnClickListener(mEscalationClickListener);
holder.text1View.setEnabled(mHasInternet);
holder.text1View.setEnabled(data.enabled1 && mHasInternet);
holder.text1View.setVisibility(View.VISIBLE);
}
if (data.text2 == 0) {
@@ -214,7 +230,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
} else {
holder.text2View.setText(data.text2);
holder.text2View.setOnClickListener(mEscalationClickListener);
holder.text2View.setEnabled(mHasInternet);
holder.text2View.setEnabled(data.enabled2 && mHasInternet);
holder.text2View.setVisibility(View.VISIBLE);
}
if (holder.summary1View != null) {
@@ -333,6 +349,8 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
final int text1;
@StringRes
final int text2;
final boolean enabled1;
final boolean enabled2;
final String summary1;
final String summary2;
@@ -343,6 +361,8 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
this.text2 = builder.mText2;
this.summary1 = builder.mSummary1;
this.summary2 = builder.mSummary2;
this.enabled1 = builder.mEnabled1;
this.enabled2 = builder.mEnabled2;
this.intent = builder.mIntent;
this.metricsEvent = builder.mMetricsEvent;
}
@@ -352,6 +372,8 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
private final int mType;
@DrawableRes
private int mIcon;
private boolean mEnabled1;
private boolean mEnabled2;
@StringRes
private int mText1;
@StringRes
@@ -370,6 +392,11 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
return this;
}
Builder setEnabled1(boolean enabled) {
mEnabled1 = enabled;
return this;
}
Builder setText1(@StringRes int text1) {
mText1 = text1;
return this;
@@ -380,6 +407,11 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
return this;
}
Builder setEnabled2(boolean enabled) {
mEnabled2 = enabled;
return this;
}
Builder setText2(@StringRes int text2) {
mText2 = text2;
return this;

View File

@@ -48,6 +48,16 @@ public interface SupportFeatureProvider {
*/
boolean isSupportTypeEnabled(Context context, @SupportType int type);
/**
* Whether or not a support type is in operation 24/7.
*/
boolean isAlwaysOperating(@SupportType int type);
/**
* Whether or not a support type is operating now.
*/
boolean isOperatingNow(@SupportType int type);
/**
* Returns a localized string indicating estimated wait time for a support time.
*/