<string name="failtry">Неудачная попытка</string>
<string name="nocalendar">Нет календаря с именем</string>
<string name="noevents">Нет записей за последнюю неделю</string>
- <string name="autherror">Ð\9dеобÑ\85одимо авÑ\82оÑ\80изоваÑ\82Ñ\8cÑ\81Ñ\8f (Ñ\87еÑ\80ез менÑ\8e)</string>
+ <string name="autherror">Ð\9eÑ\88ибка авÑ\82оÑ\80изаÑ\86ии</string>
<string name="myname">Женя</string>
- <string name="timestamp">отметка</string>
+ <string name="registered">отмечено</string>
<string name="last_call">Последний звонок</string>
<string name="in_call">к Жене</string>
<string name="out_call">от Жени</string>
- <string name="duration">длительностью</string>
+ <string name="duration">длиной</string>
<string name="minutes1">минуту</string>
<string name="minutes2to4">минуты</string>
<string name="minutes5up">минут</string>
- <string name="longago">больше суток назад</string>
- <string name="lessthanhour">меньше часа назад</string>
- <string name="onehour">час с лишним назад</string>
- <string name="hours2to4">часа назад</string>
- <string name="hours5up">часов назад</string>
+ <string name="s_at">в</string>
+ <string name="yesterday">вчера</string>
<string name="quit">Выход</string>
<string name="authorize">Авторизация</string>
<string name="settings">Конфигурация</string>
package org.average.whereami;
import org.average.whereami.PersistentStore;
+import org.average.whereami.SayWhen;
import java.lang.Math;
import java.io.IOException;
private String[] loc_lons;
private String[] loc_dists;
private String myname;
- private String timestamp;
- private String longago;
- private String lessthanhour;
- private String onehour;
- private String hours2to4;
- private String hours5up;
+ private String registered;
+ private SayWhen sayWhen;
public LastLocation(final Resources res, final PersistentStore store) {
super(res, store);
loc_lons = res.getStringArray(R.array.loc_lons);
loc_dists = res.getStringArray(R.array.loc_dists);
myname = res.getString(R.string.myname);
- timestamp = res.getString(R.string.timestamp);
- longago = res.getString(R.string.longago);
- lessthanhour = res.getString(R.string.lessthanhour);
- onehour = res.getString(R.string.onehour);
- hours2to4 = res.getString(R.string.hours2to4);
- hours5up = res.getString(R.string.hours5up);
+ registered = res.getString(R.string.registered);
+ sayWhen = new SayWhen(res);
latitude = Latitude.builder(httpTransport, jsonFactory)
.setHttpRequestInitializer(accessProtectedResource)
break;
}
}
- Long ago = (System.currentTimeMillis() - tsm) / 3600000;
- if (ago < 1) {
- agomsg = lessthanhour;
- } else if (ago < 2) {
- agomsg = onehour;
- } else if (ago < 5) {
- agomsg = "" + ago + " " + hours2to4;
- } else if (ago < 24) {
- agomsg = "" + ago + " " + hours5up;
- } else {
- agomsg = longago;
- }
- return myname + " " + locmsg + ", " + timestamp +
- " " + agomsg;
+ return myname + " " + locmsg + ", " + registered +
+ " " + sayWhen.say(tsm);
}
private Double toRad(Double deg) {
package org.average.whereami;
import org.average.whereami.PersistentStore;
+import org.average.whereami.SayWhen;
import java.io.IOException;
private String minutes1;
private String minutes2to4;
private String minutes5up;
+ private SayWhen sayWhen;
public PhoneLog(final Resources res, final PersistentStore store) {
super(res, store);
minutes1 = res.getString(R.string.minutes1);
minutes2to4 = res.getString(R.string.minutes2to4);
minutes5up = res.getString(R.string.minutes5up);
+ sayWhen = new SayWhen(res);
calendar_name = store.get("calendar_name");
peer_name = store.get("peer_name");
calendar_id = store.get("calendar_id");
} else {
minutes = minutes5up;
}
- return last_call + " " +
- (latestWasOutgoing?out_call:in_call) +
- " " + duration + " " + dur + " " + minutes +
- " " + stime.format("%H:%M");
+ return last_call +
+ " " + (latestWasOutgoing?out_call:in_call) +
+ " " + sayWhen.say(latestStartTime) +
+ " " + duration + " " + dur + " " + minutes;
}
}
--- /dev/null
+package org.average.whereami;
+
+import android.content.res.Resources;
+import android.text.format.Time;
+import android.util.Log;
+
+public class SayWhen {
+
+ private String s_at;
+ private String yesterday;
+
+ public SayWhen(final Resources res) {
+ s_at = res.getString(R.string.s_at);
+ yesterday = res.getString(R.string.yesterday);
+ }
+
+ public String say(Long when) {
+ Long now = System.currentTimeMillis();
+ Time tnow = new Time();
+ tnow.set(now);
+ Time twhen = new Time();
+ twhen.set(when);
+ Boolean datechange = tnow.monthDay != twhen.monthDay;
+ Long hoursago = (System.currentTimeMillis() - when) / 3600000;
+ if (hoursago > 24) {
+ return s_at + twhen.format(" %H:%M %d/%m/%Y");
+ } else if ((tnow.hour > 4 || hoursago > 12) && datechange) {
+ return yesterday + " " + s_at + twhen.format(" %H:%M");
+ } else {
+ return s_at + twhen.format(" %H:%M");
+ }
+ }
+}