summaryrefslogtreecommitdiff
path: root/remoteExample/src/main/java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2026-01-30 13:20:36 +0100
committerArne Schwabe <arne@rfc2549.org>2026-01-30 17:13:39 +0100
commit040eb6067528361ad444270900d26317f94c2463 (patch)
treea65e51195747d93a206ff03e4d7a9a7f8ceb2e2f /remoteExample/src/main/java
parent1f1dae89983ed10b7913638e2153d4d3bcb3ac75 (diff)
Update gradle/AGP version
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Diffstat (limited to 'remoteExample/src/main/java')
-rw-r--r--remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java110
1 files changed, 49 insertions, 61 deletions
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 c4e92f27..50954558 100644
--- a/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java
+++ b/remoteExample/src/main/java/de/blinkt/openvpn/remote/MainFragment.java
@@ -242,70 +242,58 @@ public class MainFragment extends Fragment implements View.OnClickListener, Hand
Toast.makeText(getActivity(), "No service connection to OpenVPN for Android. App not installed?", Toast.LENGTH_LONG).show();
return;
}
- switch (v.getId()) {
- case R.id.startVPN:
- try {
- prepareStartProfile(START_PROFILE_BYUUID);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- break;
- case R.id.disconnect:
- try {
- mService.disconnect();
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- break;
- case R.id.setDefaultProfile:
- try {
- prepareStartProfile(SET_DEFAULT_PROFILE_BYUUID);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- break;
- case R.id.getMyIP:
-
- // Socket handling is not allowed on main thread
- new Thread() {
-
- @Override
- public void run() {
- try {
- String myip = getMyOwnIP();
- Message msg = Message.obtain(mHandler,MSG_UPDATE_MYIP,myip);
- msg.sendToTarget();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+ int id = v.getId();
+ if (id == R.id.startVPN) {
+ try {
+ prepareStartProfile(START_PROFILE_BYUUID);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ } else if (id == R.id.disconnect) {
+ try {
+ mService.disconnect();
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (id == R.id.setDefaultProfile) {
+ try {
+ prepareStartProfile(SET_DEFAULT_PROFILE_BYUUID);
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (id == R.id.getMyIP) {// Socket handling is not allowed on main thread
+ new Thread() {
+
+ @Override
+ public void run() {
+ try {
+ String myip = getMyOwnIP();
+ Message msg = Message.obtain(mHandler, MSG_UPDATE_MYIP, myip);
+ msg.sendToTarget();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- }.start();
- break;
- case R.id.startembedded:
- try {
- prepareStartProfile(START_PROFILE_EMBEDDED);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- break;
-
- case R.id.addNewProfile:
- case R.id.addNewProfileEdit:
- int action = (v.getId() == R.id.addNewProfile) ? PROFILE_ADD_NEW : PROFILE_ADD_NEW_EDIT;
- try {
- prepareStartProfile(action);
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- default:
- break;
+ }.start();
+ } else if (id == R.id.startembedded) {
+ try {
+ prepareStartProfile(START_PROFILE_EMBEDDED);
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (id == R.id.addNewProfile || id == R.id.addNewProfileEdit) {
+ int action = (v.getId() == R.id.addNewProfile) ? PROFILE_ADD_NEW : PROFILE_ADD_NEW_EDIT;
+ try {
+ prepareStartProfile(action);
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
}