diff options
author | Fup Duck <fupduck@sacknagel.com> | 2018-01-13 16:53:54 +0100 |
---|---|---|
committer | Fup Duck <fupduck@sacknagel.com> | 2018-01-13 16:53:54 +0100 |
commit | 1690dec51d78a27a6a1f7c83d30b28d1ab432f93 (patch) | |
tree | 40d6011b575615a671edbd3881949b2bbf480e64 /app | |
parent | 5d5d6ae8aeafbba407b9a4cf5985a1cdc1cf2904 (diff) |
static constant imports
Diffstat (limited to 'app')
5 files changed, 28 insertions, 12 deletions
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailActivity.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailActivity.java index 8de97420..6977753f 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailActivity.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderDetailActivity.java @@ -2,12 +2,15 @@ package se.leap.bitmaskclient; import android.content.SharedPreferences; +import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS; +import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; + public class ProviderDetailActivity extends AbstractProviderDetailActivity { @Override public void onBackPressed() { SharedPreferences.Editor editor = preferences.edit(); - editor.remove(Provider.KEY).remove(ProviderListContent.ProviderItem.DANGER_ON).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); + editor.remove(Provider.KEY).remove(ProviderListContent.ProviderItem.DANGER_ON).remove(PROVIDER_ALLOW_ANONYMOUS).remove(PROVIDER_KEY).apply(); super.onBackPressed(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java index c180e43a..a92f8f96 100644 --- a/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/AbstractProviderDetailActivity.java @@ -18,6 +18,10 @@ import java.util.ArrayList; import butterknife.InjectView; +import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS; +import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; + public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity { final public static String TAG = "providerDetailActivity"; @@ -40,7 +44,7 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity super.onCreate(savedInstanceState); setContentView(R.layout.provider_detail_fragment); - preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE); + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); try { JSONObject providerJson = new JSONObject(preferences.getString(Provider.KEY, "")); domain.setText(providerJson.getString(Provider.DOMAIN)); @@ -92,7 +96,7 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity private boolean anonAllowed(JSONObject providerJson) { try { JSONObject serviceDescription = providerJson.getJSONObject(Provider.SERVICE); - return serviceDescription.has(Constants.PROVIDER_ALLOW_ANONYMOUS) && serviceDescription.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS); + return serviceDescription.has(PROVIDER_ALLOW_ANONYMOUS) && serviceDescription.getBoolean(PROVIDER_ALLOW_ANONYMOUS); } catch (JSONException e) { return false; } @@ -110,7 +114,7 @@ public abstract class AbstractProviderDetailActivity extends ButterKnifeActivity @Override public void onBackPressed() { SharedPreferences.Editor editor = preferences.edit(); - editor.remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); + editor.remove(Provider.KEY).remove(PROVIDER_ALLOW_ANONYMOUS).remove(PROVIDER_KEY).apply(); super.onBackPressed(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 915e948a..1c29a10a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -54,6 +54,10 @@ import se.leap.bitmaskclient.fragments.AboutFragment; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; +import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT; +import static se.leap.bitmaskclient.Constants.PROVIDER_ALLOW_ANONYMOUS; +import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.ProviderAPI.ERRORS; /** @@ -132,7 +136,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE); + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager()); providerManager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null)); @@ -210,7 +214,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity e.printStackTrace(); } - if (preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false)) { + if (preferences.getBoolean(PROVIDER_ALLOW_ANONYMOUS, false)) { mConfigState.putExtra(SERVICES_RETRIEVED, true); downloadVpnCertificate(); @@ -288,7 +292,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity hideProgressBar(); mConfigState.setAction(PROVIDER_NOT_SET); adapter.showAllProviders(); - preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); + preferences.edit().remove(Provider.KEY).remove(PROVIDER_ALLOW_ANONYMOUS).remove(PROVIDER_KEY).apply(); } @Override @@ -307,7 +311,7 @@ public abstract class BaseConfigurationWizard extends ButterKnifeActivity private void askDashboardToQuitApp() { Intent askQuit = new Intent(); - askQuit.putExtra(Constants.APP_ACTION_QUIT, Constants.APP_ACTION_QUIT); + askQuit.putExtra(APP_ACTION_QUIT, APP_ACTION_QUIT); setResult(RESULT_CANCELED, askQuit); } diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java index 82a193e7..24145864 100644 --- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java @@ -23,6 +23,8 @@ import se.leap.bitmaskclient.userstatus.SessionDialog; import se.leap.bitmaskclient.userstatus.User; import se.leap.bitmaskclient.userstatus.UserStatusFragment; +import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; + public class MainActivity extends AppCompatActivity { @@ -53,7 +55,7 @@ public class MainActivity extends AppCompatActivity { mTitle = getTitle(); fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager()); - preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE); + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java index 614c6b8d..43d7f152 100644 --- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java @@ -15,6 +15,9 @@ import java.lang.annotation.RetentionPolicy; import de.blinkt.openvpn.core.VpnStatus; import se.leap.bitmaskclient.userstatus.User; +import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION; +import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; + /** * Activity shown at startup. Evaluates if App is started for the first time or has been upgraded * and acts and calls another activity accordingly. @@ -39,7 +42,7 @@ public class StartActivity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE); + preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); Log.d(TAG, "Started"); @@ -81,7 +84,7 @@ public class StartActivity extends Activity { private int checkAppStart() { try { versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; - previousVersionCode = preferences.getInt(Constants.PREFERENCES_APP_VERSION, -1); + previousVersionCode = preferences.getInt(PREFERENCES_APP_VERSION, -1); // versions do match -> normal start if (versionCode == previousVersionCode) { @@ -135,7 +138,7 @@ public class StartActivity extends Activity { } private void storeAppVersion() { - preferences.edit().putInt(Constants.PREFERENCES_APP_VERSION, versionCode).apply(); + preferences.edit().putInt(PREFERENCES_APP_VERSION, versionCode).apply(); } } |