X-Git-Url: http://www.average.org/gitweb/?p=WhereAmI.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fwhereami%2FLastLocation.java;h=76e8ef28c73e02c82288f2a71eaefd0398592e69;hp=4b82564fae272d9e5261fb170f07014295c141cc;hb=9cc761c03fc2da437a596df5c6cbec3cd01fcf2a;hpb=902f7d8ee32a0d9c929835efe8327c8a340a6b5b diff --git a/src/org/average/whereami/LastLocation.java b/src/org/average/whereami/LastLocation.java index 4b82564..76e8ef2 100644 --- a/src/org/average/whereami/LastLocation.java +++ b/src/org/average/whereami/LastLocation.java @@ -1,6 +1,7 @@ package org.average.whereami; import org.average.whereami.PersistentStore; +import org.average.whereami.SayWhen; import java.lang.Math; import java.io.IOException; @@ -27,12 +28,8 @@ public final class LastLocation extends Oracle { 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); @@ -41,12 +38,8 @@ public final class LastLocation extends Oracle { 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) @@ -101,20 +94,8 @@ public final class LastLocation extends Oracle { 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) {