diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/urls/riseup.url | 2 | ||||
-rw-r--r-- | app/build.gradle | 18 | ||||
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java | 2 | ||||
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/testVpnFragment.java | 29 | ||||
-rw-r--r-- | app/src/insecure/AndroidManifest.xml (renamed from app/src/debug/AndroidManifest.xml) | 0 | ||||
-rw-r--r-- | app/src/insecure/assets/urls/cdev.bitmask.net.url (renamed from app/src/debug/assets/urls/cdev.bitmask.net.url) | 0 | ||||
-rw-r--r-- | app/src/insecure/assets/urls/dev.bitmask.net.url (renamed from app/src/debug/assets/urls/dev.bitmask.net.url) | 4 | ||||
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java (renamed from app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java) | 0 | ||||
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/NewProviderDialog.java (renamed from app/src/debug/java/se/leap/bitmaskclient/NewProviderDialog.java) | 0 | ||||
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java (renamed from app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java) | 0 | ||||
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java (renamed from app/src/debug/java/se/leap/bitmaskclient/ProviderDetailFragment.java) | 222 | ||||
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java (renamed from app/src/debug/java/se/leap/bitmaskclient/ProviderListContent.java) | 164 | ||||
-rw-r--r-- | app/src/insecure/res/layout-xlarge/new_provider_dialog.xml (renamed from app/src/debug/res/layout-xlarge/new_provider_dialog.xml) | 0 | ||||
-rw-r--r-- | app/src/insecure/res/layout/new_provider_dialog.xml (renamed from app/src/debug/res/layout/new_provider_dialog.xml) | 0 | ||||
-rw-r--r-- | app/src/insecure/res/values/strings.xml (renamed from app/src/debug/res/values/strings.xml) | 0 | ||||
-rw-r--r-- | app/src/main/java/de/blinkt/openvpn/LaunchVPN.java | 26 | ||||
-rw-r--r-- | app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java (renamed from app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java) | 0 | ||||
-rw-r--r-- | app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java (renamed from app/src/release/java/se/leap/bitmaskclient/NewProviderDialog.java) | 0 | ||||
-rw-r--r-- | app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java (renamed from app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java) | 0 | ||||
-rw-r--r-- | app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java (renamed from app/src/release/java/se/leap/bitmaskclient/ProviderDetailFragment.java) | 222 | ||||
-rw-r--r-- | app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java (renamed from app/src/release/java/se/leap/bitmaskclient/ProviderListContent.java) | 162 | ||||
-rw-r--r-- | app/src/production/res/layout-xlarge/new_provider_dialog.xml (renamed from app/src/release/res/layout-xlarge/new_provider_dialog.xml) | 0 | ||||
-rw-r--r-- | app/src/production/res/layout/new_provider_dialog.xml (renamed from app/src/release/res/layout/new_provider_dialog.xml) | 0 |
23 files changed, 438 insertions, 413 deletions
diff --git a/app/assets/urls/riseup.url b/app/assets/urls/riseup.url index e250e93f..4c565076 100644 --- a/app/assets/urls/riseup.url +++ b/app/assets/urls/riseup.url @@ -1,4 +1,4 @@ { "main_url" : "https://riseup.net/", - "ca_cert_fingerprint" : "c429750763322fcc20b6402d7b508ba9e754b176" + "ca_cert_fingerprint" : "aef7a642d7f8e046770521b354961a95cd4a76a8" } diff --git a/app/build.gradle b/app/build.gradle index 0f73442c..994f8b7b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'android' -import org.ajoberstar.grgit.Grgit +apply plugin: 'com.android.application' android { compileSdkVersion 21 @@ -14,6 +13,15 @@ android { } } + productFlavors { + production { + + } + insecure { + + } + } + buildTypes { release { //runProguard true @@ -22,9 +30,9 @@ android { } } - lintOptions { - abortOnError false - } + lintOptions { + abortOnError false + } sourceSets { main { diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java index a664c885..f7ab4b1e 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/ConnectionManager.java @@ -16,7 +16,7 @@ public class ConnectionManager { try { method.invoke(conman, enabled); } catch (InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); + //e.printStackTrace(); } } } diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testVpnFragment.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testVpnFragment.java index 106d5cf2..d23be601 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testVpnFragment.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testVpnFragment.java @@ -54,13 +54,28 @@ public class testVpnFragment extends BaseTestDashboard { } public void testVpnEveryProvider() { - String[] providers = {"demo.bitmask.net", "riseup.net", "calyx.net"}; - for(String provider : providers) { - changeProviderAndLogIn(provider); - vpn_controller.sleepSeconds(1); - vpn_controller.turnVpnOndAndOff(provider); - vpn_controller.sleepSeconds(1); - } + testDemoBitmaskNet(); + testRiseupNet(); + testCalyxNet(); + } + + private void testDemoBitmaskNet() { + testProvider("demo.bitmask.net"); + } + + private void testRiseupNet() { + testProvider("riseup.net"); + } + + private void testCalyxNet() { + testProvider("calyx.net"); + } + + private void testProvider(String provider) { + changeProviderAndLogIn(provider); + vpn_controller.sleepSeconds(1); + vpn_controller.turnVpnOndAndOff(provider); + vpn_controller.sleepSeconds(1); } public void testVpnIconIsDisplayed() { diff --git a/app/src/debug/AndroidManifest.xml b/app/src/insecure/AndroidManifest.xml index 523a7ec5..523a7ec5 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/insecure/AndroidManifest.xml diff --git a/app/src/debug/assets/urls/cdev.bitmask.net.url b/app/src/insecure/assets/urls/cdev.bitmask.net.url index 4ceca5ee..4ceca5ee 100644 --- a/app/src/debug/assets/urls/cdev.bitmask.net.url +++ b/app/src/insecure/assets/urls/cdev.bitmask.net.url diff --git a/app/src/debug/assets/urls/dev.bitmask.net.url b/app/src/insecure/assets/urls/dev.bitmask.net.url index a1e53f69..5d4ae485 100644 --- a/app/src/debug/assets/urls/dev.bitmask.net.url +++ b/app/src/insecure/assets/urls/dev.bitmask.net.url @@ -1,3 +1,3 @@ -{
- "main_url" : "https://dev.bitmask.net/"
+{ + "main_url" : "https://dev.bitmask.net/" }
\ No newline at end of file diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java index 2505d37b..2505d37b 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java diff --git a/app/src/debug/java/se/leap/bitmaskclient/NewProviderDialog.java b/app/src/insecure/java/se/leap/bitmaskclient/NewProviderDialog.java index c1426708..c1426708 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/NewProviderDialog.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/NewProviderDialog.java diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java index 2d7e13fe..2d7e13fe 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderAPI.java diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderDetailFragment.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java index bd21f91e..6d9a16cd 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderDetailFragment.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailFragment.java @@ -1,111 +1,111 @@ -package se.leap.bitmaskclient;
-
-import org.json.*;
-
-import se.leap.bitmaskclient.eip.*;
-import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
-
-import android.app.*;
-import android.content.*;
-import android.os.*;
-import android.view.*;
-import android.widget.*;
-
-public class ProviderDetailFragment extends DialogFragment {
-
- final public static String TAG = "providerDetailFragment";
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- try {
-
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null);
-
- JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
-
- final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain);
- domain.setText(provider_json.getString(Provider.DOMAIN));
- final TextView name = (TextView) provider_detail_view.findViewById(R.id.provider_detail_name);
- name.setText(provider_json.getJSONObject(Provider.NAME).getString("en"));
- final TextView description = (TextView) provider_detail_view.findViewById(R.id.provider_detail_description);
- description.setText(provider_json.getJSONObject(Provider.DESCRIPTION).getString("en"));
-
- builder.setView(provider_detail_view);
- builder.setTitle(R.string.provider_details_fragment_title);
-
- if (anon_allowed(provider_json)) {
- builder.setPositiveButton(R.string.use_anonymously_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- interface_with_configuration_wizard.use_anonymously();
- }
- });
- }
-
- if (registration_allowed(provider_json)) {
- builder.setNegativeButton(R.string.signup_or_login_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- interface_with_configuration_wizard.login();
- }
- });
- }
-
- return builder.create();
- } catch (JSONException e) {
- return null;
- }
- }
-
- private boolean anon_allowed(JSONObject provider_json) {
- try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON);
- } catch (JSONException e) {
- return false;
- }
- }
-
- private boolean registration_allowed(JSONObject provider_json) {
- try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Provider.ALLOW_REGISTRATION) && service_description.getBoolean(Provider.ALLOW_REGISTRATION);
- } catch (JSONException e) {
- return false;
- }
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- super.onCancel(dialog);
- SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
- editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
- interface_with_configuration_wizard.showAllProviders();
- }
-
- public static DialogFragment newInstance() {
- ProviderDetailFragment provider_detail_fragment = new ProviderDetailFragment();
- return provider_detail_fragment;
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- try {
- interface_with_configuration_wizard = (ProviderDetailFragmentInterface) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
- + " must implement LogInDialogListener");
- }
- }
-
- public interface ProviderDetailFragmentInterface {
- public void login();
-
- public void use_anonymously();
-
- public void showAllProviders();
- }
-
- ProviderDetailFragmentInterface interface_with_configuration_wizard;
-}
+package se.leap.bitmaskclient; + +import org.json.*; + +import se.leap.bitmaskclient.eip.*; +import se.leap.bitmaskclient.ProviderListContent.ProviderItem; + +import android.app.*; +import android.content.*; +import android.os.*; +import android.view.*; +import android.widget.*; + +public class ProviderDetailFragment extends DialogFragment { + + final public static String TAG = "providerDetailFragment"; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + try { + + LayoutInflater inflater = getActivity().getLayoutInflater(); + View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null); + + JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, "")); + + final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain); + domain.setText(provider_json.getString(Provider.DOMAIN)); + final TextView name = (TextView) provider_detail_view.findViewById(R.id.provider_detail_name); + name.setText(provider_json.getJSONObject(Provider.NAME).getString("en")); + final TextView description = (TextView) provider_detail_view.findViewById(R.id.provider_detail_description); + description.setText(provider_json.getJSONObject(Provider.DESCRIPTION).getString("en")); + + builder.setView(provider_detail_view); + builder.setTitle(R.string.provider_details_fragment_title); + + if (anon_allowed(provider_json)) { + builder.setPositiveButton(R.string.use_anonymously_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + interface_with_configuration_wizard.use_anonymously(); + } + }); + } + + if (registration_allowed(provider_json)) { + builder.setNegativeButton(R.string.signup_or_login_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + interface_with_configuration_wizard.login(); + } + }); + } + + return builder.create(); + } catch (JSONException e) { + return null; + } + } + + private boolean anon_allowed(JSONObject provider_json) { + try { + JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); + return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON); + } catch (JSONException e) { + return false; + } + } + + private boolean registration_allowed(JSONObject provider_json) { + try { + JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); + return service_description.has(Provider.ALLOW_REGISTRATION) && service_description.getBoolean(Provider.ALLOW_REGISTRATION); + } catch (JSONException e) { + return false; + } + } + + @Override + public void onCancel(DialogInterface dialog) { + super.onCancel(dialog); + SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit(); + editor.remove(Provider.KEY).remove(ProviderItem.DANGER_ON).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit(); + interface_with_configuration_wizard.showAllProviders(); + } + + public static DialogFragment newInstance() { + ProviderDetailFragment provider_detail_fragment = new ProviderDetailFragment(); + return provider_detail_fragment; + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + interface_with_configuration_wizard = (ProviderDetailFragmentInterface) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement LogInDialogListener"); + } + } + + public interface ProviderDetailFragmentInterface { + public void login(); + + public void use_anonymously(); + + public void showAllProviders(); + } + + ProviderDetailFragmentInterface interface_with_configuration_wizard; +} diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderListContent.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java index 0a05e839..c8dfc092 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderListContent.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListContent.java @@ -1,82 +1,82 @@ -/**
- * 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 java.util.*;
-import java.net.*;
-
-/**
- * Models the provider list shown in the ConfigurationWizard.
- *
- * @author parmegv
- */
-public class ProviderListContent {
-
- public static List<ProviderItem> ITEMS = new ArrayList<ProviderItem>();
-
- public static Map<String, ProviderItem> ITEM_MAP = new HashMap<String, ProviderItem>();
-
- /**
- * Adds a new provider item to the end of the items map, and to the items list.
- *
- * @param item
- */
- public static void addItem(ProviderItem item) {
- ITEMS.add(item);
- ITEM_MAP.put(String.valueOf(ITEMS.size()), item);
- }
-
- public static void removeItem(ProviderItem item) {
- ITEMS.remove(item);
- ITEM_MAP.remove(item);
- }
-
- /**
- * A provider item.
- */
- public static class ProviderItem {
- final public static String CUSTOM = "custom";
- final public static String DANGER_ON = "danger_on";
- private String provider_main_url;
- private String name;
-
- /**
- * @param name of the provider
- * @param provider_main_url used to download provider.json file of the provider
- */
- public ProviderItem(String name, String provider_main_url) {
- this.name = name;
- this.provider_main_url = provider_main_url;
- }
-
- public String name() {
- return name;
- }
-
- public String providerMainUrl() {
- return provider_main_url;
- }
-
- public String domain() {
- try {
- return new URL(provider_main_url).getHost();
- } catch (MalformedURLException e) {
- return provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("/.*", "");
- }
- }
- }
-}
+/** + * 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 java.util.*; +import java.net.*; + +/** + * Models the provider list shown in the ConfigurationWizard. + * + * @author parmegv + */ +public class ProviderListContent { + + public static List<ProviderItem> ITEMS = new ArrayList<ProviderItem>(); + + public static Map<String, ProviderItem> ITEM_MAP = new HashMap<String, ProviderItem>(); + + /** + * Adds a new provider item to the end of the items map, and to the items list. + * + * @param item + */ + public static void addItem(ProviderItem item) { + ITEMS.add(item); + ITEM_MAP.put(String.valueOf(ITEMS.size()), item); + } + + public static void removeItem(ProviderItem item) { + ITEMS.remove(item); + ITEM_MAP.remove(item); + } + + /** + * A provider item. + */ + public static class ProviderItem { + final public static String CUSTOM = "custom"; + final public static String DANGER_ON = "danger_on"; + private String provider_main_url; + private String name; + + /** + * @param name of the provider + * @param provider_main_url used to download provider.json file of the provider + */ + public ProviderItem(String name, String provider_main_url) { + this.name = name; + this.provider_main_url = provider_main_url; + } + + public String name() { + return name; + } + + public String providerMainUrl() { + return provider_main_url; + } + + public String domain() { + try { + return new URL(provider_main_url).getHost(); + } catch (MalformedURLException e) { + return provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("/.*", ""); + } + } + } +} diff --git a/app/src/debug/res/layout-xlarge/new_provider_dialog.xml b/app/src/insecure/res/layout-xlarge/new_provider_dialog.xml index fc7d84ab..fc7d84ab 100644 --- a/app/src/debug/res/layout-xlarge/new_provider_dialog.xml +++ b/app/src/insecure/res/layout-xlarge/new_provider_dialog.xml diff --git a/app/src/debug/res/layout/new_provider_dialog.xml b/app/src/insecure/res/layout/new_provider_dialog.xml index 19b8f442..19b8f442 100644 --- a/app/src/debug/res/layout/new_provider_dialog.xml +++ b/app/src/insecure/res/layout/new_provider_dialog.xml diff --git a/app/src/debug/res/values/strings.xml b/app/src/insecure/res/values/strings.xml index 3e568115..3e568115 100644 --- a/app/src/debug/res/values/strings.xml +++ b/app/src/insecure/res/values/strings.xml diff --git a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java index f1d769e1..90216a70 100644 --- a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java +++ b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java @@ -121,18 +121,20 @@ public class LaunchVPN extends Activity { super.onActivityResult(requestCode, resultCode, data); if(requestCode==START_VPN_PROFILE) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - boolean showLogWindow = prefs.getBoolean("showlogwindow", true); - - if(!mhideLog && showLogWindow) - showLogWindow(); - new startOpenVpnThread().start(); - } else if (resultCode == Activity.RESULT_CANCELED) { - // User does not want us to start, so we just vanish - VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, - ConnectionStatus.LEVEL_NOTCONNECTED); - - finish(); + if(resultCode == Activity.RESULT_OK) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + boolean showLogWindow = prefs.getBoolean("showlogwindow", true); + + if(!mhideLog && showLogWindow) + showLogWindow(); + new startOpenVpnThread().start(); + } else if (resultCode == Activity.RESULT_CANCELED) { + // User does not want us to start, so we just vanish + VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, + ConnectionStatus.LEVEL_NOTCONNECTED); + + finish(); + } } } diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java index 61c6b7cf..61c6b7cf 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java diff --git a/app/src/release/java/se/leap/bitmaskclient/NewProviderDialog.java b/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java index 1823d3e3..1823d3e3 100644 --- a/app/src/release/java/se/leap/bitmaskclient/NewProviderDialog.java +++ b/app/src/production/java/se/leap/bitmaskclient/NewProviderDialog.java diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java index a3f7db6a..a3f7db6a 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/production/java/se/leap/bitmaskclient/ProviderAPI.java diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderDetailFragment.java b/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java index 24d048a6..08fc5f3d 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderDetailFragment.java +++ b/app/src/production/java/se/leap/bitmaskclient/ProviderDetailFragment.java @@ -1,111 +1,111 @@ -package se.leap.bitmaskclient;
-
-import org.json.*;
-
-import se.leap.bitmaskclient.eip.*;
-import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
-
-import android.app.*;
-import android.content.*;
-import android.os.*;
-import android.view.*;
-import android.widget.*;
-
-public class ProviderDetailFragment extends DialogFragment {
-
- final public static String TAG = "providerDetailFragment";
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- try {
-
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null);
-
- JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, ""));
-
- final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain);
- domain.setText(provider_json.getString(Provider.DOMAIN));
- final TextView name = (TextView) provider_detail_view.findViewById(R.id.provider_detail_name);
- name.setText(provider_json.getJSONObject(Provider.NAME).getString("en"));
- final TextView description = (TextView) provider_detail_view.findViewById(R.id.provider_detail_description);
- description.setText(provider_json.getJSONObject(Provider.DESCRIPTION).getString("en"));
-
- builder.setView(provider_detail_view);
- builder.setTitle(R.string.provider_details_fragment_title);
-
- if (anon_allowed(provider_json)) {
- builder.setPositiveButton(R.string.use_anonymously_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- interface_with_configuration_wizard.use_anonymously();
- }
- });
- }
-
- if (registration_allowed(provider_json)) {
- builder.setNegativeButton(R.string.signup_or_login_button, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- interface_with_configuration_wizard.login();
- }
- });
- }
-
- return builder.create();
- } catch (JSONException e) {
- return null;
- }
- }
-
- private boolean anon_allowed(JSONObject provider_json) {
- try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON);
- } catch (JSONException e) {
- return false;
- }
- }
-
- private boolean registration_allowed(JSONObject provider_json) {
- try {
- JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- return service_description.has(Provider.ALLOW_REGISTRATION) && service_description.getBoolean(Provider.ALLOW_REGISTRATION);
- } catch (JSONException e) {
- return false;
- }
- }
-
- @Override
- public void onCancel(DialogInterface dialog) {
- super.onCancel(dialog);
- SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit();
- editor.remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit();
- interface_with_configuration_wizard.showAllProviders();
- }
-
- public static DialogFragment newInstance() {
- ProviderDetailFragment provider_detail_fragment = new ProviderDetailFragment();
- return provider_detail_fragment;
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- try {
- interface_with_configuration_wizard = (ProviderDetailFragmentInterface) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
- + " must implement LogInDialogListener");
- }
- }
-
- public interface ProviderDetailFragmentInterface {
- public void login();
-
- public void use_anonymously();
-
- public void showAllProviders();
- }
-
- ProviderDetailFragmentInterface interface_with_configuration_wizard;
-}
+package se.leap.bitmaskclient; + +import org.json.*; + +import se.leap.bitmaskclient.eip.*; +import se.leap.bitmaskclient.ProviderListContent.ProviderItem; + +import android.app.*; +import android.content.*; +import android.os.*; +import android.view.*; +import android.widget.*; + +public class ProviderDetailFragment extends DialogFragment { + + final public static String TAG = "providerDetailFragment"; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + try { + + LayoutInflater inflater = getActivity().getLayoutInflater(); + View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null); + + JSONObject provider_json = new JSONObject(getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, getActivity().MODE_PRIVATE).getString(Provider.KEY, "")); + + final TextView domain = (TextView) provider_detail_view.findViewById(R.id.provider_detail_domain); + domain.setText(provider_json.getString(Provider.DOMAIN)); + final TextView name = (TextView) provider_detail_view.findViewById(R.id.provider_detail_name); + name.setText(provider_json.getJSONObject(Provider.NAME).getString("en")); + final TextView description = (TextView) provider_detail_view.findViewById(R.id.provider_detail_description); + description.setText(provider_json.getJSONObject(Provider.DESCRIPTION).getString("en")); + + builder.setView(provider_detail_view); + builder.setTitle(R.string.provider_details_fragment_title); + + if (anon_allowed(provider_json)) { + builder.setPositiveButton(R.string.use_anonymously_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + interface_with_configuration_wizard.use_anonymously(); + } + }); + } + + if (registration_allowed(provider_json)) { + builder.setNegativeButton(R.string.signup_or_login_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + interface_with_configuration_wizard.login(); + } + }); + } + + return builder.create(); + } catch (JSONException e) { + return null; + } + } + + private boolean anon_allowed(JSONObject provider_json) { + try { + JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); + return service_description.has(Constants.ALLOWED_ANON) && service_description.getBoolean(Constants.ALLOWED_ANON); + } catch (JSONException e) { + return false; + } + } + + private boolean registration_allowed(JSONObject provider_json) { + try { + JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); + return service_description.has(Provider.ALLOW_REGISTRATION) && service_description.getBoolean(Provider.ALLOW_REGISTRATION); + } catch (JSONException e) { + return false; + } + } + + @Override + public void onCancel(DialogInterface dialog) { + super.onCancel(dialog); + SharedPreferences.Editor editor = getActivity().getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit(); + editor.remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).commit(); + interface_with_configuration_wizard.showAllProviders(); + } + + public static DialogFragment newInstance() { + ProviderDetailFragment provider_detail_fragment = new ProviderDetailFragment(); + return provider_detail_fragment; + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + interface_with_configuration_wizard = (ProviderDetailFragmentInterface) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement LogInDialogListener"); + } + } + + public interface ProviderDetailFragmentInterface { + public void login(); + + public void use_anonymously(); + + public void showAllProviders(); + } + + ProviderDetailFragmentInterface interface_with_configuration_wizard; +} diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderListContent.java b/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java index 235ae5ab..6466e769 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderListContent.java +++ b/app/src/production/java/se/leap/bitmaskclient/ProviderListContent.java @@ -1,81 +1,81 @@ -/**
- * 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 java.util.*;
-import java.net.*;
-
-/**
- * Models the provider list shown in the ConfigurationWizard.
- *
- * @author parmegv
- */
-public class ProviderListContent {
-
- public static List<ProviderItem> ITEMS = new ArrayList<ProviderItem>();
-
- public static Map<String, ProviderItem> ITEM_MAP = new HashMap<String, ProviderItem>();
-
- /**
- * Adds a new provider item to the end of the items map, and to the items list.
- *
- * @param item
- */
- public static void addItem(ProviderItem item) {
- ITEMS.add(item);
- ITEM_MAP.put(String.valueOf(ITEMS.size()), item);
- }
-
- public static void removeItem(ProviderItem item) {
- ITEMS.remove(item);
- ITEM_MAP.remove(item);
- }
-
- /**
- * A provider item.
- */
- public static class ProviderItem {
- final public static String CUSTOM = "custom";
- private String provider_main_url;
- private String name;
-
- /**
- * @param name of the provider
- * @param provider_main_url used to download provider.json file of the provider
- */
- public ProviderItem(String name, String provider_main_url) {
- this.name = name;
- this.provider_main_url = provider_main_url;
- }
-
- public String name() {
- return name;
- }
-
- public String providerMainUrl() {
- return provider_main_url;
- }
-
- public String domain() {
- try {
- return new URL(provider_main_url).getHost();
- } catch (MalformedURLException e) {
- return provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("/.*", "");
- }
- }
- }
-}
+/** + * 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 java.util.*; +import java.net.*; + +/** + * Models the provider list shown in the ConfigurationWizard. + * + * @author parmegv + */ +public class ProviderListContent { + + public static List<ProviderItem> ITEMS = new ArrayList<ProviderItem>(); + + public static Map<String, ProviderItem> ITEM_MAP = new HashMap<String, ProviderItem>(); + + /** + * Adds a new provider item to the end of the items map, and to the items list. + * + * @param item + */ + public static void addItem(ProviderItem item) { + ITEMS.add(item); + ITEM_MAP.put(String.valueOf(ITEMS.size()), item); + } + + public static void removeItem(ProviderItem item) { + ITEMS.remove(item); + ITEM_MAP.remove(item); + } + + /** + * A provider item. + */ + public static class ProviderItem { + final public static String CUSTOM = "custom"; + private String provider_main_url; + private String name; + + /** + * @param name of the provider + * @param provider_main_url used to download provider.json file of the provider + */ + public ProviderItem(String name, String provider_main_url) { + this.name = name; + this.provider_main_url = provider_main_url; + } + + public String name() { + return name; + } + + public String providerMainUrl() { + return provider_main_url; + } + + public String domain() { + try { + return new URL(provider_main_url).getHost(); + } catch (MalformedURLException e) { + return provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("/.*", ""); + } + } + } +} diff --git a/app/src/release/res/layout-xlarge/new_provider_dialog.xml b/app/src/production/res/layout-xlarge/new_provider_dialog.xml index 12616625..12616625 100644 --- a/app/src/release/res/layout-xlarge/new_provider_dialog.xml +++ b/app/src/production/res/layout-xlarge/new_provider_dialog.xml diff --git a/app/src/release/res/layout/new_provider_dialog.xml b/app/src/production/res/layout/new_provider_dialog.xml index 36eb0d6a..36eb0d6a 100644 --- a/app/src/release/res/layout/new_provider_dialog.xml +++ b/app/src/production/res/layout/new_provider_dialog.xml |