summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/MainActivity.java21
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VpnNotificationManager.java22
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java18
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java6
10 files changed, 59 insertions, 35 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
index 9826b89b..6738a6bb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
@@ -55,7 +55,7 @@ public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseAct
options.setAdapter(new ArrayAdapter<>(
this,
- android.R.layout.simple_list_item_activated_1,
+ R.layout.single_list_item,
android.R.id.text1,
optionsList.toArray(new String[optionsList.size()])
));
diff --git a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
index f9e45b79..15fd85f8 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BitmaskApp.java
@@ -1,7 +1,7 @@
package se.leap.bitmaskclient;
-import android.app.Application;
import android.content.Context;
+import android.support.multidex.MultiDexApplication;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
@@ -10,7 +10,7 @@ import com.squareup.leakcanary.RefWatcher;
* Created by cyberta on 24.10.17.
*/
-public class BitmaskApp extends Application {
+public class BitmaskApp extends MultiDexApplication {
private RefWatcher refWatcher;
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index a86afd78..3a433d17 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -82,10 +82,12 @@ import static se.leap.bitmaskclient.ProviderAPI.DOWNLOAD_CERTIFICATE;
public class EipFragment extends Fragment implements Observer {
- public static String TAG = EipFragment.class.getSimpleName();
+ public final static String TAG = EipFragment.class.getSimpleName();
protected static final String IS_CONNECTED = TAG + ".is_connected";
public static final String START_EIP_ON_BOOT = "start on boot";
+ public static final String ASK_TO_CANCEL_VPN = "ask_to_cancel_vpn";
+
private SharedPreferences preferences;
private Provider provider;
@@ -134,6 +136,7 @@ public class EipFragment extends Fragment implements Observer {
};
+ @Override
public void onAttach(Context context) {
super.onAttach(context);
Bundle arguments = getArguments();
@@ -167,8 +170,12 @@ public class EipFragment extends Fragment implements Observer {
ButterKnife.inject(this, view);
Bundle arguments = getArguments();
- if (arguments != null && arguments.containsKey(START_EIP_ON_BOOT) && arguments.getBoolean(START_EIP_ON_BOOT)) {
- startEipFromScratch();
+ if (arguments != null) {
+ if (arguments.containsKey(START_EIP_ON_BOOT) && arguments.getBoolean(START_EIP_ON_BOOT)) {
+ startEipFromScratch();
+ } else if (arguments.containsKey(ASK_TO_CANCEL_VPN) && arguments.getBoolean(ASK_TO_CANCEL_VPN)) {
+ askToStopEIP();
+ }
}
return view;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
index d3865559..9c047bc9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
@@ -17,6 +17,7 @@ import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_LOG_IN;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_SWITCH_PROVIDER;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.EipFragment.ASK_TO_CANCEL_VPN;
public class MainActivity extends AppCompatActivity {
@@ -66,13 +67,25 @@ public class MainActivity extends AppCompatActivity {
return;
}
+ Fragment fragment = null;
switch (intent.getAction()) {
case ACTION_SHOW_VPN_FRAGMENT:
- showEipFragment();
+ fragment = new EipFragment();
+ if (intent.hasExtra(ASK_TO_CANCEL_VPN)) {
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(ASK_TO_CANCEL_VPN, true);
+ fragment.setArguments(bundle);
+ }
break;
default:
break;
}
+
+ if (fragment != null) {
+ new FragmentManagerEnhanced(getSupportFragmentManager()).beginTransaction()
+ .replace(R.id.container, fragment)
+ .commit();
+ }
}
@Override
@@ -91,6 +104,7 @@ public class MainActivity extends AppCompatActivity {
ConfigHelper.storeProviderInPreferences(preferences, provider);
navigationDrawerFragment.refresh();
+
switch (requestCode) {
case REQUEST_CODE_SWITCH_PROVIDER:
EipCommand.stopVPN(this);
@@ -100,13 +114,9 @@ public class MainActivity extends AppCompatActivity {
case REQUEST_CODE_LOG_IN:
EipCommand.startVPN(this);
break;
-
}
- showEipFragment();
}
- }
- private void showEipFragment() {
Fragment fragment = new EipFragment();
Bundle arguments = new Bundle();
arguments.putParcelable(PROVIDER_KEY, provider);
@@ -115,5 +125,4 @@ public class MainActivity extends AppCompatActivity {
.replace(R.id.container, fragment)
.commit();
}
-
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index c89e7a49..b2daff82 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -178,7 +178,7 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity
}
private void setUpInitialUI() {
- setContentView(R.layout.configuration_wizard_activity);
+ setContentView(R.layout.provider_list_activity);
setProviderHeaderText(R.string.setup_provider);
hideProgressBar();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
index 616264f9..8607575e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -15,6 +15,7 @@ import java.lang.annotation.RetentionPolicy;
import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.userstatus.User;
+import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static se.leap.bitmaskclient.Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE;
import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
@@ -186,6 +187,7 @@ public class StartActivity extends Activity {
private void showMainActivity() {
Intent intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setAction(MainActivity.ACTION_SHOW_VPN_FRAGMENT);
startActivity(intent);
finish();
diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnNotificationManager.java b/app/src/main/java/se/leap/bitmaskclient/VpnNotificationManager.java
index 5b089524..459f337b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VpnNotificationManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VpnNotificationManager.java
@@ -44,6 +44,8 @@ import static android.text.TextUtils.isEmpty;
import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_NONETWORK;
import static de.blinkt.openvpn.core.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT;
import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP_BLOCKING_VPN;
+import static se.leap.bitmaskclient.EipFragment.ASK_TO_CANCEL_VPN;
+import static se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
/**
* Created by cyberta on 14.01.18.
@@ -86,7 +88,7 @@ public class VpnNotificationManager {
VoidVpnService.NOTIFICATION_CHANNEL_NEWSTATUS_ID,
PRIORITY_MAX,
0,
- getDashboardIntent(),
+ getMainActivityIntent(),
actionBuilder.build());
}
@@ -122,7 +124,7 @@ public class VpnNotificationManager {
if (status == LEVEL_WAITING_FOR_USER_INPUT)
contentIntent = getUserInputIntent(msg);
else
- contentIntent = getDashboardIntent();
+ contentIntent = getMainActivityIntent();
int priority;
if (OpenVPNService.NOTIFICATION_CHANNEL_NEWSTATUS_ID.equals(notificationChannelNewstatusId)) {
@@ -254,11 +256,9 @@ public class VpnNotificationManager {
lastNotificationChannel = notificationChannelNewstatusId;
}
- private PendingIntent getDashboardIntent() {
- Intent startDashboard = new Intent(context, Dashboard.class);
- startDashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
- Intent.FLAG_ACTIVITY_SINGLE_TOP);
- return PendingIntent.getActivity(context, 0, startDashboard, PendingIntent.FLAG_CANCEL_CURRENT);
+ private PendingIntent getMainActivityIntent() {
+ Intent startActivity = new Intent(context, StartActivity.class);
+ return PendingIntent.getActivity(context, 0, startActivity, PendingIntent.FLAG_CANCEL_CURRENT);
}
private PendingIntent getStopVoidVpnIntent() {
@@ -268,10 +268,10 @@ public class VpnNotificationManager {
}
private PendingIntent getDisconnectIntent() {
- Intent disconnectVPN = new Intent(context, Dashboard.class);
- disconnectVPN.setAction(Intent.ACTION_MAIN); //needs to be set that actual action can get triggered
- disconnectVPN.putExtra(Dashboard.ACTION_ASK_TO_CANCEL_VPN, true);
- disconnectVPN.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ Intent disconnectVPN = new Intent(context, MainActivity.class);
+ disconnectVPN.setAction(ACTION_SHOW_VPN_FRAGMENT);
+ disconnectVPN.putExtra(ASK_TO_CANCEL_VPN, true);
+ disconnectVPN.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
return PendingIntent.getActivity(context, 0, disconnectVPN, PendingIntent.FLAG_CANCEL_CURRENT);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
index 64d1bb72..9d5d4341 100644
--- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
@@ -120,7 +120,7 @@ public class NavigationDrawerFragment extends Fragment {
mDrawerSettingsListView.setAdapter(new ArrayAdapter<String>(
actionBar.getThemedContext(),
- android.R.layout.simple_list_item_activated_1,
+ R.layout.single_list_item,
android.R.id.text1,
new String[]{
getString(R.string.switch_provider_menu_option),
@@ -137,7 +137,7 @@ public class NavigationDrawerFragment extends Fragment {
});
accountListAdapter = new ArrayAdapter<>(actionBar.getThemedContext(),
- android.R.layout.simple_list_item_activated_1,
+ R.layout.single_list_item,
android.R.id.text1);
createListAdapterData();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
index e53d81d9..cec917f7 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -27,6 +27,8 @@ import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
+import java.lang.ref.WeakReference;
+
import de.blinkt.openvpn.LaunchVPN;
import se.leap.bitmaskclient.OnBootReceiver;
@@ -60,12 +62,12 @@ public final class EIP extends IntentService {
public final static String TAG = EIP.class.getSimpleName();
public final static String SERVICE_API_PATH = "config/eip-service.json";
- private static ResultReceiver mReceiver;
- private static SharedPreferences preferences;
+ private WeakReference<ResultReceiver> mReceiverRef = new WeakReference<>(null);
+ private SharedPreferences preferences;
- private static JSONObject eipDefinition;
+ private JSONObject eipDefinition;
private GatewaysManager gatewaysManager = new GatewaysManager();
- private static Gateway gateway;
+ private Gateway gateway;
public EIP() {
super(TAG);
@@ -83,7 +85,9 @@ public final class EIP extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
String action = intent.getAction();
- mReceiver = intent.getParcelableExtra(EIP_RECEIVER);
+ if (intent.getParcelableExtra(EIP_RECEIVER) != null) {
+ mReceiverRef = new WeakReference<>((ResultReceiver) intent.getParcelableExtra(EIP_RECEIVER));
+ }
if (action == null) {
return;
@@ -246,8 +250,8 @@ public final class EIP extends IntentService {
private void tellToReceiverOrBroadcast(String action, int resultCode) {
Bundle resultData = new Bundle();
resultData.putString(EIP_REQUEST, action);
- if (mReceiver != null) {
- mReceiver.send(resultCode, resultData);
+ if (mReceiverRef.get() != null) {
+ mReceiverRef.get().send(resultCode, resultData);
} else {
broadcastEvent(resultCode, resultData);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
index 70da20ac..2d8b5c6f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java
@@ -3,6 +3,7 @@ package se.leap.bitmaskclient.userstatus;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,7 +26,7 @@ import se.leap.bitmaskclient.R;
public class UserStatusFragment extends Fragment implements Observer {
- public static String TAG = UserStatusFragment.class.getSimpleName();
+ public final static String TAG = UserStatusFragment.class.getSimpleName();
private ProviderAPIResultReceiver providerAPI_result_receiver;
private Provider provider;
@@ -88,7 +89,8 @@ public class UserStatusFragment extends Fragment implements Observer {
android.util.Log.d(TAG, status.toString());
if(status.isLoggedIn())
logOut();
- //else if(status.isLoggedOut())
+ else if(status.isLoggedOut())
+ Log.w(TAG, "implement login from here?");
//MainActivity.sessionDialog(Bundle.EMPTY);
else if(status.inProgress())
cancelLoginOrSignup();