Program: 104948
Project: 104948
Buggy source:
void configure(String url,long startTime,EventHandler eh){
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setColor(getResources().getColor(R.color.content_toolbar_background));
  try {
    mTempUrl=new URL(url);
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.toolbar_header);
  mWebView=(WebView)findViewById(R.id.webView);
  mToolbarLayout=(LinearLayout)findViewById(R.id.content_toolbar);
  mTitleTextView=(CondensedTextView)findViewById(R.id.title_text);
  mUrlTextView=(CondensedTextView)findViewById(R.id.url_text);
  View textContainer=findViewById(R.id.content_text_container);
  textContainer.setOnTouchListener(new OnSwipeTouchListener(){
    public void onSwipeRight(){
      MainController.get().showPreviousBubble();
    }
    public void onSwipeLeft(){
      MainController.get().showNextBubble();
    }
  }
);
  mShareButton=(ContentViewButton)findViewById(R.id.share_button);
  mShareButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_share));
  mShareButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      showSelectShareMethod(mUrl,true);
    }
  }
);
  mOpenInAppButton=(OpenInAppButton)findViewById(R.id.open_in_app_button);
  mOpenInAppButton.setOnOpenInAppClickListener(new OpenInAppButton.OnOpenInAppClickListener(){
    @Override public void onAppOpened(){
      mEventHandler.onDestroyBubble();
    }
  }
);
  mOpenEmbedButton=(OpenEmbedButton)findViewById(R.id.open_embed_button);
  mOpenEmbedButton.setOnOpenEmbedClickListener(new OpenEmbedButton.OnOpenEmbedClickListener(){
    @Override public void onYouTubeEmbedOpened(){
    }
  }
);
  mReloadButton=(ContentViewButton)findViewById(R.id.reload_button);
  mReloadButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_reload));
  mReloadButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      mReloadButton.setVisibility(GONE);
      mWebView.reload();
    }
  }
);
  mOverflowButton=(ContentViewButton)mToolbarLayout.findViewById(R.id.overflow_button);
  mOverflowButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_overflow_round));
  mOverflowButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      mOverflowPopupMenu=new PopupMenu(mContext,mOverflowButton);
      Resources resources=mContext.getResources();
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_upgrade_to_pro,Menu.NONE,resources.getString(R.string.action_upgrade_to_pro));
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_reload_page,Menu.NONE,resources.getString(R.string.action_reload_page));
      String defaultBrowserLabel=Settings.get().getDefaultBrowserLabel();
      if (defaultBrowserLabel != null) {
        mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_open_in_browser,Menu.NONE,String.format(resources.getString(R.string.action_open_in_browser),defaultBrowserLabel));
      }
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_settings,Menu.NONE,resources.getString(R.string.action_settings));
      mOverflowPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
        @Override public boolean onMenuItemClick(        MenuItem item){
switch (item.getItemId()) {
case R.id.item_upgrade_to_pro:
{
              Intent intent=Config.getStoreIntent(mContext,Config.STORE_PRO_URL);
              if (intent != null) {
                mContext.startActivity(intent);
                mEventHandler.onMinimizeBubbles();
              }
              break;
            }
case R.id.item_reload_page:
{
            if (mYouTubeEmbedHelper != null) {
              mYouTubeEmbedHelper.clear();
            }
            mEventHandler.onPageLoading(mUrl);
            mWebView.stopLoading();
            mWebView.reload();
            updateAppsForUrl(mUrl);
            configureOpenInAppButton();
            configureOpenEmbedButton();
            Log.d(TAG,"String_Node_Str" + mUrl);
            mStartTime=System.currentTimeMillis();
            mTitleTextView.setText(R.string.loading);
            mUrlTextView.setText(mUrl.replace("String_Node_Str","String_Node_Str"));
            break;
          }
case R.id.item_open_in_browser:
{
          openInBrowser(mUrl);
          break;
        }
case R.id.item_settings:
{
        Intent intent=new Intent(mContext,SettingsActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        mContext.startActivity(intent);
        mEventHandler.onMinimizeBubbles();
        break;
      }
  }
  mOverflowPopupMenu=null;
  return false;
}
}
);
mOverflowPopupMenu.setOnDismissListener(new PopupMenu.OnDismissListener(){
@Override public void onDismiss(PopupMenu menu){
  if (mOverflowPopupMenu == menu) {
    mOverflowPopupMenu=null;
  }
}
}
);
mOverflowPopupMenu.show();
}
}
);
mContext=getContext();
mEventHandler=eh;
mUrl=url;
WebSettings ws=mWebView.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
ws.setLoadWithOverviewMode(true);
ws.setUseWideViewPort(true);
mWebView.setLongClickable(true);
mWebView.setOnLongClickListener(new OnLongClickListener(){
@Override public boolean onLongClick(View v){
WebView.HitTestResult hitTestResult=mWebView.getHitTestResult();
Log.d(TAG,"String_Node_Str" + hitTestResult.getType());
switch (hitTestResult.getType()) {
case WebView.HitTestResult.SRC_ANCHOR_TYPE:
case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
{
  final String url=hitTestResult.getExtra();
  if (url == null) {
    return false;
  }
  onUrlLongClick(url);
  return true;
}
case WebView.HitTestResult.UNKNOWN_TYPE:
default :
String defaultBrowserLabel=Settings.get().getDefaultBrowserLabel();
String message;
if (defaultBrowserLabel != null) {
message=String.format(getResources().getString(R.string.long_press_unsupported_default_browser),defaultBrowserLabel);
}
 else {
message=getResources().getString(R.string.long_press_unsupported_no_default_browser);
}
Toast.makeText(mContext,message,Toast.LENGTH_LONG).show();
return false;
}
}
}
);
mWebView.setWebChromeClient(new WebChromeClient(){
@Override public void onReceivedTitle(WebView webView,String title){
super.onReceivedTitle(webView,title);
mTitleTextView.setText(title);
}
@Override public void onReceivedIcon(WebView webView,Bitmap bitmap){
super.onReceivedIcon(webView,bitmap);
mEventHandler.onReceivedIcon(bitmap);
}
@Override public void onProgressChanged(WebView webView,int progress){
mEventHandler.onProgressChanged(progress);
if (progress >= 60) {
if (mCheckForEmbedsCount == 0) {
mCheckForEmbedsCount=1;
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
if (Settings.get().checkForYouTubeEmbeds()) {
Log.d(TAG,"String_Node_Str" + progress + "String_Node_Str"+ mCheckForEmbedsCount);
webView.loadUrl(JS_EMBED);
}
}
 else if (mCheckForEmbedsCount == 1 && progress >= 80) {
mCheckForEmbedsCount=2;
if (Settings.get().checkForYouTubeEmbeds()) {
Log.d(TAG,"String_Node_Str" + progress + "String_Node_Str"+ mCheckForEmbedsCount);
webView.loadUrl(JS_EMBED);
}
}
}
}
}
);
mWebView.setWebViewClient(new WebViewClient(){
@Override public boolean shouldOverrideUrlLoading(WebView wView,String url){
if (mLoadCount == 0) {
if (mCurrentLoadedUrl != null && !mLoadingPrev) {
mUrlHistory.push(mCurrentLoadedUrl);
}
mCurrentLoadedUrl=null;
mLoadingPrev=false;
}
if (isValidUrl(url)) {
++mLoadCount;
}
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
List<ResolveInfo> resolveInfos=Settings.get().getAppsThatHandleUrl(url);
updateAppsForUrl(resolveInfos,url);
if (Settings.get().redirectUrlToBrowser(url)) {
if (openInBrowser(url)) {
String title=String.format(mContext.getString(R.string.link_redirected),Settings.get().getDefaultBrowserLabel());
MainApplication.saveUrlInHistory(mContext,null,url,title);
return false;
}
}
if (Settings.get().getAutoContentDisplayAppRedirect() && resolveInfos != null && resolveInfos.size() > 0) {
ResolveInfo resolveInfo=resolveInfos.get(0);
if (resolveInfo != Settings.get().mLinkBubbleEntryActivityResolveInfo) {
if (MainApplication.loadResolveInfoIntent(mContext,resolveInfo,url,mStartTime)) {
String title=String.format(mContext.getString(R.string.link_loaded_with_app),resolveInfo.loadLabel(mContext.getPackageManager()));
MainApplication.saveUrlInHistory(mContext,resolveInfo,url,title);
mEventHandler.onDestroyBubble();
return false;
}
}
}
configureOpenInAppButton();
configureOpenEmbedButton();
Log.d(TAG,"String_Node_Str" + url);
mWebView.loadUrl(url);
mEventHandler.onPageLoading(url);
mTitleTextView.setText(R.string.loading);
mUrlTextView.setText(url.replace("String_Node_Str","String_Node_Str"));
return true;
}
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
mEventHandler.onPageLoaded(null);
mReloadButton.setVisibility(VISIBLE);
mShareButton.setVisibility(GONE);
}
@Override public void onReceivedSslError(WebView view,SslErrorHandler handler,SslError error){
handler.proceed();
}
@Override public void onPageStarted(WebView view,String url,Bitmap favIcon){
if (isValidUrl(url)) {
mLoadCount=Math.max(mLoadCount,1);
}
if (mShareButton.getVisibility() == GONE) {
mShareButton.setVisibility(VISIBLE);
}
}
@Override public void onPageFinished(WebView webView,String urlAsString){
super.onPageFinished(webView,urlAsString);
URL url=null;
try {
url=new URL(urlAsString);
}
 catch (MalformedURLException e) {
e.printStackTrace();
}
if (isValidUrl(url)) {
updateAppsForUrl(urlAsString);
configureOpenInAppButton();
configureOpenEmbedButton();
mTitleTextView.setText(webView.getTitle());
mUrlTextView.setText(urlAsString.replace("String_Node_Str","String_Node_Str"));
if (--mLoadCount == 0) {
mUrl=urlAsString;
mCurrentLoadedUrl=mUrl;
PageLoadInfo pageLoadInfo=new PageLoadInfo();
pageLoadInfo.bmp=webView.getFavicon();
pageLoadInfo.url=urlAsString;
pageLoadInfo.mHost=url.getHost();
pageLoadInfo.title=webView.getTitle();
mEventHandler.onPageLoaded(pageLoadInfo);
Log.d(TAG,"String_Node_Str" + urlAsString);
if (mStartTime > -1) {
Log.d("String_Node_Str","String_Node_Str" + ((System.currentTimeMillis() - mStartTime) / 1000) + "String_Node_Str");
mStartTime=-1;
}
if (Settings.get().checkForYouTubeEmbeds()) {
webView.loadUrl(JS_EMBED);
Log.d(TAG,"String_Node_Str");
}
}
}
}
}
);
mWebView.setOnKeyListener(new OnKeyListener(){
@Override public boolean onKey(View v,int keyCode,KeyEvent event){
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView=(WebView)v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
{
if (mUrlHistory.size() == 0) {
mEventHandler.onDestroyBubble();
}
 else {
webView.stopLoading();
String urlBefore=webView.getUrl();
String prevUrl=mUrlHistory.pop();
mLoadingPrev=true;
webView.loadUrl(prevUrl);
updateAppsForUrl(webView.getUrl());
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
Log.d(TAG,"String_Node_Str" + urlBefore + "String_Node_Str"+ webView.getUrl());
configureOpenInAppButton();
configureOpenEmbedButton();
return true;
}
break;
}
}
}
return false;
}
}
);
mWebView.setDownloadListener(new DownloadListener(){
@Override public void onDownloadStart(String url,String userAgent,String contentDisposition,String mimetype,long contentLength){
openInBrowser(url);
mEventHandler.onDestroyBubble();
}
}
);
if (Settings.get().checkForYouTubeEmbeds()) {
mJSEmbedHandler=new JSEmbedHandler();
mWebView.addJavascriptInterface(mJSEmbedHandler,JS_VARIABLE);
}
updateIncognitoMode(Settings.get().isIncognitoMode());
updateAppsForUrl(url);
configureOpenInAppButton();
configureOpenEmbedButton();
Log.d(TAG,"String_Node_Str" + url);
mStartTime=startTime;
mWebView.loadUrl(url);
mEventHandler.onPageLoading(url);
mTitleTextView.setText(R.string.loading);
mUrlTextView.setText(url.replace("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
void configure(String url,long startTime,EventHandler eh){
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setColor(getResources().getColor(R.color.content_toolbar_background));
  try {
    mTempUrl=new URL(url);
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.toolbar_header);
  mWebView=(WebView)findViewById(R.id.webView);
  mToolbarLayout=(LinearLayout)findViewById(R.id.content_toolbar);
  mTitleTextView=(CondensedTextView)findViewById(R.id.title_text);
  mUrlTextView=(CondensedTextView)findViewById(R.id.url_text);
  View textContainer=findViewById(R.id.content_text_container);
  textContainer.setOnTouchListener(new OnSwipeTouchListener(){
    public void onSwipeRight(){
      MainController.get().showPreviousBubble();
    }
    public void onSwipeLeft(){
      MainController.get().showNextBubble();
    }
  }
);
  mShareButton=(ContentViewButton)findViewById(R.id.share_button);
  mShareButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_share));
  mShareButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      showSelectShareMethod(mUrl,true);
    }
  }
);
  mOpenInAppButton=(OpenInAppButton)findViewById(R.id.open_in_app_button);
  mOpenInAppButton.setOnOpenInAppClickListener(new OpenInAppButton.OnOpenInAppClickListener(){
    @Override public void onAppOpened(){
      mEventHandler.onDestroyBubble();
    }
  }
);
  mOpenEmbedButton=(OpenEmbedButton)findViewById(R.id.open_embed_button);
  mOpenEmbedButton.setOnOpenEmbedClickListener(new OpenEmbedButton.OnOpenEmbedClickListener(){
    @Override public void onYouTubeEmbedOpened(){
    }
  }
);
  mReloadButton=(ContentViewButton)findViewById(R.id.reload_button);
  mReloadButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_reload));
  mReloadButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      mReloadButton.setVisibility(GONE);
      mWebView.reload();
    }
  }
);
  mOverflowButton=(ContentViewButton)mToolbarLayout.findViewById(R.id.overflow_button);
  mOverflowButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_overflow_round));
  mOverflowButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      mOverflowPopupMenu=new PopupMenu(mContext,mOverflowButton);
      Resources resources=mContext.getResources();
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_upgrade_to_pro,Menu.NONE,resources.getString(R.string.action_upgrade_to_pro));
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_reload_page,Menu.NONE,resources.getString(R.string.action_reload_page));
      String defaultBrowserLabel=Settings.get().getDefaultBrowserLabel();
      if (defaultBrowserLabel != null) {
        mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_open_in_browser,Menu.NONE,String.format(resources.getString(R.string.action_open_in_browser),defaultBrowserLabel));
      }
      mOverflowPopupMenu.getMenu().add(Menu.NONE,R.id.item_settings,Menu.NONE,resources.getString(R.string.action_settings));
      mOverflowPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
        @Override public boolean onMenuItemClick(        MenuItem item){
switch (item.getItemId()) {
case R.id.item_upgrade_to_pro:
{
              Intent intent=Config.getStoreIntent(mContext,Config.STORE_PRO_URL);
              if (intent != null) {
                mContext.startActivity(intent);
                mEventHandler.onMinimizeBubbles();
              }
              break;
            }
case R.id.item_reload_page:
{
            if (mYouTubeEmbedHelper != null) {
              mYouTubeEmbedHelper.clear();
            }
            mEventHandler.onPageLoading(mUrl);
            mWebView.stopLoading();
            mWebView.reload();
            updateAppsForUrl(mUrl);
            configureOpenInAppButton();
            configureOpenEmbedButton();
            Log.d(TAG,"String_Node_Str" + mUrl);
            mStartTime=System.currentTimeMillis();
            mTitleTextView.setText(R.string.loading);
            mUrlTextView.setText(mUrl.replace("String_Node_Str","String_Node_Str"));
            break;
          }
case R.id.item_open_in_browser:
{
          openInBrowser(mUrl);
          break;
        }
case R.id.item_settings:
{
        Intent intent=new Intent(mContext,SettingsActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        mContext.startActivity(intent);
        mEventHandler.onMinimizeBubbles();
        break;
      }
  }
  mOverflowPopupMenu=null;
  return false;
}
}
);
mOverflowPopupMenu.setOnDismissListener(new PopupMenu.OnDismissListener(){
@Override public void onDismiss(PopupMenu menu){
  if (mOverflowPopupMenu == menu) {
    mOverflowPopupMenu=null;
  }
}
}
);
mOverflowPopupMenu.show();
}
}
);
mContext=getContext();
mEventHandler=eh;
mUrl=url;
mPageFinishedLoading=false;
WebSettings ws=mWebView.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
ws.setLoadWithOverviewMode(true);
ws.setUseWideViewPort(true);
mWebView.setLongClickable(true);
mWebView.setOnLongClickListener(new OnLongClickListener(){
@Override public boolean onLongClick(View v){
WebView.HitTestResult hitTestResult=mWebView.getHitTestResult();
Log.d(TAG,"String_Node_Str" + hitTestResult.getType());
switch (hitTestResult.getType()) {
case WebView.HitTestResult.SRC_ANCHOR_TYPE:
case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
{
  final String url=hitTestResult.getExtra();
  if (url == null) {
    return false;
  }
  onUrlLongClick(url);
  return true;
}
case WebView.HitTestResult.UNKNOWN_TYPE:
default :
String defaultBrowserLabel=Settings.get().getDefaultBrowserLabel();
String message;
if (defaultBrowserLabel != null) {
message=String.format(getResources().getString(R.string.long_press_unsupported_default_browser),defaultBrowserLabel);
}
 else {
message=getResources().getString(R.string.long_press_unsupported_no_default_browser);
}
Toast.makeText(mContext,message,Toast.LENGTH_LONG).show();
return false;
}
}
}
);
mWebView.setWebChromeClient(new WebChromeClient(){
@Override public void onReceivedTitle(WebView webView,String title){
super.onReceivedTitle(webView,title);
mTitleTextView.setText(title);
}
@Override public void onReceivedIcon(WebView webView,Bitmap bitmap){
super.onReceivedIcon(webView,bitmap);
if (mPageFinishedLoading) {
mEventHandler.onReceivedIcon(bitmap);
}
}
@Override public void onProgressChanged(WebView webView,int progress){
mEventHandler.onProgressChanged(progress);
if (progress >= 60) {
if (mCheckForEmbedsCount == 0) {
mCheckForEmbedsCount=1;
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
if (Settings.get().checkForYouTubeEmbeds()) {
Log.d(TAG,"String_Node_Str" + progress + "String_Node_Str"+ mCheckForEmbedsCount);
webView.loadUrl(JS_EMBED);
}
}
 else if (mCheckForEmbedsCount == 1 && progress >= 80) {
mCheckForEmbedsCount=2;
if (Settings.get().checkForYouTubeEmbeds()) {
Log.d(TAG,"String_Node_Str" + progress + "String_Node_Str"+ mCheckForEmbedsCount);
webView.loadUrl(JS_EMBED);
}
}
}
}
}
);
mWebView.setWebViewClient(new WebViewClient(){
@Override public boolean shouldOverrideUrlLoading(WebView wView,String url){
if (mLoadCount == 0) {
if (mCurrentLoadedUrl != null && !mLoadingPrev) {
mUrlHistory.push(mCurrentLoadedUrl);
}
mCurrentLoadedUrl=null;
mLoadingPrev=false;
}
if (isValidUrl(url)) {
++mLoadCount;
}
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
List<ResolveInfo> resolveInfos=Settings.get().getAppsThatHandleUrl(url);
updateAppsForUrl(resolveInfos,url);
if (Settings.get().redirectUrlToBrowser(url)) {
if (openInBrowser(url)) {
String title=String.format(mContext.getString(R.string.link_redirected),Settings.get().getDefaultBrowserLabel());
MainApplication.saveUrlInHistory(mContext,null,url,title);
return false;
}
}
if (Settings.get().getAutoContentDisplayAppRedirect() && resolveInfos != null && resolveInfos.size() > 0) {
ResolveInfo resolveInfo=resolveInfos.get(0);
if (resolveInfo != Settings.get().mLinkBubbleEntryActivityResolveInfo) {
if (MainApplication.loadResolveInfoIntent(mContext,resolveInfo,url,mStartTime)) {
String title=String.format(mContext.getString(R.string.link_loaded_with_app),resolveInfo.loadLabel(mContext.getPackageManager()));
MainApplication.saveUrlInHistory(mContext,resolveInfo,url,title);
mEventHandler.onDestroyBubble();
return false;
}
}
}
configureOpenInAppButton();
configureOpenEmbedButton();
Log.d(TAG,"String_Node_Str" + url);
mWebView.loadUrl(url);
mEventHandler.onPageLoading(url);
mTitleTextView.setText(R.string.loading);
mUrlTextView.setText(url.replace("String_Node_Str","String_Node_Str"));
return true;
}
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
mEventHandler.onPageLoaded(null);
mReloadButton.setVisibility(VISIBLE);
mShareButton.setVisibility(GONE);
}
@Override public void onReceivedSslError(WebView view,SslErrorHandler handler,SslError error){
handler.proceed();
}
@Override public void onPageStarted(WebView view,String url,Bitmap favIcon){
mPageFinishedLoading=false;
if (isValidUrl(url)) {
mLoadCount=Math.max(mLoadCount,1);
}
if (mShareButton.getVisibility() == GONE) {
mShareButton.setVisibility(VISIBLE);
}
}
@Override public void onPageFinished(WebView webView,String urlAsString){
super.onPageFinished(webView,urlAsString);
mPageFinishedLoading=true;
URL url=null;
try {
url=new URL(urlAsString);
}
 catch (MalformedURLException e) {
e.printStackTrace();
}
if (isValidUrl(url)) {
updateAppsForUrl(urlAsString);
configureOpenInAppButton();
configureOpenEmbedButton();
mTitleTextView.setText(webView.getTitle());
mUrlTextView.setText(urlAsString.replace("String_Node_Str","String_Node_Str"));
if (--mLoadCount == 0) {
mUrl=urlAsString;
mCurrentLoadedUrl=mUrl;
PageLoadInfo pageLoadInfo=new PageLoadInfo();
pageLoadInfo.bmp=webView.getFavicon();
pageLoadInfo.url=urlAsString;
pageLoadInfo.mHost=url.getHost();
pageLoadInfo.title=webView.getTitle();
mEventHandler.onPageLoaded(pageLoadInfo);
Log.d(TAG,"String_Node_Str" + urlAsString);
if (mStartTime > -1) {
Log.d("String_Node_Str","String_Node_Str" + ((System.currentTimeMillis() - mStartTime) / 1000) + "String_Node_Str");
mStartTime=-1;
}
if (Settings.get().checkForYouTubeEmbeds()) {
webView.loadUrl(JS_EMBED);
Log.d(TAG,"String_Node_Str");
}
}
}
}
}
);
mWebView.setOnKeyListener(new OnKeyListener(){
@Override public boolean onKey(View v,int keyCode,KeyEvent event){
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView=(WebView)v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
{
if (mUrlHistory.size() == 0) {
mEventHandler.onDestroyBubble();
}
 else {
webView.stopLoading();
String urlBefore=webView.getUrl();
String prevUrl=mUrlHistory.pop();
mLoadingPrev=true;
webView.loadUrl(prevUrl);
updateAppsForUrl(webView.getUrl());
if (mYouTubeEmbedHelper != null) {
mYouTubeEmbedHelper.clear();
}
Log.d(TAG,"String_Node_Str" + urlBefore + "String_Node_Str"+ webView.getUrl());
configureOpenInAppButton();
configureOpenEmbedButton();
return true;
}
break;
}
}
}
return false;
}
}
);
mWebView.setDownloadListener(new DownloadListener(){
@Override public void onDownloadStart(String url,String userAgent,String contentDisposition,String mimetype,long contentLength){
openInBrowser(url);
mEventHandler.onDestroyBubble();
}
}
);
if (Settings.get().checkForYouTubeEmbeds()) {
mJSEmbedHandler=new JSEmbedHandler();
mWebView.addJavascriptInterface(mJSEmbedHandler,JS_VARIABLE);
}
updateIncognitoMode(Settings.get().isIncognitoMode());
updateAppsForUrl(url);
configureOpenInAppButton();
configureOpenEmbedButton();
Log.d(TAG,"String_Node_Str" + url);
mStartTime=startTime;
mWebView.loadUrl(url);
mEventHandler.onPageLoading(url);
mTitleTextView.setText(R.string.loading);
mUrlTextView.setText(url.replace("String_Node_Str","String_Node_Str"));
}