androidx.coordinatorlayout.widget.CoordinatorLayout Java Examples

The following examples show how to use androidx.coordinatorlayout.widget.CoordinatorLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmojiBSFragment.java    From indigenous-android with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.photoeditor_fragment_bottom_sticker_emoji_dialog, null);
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
    ((View) contentView.getParent()).setBackgroundColor(getResources().getColor(android.R.color.transparent));
    RecyclerView rvEmoji = contentView.findViewById(R.id.rvEmoji);

    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 5);
    rvEmoji.setLayoutManager(gridLayoutManager);
    EmojiAdapter emojiAdapter = new EmojiAdapter();
    rvEmoji.setAdapter(emojiAdapter);
}
 
Example #2
Source File: MapContainerLayoutBehavior.java    From ground-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBottomSheetChanged(
    CoordinatorLayout parent, FrameLayout mapContainerLayout, BottomSheetMetrics metrics) {
  if (metrics.getPeekHeight() <= 0) {
    return;
  }
  View map = mapContainerLayout.findViewById(R.id.map);
  View mapControls = mapContainerLayout.findViewById(R.id.map_controls);
  if (map == null || mapControls == null) {
    // View already destroyed.
    return;
  }
  int translationY = -metrics.getExpansionHeight() / 2;
  map.setTranslationY(translationY);
  float hideRatio = 1.0f - metrics.getRevealRatio();
  mapControls.setAlpha(hideRatio);
}
 
Example #3
Source File: NestedScrollAppBarLayout.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
AutomaticScrollAnimator(final AppBarLayout.Behavior behavior, final int toY) {
    final int fromY = (int) getY();
    this.lastY = fromY;

    setIntValues(fromY, toY);
    setDuration((long) (150.0 + 150.0 * Math.abs(toY - fromY) / getMeasuredHeight()));
    setInterpolator(new DecelerateInterpolator());
    addUpdateListener(animation -> {
        if (behavior != null) {
            int newY = (int) animation.getAnimatedValue();
            int[] total = new int[] {0, lastY - newY};
            int[] consumed = new int[] {0, 0};
            behavior.onNestedPreScroll(
                    (CoordinatorLayout) getParent(), NestedScrollAppBarLayout.this,
                    NestedScrollAppBarLayout.this, total[0], total[1],
                    consumed, ViewCompat.TYPE_TOUCH);
            behavior.onNestedScroll(
                    (CoordinatorLayout) getParent(), NestedScrollAppBarLayout.this,
                    NestedScrollAppBarLayout.this, consumed[0], consumed[1],
                    total[0] - consumed[0], total[1] - consumed[1],
                    ViewCompat.TYPE_TOUCH, consumed);
            lastY = newY;
        }
    });
}
 
Example #4
Source File: FabTransformationBehavior.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
@CallSuper
public boolean layoutDependsOn(
    @NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {
  if (child.getVisibility() == View.GONE) {
    throw new IllegalStateException(
        "This behavior cannot be attached to a GONE view. Set the view to INVISIBLE instead.");
  }

  if (dependency instanceof FloatingActionButton) {
    int expandedComponentIdHint =
        ((FloatingActionButton) dependency).getExpandedComponentIdHint();
    return expandedComponentIdHint == 0 || expandedComponentIdHint == child.getId();
  }
  return false;
}
 
Example #5
Source File: AppBarLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void animateOffsetTo(
    final CoordinatorLayout coordinatorLayout,
    @NonNull final T child,
    final int offset,
    float velocity) {
  final int distance = Math.abs(getTopBottomOffsetForScrollingSibling() - offset);

  final int duration;
  velocity = Math.abs(velocity);
  if (velocity > 0) {
    duration = 3 * Math.round(1000 * (distance / velocity));
  } else {
    final float distanceRatio = (float) distance / child.getHeight();
    duration = (int) ((distanceRatio + 1) * 150);
  }

  animateOffsetWithDuration(coordinatorLayout, child, offset, duration);
}
 
Example #6
Source File: ExtendedFloatingActionButton.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onLayoutChild(
    @NonNull CoordinatorLayout parent,
    @NonNull ExtendedFloatingActionButton child,
    int layoutDirection) {
  // First, let's make sure that the visibility of the FAB is consistent
  final List<View> dependencies = parent.getDependencies(child);
  for (int i = 0, count = dependencies.size(); i < count; i++) {
    final View dependency = dependencies.get(i);
    if (dependency instanceof AppBarLayout) {
      if (updateFabVisibilityForAppBarLayout(parent, (AppBarLayout) dependency, child)) {
        break;
      }
    } else if (isBottomSheet(dependency)) {
      if (updateFabVisibilityForBottomSheet(dependency, child)) {
        break;
      }
    }
  }
  // Now let the CoordinatorLayout lay out the FAB
  parent.onLayoutChild(child, layoutDirection);
  return true;
}
 
Example #7
Source File: BottomSheetUserDialogFragment.java    From intra42 with Apache License 2.0 6 votes vote down vote up
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.fragment_bottom_sheet_user, null);
    dialog.setContentView(contentView);

    imageViewProfile = contentView.findViewById(R.id.imageViewProfile);
    textViewName = contentView.findViewById(R.id.textViewName);

    textViewName.setText(mUser.login);

    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
}
 
