Merge "Import translations. DO NOT MERGE"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6120e9e..3c35428 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1590,7 +1590,11 @@
android:icon="@drawable/ic_settings_about"
android:taskAffinity="com.android.settings"
android:parentActivityName="Settings">
- <intent-filter android:priority="-1">
+ <intent-filter>
+ <action android:name="android.settings.ENTERPRISE_PRIVACY_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
<meta-data android:name="com.android.settings.category"
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 10d81df..b172e2a 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -17,7 +17,8 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/app_and_notification_dashboard_title">
<Preference
android:key="manage_perms"
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index bce5dd9..2dfb1cc 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -16,7 +16,8 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/network_dashboard_title">
<SwitchPreference
android:key="toggle_airplane"
diff --git a/res/xml/user_and_accounts_settings.xml b/res/xml/user_and_accounts_settings.xml
index 73b574f..9bb39f6 100644
--- a/res/xml/user_and_accounts_settings.xml
+++ b/res/xml/user_and_accounts_settings.xml
@@ -14,10 +14,11 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/account_settings_title"
- settings:keywords="@string/keywords_accounts">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/account_dashboard_title"
+ settings:keywords="@string/keywords_accounts">
<Preference
android:key="emergency_info"
@@ -33,7 +34,7 @@
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
- android:order="102" />
+ android:order="102"/>
<SwitchPreference
android:key="auto_sync_work_account_data"
@@ -53,7 +54,7 @@
android:order="105"/>
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="200"/>
+ android:key="dashboard_tile_placeholder"
+ android:order="200"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index 3c66b7e..351c2a2 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -51,7 +51,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
import com.android.internal.widget.TextViewInputDisabler;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.notification.RedactionInterstitial;
import com.android.settings.password.PasswordRequirementAdapter;
import com.android.setupwizardlib.GlifLayout;
@@ -157,7 +157,7 @@
layout.setFitsSystemWindows(false);
}
- public static class ChooseLockPasswordFragment extends InstrumentedFragment
+ public static class ChooseLockPasswordFragment extends InstrumentedPreferenceFragment
implements OnClickListener, OnEditorActionListener, TextWatcher,
SaveAndFinishWorker.Listener {
private static final String KEY_FIRST_PIN = "first_pin";
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index d92e6aa..4afeae0 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -37,7 +37,7 @@
import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell;
import com.android.internal.widget.LockPatternView.DisplayMode;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.notification.RedactionInterstitial;
import com.android.setupwizardlib.GlifLayout;
import com.google.android.collect.Lists;
@@ -127,7 +127,7 @@
return super.onKeyDown(keyCode, event);
}
- public static class ChooseLockPatternFragment extends InstrumentedFragment
+ public static class ChooseLockPatternFragment extends InstrumentedPreferenceFragment
implements View.OnClickListener, SaveAndFinishWorker.Listener {
public static final int CONFIRM_EXISTING_REQUEST = 55;
diff --git a/src/com/android/settings/CryptKeeperConfirm.java b/src/com/android/settings/CryptKeeperConfirm.java
index e12ebe0..d61fd98 100644
--- a/src/com/android/settings/CryptKeeperConfirm.java
+++ b/src/com/android/settings/CryptKeeperConfirm.java
@@ -35,11 +35,11 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import java.util.Locale;
-public class CryptKeeperConfirm extends InstrumentedFragment {
+public class CryptKeeperConfirm extends InstrumentedPreferenceFragment {
private static final String TAG = "CryptKeeperConfirm";
diff --git a/src/com/android/settings/CryptKeeperSettings.java b/src/com/android/settings/CryptKeeperSettings.java
index cdeb55f..d9b98f0 100644
--- a/src/com/android/settings/CryptKeeperSettings.java
+++ b/src/com/android/settings/CryptKeeperSettings.java
@@ -36,9 +36,9 @@
import android.widget.Button;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
-public class CryptKeeperSettings extends InstrumentedFragment {
+public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
private static final String TAG = "CryptKeeper";
private static final String TYPE = "type";
private static final String PASSWORD = "password";
diff --git a/src/com/android/settings/OptionsMenuFragment.java b/src/com/android/settings/OptionsMenuFragment.java
index d1e3db2..c8dcc8e 100644
--- a/src/com/android/settings/OptionsMenuFragment.java
+++ b/src/com/android/settings/OptionsMenuFragment.java
@@ -17,7 +17,7 @@
import android.os.Bundle;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
/**
* Base class for a fragment that has the options menu.
@@ -25,7 +25,7 @@
* preferences, and we need to call setHasOptionsMenu(true) for the back button on action bar.
* For preference fragments, use SettingsPreferenceFragment.
*/
-public abstract class OptionsMenuFragment extends InstrumentedFragment {
+public abstract class OptionsMenuFragment extends InstrumentedPreferenceFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
diff --git a/src/com/android/settings/ProxySelector.java b/src/com/android/settings/ProxySelector.java
index b272637..a72525c 100644
--- a/src/com/android/settings/ProxySelector.java
+++ b/src/com/android/settings/ProxySelector.java
@@ -41,9 +41,9 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsPreferenceFragment.SettingsDialogFragment;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
-public class ProxySelector extends InstrumentedFragment implements DialogCreatable {
+public class ProxySelector extends InstrumentedPreferenceFragment implements DialogCreatable {
private static final String TAG = "ProxySelector";
EditText mHostnameField;
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 8118dab..5f42579 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -45,7 +45,7 @@
import android.widget.Button;
import com.android.settings.applications.LayoutPreference;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.Instrumentable;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.HelpUtils;
@@ -55,7 +55,7 @@
/**
* Base class for Settings fragments, with some helper functions and dialog management.
*/
-public abstract class SettingsPreferenceFragment extends InstrumentedFragment
+public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceFragment
implements DialogCreatable {
/**
diff --git a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
index 4808837..4113152 100644
--- a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java
@@ -16,19 +16,20 @@
package com.android.settings.accounts;
import android.content.Context;
-
import android.os.Bundle;
-import android.support.v7.preference.Preference;
-import android.util.ArraySet;
+import android.provider.SearchIndexableResource;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.drawer.CategoryKey;
-
import com.android.settingslib.drawer.Tile;
+
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
import java.util.List;
import static android.provider.Settings.EXTRA_AUTHORITIES;
@@ -37,7 +38,6 @@
private static final String TAG = "UserAndAccountDashboard";
private static final String METADATA_IA_ACCOUNT = "com.android.settings.ia.account";
- private HashMap<String, ArraySet<Preference>> mAccountTiles = new HashMap<>();
@Override
public int getMetricsCategory() {
@@ -72,7 +72,7 @@
controllers.add(new AutoSyncWorkDataPreferenceController(context, this));
String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
final AccountPreferenceController accountPrefController =
- new AccountPreferenceController(context, this, authorities);
+ new AccountPreferenceController(context, this, authorities);
getLifecycle().addObserver(accountPrefController);
controllers.add(accountPrefController);
return controllers;
@@ -87,4 +87,18 @@
return true;
}
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
+ .isEnabled()) {
+ return null;
+ }
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.user_and_accounts_settings;
+ return Arrays.asList(sir);
+ }
+ };
}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 8630541..45b472a 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -17,12 +17,16 @@
package com.android.settings.applications;
import android.content.Context;
+import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.drawer.CategoryKey;
+import java.util.Arrays;
import java.util.List;
public class AppAndNotificationDashboardFragment extends DashboardFragment {
@@ -53,4 +57,19 @@
protected List<PreferenceController> getPreferenceControllers(Context context) {
return null;
}
+
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
+ .isEnabled()) {
+ return null;
+ }
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.app_and_notification;
+ return Arrays.asList(sir);
+ }
+ };
}
diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java
index ba60302..e6c040b 100644
--- a/src/com/android/settings/applications/AppOpsDetails.java
+++ b/src/com/android/settings/applications/AppOpsDetails.java
@@ -39,14 +39,14 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import java.util.List;
-public class AppOpsDetails extends InstrumentedFragment {
+public class AppOpsDetails extends InstrumentedPreferenceFragment {
static final String TAG = "AppOpsDetails";
public static final String ARG_PACKAGE_NAME = "package";
diff --git a/src/com/android/settings/applications/AppOpsSummary.java b/src/com/android/settings/applications/AppOpsSummary.java
index ac0a856..ba2a3c9 100644
--- a/src/com/android/settings/applications/AppOpsSummary.java
+++ b/src/com/android/settings/applications/AppOpsSummary.java
@@ -29,10 +29,10 @@
import android.view.ViewGroup;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
-public class AppOpsSummary extends InstrumentedFragment {
+public class AppOpsSummary extends InstrumentedPreferenceFragment {
// layout inflater object used to inflate views
private LayoutInflater mInflater;
diff --git a/src/com/android/settings/applications/BackgroundCheckSummary.java b/src/com/android/settings/applications/BackgroundCheckSummary.java
index 1ff43c8..dd5c89c 100644
--- a/src/com/android/settings/applications/BackgroundCheckSummary.java
+++ b/src/com/android/settings/applications/BackgroundCheckSummary.java
@@ -24,10 +24,10 @@
import android.view.ViewGroup;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
-public class BackgroundCheckSummary extends InstrumentedFragment {
+public class BackgroundCheckSummary extends InstrumentedPreferenceFragment {
// layout inflater object used to inflate views
private LayoutInflater mInflater;
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 0ec9f1b..37b4b96 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -67,7 +67,7 @@
import com.android.settings.Utils;
import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
import com.android.settings.applications.AppStateUsageBridge.UsageState;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.fuelgauge.HighPowerDetail;
import com.android.settings.fuelgauge.PowerWhitelistBackend;
@@ -95,7 +95,7 @@
* can be launched through Settings or via the ACTION_MANAGE_PACKAGE_STORAGE
* intent.
*/
-public class ManageApplications extends InstrumentedFragment
+public class ManageApplications extends InstrumentedPreferenceFragment
implements OnItemClickListener, OnItemSelectedListener {
static final String TAG = "ManageApplications";
diff --git a/src/com/android/settings/applications/ProcessStatsMemDetail.java b/src/com/android/settings/applications/ProcessStatsMemDetail.java
index 46a707b..b38aaf6 100644
--- a/src/com/android/settings/applications/ProcessStatsMemDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsMemDetail.java
@@ -26,12 +26,12 @@
import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import static com.android.settings.Utils.prepareCustomPreferencesList;
-public class ProcessStatsMemDetail extends InstrumentedFragment {
+public class ProcessStatsMemDetail extends InstrumentedPreferenceFragment {
public static final String EXTRA_MEM_TIMES = "mem_times";
public static final String EXTRA_MEM_STATE_WEIGHTS = "mem_state_weights";
public static final String EXTRA_MEM_CACHED_WEIGHT = "mem_cached_weight";
diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java
index 28a8029..9a173bc 100644
--- a/src/com/android/settings/applications/RunningServiceDetails.java
+++ b/src/com/android/settings/applications/RunningServiceDetails.java
@@ -33,7 +33,7 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -45,7 +45,7 @@
import java.util.ArrayList;
import java.util.Collections;
-public class RunningServiceDetails extends InstrumentedFragment
+public class RunningServiceDetails extends InstrumentedPreferenceFragment
implements RunningState.OnRefreshUiListener {
static final String TAG = "RunningServicesDetails";
diff --git a/src/com/android/settings/core/InstrumentedFragment.java b/src/com/android/settings/core/InstrumentedFragment.java
index 45e855e..e55cc27 100644
--- a/src/com/android/settings/core/InstrumentedFragment.java
+++ b/src/com/android/settings/core/InstrumentedFragment.java
@@ -17,37 +17,17 @@
package com.android.settings.core;
import android.content.Context;
-import android.os.Bundle;
import com.android.settings.core.instrumentation.Instrumentable;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.core.instrumentation.VisibilityLoggerMixin;
-import com.android.settings.core.lifecycle.ObservablePreferenceFragment;
+import com.android.settings.core.lifecycle.ObservableFragment;
import com.android.settings.overlay.FeatureFactory;
-/**
- * Instrumented fragment that logs visibility state.
- */
-public abstract class InstrumentedFragment extends ObservablePreferenceFragment
- implements Instrumentable {
+public abstract class InstrumentedFragment extends ObservableFragment implements Instrumentable {
protected MetricsFeatureProvider mMetricsFeatureProvider;
- // metrics placeholder value. Only use this for development.
- protected final int PLACEHOLDER_METRIC = 10000;
- protected final int SYSTEM_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 1;
- protected final int STORAGE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 2;
- protected final int NETWORK_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 3;
- protected final int CONNECTED_DEVICE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 4;
- protected final int APP_AND_NOTIFICATION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 5;
- protected final int INPUT_AND_GESTURE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 6;
- protected final int LANGUAGE_AND_REGION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 7;
- protected final int GESTURE_SWIPE_TO_NOTIFICATION = PLACEHOLDER_METRIC + 8;
- protected final int GESTURE_DOUBLE_TAP_POWER = PLACEHOLDER_METRIC + 9;
- protected final int GESTURE_PICKUP = PLACEHOLDER_METRIC + 10;
- protected final int GESTURE_DOUBLE_TAP_SCREEN = PLACEHOLDER_METRIC + 11;
- protected final int GESTURE_DOUBLE_TWIST = PLACEHOLDER_METRIC + 12;
-
public InstrumentedFragment() {
// Mixin that logs visibility change for activity.
getLifecycle().addObserver(new VisibilityLoggerMixin(getMetricsCategory()));
@@ -58,8 +38,4 @@
super.onAttach(context);
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
-
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
- }
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/core/InstrumentedPreferenceFragment.java b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
new file mode 100644
index 0000000..1724d0c
--- /dev/null
+++ b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
@@ -0,0 +1,65 @@
+/*
+ * 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.core;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.settings.core.instrumentation.Instrumentable;
+import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.core.instrumentation.VisibilityLoggerMixin;
+import com.android.settings.core.lifecycle.ObservablePreferenceFragment;
+import com.android.settings.overlay.FeatureFactory;
+
+/**
+ * Instrumented fragment that logs visibility state.
+ */
+public abstract class InstrumentedPreferenceFragment extends ObservablePreferenceFragment
+ implements Instrumentable {
+
+ protected MetricsFeatureProvider mMetricsFeatureProvider;
+
+ // metrics placeholder value. Only use this for development.
+ protected final int PLACEHOLDER_METRIC = 10000;
+ protected final int SYSTEM_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 1;
+ protected final int STORAGE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 2;
+ protected final int NETWORK_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 3;
+ protected final int CONNECTED_DEVICE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 4;
+ protected final int APP_AND_NOTIFICATION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 5;
+ protected final int INPUT_AND_GESTURE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 6;
+ protected final int LANGUAGE_AND_REGION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 7;
+ protected final int GESTURE_SWIPE_TO_NOTIFICATION = PLACEHOLDER_METRIC + 8;
+ protected final int GESTURE_DOUBLE_TAP_POWER = PLACEHOLDER_METRIC + 9;
+ protected final int GESTURE_PICKUP = PLACEHOLDER_METRIC + 10;
+ protected final int GESTURE_DOUBLE_TAP_SCREEN = PLACEHOLDER_METRIC + 11;
+ protected final int GESTURE_DOUBLE_TWIST = PLACEHOLDER_METRIC + 12;
+
+ public InstrumentedPreferenceFragment() {
+ // Mixin that logs visibility change for activity.
+ getLifecycle().addObserver(new VisibilityLoggerMixin(getMetricsCategory()));
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+ }
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ }
+}
diff --git a/src/com/android/settings/core/lifecycle/ObservableFragment.java b/src/com/android/settings/core/lifecycle/ObservableFragment.java
new file mode 100644
index 0000000..b146325
--- /dev/null
+++ b/src/com/android/settings/core/lifecycle/ObservableFragment.java
@@ -0,0 +1,87 @@
+/*
+ * 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.core.lifecycle;
+
+import android.annotation.CallSuper;
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+
+public class ObservableFragment extends Fragment {
+
+ private final Lifecycle mLifecycle = new Lifecycle();
+
+ protected Lifecycle getLifecycle() {
+ return mLifecycle;
+ }
+
+ @CallSuper
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ mLifecycle.onAttach(context);
+ }
+
+ @CallSuper
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ mLifecycle.onCreate(savedInstanceState);
+ super.onCreate(savedInstanceState);
+ }
+
+ @CallSuper
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mLifecycle.onSaveInstanceState(outState);
+ }
+
+ @CallSuper
+ @Override
+ public void onStart() {
+ mLifecycle.onStart();
+ super.onStart();
+ }
+
+ @CallSuper
+ @Override
+ public void onStop() {
+ mLifecycle.onStop();
+ super.onStop();
+ }
+
+ @CallSuper
+ @Override
+ public void onResume() {
+ mLifecycle.onResume();
+ super.onResume();
+ }
+
+ @CallSuper
+ @Override
+ public void onPause() {
+ mLifecycle.onPause();
+ super.onPause();
+ }
+
+ @CallSuper
+ @Override
+ public void onDestroy() {
+ mLifecycle.onDestroy();
+ super.onDestroy();
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 09c0e62..b98de22 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -32,7 +32,7 @@
import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.SettingsActivity;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.dashboard.conditional.ConditionAdapterUtils;
import com.android.settings.dashboard.conditional.ConditionManager;
@@ -47,7 +47,7 @@
import java.util.ArrayList;
import java.util.List;
-public class DashboardSummary extends InstrumentedFragment
+public class DashboardSummary extends InstrumentedPreferenceFragment
implements SettingsDrawerActivity.CategoryListener, ConditionManager.ConditionListener,
FocusRecyclerView.FocusListener {
public static final boolean DEBUG = false;
diff --git a/src/com/android/settings/dashboard/SearchResultsSummary.java b/src/com/android/settings/dashboard/SearchResultsSummary.java
index 7097485..ef84f8b 100644
--- a/src/com/android/settings/dashboard/SearchResultsSummary.java
+++ b/src/com/android/settings/dashboard/SearchResultsSummary.java
@@ -41,12 +41,12 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.search.Index;
import java.util.HashMap;
-public class SearchResultsSummary extends InstrumentedFragment {
+public class SearchResultsSummary extends InstrumentedPreferenceFragment {
private static final String LOG_TAG = "SearchResultsSummary";
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java b/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
index c4ca880..319a09c 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeFormat.java
@@ -30,10 +30,10 @@
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
-public class PrivateVolumeFormat extends InstrumentedFragment {
+public class PrivateVolumeFormat extends InstrumentedPreferenceFragment {
private VolumeInfo mVolume;
private DiskInfo mDisk;
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java b/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
index c0c0d33..e0c5d65 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollSidecar.java
@@ -28,12 +28,12 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.Utils;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
/**
* Sidecar fragment to handle the state around fingerprint enrollment.
*/
-public class FingerprintEnrollSidecar extends InstrumentedFragment {
+public class FingerprintEnrollSidecar extends InstrumentedPreferenceFragment {
private int mEnrollmentSteps = -1;
private int mEnrollmentRemaining = 0;
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
index 65b40a3..0d30bcc 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
@@ -27,7 +27,7 @@
import android.widget.ArrayAdapter;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
@@ -41,7 +41,7 @@
* As opposed to the UserDictionaryActivity, this is only invoked within Settings
* from the UserDictionarySettings.
*/
-public class UserDictionaryAddWordFragment extends InstrumentedFragment
+public class UserDictionaryAddWordFragment extends InstrumentedPreferenceFragment
implements AdapterView.OnItemSelectedListener,
com.android.internal.app.LocalePicker.LocaleSelectionListener {
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index cb75f0e..a58a879 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -18,15 +18,19 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
+import android.provider.SearchIndexableResource;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.drawer.CategoryKey;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import static com.android.settings.network.MobilePlanPreferenceController
@@ -107,4 +111,19 @@
}
return 0;
}
+
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
+ .isEnabled()) {
+ return null;
+ }
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.network_and_internet;
+ return Arrays.asList(sir);
+ }
+ };
}
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index 76b67e8..fe264f3 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -29,7 +29,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.HelpUtils;
-import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.ShowAdminSupportDetailsDialog;
@@ -38,7 +38,7 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-public class AndroidBeam extends InstrumentedFragment
+public class AndroidBeam extends InstrumentedPreferenceFragment
implements SwitchBar.OnSwitchChangeListener {
private View mView;
private NfcAdapter mNfcAdapter;
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 72aee16..7fa302c 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -34,7 +34,9 @@
import com.android.settings.WirelessSettings;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accounts.AccountSettings;
+import com.android.settings.accounts.UserAndAccountDashboardFragment;
import com.android.settings.applications.AdvancedAppSettings;
+import com.android.settings.applications.AppAndNotificationDashboardFragment;
import com.android.settings.applications.SpecialAccessSettings;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
@@ -55,6 +57,7 @@
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
import com.android.settings.location.LocationSettings;
import com.android.settings.location.ScanningSettings;
+import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.OtherSoundSettings;
import com.android.settings.notification.SoundSettings;
@@ -89,6 +92,7 @@
static {
addIndex(WifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
+ addIndex(NetworkDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
addIndex(AdvancedWifiSettings.class,
R.xml.wifi_advanced_settings, R.drawable.ic_settings_wireless);
addIndex(SavedAccessPointsWifiSettings.class,
@@ -103,6 +107,8 @@
addIndex(WallpaperTypeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
addIndex(ConfigureNotificationSettings.class,
R.xml.configure_notification_settings, R.drawable.ic_settings_notifications);
+ addIndex(AppAndNotificationDashboardFragment.class, NO_DATA_RES_ID,
+ R.drawable.ic_settings_applications);
addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
addIndex(OtherSoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
addIndex(ZenModeSettings.class,
@@ -130,6 +136,8 @@
addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
addIndex(ScreenPinningSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
addIndex(AccountSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accounts);
+ addIndex(UserAndAccountDashboardFragment.class, NO_DATA_RES_ID,
+ R.drawable.ic_settings_accounts);
addIndex(InputMethodAndLanguageSettings.class,
NO_DATA_RES_ID, R.drawable.ic_settings_language);
addIndex(PrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_backup);
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 2b3ca09..05cd93b 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -1,8 +1,5 @@
com.android.settings.notification.ConfigureNotificationSettings
com.android.settings.language.LanguageAndRegionSettings
-com.android.settings.accounts.UserAndAccountDashboardFragment
-com.android.settings.network.NetworkDashboardFragment
-com.android.settings.applications.AppAndNotificationDashboardFragment
com.android.settings.notification.ZenModePrioritySettings
com.android.settings.inputmethod.InputAndGestureSettings
com.android.settings.accounts.AccountDetailDashboardFragment
\ No newline at end of file
diff --git a/tests/robotests/assets/grandfather_not_implementing_instrumentable b/tests/robotests/assets/grandfather_not_implementing_instrumentable
index 5bd96af..c1f0d60 100644
--- a/tests/robotests/assets/grandfather_not_implementing_instrumentable
+++ b/tests/robotests/assets/grandfather_not_implementing_instrumentable
@@ -1,4 +1,5 @@
com.android.settings.deletionhelper.ActivationWarningFragment
com.android.settings.core.lifecycle.ObservableDialogFragment
+com.android.settings.core.lifecycle.ObservableFragment
com.android.settings.applications.AppOpsCategory
com.android.settings.inputmethod.UserDictionaryLocalePicker
diff --git a/tests/robotests/src/com/android/settings/accounts/UserAndAccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/UserAndAccountDashboardFragmentTest.java
index 2df7e2b..90761a0 100644
--- a/tests/robotests/src/com/android/settings/accounts/UserAndAccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/UserAndAccountDashboardFragmentTest.java
@@ -15,19 +15,29 @@
*/
package com.android.settings.accounts;
+import android.content.Context;
import android.os.Bundle;
+import android.provider.SearchIndexableResource;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.List;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -36,10 +46,17 @@
private static final String METADATA_CATEGORY = "com.android.settings.category";
private static final String METADATA_ACCOUNT_TYPE = "com.android.settings.ia.account";
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
private UserAndAccountDashboardFragment mFragment;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ FakeFeatureFactory.setupForTest(mContext);
+ final FakeFeatureFactory factory =
+ (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ when(factory.dashboardFeatureProvider.isEnabled()).thenReturn(true);
mFragment = new UserAndAccountDashboardFragment();
}
@@ -68,4 +85,15 @@
assertThat(mFragment.displayTile(tile)).isTrue();
}
+
+ @Test
+ public void testSearchIndexProvider_shouldIndexResource() {
+ final List<SearchIndexableResource> indexRes =
+ UserAndAccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ ShadowApplication.getInstance().getApplicationContext(),
+ true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/core/lifecycle/LifecycleTest.java b/tests/robotests/src/com/android/settings/core/lifecycle/LifecycleTest.java
index 6aae543..db83bbb 100644
--- a/tests/robotests/src/com/android/settings/core/lifecycle/LifecycleTest.java
+++ b/tests/robotests/src/com/android/settings/core/lifecycle/LifecycleTest.java
@@ -16,6 +16,7 @@
package com.android.settings.core.lifecycle;
import android.content.Context;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.lifecycle.events.OnAttach;
@@ -24,6 +25,7 @@
import com.android.settings.core.lifecycle.events.OnResume;
import com.android.settings.core.lifecycle.events.OnStart;
import com.android.settings.core.lifecycle.events.OnStop;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -47,6 +49,16 @@
}
}
+ public static class TestFragment extends ObservableFragment {
+
+ final TestObserver mFragObserver;
+
+ public TestFragment() {
+ mFragObserver = new TestObserver();
+ getLifecycle().addObserver(mFragObserver);
+ }
+ }
+
public static class TestActivity extends ObservableActivity {
final TestObserver mActObserver;
@@ -119,7 +131,7 @@
}
@Test
- public void runThroughFragmentLifecycles_shouldObserveEverything() {
+ public void runThroughDialogFragmentLifecycles_shouldObserveEverything() {
FragmentController<TestDialogFragment> fragmentController =
Robolectric.buildFragment(TestDialogFragment.class);
TestDialogFragment fragment = fragmentController.get();
@@ -134,4 +146,21 @@
assertThat(fragment.mFragObserver.mOnStopObserved).isTrue();
assertThat(fragment.mFragObserver.mOnDestroyObserved).isTrue();
}
+
+ @Test
+ public void runThroughFragmentLifecycles_shouldObserveEverything() {
+ FragmentController<TestFragment> fragmentController =
+ Robolectric.buildFragment(TestFragment.class);
+ TestFragment fragment = fragmentController.get();
+
+ fragmentController.attach().create().start().resume().pause().stop().destroy();
+
+ assertThat(fragment.mFragObserver.mOnAttachObserved).isTrue();
+ assertThat(fragment.mFragObserver.mOnAttachHasContext).isTrue();
+ assertThat(fragment.mFragObserver.mOnStartObserved).isTrue();
+ assertThat(fragment.mFragObserver.mOnResumeObserved).isTrue();
+ assertThat(fragment.mFragObserver.mOnPauseObserved).isTrue();
+ assertThat(fragment.mFragObserver.mOnStopObserved).isTrue();
+ assertThat(fragment.mFragObserver.mOnDestroyObserved).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
index 6dd9c75..b30e3ff 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
@@ -16,8 +16,11 @@
package com.android.settings.network;
import android.content.Context;
+import android.provider.SearchIndexableResource;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.accounts.UserAndAccountDashboardFragment;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.drawer.CategoryKey;
import org.junit.Before;
@@ -27,8 +30,12 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+
+import java.util.List;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -43,6 +50,9 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
+ final FakeFeatureFactory factory =
+ (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ when(factory.dashboardFeatureProvider.isEnabled()).thenReturn(true);
mFragment = new NetworkDashboardFragment();
}
@@ -50,4 +60,15 @@
public void testCategory_isNetwork() {
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_NETWORK);
}
+
+ @Test
+ public void testSearchIndexProvider_shouldIndexResource() {
+ final List<SearchIndexableResource> indexRes =
+ NetworkDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ ShadowApplication.getInstance().getApplicationContext(),
+ true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
index 06f4322..67189d0 100644
--- a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
@@ -19,16 +19,16 @@
import android.app.Activity;
import android.view.Menu;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search2.SearchFeatureProviderImpl;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
-
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
@@ -50,19 +50,18 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mActivity = Robolectric.buildActivity(Activity.class).create().visible().get();
- mProvider = (SearchFeatureProviderImpl) FeatureFactory.getFactory(mActivity)
- .getSearchFeatureProvider(mActivity);
+ mProvider = new SearchFeatureProviderImpl(mActivity);
}
@Test
public void testPassNull_NoError() {
- mProvider.setUpSearchMenu(null,null);
+ mProvider.setUpSearchMenu(null, null);
}
@Test
public void testSetUpMenu_HasItemAdded() {
mProvider.setUpSearchMenu(menu, mActivity);
- verify(menu).add(anyInt(),anyInt(), anyInt(), anyString());
+ verify(menu).add(anyInt(), anyInt(), anyInt(), anyString());
}
}