From 0a7cb34e42fc3b8bf8623bda45cd4d76079a96c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 20 Apr 2015 19:55:00 +0200 Subject: Always show the log if an error happens. I've removed the "reason" management in LogWindowWrapper, letting EipStatus display the error log message only if it's a new one (based on the log buffer position). --- app/src/main/java/se/leap/bitmaskclient/EipFragment.java | 7 ++----- app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index c92ae3cd..a13cab09 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -103,7 +103,6 @@ public class EipFragment extends Fragment implements Observer { @OnClick(R.id.vpn_Status_Image) void handleIcon() { - LogWindowWrapper.getInstance(dashboard.getApplicationContext()).clearReason(); if (eip_status.isConnected() || eip_status.isConnecting()) handleSwitchOff(); else @@ -243,11 +242,9 @@ public class EipFragment extends Fragment implements Observer { private void handleNewState(EipStatus eip_status) { Context context = dashboard.getApplicationContext(); String error = eip_status.lastError(5, context); - LogWindowWrapper log_window = LogWindowWrapper.getInstance(context); - if (!error.isEmpty() && log_window != null && !log_window.reason().equalsIgnoreCase(error)) { - log_window.showLog(); - log_window.showedBecauseOf(error); + if (!error.isEmpty()) { + dashboard.showLog(); VoidVpnService.stop(); } adjustSwitch(); diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java index 356cf6b0..4bfef1cb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java @@ -31,7 +31,7 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { wants_to_disconnect = false, is_connecting = false; - + int last_error_line = 0; private String state, log_message; private int localized_res_id; @@ -146,13 +146,18 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { String[] error_keywords = {"error", "ERROR", "fatal", "FATAL"}; VpnStatus.LogItem[] log = VpnStatus.getlogbuffer(); + if(log.length < last_error_line) + last_error_line = 0; String message = ""; for (int i = 1; i <= lines && log.length > i; i++) { - VpnStatus.LogItem log_item = log[log.length - i]; + int line = log.length - i; + VpnStatus.LogItem log_item = log[line]; message = log_item.getString(context); for (int j = 0; j < error_keywords.length; j++) - if (message.contains(error_keywords[j])) + if (message.contains(error_keywords[j]) && line > last_error_line) { error = message; + last_error_line = line; + } } return error; -- cgit v1.2.3