Example #8
Source File: BottomSheetDialogTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testShortDialog() throws Throwable {
  showDialog();
  // This ensures that the views are laid out before assertions below
  onView(ViewMatchers.withId(R.id.design_bottom_sheet))
      .perform(setTallPeekHeight())
      .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
  FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
  CoordinatorLayout coordinator = (CoordinatorLayout) bottomSheet.getParent();
  BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
  assertThat(bottomSheet, is(notNullValue()));
  assertThat(coordinator, is(notNullValue()));
  assertThat(behavior, is(notNullValue()));
  // This bottom sheet is shorter than the peek height
  assertThat(bottomSheet.getHeight(), is(lessThan(behavior.getPeekHeight())));
  // Confirm that the bottom sheet is bottom-aligned
  assertThat(bottomSheet.getTop(), is(coordinator.getHeight() - bottomSheet.getHeight()));
}
 
Example #9
Source File: AppBarWithAnchoredFabMarginsTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testFabTopMargin() throws Throwable {
  configureContent(
      R.layout.design_appbar_anchored_fab_margin_top,
      R.string.design_appbar_anchored_fab_margin_top);

  final FloatingActionButton fab = mCoordinatorLayout.findViewById(R.id.fab);
  final CoordinatorLayout.LayoutParams fabLp =
      (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
  assertEquals(mAppBar.getId(), fabLp.getAnchorId());

  final int[] appbarOnScreenXY = new int[2];
  final int[] fabOnScreenXY = new int[2];
  mAppBar.getLocationOnScreen(appbarOnScreenXY);
  fab.getLocationOnScreen(fabOnScreenXY);

  // FAB is horizontally centered in the coordinate system of its anchor (app bar).
  assertEquals(
      appbarOnScreenXY[0] + mAppBar.getWidth() / 2, fabOnScreenXY[0] + fab.getWidth() / 2, 1);
  // Top margin is in the coordinate space of the parent (CoordinatorLayout) and not
  // the anchor. Since our FAB is far enough from the bottom edge of CoordinatorLayout,
  // we are expecting the vertical center of the FAB to be aligned with the bottom edge
  // of its anchor (app bar).
  assertEquals(
      appbarOnScreenXY[1] + mAppBar.getHeight(), fabOnScreenXY[1] + fab.getHeight() / 2, 1);
}
 
Example #10
Source File: AppBarWithAnchoredFabMarginsTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testFabBottomMargin() throws Throwable {
  configureContent(
      R.layout.design_appbar_anchored_fab_margin_bottom,
      R.string.design_appbar_anchored_fab_margin_bottom);

  final FloatingActionButton fab = mCoordinatorLayout.findViewById(R.id.fab);
  final CoordinatorLayout.LayoutParams fabLp =
      (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
  assertEquals(mAppBar.getId(), fabLp.getAnchorId());

  final int[] appbarOnScreenXY = new int[2];
  final int[] fabOnScreenXY = new int[2];
  mAppBar.getLocationOnScreen(appbarOnScreenXY);
  fab.getLocationOnScreen(fabOnScreenXY);

  // FAB is horizontally centered in the coordinate system of its anchor (app bar).
  assertEquals(
      appbarOnScreenXY[0] + mAppBar.getWidth() / 2, fabOnScreenXY[0] + fab.getWidth() / 2, 1);
  // Bottom margin is in the coordinate space of the parent (CoordinatorLayout) and not
  // the anchor. Since our FAB is far enough from the bottom edge of CoordinatorLayout,
  // we are expecting the vertical center of the FAB to be aligned with the bottom edge
  // of its anchor (app bar).
  assertEquals(
      appbarOnScreenXY[1] + mAppBar.getHeight(), fabOnScreenXY[1] + fab.getHeight() / 2, 1);
}
 
Example #11
Source File: NestedScrollAppBarLayout.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child,
                                   View directTargetChild, View target, int nestedScrollAxes, int type) {
    if (super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type)
            && type == ViewCompat.TYPE_TOUCH) {
        bindAppBar(child);
        if (appBarLayout.nestedScrollingListener != null) {
            appBarLayout.nestedScrollingListener.onStartNestedScroll();
        }
        appBarLayout.stopScrollAnimator();
        appBarLayout.setStartY(child.getY());
        return true;
    } else {
        return false;
    }
}
 
