diff options
-rw-r--r-- | res/layout/eip_service_fragment.xml | 11 | ||||
-rwxr-xr-x | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/se/leap/leapclient/EipServiceFragment.java | 23 |
3 files changed, 34 insertions, 1 deletions
diff --git a/res/layout/eip_service_fragment.xml b/res/layout/eip_service_fragment.xml index 8f7c1d22..885c78a3 100644 --- a/res/layout/eip_service_fragment.xml +++ b/res/layout/eip_service_fragment.xml @@ -36,6 +36,17 @@ android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="10dp" /> + + <ProgressBar + android:id="@+id/eipProgress" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@android:style/Widget.Holo.ProgressBar.Horizontal" + android:indeterminate="true" + android:visibility="gone" + android:layout_below="@id/eipLabel" + android:layout_marginLeft="15dp" + android:layout_marginRight="15dp" /> <RelativeLayout android:id="@+id/eipDetail" diff --git a/res/values/strings.xml b/res/values/strings.xml index 09819809..cef7de1e 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -314,6 +314,7 @@ <string name="log_out_failed_message">Didn\'t logged out.</string> <string name="successful_authed_cert_downloaded_message">Your own cert has been correctly downloaded.</string> <string name="authed_cert_download_failed_message">Your own cert has incorrectly been downloaded.</string> + <string name="eip_status_start_pending">Initiating connection</string> <string name="eip_cancel_connect_title">Cancel connection?</string> <string name="eip_cancel_connect_text">There is a connection attempt in progress. Do you wish to cancel it?</string> <string name="eip_cancel_connect_cancel">Yes</string> diff --git a/src/se/leap/leapclient/EipServiceFragment.java b/src/se/leap/leapclient/EipServiceFragment.java index 485a06af..51284bc0 100644 --- a/src/se/leap/leapclient/EipServiceFragment.java +++ b/src/se/leap/leapclient/EipServiceFragment.java @@ -23,6 +23,8 @@ import android.widget.TextView; public class EipServiceFragment extends Fragment implements StateListener, OnClickListener, OnCheckedChangeListener { + private static final String IS_EIP_PENDING = "is_eip_pending"; + private View eipFragment; private Switch eipSwitch; private View eipDetail; @@ -37,6 +39,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + eipFragment = inflater.inflate(R.layout.eip_service_fragment, container, false); eipDetail = ((RelativeLayout) eipFragment.findViewById(R.id.eipDetail)); @@ -44,6 +47,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli View eipSettings = eipFragment.findViewById(R.id.eipSettings); eipSettings.setVisibility(View.GONE); // FIXME too! + + if (mEipStartPending) + eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); eipStatus = (TextView) eipFragment.findViewById(R.id.eipStatus); eipStatus.setOnClickListener(this); @@ -59,6 +65,9 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli super.onCreate(savedInstanceState); mEIPReceiver = new EIPReceiver(new Handler()); + + if (savedInstanceState != null) + mEipStartPending = savedInstanceState.getBoolean(IS_EIP_PENDING); } @Override @@ -76,6 +85,12 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli } @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(IS_EIP_PENDING, mEipStartPending); + } + + @Override public void onClick(View buttonView) { if (buttonView.equals(eipStatus)) showEIPLog(); @@ -95,6 +110,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli if (buttonView.equals(eipSwitch) && !eipAutoSwitched){ if (isChecked){ mEipStartPending = true; + eipFragment.findViewById(R.id.eipProgress).setVisibility(View.VISIBLE); + ((TextView) eipFragment.findViewById(R.id.eipStatus)).setText(R.string.eip_status_start_pending); eipCommand(EIP.ACTION_START_EIP); } else { if (mEipStartPending){ @@ -151,11 +168,14 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli String prefix = getString(localizedResId); if (state.equals("CONNECTED")){ statusMessage = "Connection Secure"; + getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE); mEipStartPending = false; } else if (state.equals("BYTECOUNT")) { statusMessage = logmessage; - } else if (state.equals("NOPROCESS") || state.equals("EXITING")) { + } else if ( (state.equals("NOPROCESS") && !mEipStartPending ) || state.equals("EXITING")) { statusMessage = "Not running! Connection not secure!"; + getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE); + mEipStartPending = false; switchState = false; } else { statusMessage = prefix + logmessage; @@ -204,6 +224,7 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli break; case Activity.RESULT_CANCELED: checked = false; + eipFragment.findViewById(R.id.eipProgress).setVisibility(View.GONE); break; } } else if (request == EIP.ACTION_STOP_EIP) { |