@Override
    View getContentView(PagerAdapter pages) {
      detailEmptyView = helper.buildDetailEmptyView();

      SplitPaneLayout result = new SplitPaneLayout(helper.getHost());

      result.setOrientation(SplitPaneLayout.ORIENTATION_HORIZONTAL);
      result.setSplitterDrawable(helper.getResources().getDrawable(R.drawable.divider_horizontal));

      FrameLayout listFrame = new FrameLayout(helper.getHost());
      ListView list = buildListView(helper.getHost());

      listFrame.addView(
          list,
          new FrameLayout.LayoutParams(
              FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));

      View listEmptyView = helper.buildListEmptyView();

      listFrame.addView(
          listEmptyView,
          new FrameLayout.LayoutParams(
              FrameLayout.LayoutParams.WRAP_CONTENT,
              FrameLayout.LayoutParams.WRAP_CONTENT,
              Gravity.CENTER));
      list.setEmptyView(listEmptyView);

      result.addView(
          listFrame,
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

      detailSource = pages;
      detailTarget = new FrameLayout(helper.getHost());

      // must have an ID to work for FragmentPagerAdapter
      detailTarget.setId(pagerId);
      detailTarget.addView(
          detailEmptyView,
          new FrameLayout.LayoutParams(
              FrameLayout.LayoutParams.WRAP_CONTENT,
              FrameLayout.LayoutParams.WRAP_CONTENT,
              Gravity.CENTER));

      result.addView(
          detailTarget,
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
      result.setSplitterPositionPercent(.3f);

      return (result);
    }
Example #2
0
  @Test
  public void dump_shouldDumpStructure() throws Exception {
    child3.setId(R.id.snippet_text);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    shadowOf(root).dump(new PrintStream(out), 0);
    assertEquals(
        "<FrameLayout>\n"
            + "  <View/>\n"
            + "  <View/>\n"
            + "  <FrameLayout id=\"id/snippet_text\">\n"
            + "    <View/>\n"
            + "    <View/>\n"
            + "  </FrameLayout>\n"
            + "</FrameLayout>\n",
        out.toString());
  }
  @Test
  public void dump_shouldDumpStructure() throws Exception {
    child3.setId(R.id.snippet_text);
    child3b.setVisibility(View.GONE);
    TextView textView = new TextView(context);
    textView.setText("Here's some text!");
    textView.setVisibility(View.INVISIBLE);
    child3.addView(textView);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    shadowOf(root).dump(new PrintStream(out), 0);
    assertEquals(
        "<FrameLayout>\n"
            + "  <View/>\n"
            + "  <View/>\n"
            + "  <FrameLayout id=\"id/snippet_text\">\n"
            + "    <View/>\n"
            + "    <View visibility=\"GONE\"/>\n"
            + "    <TextView visibility=\"INVISIBLE\" text=\"Here&apos;s some text!\"/>\n"
            + "  </FrameLayout>\n"
            + "</FrameLayout>\n",
        out.toString());
  }
  private ViewGroup generateLayout() {
    if (DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
      throw new IllegalStateException(
          "You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
      requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
      // Don't allow an action bar if there is no title.
      requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
      requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
      requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
      if (mIsFloating) {
        // Trash original dialog LinearLayout
        mDecor = (ViewGroup) mDecor.getParent();
        mDecor.removeAllViews();

        layoutResource = R.layout.abs__dialog_title_holo;
      } else {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
          layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
          layoutResource = R.layout.abs__screen_action_bar;
        }
      }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY)
        && !hasFeature(Window.FEATURE_NO_TITLE)) {
      layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
      layoutResource = R.layout.abs__screen_simple;
    }

    if (DEBUG)
      Log.d(
          TAG,
          "[generateLayout] using screen XML "
              + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup) mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
      throw new RuntimeException("Couldn't find content container view");
    }

    // Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
      IcsProgressBar progress = getCircularProgressBar(false);
      if (progress != null) {
        progress.setIndeterminate(true);
      }
    }

    return contentParent;
  }
