2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/2392 - Adds icon to private browsing onboarding card

This commit is contained in:
Jeff Boek 2019-05-20 13:01:26 -07:00
parent ea87c7384c
commit faaa8d9b93
3 changed files with 61 additions and 12 deletions

View File

@ -19,7 +19,10 @@ import org.mozilla.fenix.R
class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(view) {
init {
val icon = object : ImageSpan(view.context, R.drawable.ic_private_browsing) {
val iconDrawable = view.context.getDrawable(R.drawable.ic_private_browsing)!!
iconDrawable.setBounds(0, 0, view.description_text.lineHeight, view.description_text.lineHeight)
val icon = object : ImageSpan(iconDrawable) {
override fun draw(
canvas: Canvas,
text: CharSequence?,
@ -41,9 +44,10 @@ class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(
canvas.restore()
}
}
val text = SpannableString(view.context.getString(R.string.onboarding_private_browsing_description))
val text = SpannableString(view.context.getString(R.string.onboarding_private_browsing_description))
val spanStartIndex = text.indexOf(IMAGE_PLACEHOLDER)
text.setSpan(
icon,
spanStartIndex,

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M17.5,17c-2.1,0 -3.5,-2.5 -5.5,-2.5S8.4,17 6.5,17C3.9,17 2,14.6 2,10.4 2,7.8 2.8,7 6.1,7s4.3,1.4 5.9,1.4c1.6,0 2.6,-1.4 5.9,-1.4 3.3,0 4.1,0.8 4.1,3.4 0,4.2 -1.9,6.6 -4.5,6.6zM7.7,10.2c-2,0.1 -2.9,1.3 -2.9,1.6 0,0.3 1.3,1.1 2.7,1.1 1.3,0 2.9,-0.5 2.9,-0.9 0,-0.5 -0.8,-1.9 -2.7,-1.8zM16.3,10.2c-1.9,-0.1 -2.7,1.3 -2.7,1.8 0,0.4 1.5,0.9 2.9,0.9s2.7,-0.8 2.7,-1.1c-0.1,-0.3 -0.9,-1.5 -2.9,-1.6z">
<aapt:attr name="android:fillColor">
<gradient
android:type="linear"
android:tileMode="clamp"
android:startX="23.24"
android:startY="-0.94"
android:endX="1.81"
android:endY="16.33">
<item android:color="#FF5C29CC" android:offset="0" />
<item android:color="#FF7A145C" android:offset="1" />
</gradient>
</aapt:attr>
</path>
</vector>

View File

@ -2,24 +2,42 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout
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"
android:id="@+id/onboarding_card"
style="@style/OnboardingCardLight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/private_browsing_icon"
android:layout_width="30dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="H,1:1"
android:src="@drawable/ic_onboarding_private_browsing"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/header_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="14dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="@string/onboarding_private_browsing_header"
android:textAppearance="@style/HeaderTextStyle" />
android:gravity="center_vertical"
android:lines="1"
android:textAppearance="@style/HeaderTextStyle"
android:layout_marginStart="12dp"
app:layout_constraintStart_toEndOf="@id/private_browsing_icon"
app:layout_constraintTop_toTopOf="@id/private_browsing_icon"
app:layout_constraintBottom_toBottomOf="@id/private_browsing_icon"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/onboarding_private_browsing_description"
android:textAppearance="@style/Body14TextStyle" />
</LinearLayout>
android:textAppearance="@style/Body14TextStyle"
android:layout_marginTop="14dp"
app:layout_constraintTop_toBottomOf="@id/private_browsing_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>