diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-05-30 12:16:30 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-07-08 18:49:29 +0200 |
commit | 6e872fea7a6afb18e0945cf4a2ddb70515838691 (patch) | |
tree | d771d96823a47a520fb41bb928266f32d5d8d564 /src | |
parent | 254d8679c656beda8442122ee31a588c5d6e2eb3 (diff) | |
download | strongswan-6e872fea7a6afb18e0945cf4a2ddb70515838691.tar.bz2 strongswan-6e872fea7a6afb18e0945cf4a2ddb70515838691.tar.xz |
android: IMC state fragment is a button that shows remediation instructions or log
Diffstat (limited to 'src')
-rw-r--r-- | src/frontends/android/res/layout/imc_state_fragment.xml | 51 | ||||
-rw-r--r-- | src/frontends/android/src/org/strongswan/android/ui/ImcStateFragment.java | 31 |
2 files changed, 66 insertions, 16 deletions
diff --git a/src/frontends/android/res/layout/imc_state_fragment.xml b/src/frontends/android/res/layout/imc_state_fragment.xml index 86853889a..171c88d2d 100644 --- a/src/frontends/android/res/layout/imc_state_fragment.xml +++ b/src/frontends/android/res/layout/imc_state_fragment.xml @@ -21,29 +21,48 @@ android:orientation="vertical" > <LinearLayout + android:id="@+id/imc_state_button" 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" > + android:background="?android:attr/selectableItemBackground" + android:orientation="vertical" > - <TextView - android:layout_width="wrap_content" + <LinearLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginRight="5dp" - android:text="@string/imc_state_label" - android:textColor="?android:textColorPrimary" - android:textSize="20sp" /> + android:layout_marginLeft="20dp" + android:layout_marginRight="20dp" + android:layout_marginTop="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> <TextView - android:id="@+id/imc_state" - android:layout_width="wrap_content" + android:id="@+id/action" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="" - android:textColor="?android:textColorSecondary" - android:textSize="20sp" /> + android:layout_marginBottom="10dp" + android:layout_marginLeft="20dp" + android:layout_marginRight="20dp" + android:text="@string/show_remediation_instructions" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="?android:attr/textColorSecondary" /> </LinearLayout> diff --git a/src/frontends/android/src/org/strongswan/android/ui/ImcStateFragment.java b/src/frontends/android/src/org/strongswan/android/ui/ImcStateFragment.java index 18893a3b6..2b6c1466e 100644 --- a/src/frontends/android/src/org/strongswan/android/ui/ImcStateFragment.java +++ b/src/frontends/android/src/org/strongswan/android/ui/ImcStateFragment.java @@ -15,9 +15,12 @@ package org.strongswan.android.ui; +import java.util.ArrayList; + import org.strongswan.android.R; import org.strongswan.android.logic.VpnStateService; import org.strongswan.android.logic.VpnStateService.VpnStateListener; +import org.strongswan.android.logic.imc.RemediationInstruction; import android.app.Fragment; import android.app.FragmentTransaction; @@ -30,12 +33,16 @@ import android.os.Bundle; import android.os.IBinder; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; public class ImcStateFragment extends Fragment implements VpnStateListener { private TextView mStateView; + private TextView mAction; + private LinearLayout mButton; private VpnStateService mService; private final ServiceConnection mServiceConnection = new ServiceConnection() { @Override @@ -72,7 +79,28 @@ public class ImcStateFragment extends Fragment implements VpnStateListener { View view = inflater.inflate(R.layout.imc_state_fragment, null); + mButton = (LinearLayout)view.findViewById(R.id.imc_state_button); + mButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) + { + Intent intent; + if (mService != null && !mService.getRemediationInstructions().isEmpty()) + { + intent = new Intent(getActivity(), RemediationInstructionsActivity.class); + intent.putParcelableArrayListExtra(RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS, + new ArrayList<RemediationInstruction>(mService.getRemediationInstructions())); + } + else + { + intent = new Intent(getActivity(), LogActivity.class); + } + startActivity(intent); + } + }); + mStateView = (TextView)view.findViewById(R.id.imc_state); + mAction = (TextView)view.findViewById(R.id.action); return view; } @@ -116,5 +144,8 @@ public class ImcStateFragment extends Fragment implements VpnStateListener break; } ft.commit(); + + mAction.setText(mService.getRemediationInstructions().isEmpty() ? R.string.show_log + : R.string.show_remediation_instructions); } } |