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:
Fan Zhang
2016-04-20 16:20:17 -07:00
parent 185bfdf3a5
commit a9fa0059b2
15 changed files with 463 additions and 96 deletions

View File

@@ -59,7 +59,7 @@ public abstract class FeatureFactory {
return sFactory;
}
public abstract SupportFeatureProvider getSupportFeatureProvider();
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {

View File

@@ -16,13 +16,15 @@
package com.android.settings.overlay;
import android.content.Context;
/**
* {@link FeatureFactory} implementation for AOSP Settings.
*/
public final class FeatureFactoryImpl extends FeatureFactory {
@Override
public SupportFeatureProvider getSupportFeatureProvider() {
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
return null;
}

View File

@@ -16,16 +16,51 @@
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 java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Feature provider for support tab.
*/
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.
*/
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);
}