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

For #1430 - Replaces existing snackbar and adapts text size

This commit is contained in:
Jeff Boek 2019-04-05 13:52:20 -07:00
parent 371fbf7164
commit 2ce72139e3
3 changed files with 19 additions and 19 deletions

View File

@ -4,10 +4,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.components package org.mozilla.fenix.components
import android.util.TypedValue
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.google.android.material.snackbar.BaseTransientBottomBar import com.google.android.material.snackbar.BaseTransientBottomBar
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM
import androidx.core.widget.TextViewCompat
import kotlinx.android.synthetic.main.fenix_snackbar.view.* import kotlinx.android.synthetic.main.fenix_snackbar.view.*
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.increaseTapArea import org.mozilla.fenix.ext.increaseTapArea
@ -22,6 +25,8 @@ class FenixSnackbar private constructor(
init { init {
view.background = null view.background = null
content.snackbar_btn.increaseTapArea(16) content.snackbar_btn.increaseTapArea(16)
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(content.snackbar_text, 12, 18, 1, TypedValue.COMPLEX_UNIT_SP)
} }
fun setText(text: String) = this.apply { fun setText(text: String) = this.apply {

View File

@ -6,9 +6,11 @@ package org.mozilla.fenix.utils
import android.content.Context import android.content.Context
import android.view.View import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.ext.asActivity import org.mozilla.fenix.ext.asActivity
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -16,22 +18,15 @@ class ItsNotBrokenSnack(val context: Context) {
fun showSnackbar(issueNumber: String) { fun showSnackbar(issueNumber: String) {
val rootView = val rootView =
context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content) context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content) as ViewGroup
rootView?.let {
Snackbar.make(rootView, message.replace("%", issueNumber), Snackbar.LENGTH_SHORT) FenixSnackbar.make(rootView, Snackbar.LENGTH_SHORT)
.apply { .setText(message.replace("%", issueNumber))
setAction("Add Tab to Issue") { .setAction("Add Tab to Issue") {
context.components.useCases.tabsUseCases.addTab context.components.useCases.tabsUseCases.addTab
.invoke(issues + issueNumber) .invoke(issues + issueNumber)
}.setActionTextColor( }
ContextCompat.getColor( .show()
context,
R.color.accent_bright_dark_theme
)
)
show()
}
}
} }
companion object { companion object {

View File

@ -25,13 +25,13 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="3" android:maxLines="1"
android:textColor="@color/photonWhite" android:textColor="@color/photonWhite"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
android:typeface="sans" android:typeface="sans"
android:letterSpacing="0.05" android:letterSpacing="0.05"
android:lineSpacingMultiplier="1.25" android:gravity="center"
tools:text="This is a custom Snackbar text" tools:text="This is a custom Snackbar text"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/snackbar_btn" app:layout_constraintEnd_toStartOf="@id/snackbar_btn"
@ -45,6 +45,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/photonWhite" android:textColor="@color/photonWhite"
android:textAlignment="textEnd" android:textAlignment="textEnd"
android:layout_marginStart="16dp"
tools:text="Action text" tools:text="Action text"
android:padding="0dp" android:padding="0dp"
android:minHeight="0dp" android:minHeight="0dp"
@ -54,7 +55,6 @@
android:textStyle="bold" android:textStyle="bold"
android:typeface="sans" android:typeface="sans"
android:letterSpacing="0.05" android:letterSpacing="0.05"
android:lineSpacingMultiplier="1.25"
android:visibility="gone" android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/snackbar_text" app:layout_constraintStart_toEndOf="@id/snackbar_text"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"