android:gravity="center"
android:layout_weight="3"
android:textColor="#ff000000"
- android:textSize="24sp"
+ android:textSize="32sp"
android:text="@string/location"
/>
<View
android:gravity="center"
android:layout_weight="3"
android:textColor="#ff000000"
- android:textSize="24sp"
+ android:textSize="32sp"
android:text="@string/phonecall"
/>
<View
<string name="failure">Неудача</string>
<string name="lasttry">Последнее обновление</string>
<string name="failtry">Неудачная попытка</string>
+ <string name="myname">Женя</string>
+ <string name="timestamp">отметка</string>
+ <string name="longago">больше суток назад</string>
+ <string name="lessthanhour">меньше часа назад</string>
+ <string name="onehour">час с лишним назад</string>
+ <string name="hours2to4">часа назад</string>
+ <string name="hours5up">часов назад</string>
<string name="quit">Выход</string>
<string name="authorize">Авторизация</string>
<string name="settings">Конфигурация</string>
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.text.format.Time;
import android.util.Log;
public final class LastLocation extends Oracle {
private String[] loc_lats;
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;
public LastLocation(final Resources res, final CredentialStore store) {
loc_names = res.getStringArray(R.array.loc_names);
loc_lats = res.getStringArray(R.array.loc_lats);
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);
HttpTransport transport = AndroidHttp.newCompatibleTransport();
JsonFactory jsonFactory = new JacksonFactory();
Log.v(TAG, "entering locationMessage(" + lat +
"," + lon + "," + tsm + ")");
String locmsg = "<UNSET>";
+ String agomsg = "<UNSET>";
for (int i = 0; i < loc_names.length; i++) {
Double dist = haversine(lat, lon,
Double.parseDouble(loc_lats[i]),
break;
}
}
- return locmsg;
+ 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;
}
private Double toRad(Double deg) {