Example #12
Source File: HeaderBehavior.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
int setHeaderTopBottomOffset(
    CoordinatorLayout parent, V header, int newOffset, int minOffset, int maxOffset) {
  final int curOffset = getTopAndBottomOffset();
  int consumed = 0;

  if (minOffset != 0 && curOffset >= minOffset && curOffset <= maxOffset) {
    // If we have some scrolling range, and we're currently within the min and max
    // offsets, calculate a new offset
    newOffset = MathUtils.clamp(newOffset, minOffset, maxOffset);

    if (curOffset != newOffset) {
      setTopAndBottomOffset(newOffset);
      // Update how much dy we have consumed
      consumed = curOffset - newOffset;
    }
  }

  return consumed;
}
 
Example #13
Source File: DesignModuleAttributeHelper.java    From proteus with Apache License 2.0 5 votes vote down vote up
private static CoordinatorLayout.LayoutParams getLayoutParams(View v) {
  CoordinatorLayout.LayoutParams result = null;
  ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
  if (null != layoutParams && layoutParams instanceof CoordinatorLayout.LayoutParams) {
    result = (CoordinatorLayout.LayoutParams) layoutParams;
  }
  return result;
}
 
Example #14
Source File: BottomSheetBehavior.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * A utility function to get the {@link BottomSheetBehavior} associated with the {@code view}.
 *
 * @param view The {@link View} with {@link BottomSheetBehavior}.
 * @return The {@link BottomSheetBehavior} associated with the {@code view}.
 */
@NonNull
@SuppressWarnings("unchecked")
public static <V extends View> BottomSheetBehavior<V> from(@NonNull V view) {
  ViewGroup.LayoutParams params = view.getLayoutParams();
  if (!(params instanceof CoordinatorLayout.LayoutParams)) {
    throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
  }
  CoordinatorLayout.Behavior<?> behavior =
      ((CoordinatorLayout.LayoutParams) params).getBehavior();
  if (!(behavior instanceof BottomSheetBehavior)) {
    throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
  }
  return (BottomSheetBehavior<V>) behavior;
}
 
Example #15
Source File: NestedScrollAppBarLayout.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child,
                               View target, int type) {
    super.onStopNestedScroll(coordinatorLayout, child, target, type);
    bindAppBar(child);
    if (appBarLayout.nestedScrollingListener != null) {
        appBarLayout.nestedScrollingListener.onStopNestedScroll();
    }

    float top = child.getY();
    float height = child.getMeasuredHeight();
    float bottom = top + height;
    appBarLayout.computerHeightData();

    if (appBarLayout.scrollHeight > 0 || appBarLayout.enterAlwaysHeight > 0) {
        if (appBarLayout.getStartY() == top) {
            return;
        } if (appBarLayout.getStartY() > top) {  // drag up.
            appBarLayout.hideTopBar(this);
        } else if (appBarLayout.getStartY() < top) { // drag down.
            if (bottom > appBarLayout.enterAlwaysHeight + appBarLayout.staticHeight) {
                appBarLayout.showTopBar(this);
            } else if (bottom > appBarLayout.staticHeight) {
                appBarLayout.showEnterAlwaysBar(this);
            }
        }
    }
}
 
