2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

For #2941 - Remove Delete Dialog, Theme Dialogs (#3052)

This commit is contained in:
Emily Kager 2019-05-31 14:26:34 -07:00 committed by Colin Lee
parent ebe894801c
commit d5a9627273
5 changed files with 57 additions and 57 deletions

View File

@ -8,7 +8,6 @@ import android.content.DialogInterface
import android.content.res.Resources import android.content.res.Resources
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.os.Bundle import android.os.Bundle
import android.view.ContextThemeWrapper
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -379,26 +378,23 @@ class HomeFragment : Fragment(), CoroutineScope, AccountObserver {
} }
private fun createDeleteCollectionPrompt(tabCollection: TabCollection) { private fun createDeleteCollectionPrompt(tabCollection: TabCollection) {
AlertDialog.Builder( context?.let {
ContextThemeWrapper( AlertDialog.Builder(it).apply {
activity, val message = context.getString(R.string.tab_collection_dialog_message, tabCollection.title)
R.style.DeleteDialogStyle setMessage(message)
) setNegativeButton(R.string.tab_collection_dialog_negative) { dialog: DialogInterface, _ ->
).apply { dialog.cancel()
val message = context.getString(R.string.tab_collection_dialog_message, tabCollection.title)
setMessage(message)
setNegativeButton(R.string.tab_collection_dialog_negative) { dialog: DialogInterface, _ ->
dialog.cancel()
}
setPositiveButton(R.string.tab_collection_dialog_positive) { dialog: DialogInterface, _ ->
launch(Dispatchers.IO) {
requireComponents.core.tabCollectionStorage.removeCollection(tabCollection)
}.invokeOnCompletion {
dialog.dismiss()
} }
} setPositiveButton(R.string.tab_collection_dialog_positive) { dialog: DialogInterface, _ ->
create() launch(Dispatchers.IO) {
}.show() requireComponents.core.tabCollectionStorage.removeCollection(tabCollection)
}.invokeOnCompletion {
dialog.dismiss()
}
}
create()
}.show()
}
} }
@Suppress("ComplexMethod") @Suppress("ComplexMethod")

View File

