summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-02-08 15:37:15 +0100
committercyBerta <cyberta@riseup.net>2018-02-08 15:37:15 +0100
commit6770f041300fa592dfb93fb4296c55218c05cc45 (patch)
tree17dd25e0b17e50358cef4e464fa4bc2503cc2859 /app/src/main/java
parentef805faec61a4cb3155dd336f5db08cd2c40aece (diff)
parentae938c20a11b6195936f97eebd32abd35335bceb (diff)
Merge branch 'mirror_0xacab_0.9.8' into #8830_onBoot_alwaysOn
Diffstat (limited to 'app/src/main/java')
-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/Dashboard.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java16
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/MainActivity.java22
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java5
-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.java22
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/userstatus/UserStatusFragment.java6
11 files changed, 57 insertions, 52 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java
index fbb27b58..ebfc1909 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/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a4db5f84..78ec3fd2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -459,11 +459,11 @@ public class Dashboard extends ButterKnifeActivity {
String password = resultData.getString(SessionDialog.PASSWORD);
dashboard.user_status_fragment.logIn(username, password);
} else if (resultCode == ProviderAPI.FAILED_SIGNUP) {
- MainActivity.sessionDialog(resultData);
+ //MainActivity.sessionDialog(resultData);
} else if (resultCode == ProviderAPI.SUCCESSFUL_LOGIN) {
Dashboard.downloadVpnCertificate();
} else if (resultCode == ProviderAPI.FAILED_LOGIN) {
- MainActivity.sessionDialog(resultData);
+ //MainActivity.sessionDialog(resultData);
} else if (resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) {
if (switching_provider) dashboard.switchProvider();
} else if (resultCode == ProviderAPI.LOGOUT_FAILED) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 5f939a76..844bfd7d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -73,10 +73,12 @@ import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
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;
@@ -121,6 +123,7 @@ public class EipFragment extends Fragment implements Observer {
};
+ @Override
public void onAttach(Context context) {
super.onAttach(context);
downloadEIPServiceConfig();
@@ -139,6 +142,11 @@ public class EipFragment extends Fragment implements Observer {
eipStatus.addObserver(this);
View view = inflater.inflate(R.layout.eip_service_fragment, container, false);
ButterKnife.inject(this, view);
+
+ Bundle arguments = getArguments();
+ if (arguments != null && arguments.containsKey(ASK_TO_CANCEL_VPN) && arguments.getBoolean(ASK_TO_CANCEL_VPN)) {
+ askToStopEIP();
+ }
return view;
}
@@ -200,8 +208,10 @@ public class EipFragment extends Fragment implements Observer {
startEipFromScratch();
else if (canLogInToStartEIP()) {
wantsToConnect = true;
- Bundle bundle = new Bundle();
- MainActivity.sessionDialog(bundle);
+ /*Bundle bundle = new Bundle();
+ seionDialogCallback.onSessionDialog(bundle);*/
+ Log.w(TAG, "TODO: implement login from here");
+ //FIXME: implement login from here
} else {
Log.d(TAG, "WHAT IS GOING ON HERE?!");
// TODO: implement a fallback: check if vpncertificate was not downloaded properly or give
diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
index 7629f0b7..186c2928 100644
--- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
@@ -15,12 +15,11 @@ import se.leap.bitmaskclient.userstatus.SessionDialog;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.EipFragment.ASK_TO_CANCEL_VPN;
public class MainActivity extends AppCompatActivity {
- private static Provider provider = new Provider();
- private static FragmentManagerEnhanced fragmentManager;
private SharedPreferences preferences;
public final static String ACTION_SHOW_VPN_FRAGMENT = "action_show_vpn_fragment";
@@ -40,7 +39,6 @@ public class MainActivity extends AppCompatActivity {
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
- fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager());
// Set up the drawer.
navigationDrawerFragment.setUp(
R.id.navigation_drawer,
@@ -49,15 +47,6 @@ public class MainActivity extends AppCompatActivity {
handleIntentAction(getIntent());
}
- public static void sessionDialog(Bundle resultData) {
- try {
- FragmentTransaction transaction = fragmentManager.removePreviousFragment(SessionDialog.TAG);
- SessionDialog.getInstance(provider, resultData).show(transaction, SessionDialog.TAG);
- } catch (IllegalStateException e) {
- e.printStackTrace();
- }
- }
-
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
@@ -71,17 +60,21 @@ public class MainActivity extends AppCompatActivity {
}
Fragment fragment = null;
-
switch (intent.getAction()) {
case ACTION_SHOW_VPN_FRAGMENT:
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) {
- fragmentManager.beginTransaction()
+ new FragmentManagerEnhanced(getSupportFragmentManager()).beginTransaction()
.replace(R.id.container, fragment)
.commit();
}
@@ -100,5 +93,4 @@ public class MainActivity extends AppCompatActivity {
}
}
}
-
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index aee00765..fdf8df3c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -176,7 +176,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 26385f67..e4758ac9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -18,7 +18,6 @@ import se.leap.bitmaskclient.userstatus.User;
import static se.leap.bitmaskclient.Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE;
import static se.leap.bitmaskclient.Constants.EIP_ACTION_START;
-import static se.leap.bitmaskclient.Constants.EIP_RECEIVER;
import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
@@ -155,14 +154,11 @@ public class StartActivity extends Activity {
configureLeapProvider();
} else {
Log.d(TAG, "vpn provider is configured");
-
if (getIntent() != null && getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false)) {
- Log.d(TAG, "start VPN in background");
eipCommand(EIP_ACTION_START);
finish();
return;
}
- Log.d(TAG, "show MainActivity!");
showMainActivity();
}
} else {
@@ -197,6 +193,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(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 090e8d26..73c68e4c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
@@ -121,7 +121,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),
@@ -140,7 +140,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);
String providerName = ConfigHelper.getProviderName(preferences);
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 5b7c6e69..b8858c1e 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;
@@ -58,12 +60,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);
@@ -81,7 +83,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;
@@ -245,10 +249,10 @@ public final class EIP extends IntentService {
}
private void tellToReceiver(String action, int resultCode) {
- if (mReceiver != null) {
- Bundle resultData = new Bundle();
- resultData.putString(EIP_REQUEST, action);
- mReceiver.send(resultCode, resultData);
+ Bundle resultData = new Bundle();
+ resultData.putString(EIP_REQUEST, action);
+ if (mReceiverRef.get() != null) {
+ mReceiverRef.get().send(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 0f1d0cdb..4b8ce55d 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;
@@ -26,7 +27,7 @@ import se.leap.bitmaskclient.R;
public class UserStatusFragment extends Fragment implements Observer, SessionDialog.SessionDialogInterface {
- public static String TAG = UserStatusFragment.class.getSimpleName();
+ public final static String TAG = UserStatusFragment.class.getSimpleName();
private ProviderAPIResultReceiver providerAPI_result_receiver;
@InjectView(R.id.user_status_username)
@@ -88,7 +89,8 @@ public class UserStatusFragment extends Fragment implements Observer, SessionDia
if(status.isLoggedIn())
logOut();
else if(status.isLoggedOut())
- MainActivity.sessionDialog(Bundle.EMPTY);
+ Log.w(TAG, "implement login from here?");
+ //MainActivity.sessionDialog(Bundle.EMPTY);
else if(status.inProgress())
cancelLoginOrSignup();
}