Example #16
Source File: BottomSheetBehavior.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * A utility function to get the {@link BottomSheetBehavior} associated with the {@code view}.
 *
 * @param view The {@link View} with {@link BottomSheetBehavior}.
 * @return The {@link BottomSheetBehavior} associated with the {@code view}.
 */
@NonNull
@SuppressWarnings("unchecked")
public static <V extends View> BottomSheetBehavior<V> from(@NonNull V view) {
    ViewGroup.LayoutParams params = view.getLayoutParams();
    if (!(params instanceof CoordinatorLayout.LayoutParams)) {
        throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
    }
    CoordinatorLayout.Behavior<?> behavior =
            ((CoordinatorLayout.LayoutParams) params).getBehavior();
    if (!(behavior instanceof BottomSheetBehavior)) {
        throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
    }
    return (BottomSheetBehavior<V>) behavior;
}
 
Example #17
Source File: AppBarBoundFabBehavior.java    From appbarsyncedfab with Apache License 2.0 5 votes vote down vote up
@Override
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton child, @NonNull View dependency) {
    if (dependency instanceof AppBarLayout && !listenerRegistered) {
        ((AppBarLayout) dependency).addOnOffsetChangedListener(new FabOffsetter(parent, child));
        listenerRegistered = true;
    }
    return dependency instanceof AppBarLayout || super.layoutDependsOn(parent, child, dependency);
}
 
Example #18
Source File: FabScrollBehaviour.java    From leafpicrevived with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
    if (dyConsumed > 0)
        child.animate().translationY(child.getHeight() * 4).setInterpolator(new AccelerateInterpolator(2)).start();
    else
        child.animate().translationY(/*-Measure.getNavigationBarSize(coordinatorLayout
        .getContext()).y*/0).setInterpolator(new DecelerateInterpolator(2)).start();
}
 
Example #19
Source File: BottomSheetBehavior.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(
    @NonNull CoordinatorLayout coordinatorLayout,
    @NonNull V child,
    @NonNull View directTargetChild,
    @NonNull View target,
    int axes,
    int type) {
  lastNestedScrollDy = 0;
  nestedScrolled = false;
  return (axes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
}
 
Example #20
Source File: FooterBehavior.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
    if (dyConsumed > 0) {
        hide(child);
    } else if (dyConsumed < 0) {
        show(child);
    }
}
 
Example #21
Source File: AppBarBoundFabBehavior.java    From appbarsyncedfab with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
    //noinspection SimplifiableIfStatement
    if (dependency instanceof AppBarLayout) {
        // if the dependency is an AppBarLayout, do not allow super to react on that
        // we don't want that behavior
        return true;
    } else if (dependency instanceof Snackbar.SnackbarLayout) {
        updateFabTranslationForSnackbar(parent, fab, dependency);
        return true;
    }
    return super.onDependentViewChanged(parent, fab, dependency);
}
 
Example #22
Source File: BottomNavBarFabBehaviour.java    From BottomNavigation with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
    if (isDependent(dependency)) {
        updateFabTranslationForBottomNavigationBar(parent, child, dependency);
        return false;
    }

    return super.onDependentViewChanged(parent, child, dependency);
}
 
Example #23
Source File: DynamicBottomSheetBehavior.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
        @NonNull V child, @NonNull View target, int dxConsumed, int dyConsumed,
        int dxUnconsumed, int dyUnconsumed, int type, @NonNull int[] consumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed,
            dyConsumed, dxUnconsumed, dyUnconsumed, type, consumed);
    if (dyConsumed > 0) {
        if (getState() != STATE_COLLAPSED && getState() != STATE_SETTLING) {
            setState(STATE_COLLAPSED);
        }
    }
}
 
