Skip to content

Commit

Permalink
widget themes
Browse files Browse the repository at this point in the history
moon phase text colors; fixes readability of moon phase text in widgets (#744)
  • Loading branch information
forrestguice committed Dec 8, 2023
1 parent 1acde3b commit aec233e
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MAP_HIGHLIGHTCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MAP_SHADOWCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULLCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULLCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULL_STROKE_WIDTH;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEWCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEWCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEW_STROKE_WIDTH;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONRISECOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONSETCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWANINGCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWANINGCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWAXINGCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWAXINGCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOON_STROKE_DEF;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOON_STROKE_MAX;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOON_STROKE_MIN;
Expand Down Expand Up @@ -179,6 +183,11 @@ public class SuntimesTheme
protected int themeMoonWaxingColor;
protected int themeMoonFullColor;

protected int themeMoonWaningTextColor;
protected int themeMoonNewTextColor;
protected int themeMoonWaxingTextColor;
protected int themeMoonFullTextColor;

protected int themeMoonFullStroke;
protected int themeMoonFullStrokePixels = -1;

Expand Down Expand Up @@ -238,6 +247,11 @@ public SuntimesTheme(SuntimesTheme otherTheme)
this.themeMoonWaxingColor = otherTheme.themeMoonWaxingColor;
this.themeMoonFullColor = otherTheme.themeMoonFullColor;

this.themeMoonWaningTextColor = otherTheme.themeMoonWaningTextColor;
this.themeMoonNewTextColor = otherTheme.themeMoonNewTextColor;
this.themeMoonWaxingTextColor = otherTheme.themeMoonWaxingTextColor;
this.themeMoonFullTextColor = otherTheme.themeMoonFullTextColor;

this.themeMoonFullStroke = otherTheme.themeMoonFullStroke;
this.themeMoonNewStroke = otherTheme.themeMoonNewStroke;

Expand Down Expand Up @@ -335,6 +349,11 @@ public boolean initTheme( Context context, String themesPrefix, String themeName
this.themeMoonWaxingColor = themes.getInt( theme + THEME_MOONWAXINGCOLOR, defaultTheme.themeMoonWaxingColor );
this.themeMoonFullColor = themes.getInt( theme + THEME_MOONFULLCOLOR, defaultTheme.themeMoonFullColor );

this.themeMoonWaningTextColor = themes.getInt( theme + THEME_MOONWANINGCOLOR_TEXT, defaultTheme.themeMoonWaningTextColor );
this.themeMoonNewTextColor = themes.getInt( theme + THEME_MOONNEWCOLOR_TEXT, defaultTheme.themeMoonNewTextColor );
this.themeMoonWaxingTextColor = themes.getInt( theme + THEME_MOONWAXINGCOLOR_TEXT, defaultTheme.themeMoonWaxingTextColor );
this.themeMoonFullTextColor = themes.getInt( theme + THEME_MOONFULLCOLOR_TEXT, defaultTheme.themeMoonFullTextColor );

this.themeMoonFullStroke = themes.getInt( theme + THEME_MOONFULL_STROKE_WIDTH, defaultTheme.themeMoonFullStroke );
this.themeMoonNewStroke = themes.getInt( theme + THEME_MOONNEW_STROKE_WIDTH, defaultTheme.themeMoonNewStroke );

Expand Down Expand Up @@ -421,6 +440,11 @@ public ThemeDescriptor saveTheme(SharedPreferences themes)
themePrefs.putInt(themePrefix + THEME_MOONWAXINGCOLOR, this.themeMoonWaxingColor);
themePrefs.putInt(themePrefix + THEME_MOONFULLCOLOR, this.themeMoonFullColor);

themePrefs.putInt(themePrefix + THEME_MOONWANINGCOLOR_TEXT, this.themeMoonWaningTextColor);
themePrefs.putInt(themePrefix + THEME_MOONNEWCOLOR_TEXT, this.themeMoonNewTextColor);
themePrefs.putInt(themePrefix + THEME_MOONWAXINGCOLOR_TEXT, this.themeMoonWaxingTextColor);
themePrefs.putInt(themePrefix + THEME_MOONFULLCOLOR_TEXT, this.themeMoonFullTextColor);

themePrefs.putInt(themePrefix + THEME_MOONFULL_STROKE_WIDTH, this.themeMoonFullStroke);
themePrefs.putInt(themePrefix + THEME_MOONNEW_STROKE_WIDTH, this.themeMoonNewStroke);

Expand Down Expand Up @@ -507,6 +531,11 @@ public ContentValues toContentValues()
values.put(THEME_MOONWAXINGCOLOR, this.themeMoonWaxingColor);
values.put(THEME_MOONFULLCOLOR, this.themeMoonFullColor);

values.put(THEME_MOONWANINGCOLOR_TEXT, this.themeMoonWaningTextColor);
values.put(THEME_MOONNEWCOLOR_TEXT, this.themeMoonNewTextColor);
values.put(THEME_MOONWAXINGCOLOR_TEXT, this.themeMoonWaxingTextColor);
values.put(THEME_MOONFULLCOLOR_TEXT, this.themeMoonFullTextColor);

values.put(THEME_MOONFULL_STROKE_WIDTH, this.themeMoonFullStroke);
values.put(THEME_MOONNEW_STROKE_WIDTH, this.themeMoonNewStroke);

Expand Down Expand Up @@ -743,21 +772,33 @@ public int getMoonWaningColor()
{
return themeMoonWaningColor;
}
public int getMoonWaningTextColor() {
return themeMoonWaningTextColor;
}

public int getMoonNewColor()
{
return themeMoonNewColor;
}
public int getMoonNewTextColor() {
return themeMoonNewTextColor;
}

public int getMoonWaxingColor()
{
return themeMoonWaxingColor;
}
public int getMoonWaxingTextColor() {
return themeMoonWaxingTextColor;
}

public int getMoonFullColor()
{
return themeMoonFullColor;
}
public int getMoonFullTextColor() {
return themeMoonFullTextColor;
}

public int getMoonriseTextColor()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public interface SuntimesThemeContract
String THEME_MOONNEWCOLOR = "moonnewcolor"; // int (color)
String THEME_MOONFULLCOLOR = "moonfullcolor"; // int (color)

String THEME_MOONWANINGCOLOR_TEXT = "moonwaningtextcolor"; // int (color)
String THEME_MOONWAXINGCOLOR_TEXT = "moonwaxingtextcolor"; // int (color)
String THEME_MOONNEWCOLOR_TEXT = "moonnewtextcolor"; // int (color)
String THEME_MOONFULLCOLOR_TEXT = "moonfulltextcolor"; // int (color)

String THEME_MOONFULL_STROKE_WIDTH = "moonfull_strokewidth";
String THEME_MOONNEW_STROKE_WIDTH = "moonnew_strokewidth";
float THEME_MOON_STROKE_MIN = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,22 @@ public boolean write(Context context, OutputStream out, SuntimesTheme[] themes)
xml.text(colorToString(theme.getMoonNewColor()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONNEWCOLOR);

xml.startTag(namespace, SuntimesThemeContract.THEME_MOONWANINGCOLOR_TEXT);
xml.text(colorToString(theme.getMoonWaningTextColor()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONWANINGCOLOR_TEXT);

xml.startTag(namespace, SuntimesThemeContract.THEME_MOONWAXINGCOLOR_TEXT);
xml.text(colorToString(theme.getMoonWaxingTextColor()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONWAXINGCOLOR_TEXT);

xml.startTag(namespace, SuntimesThemeContract.THEME_MOONFULLCOLOR_TEXT);
xml.text(colorToString(theme.getMoonFullTextColor()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONFULLCOLOR_TEXT);

xml.startTag(namespace, SuntimesThemeContract.THEME_MOONNEWCOLOR_TEXT);
xml.text(colorToString(theme.getMoonNewTextColor()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONNEWCOLOR_TEXT);

xml.startTag(namespace, SuntimesThemeContract.THEME_MOONFULL_STROKE_WIDTH);
xml.text(Integer.toString(theme.getMoonFullStroke()));
xml.endTag(namespace, SuntimesThemeContract.THEME_MOONFULL_STROKE_WIDTH);
Expand Down Expand Up @@ -602,6 +618,15 @@ private SuntimesTheme readTheme(XmlPullParser parser) throws XmlPullParserExcept
} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONNEWCOLOR)) {
theme.themeMoonNewColor = colorStringToInt(value);

} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONWANINGCOLOR_TEXT)) {
theme.themeMoonWaningTextColor = colorStringToInt(value);
} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONWAXINGCOLOR_TEXT)) {
theme.themeMoonWaxingTextColor = colorStringToInt(value);
} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONFULLCOLOR_TEXT)) {
theme.themeMoonFullTextColor = colorStringToInt(value);
} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONNEWCOLOR_TEXT)) {
theme.themeMoonNewTextColor = colorStringToInt(value);

} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONFULL_STROKE_WIDTH)) {
theme.themeMoonFullStroke = Integer.parseInt(value);
} else if (tag.equalsIgnoreCase(SuntimesThemeContract.THEME_MOONNEW_STROKE_WIDTH)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,17 @@
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MAP_HIGHLIGHTCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MAP_SHADOWCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULLCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULLCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONFULL_STROKE_WIDTH;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEWCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEWCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONNEW_STROKE_WIDTH;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONRISECOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONSETCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWANINGCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWANINGCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWAXINGCOLOR;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOONWAXINGCOLOR_TEXT;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOON_STROKE_MAX;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_MOON_STROKE_MIN;
import static com.forrestguice.suntimeswidget.themes.SuntimesThemeContract.THEME_NAME;
Expand Down Expand Up @@ -206,6 +210,7 @@ public UIMode getMode()
private ColorChooser chooseColorSpring, chooseColorSummer, chooseColorFall, chooseColorWinter;
private ColorChooser chooseColorMoonrise, chooseColorMoonset;
private ColorChooser chooseColorMoonWaning, chooseColorMoonNew, chooseColorMoonWaxing, chooseColorMoonFull;
private ColorChooser chooseColorMoonNewText, chooseColorMoonFullText;
private ColorChooser chooseColorMapBackground, chooseColorMapForeground, chooseColorMapShadow, chooseColorMapHighlight;
private ArrayList<ColorChooser> colorChoosers;
private CheckBox checkUseFill, checkUseStroke, checkUseNoon;
Expand Down Expand Up @@ -412,6 +417,11 @@ protected void onPaddingChanged( int[] newPadding )
chooseColorMoonWaxing = createColorChooser(this, R.id.chooser_moonWaxingColor, THEME_MOONWAXINGCOLOR);
chooseColorMoonFull = createColorChooser(this, R.id.chooser_moonFullColor, THEME_MOONFULLCOLOR);

//chooseColorMoonWaningText = createColorChooser(this, R.id.chooser_moonWaningColor_text, THEME_MOONWANINGCOLOR_TEXT);
chooseColorMoonNewText = createColorChooser(this, R.id.chooser_moonNewColor_text, THEME_MOONNEWCOLOR_TEXT);
//chooseColorMoonWaxingText = createColorChooser(this, R.id.chooser_moonWaxingColor_text, THEME_MOONWAXINGCOLOR_TEXT);
chooseColorMoonFullText = createColorChooser(this, R.id.chooser_moonFullColor_text, THEME_MOONFULLCOLOR_TEXT);

// other colors
chooseColorTitle = createColorChooser(this, R.id.chooser_titleColor, THEME_TITLECOLOR);
chooseColorText = createColorChooser(this, R.id.chooser_textColor, THEME_TEXTCOLOR);
Expand Down Expand Up @@ -1513,6 +1523,9 @@ protected void loadTheme( String themeName )
chooseColorMoonWaxing.setColor(theme.getMoonWaxingColor());
chooseColorMoonFull.setColor(theme.getMoonFullColor());

chooseColorMoonNewText.setColor(theme.getMoonNewTextColor());
chooseColorMoonFullText.setColor(theme.getMoonFullTextColor());

chooseMoonStroke.setValue(theme.getMoonFullStroke());

choosePadding.setPadding(theme.getPadding());
Expand Down Expand Up @@ -1611,6 +1624,11 @@ private SuntimesTheme init()
this.themeMoonWaxingColor = chooseColorMoonWaxing.getColor();
this.themeMoonFullColor = chooseColorMoonFull.getColor();

this.themeMoonWaningTextColor = chooseColorMoonWaning.getColor();
this.themeMoonNewTextColor = chooseColorMoonNewText.getColor();
this.themeMoonWaxingTextColor = chooseColorMoonWaxing.getColor();
this.themeMoonFullTextColor = chooseColorMoonFullText.getColor();

this.themeMoonFullStroke = (int)chooseMoonStroke.getValue();
this.themeMoonNewStroke = (int)chooseMoonStroke.getValue();

Expand Down Expand Up @@ -1686,6 +1704,11 @@ protected ContentValues toContentValues()
values.put(THEME_MOONWAXINGCOLOR, chooseColorMoonWaxing.getColor());
values.put(THEME_MOONFULLCOLOR, chooseColorMoonFull.getColor());

values.put(THEME_MOONWANINGCOLOR_TEXT, chooseColorMoonWaning.getColor());
values.put(THEME_MOONNEWCOLOR_TEXT, chooseColorMoonNewText.getColor());
values.put(THEME_MOONWAXINGCOLOR_TEXT, chooseColorMoonWaxing.getColor());
values.put(THEME_MOONFULLCOLOR_TEXT, chooseColorMoonFullText.getColor());

values.put(THEME_MOONFULL_STROKE_WIDTH, (int)chooseMoonStroke.getValue());
values.put(THEME_MOONNEW_STROKE_WIDTH, (int)chooseMoonStroke.getValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public DarkTheme(Context context)
this.themeMoonWaxingColor = ContextCompat.getColor(context, THEMEDEF_MOONWAXINGCOLOR_ID);
this.themeMoonFullColor = ContextCompat.getColor(context, THEMEDEF_MOONFULLCOLOR_ID);

this.themeMoonWaningTextColor = ContextCompat.getColor(context, THEMEDEF_MOONWANINGCOLOR_ID);
this.themeMoonNewTextColor = ContextCompat.getColor(context, R.color.moonIcon_color_new_text_dark);
this.themeMoonWaxingTextColor = ContextCompat.getColor(context, THEMEDEF_MOONWAXINGCOLOR_ID);
this.themeMoonFullTextColor = ContextCompat.getColor(context, R.color.moonIcon_color_full_text_dark);

this.themeMoonFullStroke = THEMEDEF_MOONFULL_STROKEWIDTH;
this.themeMoonNewStroke = THEMEDEF_MOONNEW_STROKEWIDTH;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public LightTheme(Context context)
this.themeMoonWaxingColor = ContextCompat.getColor(context, THEMEDEF_MOONWAXINGCOLOR_ID);
this.themeMoonFullColor = ContextCompat.getColor(context, THEMEDEF_MOONFULLCOLOR_ID);

this.themeMoonWaningTextColor = ContextCompat.getColor(context, THEMEDEF_MOONWANINGCOLOR_ID);
this.themeMoonNewTextColor = ContextCompat.getColor(context, R.color.moonIcon_color_new_text_light);
this.themeMoonWaxingTextColor = ContextCompat.getColor(context, THEMEDEF_MOONWAXINGCOLOR_ID);
this.themeMoonFullTextColor = ContextCompat.getColor(context, R.color.moonIcon_color_full_text_light);

this.themeMoonFullStroke = THEMEDEF_MOONFULL_STROKEWIDTH;
this.themeMoonNewStroke = THEMEDEF_MOONNEW_STROKEWIDTH;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,23 @@ public void themeViews(Context context, RemoteViews views, SuntimesTheme theme)
suffixSizeSp = theme.getTimeSuffixSizeSp();
}

protected HashMap<MoonPhaseDisplay, Integer> phaseColors = new HashMap<>();
protected HashMap<MoonPhaseDisplay, Integer> phaseTextColors = new HashMap<>();

protected void themeViewsMoonPhase(Context context, RemoteViews views, SuntimesTheme theme)
{
int waningColor = theme.getMoonWaningColor();
int waxingColor = theme.getMoonWaxingColor();
int waningTextColor = theme.getMoonWaningTextColor();
int waxingTextColor = theme.getMoonWaxingTextColor();

phaseColors.put(MoonPhaseDisplay.FIRST_QUARTER, waxingColor);
phaseColors.put(MoonPhaseDisplay.WAXING_CRESCENT, waxingColor);
phaseColors.put(MoonPhaseDisplay.WAXING_GIBBOUS, waxingColor);
phaseTextColors.put(MoonPhaseDisplay.FIRST_QUARTER, waxingTextColor);
phaseTextColors.put(MoonPhaseDisplay.WAXING_CRESCENT, waxingTextColor);
phaseTextColors.put(MoonPhaseDisplay.WAXING_GIBBOUS, waxingTextColor);

phaseColors.put(MoonPhaseDisplay.NEW, theme.getMoonNewColor());
phaseColors.put(MoonPhaseDisplay.FULL, theme.getMoonFullColor());
phaseTextColors.put(MoonPhaseDisplay.NEW, theme.getMoonNewTextColor());
phaseTextColors.put(MoonPhaseDisplay.FULL, theme.getMoonFullTextColor());

phaseColors.put(MoonPhaseDisplay.THIRD_QUARTER, waningColor);
phaseColors.put(MoonPhaseDisplay.WANING_CRESCENT, waningColor);
phaseColors.put(MoonPhaseDisplay.WANING_GIBBOUS, waningColor);
phaseTextColors.put(MoonPhaseDisplay.THIRD_QUARTER, waningTextColor);
phaseTextColors.put(MoonPhaseDisplay.WANING_CRESCENT, waningTextColor);
phaseTextColors.put(MoonPhaseDisplay.WANING_GIBBOUS, waningTextColor);
}

protected void themeViewsMoonPhaseIcons(Context context, RemoteViews views, SuntimesTheme theme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void updateViews(Context context, int appWidgetId, RemoteViews views, Sun
views.setViewVisibility(R.id.text_info_moonphase, (showLabels ? View.VISIBLE : View.GONE));
views.setViewVisibility(phase.getView(), View.VISIBLE);

Integer phaseColor = phaseColors.get(phase);
Integer phaseColor = phaseTextColors.get(phase);
if (phaseColor != null) {
views.setTextColor(R.id.text_info_moonphase, phaseColor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void updateViews(Context context, int appWidgetId, RemoteViews views, Sun
views.setViewVisibility(R.id.text_info_moonphase, (showLabels ? View.VISIBLE : View.GONE));
views.setViewVisibility(phase.getView(), View.VISIBLE);

Integer phaseColor = phaseColors.get(phase);
Integer phaseColor = phaseTextColors.get(phase);
if (phaseColor != null)
{
views.setTextColor(R.id.text_info_moonphase, phaseColor);
Expand Down
Loading

0 comments on commit aec233e

Please sign in to comment.