diff --git a/res/values/config.xml b/res/values/config.xml
index 2920ac839d4..f5105232035 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -106,9 +106,6 @@
-->
-
- true
-
true
@@ -133,4 +130,7 @@
devices will be able to vary their amplitude but do not possess enough dynamic range to
have distinct intensity levels -->
false
+
+
+ true
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index 7e7cf46caf4..5cc1b3b6712 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -44,6 +44,7 @@ import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.dashboard.conditional.ConditionAdapter;
import com.android.settings.dashboard.suggestions.SuggestionAdapter;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.widget.RoundedHomepageIcon;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProvider.java b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
index ac11e0bb497..81fb99e83be 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProvider.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
@@ -15,8 +15,6 @@
*/
package com.android.settings.dashboard;
-import android.content.Context;
-
import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
@@ -35,34 +33,11 @@ public interface DashboardFeatureProvider {
*/
DashboardCategory getTilesForCategory(String key);
- /**
- * Get tiles (wrapped as a list of Preference) for key defined in CategoryKey.
- *
- * @param activity Activity hosting the preference
- * @param context UI context to inflate preference
- * @param sourceMetricsCategory The context (source) from which an action is performed
- * @param key Value from CategoryKey
- * @deprecated Pages implementing {@code DashboardFragment} should use
- * {@link #getTilesForCategory(String)} instead. Using this method will not get the benefit
- * of auto-ordering, progressive disclosure, auto-refreshing summary text etc.
- */
- @Deprecated
- List getPreferencesForCategory(FragmentActivity activity, Context context,
- int sourceMetricsCategory, String key);
-
/**
* Get all tiles, grouped by category.
*/
List getAllCategories();
- /**
- * Whether or not we should tint icons in setting pages.
- *
- * @deprecated in favor of color icons in homepage
- */
- @Deprecated
- boolean shouldTintIcon();
-
/**
* Returns an unique string key for the tile.
*/
@@ -72,6 +47,7 @@ public interface DashboardFeatureProvider {
* Binds preference to data provided by tile.
*
* @param activity If tile contains intent to launch, it will be launched from this activity
+ * @param forceRoundedIcon Whether or not injected tiles from other packages should be forced to rounded icon.
* @param sourceMetricsCategory The context (source) from which an action is performed
* @param pref The preference to bind data
* @param tile The binding data
@@ -79,8 +55,8 @@ public interface DashboardFeatureProvider {
* @param baseOrder The order offset value. When binding, pref's order is determined by
* both this value and tile's own priority.
*/
- void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory, Preference pref,
- Tile tile, String key, int baseOrder);
+ void bindPreferenceToTile(FragmentActivity activity, boolean forceRoundedIcon,
+ int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder);
/**
* Returns additional intent filter action for dashboard tiles
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index e4dd7a61aa9..6c575189fc1 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -80,39 +80,11 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
return mCategoryManager.getTilesByCategory(mContext, key);
}
- @Override
- public List getPreferencesForCategory(FragmentActivity activity, Context context,
- int sourceMetricsCategory, String key) {
- final DashboardCategory category = getTilesForCategory(key);
- if (category == null) {
- Log.d(TAG, "NO dashboard tiles for " + TAG);
- return null;
- }
- final List tiles = category.getTiles();
- if (tiles == null || tiles.isEmpty()) {
- Log.d(TAG, "tile list is empty, skipping category " + category.key);
- return null;
- }
- final List preferences = new ArrayList<>();
- for (Tile tile : tiles) {
- final Preference pref = new Preference(context);
- bindPreferenceToTile(activity, sourceMetricsCategory, pref, tile, null /* key */,
- Preference.DEFAULT_ORDER /* baseOrder */);
- preferences.add(pref);
- }
- return preferences;
- }
-
@Override
public List getAllCategories() {
return mCategoryManager.getCategories(mContext);
}
- @Override
- public boolean shouldTintIcon() {
- return mContext.getResources().getBoolean(R.bool.config_tintSettingIcon);
- }
-
@Override
public String getDashboardKeyForTile(Tile tile) {
if (tile == null) {
@@ -128,8 +100,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
}
@Override
- public void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory,
- Preference pref, Tile tile, String key, int baseOrder) {
+ public void bindPreferenceToTile(FragmentActivity activity, boolean forceRoundedIcon,
+ int sourceMetricsCategory, Preference pref, Tile tile, String key, int baseOrder) {
if (pref == null) {
return;
}
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index acf885dee0f..a90950e5521 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -207,6 +207,10 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
@Override
protected abstract int getPreferenceScreenResId();
+ protected boolean shouldForceRoundedIcon() {
+ return false;
+ }
+
protected T use(Class clazz) {
List controllerList = mPreferenceControllers.get(clazz);
if (controllerList != null) {
@@ -343,6 +347,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
final int tintColor = a.getColor(0, context.getColor(android.R.color.white));
a.recycle();
// Install dashboard tiles.
+ final boolean forceRoundedIcons = shouldForceRoundedIcon();
for (Tile tile : tiles) {
final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
if (TextUtils.isEmpty(key)) {
@@ -361,13 +366,15 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
if (mDashboardTilePrefKeys.contains(key)) {
// Have the key already, will rebind.
final Preference preference = screen.findPreference(key);
- mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
- preference, tile, key, mPlaceholderPreferenceController.getOrder());
+ mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons,
+ getMetricsCategory(), preference, tile, key,
+ mPlaceholderPreferenceController.getOrder());
} else {
// Don't have this key, add it.
final Preference pref = new Preference(getPrefContext());
- mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
- pref, tile, key, mPlaceholderPreferenceController.getOrder());
+ mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), forceRoundedIcons,
+ getMetricsCategory(), pref, tile, key,
+ mPlaceholderPreferenceController.getOrder());
screen.addPreference(pref);
mDashboardTilePrefKeys.add(key);
}
diff --git a/src/com/android/settings/dashboard/SummaryLoader.java b/src/com/android/settings/dashboard/SummaryLoader.java
index c85aad76b79..199331d5b21 100644
--- a/src/com/android/settings/dashboard/SummaryLoader.java
+++ b/src/com/android/settings/dashboard/SummaryLoader.java
@@ -42,12 +42,6 @@ import com.android.settingslib.utils.ThreadUtils;
import java.lang.reflect.Field;
import java.util.List;
-/**
- * TODO(b/110405144): Remove this when all top level settings are converted to PreferenceControllers
- *
- * @deprecated
- */
-@Deprecated
public class SummaryLoader {
private static final boolean DEBUG = DashboardSummary.DEBUG;
private static final String TAG = "SummaryLoader";
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 5c682cc12df..c450157d254 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -91,6 +91,12 @@ public class TopLevelSettings extends DashboardFragment implements
return true;
}
+ @Override
+ protected boolean shouldForceRoundedIcon() {
+ return getContext().getResources()
+ .getBoolean(R.bool.config_force_rounded_icon_TopLevelSettings);
+ }
+
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/dashboard/RoundedHomepageIcon.java b/src/com/android/settings/widget/RoundedHomepageIcon.java
similarity index 95%
rename from src/com/android/settings/dashboard/RoundedHomepageIcon.java
rename to src/com/android/settings/widget/RoundedHomepageIcon.java
index 9848034d7e5..ab0dfecd4e7 100644
--- a/src/com/android/settings/dashboard/RoundedHomepageIcon.java
+++ b/src/com/android/settings/widget/RoundedHomepageIcon.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.dashboard;
+package com.android.settings.widget;
import static androidx.annotation.VisibleForTesting.NONE;
@@ -33,7 +33,7 @@ public class RoundedHomepageIcon extends LayerDrawable {
private static final String TAG = "RoundedHomepageIcon";
@VisibleForTesting(otherwise = NONE)
- int mBackgroundColor = -1;
+ public int mBackgroundColor = -1;
public RoundedHomepageIcon(Context context, Drawable foreground) {
super(new Drawable[] {
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 676a8dd0c71..bbbdcc2e849 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -15,7 +15,6 @@
-->
- false
false
false
false
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
index 6b19e59d43e..eca9f862b30 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
@@ -130,7 +130,7 @@ public class AccountDetailDashboardFragmentTest {
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final Preference preference = new Preference(mContext);
- dashboardFeatureProvider.bindPreferenceToTile(activity,
+ dashboardFeatureProvider.bindPreferenceToTile(activity, false /* forceRoundedIcon */,
MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, null /* key */,
Preference.DEFAULT_ORDER);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index 8f10af7afec..0f84be1e8e9 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -50,6 +50,7 @@ import com.android.settings.dashboard.suggestions.SuggestionAdapter;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.widget.RoundedHomepageIcon;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.drawer.TileUtils;
@@ -95,7 +96,6 @@ public class DashboardAdapterTest {
mActivityInfo.packageName = "pkg";
mActivityInfo.name = "class";
mActivityInfo.metaData = new Bundle();
- when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
when(mContext.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
when(mContext.getResources()).thenReturn(mResources);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index adc1ac0ff6e..dbaf8fe5b30 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -49,7 +49,7 @@ import android.os.UserManager;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
-import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -59,7 +59,6 @@ import com.android.settings.testutils.shadow.ShadowTileUtils;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
import com.android.settingslib.drawer.CategoryKey;
-import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.drawer.TileUtils;
@@ -88,19 +87,19 @@ public class DashboardFeatureProviderImplTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock
- private CategoryManager mCategoryManager;
- @Mock
private PackageManager mPackageManager;
private FakeFeatureFactory mFeatureFactory;
private Context mContext;
private ActivityInfo mActivityInfo;
private DashboardFeatureProviderImpl mImpl;
+ private boolean mForceRoundedIcon;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ mForceRoundedIcon = false;
mActivityInfo = new ActivityInfo();
mActivityInfo.packageName = "pkg";
mActivityInfo.name = "class";
@@ -127,7 +126,7 @@ public class DashboardFeatureProviderImplTest {
doReturn(Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565)))
.when(tile).getIcon(any(Context.class));
mActivityInfo.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getTitle()).isEqualTo(tile.title);
@@ -144,7 +143,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getFragment()).isNull();
@@ -163,7 +162,7 @@ public class DashboardFeatureProviderImplTest {
when(mActivity.getApplicationContext().getSystemService(Context.USER_SERVICE))
.thenReturn(mUserManager);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
@@ -180,14 +179,14 @@ public class DashboardFeatureProviderImplTest {
when(mActivity.getSystemService(Context.USER_SERVICE))
.thenReturn(mUserManager);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
any(Context.class),
any(Intent.class),
- eq(MetricsProto.MetricsEvent.SETTINGS_GESTURES));
+ eq(MetricsEvent.SETTINGS_GESTURES));
verify(mActivity)
.startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
@@ -205,7 +204,7 @@ public class DashboardFeatureProviderImplTest {
when(mActivity.getApplicationContext().getPackageName())
.thenReturn(RuntimeEnvironment.application.getPackageName());
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(
@@ -219,7 +218,7 @@ public class DashboardFeatureProviderImplTest {
@Test
public void bindPreference_nullPreference_shouldIgnore() {
final Tile tile = mock(Tile.class);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
null, tile, "123", Preference.DEFAULT_ORDER);
verifyZeroInteractions(tile);
@@ -229,7 +228,7 @@ public class DashboardFeatureProviderImplTest {
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isNotNull();
@@ -240,7 +239,7 @@ public class DashboardFeatureProviderImplTest {
public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
assertThat(preference.getSummary())
@@ -252,7 +251,7 @@ public class DashboardFeatureProviderImplTest {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.summary = "test";
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
assertThat(preference.getSummary()).isEqualTo(tile.summary);
@@ -266,7 +265,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
"content://com.android.settings/tile_summary");
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
@@ -277,7 +276,7 @@ public class DashboardFeatureProviderImplTest {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, null /* key */, Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
@@ -304,7 +303,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", baseOrder);
assertThat(preference.getOrder()).isEqualTo(tile.getOrder() + baseOrder);
@@ -317,7 +316,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, testOrder);
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getOrder()).isEqualTo(testOrder);
@@ -329,7 +328,7 @@ public class DashboardFeatureProviderImplTest {
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_KEY_ORDER, "hello");
- mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+ mImpl.bindPreferenceToTile(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN,
preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
@@ -343,7 +342,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
- mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
@@ -352,7 +351,7 @@ public class DashboardFeatureProviderImplTest {
assertThat(launchIntent.getAction())
.isEqualTo("TestAction");
assertThat(launchIntent.getIntExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY, 0))
- .isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GESTURES);
+ .isEqualTo(MetricsEvent.SETTINGS_GESTURES);
}
@Test
@@ -367,7 +366,7 @@ public class DashboardFeatureProviderImplTest {
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
- mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
+ mImpl.bindPreferenceToTile(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES,
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
@@ -377,63 +376,11 @@ public class DashboardFeatureProviderImplTest {
assertThat(launchIntent).isNull();
}
- @Test
- public void getPreferences_noCategory_shouldReturnNull() {
- mImpl = new DashboardFeatureProviderImpl(mActivity);
- ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
- when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
- .thenReturn(null);
-
- assertThat(mImpl.getPreferencesForCategory(null, null,
- MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
- .isNull();
- }
-
- @Test
- public void getPreferences_noTileForCategory_shouldReturnNull() {
- mImpl = new DashboardFeatureProviderImpl(mActivity);
- ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
- when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
- .thenReturn(new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE));
-
- assertThat(mImpl.getPreferencesForCategory(null, null,
- MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
- .isNull();
- }
-
- @Test
- public void getPreferences_hasTileForCategory_shouldReturnPrefList() {
- mImpl = new DashboardFeatureProviderImpl(mActivity);
- ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
- final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
- category.addTile(new Tile(mActivityInfo, category.key));
- when(mCategoryManager
- .getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
- .thenReturn(category);
-
- assertThat(mImpl.getPreferencesForCategory(mActivity,
- ShadowApplication.getInstance().getApplicationContext(),
- MetricsProto.MetricsEvent.SETTINGS_GESTURES,
- CategoryKey.CATEGORY_HOMEPAGE).isEmpty())
- .isFalse();
- }
-
@Test
public void testGetExtraIntentAction_shouldReturnNull() {
assertThat(mImpl.getExtraIntentAction()).isNull();
}
- @Test
- public void testShouldTintIcon_enabledInResources_shouldBeTrue() {
- assertThat(mImpl.shouldTintIcon()).isTrue();
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void testShouldTintIcon_disabledInResources_shouldBeFalse() {
- assertThat(mImpl.shouldTintIcon()).isFalse();
- }
-
@Test
public void openTileIntent_profileSelectionDialog_shouldShow() {
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
diff --git a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
new file mode 100644
index 00000000000..83ab948935e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 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.homepage;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class TopLevelSettingsTest {
+ private Context mContext;
+ private TopLevelSettings mSettings;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mSettings = spy(new TopLevelSettings());
+ when(mSettings.getContext()).thenReturn(mContext);
+ }
+
+ @Test
+ public void shouldForceRoundedIcon_true() {
+ assertThat(mSettings.shouldForceRoundedIcon()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
similarity index 98%
rename from tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
rename to tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
index 0c90660b114..177dba0083e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package com.android.settings.dashboard;
+package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;