bug:3321005 make Settings --> Storage screen display little less ugly

I have implemented most of what the UX designer proposed. except these
1. Percentage Bar chart left padding should be 16dip
2. Percentage Bar chart and Total Space preferences should be combined into
   one singne ViewGroup or something. and "total Space" shoudl be aligned
   on the right border

Change-Id: I9b238eaa561c9837b47b9955e7d718d92543ca34
This commit is contained in:
Vasu Nori
2011-03-02 11:07:35 -08:00
parent 6291d50b5d
commit 340e85d1d0
6 changed files with 30 additions and 37 deletions

View File

@@ -33,7 +33,7 @@ import android.content.DialogInterface.OnCancelListener;
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -177,27 +177,16 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
mInternalAppsColor = mRes.getColor(R.color.memory_apps_usage);
mInternalUsedColor = android.graphics.Color.GRAY;
mInternalAvailColor = mRes.getColor(R.color.memory_avail);
final int buttonSize = (int) mRes.getDimension(R.dimen.device_memory_usage_button_size);
float[] radius = new float[] {
5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f
};
RoundRectShape shape1 = new RoundRectShape(radius, null, null);
final int buttonWidth = (int) mRes.getDimension(R.dimen.device_memory_usage_button_width);
final int buttonHeight = (int) mRes.getDimension(R.dimen.device_memory_usage_button_height);
// total available space
mInternalAvail = findPreference(MEMORY_INTERNAL_AVAIL);
ShapeDrawable availShape = new ShapeDrawable(shape1);
availShape.setIntrinsicWidth(buttonSize);
availShape.setIntrinsicHeight(buttonSize);
availShape.getPaint().setColor(mInternalAvailColor);
mInternalAvail.setIcon(availShape);
mInternalAvail.setIcon(createRectShape(buttonHeight, buttonWidth, mInternalAvailColor));
// used by apps
mInternalAppsUsage = findPreference(MEMORY_INTERNAL_APPS);
ShapeDrawable appsShape = new ShapeDrawable(shape1);
appsShape.setIntrinsicWidth(buttonSize);
appsShape.setIntrinsicHeight(buttonSize);
appsShape.getPaint().setColor(mInternalAppsColor);
mInternalAppsUsage.setIcon(appsShape);
mInternalAppsUsage.setIcon(createRectShape(buttonHeight, buttonWidth, mInternalAppsColor));
// space used by individual major directories on /sdcard
for (int i = 0; i < Constants.NUM_MEDIA_DIRS_TRACKED; i++) {
@@ -206,9 +195,6 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
continue;
}
mMediaPreferences[i] = findPreference(Constants.mMediaDirs.get(i).mPreferenceName);
ShapeDrawable shape = new ShapeDrawable(shape1);
shape.setIntrinsicWidth(buttonSize);
shape.setIntrinsicHeight(buttonSize);
int color = 0;
switch (i) {
case Constants.DOWNLOADS_INDEX:
@@ -224,8 +210,7 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
color = mRes.getColor(R.color.memory_misc);
break;
}
shape.getPaint().setColor(color);
mMediaPreferences[i].setIcon(shape);
mMediaPreferences[i].setIcon(createRectShape(buttonHeight, buttonWidth, color));
}
mInternalUsageChart = (UsageBarPreference) findPreference(MEMORY_INTERNAL_CHART);
@@ -233,6 +218,14 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
mMeasurement.setReceiver(this);
}
private ShapeDrawable createRectShape(int height, int width, int color) {
ShapeDrawable shape = new ShapeDrawable(new RectShape());
shape.setIntrinsicHeight(height);
shape.setIntrinsicWidth(width);
shape.getPaint().setColor(color);
return shape;
}
@Override
public void onResume() {
super.onResume();