Add c2c and chat support when there is eligible account.
Bug: 28141203 Bug: 28316618 Bug: 28316343 - Replaced hardcoded fragment layout with a RecyclerView. The old layout was essentially building a list manually. - Tweaked layout to look better. - Hide escalation cards when there is no account. Show cards when there is at least 1 account. - Request an intent to start specified support type when card is clicked. - Monitor account changes so we can hide/show escalation cards when add/remove account. Change-Id: Ie48158b85ade1363a41817cc88b1193e0aef87ae
This commit is contained in:
31
res/drawable/ic_call_24dp.xml
Normal file
31
res/drawable/ic_call_24dp.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?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="#FFFFFF"
|
||||||
|
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>
|
29
res/drawable/ic_chat_24dp.xml
Normal file
29
res/drawable/ic_chat_24dp.xml
Normal file
@@ -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="#FFFFFF"
|
||||||
|
android:pathData="M20,2H4c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2V4c0,-1.1
|
||||||
|
-0.9,-2 -2,-2zM6,9h12v2H6V9zm8,5H6v-2h8v2zm4,-6H6V6h12v2z"/>
|
||||||
|
</vector>
|
29
res/drawable/ic_mail_24dp.xml
Normal file
29
res/drawable/ic_mail_24dp.xml
Normal file
@@ -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="#FFFFFFFF"
|
||||||
|
android:pathData="M20,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9
|
||||||
|
2,-2V6c0,-1.1 -0.9,-2 -2,-2zm0,4l-8,5 -8,-5V6l8,5 8,-5v2z"/>
|
||||||
|
</vector>
|
@@ -17,29 +17,30 @@
|
|||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="4dp"
|
||||||
android:background="?android:attr/selectableItemBackground">
|
android:clickable="true"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:orientation="vertical">
|
android:orientation="horizontal">
|
||||||
|
<ImageView
|
||||||
|
android:id="@android:id/icon"
|
||||||
|
android:layout_width="@dimen/dashboard_tile_image_size"
|
||||||
|
android:layout_height="@dimen/dashboard_tile_image_size"
|
||||||
|
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
|
||||||
|
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
|
||||||
|
android:scaleType="centerInside"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@android:id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="@style/TextAppearance.TileTitle"/>
|
android:textAppearance="@style/TextAppearance.TileTitle"/>
|
||||||
<TextView
|
|
||||||
android:id="@+id/summary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="@style/TextAppearance.Small"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
@@ -15,53 +15,8 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<ScrollView
|
<android.support.v7.widget.RecyclerView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/support_items"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"/>
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingEnd="16dp"
|
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingTop="16dp"
|
|
||||||
android:text="@string/support_escalation_title"
|
|
||||||
android:textColor="@color/material_grey_900"
|
|
||||||
android:textSize="16sp"/>
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/escalation_options"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingEnd="8dp"
|
|
||||||
android:paddingStart="8dp">
|
|
||||||
<include
|
|
||||||
android:id="@+id/escalation_by_phone"
|
|
||||||
layout="@layout/support_escalation_card"/>
|
|
||||||
<include
|
|
||||||
android:id="@+id/escalation_by_email"
|
|
||||||
layout="@layout/support_escalation_card"/>
|
|
||||||
</LinearLayout>
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:attr/listDivider"/>
|
|
||||||
<include
|
|
||||||
android:id="@+id/forum_tile"
|
|
||||||
layout="@layout/support_tile"/>
|
|
||||||
<include
|
|
||||||
android:id="@+id/article_tile"
|
|
||||||
layout="@layout/support_tile"/>
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="?android:attr/listDivider"/>
|
|
||||||
<include
|
|
||||||
android:id="@+id/feedback_tile"
|
|
||||||
layout="@layout/support_tile"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
27
res/layout/support_item_subtitle.xml
Normal file
27
res/layout/support_item_subtitle.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.CategoryTitle"/>
|
40
res/layout/support_item_title.xml
Normal file
40
res/layout/support_item_title.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?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">
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.SupportTitle"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.CategoryTitle"/>
|
||||||
|
</LinearLayout>
|
@@ -7469,8 +7469,14 @@
|
|||||||
<!-- Button which clears out storage in the deletion helper. [CHAR LIMIT=60]-->
|
<!-- Button which clears out storage in the deletion helper. [CHAR LIMIT=60]-->
|
||||||
<string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string>
|
<string name="deletion_helper_free_button">Free up <xliff:g id="freeable" example="1.2GB">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Title text for calling or emailing customer support [CHAR LIMIT=80]-->
|
<!-- Title text for connecting to customer support [CHAR LIMIT=80]-->
|
||||||
<string name="support_escalation_title">24/7 support</string>
|
<string name="support_escalation_title">Around the clock help</string>
|
||||||
|
|
||||||
|
<!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="support_escalation_summary">Call or email us and we\'ll get your issue solved right away. No muss, no fuss.</string>
|
||||||
|
|
||||||
|
<!-- Title text for showing a list of help options [CHAR LIMIT=80]-->
|
||||||
|
<string name="support_more_help_title">More help</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">Phone</string>
|
<string name="support_escalation_by_phone">Phone</string>
|
||||||
@@ -7478,6 +7484,9 @@
|
|||||||
<!-- Button label for contacting customer support by email [CHAR LIMIT=20]-->
|
<!-- Button label for contacting customer support by email [CHAR LIMIT=20]-->
|
||||||
<string name="support_escalation_by_email">Email</string>
|
<string name="support_escalation_by_email">Email</string>
|
||||||
|
|
||||||
|
<!-- Button label for contacting customer support by chat [CHAR LIMIT=20]-->
|
||||||
|
<string name="support_escalation_by_chat">Chat</string>
|
||||||
|
|
||||||
<!-- Button label for visiting help forum [CHAR LIMIT=60]-->
|
<!-- Button label for visiting help forum [CHAR LIMIT=60]-->
|
||||||
<string name="support_forum_title">Help forum</string>
|
<string name="support_forum_title">Help forum</string>
|
||||||
|
|
||||||
|
@@ -340,6 +340,14 @@
|
|||||||
<item name="android:textColor">@color/warning</item>
|
<item name="android:textColor">@color/warning</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SupportTitle"
|
||||||
|
parent="@android:style/TextAppearance.Material.Subhead">
|
||||||
|
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||||
|
<item name="android:textSize">24sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
|
||||||
|
|
||||||
<style name="FingerprintLayoutTheme">
|
<style name="FingerprintLayoutTheme">
|
||||||
<item name="suwBackground">@drawable/fp_enrollment_header</item>
|
<item name="suwBackground">@drawable/fp_enrollment_header</item>
|
||||||
<item name="suwIllustrationAspectRatio">@dimen/fingerprint_illustration_aspect_ratio</item>
|
<item name="suwIllustrationAspectRatio">@dimen/fingerprint_illustration_aspect_ratio</item>
|
||||||
|
@@ -99,7 +99,7 @@ public final class DashboardContainerFragment extends InstrumentedFragment {
|
|||||||
super(fragmentManager);
|
super(fragmentManager);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSupportFeatureProvider =
|
mSupportFeatureProvider =
|
||||||
FeatureFactory.getFactory(context).getSupportFeatureProvider();
|
FeatureFactory.getFactory(context).getSupportFeatureProvider(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
package com.android.settings.dashboard;
|
package com.android.settings.dashboard;
|
||||||
|
|
||||||
import android.annotation.DrawableRes;
|
import android.accounts.Account;
|
||||||
import android.annotation.IdRes;
|
import android.accounts.AccountManager;
|
||||||
import android.annotation.StringRes;
|
import android.accounts.OnAccountsUpdateListener;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.settings.InstrumentedFragment;
|
import com.android.settings.InstrumentedFragment;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -35,10 +35,14 @@ import com.android.settings.overlay.SupportFeatureProvider;
|
|||||||
/**
|
/**
|
||||||
* Fragment for support tab in SettingsGoogle.
|
* Fragment for support tab in SettingsGoogle.
|
||||||
*/
|
*/
|
||||||
public final class SupportFragment extends InstrumentedFragment implements View.OnClickListener {
|
public final class SupportFragment extends InstrumentedFragment implements View.OnClickListener,
|
||||||
|
OnAccountsUpdateListener {
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private View mContent;
|
private View mContent;
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
private SupportItemAdapter mSupportItemAdapter;
|
||||||
|
private AccountManager mAccountManager;
|
||||||
private SupportFeatureProvider mSupportFeatureProvider;
|
private SupportFeatureProvider mSupportFeatureProvider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,45 +54,49 @@ public final class SupportFragment extends InstrumentedFragment implements View.
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
mAccountManager = AccountManager.get(mActivity);
|
||||||
mSupportFeatureProvider =
|
mSupportFeatureProvider =
|
||||||
FeatureFactory.getFactory(getContext()).getSupportFeatureProvider();
|
FeatureFactory.getFactory(mActivity).getSupportFeatureProvider(mActivity);
|
||||||
|
mSupportItemAdapter = new SupportItemAdapter(mActivity, mSupportFeatureProvider,
|
||||||
|
this /* itemClickListener */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
mContent = inflater.inflate(R.layout.support_fragment, container, false);
|
mContent = inflater.inflate(R.layout.support_fragment, container, false);
|
||||||
// Update escalation items.
|
mRecyclerView = (RecyclerView) mContent.findViewById(R.id.support_items);
|
||||||
updateEscalationCard(R.id.escalation_by_phone, R.string.support_escalation_by_phone);
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(
|
||||||
updateEscalationCard(R.id.escalation_by_email, R.string.support_escalation_by_email);
|
getActivity(), LinearLayoutManager.VERTICAL, false /* reverseLayout */));
|
||||||
// Update other support items.
|
mRecyclerView.setAdapter(mSupportItemAdapter);
|
||||||
updateSupportTile(R.id.forum_tile, R.drawable.ic_forum_24dp, R.string.support_forum_title);
|
|
||||||
updateSupportTile(R.id.article_tile, R.drawable.ic_help_24dp,
|
|
||||||
R.string.support_articles_title);
|
|
||||||
// Update feedback item.
|
|
||||||
updateSupportTile(R.id.feedback_tile, R.drawable.ic_feedback_24dp,
|
|
||||||
R.string.support_feedback_title);
|
|
||||||
return mContent;
|
return mContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEscalationCard(@IdRes int cardId, @StringRes int title) {
|
@Override
|
||||||
final View card = mContent.findViewById(cardId);
|
public void onResume() {
|
||||||
((TextView) card.findViewById(R.id.title)).setText(title);
|
super.onResume();
|
||||||
|
// Monitor account change.
|
||||||
|
mAccountManager.addOnAccountsUpdatedListener(
|
||||||
|
this /* listener */, null /* handler */, true /* updateImmediately */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSupportTile(@IdRes int tileId, @DrawableRes int icon, @StringRes int title) {
|
@Override
|
||||||
final View tile = mContent.findViewById(tileId);
|
public void onPause() {
|
||||||
((ImageView) tile.findViewById(android.R.id.icon)).setImageResource(icon);
|
super.onPause();
|
||||||
((TextView) tile.findViewById(android.R.id.title)).setText(title);
|
// Stop monitor account change.
|
||||||
tile.setOnClickListener(this);
|
mAccountManager.removeOnAccountsUpdatedListener(this /* listener */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountsUpdated(Account[] accounts) {
|
||||||
|
// Account changed, update support items.
|
||||||
|
mSupportItemAdapter.refreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
final SupportItemAdapter.ViewHolder vh =
|
||||||
case R.id.forum_tile:
|
(SupportItemAdapter.ViewHolder) mRecyclerView.getChildViewHolder(v);
|
||||||
mActivity.startActivity(mSupportFeatureProvider.getForumIntent());
|
mSupportItemAdapter.onItemClicked(vh.getAdapterPosition());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
193
src/com/android/settings/dashboard/SupportItemAdapter.java
Normal file
193
src/com/android/settings/dashboard/SupportItemAdapter.java
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
/*
|
||||||
|
* 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.dashboard;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
|
import android.annotation.DrawableRes;
|
||||||
|
import android.annotation.LayoutRes;
|
||||||
|
import android.annotation.StringRes;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.overlay.SupportFeatureProvider;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.CHAT;
|
||||||
|
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.EMAIL;
|
||||||
|
import static com.android.settings.overlay.SupportFeatureProvider.SupportType.PHONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item adapter for support tiles.
|
||||||
|
*/
|
||||||
|
public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAdapter.ViewHolder> {
|
||||||
|
|
||||||
|
private static final int TYPE_TITLE = R.layout.support_item_title;
|
||||||
|
private static final int TYPE_SUBTITLE = R.layout.support_item_subtitle;
|
||||||
|
private static final int TYPE_ESCALATION_CARD = R.layout.support_escalation_card;
|
||||||
|
private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
|
||||||
|
|
||||||
|
private final Activity mActivity;
|
||||||
|
private final SupportFeatureProvider mSupportFeatureProvider;
|
||||||
|
private final View.OnClickListener mItemClickListener;
|
||||||
|
private final List<SupportData> mSupportData;
|
||||||
|
|
||||||
|
public SupportItemAdapter(Activity activity, SupportFeatureProvider supportFeatureProvider,
|
||||||
|
View.OnClickListener itemClickListener) {
|
||||||
|
mActivity = activity;
|
||||||
|
mSupportFeatureProvider = supportFeatureProvider;
|
||||||
|
mItemClickListener = itemClickListener;
|
||||||
|
mSupportData = new ArrayList<>();
|
||||||
|
setHasStableIds(true);
|
||||||
|
refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(
|
||||||
|
viewType, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
|
final SupportData data = mSupportData.get(position);
|
||||||
|
if (holder.iconView != null) {
|
||||||
|
holder.iconView.setImageResource(data.icon);
|
||||||
|
}
|
||||||
|
if (holder.titleView != null) {
|
||||||
|
holder.titleView.setText(data.title);
|
||||||
|
}
|
||||||
|
if (holder.summaryView != null) {
|
||||||
|
holder.summaryView.setText(data.summary);
|
||||||
|
}
|
||||||
|
holder.itemView.setOnClickListener(mItemClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
return mSupportData.get(position).type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mSupportData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a support item is clicked.
|
||||||
|
*/
|
||||||
|
public void onItemClicked(int position) {
|
||||||
|
if (position >= 0 && position < mSupportData.size()) {
|
||||||
|
final SupportData data = mSupportData.get(position);
|
||||||
|
if (data.intent != null) {
|
||||||
|
mActivity.startActivityForResult(data.intent, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create data for the adapter. If there is already data in the adapter, they will be
|
||||||
|
* destroyed and recreated.
|
||||||
|
*/
|
||||||
|
public void refreshData() {
|
||||||
|
mSupportData.clear();
|
||||||
|
final Account[] accounts = mSupportFeatureProvider.getSupportEligibleAccounts(mActivity);
|
||||||
|
if (accounts.length > 0) {
|
||||||
|
addEscalationCards(accounts[0]);
|
||||||
|
}
|
||||||
|
addMoreHelpItems();
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addEscalationCards(Account account) {
|
||||||
|
mSupportData.add(new SupportData(TYPE_TITLE, 0 /* icon */,
|
||||||
|
R.string.support_escalation_title, R.string.support_escalation_summary,
|
||||||
|
null /* intent */));
|
||||||
|
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) {
|
||||||
|
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_call_24dp,
|
||||||
|
R.string.support_escalation_by_phone, 0 /* summary */,
|
||||||
|
mSupportFeatureProvider.getSupportIntent(mActivity, account, PHONE)));
|
||||||
|
}
|
||||||
|
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, EMAIL)) {
|
||||||
|
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_mail_24dp,
|
||||||
|
R.string.support_escalation_by_email, 0 /* summary */,
|
||||||
|
mSupportFeatureProvider.getSupportIntent(mActivity, account, EMAIL)));
|
||||||
|
}
|
||||||
|
if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT)) {
|
||||||
|
mSupportData.add(new SupportData(TYPE_ESCALATION_CARD, R.drawable.ic_chat_24dp,
|
||||||
|
R.string.support_escalation_by_chat, 0 /* summary */,
|
||||||
|
mSupportFeatureProvider.getSupportIntent(mActivity, account, CHAT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMoreHelpItems() {
|
||||||
|
mSupportData.add(new SupportData(TYPE_SUBTITLE, 0 /* icon */,
|
||||||
|
R.string.support_more_help_title, 0 /* summary */, null /* intent */));
|
||||||
|
mSupportData.add(new SupportData(TYPE_SUPPORT_TILE, R.drawable.ic_forum_24dp,
|
||||||
|
R.string.support_forum_title, 0 /* summary */,
|
||||||
|
mSupportFeatureProvider.getForumIntent()));
|
||||||
|
mSupportData.add(new SupportData(TYPE_SUPPORT_TILE, R.drawable.ic_help_24dp,
|
||||||
|
R.string.support_articles_title, 0 /* summary */, null /*intent */));
|
||||||
|
mSupportData.add(new SupportData(TYPE_SUPPORT_TILE, R.drawable.ic_feedback_24dp,
|
||||||
|
R.string.support_feedback_title, 0 /* summary */, null /*intent */));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link RecyclerView.ViewHolder} for support items.
|
||||||
|
*/
|
||||||
|
static final class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final ImageView iconView;
|
||||||
|
final TextView titleView;
|
||||||
|
final TextView summaryView;
|
||||||
|
|
||||||
|
ViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
iconView = (ImageView) itemView.findViewById(android.R.id.icon);
|
||||||
|
titleView = (TextView) itemView.findViewById(android.R.id.title);
|
||||||
|
summaryView = (TextView) itemView.findViewById(android.R.id.summary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data for a single support item.
|
||||||
|
*/
|
||||||
|
private static final class SupportData {
|
||||||
|
|
||||||
|
final Intent intent;
|
||||||
|
@LayoutRes final int type;
|
||||||
|
@DrawableRes final int icon;
|
||||||
|
@StringRes final int title;
|
||||||
|
@StringRes final int summary;
|
||||||
|
|
||||||
|
SupportData(@LayoutRes int type, @DrawableRes int icon, @StringRes int title,
|
||||||
|
@StringRes int summary, Intent intent) {
|
||||||
|
this.type = type;
|
||||||
|
this.icon = icon;
|
||||||
|
this.title = title;
|
||||||
|
this.summary = summary;
|
||||||
|
this.intent = intent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -59,7 +59,7 @@ public abstract class FeatureFactory {
|
|||||||
return sFactory;
|
return sFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract SupportFeatureProvider getSupportFeatureProvider();
|
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
|
||||||
|
|
||||||
public static final class FactoryNotFoundException extends RuntimeException {
|
public static final class FactoryNotFoundException extends RuntimeException {
|
||||||
public FactoryNotFoundException(Throwable throwable) {
|
public FactoryNotFoundException(Throwable throwable) {
|
||||||
|
@@ -16,13 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.overlay;
|
package com.android.settings.overlay;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link FeatureFactory} implementation for AOSP Settings.
|
* {@link FeatureFactory} implementation for AOSP Settings.
|
||||||
*/
|
*/
|
||||||
public final class FeatureFactoryImpl extends FeatureFactory {
|
public final class FeatureFactoryImpl extends FeatureFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SupportFeatureProvider getSupportFeatureProvider() {
|
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,16 +16,51 @@
|
|||||||
|
|
||||||
package com.android.settings.overlay;
|
package com.android.settings.overlay;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
|
import android.annotation.IntDef;
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feature provider for support tab.
|
* Feature provider for support tab.
|
||||||
*/
|
*/
|
||||||
public interface SupportFeatureProvider {
|
public interface SupportFeatureProvider {
|
||||||
|
|
||||||
|
@IntDef({SupportType.EMAIL, SupportType.PHONE, SupportType.CHAT})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@interface SupportType {
|
||||||
|
int EMAIL = 1;
|
||||||
|
int PHONE = 2;
|
||||||
|
int CHAT = 3;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a intent that will open help forum.
|
* Returns a intent that will open help forum.
|
||||||
*/
|
*/
|
||||||
Intent getForumIntent();
|
Intent getForumIntent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not a support type is enabled.
|
||||||
|
*/
|
||||||
|
boolean isSupportTypeEnabled(Context context, @SupportType int type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an {@link Account} that's eligible for support options.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
Account[] getSupportEligibleAccounts(Context context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an {@link Intent} that opens email support for specified account.
|
||||||
|
*
|
||||||
|
* @param context A UI Context
|
||||||
|
* @param account A account returned by {@link #getSupportEligibleAccounts}
|
||||||
|
* @param type The type of support account needs.
|
||||||
|
*/
|
||||||
|
Intent getSupportIntent(Context context, Account account, @SupportType int type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user