public void from(LinearLayout layout) { mLayout = layout; mShowSiteSecurity = false; mShowReader = false; mReaderPopup = null; mAwesomeBar = (Button) mLayout.findViewById(R.id.awesome_bar); mAwesomeBar.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { GeckoApp.mAppContext.hideTabs(); onAwesomeBarSearch(); } }); mAwesomeBar.setOnCreateContextMenuListener( new View.OnCreateContextMenuListener() { public void onCreateContextMenu( ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { MenuInflater inflater = GeckoApp.mAppContext.getMenuInflater(); inflater.inflate(R.menu.titlebar_contextmenu, menu); String clipboard = GeckoAppShell.getClipboardText(); if (clipboard == null || TextUtils.isEmpty(clipboard)) { menu.findItem(R.id.pasteandgo).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } Tab tab = Tabs.getInstance().getSelectedTab(); if (tab != null) { String url = tab.getURL(); if (url == null) { menu.findItem(R.id.copyurl).setVisible(false); menu.findItem(R.id.share).setVisible(false); menu.findItem(R.id.add_to_launcher).setVisible(false); } } else { // if there is no tab, remove anything tab dependent menu.findItem(R.id.copyurl).setVisible(false); menu.findItem(R.id.share).setVisible(false); menu.findItem(R.id.add_to_launcher).setVisible(false); } } }); mPadding = new int[] { mAwesomeBar.getPaddingLeft(), mAwesomeBar.getPaddingTop(), mAwesomeBar.getPaddingRight(), mAwesomeBar.getPaddingBottom() }; mTabs = (ImageButton) mLayout.findViewById(R.id.tabs); mTabs.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { toggleTabs(); } }); mTabs.setImageLevel(0); mTabsCount = (TextSwitcher) mLayout.findViewById(R.id.tabs_count); mTabsCount.removeAllViews(); mTabsCount.setFactory(this); mTabsCount.setText(""); mCount = 0; mBack = (ImageButton) mLayout.findViewById(R.id.back); mBack.setOnClickListener( new Button.OnClickListener() { public void onClick(View view) { Tabs.getInstance().getSelectedTab().doBack(); } }); mForward = (ImageButton) mLayout.findViewById(R.id.forward); mForward.setOnClickListener( new Button.OnClickListener() { public void onClick(View view) { Tabs.getInstance().getSelectedTab().doForward(); } }); mFavicon = (ImageButton) mLayout.findViewById(R.id.favicon); mSiteSecurity = (ImageButton) mLayout.findViewById(R.id.site_security); mSiteSecurity.setOnClickListener( new Button.OnClickListener() { public void onClick(View view) { int[] lockLocation = new int[2]; view.getLocationOnScreen(lockLocation); LayoutParams lockLayoutParams = (LayoutParams) view.getLayoutParams(); // Calculate the left margin for the arrow based on the position of the lock icon. int leftMargin = lockLocation[0] - lockLayoutParams.rightMargin; SiteIdentityPopup.getInstance().show(mSiteSecurity, leftMargin); } }); mProgressSpinner = (AnimationDrawable) mContext.getResources().getDrawable(R.drawable.progress_spinner); mStop = (ImageButton) mLayout.findViewById(R.id.stop); mStop.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { Tab tab = Tabs.getInstance().getSelectedTab(); if (tab != null) tab.doStop(); } }); mReader = (ImageButton) mLayout.findViewById(R.id.reader); mReader.setOnClickListener( new Button.OnClickListener() { public void onClick(View view) { if (mReaderPopup == null) mReaderPopup = new ReaderPopup(GeckoApp.mAppContext); mReaderPopup.show(); } }); mShadow = (ImageView) mLayout.findViewById(R.id.shadow); mHandler = new Handler(); mSlideUpIn = new TranslateAnimation(0, 0, 40, 0); mSlideUpOut = new TranslateAnimation(0, 0, 0, -40); mSlideDownIn = new TranslateAnimation(0, 0, -40, 0); mSlideDownOut = new TranslateAnimation(0, 0, 0, 40); mDuration = 750; mSlideUpIn.setDuration(mDuration); mSlideUpOut.setDuration(mDuration); mSlideDownIn.setDuration(mDuration); mSlideDownOut.setDuration(mDuration); mMenu = (ImageButton) mLayout.findViewById(R.id.menu); mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items); mHasSoftMenuButton = false; if (Build.VERSION.SDK_INT >= 11) mHasSoftMenuButton = true; if (Build.VERSION.SDK_INT >= 14) { if (!ViewConfiguration.get(GeckoApp.mAppContext).hasPermanentMenuKey()) mHasSoftMenuButton = true; else mHasSoftMenuButton = false; } if (mHasSoftMenuButton) { mMenu.setVisibility(View.VISIBLE); mMenu.setOnClickListener( new Button.OnClickListener() { public void onClick(View view) { GeckoApp.mAppContext.openOptionsMenu(); } }); } if (Build.VERSION.SDK_INT >= 11) { View panel = GeckoApp.mAppContext.getMenuPanel(); // If panel is null, the app is starting up for the first time; // add this to the popup only if we have a soft menu button. // else, browser-toolbar is initialized on rotation, // and we need to re-attach action-bar items. if (panel == null) { GeckoApp.mAppContext.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null); panel = GeckoApp.mAppContext.getMenuPanel(); if (mHasSoftMenuButton) { mMenuPopup = new MenuPopup(mContext); mMenuPopup.setPanelView(panel); } } } }