Add ASM enabled/disabled text to the Storage settings.
Bug: 33199077 Test: Settings Robo Tests Change-Id: I86897c63b584d3c8be171723367a6b4e060684f3
This commit is contained in:
@@ -18,17 +18,27 @@ package com.android.settings.deviceinfo.storage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.MathUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.DonutView;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* StorageSummaryDonutPreference is a preference which summarizes the used and remaining storage left
|
||||
* on a given storage volume. It is visualized with a donut graphing the % used.
|
||||
@@ -68,6 +78,23 @@ public class StorageSummaryDonutPreference extends Preference implements View.On
|
||||
if (deletionHelperButton != null) {
|
||||
deletionHelperButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
final TextView storageManagerText =
|
||||
(TextView) view.findViewById(R.id.storage_manager_indicator);
|
||||
if (storageManagerText != null) {
|
||||
Context context = getContext();
|
||||
final SpannableString templateSs = new SpannableString(
|
||||
context.getString(R.string.storage_manager_indicator));
|
||||
boolean isStorageManagerEnabled = Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
|
||||
String value = isStorageManagerEnabled ?
|
||||
context.getString(R.string.storage_manager_indicator_on) :
|
||||
context.getString(R.string.storage_manager_indicator_off);
|
||||
Locale locale = storageManagerText.getTextLocale();
|
||||
final SpannableString ss = new SpannableString(value.toUpperCase(locale));
|
||||
ss.setSpan(new BoldLinkSpan(), 0, value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
storageManagerText.setText(TextUtils.expandTemplate(templateSs, ss));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,4 +104,16 @@ public class StorageSummaryDonutPreference extends Preference implements View.On
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private static class BoldLinkSpan extends StyleSpan {
|
||||
public BoldLinkSpan() {
|
||||
super(Typeface.BOLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ds.linkColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user