Always show at least 1% when some space used.
Don't let the progress value round down to 0, since that would be misleading. Test: builds Bug: 24017703 Change-Id: I6a0268361645da16af67e12bf7f6823d027dd72c
This commit is contained in:
@@ -269,7 +269,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
result.value, result.units));
|
result.value, result.units));
|
||||||
mSummary.setSummary(getString(R.string.storage_volume_used,
|
mSummary.setSummary(getString(R.string.storage_volume_used,
|
||||||
Formatter.formatFileSize(context, mTotalSize)));
|
Formatter.formatFileSize(context, mTotalSize)));
|
||||||
mSummary.setPercent((int) ((usedBytes * 100) / mTotalSize));
|
mSummary.setPercent(usedBytes, mTotalSize);
|
||||||
|
|
||||||
mMeasure.forceMeasure();
|
mMeasure.forceMeasure();
|
||||||
mNeedsUpdate = false;
|
mNeedsUpdate = false;
|
||||||
|
@@ -166,7 +166,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
result.value, result.units));
|
result.value, result.units));
|
||||||
mSummary.setSummary(getString(R.string.storage_volume_used,
|
mSummary.setSummary(getString(R.string.storage_volume_used,
|
||||||
Formatter.formatFileSize(context, totalBytes)));
|
Formatter.formatFileSize(context, totalBytes)));
|
||||||
mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
|
mSummary.setPercent(usedBytes, totalBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
|
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
|
||||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.util.MathUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -36,8 +37,9 @@ public class StorageSummaryPreference extends Preference {
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPercent(int percent) {
|
public void setPercent(long usedBytes, long totalBytes) {
|
||||||
mPercent = percent;
|
mPercent = MathUtils.constrain((int) ((usedBytes * 100) / totalBytes),
|
||||||
|
(usedBytes > 0) ? 1 : 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user