Example #24
Source File: FabScrollBehavior.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
                                   @NonNull FloatingActionButton child,
                                   @NonNull View directTargetChild,
                                   @NonNull View target, int axes, int type) {
    // Ensure we react to vertical scrolling
    return type == ViewCompat.TYPE_TOUCH && axes == ViewCompat.SCROLL_AXIS_VERTICAL;
}
 
Example #25
Source File: BottomSheetBehavior.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onRestoreInstanceState(
    @NonNull CoordinatorLayout parent, @NonNull V child, @NonNull Parcelable state) {
  SavedState ss = (SavedState) state;
  super.onRestoreInstanceState(parent, child, ss.getSuperState());
  // Restore Optional State values designated by saveFlags
  restoreOptionalState(ss);
  // Intermediate states are restored as collapsed state
  if (ss.state == STATE_DRAGGING || ss.state == STATE_SETTLING) {
    this.state = STATE_COLLAPSED;
  } else {
    this.state = ss.state;
  }
}
 
Example #26
Source File: BottomSheetBehavior.java    From bottomsheetrecycler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
    if (!child.isShown()) {
        return false;
    }
    int action = event.getActionMasked();
    if (state == STATE_DRAGGING && action == MotionEvent.ACTION_DOWN) {
        return true;
    }
    if (viewDragHelper != null) {
        viewDragHelper.processTouchEvent(event);
    }
    // Record the velocity
    if (action == MotionEvent.ACTION_DOWN) {
        reset();
    }
    if (velocityTracker == null) {
        velocityTracker = VelocityTracker.obtain();
    }
    velocityTracker.addMovement(event);
    // The ViewDragHelper tries to capture only the top-most View. We have to explicitly tell it
    // to capture the bottom sheet in case it is not captured and the touch slop is passed.
    if (action == MotionEvent.ACTION_MOVE && !ignoreEvents) {
        if (Math.abs(initialY - event.getY()) > viewDragHelper.getTouchSlop()) {
            viewDragHelper.captureChildView(child, event.getPointerId(event.getActionIndex()));
        }
    }
    return !ignoreEvents;
}
 
Example #27
Source File: AppBarWithToolbarTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testUpdateAccessibilityActionsWithEnterAlwaysFlag() throws Throwable {
  configureContent(
      R.layout.design_appbar_toolbar_scroll_fitsystemwindows,
      R.string.design_appbar_toolbar_scroll_tabs_pin);

  final int[] appbarOnScreenXY = new int[2];
  mAppBar.getLocationOnScreen(appbarOnScreenXY);

  final int originalAppbarBottom = appbarOnScreenXY[1] + mAppBar.getHeight();
  final int centerX = appbarOnScreenXY[0] + mAppBar.getWidth() / 2;

  final int appbarHeight = mAppBar.getHeight();
  final int longSwipeAmount = 3 * appbarHeight / 2;

  // Call onLayout so the accessibility actions are initially updated.
  activityTestRule.runOnUiThread(
      () -> {
        final CoordinatorLayout.Behavior<AppBarLayout> behavior =
            ((CoordinatorLayout.LayoutParams) mAppBar.getLayoutParams()).getBehavior();
        behavior.onLayoutChild(mCoordinatorLayout, mAppBar, mAppBar.getLayoutDirection());
      });

  // Very top of screen, can scroll forward to collapse but can't scroll backward.
  assertAccessibilityHasScrollForwardAction(true);
  assertAccessibilityHasScrollBackwardAction(false);

  // Perform a swipe-up gesture across the horizontal center of the screen.
  performVerticalSwipeUpGesture(
      R.id.coordinator_layout,
      centerX,
      originalAppbarBottom + 3 * longSwipeAmount / 2,
      longSwipeAmount);

  // AppBar has been collapsed fully so we can't scroll forward. Can scroll backward since
  // the bar will always be entered/expanded on scroll.
  assertAccessibilityHasScrollForwardAction(false);
  assertAccessibilityHasScrollBackwardAction(true);
}
 
