view_tubi_ad_learn_more.xml


Overview

`view_tubi_ad_learn_more.xml` is an Android layout resource file that defines the visual structure and data bindings for a compact "Learn More" advertisement view in the Tubi TV application. The view is designed to display information about the number of ads remaining, a message indicating when ads will resume, and a clickable "Learn More" button (if applicable) that directs users to more information about the current ad.

This layout utilizes Android Data Binding to dynamically update UI components based on the state exposed by a `UserController` class, specifically reacting to ad-related data such as the number of ads left and the presence of an ad click URL.


Detailed Explanation

Root Element

Data Binding Setup

<data>
    <import type="android.view.View" />
    <import type="android.text.TextUtils" />
    <variable
        name="controller"
        type="com.tubitv.media.bindings.UserController" />
</data>

View Hierarchy and Components

The root view is a **ConstraintLayout** with `match_parent` width and `wrap_content` height, ensuring the view wraps its content horizontally and vertically.

1. Ads Remaining Label

<com.tubitv.ui.VaudTextView
    android:id="@+id/view_tubi_ad_learn_more_ads_remaining"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:maxLines="1"
    android:textColor="@color/tubi_tv_golden_gate"
    android:textSize="@dimen/view_tubi_ad_learn_more_text_size"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="Ad" />

2. Ads Remaining Description

<com.tubitv.ui.VaudTextView
    android:id="@+id/view_tubi_ad_learn_more_ads_resume_shortly"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dp"
    android:maxLines="1"
    android:text="@{String.format(@string/view_tubi_ad_learn_more_ads_remaining_text, controller.numberOfAdsLeft)}"
    android:textColor="@android:color/white"
    android:textSize="@dimen/view_tubi_ad_learn_more_text_size"
    app:layout_constraintBottom_toBottomOf="@+id/view_tubi_ad_learn_more_ads_remaining"
    app:layout_constraintLeft_toRightOf="@+id/view_tubi_ad_learn_more_ads_remaining"
    app:layout_constraintTop_toTopOf="@+id/view_tubi_ad_learn_more_ads_remaining" />

3. Learn More Button Container (Clickable)

<android.support.constraint.ConstraintLayout
    android:id="@+id/view_tubi_ad_learn_more_ads_learn_ll"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/tubi_tv_player_ad_learn_more_background"
    android:clickable="true"
    android:onClick="@{()-> controller.clickCurrentAd()}"
    android:visibility="@{!TextUtils.isEmpty(controller.adClickUrl) ? View.VISIBLE : View.GONE }"
    app:layout_constraintBottom_toBottomOf="@+id/view_tubi_ad_learn_more_ads_resume_shortly"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/view_tubi_ad_learn_more_ads_resume_shortly">
Contents of Learn More Button:

Parameters and Data Binding Variables

Variable Name

Type

Description

`controller`

`com.tubitv.media.bindings.UserController`

Provides ad-related data and event handlers used to update the view dynamically.

**Key Properties from `controller` used:**


Usage Example

This layout is intended to be used within an Android UI component (e.g., a Fragment or Activity) that has a `UserController` instance bound to it. The binding would typically be set up as follows:

ViewTubiAdLearnMoreBinding binding = ViewTubiAdLearnMoreBinding.inflate(layoutInflater);
binding.setController(userController);

Once set, the UI automatically updates:


Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram

flowchart TD
    A[view_tubi_ad_learn_more.xml Layout] --> B[ConstraintLayout (Root)]
    
    B --> C[VaudTextView: ads_remaining_label]
    B --> D[VaudTextView: ads_remaining_description]
    B --> E[ConstraintLayout: learn_more_button_container]
    
    E --> F[VaudTextView: learn_more_text]
    E --> G[ImageView: learn_more_icon]
    
    %% Data Binding Links
    B -- binds --> H[UserController]
    H -- provides --> D["numberOfAdsLeft"]
    H -- provides --> E["adClickUrl" visibility]
    E -- click triggers --> H["clickCurrentAd()"]

Summary

`view_tubi_ad_learn_more.xml` is a data-bound Android layout that visually presents ad-related information and interaction options within the Tubi TV app. It dynamically reflects the state of ad playback, showing how many ads remain and providing a conditional "Learn More" button linked to the current ad's URL. The layout leverages ConstraintLayout for flexible design, custom text views for branding, and data binding for clean, reactive UI updates tied to a `UserController` data source. This file is a UI component integrated into the ad playback experience, enhancing user engagement by offering clear, actionable information during ads.


If you need further details on the `UserController` or other components interacting with this layout, please provide the relevant source files or documentation.