Skip to content

Commit

Permalink
refactor(crash, functions): replace RelativeLayout with ConstraintLay…
Browse files Browse the repository at this point in the history
…out (firebase#1235)

* refactor(crashlytics): replace RelativeLayout with ConstraintLayout
* refactor(functions): replace RelativeLayout with ConstraintLayout
  • Loading branch information
thatfiredev authored Dec 28, 2020
1 parent 6d82733 commit 0c39fb9
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 99 deletions.
28 changes: 16 additions & 12 deletions crash/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

<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 @@ -24,25 +25,28 @@ specific language governing permissions and limitations under the License.
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:src="@drawable/firebase_lockup_400" />
android:src="@drawable/firebase_lockup_400"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/crashButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/icon"
android:layout_centerHorizontal="true"
android:text="@string/crash_button_label" />
android:text="@string/crash_button_label"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="@+id/icon"
app:layout_constraintStart_toStartOf="@+id/icon"
app:layout_constraintTop_toBottomOf="@+id/icon" />

<CheckBox
android:id="@+id/catchCrashCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/crashButton"
android:layout_alignLeft="@+id/crashButton"
android:layout_below="@+id/crashButton"
android:text="@string/catch_crash_checkbox_label"
android:layout_marginTop="10dp"
android:text="@string/catch_crash_checkbox_label" />
</RelativeLayout>
app:layout_constraintEnd_toEndOf="@+id/crashButton"
app:layout_constraintStart_toStartOf="@+id/crashButton"
app:layout_constraintTop_toBottomOf="@+id/crashButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
182 changes: 95 additions & 87 deletions functions/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ specific language governing permissions and limitations under the License.
app:cardBackgroundColor="@android:color/white"
app:cardUseCompatPadding="true">

<RelativeLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<TextView
Expand All @@ -52,69 +52,76 @@ specific language governing permissions and limitations under the License.
android:layout_height="wrap_content"
android:text="@string/heading_add_numbers"
android:textSize="20sp"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/fieldFirstNumber"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
app:layout_constraintStart_toStartOf="@+id/header_add_numbers"
app:layout_constraintTop_toBottomOf="@+id/header_add_numbers"
tools:text="1" />

<LinearLayout
android:id="@+id/form_add_numbers"
android:layout_width="match_parent"
<TextView
android:id="@+id/labelPlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/plus"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/fieldFirstNumber"
app:layout_constraintStart_toEndOf="@+id/fieldFirstNumber"
app:layout_constraintTop_toTopOf="@+id/fieldFirstNumber" />

<EditText
android:id="@+id/fieldSecondNumber"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_below="@+id/header_add_numbers"
android:orientation="horizontal">

<EditText
android:id="@+id/fieldFirstNumber"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
tools:text="1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/plus"
android:textSize="14sp"
android:textStyle="bold" />

<EditText
android:id="@+id/fieldSecondNumber"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="center"
android:inputType="number"
tools:text="1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/equals"
android:textSize="14sp"
android:textStyle="bold" />

<EditText
android:id="@+id/fieldAddResult"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:enabled="false"
android:gravity="center"
android:inputType="number"
tools:text="2" />

</LinearLayout>
android:gravity="center"
android:inputType="number"
tools:text="1"
app:layout_constraintBottom_toBottomOf="@+id/labelPlus"
app:layout_constraintStart_toEndOf="@+id/labelPlus"
app:layout_constraintTop_toTopOf="@+id/labelPlus" />

<TextView
android:id="@+id/labelEquals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/equals"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/fieldSecondNumber"
app:layout_constraintStart_toEndOf="@+id/fieldSecondNumber"
app:layout_constraintTop_toTopOf="@+id/fieldSecondNumber" />

<EditText
android:id="@+id/fieldAddResult"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:enabled="false"
android:gravity="center"
android:inputType="number"
tools:text="2"
app:layout_constraintBottom_toBottomOf="@+id/labelEquals"
app:layout_constraintStart_toEndOf="@+id/labelEquals"
app:layout_constraintTop_toTopOf="@+id/labelEquals" />


<com.google.android.material.button.MaterialButton
android:id="@+id/buttonCalculate"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/form_add_numbers"
android:text="@string/calculate" />
android:text="@string/calculate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fieldFirstNumber" />


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

</com.google.android.material.card.MaterialCardView>

Expand All @@ -125,9 +132,9 @@ specific language governing permissions and limitations under the License.
app:cardBackgroundColor="@android:color/white"
app:cardUseCompatPadding="true">

<RelativeLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<TextView
Expand All @@ -136,54 +143,55 @@ specific language governing permissions and limitations under the License.
android:layout_height="wrap_content"
android:text="@string/heading_add_message"
android:textSize="20sp"
android:textStyle="bold" />

android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/form_add_message"
<EditText
android:id="@+id/fieldMessageInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header_add_message"
android:orientation="vertical">

<EditText
android:id="@+id/fieldMessageInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/input"
tools:text="some bad message" />

<EditText
android:id="@+id/fieldMessageOutput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/output"
tools:text="some clean message" />

</LinearLayout>
android:hint="@string/input"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header_add_message"
tools:text="some bad message" />

<EditText
android:id="@+id/fieldMessageOutput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/output"
android:inputType="text"
app:layout_constraintEnd_toEndOf="@+id/fieldMessageInput"
app:layout_constraintStart_toStartOf="@+id/fieldMessageInput"
app:layout_constraintTop_toBottomOf="@+id/fieldMessageInput"
tools:text="some clean message" />

<com.google.android.material.button.MaterialButton
android:id="@+id/buttonSignIn"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/buttonAddMessage"
android:layout_toLeftOf="@+id/buttonAddMessage"
android:layout_toStartOf="@+id/buttonAddMessage"
android:text="@string/sign_in" />
android:layout_toLeftOf="@+id/buttonAddMessage"
android:text="@string/sign_in"
app:layout_constraintEnd_toStartOf="@+id/buttonAddMessage"
app:layout_constraintTop_toBottomOf="@+id/fieldMessageOutput" />

<com.google.android.material.button.MaterialButton
android:id="@+id/buttonAddMessage"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/form_add_message"
android:text="@string/add_message" />
android:text="@string/add_message"
app:layout_constraintEnd_toEndOf="@+id/fieldMessageOutput"
app:layout_constraintTop_toBottomOf="@+id/fieldMessageOutput" />

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

</com.google.android.material.card.MaterialCardView>

Expand Down

0 comments on commit 0c39fb9

Please sign in to comment.