2 * Copyright (C) 2013 Tobias Brunner
4 * Copyright (C) secunet Security Networks AG
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>.
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
17 package org
.strongswan
.android
.ui
;
19 import android
.os
.Bundle
;
20 import androidx
.appcompat
.app
.AppCompatActivity
;
21 import android
.view
.MenuItem
;
23 import org
.strongswan
.android
.R
;
24 import org
.strongswan
.android
.logic
.imc
.RemediationInstruction
;
25 import org
.strongswan
.android
.ui
.RemediationInstructionsFragment
.OnRemediationInstructionSelectedListener
;
27 import java
.util
.ArrayList
;
29 public class RemediationInstructionsActivity
extends AppCompatActivity
implements OnRemediationInstructionSelectedListener
32 protected void onCreate(Bundle savedInstanceState
)
34 super.onCreate(savedInstanceState
);
35 setContentView(R
.layout
.remediation_instructions
);
36 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
38 if (savedInstanceState
!= null)
39 { /* only update if we're not restoring */
42 RemediationInstructionsFragment frag
= (RemediationInstructionsFragment
)getSupportFragmentManager().findFragmentById(R
.id
.remediation_instructions_fragment
);
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
);
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();
58 public boolean onOptionsItemSelected(MenuItem item
)
60 switch (item
.getItemId())
62 case android
.R
.id
.home
:
63 /* one-pane layout, pop possible fragment from stack, finish otherwise */
64 if (!getSupportFragmentManager().popBackStackImmediate())
68 getSupportActionBar().setTitle(getTitle());
71 return super.onOptionsItemSelected(item
);
76 public void onRemediationInstructionSelected(RemediationInstruction instruction
)
78 RemediationInstructionFragment frag
= (RemediationInstructionFragment
)getSupportFragmentManager().findFragmentById(R
.id
.remediation_instruction_fragment
);
81 { /* two-pane layout, update directly */
82 frag
.updateView(instruction
);
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
);
91 getSupportFragmentManager().beginTransaction().replace(R
.id
.fragment_container
, frag
).addToBackStack(null).commit();
92 getSupportActionBar().setTitle(instruction
.getTitle());