package com.gaze.webpaser;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.WindowManager.LayoutParams;
import android.webkit.WebView;
import android.widget.RelativeLayout;

public class CommentActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_comment);

		handleIntent(getIntent());

		getActionBar().setTitle("DISQUS");

	}

	@SuppressLint("SetJavaScriptEnabled")
	private void handleIntent(Intent intent) {

		if (intent == null)
			return;

		String disqus = intent.getStringExtra(GlobalData.DISQUS_COMMENT);

		if (disqus == null)
			return;

		WebView webview = (WebView) findViewById(R.id.webView2);
		webview.getSettings().setJavaScriptEnabled(true);
		webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
		webview.getSettings().setSupportMultipleWindows(true);

		webview.loadDataWithBaseURL(GlobalData.baseUrl, disqus,
				"text/html; charset=UTF-8", null, null);
		
		
		// create popup view container layout
		RelativeLayout browserLayout = new RelativeLayout(this);
		browserLayout.setBackgroundColor(android.graphics.Color
				.parseColor("#282A79"));
		RelativeLayout.LayoutParams browser_LayoutParams = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		browser_LayoutParams.addRule(RelativeLayout.ABOVE,
				R.id.webView2);
		browserLayout.setLayoutParams(browser_LayoutParams);
		
		RelativeLayout root = (RelativeLayout) findViewById(R.id.relative1);
		root.addView(browserLayout);
		
		DisqusWebviewChromeClient client = new DisqusWebviewChromeClient(browserLayout, this);
		webview.setWebChromeClient(client);

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		// Respond to the action bar's Up/Home button
		case android.R.id.home:
			closeActivity();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	@Override
	public void onBackPressed() {

		closeActivity();

	}

	private void closeActivity() {
		this.finish();
		overridePendingTransition(0, R.anim.right_slide_out);
	}
}

@@ -177,16 +177,42 @@
 nuItem;%0A
+import android.view.View;%0A
 import a
@@ -251,16 +251,16 @@
 Params;%0A
-
 import a
@@ -877,293 +877,8 @@
 2);%0A
-%09%09webview.getSettings().setJavaScriptEnabled(true);%0A%09%09webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);%0A%09%09webview.getSettings().setSupportMultipleWindows(true);%0A%0A%09%09webview.loadDataWithBaseURL(GlobalData.baseUrl, disqus,%0A%09%09%09%09%22text/html; charset=UTF-8%22, null, null);%0A
 %09%09%0A%09
@@ -1261,12 +1261,16 @@
 ut.A
-BOVE
+LIGN_TOP
 ,%0A%09%09
@@ -1447,16 +1447,63 @@
 ayout);%0A
+%09%09browserLayout.setVisibility(View.INVISIBLE);%0A
 %09%09%0A%09%09Dis
@@ -1586,16 +1586,16 @@
  this);%0A
-
 %09%09webvie
@@ -1624,16 +1624,311 @@
 lient);%0A
+%09%09%0A%09%09webview.getSettings().setJavaScriptEnabled(true);%0A%09%09webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);%0A%09%09webview.getSettings().setSupportMultipleWindows(true);%0A%0A%09%09webview.loadDataWithBaseURL(GlobalData.baseUrl, disqus,%0A%09%09%09%09%22text/html; charset=UTF-8%22, null, null);%0A%09%09%0A%09%09%0A%0A
 %0A%09%7D%0A%0A%09@O

fix the sub webview display issue.