Add a config flag so OEMs can disable avatar mixin
Not all devices have account, OEMs should be able to disable this feature if they want. Bug: 117509285 Test: robotests Change-Id: I3b03a04cff6ff0ec6c31763ac1829b119531e489
This commit is contained in:
@@ -140,6 +140,9 @@
|
|||||||
-->
|
-->
|
||||||
<bool name="config_use_legacy_suggestion">true</bool>
|
<bool name="config_use_legacy_suggestion">true</bool>
|
||||||
|
|
||||||
|
<!-- Whether or not homepage should display user's account avatar -->
|
||||||
|
<bool name="config_show_avatar_in_homepage">false</bool>
|
||||||
|
|
||||||
<!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
|
<!-- Whether or not TopLevelSettings should force rounded icon for injected tiles -->
|
||||||
<bool name="config_force_rounded_icon_TopLevelSettings">true</bool>
|
<bool name="config_force_rounded_icon_TopLevelSettings">true</bool>
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accounts;
|
|||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -34,8 +35,10 @@ import com.android.settings.overlay.FeatureFactory;
|
|||||||
* in {@link SettingsHomepageActivity}.
|
* in {@link SettingsHomepageActivity}.
|
||||||
*/
|
*/
|
||||||
public class AvatarViewMixin implements LifecycleObserver {
|
public class AvatarViewMixin implements LifecycleObserver {
|
||||||
private Context mContext;
|
private static final String TAG = "AvatarViewMixin";
|
||||||
private ImageView mAvatarView;
|
|
||||||
|
private final Context mContext;
|
||||||
|
private final ImageView mAvatarView;
|
||||||
|
|
||||||
public AvatarViewMixin(Context context, ImageView avatarView) {
|
public AvatarViewMixin(Context context, ImageView avatarView) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
@@ -44,6 +47,10 @@ public class AvatarViewMixin implements LifecycleObserver {
|
|||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
|
if (!mContext.getResources().getBoolean(R.bool.config_show_avatar_in_homepage)) {
|
||||||
|
Log.d(TAG, "Feature disabled. Skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (hasAccount()) {
|
if (hasAccount()) {
|
||||||
//TODO(b/117509285): To migrate account icon on search bar
|
//TODO(b/117509285): To migrate account icon on search bar
|
||||||
} else {
|
} else {
|
||||||
|
@@ -63,6 +63,7 @@
|
|||||||
<bool name="config_disable_uninstall_update">true</bool>
|
<bool name="config_disable_uninstall_update">true</bool>
|
||||||
<bool name="config_show_device_name">false</bool>
|
<bool name="config_show_device_name">false</bool>
|
||||||
<bool name="config_use_legacy_suggestion">false</bool>
|
<bool name="config_use_legacy_suggestion">false</bool>
|
||||||
|
<bool name="config_show_avatar_in_homepage">true</bool>
|
||||||
|
|
||||||
<!-- Whether or not extra preview panels should be used for screen zoom setting. -->
|
<!-- Whether or not extra preview panels should be used for screen zoom setting. -->
|
||||||
<bool name="config_enable_extra_screen_zoom_preview">false</bool>
|
<bool name="config_enable_extra_screen_zoom_preview">false</bool>
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accounts;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
@@ -29,7 +30,6 @@ import com.android.settings.homepage.SettingsHomepageActivity;
|
|||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
@@ -69,6 +69,15 @@ public class AvatarViewMixinTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
public void onStart_configDisabled_doNothing() {
|
||||||
|
final AvatarViewMixin mixin = spy(new AvatarViewMixin(mContext, mImageView));
|
||||||
|
mixin.onStart();
|
||||||
|
|
||||||
|
verify(mixin, never()).hasAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(qualifiers = "mcc999")
|
||||||
public void onStart_useMockAvatarViewMixin_shouldBeExecuted() {
|
public void onStart_useMockAvatarViewMixin_shouldBeExecuted() {
|
||||||
final AvatarViewMixin mockAvatar = spy(new AvatarViewMixin(mContext, mImageView));
|
final AvatarViewMixin mockAvatar = spy(new AvatarViewMixin(mContext, mImageView));
|
||||||
|
|
||||||
@@ -79,7 +88,7 @@ public class AvatarViewMixinTest {
|
|||||||
settingsHomepageActivity.getLifecycle().addObserver(mockAvatar);
|
settingsHomepageActivity.getLifecycle().addObserver(mockAvatar);
|
||||||
controller.start();
|
controller.start();
|
||||||
|
|
||||||
verify(mockAvatar).onStart();
|
verify(mockAvatar).hasAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Implements(AccountFeatureProviderImpl.class)
|
@Implements(AccountFeatureProviderImpl.class)
|
||||||
|
Reference in New Issue
Block a user