Fixes 'learn more' link in ScreenTimeoutSettings
Bug: 227292811 Test: make RunSettingsRoboTests Change-Id: I0e5678e6760ebd590dfd526f362207776ece3a70
This commit is contained in:
@@ -32,14 +32,8 @@ import android.hardware.SensorPrivacyManager;
|
|||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.style.ClickableSpan;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -95,7 +89,7 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
|||||||
RestrictedLockUtils.EnforcedAdmin mAdmin;
|
RestrictedLockUtils.EnforcedAdmin mAdmin;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Preference mDisableOptionsPreference;
|
FooterPreference mDisableOptionsPreference;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
AdaptiveSleepPermissionPreferenceController mAdaptiveSleepPermissionController;
|
AdaptiveSleepPermissionPreferenceController mAdaptiveSleepPermissionController;
|
||||||
@@ -228,26 +222,13 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
|||||||
R.string.admin_disabled_other_options));
|
R.string.admin_disabled_other_options));
|
||||||
final String textMoreDetails = getResources().getString(R.string.admin_more_details);
|
final String textMoreDetails = getResources().getString(R.string.admin_more_details);
|
||||||
|
|
||||||
final SpannableString spannableString = new SpannableString(
|
|
||||||
textDisabledByAdmin + System.lineSeparator()
|
|
||||||
+ System.lineSeparator() + textMoreDetails);
|
|
||||||
final ClickableSpan clickableSpan = new ClickableSpan() {
|
|
||||||
@Override
|
|
||||||
public void onClick(@NonNull View widget) {
|
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (textDisabledByAdmin != null && textMoreDetails != null) {
|
|
||||||
spannableString.setSpan(clickableSpan, textDisabledByAdmin.length() + 1,
|
|
||||||
textDisabledByAdmin.length() + textMoreDetails.length() + 2,
|
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
mDisableOptionsPreference = new FooterPreference(getContext());
|
mDisableOptionsPreference = new FooterPreference(getContext());
|
||||||
mDisableOptionsPreference.setLayoutResource(R.layout.preference_footer);
|
mDisableOptionsPreference.setTitle(textDisabledByAdmin);
|
||||||
mDisableOptionsPreference.setTitle(spannableString);
|
|
||||||
mDisableOptionsPreference.setSelectable(false);
|
mDisableOptionsPreference.setSelectable(false);
|
||||||
|
mDisableOptionsPreference.setLearnMoreText(textMoreDetails);
|
||||||
|
mDisableOptionsPreference.setLearnMoreAction(v -> {
|
||||||
|
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
|
||||||
|
});
|
||||||
mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
|
mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
|
||||||
|
|
||||||
// The 'disabled by admin' preference should always be at the end of the setting page.
|
// The 'disabled by admin' preference should always be at the end of the setting page.
|
||||||
|
@@ -44,12 +44,12 @@ import android.content.res.Resources;
|
|||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -86,7 +86,7 @@ public class ScreenTimeoutSettingsTest {
|
|||||||
AdaptiveSleepBatterySaverPreferenceController mAdaptiveSleepBatterySaverPreferenceController;
|
AdaptiveSleepBatterySaverPreferenceController mAdaptiveSleepBatterySaverPreferenceController;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
Preference mDisableOptionsPreference;
|
FooterPreference mDisableOptionsPreference;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
Reference in New Issue
Block a user