summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-12 12:02:08 +0100
committerParménides GV <parmegv@sdf.org>2015-03-12 12:02:08 +0100
commitc5124635b8272d08538889c1a9edfafe4acaf759 (patch)
tree1c0de82cc3bb4186cb4eb6dc0cb974d0d3de0580
parent777cdf0e0844f8450fac6bc9146c013f30e820d2 (diff)
parentf62c2c0ef907744814b48a56d08a83a6fbe1bed4 (diff)
Merge branch 'bug/Give-more-feedback-if-something-fails-#6782' into develop
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java19
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java75
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java12
-rw-r--r--app/src/main/res/values/strings.xml2
4 files changed, 65 insertions, 43 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 4fe51939..04385ddd 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -249,16 +249,12 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
@Override
public boolean onOptionsItemSelected(MenuItem item){
- Intent intent;
switch (item.getItemId()){
case R.id.about_leap:
- intent = new Intent(this, AboutActivity.class);
- startActivity(intent);
+ showAbout();
return true;
case R.id.log_window:
- Intent startLW = new Intent(getAppContext(), LogWindow.class);
- startLW.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
- startActivity(startLW);
+ showLog();
return true;
case R.id.switch_provider:
switching_provider = true;
@@ -279,6 +275,17 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
}
}
+ public void showAbout() {
+ Intent intent = new Intent(this, AboutActivity.class);
+ startActivity(intent);
+ }
+
+ public void showLog() {
+ Intent startLW = new Intent(getAppContext(), LogWindow.class);
+ //startLW.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ startActivity(startLW);
+ }
+
@Override
public void signUp(String username, String password) {
Bundle parameters = bundleParameters(username, password);
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 588b137b..680f21e1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -1,32 +1,33 @@
+/**
+ * Copyright (c) 2013 LEAP Encryption Access Project and contributers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
package se.leap.bitmaskclient;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Fragment;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.ResultReceiver;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ProgressBar;
-import android.widget.Switch;
-import android.widget.TextView;
-
-import java.util.Observable;
-import java.util.Observer;
-
-import butterknife.ButterKnife;
-import butterknife.InjectView;
-import butterknife.OnCheckedChanged;
-import de.blinkt.openvpn.activities.DisconnectVPN;
-import se.leap.bitmaskclient.eip.Constants;
-import se.leap.bitmaskclient.eip.EIP;
-import se.leap.bitmaskclient.eip.EipStatus;
-import se.leap.bitmaskclient.eip.VoidVpnService;
+import android.app.*;
+import android.content.*;
+import android.os.*;
+import android.util.*;
+import android.view.*;
+import android.widget.*;
+
+import java.util.*;
+
+import butterknife.*;
+import de.blinkt.openvpn.activities.*;
+import se.leap.bitmaskclient.eip.*;
public class EipFragment extends Fragment implements Observer {
@@ -193,6 +194,10 @@ public class EipFragment extends Fragment implements Observer {
private void stopEIP() {
if(eip_status.isConnecting())
VoidVpnService.stop();
+ disconnect();
+ }
+
+ private void disconnect() {
Intent disconnect_vpn = new Intent(dashboard, DisconnectVPN.class);
dashboard.startActivityForResult(disconnect_vpn, EIP.DISCONNECT);
eip_status.setDisconnecting();
@@ -201,8 +206,8 @@ public class EipFragment extends Fragment implements Observer {
protected void askToStopEIP() {
hideProgressBar();
- String status = dashboard.getString(R.string.eip_state_not_connected);
- status_message.setText(status);
+ String message = dashboard.getString(R.string.eip_state_not_connected);
+ status_message.setText(message);
eipCommand(Constants.ACTION_STOP_EIP);
}
@@ -240,11 +245,10 @@ public class EipFragment extends Fragment implements Observer {
}
private void handleNewState(EipStatus eip_status) {
- Log.d(TAG, "handleNewState: " + eip_status.toString());
if(eip_status.wantsToDisconnect())
setDisconnectedUI();
- else if(eip_status.isConnecting() || is_starting_to_connect)
- setInProgressUI(eip_status);
+ else if(eip_status.isConnecting() || is_starting_to_connect)
+ setInProgressUI(eip_status);
else if (eip_status.isConnected())
setConnectedUI();
else if (eip_status.isDisconnected() && !eip_status.isConnecting())
@@ -262,7 +266,12 @@ public class EipFragment extends Fragment implements Observer {
private void setDisconnectedUI(){
hideProgressBar();
adjustSwitch();
- status_message.setText(dashboard.getString(R.string.eip_state_not_connected));
+ String last_log_message = eip_status.getLastLogMessage(dashboard.getApplicationContext());
+ if((last_log_message.contains("error") || last_log_message.contains("ERROR"))
+ && !status_message.getText().toString().equalsIgnoreCase(dashboard.getString(R.string.eip_state_not_connected))){
+ dashboard.showLog();
+ }
+ status_message.setText(dashboard.getString(R.string.eip_state_not_connected));
}
private void 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 c6735130..14158696 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
@@ -16,11 +16,12 @@
*/
package se.leap.bitmaskclient.eip;
-import android.util.Log;
+import android.util.*;
+import android.content.*;
-import java.util.Observable;
+import java.util.*;
-import de.blinkt.openvpn.core.VpnStatus;
+import de.blinkt.openvpn.core.*;
public class EipStatus extends Observable implements VpnStatus.StateListener {
public static String TAG = EipStatus.class.getSimpleName();
@@ -135,6 +136,11 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
EipStatus.level = level;
}
+ public String getLastLogMessage(Context context) {
+ VpnStatus.LogItem[] log = VpnStatus.getlogbuffer();
+ return log[log.length-1].getString(context);
+ }
+
@Override
public String toString() {
return "State: " + state + " Level: " + level.toString();
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 709d92b5..032602cb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -58,7 +58,7 @@
<string name="signingup_message">Signing up</string>
<string name="logout_message">Logging out from this session.</string>
<string name="logged_out_message">Logged out.</string>
- <string name="log_out_failed_message">Didn\'t log out.</string>
+ <string name="log_out_failed_message">Didn\'t log out. Try later, it may be a problem in the network or in the provider. If the problem persists, then wipe Bitmask data from the Android settings</string>
<string name="succesful_authentication_message">Authentication succeeded.</string>
<string name="authentication_failed_message">Authentication failed.</string>
<string name="registration_failed_message">Registration failed.</string>