1
0
Fork 0

For #7219 - Polish Download Notification Dialog. (#7224)

* For #7219 - Use accent color for downloads dialog positive button

* For #7219 - Fixes gap beneath download notification dialog

* switch to setimageresource
master
Emily Kager 2019-12-18 09:26:41 -08:00 committed by Sawyer Blatz
parent 9ae20f2bcb
commit 5ac79f59a3
2 changed files with 95 additions and 92 deletions

View File

@ -8,9 +8,11 @@ import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.os.Bundle import android.os.Bundle
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.appcompat.content.res.AppCompatResources import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.android.synthetic.main.download_notification_layout.* import kotlinx.android.synthetic.main.download_notification_layout.*
import mozilla.components.browser.state.state.content.DownloadState import mozilla.components.browser.state.state.content.DownloadState
@ -36,10 +38,9 @@ class DownloadNotificationBottomSheetDialog(
download_notification_title.text = download_notification_title.text =
context.getString(R.string.mozac_feature_downloads_failed_notification_text2) context.getString(R.string.mozac_feature_downloads_failed_notification_text2)
download_notification_icon.setImageDrawable(AppCompatResources.getDrawable( download_notification_icon.setImageResource(
context,
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_failed mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_failed
)) )
download_notification_action_button.apply { download_notification_action_button.apply {
text = context.getString( text = context.getString(
@ -58,10 +59,9 @@ class DownloadNotificationBottomSheetDialog(
download_notification_title.text = titleText download_notification_title.text = titleText
download_notification_icon.setImageDrawable(AppCompatResources.getDrawable( download_notification_icon.setImageResource(
context,
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_complete mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_complete
)) )
download_notification_action_button.apply { download_notification_action_button.apply {
text = context.getString( text = context.getString(
@ -91,15 +91,20 @@ class DownloadNotificationBottomSheetDialog(
download_notification_filename.text = download.fileName download_notification_filename.text = download.fileName
setOnShowListener { setOnShowListener {
val bottomSheet =
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout
val behavior = BottomSheetBehavior.from(bottomSheet)
behavior.state = BottomSheetBehavior.STATE_EXPANDED
window?.apply { window?.apply {
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
setLayout( setLayout(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT ViewGroup.LayoutParams.MATCH_PARENT
) )
navigationBarColor = ContextCompat.getColor( navigationBarColor = ContextCompat.getColor(
context, context,
ThemeManager.resolveAttribute(R.attr.foundation, context ThemeManager.resolveAttribute(
R.attr.foundation, context
) )
) )
} }

View File

@ -2,90 +2,88 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public <!-- 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 - 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/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?foundation"
android:paddingBottom="16dp">
<androidx.constraintlayout.widget.ConstraintLayout <ImageView
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/download_notification_icon"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="32dp"
xmlns:tools="http://schemas.android.com/tools" android:layout_height="32dp"
android:layout_width="match_parent" android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:importantForAccessibility="no"
android:scaleType="center"
android:tint="?primaryText"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/mozac_feature_download_ic_download_complete" />
<TextView
android:id="@+id/download_notification_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="16dp" android:layout_alignParentTop="true"
android:background="?foundation"> android:layout_marginStart="3dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="11dp"
android:paddingStart="5dp"
android:paddingTop="4dp"
android:paddingEnd="5dp"
android:textColor="?primaryText"
android:textSize="16sp"
app:layout_constraintEnd_toStartOf="@id/download_notification_close_button"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@id/download_notification_icon"
app:layout_constraintTop_toTopOf="parent"
tools:text="Download (85.7 MB)" />
<ImageView <ImageButton
android:id="@+id/download_notification_icon" android:id="@+id/download_notification_close_button"
android:layout_width="32dp" android:layout_width="wrap_content"
android:layout_height="32dp" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="3dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:scaleType="center" android:layout_marginEnd="12dp"
app:srcCompat="@drawable/mozac_feature_download_ic_download_complete" android:background="@null"
android:importantForAccessibility="no" android:contentDescription="@string/mozac_feature_downloads_button_close"
app:layout_constraintTop_toTopOf="parent" android:tint="?primaryText"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:tint="?primaryText"/> app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/mozac_ic_close" />
<TextView <TextView
android:id="@+id/download_notification_title" android:id="@+id/download_notification_filename"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="11dp" android:layout_marginStart="3dp"
android:layout_marginStart="3dp" android:layout_marginTop="16dp"
android:textSize="16sp" android:paddingStart="5dp"
android:textColor="?primaryText" android:paddingTop="4dp"
android:paddingTop="4dp" android:paddingEnd="5dp"
android:paddingStart="5dp" android:textColor="?primaryText"
android:paddingEnd="5dp" app:layout_constraintStart_toEndOf="@id/download_notification_icon"
android:layout_alignParentTop="true" app:layout_constraintTop_toBottomOf="@id/download_notification_title"
android:layout_marginTop="16dp" tools:text="Firefox_Preview_v2.1.apk" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintEnd_toStartOf="@id/download_notification_close_button"
app:layout_constraintStart_toEndOf="@id/download_notification_icon"
tools:text="Download (85.7 MB)"/>
<ImageButton <Button
android:id="@+id/download_notification_close_button" android:id="@+id/download_notification_action_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="12dp" android:layout_marginStart="8dp"
android:layout_marginStart="3dp" android:layout_marginTop="16dp"
android:contentDescription="@string/mozac_feature_downloads_button_close" android:layout_marginEnd="16dp"
android:background="@null" android:layout_marginBottom="4dp"
android:tint="?primaryText" android:background="@drawable/rounded_all_corners"
app:srcCompat="@drawable/mozac_ic_close" android:backgroundTint="?accent"
app:layout_constraintTop_toTopOf="parent" android:text="@string/mozac_feature_downloads_button_open"
app:layout_constraintEnd_toEndOf="parent" android:textAllCaps="false"
android:layout_marginTop="16dp"/> android:textColor="?contrastText"
app:layout_constraintBottom_toBottomOf="parent"
<TextView app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/download_notification_filename" app:layout_constraintTop_toBottomOf="@id/download_notification_filename" />
android:layout_width="wrap_content" </androidx.constraintlayout.widget.ConstraintLayout>
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:textColor="?primaryText"
android:paddingTop="4dp"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/download_notification_title"
app:layout_constraintStart_toEndOf="@id/download_notification_icon"
tools:text="Firefox_Preview_v2.1.apk"/>
<Button
android:id="@+id/download_notification_action_button"
android:textColor="?contrastText"
android:backgroundTint="?accentBright"
android:background="@drawable/rounded_all_corners"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/download_notification_filename"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mozac_feature_downloads_button_open"/>
</androidx.constraintlayout.widget.ConstraintLayout>