summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2017-11-23 11:34:52 +0100
committerFup Duck <fupduck@sacknagel.com>2017-11-24 12:26:55 +0100
commit38796aeb892379b8c2b7e4e1d7af00c4c050e8dc (patch)
tree5149eb015674db51a2be97faa6bfdf70ce3d0700 /app/src/main/java/se/leap/bitmaskclient/Dashboard.java
parentf19e355b2e53af5d76880bb7450137c4c9a2e227 (diff)
Add Splash StartActivity
* added Splash StartActivity to handle updates and initialization * created global Constants * renamed EIP Constants
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/Dashboard.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java41
1 files changed, 8 insertions, 33 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 3f1663d0..e2366551 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -1,20 +1,4 @@
-/**
- * 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/>.
- */
-/**
+/*
* Copyright (c) 2013 LEAP Encryption Access Project and contributers
*
* This program is free software: you can redistribute it and/or modify
@@ -57,8 +41,7 @@ import java.net.URL;
import butterknife.ButterKnife;
import butterknife.InjectView;
-import de.blinkt.openvpn.core.VpnStatus;
-import se.leap.bitmaskclient.eip.Constants;
+import se.leap.bitmaskclient.eip.EIPConstants;
import se.leap.bitmaskclient.userstatus.SessionDialog;
import se.leap.bitmaskclient.userstatus.User;
import se.leap.bitmaskclient.userstatus.UserStatusFragment;
@@ -76,7 +59,6 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
protected static final int SWITCH_PROVIDER = 1;
public static final String TAG = Dashboard.class.getSimpleName();
- public static final String SHARED_PREFERENCES = "LEAPPreferences";
public static final String ACTION_QUIT = "quit";
public static final String ACTION_ASK_TO_CANCEL_VPN = "ask to cancel vpn";
public static final String REQUEST_CODE = "request_code";
@@ -84,7 +66,6 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
public static final String START_ON_BOOT = "dashboard start on boot";
//FIXME: remove OR FIX ON_BOOT
public static final String ON_BOOT = "dashboard on boot";
- public static final String APP_VERSION = "bitmask version";
private static Context app;
protected static SharedPreferences preferences;
@@ -102,18 +83,14 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
fragment_manager = new FragmentManagerEnhanced(getFragmentManager());
- ProviderAPICommand.initialize(this);
providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler(), this);
if (app == null) {
app = this;
-
- VpnStatus.initLogCache(getApplicationContext().getCacheDir());
handleVersion();
- User.init(getString(R.string.default_username));
}
boolean provider_exists = previousProviderExists(savedInstanceState);
if (provider_exists) {
@@ -154,7 +131,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
private boolean providerInSharedPreferences() {
return preferences != null &&
- preferences.getBoolean(Constants.PROVIDER_CONFIGURED, false);
+ preferences.getBoolean(EIPConstants.PROVIDER_CONFIGURED, false);
}
@@ -179,13 +156,11 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
private void handleVersion() {
try {
int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
- int lastDetectedVersion = preferences.getInt(APP_VERSION, 0);
- preferences.edit().putInt(APP_VERSION, versionCode).apply();
switch (versionCode) {
case 91: // 0.6.0 without Bug #5999
case 101: // 0.8.0
- if (!preferences.getString(Constants.KEY, "").isEmpty())
+ if (!preferences.getString(EIPConstants.KEY, "").isEmpty())
eip_fragment.updateEipService();
break;
}
@@ -230,7 +205,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
@SuppressLint("CommitPrefEdits")
private void providerToPreferences(Provider provider) {
- preferences.edit().putBoolean(Constants.PROVIDER_CONFIGURED, true).commit();
+ preferences.edit().putBoolean(EIPConstants.PROVIDER_CONFIGURED, true).commit();
preferences.edit().putString(Provider.MAIN_URL, provider.mainUrl().toString()).apply();
preferences.edit().putString(Provider.KEY, provider.definition().toString()).apply();
}
@@ -250,7 +225,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
.setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_CONFIGURED).apply();
+ preferences.edit().remove(Provider.KEY).remove(EIPConstants.PROVIDER_CONFIGURED).apply();
finish();
}
})
@@ -341,7 +316,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
public void downloadVpnCertificate() {
boolean is_authenticated = User.loggedIn();
- boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false);
+ boolean allowed_anon = preferences.getBoolean(EIPConstants.ALLOWED_ANON, false);
if (allowed_anon || is_authenticated)
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE, providerAPI_result_receiver);
else