Example #5
0
  public Materialize build() {
    // we need an activity for this
    if (mActivity == null) {
      throw new RuntimeException("please pass an activity");
    }

    // if the user has not set a drawerLayout use the default one :D
    mScrimInsetsLayout =
        (ScrimInsetsFrameLayout)
            mActivity.getLayoutInflater().inflate(R.layout.materialize, mRootView, false);

    // check if the activity was initialized correctly
    if (mRootView == null || mRootView.getChildCount() == 0) {
      throw new RuntimeException(
          "You have to set your layout for this activity with setContentView() first. Or you build the drawer on your own with .buildView()");
    }

    // get the content view
    View originalContentView = mRootView.getChildAt(0);

    boolean alreadyInflated = originalContentView.getId() == R.id.materialize_root;

    // define the statusBarColor
    if (mStatusBarColor == 0 && mStatusBarColorRes != -1) {
      mStatusBarColor = mActivity.getResources().getColor(mStatusBarColorRes);
    } else if (mStatusBarColor == 0) {
      mStatusBarColor =
          UIUtils.getThemeColorFromAttrOrRes(
              mActivity, R.attr.colorPrimaryDark, R.color.materialize_primary_dark);
    }

    // handling statusBar / navigationBar tinting
    mScrimInsetsLayout.setInsetForeground(mStatusBarColor);
    mScrimInsetsLayout.setTintStatusBar(mTintStatusBar);
    mScrimInsetsLayout.setTintNavigationBar(mTintNavigationBar);

    // if we are fullscreen remove all insets
    mScrimInsetsLayout.setSystemUIVisible(!mFullscreen && !mSystemUIHidden);

    // do some magic specific to the statusBar
    if (!alreadyInflated && mTranslucentStatusBar) {
      if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
        UIUtils.setTranslucentStatusFlag(mActivity, true);
      }
      if (Build.VERSION.SDK_INT >= 19) {
        if (mTranslucentStatusBarProgrammatically) {
          mActivity
              .getWindow()
              .getDecorView()
              .setSystemUiVisibility(
                  View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
      }
      if (Build.VERSION.SDK_INT >= 21) {
        UIUtils.setTranslucentStatusFlag(mActivity, false);
        if (mTranslucentStatusBarProgrammatically) {
          mActivity.getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
      }
      mScrimInsetsLayout.getView().setPadding(0, UIUtils.getStatusBarHeight(mActivity), 0, 0);
    }

    // do some magic specific to the navigationBar
    if (!alreadyInflated && mTranslucentNavigationBar) {
      if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
        UIUtils.setTranslucentNavigationFlag(mActivity, true);
      }
      if (Build.VERSION.SDK_INT >= 19) {
        if (mTranslucentNavigationBarProgrammatically) {
          mActivity
              .getWindow()
              .getDecorView()
              .setSystemUiVisibility(
                  View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
          UIUtils.setTranslucentNavigationFlag(mActivity, true);
        }
      }
      if (Build.VERSION.SDK_INT >= 21) {
        if (mTranslucentNavigationBarProgrammatically) {
          mActivity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
        }
      }
    }

    // set the flags if we want to hide the system ui
    if (mSystemUIHidden) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        View decorView = this.mActivity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
      }
    }

    // only add the new layout if it wasn't done before
    if (!alreadyInflated) {
      // remove the contentView
      mRootView.removeView(originalContentView);
    } else {
      // if it was already inflated we have to clean up again
      mRootView.removeAllViews();
    }

    // create the layoutParams to use for the contentView
    FrameLayout.LayoutParams layoutParamsContentView =
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    // if we have a translucent navigation bar set the bottom margin
    if (!mFullscreen && mTranslucentNavigationBar && Build.VERSION.SDK_INT >= 19) {
      layoutParamsContentView.bottomMargin = UIUtils.getNavigationBarHeight(mActivity);
    }

    // add the contentView to the drawer content frameLayout
    mScrimInsetsLayout.getView().addView(originalContentView, layoutParamsContentView);

    // if we have a mContainer we use this one
    mContentRoot = mScrimInsetsLayout.getView();
    if (mContainer != null) {
      mContentRoot = mContainer;
      mContentRoot.addView(
          mScrimInsetsLayout.getView(),
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }

    // set the id so we can check if it was already inflated
    mContentRoot.setId(R.id.materialize_root);

    // make sure we have the correct layoutParams
    if (mContainerLayoutParams == null) {
      mContainerLayoutParams =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    }
    // add the drawerLayout to the root
    mRootView.addView(mContentRoot, mContainerLayoutParams);

    // set activity to null as we do not need it anymore
    this.mActivity = null;

    // create a Materialize object with the builder
    return new Materialize(this);
  }
Example #6
0
 public final View a(int i, ViewGroup viewgroup) {
   viewgroup = (TextView) g.inflate(0x7f030256, viewgroup, false);
   viewgroup.setText(c(i));
   viewgroup.setId(((c) b.get(i)).e);
   return viewgroup;
 }