Program: 117656
Project: 117656
Buggy source:
private synchronized void initialize(){
  mClickHandler=new ClickHandler(this);
  mParentBackground=(RelativeLayout)findViewById(R.id.background);
  mUrlBar=(RelativeLayout)findViewById(R.id.urlBar);
  mNewTab=(LinearLayout)findViewById(R.id.action_new_tab);
  mBack=(ImageView)findViewById(R.id.back);
  mForward=(ImageView)findViewById(R.id.forward);
  mOptions=(ImageView)findViewById(R.id.options);
  mTabLayout=(LinearLayout)findViewById(R.id.TabLayout);
  mBrowserFrame=(FrameLayout)findViewById(R.id.holder);
  mTabScrollView=(HorizontalScrollView)findViewById(R.id.tabScroll);
  mSearch=(AutoCompleteTextView)findViewById(R.id.enterUrl);
  mDeleteIcon=getResources().getDrawable(R.drawable.ic_action_delete);
  mDeleteIcon.setBounds(0,0,Utils.convertToDensityPixels(mContext,24),Utils.convertToDensityPixels(mContext,24));
  mRefreshIcon=getResources().getDrawable(R.drawable.ic_action_refresh);
  mRefreshIcon.setBounds(0,0,Utils.convertToDensityPixels(mContext,24),Utils.convertToDensityPixels(mContext,24));
  mIcon=mRefreshIcon;
  mProgressBar=(ProgressBar)findViewById(R.id.progressBar);
  if (mWebViewList != null) {
    mWebViewList.clear();
  }
 else {
    mWebViewList=new ArrayList<LightningView>();
  }
  if (mTabList != null) {
    mTabList.clear();
  }
 else {
    mTabList=new ArrayList<TextView>();
  }
  if (mIdList != null) {
    mIdList.clear();
  }
 else {
    mIdList=new ArrayList<Integer>();
  }
  mHomepage=mPreferences.getString(PreferenceConstants.HOMEPAGE,Constants.HOMEPAGE);
  mSystemBrowser=getSystemBrowser();
  mMenu=new PopupMenu(mContext,mOptions);
  mMenu.setOnMenuItemClickListener(new OnMenuItemClickListener(){
    @Override public boolean onMenuItemClick(    MenuItem item){
switch (item.getItemId()) {
case R.id.action_new_tab:
        newTab(true,null);
      return true;
case R.id.action_incognito:
    startActivity(new Intent(mContext,IncognitoActivity.class));
  return true;
case R.id.action_share:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
  Intent shareIntent=new Intent(android.content.Intent.ACTION_SEND);
  shareIntent.setType("String_Node_Str");
  shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,mCurrentView.getTitle());
  String shareMessage=mCurrentView.getUrl();
  shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,shareMessage);
  startActivity(Intent.createChooser(shareIntent,getResources().getString(R.string.dialog_title_share)));
}
return true;
case R.id.action_bookmarks:
openBookmarkPage(mCurrentView.getWebView());
return true;
case R.id.action_copy:
if (mCurrentView != null) {
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
ClipboardManager clipboard=(ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
ClipData clip=ClipData.newPlainText("String_Node_Str",mCurrentView.getUrl().toString());
clipboard.setPrimaryClip(clip);
Utils.showToast(mContext,mContext.getResources().getString(R.string.message_link_copied));
}
}
return true;
case R.id.action_settings:
startActivity(new Intent(mContext,SettingsActivity.class));
return true;
case R.id.action_history:
openHistory();
return true;
case R.id.action_add_bookmark:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
addBookmark(mContext,mCurrentView.getTitle(),mCurrentView.getUrl());
}
return true;
case R.id.action_find:
findInPage();
return true;
default :
return true;
}
}
}
);
mMenuInflater=mMenu.getMenuInflater();
mMenuInflater.inflate(getMenu(),mMenu.getMenu());
OnTouchListener drag=null;
if (API > 18) {
drag=mMenu.getDragToOpenListener();
}
if (drag != null) {
mOptions.setOnTouchListener(drag);
}
mOptions.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mMenu.show();
}
}
);
mBack.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
if (mCurrentView.canGoBack()) {
mCurrentView.goBack();
}
 else {
deleteTab(mCurrentView.getId());
}
}
}
);
mForward.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
if (mCurrentView.canGoForward()) {
mCurrentView.goForward();
}
}
}
);
mNewTab.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
newTab(true,null);
}
}
);
mNewTab.setOnLongClickListener(new OnLongClickListener(){
@Override public boolean onLongClick(View v){
String url=mPreferences.getString(PreferenceConstants.SAVE_URL,null);
if (url != null) {
newTab(true,url);
Toast.makeText(mContext,R.string.deleted_tab,Toast.LENGTH_SHORT).show();
}
mEditPrefs.putString(PreferenceConstants.SAVE_URL,null);
return false;
}
}
);
mSearch.setOnFocusChangeListener(new View.OnFocusChangeListener(){
@Override public void onFocusChange(View v,boolean hasFocus){
if (!hasFocus && mCurrentView != null) {
if (mCurrentView != null) {
if (mCurrentView.getProgress() < 100) {
setIsLoading();
}
 else {
setIsFinishedLoading();
}
}
updateUrl(mCurrentView.getUrl());
}
 else if (hasFocus) {
}
}
}
);
mSearch.setOnKeyListener(new OnKeyListener(){
@Override public boolean onKey(View arg0,int arg1,KeyEvent arg2){
switch (arg1) {
case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(),0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
default :
break;
}
return false;
}
}
);
mSearch.setOnTouchListener(new OnTouchListener(){
@SuppressLint("String_Node_Str") @Override public boolean onTouch(View v,MotionEvent event){
if (mSearch.getCompoundDrawables()[2] != null) {
boolean tappedX=event.getX() > (mSearch.getWidth() - mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
if (tappedX) {
if (event.getAction() == MotionEvent.ACTION_UP) {
refreshOrStop();
}
return true;
}
}
return false;
}
}
);
mSearch.setOnEditorActionListener(new OnEditorActionListener(){
@Override public boolean onEditorAction(TextView arg0,int actionId,KeyEvent arg2){
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_SEARCH || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(),0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
}
return false;
}
}
);
mAddTab=AnimationUtils.loadAnimation(mContext,R.anim.up);
mSlideDownAnimation=AnimationUtils.loadAnimation(mContext,R.anim.slide_down);
mSlideUpAnimation=AnimationUtils.loadAnimation(mContext,R.anim.slide_up);
mSlideDownAnimation.setAnimationListener(new AnimationListener(){
@Override public void onAnimationEnd(Animation animation){
}
@Override public void onAnimationRepeat(Animation animation){
}
@Override public void onAnimationStart(Animation animation){
mUrlBar.setVisibility(View.VISIBLE);
}
}
);
mSlideUpAnimation.setAnimationListener(new AnimationListener(){
@Override public void onAnimationEnd(Animation animation){
mUrlBar.setVisibility(View.INVISIBLE);
}
@Override public void onAnimationRepeat(Animation animation){
}
@Override public void onAnimationStart(Animation animation){
}
}
);
if (mHistoryHandler == null) {
mHistoryHandler=new DatabaseHandler(this);
}
 else if (!mHistoryHandler.isOpen()) {
mHistoryHandler=new DatabaseHandler(this);
}
mHistoryDatabase=mHistoryHandler.getReadableDatabase();
if (API < 19) {
WebIconDatabase.getInstance().open(getDir("String_Node_Str",MODE_PRIVATE).getPath());
}
initializeSearchSuggestions(mSearch);
initializeTabs();
mPreferences.getBoolean(PreferenceConstants.USE_PROXY,false);
checkForTor();
}

