mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Make frequency text more natural
This commit is contained in:
@@ -168,30 +168,40 @@ 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.freqNum.equals(habit.freqDen))
|
|
||||||
freqText = getResources().getString(R.string.every_day);
|
|
||||||
else if(habit.freqNum == 1 && habit.freqDen == 7)
|
|
||||||
freqText = getResources().getString(R.string.every_week);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String times_every;
|
|
||||||
if(habit.freqNum == 1)
|
|
||||||
times_every = getResources().getString(R.string.time_every);
|
|
||||||
else
|
|
||||||
times_every = getResources().getString(R.string.times_every);
|
|
||||||
|
|
||||||
freqText = String.format("%d %s %d %s", habit.freqNum, times_every, habit.freqDen,
|
|
||||||
getResources().getString(R.string.days));
|
|
||||||
}
|
|
||||||
|
|
||||||
frequencyLabel.setText(freqText);
|
|
||||||
|
|
||||||
if(habit.description.isEmpty())
|
if(habit.description.isEmpty())
|
||||||
questionLabel.setVisibility(View.GONE);
|
questionLabel.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFreqText()
|
||||||
|
{
|
||||||
|
if(habit == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if(habit.freqNum.equals(habit.freqDen))
|
||||||
|
return getResources().getString(R.string.every_day);
|
||||||
|
|
||||||
|
if(habit.freqNum == 1)
|
||||||
|
{
|
||||||
|
if (habit.freqDen == 7)
|
||||||
|
return getResources().getString(R.string.every_week);
|
||||||
|
|
||||||
|
if (habit.freqDen % 7 == 0)
|
||||||
|
return getResources().getString(R.string.every_x_weeks, habit.freqDen / 7);
|
||||||
|
|
||||||
|
return getResources().getString(R.string.every_x_days, habit.freqDen);
|
||||||
|
}
|
||||||
|
|
||||||
|
String times_every = getResources().getString(R.string.times_every);
|
||||||
|
|
||||||
|
if(habit.freqNum == 1)
|
||||||
|
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
|
||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user