diff --git a/res/layout/support_offline_escalation_options.xml b/res/layout/support_offline_escalation_options.xml
new file mode 100644
index 00000000000..f440d205d54
--- /dev/null
+++ b/res/layout/support_offline_escalation_options.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0b8f3517e1b..c4ac8e3b896 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7522,12 +7522,24 @@
%s - %s, %s - %s<br>
+
+ Support for:
+
+
+ %s - %s
+
You\'re offline
To reach support, first connect to Wi-Fi or data.
+
+ Traveling aboard?
+
+
+ International charges may apply
+
Phone
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index e76ca8b5759..94cc94b5a44 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -28,7 +28,10 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.ImageView;
+import android.widget.Spinner;
import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
@@ -36,6 +39,7 @@ import com.android.internal.logging.MetricsProto;
import com.android.settings.R;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.support.SupportDisclaimerDialogFragment;
+import com.android.settings.support.SupportPhone;
import java.util.ArrayList;
import java.util.List;
@@ -51,15 +55,19 @@ public final class SupportItemAdapter extends RecyclerView.Adapter mSupportData;
+ private String mSelectedCountry;
private boolean mHasInternet;
private Account mAccount;
@@ -69,6 +77,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter();
// Optimistically assume we have Internet access. It will be updated later to correct value.
mHasInternet = true;
@@ -92,6 +101,9 @@ public final class SupportItemAdapter extends RecyclerView.Adapter adapter = new ArrayAdapter(
+ mActivity, android.R.layout.simple_spinner_dropdown_item, data.countries);
+ spinner.setAdapter(adapter);
+ final List countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
+ for (int i = 0; i < countryCodes.size(); i++) {
+ if (TextUtils.equals(countryCodes.get(i), mSelectedCountry)) {
+ spinner.setSelection(i);
+ break;
+ }
+ }
+ spinner.setOnItemSelectedListener(mSpinnerItemSelectListener);
+ // Bind buttons
+ if (data.tollFreePhone != null) {
+ holder.text1View.setText(data.tollFreePhone.number);
+ holder.text1View.setVisibility(View.VISIBLE);
+ holder.text1View.setOnClickListener(mEscalationClickListener);
+ } else {
+ holder.text1View.setVisibility(View.GONE);
+ }
+ if (data.tolledPhone != null) {
+ holder.text2View.setText(
+ mActivity.getString(R.string.support_international_phone_title));
+ holder.text2View.setVisibility(View.VISIBLE);
+ holder.text2View.setOnClickListener(mEscalationClickListener);
+ } else {
+ holder.text2View.setVisibility(View.GONE);
+ }
+ }
+
private void bindSignInPromoTile(ViewHolder holder, SupportData data) {
holder.text1View.setText(data.text1);
holder.text2View.setText(data.text2);
@@ -299,7 +352,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter parent, View view, int position, long id) {
+ final List countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
+ final String selectedCountry = countryCodes.get(position);
+ if (!TextUtils.equals(selectedCountry, mSelectedCountry)) {
+ mSelectedCountry = selectedCountry;
+ refreshData();
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ // Do nothing.
+ }
+ }
+
/**
* {@link RecyclerView.ViewHolder} for support items.
*/
@@ -340,7 +423,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter countries;
+ final SupportPhone tollFreePhone;
+ final SupportPhone tolledPhone;
+
+ private OfflineSupportData(Builder builder) {
+ super(builder);
+ countries = builder.mCountries;
+ tollFreePhone = builder.mTollFreePhone;
+ tolledPhone = builder.mTolledPhone;
+ }
+
+ static final class Builder extends SupportData.Builder {
+
+ private List mCountries;
+ private SupportPhone mTollFreePhone;
+ private SupportPhone mTolledPhone;
+
+ Builder(Context context) {
+ super(context, TYPE_ESCALATION_OPTIONS_OFFLINE);
+ }
+
+ Builder setCountries(List countries) {
+ mCountries = countries;
+ return this;
+ }
+
+ Builder setTollFreePhone(SupportPhone phone) {
+ mTollFreePhone = phone;
+ return this;
+ }
+
+ Builder setTolledPhone(SupportPhone phone) {
+ mTolledPhone = phone;
+ return this;
+ }
+
+ OfflineSupportData build() {
+ return new OfflineSupportData(this);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index 3c66910bd1a..df066ea64ac 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -22,8 +22,11 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import com.android.settings.support.SupportPhone;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.List;
/**
* Feature provider for support tab.
@@ -68,6 +71,22 @@ public interface SupportFeatureProvider {
*/
String getEstimatedWaitTime(Context context, @SupportType int type);
+
+ /**
+ * Returns a list of country codes that have phone support.
+ */
+ List getPhoneSupportCountryCodes();
+
+ /**
+ * Returns a list of countries that have phone support.
+ */
+ List getPhoneSupportCountries();
+
+ /**
+ * Returns a support phone for specified country.
+ */
+ SupportPhone getSupportPhones(String countryCode, boolean isTollfree);
+
/**
* Whether or not a disclaimer dialog should be displayed.
*/
diff --git a/src/com/android/settings/support/SupportPhone.java b/src/com/android/settings/support/SupportPhone.java
new file mode 100644
index 00000000000..6c8bf2987e8
--- /dev/null
+++ b/src/com/android/settings/support/SupportPhone.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.support;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.text.TextUtils;
+
+import java.text.ParseException;
+
+/**
+ * Data model for a support phone number.
+ */
+public final class SupportPhone {
+
+ public final String language;
+ public final String number;
+ public final boolean isTollFree;
+
+ public SupportPhone(String config) throws ParseException {
+ // Config follows this format: language:[tollfree|tolled]:number
+ final String[] tokens = config.split(":");
+ if (tokens.length != 3) {
+ throw new ParseException("Phone config is invalid " + config, 0);
+ }
+ language = tokens[0];
+ isTollFree = TextUtils.equals(tokens[1], "tollfree");
+ number = tokens[2];
+ }
+
+ public Intent getDialIntent() {
+ return new Intent(Intent.ACTION_DIAL)
+ .setData(new Uri.Builder()
+ .scheme("tel")
+ .appendPath(number)
+ .build());
+ }
+}