Commit 9449cb44 authored by Josh Vocal's avatar Josh Vocal Committed by Emily Kager
Browse files

Fix truncated tracking protection info text

* Allow tracking protection titles to wrap instead of being cut off
* Refactor view ids to match the layout
parent eae3209f
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.withStyledAttributes
import kotlinx.android.synthetic.main.switch_with_description.view.*
import kotlinx.android.synthetic.main.tracking_protection_category.view.switchItemDescription
import kotlinx.android.synthetic.main.tracking_protection_category.view.switchItemTitle
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
import org.mozilla.fenix.R

@@ -36,13 +34,13 @@ class SwitchWithDescription @JvmOverloads constructor(
                    id
                )
            )
            switchItemTitle.text = resources.getString(
            trackingProtectionCategoryTitle.text = resources.getString(
                getResourceId(
                    R.styleable.SwitchWithDescription_switchTitle,
                    R.string.preference_enhanced_tracking_protection
                )
            )
            switchItemDescription.text = resources.getString(
            trackingProtectionCategoryItemDescription.text = resources.getString(
                getResourceId(
                    R.styleable.SwitchWithDescription_switchDescription,
                    R.string.preference_enhanced_tracking_protection_explanation
+3 −3
Original line number Diff line number Diff line
@@ -30,14 +30,14 @@ class TrackingProtectionCategoryItem @JvmOverloads constructor(
                R.styleable.TrackingProtectionCategory_categoryItemIcon,
                R.drawable.ic_cryptominers
            )
            switchIcon?.background = resources.getDrawable(id, context.theme)
            switchItemTitle?.text = resources.getString(
            trackingProtectionCategoryIcon?.background = resources.getDrawable(id, context.theme)
            trackingProtectionCategoryTitle?.text = resources.getString(
                getResourceId(
                    R.styleable.TrackingProtectionCategory_categoryItemTitle,
                    R.string.etp_cookies_title
                )
            )
            switchItemDescription?.text = resources.getString(
            trackingProtectionCategoryItemDescription?.text = resources.getString(
                getResourceId(
                    R.styleable.TrackingProtectionCategory_categoryItemDescription,
                    R.string.etp_cookies_description
+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ class TrackingProtectionPanelView(
    }

    private fun bindTrackingProtectionInfo(isTrackingProtectionOn: Boolean) {
        trackingProtectionSwitch.switchItemDescription.text =
        trackingProtectionSwitch.trackingProtectionCategoryItemDescription.text =
            view.context.getString(if (isTrackingProtectionOn) R.string.etp_panel_on else R.string.etp_panel_off)
        trackingProtectionSwitch.switch_widget.isChecked = isTrackingProtectionOn
        trackingProtectionSwitch.switch_widget.jumpDrawablesToCurrentState()
+8 −8
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@

    <TextView
        android:layout_marginTop="4dp"
        android:id="@+id/switchItemTitle"
        android:id="@+id/trackingProtectionCategoryTitle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="48dp"
@@ -18,7 +18,7 @@
        android:clickable="false"
        android:textAppearance="@style/ListItemTextStyle"
        android:textSize="16sp"
        app:layout_constraintBottom_toTopOf="@+id/switchItemDescription"
        app:layout_constraintBottom_toTopOf="@+id/trackingProtectionCategoryItemDescription"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toStartOf="parent"
@@ -27,17 +27,17 @@
        tools:text="@tools:sample/lorem" />

    <TextView
        android:id="@+id/switchItemDescription"
        android:id="@+id/trackingProtectionCategoryItemDescription"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:textColor="?attr/secondaryText"
        android:layout_marginBottom="4dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@id/switchItemTitle"
        app:layout_constraintEnd_toEndOf="@id/trackingProtectionCategoryTitle"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="@id/switchItemTitle"
        app:layout_constraintTop_toBottomOf="@+id/switchItemTitle"
        app:layout_constraintStart_toStartOf="@id/trackingProtectionCategoryTitle"
        app:layout_constraintTop_toBottomOf="@+id/trackingProtectionCategoryTitle"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="@tools:sample/lorem" />

@@ -48,7 +48,7 @@
        android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
        android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal"
        app:drawableStartCompat="@drawable/ic_tracking_protection"
        app:layout_constraintBottom_toBottomOf="@id/switchItemDescription"
        app:layout_constraintBottom_toBottomOf="@id/trackingProtectionCategoryItemDescription"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/switchItemTitle" />
        app:layout_constraintTop_toTopOf="@id/trackingProtectionCategoryTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
+10 −9
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
    tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">

    <ImageView
        android:id="@+id/switchIcon"
        android:id="@+id/trackingProtectionCategoryIcon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
@@ -24,23 +24,24 @@
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/switchItemTitle"
        android:layout_width="wrap_content"
        android:id="@+id/trackingProtectionCategoryTitle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal"
        android:layout_marginEnd="16dp"
        android:clickable="false"
        android:textAppearance="@style/ListItemTextStyle"
        android:textSize="16sp"
        app:layout_constraintBottom_toTopOf="@+id/switchItemDescription"
        app:layout_constraintBottom_toTopOf="@+id/trackingProtectionCategoryItemDescription"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@id/switchIcon"
        app:layout_constraintStart_toEndOf="@id/trackingProtectionCategoryIcon"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="@tools:sample/lorem" />

    <TextView
        android:id="@+id/switchItemDescription"
        android:id="@+id/trackingProtectionCategoryItemDescription"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
@@ -51,7 +52,7 @@
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@id/switchIcon"
        app:layout_constraintTop_toBottomOf="@+id/switchItemTitle"
        app:layout_constraintStart_toEndOf="@id/trackingProtectionCategoryIcon"
        app:layout_constraintTop_toBottomOf="@+id/trackingProtectionCategoryTitle"
        tools:text="@tools:sample/lorem/random" />
</merge>