From: Eugene Crosser Date: Sat, 11 Feb 2012 10:51:03 +0000 (+0400) Subject: Network access error message X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=f865ec027b40d832f5c78eceb32f268dca3dda52;p=WhereAmI.git Network access error message --- diff --git a/res/values/strings.xml b/res/values/strings.xml index fe162bb..0800bbf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10,6 +10,7 @@ Нет календаря с именем Нет записей за последнюю неделю Ошибка авторизации + Нет связи с сервером через Интернет Женя отмечено Последний звонок diff --git a/src/org/average/whereami/APIBase.java b/src/org/average/whereami/APIBase.java index e8dfbb1..e04f3a5 100644 --- a/src/org/average/whereami/APIBase.java +++ b/src/org/average/whereami/APIBase.java @@ -33,6 +33,7 @@ public class APIBase { public MyAccessProtectedResource accessProtectedResource; public String authErrorMessage; + public String connectErrorMessage; public APIBase(final Resources res, final PersistentStore store) { this.res = res; @@ -50,6 +51,7 @@ public class APIBase { ClientCredentials.CLIENT_SECRET, token.refreshToken); authErrorMessage = res.getString(R.string.autherror); + connectErrorMessage = res.getString(R.string.connecterror); enableLogging(); } diff --git a/src/org/average/whereami/LastLocation.java b/src/org/average/whereami/LastLocation.java index c579116..27c5c51 100644 --- a/src/org/average/whereami/LastLocation.java +++ b/src/org/average/whereami/LastLocation.java @@ -8,6 +8,8 @@ import org.average.whereami.SayWhen; import java.lang.Math; import java.io.IOException; +import java.net.UnknownHostException; +import org.apache.http.conn.HttpHostConnectException; import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.http.HttpResponseException; @@ -77,6 +79,16 @@ public final class LastLocation extends Oracle { } catch (HttpResponseException e) { Log.e(TAG, "HttpResponseException: " + e); return new Utterance(false, e.getMessage()); + } catch (UnknownHostException e) { + Log.e(TAG, "UnknownHostException: " + e); + return new Utterance(false, + base.connectErrorMessage + "\n" + + e.getMessage()); + } catch (HttpHostConnectException e) { + Log.e(TAG, "HttpHostConnectException: " + e); + return new Utterance(false, + base.connectErrorMessage + "\n" + + e.getMessage()); } catch (IOException e) { Log.e(TAG, "IOException: " + e); return new Utterance(false, e.getMessage()); diff --git a/src/org/average/whereami/PhoneLog.java b/src/org/average/whereami/PhoneLog.java index cf904c6..7ce53ea 100644 --- a/src/org/average/whereami/PhoneLog.java +++ b/src/org/average/whereami/PhoneLog.java @@ -7,6 +7,8 @@ import org.average.whereami.PersistentStore; import org.average.whereami.SayWhen; import java.io.IOException; +import java.net.UnknownHostException; +import org.apache.http.conn.HttpHostConnectException; import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.http.HttpResponseException; @@ -96,6 +98,16 @@ public final class PhoneLog extends Oracle { } catch (HttpResponseException e) { Log.e(TAG, "HttpResponseException: " + e); return new Utterance(false, e.getMessage()); + } catch (UnknownHostException e) { + Log.e(TAG, "UnknownHostException: " + e); + return new Utterance(false, + base.connectErrorMessage + "\n" + + e.getMessage()); + } catch (HttpHostConnectException e) { + Log.e(TAG, "HttpHostConnectException: " + e); + return new Utterance(false, + base.connectErrorMessage + "\n" + + e.getMessage()); } catch (IOException e) { Log.e(TAG, "IOException: " + e); return new Utterance(false, e.getMessage());