Prompt sign-in when there is no account for support options
Bug: 28141203 Bug: 28316343 Change-Id: Ie7f86955519504e5eed4af4c8406a353a3847995
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
|
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"
|
||||||
android:scaleType="centerInside"/>
|
android:scaleType="centerInside"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/text1"
|
||||||
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"/>
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/text1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/text1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingEnd="8dp"
|
android:paddingEnd="8dp"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:textAppearance="@style/TextAppearance.SupportTitle"/>
|
android:textAppearance="@style/TextAppearance.SupportTitle"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/summary"
|
android:id="@android:id/text2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
|
34
res/layout/support_sign_in_button.xml
Normal file
34
res/layout/support_sign_in_button.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?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">
|
||||||
|
<Button
|
||||||
|
android:id="@android:id/text1"
|
||||||
|
style="@style/SupportPrimaryButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@android:id/text2"
|
||||||
|
style="@style/SupportSecondaryButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
</LinearLayout>
|
@@ -31,7 +31,7 @@
|
|||||||
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
|
android:layout_marginStart="@dimen/dashboard_tile_image_margin_start"
|
||||||
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"/>
|
android:layout_marginEnd="@dimen/dashboard_tile_image_margin_end"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/text1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
@@ -7510,4 +7510,17 @@
|
|||||||
|
|
||||||
<!-- Button label for sending user feedback [CHAR LIMIT=60]-->
|
<!-- Button label for sending user feedback [CHAR LIMIT=60]-->
|
||||||
<string name="support_feedback_title">Send feedback</string>
|
<string name="support_feedback_title">Send feedback</string>
|
||||||
|
|
||||||
|
<!-- Title text that indicates user needs to sign in to get customer support. [CHAR LIMIT=80]-->
|
||||||
|
<string name="support_sign_in_required_title">Need assistance now?</string>
|
||||||
|
|
||||||
|
<!-- Summary text that indicates user needs to sign-in to get real time customer support. [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="support_sign_in_required_summary" translatable="false"></string>
|
||||||
|
|
||||||
|
<!-- Button label for signing in an account [CHAR LIMIT=40]-->
|
||||||
|
<string name="support_sign_in_button_text">Sign in</string>
|
||||||
|
|
||||||
|
<!-- Button label that redirects user who needs help for signin to help screen [CHAR LIMIT=NONE]-->
|
||||||
|
<string name="support_sign_in_required_help">Can\'t access your account?</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -352,6 +352,13 @@
|
|||||||
|
|
||||||
<style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
|
<style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
|
||||||
|
|
||||||
|
<style name="SupportPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
|
||||||
|
|
||||||
|
<style name="SupportSecondaryButton"
|
||||||
|
parent="android:Widget.Material.Button.Borderless.Colored">
|
||||||
|
<item name="android:textSize">12sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="FingerprintLayoutTheme">
|
<style name="FingerprintLayoutTheme">
|
||||||
<item name="android:icon">@drawable/ic_fingerprint_header</item>
|
<item name="android:icon">@drawable/ic_fingerprint_header</item>
|
||||||
</style>
|
</style>
|
||||||
|
@@ -22,7 +22,6 @@ import android.annotation.StringRes;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -44,14 +43,14 @@ import static com.android.settings.overlay.SupportFeatureProvider.SupportType.PH
|
|||||||
*/
|
*/
|
||||||
public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAdapter.ViewHolder> {
|
public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAdapter.ViewHolder> {
|
||||||
|
|
||||||
private static final String TAG = "SupportItemAdapter";
|
|
||||||
|
|
||||||
private static final int TYPE_TITLE = R.layout.support_item_title;
|
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_SUBTITLE = R.layout.support_item_subtitle;
|
||||||
private static final int TYPE_ESCALATION_CARD = R.layout.support_escalation_card;
|
private static final int TYPE_ESCALATION_CARD = R.layout.support_escalation_card;
|
||||||
private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
|
private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
|
||||||
|
private static final int TYPE_SIGN_IN_BUTTON = R.layout.support_sign_in_button;
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
|
private final SignInPromoClickListener mSignInPromoClickListener;
|
||||||
private final SupportFeatureProvider mSupportFeatureProvider;
|
private final SupportFeatureProvider mSupportFeatureProvider;
|
||||||
private final View.OnClickListener mItemClickListener;
|
private final View.OnClickListener mItemClickListener;
|
||||||
private final List<SupportData> mSupportData;
|
private final List<SupportData> mSupportData;
|
||||||
@@ -63,6 +62,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mSupportFeatureProvider = supportFeatureProvider;
|
mSupportFeatureProvider = supportFeatureProvider;
|
||||||
mItemClickListener = itemClickListener;
|
mItemClickListener = itemClickListener;
|
||||||
|
mSignInPromoClickListener = new SignInPromoClickListener();
|
||||||
mSupportData = new ArrayList<>();
|
mSupportData = new ArrayList<>();
|
||||||
// Optimistically assume we have Internet access. It will be updated later to correct value.
|
// Optimistically assume we have Internet access. It will be updated later to correct value.
|
||||||
mHasInternet = true;
|
mHasInternet = true;
|
||||||
@@ -79,16 +79,14 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
final SupportData data = mSupportData.get(position);
|
final SupportData data = mSupportData.get(position);
|
||||||
if (holder.iconView != null) {
|
switch (holder.getItemViewType()) {
|
||||||
holder.iconView.setImageResource(data.icon);
|
case TYPE_SIGN_IN_BUTTON:
|
||||||
|
bindSignInPromoTile(holder, data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bindSupportTile(holder, data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (holder.titleView != null) {
|
|
||||||
holder.titleView.setText(data.title);
|
|
||||||
}
|
|
||||||
if (holder.summaryView != null) {
|
|
||||||
holder.summaryView.setText(data.summary);
|
|
||||||
}
|
|
||||||
holder.itemView.setOnClickListener(mItemClickListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,7 +126,7 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
mSupportData.clear();
|
mSupportData.clear();
|
||||||
final Account[] accounts = mSupportFeatureProvider.getSupportEligibleAccounts(mActivity);
|
final Account[] accounts = mSupportFeatureProvider.getSupportEligibleAccounts(mActivity);
|
||||||
if (accounts.length == 0) {
|
if (accounts.length == 0) {
|
||||||
Log.d(TAG, "Account unavailable. Skipping");
|
addSignInPromo();
|
||||||
} else {
|
} else {
|
||||||
addEscalationCards(accounts[0]);
|
addEscalationCards(accounts[0]);
|
||||||
}
|
}
|
||||||
@@ -163,6 +161,16 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addSignInPromo() {
|
||||||
|
mSupportData.add(new SupportData(TYPE_TITLE, 0 /* icon */,
|
||||||
|
R.string.support_sign_in_required_title, R.string.support_sign_in_required_summary,
|
||||||
|
null /* intent */));
|
||||||
|
mSupportData.add(new SupportData(TYPE_SIGN_IN_BUTTON, 0 /* icon */,
|
||||||
|
R.string.support_sign_in_button_text, R.string.support_sign_in_required_help,
|
||||||
|
null /* intent */));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void addMoreHelpItems() {
|
private void addMoreHelpItems() {
|
||||||
mSupportData.add(new SupportData(TYPE_SUBTITLE, 0 /* icon */,
|
mSupportData.add(new SupportData(TYPE_SUBTITLE, 0 /* icon */,
|
||||||
R.string.support_more_help_title, 0 /* summary */, null /* intent */));
|
R.string.support_more_help_title, 0 /* summary */, null /* intent */));
|
||||||
@@ -175,20 +183,60 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
R.string.support_feedback_title, 0 /* summary */, null /*intent */));
|
R.string.support_feedback_title, 0 /* summary */, null /*intent */));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bindSignInPromoTile(ViewHolder holder, SupportData data) {
|
||||||
|
holder.text1View.setText(data.text1);
|
||||||
|
holder.text2View.setText(data.text2);
|
||||||
|
holder.text1View.setOnClickListener(mSignInPromoClickListener);
|
||||||
|
holder.text2View.setOnClickListener(mSignInPromoClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindSupportTile(ViewHolder holder, SupportData data) {
|
||||||
|
if (holder.iconView != null) {
|
||||||
|
holder.iconView.setImageResource(data.icon);
|
||||||
|
}
|
||||||
|
if (holder.text1View != null) {
|
||||||
|
holder.text1View.setText(data.text1);
|
||||||
|
}
|
||||||
|
if (holder.text2View != null) {
|
||||||
|
holder.text2View.setText(data.text2);
|
||||||
|
}
|
||||||
|
holder.itemView.setOnClickListener(mItemClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Click handler for sign-in promo.
|
||||||
|
*/
|
||||||
|
private final class SignInPromoClickListener implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case android.R.id.text1:
|
||||||
|
mActivity.startActivityForResult(
|
||||||
|
mSupportFeatureProvider.getAccountLoginIntent(), 0 /* requestCode */);
|
||||||
|
break;
|
||||||
|
case android.R.id.text2:
|
||||||
|
mActivity.startActivityForResult(
|
||||||
|
mSupportFeatureProvider.getSignInHelpIntent(mActivity),
|
||||||
|
0 /* requestCode */);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RecyclerView.ViewHolder} for support items.
|
* {@link RecyclerView.ViewHolder} for support items.
|
||||||
*/
|
*/
|
||||||
static final class ViewHolder extends RecyclerView.ViewHolder {
|
static final class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
final ImageView iconView;
|
final ImageView iconView;
|
||||||
final TextView titleView;
|
final TextView text1View;
|
||||||
final TextView summaryView;
|
final TextView text2View;
|
||||||
|
|
||||||
ViewHolder(View itemView) {
|
ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
iconView = (ImageView) itemView.findViewById(android.R.id.icon);
|
iconView = (ImageView) itemView.findViewById(android.R.id.icon);
|
||||||
titleView = (TextView) itemView.findViewById(android.R.id.title);
|
text1View = (TextView) itemView.findViewById(android.R.id.text1);
|
||||||
summaryView = (TextView) itemView.findViewById(android.R.id.summary);
|
text2View = (TextView) itemView.findViewById(android.R.id.text2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,15 +248,15 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
|
|||||||
final Intent intent;
|
final Intent intent;
|
||||||
@LayoutRes final int type;
|
@LayoutRes final int type;
|
||||||
@DrawableRes final int icon;
|
@DrawableRes final int icon;
|
||||||
@StringRes final int title;
|
@StringRes final int text1;
|
||||||
@StringRes final int summary;
|
@StringRes final int text2;
|
||||||
|
|
||||||
SupportData(@LayoutRes int type, @DrawableRes int icon, @StringRes int title,
|
SupportData(@LayoutRes int type, @DrawableRes int icon, @StringRes int text1,
|
||||||
@StringRes int summary, Intent intent) {
|
@StringRes int text2, Intent intent) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.title = title;
|
this.text1 = text1;
|
||||||
this.summary = summary;
|
this.text2 = text2;
|
||||||
this.intent = intent;
|
this.intent = intent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,4 +63,13 @@ public interface SupportFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
Intent getSupportIntent(Context context, Account account, @SupportType int type);
|
Intent getSupportIntent(Context context, Account account, @SupportType int type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an {@link Intent} that opens help and allow user get help on sign in.
|
||||||
|
*/
|
||||||
|
Intent getSignInHelpIntent(Context context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an intent that will start the add account UI.
|
||||||
|
*/
|
||||||
|
Intent getAccountLoginIntent();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user