android: IMC state fragment is a button that shows remediation instructions or log
This commit is contained in:
@@ -21,29 +21,48 @@
|
|||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/imc_state_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:layout_marginRight="20dp"
|
android:orientation="vertical" >
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginBottom="10dp"
|
<LinearLayout
|
||||||
android:orientation="horizontal" >
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/action"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:text="@string/imc_state_label"
|
android:layout_marginLeft="20dp"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:layout_marginRight="20dp"
|
||||||
android:textSize="20sp" />
|
android:text="@string/show_remediation_instructions"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
<TextView
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,12 @@
|
|||||||
|
|
||||||
package org.strongswan.android.ui;
|
package org.strongswan.android.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.strongswan.android.R;
|
import org.strongswan.android.R;
|
||||||
import org.strongswan.android.logic.VpnStateService;
|
import org.strongswan.android.logic.VpnStateService;
|
||||||
import org.strongswan.android.logic.VpnStateService.VpnStateListener;
|
import org.strongswan.android.logic.VpnStateService.VpnStateListener;
|
||||||
|
import org.strongswan.android.logic.imc.RemediationInstruction;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
@@ -30,12 +33,16 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class ImcStateFragment extends Fragment implements VpnStateListener
|
public class ImcStateFragment extends Fragment implements VpnStateListener
|
||||||
{
|
{
|
||||||
private TextView mStateView;
|
private TextView mStateView;
|
||||||
|
private TextView mAction;
|
||||||
|
private LinearLayout mButton;
|
||||||
private VpnStateService mService;
|
private VpnStateService mService;
|
||||||
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +79,28 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
|
|||||||
{
|
{
|
||||||
View view = inflater.inflate(R.layout.imc_state_fragment, null);
|
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);
|
mStateView = (TextView)view.findViewById(R.id.imc_state);
|
||||||
|
mAction = (TextView)view.findViewById(R.id.action);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -116,5 +144,8 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
|
mAction.setText(mService.getRemediationInstructions().isEmpty() ? R.string.show_log
|
||||||
|
: R.string.show_remediation_instructions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user