[fenix] Fix truncated tracking protection info text

* Allow tracking protection titles to wrap instead of being cut off
* Refactor view ids to match the layout
pull/600/head
Josh Vocal 5 years ago committed by Emily Kager
parent ba65f30cbd
commit c888e71c40

@ -11,8 +11,6 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.withStyledAttributes import androidx.core.content.withStyledAttributes
import kotlinx.android.synthetic.main.switch_with_description.view.* 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 mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
import org.mozilla.fenix.R import org.mozilla.fenix.R
@ -36,13 +34,13 @@ class SwitchWithDescription @JvmOverloads constructor(
id id
) )
) )
switchItemTitle.text = resources.getString( trackingProtectionCategoryTitle.text = resources.getString(
getResourceId( getResourceId(
R.styleable.SwitchWithDescription_switchTitle, R.styleable.SwitchWithDescription_switchTitle,
R.string.preference_enhanced_tracking_protection R.string.preference_enhanced_tracking_protection
) )
) )
switchItemDescription.text = resources.getString( trackingProtectionCategoryItemDescription.text = resources.getString(
getResourceId( getResourceId(
R.styleable.SwitchWithDescription_switchDescription, R.styleable.SwitchWithDescription_switchDescription,
R.string.preference_enhanced_tracking_protection_explanation R.string.preference_enhanced_tracking_protection_explanation

@ -30,14 +30,14 @@ class TrackingProtectionCategoryItem @JvmOverloads constructor(
R.styleable.TrackingProtectionCategory_categoryItemIcon, R.styleable.TrackingProtectionCategory_categoryItemIcon,
R.drawable.ic_cryptominers R.drawable.ic_cryptominers
) )
switchIcon?.background = resources.getDrawable(id, context.theme) trackingProtectionCategoryIcon?.background = resources.getDrawable(id, context.theme)
switchItemTitle?.text = resources.getString( trackingProtectionCategoryTitle?.text = resources.getString(
getResourceId( getResourceId(
R.styleable.TrackingProtectionCategory_categoryItemTitle, R.styleable.TrackingProtectionCategory_categoryItemTitle,
R.string.etp_cookies_title R.string.etp_cookies_title
) )
) )
switchItemDescription?.text = resources.getString( trackingProtectionCategoryItemDescription?.text = resources.getString(
getResourceId( getResourceId(
R.styleable.TrackingProtectionCategory_categoryItemDescription, R.styleable.TrackingProtectionCategory_categoryItemDescription,
R.string.etp_cookies_description R.string.etp_cookies_description

@ -162,7 +162,7 @@ class TrackingProtectionPanelView(
} }
private fun bindTrackingProtectionInfo(isTrackingProtectionOn: Boolean) { 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) view.context.getString(if (isTrackingProtectionOn) R.string.etp_panel_on else R.string.etp_panel_off)
trackingProtectionSwitch.switch_widget.isChecked = isTrackingProtectionOn trackingProtectionSwitch.switch_widget.isChecked = isTrackingProtectionOn
trackingProtectionSwitch.switch_widget.jumpDrawablesToCurrentState() trackingProtectionSwitch.switch_widget.jumpDrawablesToCurrentState()

@ -10,7 +10,7 @@
<TextView <TextView
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:id="@+id/switchItemTitle" android:id="@+id/trackingProtectionCategoryTitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="48dp" android:layout_marginStart="48dp"
@ -18,7 +18,7 @@
android:clickable="false" android:clickable="false"
android:textAppearance="@style/ListItemTextStyle" android:textAppearance="@style/ListItemTextStyle"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/switchItemDescription" app:layout_constraintBottom_toTopOf="@+id/trackingProtectionCategoryItemDescription"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -27,17 +27,17 @@
tools:text="@tools:sample/lorem" /> tools:text="@tools:sample/lorem" />
<TextView <TextView
android:id="@+id/switchItemDescription" android:id="@+id/trackingProtectionCategoryItemDescription"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="false" android:clickable="false"
android:textColor="?attr/secondaryText" android:textColor="?attr/secondaryText"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent" 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_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@id/switchItemTitle" app:layout_constraintStart_toStartOf="@id/trackingProtectionCategoryTitle"
app:layout_constraintTop_toBottomOf="@+id/switchItemTitle" app:layout_constraintTop_toBottomOf="@+id/trackingProtectionCategoryTitle"
app:layout_constraintVertical_chainStyle="packed" app:layout_constraintVertical_chainStyle="packed"
tools:text="@tools:sample/lorem" /> tools:text="@tools:sample/lorem" />
@ -48,7 +48,7 @@
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal" android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal" android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal"
app:drawableStartCompat="@drawable/ic_tracking_protection" 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_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/switchItemTitle" /> app:layout_constraintTop_toTopOf="@id/trackingProtectionCategoryTitle" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -10,7 +10,7 @@
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<ImageView <ImageView
android:id="@+id/switchIcon" android:id="@+id/trackingProtectionCategoryIcon"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal" android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
@ -24,23 +24,24 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/switchItemTitle" android:id="@+id/trackingProtectionCategoryTitle"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal" android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginEnd="@dimen/library_item_icon_margin_horizontal" android:layout_marginEnd="16dp"
android:clickable="false" android:clickable="false"
android:textAppearance="@style/ListItemTextStyle" android:textAppearance="@style/ListItemTextStyle"
android:textSize="16sp" 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_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@id/switchIcon" app:layout_constraintStart_toEndOf="@id/trackingProtectionCategoryIcon"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="@tools:sample/lorem" /> tools:text="@tools:sample/lorem" />
<TextView <TextView
android:id="@+id/switchItemDescription" android:id="@+id/trackingProtectionCategoryItemDescription"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/library_item_icon_margin_horizontal" android:layout_marginStart="@dimen/library_item_icon_margin_horizontal"
@ -51,7 +52,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@id/switchIcon" app:layout_constraintStart_toEndOf="@id/trackingProtectionCategoryIcon"
app:layout_constraintTop_toBottomOf="@+id/switchItemTitle" app:layout_constraintTop_toBottomOf="@+id/trackingProtectionCategoryTitle"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />
</merge> </merge>

Loading…
Cancel
Save