Esempio n. 1
0
  @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);
  }
Esempio n. 2
0
  public static void addActionsButton(BaseButton baseButton) {
    Drawable iconImage = mShell.getResources().getDrawable(baseButton.getButtonIconId());

    int ten_dip = (int) (10 * mShell.getResources().getDisplayMetrics().density);

    ImageView buttonIcon = new ImageView(mShell.getContext());
    buttonIcon.setImageDrawable(iconImage);
    LayoutParams iconParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    iconParams.setMargins(ten_dip, 0, 0, 0);
    iconParams.gravity = Gravity.CENTER_VERTICAL;

    TextView buttonText = new TextView(mShell.getContext());
    buttonText.setText(baseButton.getButtonText());
    buttonText.setTextColor(Color.WHITE);
    buttonText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    LayoutParams textParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    buttonText.setPadding(ten_dip, ten_dip, ten_dip, ten_dip);

    LinearLayout button = new LinearLayout(mShell.getContext());
    button.addView(buttonIcon, iconParams);
    button.addView(buttonText, textParams);

    baseButton.setActionImageView(buttonIcon);
    baseButton.setActionTextView(buttonText);

    button.setOnClickListener(baseButton.getOnClickListener());

    ActionButtonRunnable addButtonRunnable = new ActionButtonRunnable(button);
    mCurrentActivity.runOnUiThread(addButtonRunnable);
  }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
  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));
  }
Esempio n. 5
0
    @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);
    }
Esempio n. 6
0
  private static void setActivityContent(int layoutId) {
    LayoutInflater inflater = LayoutInflater.from(mShell.getContext());
    View content = (View) inflater.inflate(layoutId, null);

    FrameLayout.LayoutParams lp =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    setContentContainerSize();
    mContentContainer.addView(content, lp);
  }
 @Override
 public void onClick(View v) {
   if (mCurrentActivity.getClass().equals(mTargetContext)) {
     RelativeLayout touchInterceptor =
         (RelativeLayout) mCurrentActivity.findViewById(R.id.touch_interceptor);
     touchInterceptor.setVisibility(View.GONE);
     mParent.scrollToApplicationView();
   } else {
     Intent intent = new Intent(mCurrentActivity, mTargetContext);
     mCurrentActivity.startActivity(intent);
   }
 }
Esempio n. 8
0
  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();
  }
Esempio n. 9
0
  public static void setSplashScreen() {
    LayoutInflater inflater = LayoutInflater.from(mShell.getContext());
    View splashScreen = (View) inflater.inflate(R.layout.ui_splash_screen, null);

    TextView splashText = (TextView) splashScreen.findViewById(R.id.splash_text);
    splashText.setText("Downloading information...");

    FrameLayout.LayoutParams lp =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mContentContainer.addView(splashScreen, 0, lp);

    mContentContainer.getChildAt(1).setVisibility(View.INVISIBLE);
  }
Esempio n. 10
0
 private static void clearActionsMenu() {
   LinearLayout actionsButtons = (LinearLayout) mShell.findViewById(R.id.action_buttons_container);
   actionsButtons.removeAllViews();
 }
Esempio n. 11
0
 public static void setBackgroundColor(int color) {
   FrameLayout activityContainer = (FrameLayout) mShell.findViewById(R.id.activity_container);
   activityContainer.setBackgroundResource(color);
 }
Esempio n. 12
0
 public static void hideActionsMenu() {
   RelativeLayout actionsButton = (RelativeLayout) mShell.findViewById(R.id.action_button);
   actionsButton.setOnClickListener(null);
   actionsButton.setVisibility(View.INVISIBLE);
 }