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:
parent
371fbf7164
commit
2ce72139e3
@ -4,10 +4,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.components
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||
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 org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.increaseTapArea
|
||||
@ -22,6 +25,8 @@ class FenixSnackbar private constructor(
|
||||
init {
|
||||
view.background = null
|
||||
content.snackbar_btn.increaseTapArea(16)
|
||||
|
||||
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(content.snackbar_text, 12, 18, 1, TypedValue.COMPLEX_UNIT_SP)
|
||||
}
|
||||
|
||||
fun setText(text: String) = this.apply {
|
||||
|
@ -6,9 +6,11 @@ package org.mozilla.fenix.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.FenixSnackbar
|
||||
import org.mozilla.fenix.ext.asActivity
|
||||
import org.mozilla.fenix.ext.components
|
||||
|
||||
@ -16,22 +18,15 @@ class ItsNotBrokenSnack(val context: Context) {
|
||||
|
||||
fun showSnackbar(issueNumber: String) {
|
||||
val rootView =
|
||||
context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content)
|
||||
rootView?.let {
|
||||
Snackbar.make(rootView, message.replace("%", issueNumber), Snackbar.LENGTH_SHORT)
|
||||
.apply {
|
||||
setAction("Add Tab to Issue") {
|
||||
context.components.useCases.tabsUseCases.addTab
|
||||
.invoke(issues + issueNumber)
|
||||
}.setActionTextColor(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.accent_bright_dark_theme
|
||||
)
|
||||
)
|
||||
show()
|
||||
}
|
||||
}
|
||||
context.asActivity()?.window?.decorView?.findViewById<View>(android.R.id.content) as ViewGroup
|
||||
|
||||
FenixSnackbar.make(rootView, Snackbar.LENGTH_SHORT)
|
||||
.setText(message.replace("%", issueNumber))
|
||||
.setAction("Add Tab to Issue") {
|
||||
context.components.useCases.tabsUseCases.addTab
|
||||
.invoke(issues + issueNumber)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -25,13 +25,13 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/photonWhite"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:typeface="sans"
|
||||
android:letterSpacing="0.05"
|
||||
android:lineSpacingMultiplier="1.25"
|
||||
android:gravity="center"
|
||||
tools:text="This is a custom Snackbar text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/snackbar_btn"
|
||||
@ -45,6 +45,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/photonWhite"
|
||||
android:textAlignment="textEnd"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:text="Action text"
|
||||
android:padding="0dp"
|
||||
android:minHeight="0dp"
|
||||
@ -54,7 +55,6 @@
|
||||
android:textStyle="bold"
|
||||
android:typeface="sans"
|
||||
android:letterSpacing="0.05"
|
||||
android:lineSpacingMultiplier="1.25"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/snackbar_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
Loading…
Reference in New Issue
Block a user