diff options
| -rw-r--r-- | main/build.gradle | 4 | ||||
| -rw-r--r-- | main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java | 25 | ||||
| -rw-r--r-- | remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java | 5 | 
3 files changed, 28 insertions, 6 deletions
| diff --git a/main/build.gradle b/main/build.gradle index 750c3eb9..58565e73 100644 --- a/main/build.gradle +++ b/main/build.gradle @@ -20,8 +20,8 @@ android {      defaultConfig {          minSdkVersion 14          targetSdkVersion 21 -        versionCode = 100 -        versionName = "0.6.19" +        versionCode = 101 +        versionName = "0.6.20"      }      sourceSets { diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java index d1cdafc7..4b07c7ab 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java @@ -22,6 +22,8 @@ import android.content.pm.PackageManager;  import android.content.pm.PackageManager.NameNotFoundException;
  import android.net.VpnService;
  import android.os.*;
 +
 +import de.blinkt.openvpn.LaunchVPN;
  import de.blinkt.openvpn.R;
  import de.blinkt.openvpn.VpnProfile;
  import de.blinkt.openvpn.core.ConfigParser;
 @@ -112,12 +114,30 @@ public class ExternalOpenVPNService extends Service implements StateListener {              return profiles;
          }
 +
 +        private void startProfile(VpnProfile vp)
 +        {
 +            Intent vpnPermissionIntent = VpnService.prepare(ExternalOpenVPNService.this);
 +            /* Check if we need to show the confirmation dialog */
 +            if(vpnPermissionIntent != null){
 +                Intent shortVPNIntent = new Intent(Intent.ACTION_MAIN);
 +                shortVPNIntent.setClass(getBaseContext(), de.blinkt.openvpn.LaunchVPN.class);
 +                shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_KEY, vp.getUUIDString());
 +                shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_HIDELOG, true);
 +                shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 +                startActivity(shortVPNIntent);
 +            } else {
 +                VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
 +            }
 +
 +        }
 +
          @Override
          public void startProfile(String profileUUID) throws RemoteException {
              checkOpenVPNPermission();
              VpnProfile vp = ProfileManager.get(getBaseContext(), profileUUID);
 -            VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
 +            startProfile(vp);
          }
          public void startVPN(String inlineconfig) throws RemoteException {
 @@ -132,8 +152,7 @@ public class ExternalOpenVPNService extends Service implements StateListener {                  ProfileManager.setTemporaryProfile(vp);
 -                VPNLaunchHelper.startOpenVpn(vp, getBaseContext());
 -
 +                startProfile(vp);
              } catch (IOException e) {
                  throw new RemoteException(e.getMessage());
 diff --git a/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java b/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java index 2ea37861..0bb634aa 100644 --- a/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java +++ b/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java @@ -168,10 +168,13 @@ public class MainFragment extends Fragment implements View.OnClickListener, Hand          try {              List<APIVpnProfile> list = mService.getProfiles();              String all="List:"; -            for(APIVpnProfile vp:list) { +            for(APIVpnProfile vp:list.subList(0, Math.min(5, list.size()))) {                  all = all + vp.mName + ":" + vp.mUUID + "\n";              } +            if (list.size() > 5) +                all +="\n And some profiles...."; +              if(list.size()> 0) {                  Button b= mStartVpn;                  b.setOnClickListener(this); | 
