From 8ebea084e117365c4b7a9c10e56aaaceabcd43b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Fri, 4 Jul 2014 10:33:27 +0200 Subject: Change the name of the gateway to its location. This way, the notification shows the city of the gateway rather than the hostname :) --- app/src/main/java/se/leap/bitmaskclient/EIP.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java index 75c6ada8..01b7d827 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java @@ -369,7 +369,7 @@ public final class EIP extends IntentService { for (int i = 0; i < gateways.length(); i++) { JSONObject gw = gateways.getJSONObject(i); if ( gw.getString("location").equalsIgnoreCase(closestLocation) || closestLocation.isEmpty()){ - chosenHost = gw.getString("host"); + chosenHost = eipDefinition.getJSONObject("locations").getJSONObject(gw.getString("location")).getString("name"); break; } } @@ -480,7 +480,6 @@ public final class EIP extends IntentService { private void loadVpnProfile() { ProfileManager vpl = ProfileManager.getInstance(context); - try { if ( mName == null ) mVpnProfile = vpl.getProfiles().iterator().next(); @@ -510,8 +509,10 @@ public final class EIP extends IntentService { Collection profiles = vpl.getProfiles(); for (Iterator it = profiles.iterator(); it.hasNext(); ){ VpnProfile p = it.next(); + try { - if ( p.mName.equalsIgnoreCase( gateway.getString("host") ) ){ + String name = eipDefinition.getJSONObject("locations").getJSONObject(mGateway.getString("location")).getString("name"); + if ( p.mName.equalsIgnoreCase( name ) ) { it.remove(); vpl.removeProfile(context, p); } @@ -548,7 +549,9 @@ public final class EIP extends IntentService { newname = getString(R.string.converted_profile_i,i); } + newname = eipDefinition.getJSONObject("locations").getJSONObject(mGateway.getString("location")).getString("name"); mVpnProfile.mName=newname; + mName = newname; } catch (JSONException e) { // TODO Auto-generated catch block Log.v(TAG,"Couldn't read gateway name for profile creation!"); -- cgit v1.2.3