Merge "Show tolled support number when click travel abroad." into nyc-mr1-dev
diff --git a/res/drawable/ic_call_24dp.xml b/res/drawable/ic_call_24dp.xml
new file mode 100644
index 0000000..26bbde5
--- /dev/null
+++ b/res/drawable/ic_call_24dp.xml
@@ -0,0 +1,29 @@
+<?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="@android:color/white"
+ 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>
diff --git a/res/layout/support_phone_dialog_content.xml b/res/layout/support_phone_dialog_content.xml
new file mode 100644
index 0000000..97bf567
--- /dev/null
+++ b/res/layout/support_phone_dialog_content.xml
@@ -0,0 +1,37 @@
+<?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:orientation="vertical"
+ android:padding="24dp">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="16dp"
+ android:text="@string/support_international_phone_summary"/>
+ <TextView
+ android:id="@+id/phone_number"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/selectableItemBackground"
+ android:drawableLeft="@drawable/ic_call_24dp"
+ android:drawablePadding="16dp"
+ android:gravity="center_vertical"
+ android:minHeight="48dp"
+ android:textAppearance="@style/TextAppearance.TileTitle"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1086a97..09ded68 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7530,6 +7530,11 @@
<!-- Template for formatting country and language. eg Canada - French [CHAR LIMIT=NONE]-->
<string name="support_country_format"><xliff:g id="country" example="Canada">%s</xliff:g> - <xliff:g id="language" example="French">%s</xliff:g></string>
+ <!-- Template for formatting phone number and language. eg English (800-000-0000) [CHAR LIMIT=NONE]-->
+ <string name ="support_phone_international_format">
+ <xliff:g id="language" example="English">%s</xliff:g> (<xliff:g id="phone" example="800-000-0000">%s</xliff:g>)
+ </string>
+
<!-- Title text that indicates there is not internet connection. [CHAR LIMIT=80]-->
<string name="support_offline_title">You\'re offline</string>
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 0c5a9c3..f1950a1 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -41,6 +41,7 @@
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.support.SupportDisclaimerDialogFragment;
import com.android.settings.support.SupportPhone;
+import com.android.settings.support.SupportPhoneDialogFragment;
import java.util.ArrayList;
import java.util.List;
@@ -376,15 +377,23 @@
}
} else {
switch (v.getId()) {
- case android.R.id.text1:
+ case android.R.id.text1: {
final SupportPhone phone = mSupportFeatureProvider
.getSupportPhones(mSelectedCountry, true /* isTollFree */);
if (phone != null) {
mActivity.startActivity(phone.getDialIntent());
}
break;
- case android.R.id.text2:
+ }
+ case android.R.id.text2: {
+ final SupportPhone phone = mSupportFeatureProvider
+ .getSupportPhones(mSelectedCountry, false /* isTollFree */);
+ final SupportPhoneDialogFragment fragment =
+ SupportPhoneDialogFragment.newInstance(phone);
+ fragment.show(mActivity.getFragmentManager(),
+ SupportPhoneDialogFragment.TAG);
break;
+ }
}
}
}
diff --git a/src/com/android/settings/support/SupportPhone.java b/src/com/android/settings/support/SupportPhone.java
index 6c8bf29..d27dca5 100644
--- a/src/com/android/settings/support/SupportPhone.java
+++ b/src/com/android/settings/support/SupportPhone.java
@@ -18,6 +18,8 @@
import android.content.Intent;
import android.net.Uri;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.text.TextUtils;
import java.text.ParseException;
@@ -25,7 +27,7 @@
/**
* Data model for a support phone number.
*/
-public final class SupportPhone {
+public final class SupportPhone implements Parcelable {
public final String language;
public final String number;
@@ -42,6 +44,12 @@
number = tokens[2];
}
+ protected SupportPhone(Parcel in) {
+ language = in.readString();
+ number = in.readString();
+ isTollFree = in.readInt() != 0;
+ }
+
public Intent getDialIntent() {
return new Intent(Intent.ACTION_DIAL)
.setData(new Uri.Builder()
@@ -49,4 +57,28 @@
.appendPath(number)
.build());
}
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(language);
+ dest.writeString(number);
+ dest.writeInt(isTollFree ? 1 : 0);
+ }
+
+ public static final Creator<SupportPhone> CREATOR = new Creator<SupportPhone>() {
+ @Override
+ public SupportPhone createFromParcel(Parcel in) {
+ return new SupportPhone(in);
+ }
+
+ @Override
+ public SupportPhone[] newArray(int size) {
+ return new SupportPhone[size];
+ }
+ };
}
diff --git a/src/com/android/settings/support/SupportPhoneDialogFragment.java b/src/com/android/settings/support/SupportPhoneDialogFragment.java
new file mode 100644
index 0000000..15d4a7d
--- /dev/null
+++ b/src/com/android/settings/support/SupportPhoneDialogFragment.java
@@ -0,0 +1,71 @@
+/*
+ * 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.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.settings.R;
+
+import java.util.Locale;
+
+/**
+ * A dialog fragment that displays support phone numbers.
+ */
+public final class SupportPhoneDialogFragment extends DialogFragment implements
+ View.OnClickListener {
+
+ public static final String TAG = "SupportPhoneDialog";
+ private static final String EXTRA_PHONE = "extra_phone";
+
+ public static SupportPhoneDialogFragment newInstance(SupportPhone phone) {
+ final SupportPhoneDialogFragment fragment = new SupportPhoneDialogFragment();
+ final Bundle bundle = new Bundle(2);
+ bundle.putParcelable(EXTRA_PHONE, phone);
+ fragment.setArguments(bundle);
+ return fragment;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
+ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.support_international_phone_title);
+ final View content = LayoutInflater.from(builder.getContext())
+ .inflate(R.layout.support_phone_dialog_content, null);
+ final TextView phoneView = (TextView) content.findViewById(R.id.phone_number);
+ final String formattedPhoneNumber = getContext().getString(
+ R.string.support_phone_international_format,
+ new Locale(phone.language).getDisplayLanguage(), phone.number);
+ phoneView.setText(formattedPhoneNumber);
+ phoneView.setOnClickListener(this);
+ return builder
+ .setView(content)
+ .create();
+ }
+
+ @Override
+ public void onClick(View v) {
+ final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
+ getActivity().startActivity(phone.getDialIntent());
+ dismiss();
+ }
+}