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

Commit

Permalink
Add kebab menu icon and strings. Set up fragment for addition to tool…
Browse files Browse the repository at this point in the history
…bar.
  • Loading branch information
Elise Richards committed Jun 16, 2019
1 parent a8c827f commit 7a5c929
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ 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
12 changes: 12 additions & 0 deletions app/src/main/java/mozilla/lockbox/presenter/ItemDetailPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import mozilla.lockbox.action.ClipboardAction
import mozilla.lockbox.action.DataStoreAction
import mozilla.lockbox.action.ItemDetailAction
import mozilla.lockbox.action.RouteAction
import mozilla.lockbox.action.Setting
import mozilla.lockbox.extensions.filterNotNull
import mozilla.lockbox.extensions.toDetailViewModel
import mozilla.lockbox.flux.Dispatcher
Expand All @@ -33,10 +34,13 @@ 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)
fun updateKebabMenu()

// val retryNetworkConnectionClicks: Observable<Unit>
}

Expand Down Expand Up @@ -80,6 +84,14 @@ class ItemDetailPresenter(
}
}

this.view.kebabMenuClicks
.map { ItemDetailAction.Delete }
.subscribe {
view.updateKebabMenu()
dispatcher.dispatch(RouteAction.DialogFragment.DeleteConfirmation)
}
.addTo(compositeDisposable)

this.view.learnMoreClicks
.map { AppWebPageAction.FaqEdit }
.subscribe(dispatcher::dispatch)
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/java/mozilla/lockbox/view/ItemDetailFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import com.jakewharton.rxbinding2.view.clicks
import io.reactivex.Observable
import kotlinx.android.synthetic.main.fragment_item_detail.*
import kotlinx.android.synthetic.main.fragment_item_detail.view.*
import kotlinx.android.synthetic.main.include_backable.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.lockbox.R
import mozilla.lockbox.action.Setting
import mozilla.lockbox.model.ItemDetailViewModel
import mozilla.lockbox.presenter.ItemDetailPresenter
import mozilla.lockbox.presenter.ItemDetailView
import mozilla.lockbox.support.assertOnUiThread

@Suppress("DEPRECATION")
@ExperimentalCoroutinesApi
class ItemDetailFragment : BackableFragment(), ItemDetailView {
override fun onCreateView(
Expand Down Expand Up @@ -62,6 +63,9 @@ class ItemDetailFragment : BackableFragment(), ItemDetailView {
override val learnMoreClicks: Observable<Unit>
get() = view!!.detailLearnMore.clicks()

override val kebabMenuClicks: Observable<Unit>
get() = view!!.toolbar.kebabMenu.clicks()

override var isPasswordVisible: Boolean = false
set(value) {
assertOnUiThread()
Expand All @@ -79,9 +83,18 @@ class ItemDetailFragment : BackableFragment(), ItemDetailView {
}
}

override fun updateKebabMenu() {
// sortItemsAdapter.setSelection(sortMenuOptions.indexOf(sort))
spinner.setSelection(0, false)
// scrollToTop()
}

override fun updateItem(item: ItemDetailViewModel) {
assertOnUiThread()
toolbar.elevation = resources.getDimension(R.dimen.larger_toolbar_elevation)
toolbar.title = item.title
// val menuIcon = resources.getDrawable(R.drawable.ic_menu_kebab)
// toolbar.kebabMenu.

inputLayoutHostname.isHintAnimationEnabled = false
inputLayoutUsername.isHintAnimationEnabled = false
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/drawable-anydpi/ic_menu_kebab.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
~ 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/.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<path
android:fillColor="#FF000000"
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>
Binary file added app/src/main/res/drawable-hdpi/ic_menu_kebab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_menu_kebab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_menu_kebab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_menu_kebab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion app/src/main/res/layout/fragment_item_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,45 @@
android:id="@+id/fragment_item_detail"
android:background="@color/background_grey" >

<include layout="@layout/include_backable"/>
<include layout="@layout/fragment_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toTopOf="@id/cardView"
tools:text="@string/no_internet_connection"/>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ToolBar"
app:layout_constraintTop_toTopOf="parent">
<!--<LinearLayout-->
<!--android:orientation="horizontal"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginStart="250dp">-->
<!--<Spinner-->
<!--android:id="@+id/kebabMenu"-->
<!--android:layout_width="100dp"-->
<!--android:layout_height="match_parent"-->
<!--android:textAllCaps="false"-->
<!--android:drawableEnd="@drawable/ic_menu_kebab"-->
<!--android:paddingStart="160dp"-->
<!--android:paddingEnd="16dp"-->
<!--android:contentDescription="@string/kebab_menu"-->
<!--android:overlapAnchor="false"-->
<!--android:popupElevation="8dp"-->
<!--android:dropDownWidth="150dp"-->
<!--android:dropDownSelector="@color/selection"-->
<!--android:spinnerMode="dropdown"-->
<!--android:popupBackground="@drawable/sort_menu_bg"-->
<!--android:textSize="20sp"-->
<!--android:background="@null"-->
<!--style="@style/PopupTheme"/>-->
<!--</LinearLayout>-->

</androidx.appcompat.widget.Toolbar>

<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<dimen name="network_error_with_toolbar">96dp</dimen>
<dimen name="network_error">40dp</dimen>
<dimen name="toolbar_elevation">4dp</dimen>
<dimen name="larger_toolbar_elevation">8dp</dimen>
<dimen name="logo_size">90dp</dimen>
<dimen name="logo_top_margin">216dp</dimen>
<dimen name="app_name_top_margin">318dp</dimen>
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,16 @@

<!-- This is the placeholder text for an empty or null username. -->
<string name="no_username">(no username)</string>

<!-- This is the message displayed when sync has timed out. -->
<string name="sync_timed_out">Syncing has timed out</string>

<!-- This is the description for the kebab menu in the item detail toolbar. -->
<string name="kebab_menu">More options</string>
<!-- This is the text on a button to delete a login. -->
<string name="delete">Delete</string>
<!-- This is the confirmation message title seen when attempting to delete a login. -->
<string name="delete_confirmation">Delete this login?</string>
<!-- This is the description for the deletion dialog. -->
<string name="delete_description">This will delete the login from both Lockwise and Firefox.</string>
</resources>

0 comments on commit 7a5c929

Please sign in to comment.