Skip to content

Remove RelativeLayout from Database quickstart #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 12, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,22 @@ public void newPostTest() {

// Select email field
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.fieldEmail),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
allOf(withId(R.id.fieldEmail), isDisplayed()));
appCompatEditText.perform(click());

// Enter email address
ViewInteraction appCompatEditText2 = onView(
allOf(withId(R.id.fieldEmail),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
allOf(withId(R.id.fieldEmail), isDisplayed()));
appCompatEditText2.perform(replaceText(email));

// Enter password
ViewInteraction appCompatEditText3 = onView(
allOf(withId(R.id.fieldPassword),
withParent(withId(R.id.layoutEmailPassword)),
isDisplayed()));
allOf(withId(R.id.fieldPassword), isDisplayed()));
appCompatEditText3.perform(replaceText(password));

// Click sign up
ViewInteraction appCompatButton = onView(
allOf(withId(R.id.buttonSignUp), withText(R.string.sign_up),
withParent(withId(R.id.layoutButtons)),
isDisplayed()));
allOf(withId(R.id.buttonSignUp), withText(R.string.sign_up), isDisplayed()));
appCompatButton.perform(click());

// Click new post button
Expand Down Expand Up @@ -111,9 +103,7 @@ public void newPostTest() {

// Check that it has zero stars
ViewInteraction textView3 = onView(
allOf(withId(R.id.postNumStars), withText("0"),
withParent(withId(R.id.starLayout)),
isDisplayed()));
allOf(withId(R.id.postNumStars), withText("0"), isDisplayed()));
textView3.check(matches(withText("0")));

}
Expand Down
23 changes: 15 additions & 8 deletions database/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
/>

<androidx.viewpager.widget.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabs" />
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tabs" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabNewPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_image_edit"
android:layout_margin="16dp"/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
39 changes: 26 additions & 13 deletions database/app/src/main/res/layout/activity_new_post.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -8,34 +10,45 @@
android:id="@+id/fieldTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:hint="Title"
android:maxLines="1" />
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<EditText
android:id="@+id/fieldBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fieldTitle"
android:layout_marginBottom="5dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="5dp"
android:hint="Write your post..."
android:inputType="textMultiLine"
android:maxLines="10"
android:scrollHorizontally="false" />
android:scrollHorizontally="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fieldTitle"
/>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabSubmitPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/ic_navigation_check_24"/>
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_navigation_check_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
76 changes: 40 additions & 36 deletions database/app/src/main/res/layout/activity_post_detail.xml
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
android:paddingBottom="@dimen/activity_vertical_margin">

<include
android:id="@+id/postAuthorLayout"
layout="@layout/include_post_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<include
android:id="@+id/postTextLayout"
layout="@layout/include_post_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/postAuthorLayout"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp" />
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/postAuthorLayout" />

<LinearLayout
android:id="@+id/commentForm"
android:layout_width="match_parent"
<EditText
android:id="@+id/fieldCommentText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/postTextLayout"
android:layout_marginTop="20dp"
android:weightSum="1.0">
android:layout_marginTop="16dp"
android:hint="Write a comment..."
android:maxLines="1"
app:layout_constraintEnd_toStartOf="@+id/buttonPostComment"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_weight="8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/postTextLayout" />

<EditText
android:id="@+id/fieldCommentText"
android:layout_width="0dp"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:maxLines="1"
android:hint="Write a comment..."/>

<com.google.android.material.button.MaterialButton
android:id="@+id/buttonPostComment"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_weight="0.2"
android:layout_height="wrap_content"
android:text="Post"/>

</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonPostComment"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Post"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@+id/fieldCommentText"
app:layout_constraintTop_toTopOf="@+id/fieldCommentText" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerPostComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/commentForm"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonPostComment"
tools:listitem="@layout/item_comment" />

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading