Improve custom views' colors

pull/84/head
Alinson S. Xavier 10 years ago
parent 52c07660b1
commit 11fcb67624

@ -40,7 +40,7 @@
android:backupAgent=".HabitsBackupAgent"
android:icon="@mipmap/ic_launcher"
android:label="@string/main_activity_title"
android:theme="@style/AppBaseThemeDark"
android:theme="@style/AppBaseTheme"
android:supportsRtl="true">
<meta-data

@ -48,7 +48,7 @@ public class ListHabitsHelper
this.context = context;
this.loader = loader;
inactiveColor = UIHelper.getStyledColor(context, R.attr.inactiveCheckmarkColor);
inactiveColor = UIHelper.getStyledColor(context, R.attr.lowContrastTextColor);
fontawesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
}

@ -26,8 +26,10 @@ import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import org.isoron.uhabits.R;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.DateHelper;
import org.isoron.uhabits.helpers.UIHelper;
import org.isoron.uhabits.models.Habit;
import java.text.SimpleDateFormat;
@ -56,7 +58,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
private int nColumns;
private int textColor;
private int dimmedTextColor;
private int gridColor;
private int[] colors;
private int primaryColor;
private boolean isBackgroundTransparent;
@ -111,17 +113,17 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
primaryColor = ColorHelper.setValue(primaryColor, 1.0f);
textColor = Color.argb(192, 255, 255, 255);
dimmedTextColor = Color.argb(128, 255, 255, 255);
gridColor = Color.argb(128, 255, 255, 255);
}
else
{
textColor = Color.argb(64, 0, 0, 0);
dimmedTextColor = Color.argb(16, 0, 0, 0);
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
gridColor = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
}
colors = new int[4];
colors[0] = Color.rgb(230, 230, 230);
colors[0] = gridColor;
colors[3] = primaryColor;
colors[1] = ColorHelper.mixColors(colors[0], colors[3], 0.66f);
colors[2] = ColorHelper.mixColors(colors[0], colors[3], 0.33f);
@ -289,7 +291,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
pText.setTextAlign(Paint.Align.LEFT);
pText.setColor(textColor);
pGrid.setColor(dimmedTextColor);
pGrid.setColor(gridColor);
for (int i = 0; i < nRows; i++)
{

@ -70,6 +70,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
private boolean isBackgroundTransparent;
private int textColor;
private int reverseTextColor;
private boolean isEditable;
public HabitHistoryView(Context context)
@ -92,8 +93,8 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
private void init()
{
createPaints();
createColors();
createPaints();
isEditable = false;
checkmarks = new int[0];
@ -184,10 +185,11 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
else
{
colors = new int[3];
colors[0] = Color.argb(25, 0, 0, 0);
colors[0] = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
colors[1] = Color.argb(127, red, green, blue);
colors[2] = primaryColor;
textColor = Color.argb(64, 0, 0, 0);
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
reverseTextColor = UIHelper.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
}
}
@ -201,7 +203,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
pSquareBg.setColor(primaryColor);
pSquareFg = new Paint();
pSquareFg.setColor(Color.WHITE);
pSquareFg.setColor(reverseTextColor);
pSquareFg.setAntiAlias(true);
pSquareFg.setTextAlign(Align.CENTER);
}

@ -66,7 +66,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
private int nColumns;
private int textColor;
private int dimmedTextColor;
private int gridColor;
@Nullable
private int[] scores;
@ -120,12 +120,12 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
primaryColor = ColorHelper.setValue(primaryColor, 1.0f);
textColor = Color.argb(192, 255, 255, 255);
dimmedTextColor = Color.argb(128, 255, 255, 255);
gridColor = Color.argb(128, 255, 255, 255);
}
else
{
textColor = Color.argb(64, 0, 0, 0);
dimmedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
gridColor = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
}
}
@ -175,7 +175,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
pGraph.setTextSize(baseSize * 0.5f);
pGraph.setStrokeWidth(baseSize * 0.1f);
pGrid.setStrokeWidth(baseSize * 0.05f);
pGrid.setStrokeWidth(baseSize * 0.025f);
}
public void refreshData()
@ -325,7 +325,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
pText.setTextAlign(Paint.Align.LEFT);
pText.setColor(textColor);
pGrid.setColor(dimmedTextColor);
pGrid.setColor(gridColor);
for (int i = 0; i < nRows; i++)
{

@ -54,7 +54,6 @@ public class HabitStreakView extends View implements HabitDataView
private List<Streak> streaks;
private boolean isBackgroundTransparent;
private int textColor;
private DateFormat dateFormat;
private int width;
private float em;
@ -62,6 +61,8 @@ public class HabitStreakView extends View implements HabitDataView
private float textMargin;
private boolean shouldShowLabels;
private int maxStreakCount;
private int textColor;
private int reverseTextColor;
public HabitStreakView(Context context)
{
@ -150,8 +151,9 @@ public class HabitStreakView extends View implements HabitDataView
colors[3] = primaryColor;
colors[2] = Color.argb(192, red, green, blue);
colors[1] = Color.argb(96, red, green, blue);
colors[0] = Color.argb(32, 0, 0, 0);
textColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
colors[0] = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
reverseTextColor = UIHelper.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
}
}
@ -217,7 +219,7 @@ public class HabitStreakView extends View implements HabitDataView
if(shouldShowLabels) availableWidth -= 2 * textMargin;
float barWidth = percentage * availableWidth;
float minBarWidth = paint.measureText(streak.length.toString());
float minBarWidth = paint.measureText(streak.length.toString()) + em;
barWidth = Math.max(barWidth, minBarWidth);
float gap = (width - barWidth) / 2;
@ -230,7 +232,7 @@ public class HabitStreakView extends View implements HabitDataView
float yOffset = rect.centerY() + 0.3f * em;
paint.setColor(Color.WHITE);
paint.setColor(reverseTextColor);
paint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(streak.length.toString(), rect.centerX(), yOffset, paint);

