Merge "Add SuggestionFeatureProvider interface."
This commit is contained in:
committed by
Android (Google) Code Review
commit
0d3d5e4a8e
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.content.Context;
|
||||
|
||||
/** Interface should be implemented if you have added new suggestions */
|
||||
public interface SuggestionFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns true if smart suggestion should be used instead of xml based SuggestionParser.
|
||||
*/
|
||||
boolean isSmartSuggestionEnabled(Context context);
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.content.Context;
|
||||
|
||||
public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider {
|
||||
|
||||
@Override
|
||||
public boolean isSmartSuggestionEnabled(Context context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -24,6 +24,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.SuggestionFeatureProvider;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
@@ -67,6 +68,8 @@ public abstract class FeatureFactory {
|
||||
return sFactory;
|
||||
}
|
||||
|
||||
public abstract SuggestionFeatureProvider getSuggestionFeatureProvider();
|
||||
|
||||
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
|
||||
|
||||
public abstract MetricsFeatureProvider getMetricsFeatureProvider();
|
||||
|
@@ -30,16 +30,18 @@ import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProviderImpl;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
||||
import com.android.settings.dashboard.SuggestionFeatureProvider;
|
||||
import com.android.settings.dashboard.SuggestionFeatureProviderImpl;
|
||||
import com.android.settings.enterprise.DevicePolicyManagerWrapperImpl;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProviderImpl;
|
||||
import com.android.settings.security.SecurityFeatureProvider;
|
||||
import com.android.settings.security.SecurityFeatureProviderImpl;
|
||||
import com.android.settings.search2.SearchFeatureProvider;
|
||||
import com.android.settings.search2.SearchFeatureProviderImpl;
|
||||
import com.android.settings.security.SecurityFeatureProvider;
|
||||
import com.android.settings.security.SecurityFeatureProviderImpl;
|
||||
import com.android.settings.vpn2.ConnectivityManagerWrapperImpl;
|
||||
|
||||
/**
|
||||
@@ -55,6 +57,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private EnterprisePrivacyFeatureProvider mEnterprisePrivacyFeatureProvider;
|
||||
private SearchFeatureProvider mSearchFeatureProvider;
|
||||
private SecurityFeatureProvider mSecurityFeatureProvider;
|
||||
private SuggestionFeatureProvider mSuggestionFeatureProvider;
|
||||
|
||||
@Override
|
||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||
@@ -137,4 +140,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
}
|
||||
return mSecurityFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionFeatureProvider getSuggestionFeatureProvider() {
|
||||
if (mSuggestionFeatureProvider == null) {
|
||||
mSuggestionFeatureProvider = new SuggestionFeatureProviderImpl();
|
||||
}
|
||||
return mSuggestionFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.SuggestionFeatureProvider;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
@@ -49,6 +50,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public final SearchFeatureProvider searchFeatureProvider;
|
||||
public final SurveyFeatureProvider surveyFeatureProvider;
|
||||
public final SecurityFeatureProvider securityFeatureProvider;
|
||||
public final SuggestionFeatureProvider suggestionsFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -81,6 +83,12 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
searchFeatureProvider = mock(SearchFeatureProvider.class);
|
||||
surveyFeatureProvider = mock(SurveyFeatureProvider.class);
|
||||
securityFeatureProvider = mock(SecurityFeatureProvider.class);
|
||||
suggestionsFeatureProvider = mock(SuggestionFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionFeatureProvider getSuggestionFeatureProvider() {
|
||||
return suggestionsFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user