Skip to content

Commit

Permalink
show date
Browse files Browse the repository at this point in the history
adds "show phase date" option to moon dialog (#846)
  • Loading branch information
forrestguice committed Nov 19, 2024
1 parent b8140f9 commit 2a71aec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ public void centerDialog()
//moonapsis.scrollToCenter();
}

protected void toggleShowPhaseDate(Context context)
{
boolean value = AppSettings.loadShowMoonPhaseDatePref(context);
AppSettings.saveShowMoonPhaseDatePref(context, !value);
moonphases.notifyDataSetChanged();
}

protected void toggleLunarNoon(Context context)
{
boolean value = AppSettings.loadShowLunarNoonPref(context);
Expand Down Expand Up @@ -732,6 +739,11 @@ private void updateOverflowMenu(Context context, PopupMenu popup)
lunarNoonItem.setChecked(AppSettings.loadShowLunarNoonPref(context));
}

MenuItem phaseDateItem = menu.findItem(R.id.action_phase_showdate);
if (phaseDateItem != null) {
phaseDateItem.setChecked(AppSettings.loadShowMoonPhaseDatePref(context));
}

MenuItem columnItem;
switch (moonphases.numColumns())
{
Expand All @@ -754,6 +766,10 @@ public boolean onMenuItemClick(MenuItem item)
showColorDialog(getActivity());
return true;

case R.id.action_phase_showdate:
toggleShowPhaseDate(getContext());
return true;

case R.id.action_phase_columns_2:
saveMoonPhaseColumns(2);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ private void showEmptyView( boolean show )
card_view.setVisibility(show ? View.GONE : View.VISIBLE);
}

public void notifyDataSetChanged() {
card_adapter.notifyDataSetChanged();
}

public void updateViews( Context context )
{
if (isInEditMode()) {
Expand Down Expand Up @@ -624,6 +628,7 @@ public void bindDataToPosition(Context context, SuntimesMoonData1 data, Suntimes
return;
}

boolean showDate = AppSettings.loadShowMoonPhaseDatePref(context);
boolean showWeeks = WidgetSettings.loadShowWeeksPref(context, 0);
boolean showTime = WidgetSettings.loadShowTimeDatePref(context, 0);
boolean showHours = WidgetSettings.loadShowHoursPref(context, 0);
Expand Down Expand Up @@ -651,7 +656,7 @@ public void bindDataToPosition(Context context, SuntimesMoonData1 data, Suntimes
}
}

updateField(context, data.now(), phaseDate, showWeeks, showTime, showHours, showSeconds);
updateField(context, data.now(), phaseDate, showDate, showWeeks, showTime, showHours, showSeconds);
setLabel(phaseLabel);
}

Expand All @@ -675,11 +680,12 @@ public void themeViews(int labelColor, @Nullable Float labelSizeSp, boolean labe
icon.setImageBitmap(bitmap);
}

public void updateField(Context context, Calendar now, Calendar dateTime, boolean showWeeks, boolean showTime, boolean showHours, boolean showSeconds)
public void updateField(Context context, Calendar now, Calendar dateTime, boolean showDate, boolean showWeeks, boolean showTime, boolean showHours, boolean showSeconds)
{
if (field != null)
{
field.setText(utils.calendarDateTimeDisplayString(context, dateTime, showTime, showSeconds).getValue());
field.setVisibility(showDate ? View.VISIBLE : View.GONE);
}

if (note != null)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/moonmenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
android:checkable="true"
app:showAsAction="never" />

<item android:id="@+id/action_phase_showdate"
android:title="@string/configLabel_ui_showMoonPhaseDate"
android:checkable="true"
app:showAsAction="never" />

<item android:id="@+id/action_phase_columns"
android:title="@string/configLabel_ui_showmoon_phase_columns"
app:showAsAction="never">
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,10 @@
<string name="configLabel_ui_showmoon_phase_columns_3">3</string>
<string name="configLabel_ui_showmoon_phase_columns_4">4</string>

<!-- App Setting: Moon Phase Date -->
<string name="configLabel_ui_showMoonPhaseDate">Show Phase Dates</string> <!-- TODO -->
<string name="configLabel_ui_showMoonPhaseDate_summary">Include the date when showing moon phases.</string> <!-- TODO -->

<!-- App Setting: Show Cross Quarter days -->
<string name="configLabel_ui_showCrossQuarter">Cross-Quarter Days</string>
<string name="configLabel_ui_showCrossQuarter_summary">Include midpoints between solstices and equinoxes.</string>
Expand Down

0 comments on commit 2a71aec

Please sign in to comment.