mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Internationalize more string
This commit is contained in:
@@ -19,8 +19,6 @@ package org.isoron.helpers;
|
||||
import android.content.Context;
|
||||
import android.text.format.DateFormat;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
@@ -70,7 +68,7 @@ public class DateHelper
|
||||
{
|
||||
String dayOfMonth = Integer.toString(day.get(GregorianCalendar.DAY_OF_MONTH));
|
||||
String dayOfWeek = day.getDisplayName(GregorianCalendar.DAY_OF_WEEK,
|
||||
GregorianCalendar.SHORT, Locale.US);
|
||||
GregorianCalendar.SHORT, Locale.getDefault());
|
||||
|
||||
return dayOfWeek + "\n" + dayOfMonth;
|
||||
}
|
||||
@@ -81,53 +79,21 @@ public class DateHelper
|
||||
return (int) (milliseconds / millisecondsInOneDay);
|
||||
}
|
||||
|
||||
public static String differenceInWords(Date from, Date to)
|
||||
public static String[] getShortDayNames()
|
||||
{
|
||||
Integer days = differenceInDays(from, to);
|
||||
boolean negative = (days < 0);
|
||||
days = Math.abs(days);
|
||||
String[] wdays = new String[7];
|
||||
|
||||
Integer weeks = (int) Math.round(days / 7.0);
|
||||
Double months = days / 30.4;
|
||||
Double years = days / 365.0;
|
||||
GregorianCalendar day = new GregorianCalendar();
|
||||
day.set(GregorianCalendar.DAY_OF_WEEK, 0);
|
||||
|
||||
StringBuffer s = new StringBuffer();
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
|
||||
if (months > 18)
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
s.append(df.format(years));
|
||||
s.append(" years");
|
||||
}
|
||||
else if (weeks > 6)
|
||||
{
|
||||
s.append(df.format(months));
|
||||
s.append(" months");
|
||||
}
|
||||
else if (days > 13)
|
||||
{
|
||||
s.append(weeks);
|
||||
s.append(" weeks");
|
||||
}
|
||||
else if (days > 6)
|
||||
{
|
||||
s.append(days);
|
||||
s.append(" days");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (days == 0) s.append("Today");
|
||||
else if (days == 1 && negative) s.append("Yesterday");
|
||||
else if (days == 1 && !negative) s.append("Tomorrow");
|
||||
else
|
||||
{
|
||||
if (negative) s.append("past ");
|
||||
s.append(new SimpleDateFormat("EEEE").format(to));
|
||||
}
|
||||
wdays[i] = day.getDisplayName(GregorianCalendar.DAY_OF_WEEK, GregorianCalendar.SHORT,
|
||||
Locale.getDefault());
|
||||
day.add(GregorianCalendar.DAY_OF_MONTH, 1);
|
||||
}
|
||||
|
||||
if (negative && days > 6) s.append(" ago");
|
||||
|
||||
return s.toString();
|
||||
return wdays;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
@@ -106,7 +105,6 @@ public class ReminderAlarmReceiver extends BroadcastReceiver
|
||||
|
||||
if (habit.hasImplicitRepToday()) return;
|
||||
|
||||
Log.d("Alarm", String.format("Applying highlight: %s", habit.name));
|
||||
habit.highlight = 1;
|
||||
habit.save();
|
||||
|
||||
@@ -144,8 +142,10 @@ public class ReminderAlarmReceiver extends BroadcastReceiver
|
||||
.setContentText(habit.description)
|
||||
.setContentIntent(contentPendingIntent)
|
||||
.setDeleteIntent(deletePendingIntent)
|
||||
.addAction(R.drawable.ic_action_check, "Check", checkIntentPending)
|
||||
.addAction(R.drawable.ic_action_snooze, "Later", snoozeIntentPending)
|
||||
.addAction(R.drawable.ic_action_check,
|
||||
context.getString(R.string.check), checkIntentPending)
|
||||
.addAction(R.drawable.ic_action_snooze,
|
||||
context.getString(R.string.snooze), snoozeIntentPending)
|
||||
.setSound(soundUri)
|
||||
.extend(wearableExtender)
|
||||
.build();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class EditHabitFragment extends DialogFragment implements OnClickListener
|
||||
|
||||
if (mode == CREATE_MODE)
|
||||
{
|
||||
getDialog().setTitle("Create habit");
|
||||
getDialog().setTitle(R.string.create_habit);
|
||||
modifiedHabit = new Habit();
|
||||
|
||||
int defaultNum = prefs.getInt("pref_default_habit_freq_num", modifiedHabit.freqNum);
|
||||
@@ -121,7 +121,7 @@ public class EditHabitFragment extends DialogFragment implements OnClickListener
|
||||
originalHabit = Habit.get((Long) args.get("habitId"));
|
||||
modifiedHabit = new Habit(originalHabit);
|
||||
|
||||
getDialog().setTitle("Edit habit");
|
||||
getDialog().setTitle(R.string.edit_habit);
|
||||
tvName.append(modifiedHabit.name);
|
||||
tvDescription.append(modifiedHabit.description);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedL
|
||||
LinearLayout llOverview = (LinearLayout) view.findViewById(R.id.llOverview);
|
||||
llOverview.addView(new RingView(activity,
|
||||
(int) activity.getResources().getDimension(R.dimen.small_square_size) * 4,
|
||||
habit.color, ((float) habit.getScore() / Habit.MAX_SCORE), "Habit strength"));
|
||||
habit.color, ((float) habit.getScore() / Habit.MAX_SCORE), activity.getString(R.string.habit_strength)));
|
||||
|
||||
LinearLayout llStrength = (LinearLayout) view.findViewById(R.id.llStrength);
|
||||
llStrength.addView(new HabitScoreView(activity, habit,
|
||||
|
||||
@@ -50,6 +50,8 @@ public class HabitHistoryView extends View
|
||||
private int colorPrimary, colorPrimaryBrighter, grey;
|
||||
private Float prevX, prevY;
|
||||
|
||||
private String wdays[];
|
||||
|
||||
public HabitHistoryView(Context context, Habit habit, int squareSize)
|
||||
{
|
||||
super(context);
|
||||
@@ -76,6 +78,8 @@ public class HabitHistoryView extends View
|
||||
pSquareFg.setAntiAlias(true);
|
||||
pSquareFg.setTextSize(squareSize * 0.5f);
|
||||
pSquareFg.setTextAlign(Align.CENTER);
|
||||
|
||||
wdays = DateHelper.getShortDayNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,8 +197,6 @@ public class HabitHistoryView extends View
|
||||
square.offset(squareSize, -8 * squareSize);
|
||||
}
|
||||
|
||||
String wdays[] = {"Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"};
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
square.offset(0, squareSize);
|
||||
|
||||
Reference in New Issue
Block a user