Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 841b13ac authored by Fan Zhang's avatar Fan Zhang
Browse files

Enable/disable support buttons based on operation hours.

Also update support title based on whether support operation is
available.

Bug: 28827790
Change-Id: I65eb70d18ba16ccc263bce019fcbbe5e10ffa596
parent b363eb89
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -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>
+38 −6
Original line number Diff line number Diff line
@@ -147,10 +147,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)
@@ -161,10 +175,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());
    }
@@ -199,7 +215,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) {
@@ -207,7 +223,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) {
@@ -319,6 +335,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;

@@ -329,6 +347,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;
        }

@@ -337,6 +357,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
@@ -354,6 +376,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;
@@ -364,6 +391,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;
+10 −0
Original line number Diff line number Diff line
@@ -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.
     */