Merge "Update storage usage progress bar summary text" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8b58ae9d4f
@@ -11814,9 +11814,9 @@
|
||||
<string name="storage_percent_full">used</string>
|
||||
|
||||
<!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
|
||||
<string name="storage_usage_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g></string>
|
||||
<string name="storage_usage_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> used</string>
|
||||
<!-- Summary of a single storage volume total space. [CHAR LIMIT=24] -->
|
||||
<string name="storage_total_summary"><xliff:g id="percentage" example="54%">%1$s</xliff:g> used of <xliff:g id="number" example="128">%2$s</xliff:g> <xliff:g id="unit" example="KB">%3$s</xliff:g></string>
|
||||
<string name="storage_total_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> total</string>
|
||||
|
||||
<!-- Label for button allow user to remove the instant app from the device. -->
|
||||
<string name="clear_instant_app_data">Clear app</string>
|
||||
|
@@ -26,7 +26,6 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.settingslib.widget.UsageProgressBarPreference;
|
||||
@@ -108,23 +107,16 @@ public class StorageUsageProgressBarPreferenceController extends BasePreferenceC
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final Formatter.BytesResult usedResult = getBytesResult(mUsedBytes);
|
||||
mUsageProgressBarPreference.setUsageSummary(
|
||||
mContext.getString(R.string.storage_usage_summary,
|
||||
usedResult.value, usedResult.units));
|
||||
|
||||
final String percentageString = mTotalBytes == 0L
|
||||
? Utils.formatPercentage(0)
|
||||
: Utils.formatPercentage((mUsedBytes * 100) / mTotalBytes, true /* round */);
|
||||
final Formatter.BytesResult totalResult = getBytesResult(mTotalBytes);
|
||||
getStorageSummary(R.string.storage_usage_summary, mUsedBytes));
|
||||
mUsageProgressBarPreference.setTotalSummary(
|
||||
mContext.getString(R.string.storage_total_summary, percentageString,
|
||||
totalResult.value, totalResult.units));
|
||||
|
||||
getStorageSummary(R.string.storage_total_summary, mTotalBytes));
|
||||
mUsageProgressBarPreference.setPercent(mUsedBytes, mTotalBytes);
|
||||
}
|
||||
|
||||
private Formatter.BytesResult getBytesResult(long bytes) {
|
||||
return Formatter.formatBytes(mContext.getResources(), bytes, Formatter.FLAG_SHORTER);
|
||||
private String getStorageSummary(int resId, long bytes) {
|
||||
final Formatter.BytesResult result = Formatter.formatBytes(mContext.getResources(),
|
||||
bytes, Formatter.FLAG_SHORTER);
|
||||
return mContext.getString(resId, result.value, result.units);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user