This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
626, 627: Add kebab menu for delete (#764)
* Add kebab menu icon and strings. Set up fragment for addition to toolbar. * Create fragment and dialog. * Add confirmation dialog, actions, and presenters * Routing * Ensure item is actually deleted and item list is refreshed before navigating back. * Refactor and remove edit for now * Keeping edit button, just not doing any functionality with it * Test for item detail presenter * Ellipsize long item titles in detail view * Delete confirmation toast * Delete toast and tests * Consumable toast notification for delete * Specify return type on Optional extension * ItemListPresenterTest needed a consumable for the delete toast test * Cleanup * Fix toast notifications
- Loading branch information
Elise Richards
authored
Jul 3, 2019
1 parent
297f829
commit 17605c3
Showing
29 changed files
with
478 additions
and
81 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
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/mozilla/lockbox/adapter/DeleteItemAdapter.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,45 @@ | ||
package mozilla.lockbox.adapter | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import android.widget.TextView | ||
import mozilla.lockbox.R | ||
import mozilla.lockbox.action.ItemDetailAction | ||
|
||
class DeleteItemAdapter( | ||
context: Context, | ||
textViewResourceId: Int, | ||
val values: ArrayList<ItemDetailAction.EditItemMenu> | ||
) : ArrayAdapter<ItemDetailAction.EditItemMenu>(context, textViewResourceId, values) { | ||
|
||
private var selectedIndex = -1 | ||
|
||
fun setSelection(position: Int) { | ||
selectedIndex = position | ||
notifyDataSetChanged() | ||
} | ||
|
||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { | ||
val label = super.getView(position, convertView, parent) as TextView | ||
label.setTextAppearance(R.style.TextAppearanceWidgetEventToolbarTitle) | ||
label.setTextColor(label.resources.getColor(R.color.text_white, null)) | ||
label.setBackgroundColor(label.resources.getColor(R.color.color_primary, null)) | ||
label.text = context.resources.getString(values[position].titleId) | ||
label.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_menu_kebab, 0) | ||
|
||
return label | ||
} | ||
|
||
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View { | ||
val label = super.getDropDownView(position, convertView, parent) as TextView | ||
label.setTextAppearance(R.style.TextAppearanceSortMenuItem) | ||
label.text = context.resources.getString(values[position].titleId) | ||
label.background = context.resources.getDrawable(R.drawable.button_pressed_white, null) | ||
val padding = label.resources.getDimensionPixelSize(R.dimen.sort_item_padding) | ||
label.setPadding(padding, padding, padding, padding) | ||
|
||
return label | ||
} | ||
} |
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
Oops, something went wrong.