@ -49,7 +49,7 @@ public class RingView extends View
private float maxDiameter;
private float textSize;
private int fadedTextColor;
private int textColor;
private int backgroundColor;
public RingView(Context context)
@ -98,7 +98,7 @@ public class RingView extends View
pRing.setTextAlign(Paint.Align.CENTER);
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
fadedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
textSize = getResources().getDimension(R.dimen.smallTextSize);
rect = new RectF();
@ -137,7 +137,7 @@ public class RingView extends View
rect.offset((width - diameter) / 2, 0);
canvas.drawArc(rect, -90, 360 * percentage, true, pRing);
int grey = UIHelper.getStyledColor(getContext(), R.attr.inactiveCheckmarkColor);
int grey = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
pRing.setColor(grey);
canvas.drawArc(rect, 360 * percentage - 90 + 2, 360 * (1 - percentage) - 4, true, pRing);
@ -145,7 +145,7 @@ public class RingView extends View
rect.inset(thickness, thickness);
canvas.drawArc(rect, -90, 360, true, pRing);
pRing.setColor(fadedTextColor);
pRing.setColor(textColor);
pRing.setTextSize(textSize);
float lineHeight = pRing.getFontSpacing();
canvas.drawText(String.format("%.0f%%", percentage * 100), rect.centerX(),

@ -25,7 +25,7 @@
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@color/transparent"
android:textColor="?fadedTextColor"
android:textColor="?mediumContrastTextColor"
android:textAllCaps="true"
android:textStyle="bold"
android:textSize="10sp"/>

@ -29,17 +29,22 @@
<item name="android:colorPrimary">@color/blue_grey_800</item>
<item name="android:colorPrimaryDark">@color/blue_grey_900</item>
<item name="cardBackgroundColor">@color/white</item>
<item name="cardBackgroundColor">@color/grey_50</item>
<item name="windowBackgroundColor">@color/grey_200</item>
<item name="headerBackgroundColor">@color/grey_200</item>
<item name="highlightedBackgroundColor">@color/grey_100</item>
<item name="android:textColor">#606060</item>
<item name="fadedTextColor">@color/grey_600</item>
<item name="inactiveCheckmarkColor">@color/grey_300</item>
<item name="secondaryTextColor">@color/grey_800</item>
<item name="android:textColor">@color/grey_800</item>
<item name="useHabitColorAsPrimary">true</item>
<item name="palette">@array/lightPalette</item>
<item name="highContrastReverseTextColor">@color/white</item>
<item name="mediumContrastReverseTextColor">@color/grey_500</item>
<item name="lowContrastReverseTextColor">@color/grey_700</item>
<item name="highContrastTextColor">@color/grey_800</item>
<item name="mediumContrastTextColor">@color/grey_500</item>
<item name="lowContrastTextColor">@color/grey_300</item>
</style>
<style name="AppBaseThemeDark" parent="android:Theme.Material">
@ -51,20 +56,37 @@
<item name="android:colorPrimary">@color/grey_950</item>
<item name="android:colorPrimaryDark">@color/black</item>
<item name="cardBackgroundColor">@color/grey_800</item>
<item name="windowBackgroundColor">@color/grey_850</item>
<item name="cardBackgroundColor">@color/grey_850</item>
<item name="windowBackgroundColor">@color/grey_900</item>
<item name="headerBackgroundColor">@color/grey_900</item>
<item name="highlightedBackgroundColor">@color/grey_800</item>
<item name="android:textColor">@color/grey_50</item>
<item name="fadedTextColor">@color/grey_500</item>
<item name="inactiveCheckmarkColor">@color/grey_700</item>
<item name="secondaryTextColor">@color/grey_100</item>
<item name="android:textColor">@color/grey_100</item>
<item name="useHabitColorAsPrimary">false</item>
<item name="highContrastTextColor">@color/grey_100</item>
<item name="mediumContrastTextColor">@color/grey_500</item>
<item name="lowContrastTextColor">@color/grey_800</item>
<item name="highContrastReverseTextColor">@color/grey_900</item>
<item name="mediumContrastReverseTextColor">@color/grey_700</item>
<item name="lowContrastReverseTextColor">@color/grey_300</item>
<item name="palette">@array/darkPalette</item>
</style>
<style name="AppBaseThemeDark.PureBlack">
<item name="android:colorPrimary">@color/black</item>
<item name="android:colorPrimaryDark">@color/black</item>
<item name="cardBackgroundColor">@color/black</item>
<item name="windowBackgroundColor">@color/black</item>
<item name="headerBackgroundColor">@color/black</item>
<item name="highlightedBackgroundColor">@color/black</item>
<item name="lowContrastTextColor">@color/grey_900</item>
<item name="highContrastReverseTextColor">@color/black</item>
</style>
<style name="MyDialogStyle" parent="android:Theme.Material.Light.Dialog">
<item name="android:spinnerItemStyle">@style/dialogFormText</item>
<item name="android:spinnerDropDownItemStyle">@style/dialogFormSpinnerDropDown</item>

@ -21,11 +21,16 @@
<resources>
<attr name="windowBackgroundColor" format="reference"/>
<attr name="cardBackgroundColor" format="reference"/>
<attr name="fadedTextColor" format="reference"/>
<attr name="headerBackgroundColor" format="reference"/>
<attr name="secondaryTextColor" format="reference"/>
<attr name="inactiveCheckmarkColor" format="reference"/>
<attr name="highlightedBackgroundColor" format="reference"/>
<attr name="useHabitColorAsPrimary" format="boolean"/>
<attr name="palette" format="reference"/>
<attr name="highContrastTextColor" format="reference"/>
<attr name="mediumContrastTextColor" format="reference"/>
<attr name="lowContrastTextColor" format="reference"/>
<attr name="highContrastReverseTextColor" format="reference"/>
<attr name="mediumContrastReverseTextColor" format="reference"/>
<attr name="lowContrastReverseTextColor" format="reference"/>
</resources>

@ -28,7 +28,7 @@
<item>@color/deep_purple_600</item>
<item>@color/purple_600</item>
<item>@color/pink_600</item>
<item>@color/grey_850</item>
<item>@color/grey_800</item>
<item>@color/grey_500</item>
</array>
@ -44,8 +44,8 @@
<item>@color/deep_purple_200</item>
<item>@color/purple_200</item>
<item>@color/pink_200</item>
<item>@color/grey_200</item>
<item>@color/grey_700</item>
<item>@color/grey_100</item>
<item>@color/grey_500</item>
</array>
<!-- Time and Date picker -->
@ -346,6 +346,7 @@
<color name="grey_500">#9E9E9E</color>
<color name="grey_600">#757575</color>
<color name="grey_700">#616161</color>
<color name="grey_750">#525252</color>
<color name="grey_800">#424242</color>
<color name="grey_850">#303030</color>
<color name="grey_875">#282828</color>

@ -102,7 +102,7 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:textColor">?fadedTextColor</item>
<item name="android:textColor">?mediumContrastTextColor</item>
</style>
</resources>

@ -45,19 +45,19 @@
<style name="dialogFormText">
<item name="android:textSize">@dimen/regularTextSize</item>
<item name="android:textColor">?secondaryTextColor</item>
<item name="android:textColor">?highContrastTextColor</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="dialogFormSmallText">
<item name="android:textSize">@dimen/smallTextSize</item>
<item name="android:textColor">?fadedTextColor</item>
<item name="android:textColor">?mediumContrastTextColor</item>
</style>
<style name="dialogFormSpinnerDropDown" parent="dialogFormText">
<item name="android:padding">12dp</item>
<item name="android:textColor">?secondaryTextColor</item>
<item name="android:textColor">?highContrastTextColor</item>
</style>
<style name="dialogFormInput" parent="dialogFormText">
@ -74,7 +74,7 @@
<item name="android:minWidth">100dp</item>
<item name="android:gravity">left</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:textColor">?fadedTextColor</item>
<item name="android:textColor">?mediumContrastTextColor</item>
</style>
<style name="dialogFormSpinner" parent="android:Widget.DeviceDefault.Light.Spinner">
@ -83,7 +83,7 @@
<item name="android:paddingLeft">12dp</item>
<item name="android:textSize">@dimen/regularTextSize</item>
<item name="android:minWidth">400dp</item>
<item name="android:textColor">?secondaryTextColor</item>
<item name="android:textColor">?highContrastTextColor</item>
</style>
<style name="dialogFormRow">

Loading…
Cancel
Save