@ -16,7 +16,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.Navigation import androidx.navigation.Navigation
@ -228,12 +227,7 @@ class HistoryFragment : Fragment(), CoroutineScope by MainScope(), BackHandler {
private fun displayDeleteAllDialog() { private fun displayDeleteAllDialog() {
activity?.let { activity -> activity?.let { activity ->
AlertDialog.Builder( AlertDialog.Builder(activity).apply {
ContextThemeWrapper(
activity,
R.style.DeleteDialogStyle
)
).apply {
setMessage(R.string.history_delete_all_dialog) setMessage(R.string.history_delete_all_dialog)
setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _ -> setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _ ->
dialog.cancel() dialog.cancel()

View File

@ -6,7 +6,6 @@ package org.mozilla.fenix.settings
import android.content.DialogInterface import android.content.DialogInterface
import android.os.Bundle import android.os.Bundle
import android.view.ContextThemeWrapper
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -108,26 +107,23 @@ class DeleteBrowsingDataFragment : Fragment(), CoroutineScope {
} }
private fun askToDelete() { private fun askToDelete() {
AlertDialog.Builder( context?.let {
ContextThemeWrapper( AlertDialog.Builder(it).apply {
activity, val appName = context.getString(R.string.app_name)
R.style.DeleteDialogStyle val message = context.getString(R.string.preferences_delete_browsing_data_prompt_message, appName)
) setMessage(message)
).apply {
val appName = context.getString(R.string.app_name)
val message = context.getString(R.string.preferences_delete_browsing_data_prompt_message, appName)
setMessage(message)
setNegativeButton(R.string.preferences_delete_browsing_data_prompt_cancel) { dialog: DialogInterface, _ -> setNegativeButton(R.string.preferences_delete_browsing_data_prompt_cancel) { it: DialogInterface, _ ->
dialog.cancel() it.cancel()
} }
setPositiveButton(R.string.preferences_delete_browsing_data_prompt_allow) { dialog: DialogInterface, _ -> setPositiveButton(R.string.preferences_delete_browsing_data_prompt_allow) { it: DialogInterface, _ ->
dialog.dismiss() it.dismiss()
deleteSelected() deleteSelected()
} }
create() create()
}.show() }.show()
}
} }
private fun deleteSelected() { private fun deleteSelected() {

View File

@ -0,0 +1,7 @@
<?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/. -->
<resources>
<style name="DialogStyleNormal" parent="DialogStyleDark"/>
</resources>

View File

@ -15,8 +15,8 @@
<item name="android:colorAccent">@color/primary_text_normal_theme</item> <item name="android:colorAccent">@color/primary_text_normal_theme</item>
<item name="android:textColorPrimary">@color/primary_text_normal_theme</item> <item name="android:textColorPrimary">@color/primary_text_normal_theme</item>
<item name="android:textColorSecondary">@color/secondary_text_normal_theme</item> <item name="android:textColorSecondary">@color/secondary_text_normal_theme</item>
<item name="alertDialogStyle">@style/DialogStyle</item> <item name="alertDialogStyle">@style/DialogStyleNormal</item>
<item name="alertDialogTheme">@style/DialogStyle</item> <item name="alertDialogTheme">@style/DialogStyleNormal</item>
<!-- Active thumb color & Active track color (30% transparency) --> <!-- Active thumb color & Active track color (30% transparency) -->
<item name="android:colorControlActivated">@color/accent_high_contrast_normal_theme</item> <item name="android:colorControlActivated">@color/accent_high_contrast_normal_theme</item>
@ -55,21 +55,28 @@
<item name="android:background">?above</item> <item name="android:background">?above</item>
<item name="colorAccent">?accent</item> <item name="colorAccent">?accent</item>
<item name="android:textColorPrimary">?primaryText</item> <item name="android:textColorPrimary">?primaryText</item>
<item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
</style> </style>
<style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="DialogStyleLight" parent="DialogStyle">
<item name="android:textColor">?primaryText</item> <item name="buttonBarNegativeButtonStyle">@style/DialogButtonStyleLight</item>
<item name="buttonBarPositiveButtonStyle">@style/DialogButtonStyleLight</item>
</style> </style>
<style name="PositiveButtonDeleteStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="DialogStyleDark" parent="DialogStyle">
<item name="android:textColor">?destructive</item> <item name="buttonBarNegativeButtonStyle">@style/DialogButtonStyleDark</item>
<item name="buttonBarPositiveButtonStyle">@style/DialogButtonStyleDark</item>
</style> </style>
<style name="DeleteDialogStyle" parent="DialogStyle"> <style name="DialogButtonStyleLight" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/PositiveButtonDeleteStyle</item> <item name="android:textColor">?accentBright</item>
</style> </style>
<style name="DialogButtonStyleDark" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">?accentHighContrast</item>
</style>
<style name="DialogStyleNormal" parent="DialogStyleLight"/>
<style name="PrivateThemeBase" parent="Theme.AppCompat.NoActionBar"> <style name="PrivateThemeBase" parent="Theme.AppCompat.NoActionBar">
<!-- Android system styling --> <!-- Android system styling -->
<item name="android:windowContentTransitions">true</item> <item name="android:windowContentTransitions">true</item>
@ -82,8 +89,8 @@
<item name="android:colorControlActivated">@color/accent_high_contrast_private_theme</item> <item name="android:colorControlActivated">@color/accent_high_contrast_private_theme</item>
<item name="android:textColorPrimary">@color/primary_text_private_theme</item> <item name="android:textColorPrimary">@color/primary_text_private_theme</item>
<item name="android:textColorSecondary">@color/secondary_text_private_theme</item> <item name="android:textColorSecondary">@color/secondary_text_private_theme</item>
<item name="alertDialogStyle">@style/DialogStyle</item> <item name="alertDialogStyle">@style/DialogStyleDark</item>
<item name="alertDialogTheme">@style/DialogStyle</item> <item name="alertDialogTheme">@style/DialogStyleDark</item>
<!-- Inactive thumb color --> <!-- Inactive thumb color -->
<item name="colorSwitchThumbNormal">@color/toggle_off_knob_dark_theme</item> <item name="colorSwitchThumbNormal">@color/toggle_off_knob_dark_theme</item>