Sharingang/Sharingang-Android

View on GitHub
app/src/main/res/layout/fragment_detailed_item.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<layout 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">

    <data>

        <import type="android.view.View" />

        <variable
            name="ratingVisibility"
            type="int" />

        <variable
            name="sellerVisibility"
            type="int" />

        <variable
            name="quantity"
            type="String"/>

        <variable
            name="item"
            type="com.example.sharingang.models.Item" />

        <variable
            name="username"
            type="String" />
    </data>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingStart="16dp"
        android:paddingEnd="16dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/itemTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{item.title}"
                android:textSize="30sp"
                tools:text="Title" />

        </LinearLayout>

        <ImageView
            android:id="@+id/detailed_item_image"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:contentDescription="@string/item_image_description"
            android:src="@drawable/ic_baseline_image_24" />

        <TextView
            android:id="@+id/itemCategory"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@{item.categoryString}"
            android:textSize="25sp"
            tools:text="Category" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/itemPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{@string/display_price(item.price)}"
                android:textSize="18sp"
                tools:text="10.00" />

            <Space
                android:layout_width="10dp"
                android:layout_height="match_parent" />

            <TextView
                android:id="@+id/itemDiscountPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="12dp"
                android:text="@{@string/display_price(item.discountPrice)}"
                android:visibility="@{item.discount ? View.VISIBLE : View.GONE}"
                android:textSize="18sp"
                tools:text="10.00" />

            <Space
                android:layout_width="10dp"
                android:layout_height="match_parent" />

            <TextView
                android:id="@+id/detailedItemQuantity"
                android:textSize="18sp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{@string/display_quantity(item.quantity)}"/>

        </LinearLayout>

        <TextView
            android:id="@+id/itemDescription"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@{item.description}"
            android:textSize="18sp"
            tools:text="Here goes the description of the item." />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textViewPostedBy"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/posted_by"
                android:textSize="18sp"
                tools:ignore="RtlSymmetry"
                tools:text="Posted by" />


            <Button
                android:id="@+id/itemPostedBy"
                style="@style/Widget.MaterialComponents.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="@{username}"
                android:textColor="@color/themeColor"
                android:textSize="18sp"
                tools:text="TestUser" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                android:gravity="right|center_vertical"
                android:orientation="horizontal"
                tools:ignore="InefficientWeight,RtlHardcoded,UseCompoundDrawables">

                <ImageView
                    android:id="@+id/updateImage"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:srcCompat="@android:drawable/ic_menu_recent_history"
                    android:contentDescription="@string/lastUpdate" />

                <TextView
                    android:id="@+id/lastUpdateText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/lastUpdate" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:visibility="@{sellerVisibility}">

            <Button
                android:id="@+id/buyButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="@string/buy"
                app:layout_constraintEnd_toEndOf="@+id/cardInputWidget"
                app:layout_constraintStart_toStartOf="@+id/cardInputWidget"
                app:layout_constraintTop_toBottomOf="@+id/cardInputWidget" />

            <EditText
                android:id="@+id/buyQuantity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:hint="@string/_1"
                android:autofillHints="@string/_1"
                android:inputType="number"
                android:text="@={quantity}"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <RadioGroup
                android:id="@+id/radioGroup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:orientation="horizontal"
                android:padding="10dp"
                android:visibility="@{ratingVisibility}"
                tools:ignore="UselessParent">

                <androidx.appcompat.widget.AppCompatRadioButton
                    android:id="@+id/radioButton1"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:background="@drawable/rate_left_selector"
                    android:button="@android:color/transparent"
                    android:checked="false"
                    android:gravity="center"
                    android:paddingHorizontal="20dp"
                    android:text="1"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />

                <androidx.appcompat.widget.AppCompatRadioButton
                    android:id="@+id/radioButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:background="@drawable/rate_center_selector"
                    android:button="@android:color/transparent"
                    android:checked="false"
                    android:gravity="center"
                    android:paddingHorizontal="20dp"
                    android:text="2"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />

                <androidx.appcompat.widget.AppCompatRadioButton
                    android:id="@+id/radioButton3"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:background="@drawable/rate_center_selector"
                    android:button="@android:color/transparent"
                    android:checked="false"
                    android:gravity="center"
                    android:paddingHorizontal="20dp"
                    android:text="3"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />

                <androidx.appcompat.widget.AppCompatRadioButton
                    android:id="@+id/radioButton4"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:background="@drawable/rate_center_selector"
                    android:button="@android:color/transparent"
                    android:checked="false"
                    android:gravity="center"
                    android:paddingHorizontal="20dp"
                    android:text="4"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />

                <androidx.appcompat.widget.AppCompatRadioButton
                    android:id="@+id/radioButton5"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:background="@drawable/rate_right_selector"
                    android:button="@android:color/transparent"
                    android:checked="false"
                    android:gravity="center"
                    android:paddingHorizontal="20dp"
                    android:text="5"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />

            </RadioGroup>

            <Button
                android:id="@+id/ratingButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/apply_rating"
                android:visibility="@{ratingVisibility}" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <Button
                android:id="@+id/addToWishlist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/add_wishlist" />

            <Space
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/shareButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="fill_horizontal|top"
                android:contentDescription="@string/share"
                android:backgroundTint="@color/themeColor"
                android:layout_marginTop="16dp"
                app:srcCompat="?attr/actionModeShareDrawable" />

            <Space
                android:layout_width="10dp"
                android:layout_height="wrap_content" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/locateButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="end|bottom"
                android:backgroundTint="@color/themeColor"
                android:layout_marginTop="16dp"
                android:contentDescription="@string/locate_item"
                app:srcCompat="@drawable/baseline_directions_white_24dp" />
        </LinearLayout>

    </LinearLayout>
</layout>