--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 Tobias Brunner
+ Hochschule fuer Technik Rapperswil
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/vpn_state_background"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20dp"
+ android:layout_marginRight="20dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginBottom="10dp"
+ android:orientation="horizontal" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="5dp"
+ android:text="@string/imc_state_label"
+ android:textColor="?android:textColorPrimary"
+ android:textSize="20sp" />
+
+ <TextView
+ android:id="@+id/imc_state"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:textColor="?android:textColorSecondary"
+ android:textSize="20sp" />
+
+ </LinearLayout>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="2dp"
+ android:background="?android:attr/listDivider" />
+
+</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012-2013 Tobias Brunner
Hochschule fuer Technik Rapperswil
This program is free software; you can redistribute it and/or modify it
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+ <fragment
+ class="org.strongswan.android.ui.ImcStateFragment"
+ android:id="@+id/imc_state_frag"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
<fragment
class="org.strongswan.android.ui.VpnProfileListFragment"
android:id="@+id/profile_list_frag"
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012-2013 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
Hochschule fuer Technik Rapperswil
<string name="state_disabled">Kein aktives Profil</string>
<string name="state_error">Fehler</string>
+ <!-- IMC state fragment -->
+ <string name="imc_state_label">Assessment:</string>
+ <string name="imc_state_isolate">Eingeschränkt</string>
+ <string name="imc_state_block">Fehlgeschlagen</string>
+
<!-- Dialogs -->
<string name="login_title">Passwort eingeben um zu verbinden</string>
<string name="login_confirm">Verbinden</string>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Giuliano Grassi
- Copyright (C) 2012 Ralf Sager
Copyright (C) 2012 Andreas Steffen
HSR Hochschule fuer Technik Rapperswil
<string name="state_disabled">Brak aktywnego VPN</string>
<string name="state_error">Błąd</string>
+ <!-- IMC state fragment -->
+ <string name="imc_state_label">Assessment:</string>
+ <string name="imc_state_isolate">Restricted</string>
+ <string name="imc_state_block">Failed</string>
+
<!-- Dialogs -->
<string name="login_title">Wprowadż hasło</string>
<string name="login_confirm">Połącz</string>
<string name="state_disabled">Нет активных VPN</string>
<string name="state_error">Ошибка</string>
+ <!-- IMC state fragment -->
+ <string name="imc_state_label">Assessment:</string>
+ <string name="imc_state_isolate">Restricted</string>
+ <string name="imc_state_block">Failed</string>
+
<!-- Dialogs -->
<string name="login_title">Введите пароль для соединения</string>
<string name="login_confirm">Соединить</string>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Dmitry Korzhevin
Copyright (C) 2013 Pavel Kopchyk
+ Copyright (C) 2012 Dmitry Korzhevin
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
<string name="state_disabled">Немає активних VPN</string>
<string name="state_error">Помилка</string>
+ <!-- IMC state fragment -->
+ <string name="imc_state_label">Assessment:</string>
+ <string name="imc_state_isolate">Restricted</string>
+ <string name="imc_state_block">Failed</string>
+
<!-- Dialogs -->
<string name="login_title">Введіть пароль для з\'єднання</string>
<string name="login_confirm">Підключити</string>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012-2013 Tobias Brunner
Hochschule fuer Technik Rapperswil
This program is free software; you can redistribute it and/or modify it
<color
name="error_text">#D9192C</color>
+ <color
+ name="warning_text">#FF9909</color>
+
<color
name="success_text">#99CC00</color>
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012 Tobias Brunner
+ Copyright (C) 2012-2013 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
Hochschule fuer Technik Rapperswil
<string name="state_disabled">No active VPN</string>
<string name="state_error">Error</string>
+ <!-- IMC state fragment -->
+ <string name="imc_state_label">Assessment:</string>
+ <string name="imc_state_isolate">Restricted</string>
+ <string name="imc_state_block">Failed</string>
+
<!-- Dialogs -->
<string name="login_title">Enter password to connect</string>
<string name="login_confirm">Connect</string>
--- /dev/null
+/*
+ * Copyright (C) 2013 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+package org.strongswan.android.ui;
+
+import org.strongswan.android.R;
+import org.strongswan.android.logic.VpnStateService;
+import org.strongswan.android.logic.VpnStateService.VpnStateListener;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.app.Service;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+public class ImcStateFragment extends Fragment implements VpnStateListener
+{
+ private TextView mStateView;
+ private VpnStateService mService;
+ private final ServiceConnection mServiceConnection = new ServiceConnection() {
+ @Override
+ public void onServiceDisconnected(ComponentName name)
+ {
+ mService = null;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service)
+ {
+ mService = ((VpnStateService.LocalBinder)service).getService();
+ mService.registerListener(ImcStateFragment.this);
+ updateView();
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ /* bind to the service only seems to work from the ApplicationContext */
+ Context context = getActivity().getApplicationContext();
+ context.bindService(new Intent(context, VpnStateService.class),
+ mServiceConnection, Service.BIND_AUTO_CREATE);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState)
+ {
+ View view = inflater.inflate(R.layout.imc_state_fragment, null);
+
+ mStateView = (TextView)view.findViewById(R.id.imc_state);
+
+ return view;
+ }
+
+ @Override
+ public void onDestroy()
+ {
+ super.onDestroy();
+ if (mService != null)
+ {
+ mService.unregisterListener(this);
+ getActivity().getApplicationContext().unbindService(mServiceConnection);
+ }
+ }
+
+ @Override
+ public void stateChanged()
+ {
+ updateView();
+ }
+
+ public void updateView()
+ {
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ ft.show(this);
+
+ switch (mService.getImcState())
+ {
+ case UNKNOWN:
+ case ALLOW:
+ ft.hide(this);
+ break;
+ case ISOLATE:
+ mStateView.setText(R.string.imc_state_isolate);
+ mStateView.setTextColor(getResources().getColor(R.color.warning_text));
+ break;
+ case BLOCK:
+ mStateView.setText(R.string.imc_state_block);
+ mStateView.setTextColor(getResources().getColor(R.color.error_text));
+ break;
+ }
+ ft.commit();
+ }
+}