Fixed version (ground truth):
private synchronized void initialize(){
  mClickHandler=new ClickHandler(this);
  mParentBackground=(RelativeLayout)findViewById(R.id.background);
  mUrlBar=(RelativeLayout)findViewById(R.id.urlBar);
  mNewTab=(LinearLayout)findViewById(R.id.action_new_tab);
  mBack=(ImageView)findViewById(R.id.back);
  mForward=(ImageView)findViewById(R.id.forward);
  mOptions=(ImageView)findViewById(R.id.options);
  mTabLayout=(LinearLayout)findViewById(R.id.TabLayout);
  mBrowserFrame=(FrameLayout)findViewById(R.id.holder);
  mTabScrollView=(HorizontalScrollView)findViewById(R.id.tabScroll);
  mSearch=(AutoCompleteTextView)findViewById(R.id.enterUrl);
  mDeleteIcon=getResources().getDrawable(R.drawable.ic_action_delete);
  mDeleteIcon.setBounds(0,0,Utils.convertToDensityPixels(mContext,24),Utils.convertToDensityPixels(mContext,24));
  mRefreshIcon=getResources().getDrawable(R.drawable.ic_action_refresh);
  mRefreshIcon.setBounds(0,0,Utils.convertToDensityPixels(mContext,24),Utils.convertToDensityPixels(mContext,24));
  mIcon=mRefreshIcon;
  mProgressBar=(ProgressBar)findViewById(R.id.progressBar);
  if (mWebViewList != null) {
    mWebViewList.clear();
  }
 else {
    mWebViewList=new ArrayList<LightningView>();
  }
  if (mTabList != null) {
    mTabList.clear();
  }
 else {
    mTabList=new ArrayList<TextView>();
  }
  if (mIdList != null) {
    mIdList.clear();
  }
 else {
    mIdList=new ArrayList<Integer>();
  }
  mHomepage=mPreferences.getString(PreferenceConstants.HOMEPAGE,Constants.HOMEPAGE);
  mSystemBrowser=getSystemBrowser();
  mMenu=new PopupMenu(mContext,mOptions);
  mMenu.setOnMenuItemClickListener(new OnMenuItemClickListener(){
    @Override public boolean onMenuItemClick(    MenuItem item){
switch (item.getItemId()) {
case R.id.action_new_tab:
        newTab(true,null);
      return true;
case R.id.action_incognito:
    startActivity(new Intent(mContext,IncognitoActivity.class));
  return true;
case R.id.action_share:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
  Intent shareIntent=new Intent(android.content.Intent.ACTION_SEND);
  shareIntent.setType("String_Node_Str");
  shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,mCurrentView.getTitle());
  String shareMessage=mCurrentView.getUrl();
  shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,shareMessage);
  startActivity(Intent.createChooser(shareIntent,getResources().getString(R.string.dialog_title_share)));
}
return true;
case R.id.action_bookmarks:
openBookmarkPage(mCurrentView.getWebView());
return true;
case R.id.action_copy:
if (mCurrentView != null) {
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
ClipboardManager clipboard=(ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
ClipData clip=ClipData.newPlainText("String_Node_Str",mCurrentView.getUrl().toString());
clipboard.setPrimaryClip(clip);
Utils.showToast(mContext,mContext.getResources().getString(R.string.message_link_copied));
}
}
return true;
case R.id.action_settings:
startActivity(new Intent(mContext,SettingsActivity.class));
return true;
case R.id.action_history:
openHistory();
return true;
case R.id.action_add_bookmark:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
addBookmark(mContext,mCurrentView.getTitle(),mCurrentView.getUrl());
}
return true;
case R.id.action_find:
findInPage();
return true;
default :
return true;
}
}
}
);
mMenuInflater=mMenu.getMenuInflater();
mMenuInflater.inflate(getMenu(),mMenu.getMenu());
OnTouchListener drag=null;
if (API > 18) {
drag=mMenu.getDragToOpenListener();
}
if (drag != null) {
mOptions.setOnTouchListener(drag);
}
mOptions.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mMenu.show();
}
}
);
mBack.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
if (mCurrentView.canGoBack()) {
mCurrentView.goBack();
}
 else {
deleteTab(mCurrentView.getId());
}
}
}
);
mForward.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
if (mCurrentView.canGoForward()) {
mCurrentView.goForward();
}
}
}
);
mNewTab.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
newTab(true,null);
}
}
);
mNewTab.setOnLongClickListener(new OnLongClickListener(){
@Override public boolean onLongClick(View v){
String url=mPreferences.getString(PreferenceConstants.SAVE_URL,null);
if (url != null) {
newTab(true,url);
Toast.makeText(mContext,R.string.deleted_tab,Toast.LENGTH_SHORT).show();
}
mEditPrefs.putString(PreferenceConstants.SAVE_URL,null).apply();
return true;
}
}
);
mSearch.setOnFocusChangeListener(new View.OnFocusChangeListener(){
@Override public void onFocusChange(View v,boolean hasFocus){
if (!hasFocus && mCurrentView != null) {
if (mCurrentView != null) {
if (mCurrentView.getProgress() < 100) {
setIsLoading();
}
 else {
setIsFinishedLoading();
}
}
updateUrl(mCurrentView.getUrl());
}
 else if (hasFocus) {
}
}
}
);
mSearch.setOnKeyListener(new OnKeyListener(){
@Override public boolean onKey(View arg0,int arg1,KeyEvent arg2){
switch (arg1) {
case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(),0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
default :
break;
}
return false;
}
}
);
mSearch.setOnTouchListener(new OnTouchListener(){
@SuppressLint("String_Node_Str") @Override public boolean onTouch(View v,MotionEvent event){
if (mSearch.getCompoundDrawables()[2] != null) {
boolean tappedX=event.getX() > (mSearch.getWidth() - mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
if (tappedX) {
if (event.getAction() == MotionEvent.ACTION_UP) {
refreshOrStop();
}
return true;
}
}
return false;
}
}
);
mSearch.setOnEditorActionListener(new OnEditorActionListener(){
@Override public boolean onEditorAction(TextView arg0,int actionId,KeyEvent arg2){
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_SEARCH || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(),0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
}
return false;
}
}
);
mAddTab=AnimationUtils.loadAnimation(mContext,R.anim.up);
mSlideDownAnimation=AnimationUtils.loadAnimation(mContext,R.anim.slide_down);
mSlideUpAnimation=AnimationUtils.loadAnimation(mContext,R.anim.slide_up);
mSlideDownAnimation.setAnimationListener(new AnimationListener(){
@Override public void onAnimationEnd(Animation animation){
}
@Override public void onAnimationRepeat(Animation animation){
}
@Override public void onAnimationStart(Animation animation){
mUrlBar.setVisibility(View.VISIBLE);
}
}
);
mSlideUpAnimation.setAnimationListener(new AnimationListener(){
@Override public void onAnimationEnd(Animation animation){
mUrlBar.setVisibility(View.INVISIBLE);
}
@Override public void onAnimationRepeat(Animation animation){
}
@Override public void onAnimationStart(Animation animation){
}
}
);
if (mHistoryHandler == null) {
mHistoryHandler=new DatabaseHandler(this);
}
 else if (!mHistoryHandler.isOpen()) {
mHistoryHandler=new DatabaseHandler(this);
}
mHistoryDatabase=mHistoryHandler.getReadableDatabase();
if (API < 19) {
WebIconDatabase.getInstance().open(getDir("String_Node_Str",MODE_PRIVATE).getPath());
}
initializeSearchSuggestions(mSearch);
initializeTabs();
mPreferences.getBoolean(PreferenceConstants.USE_PROXY,false);
checkForTor();
}