]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/frontends/android/app/src/main/java/org/strongswan/android/ui/RemediationInstructionsActivity.java
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / frontends / android / app / src / main / java / org / strongswan / android / ui / RemediationInstructionsActivity.java
1 /*
2 * Copyright (C) 2013 Tobias Brunner
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 package org.strongswan.android.ui;
18
19 import android.os.Bundle;
20 import androidx.appcompat.app.AppCompatActivity;
21 import android.view.MenuItem;
22
23 import org.strongswan.android.R;
24 import org.strongswan.android.logic.imc.RemediationInstruction;
25 import org.strongswan.android.ui.RemediationInstructionsFragment.OnRemediationInstructionSelectedListener;
26
27 import java.util.ArrayList;
28
29 public class RemediationInstructionsActivity extends AppCompatActivity implements OnRemediationInstructionSelectedListener
30 {
31 @Override
32 protected void onCreate(Bundle savedInstanceState)
33 {
34 super.onCreate(savedInstanceState);
35 setContentView(R.layout.remediation_instructions);
36 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
37
38 if (savedInstanceState != null)
39 { /* only update if we're not restoring */
40 return;
41 }
42 RemediationInstructionsFragment frag = (RemediationInstructionsFragment)getSupportFragmentManager().findFragmentById(R.id.remediation_instructions_fragment);
43 if (frag != null)
44 { /* two-pane layout, update fragment */
45 Bundle extras = getIntent().getExtras();
46 ArrayList<RemediationInstruction> list = extras.getParcelableArrayList(RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS);
47 frag.updateView(list);
48 }
49 else
50 { /* one-pane layout, create fragment */
51 frag = new RemediationInstructionsFragment();
52 frag.setArguments(getIntent().getExtras());
53 getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, frag).commit();
54 }
55 }
56
57 @Override
58 public boolean onOptionsItemSelected(MenuItem item)
59 {
60 switch (item.getItemId())
61 {
62 case android.R.id.home:
63 /* one-pane layout, pop possible fragment from stack, finish otherwise */
64 if (!getSupportFragmentManager().popBackStackImmediate())
65 {
66 finish();
67 }
68 getSupportActionBar().setTitle(getTitle());
69 return true;
70 default:
71 return super.onOptionsItemSelected(item);
72 }
73 }
74
75 @Override
76 public void onRemediationInstructionSelected(RemediationInstruction instruction)
77 {
78 RemediationInstructionFragment frag = (RemediationInstructionFragment)getSupportFragmentManager().findFragmentById(R.id.remediation_instruction_fragment);
79
80 if (frag != null)
81 { /* two-pane layout, update directly */
82 frag.updateView(instruction);
83 }
84 else
85 { /* one-pane layout, replace fragment */
86 frag = new RemediationInstructionFragment();
87 Bundle args = new Bundle();
88 args.putParcelable(RemediationInstructionFragment.ARG_REMEDIATION_INSTRUCTION, instruction);
89 frag.setArguments(args);
90
91 getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, frag).addToBackStack(null).commit();
92 getSupportActionBar().setTitle(instruction.getTitle());
93 }
94 }
95 }