Make frequency text more natural

pull/114/merge
Alinson S. Xavier 10 years ago
parent d292ecd988
commit 5e873a3659

@ -168,28 +168,38 @@ public class ShowHabitFragment extends Fragment
reminderLabel.setText(getResources().getString(R.string.reminder_off)); reminderLabel.setText(getResources().getString(R.string.reminder_off));
TextView frequencyLabel = (TextView) view.findViewById(R.id.frequencyLabel); TextView frequencyLabel = (TextView) view.findViewById(R.id.frequencyLabel);
String freqText; frequencyLabel.setText(getFreqText());
if(habit.description.isEmpty())
questionLabel.setVisibility(View.GONE);
}
private String getFreqText()
{
if(habit == null)
return "";
if(habit.freqNum.equals(habit.freqDen)) if(habit.freqNum.equals(habit.freqDen))
freqText = getResources().getString(R.string.every_day); return getResources().getString(R.string.every_day);
else if(habit.freqNum == 1 && habit.freqDen == 7)
freqText = getResources().getString(R.string.every_week); if(habit.freqNum == 1)
else
{ {
String times_every; if (habit.freqDen == 7)
if(habit.freqNum == 1) return getResources().getString(R.string.every_week);
times_every = getResources().getString(R.string.time_every);
else if (habit.freqDen % 7 == 0)
times_every = getResources().getString(R.string.times_every); return getResources().getString(R.string.every_x_weeks, habit.freqDen / 7);
freqText = String.format("%d %s %d %s", habit.freqNum, times_every, habit.freqDen, return getResources().getString(R.string.every_x_days, habit.freqDen);
getResources().getString(R.string.days));
} }
frequencyLabel.setText(freqText); String times_every = getResources().getString(R.string.times_every);
if(habit.description.isEmpty()) if(habit.freqNum == 1)
questionLabel.setVisibility(View.GONE); times_every = getResources().getString(R.string.time_every);
return String.format("%d %s %d %s", habit.freqNum, times_every, habit.freqDen,
getResources().getString(R.string.days));
} }
@Override @Override

Loading…
Cancel
Save