Files
packages_apps_Settings/src/com/android/settings/overlay/FeatureFactory.java
Fan Zhang a9fa0059b2 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
2016-04-27 09:06:17 -07:00

70 lines
2.6 KiB
Java

/*
* 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.overlay;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.R;
/**
* Abstract class for creating feature controllers. Allows OEM implementations to define their own
* factories with their own controllers containing whatever code is needed to implement
* the features. To provide a factory implementation, implementors should override
* {@link R.string#config_featureFactory} in their override.
*/
public abstract class FeatureFactory {
private static final String LOG_TAG = "FeatureFactory";
private static final boolean DEBUG = false;
private static FeatureFactory sFactory;
/**
* Returns a factory for creating feature controllers. Creates the factory if it does not
* already exist. Uses the value of {@link R.string#config_featureFactory} to instantiate
* a factory implementation.
*/
public static FeatureFactory getFactory(Context context) {
if (sFactory != null) {
return sFactory;
}
if (DEBUG) Log.d(LOG_TAG, "getFactory");
final String clsName = context.getString(R.string.config_featureFactory);
if (TextUtils.isEmpty(clsName)) {
throw new UnsupportedOperationException("No feature factory configured");
}
try {
sFactory = (FeatureFactory) context.getClassLoader().loadClass(clsName).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new FactoryNotFoundException(e);
}
if (DEBUG) Log.d(LOG_TAG, "started " + sFactory.getClass().getSimpleName());
return sFactory;
}
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
}
}
}