public static void showActionsMenu() {
   RelativeLayout actionsButton = (RelativeLayout) mShell.findViewById(R.id.action_button);
   RelativeLayout touchInterceptor = (RelativeLayout) mShell.findViewById(R.id.touch_interceptor);
   View actionsMenu = mShell.getActionMenuView();
   actionsButton.setOnClickListener(
       new UiMenuOnClickListener(mShell, actionsMenu, touchInterceptor, 2));
   actionsButton.setVisibility(View.VISIBLE);
 }
  @Override
  public void onCreate() {
    super.onCreate();

    LayoutInflater inflater = LayoutInflater.from(this);
    mShell = (UiShell) inflater.inflate(R.layout.ui_application_container, null);

    View navMenu = inflater.inflate(R.layout.ui_navigation_menu, null);
    View actionsMenu = inflater.inflate(R.layout.ui_actions_menu, null);
    View activityContainer = inflater.inflate(R.layout.ui_activity_container, null);

    RelativeLayout touchInterceptor =
        (RelativeLayout) activityContainer.findViewById(R.id.touch_interceptor);
    RelativeLayout menuButton = (RelativeLayout) activityContainer.findViewById(R.id.menu_button);
    RelativeLayout actionsButton =
        (RelativeLayout) activityContainer.findViewById(R.id.action_button);

    menuButton.setOnClickListener(new UiMenuOnClickListener(mShell, navMenu, touchInterceptor, 0));
    actionsButton.setOnClickListener(
        new UiMenuOnClickListener(mShell, actionsMenu, touchInterceptor, 2));

    final View[] children = new View[] {navMenu, activityContainer, actionsMenu};
    int scrollToViewIndex = 1;
    mShell.initViews(children, scrollToViewIndex);

    mContentContainer = (FrameLayout) mShell.findViewById(R.id.content_container);
  }
  public static void detachShell() {
    // Basically, contentView of Activity, we're doing the opposite of setContentView
    ViewGroup parent = (ViewGroup) mShell.getParent();
    parent.removeView(mShell);

    // Clear out activity specific stuff from shell
    clearActionsMenu();
    unbindDrawables(mShell.findViewById(R.id.content_container));
  }
  public static void initializeShell(Activity activity, int layoutId) {
    mCurrentActivity = activity;

    // First, initialize Navigation menu
    LinearLayout bookmarksListButton =
        (LinearLayout) mShell.findViewById(R.id.nav_bookmarks_list_button);
    bookmarksListButton.setOnClickListener(
        new UiNavigationItemOnClickListener(mShell, ListBookmarks.class, activity));
    LinearLayout historyListButton =
        (LinearLayout) mShell.findViewById(R.id.nav_recent_history_button);
    historyListButton.setOnClickListener(
        new UiNavigationItemOnClickListener(mShell, RecentHistory.class, activity));
    LinearLayout accountsButton = (LinearLayout) mShell.findViewById(R.id.nav_account_button);
    accountsButton.setOnClickListener(
        new UiNavigationItemOnClickListener(mShell, Account.class, activity));

    // Then Actions menu
    clearActionsMenu();

    RelativeLayout infoItButton = (RelativeLayout) mShell.findViewById(R.id.infoit_button);
    infoItButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            EasyTracker.getTracker()
                .trackEvent(
                    Constants.SHELL_CATEGORY,
                    Constants.SHELL_INFOIT_BUTTON,
                    getCurrentActivity().getClass().getName(),
                    0);
            Intent intent = new Intent(mCurrentActivity, InfoChooser.class);
            mCurrentActivity.startActivity(intent);
          }
        });

    setBackgroundColor(R.color.standard_bg);

    setActivityContent(layoutId);
    mShell.scrollToApplicationView();
  }
    @Override
    public void run() {
      LinearLayout actionsButtons =
          (LinearLayout) mShell.findViewById(R.id.action_buttons_container);

      ImageView menuSeparator = new ImageView(mShell.getContext());
      Drawable menuSeparatorImage = mShell.getResources().getDrawable(R.drawable.ui_menu_separator);
      menuSeparator.setImageDrawable(menuSeparatorImage);
      menuSeparator.setScaleType(ScaleType.FIT_XY);
      LayoutParams separatorParams =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

      actionsButtons.addView(mButton, actionsButtons.getChildCount());
      actionsButtons.addView(menuSeparator, separatorParams);
    }
 private static void clearActionsMenu() {
   LinearLayout actionsButtons = (LinearLayout) mShell.findViewById(R.id.action_buttons_container);
   actionsButtons.removeAllViews();
 }
 public static void setBackgroundColor(int color) {
   FrameLayout activityContainer = (FrameLayout) mShell.findViewById(R.id.activity_container);
   activityContainer.setBackgroundResource(color);
 }
 public static void hideActionsMenu() {
   RelativeLayout actionsButton = (RelativeLayout) mShell.findViewById(R.id.action_button);
   actionsButton.setOnClickListener(null);
   actionsButton.setVisibility(View.INVISIBLE);
 }