summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorkwadronaut <kwadronaut@leap.se>2016-09-19 12:38:29 +0200
committerkwadronaut <kwadronaut@leap.se>2016-09-19 12:38:29 +0200
commitf9c44da143a2d29baac6260c2e5caf9a96dacbc3 (patch)
treec2435766b6a8d7ddd70f2a0dcfc501a7d93c45f4 /app/src/main/java/se/leap
parent00ebc6d66ff9e8a0fa01b808ce7dbd0335933baf (diff)
parent56ba118a5713fe0e24120815cd28db141709a497 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java73
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VpnFragment.java5
2 files changed, 56 insertions, 22 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index bdc36e89..dbdf0a51 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -14,6 +14,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * 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.annotation.*;
@@ -31,6 +47,7 @@ import org.json.*;
import java.net.*;
import butterknife.*;
+import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.eip.*;
import se.leap.bitmaskclient.userstatus.*;
@@ -71,35 +88,55 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- app = this;
-
- PRNGFixes.apply();
-
preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
- handleVersion();
- User.init(getString(R.string.default_username));
ProviderAPICommand.initialize(this);
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
- restoreProvider(savedInstanceState);
- if (!provider.isConfigured())
+ if (app == null) {
+ app = this;
+
+ PRNGFixes.apply();
+ VpnStatus.initLogCache(getApplicationContext().getCacheDir());
+ handleVersion();
+ User.init(getString(R.string.default_username));
+ }
+ boolean provider_exists = previousProviderExists(savedInstanceState);
+ if (provider_exists) {
+ provider = getProvider(savedInstanceState);
+ if(!provider.isConfigured())
+ startActivityForResult(new Intent(this, ConfigurationWizard.class), CONFIGURE_LEAP);
+ else {
+ buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false));
+ user_status_fragment.restoreSessionStatus(savedInstanceState);
+ }
+ } else {
startActivityForResult(new Intent(this, ConfigurationWizard.class), CONFIGURE_LEAP);
- else {
- buildDashboard(getIntent().getBooleanExtra(ON_BOOT, false));
- user_status_fragment.restoreSessionStatus(savedInstanceState);
}
}
- private void restoreProvider(Bundle savedInstanceState) {
- if (savedInstanceState != null) {
- if (savedInstanceState.containsKey(Provider.KEY))
- provider = savedInstanceState.getParcelable(Provider.KEY);
- }
- if (!provider.isConfigured() && preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false))
+ private boolean previousProviderExists(Bundle savedInstanceState) {
+ return providerInSavedInstance(savedInstanceState) || providerInSharedPreferences();
+ }
+
+ private Provider getProvider(Bundle savedInstanceState) {
+ if(providerInSavedInstance(savedInstanceState))
+ provider = savedInstanceState.getParcelable(Provider.KEY);
+ else if (providerInSharedPreferences())
provider = getSavedProviderFromSharedPreferences();
+ return provider;
+ }
+
+ private boolean providerInSavedInstance(Bundle savedInstanceState) {
+ return savedInstanceState != null &&
+ savedInstanceState.containsKey(Provider.KEY);
+ }
+
+ private boolean providerInSharedPreferences() {
+ return preferences != null &&
+ preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false);
+
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
index 2e3d7524..9210c6ec 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
@@ -244,10 +244,7 @@ public class VpnFragment extends Fragment implements Observer {
Context context = dashboard.getApplicationContext();
String error = eip_status.lastError(5, context);
- if (!error.isEmpty()) {
- dashboard.showLog();
- VoidVpnService.stop();
- }
+ if (!error.isEmpty()) VoidVpnService.stop();
updateIcon();
updateButton();
}