summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OkHttpClientGenerator.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java8
4 files changed, 22 insertions, 10 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/OkHttpClientGenerator.java b/app/src/main/java/se/leap/bitmaskclient/OkHttpClientGenerator.java
index 7d1054f1..69270140 100644
--- a/app/src/main/java/se/leap/bitmaskclient/OkHttpClientGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/OkHttpClientGenerator.java
@@ -52,7 +52,7 @@ import static se.leap.bitmaskclient.R.string.error_io_exception_user_message;
import static se.leap.bitmaskclient.R.string.error_no_such_algorithm_exception_user_message;
import static se.leap.bitmaskclient.R.string.keyChainAccessError;
import static se.leap.bitmaskclient.R.string.server_unreachable_message;
-import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert;
+import static se.leap.bitmaskclient.utils.ConfigHelper.getProviderFormattedString;
/**
* Created by cyberta on 08.01.18.
@@ -92,7 +92,7 @@ public class OkHttpClientGenerator {
} catch (IllegalArgumentException e) {
e.printStackTrace();
// TODO ca cert is invalid - show better error ?!
- addErrorMessageToJson(initError, resources.getString(certificate_error));
+ addErrorMessageToJson(initError, getProviderFormattedString(resources, certificate_error));
} catch (IllegalStateException | KeyManagementException | KeyStoreException e) {
e.printStackTrace();
addErrorMessageToJson(initError, String.format(resources.getString(keyChainAccessError), e.getLocalizedMessage()));
@@ -102,7 +102,7 @@ public class OkHttpClientGenerator {
} catch (CertificateException e) {
e.printStackTrace();
// TODO ca cert is invalid - show better error ?!
- addErrorMessageToJson(initError, resources.getString(certificate_error));
+ addErrorMessageToJson(initError, getProviderFormattedString(resources, certificate_error));
} catch (UnknownHostException e) {
e.printStackTrace();
addErrorMessageToJson(initError, resources.getString(server_unreachable_message));
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
index 15c7457e..37adbe93 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
@@ -107,6 +107,7 @@ import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_details;
import static se.leap.bitmaskclient.R.string.warning_expired_provider_cert;
import static se.leap.bitmaskclient.utils.ConfigHelper.getFingerprintFromCertificate;
+import static se.leap.bitmaskclient.utils.ConfigHelper.getProviderFormattedString;
import static se.leap.bitmaskclient.utils.ConfigHelper.parseRsaKeyFromString;
import static se.leap.bitmaskclient.utils.PreferenceHelper.deleteProviderDetailsFromPreferences;
import static se.leap.bitmaskclient.utils.PreferenceHelper.getFromPersistedProvider;
@@ -237,8 +238,8 @@ public abstract class ProviderApiManagerBase {
deleteProviderDetailsFromPreferences(preferences, provider.getDomain());
}
- String formatErrorMessage(final int toastStringId) {
- return formatErrorMessage(resources.getString(toastStringId));
+ String formatErrorMessage(final int errorStringId) {
+ return formatErrorMessage(getProviderFormattedString(resources, errorStringId));
}
private String formatErrorMessage(String errorMessage) {
@@ -751,10 +752,11 @@ public abstract class ProviderApiManagerBase {
Bundle setErrorResult(Bundle result, int errorMessageId, String errorId) {
JSONObject errorJson = new JSONObject();
+ String errorMessage = getProviderFormattedString(resources, errorMessageId);
if (errorId != null) {
- addErrorMessageToJson(errorJson, resources.getString(errorMessageId), errorId);
+ addErrorMessageToJson(errorJson, errorMessage, errorId);
} else {
- addErrorMessageToJson(errorJson, resources.getString(errorMessageId));
+ addErrorMessageToJson(errorJson, errorMessage);
}
result.putString(ERRORS, errorJson.toString());
result.putBoolean(BROADCAST_RESULT_KEY, false);
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
index a896197c..f6e3df7c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -40,6 +40,7 @@ import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_BLOCKING_VPN;
import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP_BLOCKING_VPN;
import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.utils.ConfigHelper.getProviderFormattedString;
public class VoidVpnService extends VpnService implements Observer, VpnNotificationManager.VpnServiceCallback {
@@ -147,7 +148,7 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
private void establishBlockingVpn() {
try {
- VpnStatus.logInfo(getString(R.string.void_vpn_establish));
+ VpnStatus.logInfo(getProviderFormattedString(getResources(), R.string.void_vpn_establish));
VpnStatus.updateStateString(STATE_ESTABLISH, "",
R.string.void_vpn_establish, ConnectionStatus.LEVEL_BLOCKING);
Builder builder = prepareBlockingVpnProfile();
@@ -180,9 +181,10 @@ public class VoidVpnService extends VpnService implements Observer, VpnNotificat
}
if (eipStatus.isBlockingVpnEstablished()) {
+ String blockingMessage = getProviderFormattedString(getResources(), eipStatus.getLocalizedResId());
notificationManager.buildVoidVpnNotification(
- getString(eipStatus.getLocalizedResId()),
- getString(eipStatus.getLocalizedResId()),
+ blockingMessage,
+ blockingMessage,
eipStatus.getLevel());
} else {
notificationManager.stopNotifications(NOTIFICATION_CHANNEL_NEWSTATUS_ID);
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java
index d1ac0eb3..da74c7c4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/utils/ConfigHelper.java
@@ -17,8 +17,10 @@
package se.leap.bitmaskclient.utils;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Looper;
import android.support.annotation.NonNull;
+import android.support.annotation.StringRes;
import org.json.JSONException;
import org.json.JSONObject;
@@ -43,6 +45,7 @@ import java.util.Calendar;
import se.leap.bitmaskclient.BuildConfig;
import se.leap.bitmaskclient.ProviderAPI;
+import se.leap.bitmaskclient.R;
import static se.leap.bitmaskclient.Constants.DEFAULT_BITMASK;
@@ -182,4 +185,9 @@ public class ConfigHelper {
public static int getCurrentTimezone() {
return Calendar.getInstance().get(Calendar.ZONE_OFFSET) / 3600000;
}
+
+ public static String getProviderFormattedString(Resources resources, @StringRes int resourceId) {
+ String appName = resources.getString(R.string.app_name);
+ return resources.getString(resourceId, appName);
+ }
}