import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
+import android.webkit.CookieSyncManager;
import android.webkit.WebBackForwardList;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.actionbarsherlock.app.SherlockDialogFragment;
-import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.SsoWebViewClient;
import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;
+import com.owncloud.android.lib.network.OwnCloudClient;
+import com.owncloud.android.utils.Log_OC;
-import eu.alefzero.webdav.WebdavClient;
/**
* Dialog to show the WebView for SAML Authentication
private static final String ARG_TARGET_URL = "TARGET_URL";
private static final String KEY_WEBVIEW_STATE = "WEBVIEW_STATE";
- //private WebView mSsoWebView;
+ private WebView mSsoWebView;
private SsoWebViewClient mWebViewClient;
private String mInitialUrl;
public void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
+
+ CookieSyncManager.createInstance(getActivity());
if (savedInstanceState == null) {
mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
// Inflate layout of the dialog
View rootView = inflater.inflate(R.layout.sso_dialog, container, false); // null parent view because it will go in the dialog layout
- WebView ssoWebView = (WebView) rootView.findViewById(R.id.sso_webview);
+ mSsoWebView = (WebView) rootView.findViewById(R.id.sso_webview);
mWebViewClient.setTargetUrl(mTargetUrl);
- ssoWebView.setWebViewClient(mWebViewClient);
+ mSsoWebView.setWebViewClient(mWebViewClient);
if (savedInstanceState == null) {
Log_OC.d(TAG, " initWebView start");
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeAllCookie();
- ssoWebView.loadUrl(mInitialUrl);
+ mSsoWebView.loadUrl(mInitialUrl);
} else {
Log_OC.d(TAG, " restoreWebView start");
- WebBackForwardList history = ssoWebView.restoreState(savedInstanceState.getBundle(KEY_WEBVIEW_STATE));
+ WebBackForwardList history = mSsoWebView.restoreState(savedInstanceState.getBundle(KEY_WEBVIEW_STATE));
if (history == null) {
Log_OC.e(TAG, "Error restoring WebView state ; back to starting URL");
- ssoWebView.loadUrl(mInitialUrl);
+ mSsoWebView.loadUrl(mInitialUrl);
}
}
- WebSettings webSettings = ssoWebView.getSettings();
+ WebSettings webSettings = mSsoWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setLoadWithOverviewMode(false);
webSettings.setSavePassword(false);
- webSettings.setUserAgentString(WebdavClient.USER_AGENT);
+ webSettings.setUserAgentString(OwnCloudClient.USER_AGENT);
webSettings.setSaveFormData(false);
return rootView;
// Save the state of the WebView
Bundle webviewState = new Bundle();
- ((WebView) getDialog().findViewById(R.id.sso_webview)).saveState(webviewState);
+ mSsoWebView.saveState(webviewState);
outState.putBundle(KEY_WEBVIEW_STATE, webviewState);
}
public void onDestroyView() {
Log_OC.d(TAG, "onDestroyView");
+ mSsoWebView.setWebViewClient(null);
+
// Work around bug: http://code.google.com/p/android/issues/detail?id=17423
Dialog dialog = getDialog();
if ((dialog != null)) {