Example #28
Source File: LocationHelpDialog.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetTextI18n")
private void initWidget(View view) {
    if (getActivity() == null) {
        return;
    }

    CoordinatorLayout container = view.findViewById(R.id.dialog_location_help_container);
    container.setBackgroundColor(ThemeManager.getInstance(requireActivity()).getRootColor(getActivity()));

    ((TextView) view.findViewById(R.id.dialog_location_help_title)).setTextColor(
            ThemeManager.getInstance(requireActivity()).getTextTitleColor(getActivity()));

    view.findViewById(R.id.dialog_location_help_permissionContainer)
            .setOnClickListener(v -> IntentHelper.startApplicationDetailsActivity(getActivity()));
    ((TextView) view.findViewById(R.id.dialog_location_help_permissionTitle)).setTextColor(
            ThemeManager.getInstance(requireActivity()).getTextContentColor(getActivity()));

    view.findViewById(R.id.dialog_location_help_locationContainer)
            .setOnClickListener(v -> IntentHelper.startLocationSettingsActivity(getActivity()));
    ((TextView) view.findViewById(R.id.dialog_location_help_locationTitle)).setTextColor(
            ThemeManager.getInstance(requireActivity()).getTextContentColor(getActivity()));

    view.findViewById(R.id.dialog_location_help_providerContainer)
            .setOnClickListener(v -> IntentHelper.startSelectProviderActivity(getActivity()));
    ((TextView) view.findViewById(R.id.dialog_location_help_providerTitle)).setTextColor(
            ThemeManager.getInstance(requireActivity()).getTextContentColor(getActivity()));

    view.findViewById(R.id.dialog_location_help_manageContainer).setOnClickListener(v ->
            IntentHelper.startManageActivityForResult(getActivity(), MainActivity.MANAGE_ACTIVITY)
    );
    ((TextView) view.findViewById(R.id.dialog_location_help_manageTitle)).setTextColor(
            ThemeManager.getInstance(requireActivity()).getTextContentColor(getActivity()));
    ((TextView) view.findViewById(R.id.dialog_location_help_manageTitle)).setText(
            getString(R.string.feedback_add_location_manually).replace(
                    "$", getString(R.string.current_location)
            )
    );
}
 
Example #29
Source File: ModalStackTest.java    From react-native-navigation with MIT License 5 votes vote down vote up
@Override
public void beforeEach() {
    activity = newActivity();
    childRegistry = new ChildControllersRegistry();
    root = new SimpleViewController(activity, childRegistry, "root", new Options());

    FrameLayout rootLayout = new FrameLayout(activity);
    CoordinatorLayout modalsLayout = new CoordinatorLayout(activity);
    FrameLayout contentLayout = new FrameLayout(activity);
    contentLayout.addView(rootLayout);
    contentLayout.addView(modalsLayout);
    activity.setContentView(contentLayout);

    animator = spy(new ModalAnimatorMock(activity));
    presenter = spy(new ModalPresenter(animator));
    uut = new ModalStack(presenter);
    uut.setModalsLayout(modalsLayout);
    uut.setRootLayout(rootLayout);
    emitter = Mockito.mock(EventEmitter.class);
    uut.setEventEmitter(emitter);
    modal1 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_1, new Options()));
    modal2 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_2, new Options()));
    modal3 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_3, new Options()));
    modal4 = spy(new SimpleViewController(activity, childRegistry, MODAL_ID_4, new Options()));
    stack = TestUtils.newStackController(activity)
            .setChildren(modal4)
            .build();
}
 
Example #30
Source File: ArticleTabFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
private void updateFloatingMenu() {
    CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mFam.getLayoutParams();
    mBehavior = (ScrollAwareFamBehavior) lp.getBehavior();
    if (mConfig.isLeftHandMode()) {
        lp.gravity = Gravity.START | Gravity.BOTTOM;
        mFam.setExpandDirection(FloatingActionsMenu.EXPAND_UP, FloatingActionsMenu.LABELS_ON_RIGHT_SIDE);
        mFam.setLayoutParams(lp);
    }
}