Fix UI janky in privacy settings

Set a summary holder for initial preference at the biginning.
If there is no any permission granted, then set a string for it.

Test: Rebuild, visual
Fixes: 140783222
Change-Id: Ic5f2730123110bad5fbc08fcd22b1df564b8637d
This commit is contained in:
Tsung-Mao Fang
2019-10-28 16:37:22 +08:00
parent ac9fd3d474
commit 327dba2488
3 changed files with 7 additions and 3 deletions

View File

@@ -50,6 +50,7 @@
<Preference
android:key="privacy_manage_perms"
android:title="@string/app_permissions"
android:summary="@string/summary_placeholder"
settings:allowDividerAbove="true"
settings:keywords="@string/keywords_app_permissions"
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">

View File

@@ -105,7 +105,7 @@ public class AppPermissionsPreferenceController extends BasePreferenceController
final CharSequence summary = !permissionsToShow.isEmpty()
? mContext.getString(R.string.app_permissions_summary,
ListFormatter.getInstance().format(permissionsToShow).toLowerCase())
: null;
: mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted);
mPreference.setSummary(summary);
}
}

View File

@@ -31,6 +31,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
import androidx.preference.Preference;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,14 +72,15 @@ public class AppPermissionsPreferenceControllerTest {
}
@Test
public void updateSummary_noGrantedPermission_shouldSetNullSummary() {
public void updateSummary_noGrantedPermission_shouldSetNoPermissionGrantedSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
mController.mNumPackageChecked = 2;
mController.updateSummary(new ArrayList<>());
assertThat(mPreference.getSummary()).isNull();
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted));
}
@Test