mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
For #2025 - Create and theme Dialog for deleting all history
This commit is contained in:
parent
fd4de3509d
commit
028c6cad70
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.library.history
|
package org.mozilla.fenix.library.history
|
||||||
|
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.graphics.PorterDuffColorFilter
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -14,7 +15,9 @@ import android.view.MenuInflater
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
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
|
||||||
@ -136,9 +139,28 @@ class HistoryFragment : Fragment(), CoroutineScope, BackHandler {
|
|||||||
.onNext(HistoryChange.RemoveItemForRemoval(it.item))
|
.onNext(HistoryChange.RemoveItemForRemoval(it.item))
|
||||||
is HistoryAction.BackPressed -> getManagedEmitter<HistoryChange>()
|
is HistoryAction.BackPressed -> getManagedEmitter<HistoryChange>()
|
||||||
.onNext(HistoryChange.ExitEditMode)
|
.onNext(HistoryChange.ExitEditMode)
|
||||||
is HistoryAction.Delete.All -> launch(Dispatchers.IO) {
|
is HistoryAction.Delete.All -> {
|
||||||
requireComponents.core.historyStorage.deleteEverything()
|
activity?.let {
|
||||||
reloadData()
|
AlertDialog.Builder(
|
||||||
|
ContextThemeWrapper(
|
||||||
|
it,
|
||||||
|
R.style.DialogStyle
|
||||||
|
)
|
||||||
|
).apply {
|
||||||
|
setMessage(R.string.history_delete_all_dialog)
|
||||||
|
setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _ ->
|
||||||
|
dialog.cancel()
|
||||||
|
}
|
||||||
|
setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _ ->
|
||||||
|
launch(Dispatchers.IO) {
|
||||||
|
requireComponents.core.historyStorage.deleteEverything()
|
||||||
|
reloadData()
|
||||||
|
}
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
create()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is HistoryAction.Delete.One -> launch(Dispatchers.IO) {
|
is HistoryAction.Delete.One -> launch(Dispatchers.IO) {
|
||||||
requireComponents.core.historyStorage.deleteVisit(it.item.url, it.item.visitedAt)
|
requireComponents.core.historyStorage.deleteVisit(it.item.url, it.item.visitedAt)
|
||||||
|
@ -11,6 +11,7 @@ import android.graphics.Typeface.BOLD
|
|||||||
import android.graphics.Typeface.ITALIC
|
import android.graphics.Typeface.ITALIC
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
|
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
|
||||||
@ -112,7 +113,12 @@ class SearchFragment : Fragment(), BackHandler {
|
|||||||
onScanResult = { result ->
|
onScanResult = { result ->
|
||||||
search_scan_button.isChecked = false
|
search_scan_button.isChecked = false
|
||||||
activity?.let {
|
activity?.let {
|
||||||
AlertDialog.Builder(it).apply {
|
AlertDialog.Builder(
|
||||||
|
ContextThemeWrapper(
|
||||||
|
it,
|
||||||
|
R.style.DialogStyle
|
||||||
|
)
|
||||||
|
).apply {
|
||||||
val spannable = resources.getSpannable(
|
val spannable = resources.getSpannable(
|
||||||
R.string.qr_scanner_confirmation_dialog_message,
|
R.string.qr_scanner_confirmation_dialog_message,
|
||||||
listOf(
|
listOf(
|
||||||
|
@ -299,6 +299,8 @@
|
|||||||
<!-- History -->
|
<!-- History -->
|
||||||
<!-- Text for the button to clear all history -->
|
<!-- Text for the button to clear all history -->
|
||||||
<string name="history_delete_all">Delete history</string>
|
<string name="history_delete_all">Delete history</string>
|
||||||
|
<!-- Text for the dialog to confirm clearing all history -->
|
||||||
|
<string name="history_delete_all_dialog">Are you sure you want to clear your history?</string>
|
||||||
<!-- Text for the button to delete a single history item -->
|
<!-- Text for the button to delete a single history item -->
|
||||||
<string name="history_delete_item">Delete</string>
|
<string name="history_delete_item">Delete</string>
|
||||||
<!-- History multi select title in app bar
|
<!-- History multi select title in app bar
|
||||||
|
@ -47,6 +47,12 @@
|
|||||||
|
|
||||||
<style name="NormalTheme" parent="NormalThemeBase" />
|
<style name="NormalTheme" parent="NormalThemeBase" />
|
||||||
|
|
||||||
|
<style name="DialogStyle" parent="Theme.MaterialComponents.Dialog.Alert">
|
||||||
|
<item name="android:background">?above</item>
|
||||||
|
<item name="colorAccent">?accent</item>
|
||||||
|
<item name="android:textColorPrimary">?primaryText</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="PrivateThemeBase" parent="Theme.AppCompat.NoActionBar">
|
<style name="PrivateThemeBase" parent="Theme.AppCompat.NoActionBar">
|
||||||
<!-- Android system styling -->
|
<!-- Android system styling -->
|
||||||
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
|
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user