package com.hippo.ehviewer.ui;

import android.os.Bundle;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.ehclient.EhInfo;

public class WebViewLoginActivity extends AbsActivity {

    private static final String TITLE_LOGIN_SUCCESS = "Please stand by...";

    public static final String KEY_ERROR = "error";


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        CookieManager.getInstance().removeAllCookie();
        WebView wv = new WebView(this);
        wv.setWebViewClient(new LoginWebViewClient());
        wv.loadUrl(EhClient.LOGIN_URL);
        setContentView(wv);
    }

    private class LoginWebViewClient extends WebViewClient {
        @Override
        public void onPageFinished(WebView view, String url) {
            if (TITLE_LOGIN_SUCCESS.equals(view.getTitle())) {
                // Login OK
                String cookies = CookieManager.getInstance().getCookie(url);
                if (cookies != null) {
                    // Store cookie
                    EhInfo ehInfo = EhInfo.getInstance(WebViewLoginActivity.this);
                    ehInfo.setCookie(cookies);
                    ehInfo.login("User", "User");
                    setResult(RESULT_OK);
                } else {
                    setResult(RESULT_CANCELED);
                }
                finish();
            }
        }
    }
}

@@ -1,35 +1,676 @@
-package com.hippo.ehviewer.ui;%0A
+/*%0A * Copyright (C) 2015 Hippo Seven%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.hippo.ehviewer.ui;%0A%0Aimport android.annotation.SuppressLint;
 %0Aimp
@@ -1074,16 +1074,57 @@
 rror%22;%0A%0A
+    @SuppressLint(%22SetJavaScriptEnabled%22)
 %0A    pro
@@ -1309,24 +1309,77 @@
 View(this);%0A
+        wv.getSettings().setJavaScriptEnabled(true);%0A
         wv.s

Enable js in login webview