Fix double divider in Privacy page
The second divider is shown after we set a background to the pinned header. - Simply hide the pinned header instead of its inner views. - Move setActionBarShadowAnimation to controller and just call it when the bar chart is available. Fixes: 134652710 Test: robotest, visual Change-Id: I4381e5ca1a042583d3e5874f5600719267b19786
This commit is contained in:
@@ -123,10 +123,13 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a shadow animation to action bar scroll only when the chart is available.
|
||||||
|
com.android.settings.Utils.setActionBarShadowAnimation(mParent.getActivity(),
|
||||||
|
mParent.getSettingsLifecycle(), mParent.getListView());
|
||||||
// We don't hide chart when we have existing data.
|
// We don't hide chart when we have existing data.
|
||||||
mBarChartPreference.updateLoadingState(mOldUsageInfos.isEmpty() /* isLoading */);
|
mBarChartPreference.updateLoadingState(mOldUsageInfos.isEmpty() /* isLoading */);
|
||||||
// But we still need to hint user with progress bar that we are updating new usage data.
|
// But we still need to hint user with progress bar that we are updating new usage data.
|
||||||
mParent.setLoadingEnabled(true /* enabled */);
|
mParent.showPinnedHeader(true);
|
||||||
retrievePermissionUsageData();
|
retrievePermissionUsageData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +165,7 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBarChartPreference.updateLoadingState(false /* isLoading */);
|
mBarChartPreference.updateLoadingState(false /* isLoading */);
|
||||||
mParent.setLoadingEnabled(false /* enabled */);
|
mParent.showPinnedHeader(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void retrievePermissionUsageData() {
|
private void retrievePermissionUsageData() {
|
||||||
|
@@ -45,11 +45,6 @@ public class PrivacyDashboardFragment extends DashboardFragment {
|
|||||||
private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
|
private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
|
||||||
"privacy_lock_screen_work_profile_notifications";
|
"privacy_lock_screen_work_profile_notifications";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
View mProgressHeader;
|
|
||||||
@VisibleForTesting
|
|
||||||
View mProgressAnimation;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.TOP_LEVEL_PRIVACY;
|
return SettingsEnums.TOP_LEVEL_PRIVACY;
|
||||||
@@ -84,23 +79,13 @@ public class PrivacyDashboardFragment extends DashboardFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(), getListView());
|
|
||||||
initLoadingBar();
|
initLoadingBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void initLoadingBar() {
|
void initLoadingBar() {
|
||||||
mProgressHeader = setPinnedHeaderView(R.layout.progress_header);
|
setPinnedHeaderView(R.layout.progress_header);
|
||||||
mProgressAnimation = mProgressHeader.findViewById(R.id.progress_bar_animation);
|
showPinnedHeader(false);
|
||||||
setLoadingEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
void setLoadingEnabled(boolean enabled) {
|
|
||||||
if (mProgressHeader != null && mProgressAnimation != null) {
|
|
||||||
mProgressHeader.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
|
|
||||||
mProgressAnimation.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
||||||
|
@@ -103,8 +103,7 @@ public class PermissionBarChartPreferenceControllerTest {
|
|||||||
.create().start().get());
|
.create().start().get());
|
||||||
mController.setFragment(mFragment);
|
mController.setFragment(mFragment);
|
||||||
mPreference = spy(new BarChartPreference(context));
|
mPreference = spy(new BarChartPreference(context));
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey()))
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
.thenReturn((BarChartPreference) mPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -189,7 +188,8 @@ public class PermissionBarChartPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onStart();
|
mController.onStart();
|
||||||
|
|
||||||
verify(mFragment).setLoadingEnabled(true /* enabled */);
|
assertThat(mFragment.getActivity().getActionBar().getElevation()).isZero();
|
||||||
|
verify(mFragment).showPinnedHeader(true);
|
||||||
verify(mPreference).updateLoadingState(true /* isLoading */);
|
verify(mPreference).updateLoadingState(true /* isLoading */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,8 @@ public class PermissionBarChartPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onStart();
|
mController.onStart();
|
||||||
|
|
||||||
verify(mFragment).setLoadingEnabled(true /* enabled */);
|
assertThat(mFragment.getActivity().getActionBar().getElevation()).isZero();
|
||||||
|
verify(mFragment).showPinnedHeader(true);
|
||||||
verify(mPreference).updateLoadingState(false /* isLoading */);
|
verify(mPreference).updateLoadingState(false /* isLoading */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +218,8 @@ public class PermissionBarChartPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onStart();
|
mController.onStart();
|
||||||
|
|
||||||
verify(mFragment, never()).setLoadingEnabled(true /* enabled */);
|
assertThat(mFragment.getActivity().getActionBar().getElevation()).isNonZero();
|
||||||
|
verify(mFragment, never()).showPinnedHeader(true);
|
||||||
verify(mPreference, never()).updateLoadingState(true /* isLoading */);
|
verify(mPreference, never()).updateLoadingState(true /* isLoading */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +233,7 @@ public class PermissionBarChartPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.onPermissionUsageResult(infos1);
|
mController.onPermissionUsageResult(infos1);
|
||||||
|
|
||||||
verify(mFragment).setLoadingEnabled(false /* enabled */);
|
verify(mFragment).showPinnedHeader(false);
|
||||||
verify(mPreference).updateLoadingState(false /* isLoading */);
|
verify(mPreference).updateLoadingState(false /* isLoading */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.privacy;
|
package com.android.settings.privacy;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -27,7 +25,6 @@ import android.content.Context;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.permission.PermissionControllerManager;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
@@ -57,8 +54,6 @@ public class PrivacyDashboardFragmentTest {
|
|||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
@Mock
|
|
||||||
private PermissionControllerManager mPCM;
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private PrivacyDashboardFragment mFragment;
|
private PrivacyDashboardFragment mFragment;
|
||||||
@@ -79,33 +74,10 @@ public class PrivacyDashboardFragmentTest {
|
|||||||
.create().start().get());
|
.create().start().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onViewCreated_shouldSetActionBarShadowAnimation() {
|
|
||||||
mFragment.onViewCreated(new View(mContext), new Bundle());
|
|
||||||
|
|
||||||
assertThat(mFragment.getActivity().getActionBar().getElevation()).isEqualTo(0.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onViewCreated_shouldInitLinearProgressBar() {
|
public void onViewCreated_shouldInitLinearProgressBar() {
|
||||||
mFragment.onViewCreated(new View(mContext), new Bundle());
|
mFragment.onViewCreated(new View(mContext), new Bundle());
|
||||||
|
|
||||||
verify(mFragment).initLoadingBar();
|
verify(mFragment).initLoadingBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateLinearProgressbar_isVisible_shouldShowProgressBar() {
|
|
||||||
mFragment.setLoadingEnabled(true /* enabled */);
|
|
||||||
|
|
||||||
assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.VISIBLE);
|
|
||||||
assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateLinearProgressbar_isInVisible_shouldHideProgressBar() {
|
|
||||||
mFragment.setLoadingEnabled(false /* enabled */);
|
|
||||||
|
|
||||||
assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.INVISIBLE);
|
|
||||||
assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user