From: Eugene Crosser Date: Thu, 2 Feb 2012 15:11:21 +0000 (+0400) Subject: location message complete, font size adjustment X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=ff11b2008ca666c719643b54a3825653168ca6da;p=WhereAmI.git location message complete, font size adjustment --- diff --git a/res/layout/main.xml b/res/layout/main.xml index dce5deb..d3c051a 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -47,7 +47,7 @@ android:gravity="center" android:layout_weight="3" android:textColor="#ff000000" - android:textSize="24sp" + android:textSize="32sp" android:text="@string/location" /> Неудача Последнее обновление Неудачная попытка + Женя + отметка + больше суток назад + меньше часа назад + час с лишним назад + часа назад + часов назад Выход Авторизация Конфигурация diff --git a/src/org/average/whereami/LastLocation.java b/src/org/average/whereami/LastLocation.java index b710e16..98b7cf0 100644 --- a/src/org/average/whereami/LastLocation.java +++ b/src/org/average/whereami/LastLocation.java @@ -19,6 +19,7 @@ import com.google.api.services.latitude.model.Location; 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 { @@ -31,12 +32,26 @@ 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(); @@ -97,6 +112,7 @@ public final class LastLocation extends Oracle { Log.v(TAG, "entering locationMessage(" + lat + "," + lon + "," + tsm + ")"); String locmsg = ""; + String agomsg = ""; for (int i = 0; i < loc_names.length; i++) { Double dist = haversine(lat, lon, Double.parseDouble(loc_lats[i]), @@ -109,7 +125,20 @@ public final class LastLocation extends Oracle { 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) {