Loading src/com/android/settings/overlay/FeatureFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public abstract class FeatureFactory { public abstract SearchFeatureProvider getSearchFeatureProvider(Context context); public abstract SurveyFeatureProvider getSurveyFeatureProvider(Context context); public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); Loading src/com/android/settings/overlay/FeatureFactoryImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,9 @@ public class FeatureFactoryImpl extends FeatureFactory { } return mSearchFeatureProvider; } @Override public SurveyFeatureProvider getSurveyFeatureProvider(Context context) { return null; } } src/com/android/settings/overlay/SurveyFeatureProvider.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.IntentFilter; import android.support.annotation.Nullable; /** * An interface for classes wishing to provide the ability to serve surveys to implement. */ public interface SurveyFeatureProvider { /** * Downloads a survey asynchronously to shared preferences to be served at a later date. * * @param activity A valid context. * @param surveyId A unique Id representing a survey to download. * @param data a text blob to be attached to the survey results. */ void downloadSurvey(Activity activity, String surveyId, @Nullable String data); /** * Shows a previously downloaded survey/prompt if possible in the activity provided. * * @param activity The host activity to show the survey in. * @param surveyId A unique Id representing a survey to download. */ void showSurveyIfAvailable(Activity activity, String surveyId); /** * A helper method to get the surveyId. Implementers should create a mapping of * keys to surveyIds and provide them via this function. * * @param context A valid context. * @param key The key to get the surveyId for. * @return The unique Id as a string or null on error. */ String getSurveyId(Context context, String key); } tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +8 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.SupportFeatureProvider; import com.android.settings.search2.SearchFeatureProvider; import com.android.settings.overlay.SurveyFeatureProvider; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; Loading @@ -45,6 +46,7 @@ public class FakeFeatureFactory extends FeatureFactory { public final ApplicationFeatureProvider applicationFeatureProvider; public final EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider; public final SearchFeatureProvider searchFeatureProvider; public final SurveyFeatureProvider surveyFeatureProvider; /** * Call this in {@code @Before} method of the test class to use fake factory. Loading Loading @@ -75,6 +77,7 @@ public class FakeFeatureFactory extends FeatureFactory { applicationFeatureProvider = mock(ApplicationFeatureProvider.class); enterprisePrivacyFeatureProvider = mock(EnterprisePrivacyFeatureProvider.class); searchFeatureProvider = mock(SearchFeatureProvider.class); surveyFeatureProvider = mock(SurveyFeatureProvider.class); } @Override Loading Loading @@ -116,4 +119,9 @@ public class FakeFeatureFactory extends FeatureFactory { public SearchFeatureProvider getSearchFeatureProvider(Context context) { return searchFeatureProvider; } @Override public SurveyFeatureProvider getSurveyFeatureProvider(Context context) { return surveyFeatureProvider; } } Loading
src/com/android/settings/overlay/FeatureFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,8 @@ public abstract class FeatureFactory { public abstract SearchFeatureProvider getSearchFeatureProvider(Context context); public abstract SurveyFeatureProvider getSurveyFeatureProvider(Context context); public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); Loading
src/com/android/settings/overlay/FeatureFactoryImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,9 @@ public class FeatureFactoryImpl extends FeatureFactory { } return mSearchFeatureProvider; } @Override public SurveyFeatureProvider getSurveyFeatureProvider(Context context) { return null; } }
src/com/android/settings/overlay/SurveyFeatureProvider.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /* * 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.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.IntentFilter; import android.support.annotation.Nullable; /** * An interface for classes wishing to provide the ability to serve surveys to implement. */ public interface SurveyFeatureProvider { /** * Downloads a survey asynchronously to shared preferences to be served at a later date. * * @param activity A valid context. * @param surveyId A unique Id representing a survey to download. * @param data a text blob to be attached to the survey results. */ void downloadSurvey(Activity activity, String surveyId, @Nullable String data); /** * Shows a previously downloaded survey/prompt if possible in the activity provided. * * @param activity The host activity to show the survey in. * @param surveyId A unique Id representing a survey to download. */ void showSurveyIfAvailable(Activity activity, String surveyId); /** * A helper method to get the surveyId. Implementers should create a mapping of * keys to surveyIds and provide them via this function. * * @param context A valid context. * @param key The key to get the surveyId for. * @return The unique Id as a string or null on error. */ String getSurveyId(Context context, String key); }
tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +8 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.SupportFeatureProvider; import com.android.settings.search2.SearchFeatureProvider; import com.android.settings.overlay.SurveyFeatureProvider; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; Loading @@ -45,6 +46,7 @@ public class FakeFeatureFactory extends FeatureFactory { public final ApplicationFeatureProvider applicationFeatureProvider; public final EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider; public final SearchFeatureProvider searchFeatureProvider; public final SurveyFeatureProvider surveyFeatureProvider; /** * Call this in {@code @Before} method of the test class to use fake factory. Loading Loading @@ -75,6 +77,7 @@ public class FakeFeatureFactory extends FeatureFactory { applicationFeatureProvider = mock(ApplicationFeatureProvider.class); enterprisePrivacyFeatureProvider = mock(EnterprisePrivacyFeatureProvider.class); searchFeatureProvider = mock(SearchFeatureProvider.class); surveyFeatureProvider = mock(SurveyFeatureProvider.class); } @Override Loading Loading @@ -116,4 +119,9 @@ public class FakeFeatureFactory extends FeatureFactory { public SearchFeatureProvider getSearchFeatureProvider(Context context) { return searchFeatureProvider; } @Override public SurveyFeatureProvider getSurveyFeatureProvider(Context context) { return surveyFeatureProvider; } }