Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Revert "626, 627: Add kebab menu for delete (#764)"
Browse files Browse the repository at this point in the history
This reverts commit 17605c3.
  • Loading branch information
Elise Richards committed Jul 19, 2019
1 parent b8b1cf6 commit c434f12
Show file tree
Hide file tree
Showing 29 changed files with 80 additions and 473 deletions.
11 changes: 1 addition & 10 deletions app/src/main/java/mozilla/lockbox/action/DataStoreAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package mozilla.lockbox.action

import mozilla.appservices.logins.ServerPassword
import mozilla.lockbox.model.SyncCredentials

sealed class DataStoreAction(
Expand All @@ -17,14 +16,6 @@ sealed class DataStoreAction(
object Unlock : DataStoreAction(TelemetryEventMethod.unlock, TelemetryEventObject.datastore)
object Reset : DataStoreAction(TelemetryEventMethod.reset, TelemetryEventObject.datastore)
object Sync : DataStoreAction(TelemetryEventMethod.sync, TelemetryEventObject.datastore)

data class Touch(val id: String) : DataStoreAction(TelemetryEventMethod.touch, TelemetryEventObject.datastore)

data class UpdateCredentials(val syncCredentials: SyncCredentials) :
DataStoreAction(TelemetryEventMethod.update_credentials, TelemetryEventObject.datastore)

data class Delete(val item: ServerPassword?) :
DataStoreAction(TelemetryEventMethod.delete, TelemetryEventObject.delete_credential)

data class Edit(val itemId: Int) : DataStoreAction(TelemetryEventMethod.edit, TelemetryEventObject.edit_credential)
data class UpdateCredentials(val syncCredentials: SyncCredentials) : DataStoreAction(TelemetryEventMethod.update_credentials, TelemetryEventObject.datastore)
}
44 changes: 12 additions & 32 deletions app/src/main/java/mozilla/lockbox/action/DialogAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package mozilla.lockbox.action

import mozilla.appservices.logins.ServerPassword
import mozilla.lockbox.R
import mozilla.lockbox.flux.Action
import mozilla.lockbox.model.DialogViewModel
Expand All @@ -16,17 +15,15 @@ sealed class DialogAction(
val positiveButtonActionList: List<Action> = emptyList(),
val negativeButtonActionList: List<Action> = emptyList()
) : RouteAction(TelemetryEventMethod.show, TelemetryEventObject.dialog) {

object SecurityDisclaimer : DialogAction(
DialogViewModel(
R.string.no_device_security_title,
R.string.no_device_security_message,
R.string.set_up_security_button,
R.string.cancel
),
listOf(SystemSetting(SettingIntent.Security))
listOf(RouteAction.SystemSetting(SettingIntent.Security))
)

object UnlinkDisclaimer : DialogAction(
DialogViewModel(
R.string.disconnect_disclaimer_title,
Expand All @@ -37,34 +34,17 @@ sealed class DialogAction(
),
listOf(LifecycleAction.UserReset)
)

object OnboardingSecurityDialog : DialogAction(
DialogViewModel(
R.string.secure_your_device,
R.string.device_security_description,
R.string.set_up_now,
R.string.skip_button
),
listOf(
SystemSetting(SettingIntent.Security),
Login
),
listOf(Login)
)

data class DeleteConfirmationDialog(
val item: ServerPassword?
) : DialogAction(
DialogViewModel(
R.string.delete_this_login,
R.string.delete_description,
R.string.delete,
R.string.cancel,
R.color.red
),
listOf(
DataStoreAction.Delete(item),
ItemList
DialogViewModel(
R.string.secure_your_device,
R.string.device_security_description,
R.string.set_up_now,
R.string.skip_button
),
listOf(
RouteAction.SystemSetting(SettingIntent.Security),
RouteAction.Login
),
listOf(RouteAction.Login)
)
)
}
8 changes: 0 additions & 8 deletions app/src/main/java/mozilla/lockbox/action/ItemDetailAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@

package mozilla.lockbox.action

import androidx.annotation.StringRes
import mozilla.lockbox.R

sealed class ItemDetailAction(
override val eventMethod: TelemetryEventMethod,
override val eventObject: TelemetryEventObject
) : TelemetryAction {
data class TogglePassword(val displayed: Boolean)
: ItemDetailAction(TelemetryEventMethod.tap, TelemetryEventObject.reveal_password)

enum class EditItemMenu(@StringRes val titleId: Int) {
EDIT(R.string.edit),
DELETE(R.string.delete)
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/mozilla/lockbox/action/SettingAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Setting {
val ms: Long = this.seconds * 1000
}

enum class ItemListSort(@StringRes val titleId: Int, @StringRes val valueId: Int) {
enum class ItemListSort(val titleId: Int, val valueId: Int) {
ALPHABETICALLY(R.string.all_logins_a_z, R.string.sort_menu_az),
RECENTLY_USED(R.string.all_logins_recent, R.string.sort_menu_recent)
}
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/java/mozilla/lockbox/action/TelemetryAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface TelemetryAction : Action {
val extras: Map<String, Any>?
get() = null

fun createEvent(category: String = "action"): TelemetryEvent {
open fun createEvent(category: String = "action"): TelemetryEvent {
val evt = TelemetryEvent.create(
category,
eventMethod.name,
Expand Down Expand Up @@ -53,9 +53,7 @@ enum class TelemetryEventMethod {
autofill_multiple,
autofill_cancel,
autofill_error,
autofill_filter,
delete,
edit
autofill_filter
}

enum class TelemetryEventObject {
Expand Down Expand Up @@ -95,8 +93,5 @@ enum class TelemetryEventObject {
filter,
back,
dialog,
datastore,
delete_credential,
edit_credential,
entry_kebab
datastore
}
45 changes: 0 additions & 45 deletions app/src/main/java/mozilla/lockbox/adapter/DeleteItemAdapter.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class SectionedAdapter(
else
baseAdapter.getItemViewType(sectionedPositionToPosition(position)) + 1
}

class Section(internal var firstPosition: Int, @StringRes title: Int) {
internal var sectionedPosition: Int = 0
@StringRes var title: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import kotlinx.android.synthetic.main.list_cell_setting_toggle.*
import mozilla.lockbox.R
import mozilla.lockbox.model.DialogViewModel

Expand All @@ -26,7 +25,7 @@ object AlertDialogHelper {
viewModel: DialogViewModel
): Observable<AlertState> {
return Observable.create { emitter ->
val builder = AlertDialog.Builder(context, R.style.DeleteDialogStyle)
val builder = AlertDialog.Builder(context, R.style.AlertDialogStyle)

viewModel.title?.let {
val titleString = context.getString(it)
Expand Down Expand Up @@ -63,6 +62,7 @@ object AlertDialogHelper {
setUpDismissal(builder, emitter)

val dialog = builder.create()

dialog.show()

val defaultColor = context.getColor(R.color.violet_70)
Expand Down
14 changes: 2 additions & 12 deletions app/src/main/java/mozilla/lockbox/presenter/ItemDetailPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import mozilla.lockbox.R
import mozilla.lockbox.action.AppWebPageAction
import mozilla.lockbox.action.ClipboardAction
import mozilla.lockbox.action.DataStoreAction
import mozilla.lockbox.action.DialogAction
import mozilla.lockbox.action.ItemDetailAction
import mozilla.lockbox.action.RouteAction
import mozilla.lockbox.extensions.filterNotNull
Expand All @@ -34,12 +33,10 @@ interface ItemDetailView {
val togglePasswordClicks: Observable<Unit>
val hostnameClicks: Observable<Unit>
val learnMoreClicks: Observable<Unit>
val kebabMenuClicks: Observable<Unit>
var isPasswordVisible: Boolean
fun updateItem(item: ItemDetailViewModel)
fun showToastNotification(@StringRes strId: Int)
fun handleNetworkError(networkErrorVisibility: Boolean)
val menuItemSelection: Observable<ItemDetailAction.EditItemMenu>
// val retryNetworkConnectionClicks: Observable<Unit>
}

Expand Down Expand Up @@ -83,13 +80,6 @@ class ItemDetailPresenter(
}
}

view.menuItemSelection
.map {
DialogAction.DeleteConfirmationDialog(credentials)
}
.subscribe(dispatcher::dispatch)
.addTo(compositeDisposable)

this.view.learnMoreClicks
.map { AppWebPageAction.FaqEdit }
.subscribe(dispatcher::dispatch)
Expand Down Expand Up @@ -127,8 +117,8 @@ class ItemDetailPresenter(

private fun handleClicks(clicks: Observable<Unit>, withServerPassword: (ServerPassword) -> Unit) {
clicks.subscribe {
this.credentials?.let { password -> withServerPassword(password) }
}
this.credentials?.let { password -> withServerPassword(password) }
}
.addTo(compositeDisposable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ interface ItemListView {
val isRefreshing: Boolean
fun stopRefreshing()
fun showToastNotification(@StringRes strId: Int)
fun showDeleteToastNotification(text: String)
}

@ExperimentalCoroutinesApi
Expand Down Expand Up @@ -168,13 +167,6 @@ class ItemListPresenter(
.subscribe(view::handleNetworkError)
.addTo(compositeDisposable)

dataStore.deletedItem
.subscribe {
val event = it.get() ?: return@subscribe
view.showDeleteToastNotification(event.formSubmitURL ?: event.hostname)
}
.addTo(compositeDisposable)

// TODO: make this more robust to retry loading the correct page again (loadUrl)
// view.retryNetworkConnectionClicks.subscribe {
// dispatcher.dispatch(NetworkAction.CheckConnectivity)
Expand Down
30 changes: 3 additions & 27 deletions app/src/main/java/mozilla/lockbox/store/DataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import mozilla.lockbox.support.DataStoreSupport
import mozilla.lockbox.support.FxASyncDataStoreSupport
import mozilla.lockbox.support.Optional
import mozilla.lockbox.support.TimingSupport
import mozilla.lockbox.support.asOptional
import java.util.concurrent.TimeUnit
import kotlin.coroutines.CoroutineContext

Expand Down Expand Up @@ -61,12 +62,10 @@ open class DataStore(
private val stateSubject = ReplayRelay.createWithSize<State>(1)
private val syncStateSubject = BehaviorRelay.createDefault<SyncState>(SyncState.NotSyncing)
private val listSubject: BehaviorRelay<List<ServerPassword>> = BehaviorRelay.createDefault(emptyList())
private val deletedItemSubject = ReplayRelay.create<Consumable<ServerPassword>>()

open val state: Observable<State> = stateSubject
open val syncState: Observable<SyncState> = syncStateSubject
open val list: Observable<List<ServerPassword>> get() = listSubject
open val deletedItem: Observable<Consumable<ServerPassword>> get() = deletedItemSubject

private val exceptionHandler: CoroutineExceptionHandler
get() = CoroutineExceptionHandler { _, e ->
Expand Down Expand Up @@ -108,7 +107,6 @@ open class DataStore(
is DataStoreAction.Touch -> touch(action.id)
is DataStoreAction.Reset -> reset()
is DataStoreAction.UpdateCredentials -> updateCredentials(action.syncCredentials)
is DataStoreAction.Delete -> deleteCredentials(action.item)
}
}
.addTo(compositeDisposable)
Expand All @@ -121,26 +119,6 @@ open class DataStore(
setupAutoLock()
}

private fun deleteCredentials(item: ServerPassword?) {
try {
if (item != null) {
backend.delete(item.id)
.asSingle(coroutineContext)
.subscribe()
.addTo(compositeDisposable)
sync()
deletedItemSubject.accept(Consumable(item))
}
} catch (loginsStorageException: LoginsStorageException) {
log.error("Exception: ", loginsStorageException)
}
}

private fun editEntry() {
// TODO
// dispatcher.dispatch(RouteAction.ItemList)
}

private fun shutdown() {
// rather than calling `close`, which will make the `AsyncLoginsStorage` instance unusable,
// we use the `ensureLocked` method to close the database connection.
Expand All @@ -166,10 +144,8 @@ open class DataStore(

open fun get(id: String): Observable<Optional<ServerPassword>> {
return list.map { items ->
Optional(
items.findLast { item -> item.id == id }
)
}
items.findLast { item -> item.id == id }.asOptional()
}
}

private fun touch(id: String) {
Expand Down
20 changes: 0 additions & 20 deletions app/src/main/java/mozilla/lockbox/support/Consumable.kt

This file was deleted.

Loading

0 comments on commit c434f12

Please sign in to comment.