diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-05-30 11:55:44 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-07-08 18:49:29 +0200 |
commit | 0ef98957a7c5efe8f033ab876ae1969e3f3938c8 (patch) | |
tree | e741bf0a068f55aec8230cee17c192757833e3a6 /src | |
parent | 611d35e8e87ed0bbbcd5ab9ff90522f557ee6dd6 (diff) | |
download | strongswan-0ef98957a7c5efe8f033ab876ae1969e3f3938c8.tar.bz2 strongswan-0ef98957a7c5efe8f033ab876ae1969e3f3938c8.tar.xz |
android: Add activity that displays a list of remediation instructions
On large displays a two-pane layout is used that displays the list next
to the actual instructions.
Diffstat (limited to 'src')
11 files changed, 212 insertions, 1 deletions
diff --git a/src/frontends/android/AndroidManifest.xml b/src/frontends/android/AndroidManifest.xml index 4d76ac09e..dd03cf2a1 100644 --- a/src/frontends/android/AndroidManifest.xml +++ b/src/frontends/android/AndroidManifest.xml @@ -55,6 +55,10 @@ android:label="@string/log_title" > </activity> <activity + android:name=".ui.RemediationInstructionsActivity" + android:label="@string/remediation_instructions_title" > + </activity> + <activity android:name=".ui.VpnProfileSelectActivity" android:label="@string/strongswan_shortcut" > <intent-filter> diff --git a/src/frontends/android/res/drawable/remediation_instruction_background_large.xml b/src/frontends/android/res/drawable/remediation_instruction_background_large.xml new file mode 100644 index 000000000..470fecb12 --- /dev/null +++ b/src/frontends/android/res/drawable/remediation_instruction_background_large.xml @@ -0,0 +1,32 @@ +<?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. +--> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + + <item> + <shape> + <solid + android:color="@color/panel_separator" /> + </shape> + </item> + + <item android:left="2dp"> + <shape> + <solid + android:color="@color/panel_background" /> + </shape> + </item> + +</layer-list> diff --git a/src/frontends/android/res/layout-large/remediation_instructions.xml b/src/frontends/android/res/layout-large/remediation_instructions.xml new file mode 100644 index 000000000..5a28dd654 --- /dev/null +++ b/src/frontends/android/res/layout-large/remediation_instructions.xml @@ -0,0 +1,44 @@ +<?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:orientation="horizontal" + android:baselineAligned="false" > + + <fragment + class="org.strongswan.android.ui.RemediationInstructionsFragment" + android:id="@+id/remediation_instructions_fragment" + android:layout_height="match_parent" + android:layout_weight="1" + android:layout_width="0dp" /> + + <FrameLayout + android:layout_height="match_parent" + android:layout_weight="2" + android:layout_width="0dp" + android:background="@drawable/remediation_instruction_background_large" + android:padding="5dp" > + + <fragment + class="org.strongswan.android.ui.RemediationInstructionFragment" + android:id="@+id/remediation_instruction_fragment" + android:layout_height="match_parent" + android:layout_width="match_parent" /> + + </FrameLayout> + +</LinearLayout> diff --git a/src/frontends/android/res/layout/remediation_instructions.xml b/src/frontends/android/res/layout/remediation_instructions.xml new file mode 100644 index 000000000..84143b575 --- /dev/null +++ b/src/frontends/android/res/layout/remediation_instructions.xml @@ -0,0 +1,21 @@ +<?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. +--> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/fragment_container"> + +</FrameLayout>
\ No newline at end of file diff --git a/src/frontends/android/res/values-de/strings.xml b/src/frontends/android/res/values-de/strings.xml index 97da97ee4..6414f11c0 100644 --- a/src/frontends/android/res/values-de/strings.xml +++ b/src/frontends/android/res/values-de/strings.xml @@ -91,6 +91,9 @@ <string name="imc_state_isolate">Eingeschränkt</string> <string name="imc_state_block">Fehlgeschlagen</string> + <!-- Remediation instructions --> + <string name="remediation_instructions_title">Korrekturanweisungen</string> + <!-- Dialogs --> <string name="login_title">Passwort eingeben um zu verbinden</string> <string name="login_confirm">Verbinden</string> diff --git a/src/frontends/android/res/values-pl/strings.xml b/src/frontends/android/res/values-pl/strings.xml index e3576d5de..722bc10d3 100644 --- a/src/frontends/android/res/values-pl/strings.xml +++ b/src/frontends/android/res/values-pl/strings.xml @@ -91,6 +91,9 @@ <string name="imc_state_isolate">Restricted</string> <string name="imc_state_block">Failed</string> + <!-- Remediation instructions --> + <string name="remediation_instructions_title">Remediation instructions</string> + <!-- Dialogs --> <string name="login_title">Wprowadż hasło</string> <string name="login_confirm">Połącz</string> diff --git a/src/frontends/android/res/values-ru/strings.xml b/src/frontends/android/res/values-ru/strings.xml index f5f696ab4..c82350bdf 100644 --- a/src/frontends/android/res/values-ru/strings.xml +++ b/src/frontends/android/res/values-ru/strings.xml @@ -88,6 +88,9 @@ <string name="imc_state_isolate">Restricted</string> <string name="imc_state_block">Failed</string> + <!-- Remediation instructions --> + <string name="remediation_instructions_title">Remediation instructions</string> + <!-- Dialogs --> <string name="login_title">Введите пароль для соединения</string> <string name="login_confirm">Соединить</string> diff --git a/src/frontends/android/res/values-ua/strings.xml b/src/frontends/android/res/values-ua/strings.xml index 39d67eaba..3d82008c7 100644 --- a/src/frontends/android/res/values-ua/strings.xml +++ b/src/frontends/android/res/values-ua/strings.xml @@ -89,6 +89,9 @@ <string name="imc_state_isolate">Restricted</string> <string name="imc_state_block">Failed</string> + <!-- Remediation instructions --> + <string name="remediation_instructions_title">Remediation instructions</string> + <!-- Dialogs --> <string name="login_title">Введіть пароль для з\'єднання</string> <string name="login_confirm">Підключити</string> diff --git a/src/frontends/android/res/values/strings.xml b/src/frontends/android/res/values/strings.xml index 78475df6e..b275cd5e7 100644 --- a/src/frontends/android/res/values/strings.xml +++ b/src/frontends/android/res/values/strings.xml @@ -91,6 +91,9 @@ <string name="imc_state_isolate">Restricted</string> <string name="imc_state_block">Failed</string> + <!-- Remediation instructions --> + <string name="remediation_instructions_title">Remediation instructions</string> + <!-- Dialogs --> <string name="login_title">Enter password to connect</string> <string name="login_confirm">Connect</string> diff --git a/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsActivity.java b/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsActivity.java new file mode 100644 index 000000000..66d0de261 --- /dev/null +++ b/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsActivity.java @@ -0,0 +1,94 @@ +/* + * 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 java.util.ArrayList; + +import org.strongswan.android.R; +import org.strongswan.android.logic.imc.RemediationInstruction; +import org.strongswan.android.ui.RemediationInstructionsFragment.OnRemediationInstructionSelectedListener; + +import android.app.Activity; +import android.os.Bundle; +import android.view.MenuItem; + +public class RemediationInstructionsActivity extends Activity implements OnRemediationInstructionSelectedListener +{ + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.remediation_instructions); + getActionBar().setDisplayHomeAsUpEnabled(true); + + if (savedInstanceState != null) + { /* only update if we're not restoring */ + return; + } + RemediationInstructionsFragment frag = (RemediationInstructionsFragment)getFragmentManager().findFragmentById(R.id.remediation_instructions_fragment); + if (frag != null) + { /* two-pane layout, update fragment */ + Bundle extras = getIntent().getExtras(); + ArrayList<RemediationInstruction> list = extras.getParcelableArrayList(RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS); + frag.updateView(list); + } + else + { /* one-pane layout, create fragment */ + frag = new RemediationInstructionsFragment(); + frag.setArguments(getIntent().getExtras()); + getFragmentManager().beginTransaction().add(R.id.fragment_container, frag).commit(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) + { + switch (item.getItemId()) + { + case android.R.id.home: + /* one-pane layout, pop possible fragment from stack, finish otherwise */ + if (!getFragmentManager().popBackStackImmediate()) + { + finish(); + } + getActionBar().setTitle(getTitle()); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + public void onRemediationInstructionSelected(RemediationInstruction instruction) + { + RemediationInstructionFragment frag = (RemediationInstructionFragment)getFragmentManager().findFragmentById(R.id.remediation_instruction_fragment); + + if (frag != null) + { /* two-pane layout, update directly */ + frag.updateView(instruction); + } + else + { /* one-pane layout, replace fragment */ + frag = new RemediationInstructionFragment(); + Bundle args = new Bundle(); + args.putParcelable(RemediationInstructionFragment.ARG_REMEDIATION_INSTRUCTION, instruction); + frag.setArguments(args); + + getFragmentManager().beginTransaction().replace(R.id.fragment_container, frag).addToBackStack(null).commit(); + getActionBar().setTitle(instruction.getTitle()); + } + } +} diff --git a/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsFragment.java b/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsFragment.java index 9aa7ea140..86467dc35 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsFragment.java +++ b/src/frontends/android/src/org/strongswan/android/ui/RemediationInstructionsFragment.java @@ -17,6 +17,7 @@ package org.strongswan.android.ui; import java.util.ArrayList; +import org.strongswan.android.R; import org.strongswan.android.logic.imc.RemediationInstruction; import org.strongswan.android.ui.adapter.RemediationInstructionAdapter; @@ -79,7 +80,7 @@ public class RemediationInstructionsFragment extends ListFragment { super.onStart(); - boolean two_pane = false; + boolean two_pane = getFragmentManager().findFragmentById(R.id.remediation_instruction_fragment) != null; if (two_pane) { /* two-pane layout, make list items selectable */ getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); |