-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lists: confirm deletion, rename from remove to delete
Removal sounds like it's just removed from the list of lists, but it is actually deleted.
- Loading branch information
1 parent
bbbe754
commit fc8ad9b
Showing
7 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/battlelancer/seriesguide/lists/DeleteListDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Uwe Trottmann | ||
|
||
package com.battlelancer.seriesguide.lists | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatDialogFragment | ||
import androidx.core.os.bundleOf | ||
import com.battlelancer.seriesguide.R | ||
import com.battlelancer.seriesguide.provider.SgRoomDatabase | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
|
||
/** | ||
* Dialog to confirm deletion of a list and its items. | ||
*/ | ||
class DeleteListDialogFragment : AppCompatDialogFragment() { | ||
|
||
private lateinit var listId: String | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
listId = requireArguments().getString(ARG_LIST_ID) | ||
?: throw IllegalArgumentException("list_id must be supplied") | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
val listTitle = SgRoomDatabase.getInstance(requireContext()).sgListHelper() | ||
.getList(listId) | ||
?.name ?: getString(R.string.unknown) | ||
|
||
return MaterialAlertDialogBuilder(requireContext()) | ||
.setTitle(requireContext().getString(R.string.confirm_delete, listTitle)) | ||
.setPositiveButton(android.R.string.cancel) { _, _ -> | ||
// just dismiss | ||
} | ||
.setNegativeButton(R.string.list_remove) { _, _ -> | ||
ListsTools.deleteList(requireContext(), listId) | ||
} | ||
.create() | ||
} | ||
|
||
companion object { | ||
|
||
private const val ARG_LIST_ID = "list_id" | ||
|
||
fun create(listId: String): DeleteListDialogFragment { | ||
return DeleteListDialogFragment().apply { | ||
arguments = bundleOf(ARG_LIST_ID to listId) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters