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

991: UX cleanup part deux #1071

Merged
merged 7 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import mozilla.lockbox.support.DataStoreSupport
import mozilla.lockbox.support.FixedDataStoreSupport
import mozilla.lockbox.support.FxASyncDataStoreSupport

private val emptyString = ""
private const val emptyString = ""
eliserichards marked this conversation as resolved.
Show resolved Hide resolved

interface SyncCredentials {
val isNew: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import mozilla.lockbox.R
import mozilla.lockbox.action.DialogAction
import mozilla.lockbox.action.ItemDetailAction
import mozilla.lockbox.action.RouteAction
import mozilla.lockbox.extensions.filterNotNull
import mozilla.lockbox.extensions.filter
import mozilla.lockbox.extensions.filterNotNull
import mozilla.lockbox.extensions.toDetailViewModel
import mozilla.lockbox.flux.Dispatcher
import mozilla.lockbox.flux.Presenter
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/mozilla/lockbox/view/EditItemFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class EditItemFragment : BackableFragment(), EditItemDetailView {
}

private fun updatePasswordVisibility(visible: Boolean) {
view?.inputPassword?.setSelection(view?.inputPassword?.length() ?: 0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much better putting this here.

if (visible) {
inputPassword.transformationMethod = null
btnPasswordToggle.setImageResource(R.drawable.ic_hide)
Expand Down Expand Up @@ -123,20 +125,34 @@ class EditItemFragment : BackableFragment(), EditItemDetailView {
}

private fun setupKeyboardFocus(view: View) {
val focusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
view.inputUsername.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
if (!hasFocus) {
closeKeyboard()
} else {
view.inputUsername?.setSelection(view.inputUsername?.length() ?: 0)
}
}

view.inputUsername.onFocusChangeListener = focusChangeListener
view.fragment_item_edit.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
if (hasFocus) {
closeKeyboard()
}
}

view.inputPassword.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
togglePasswordVisibility.accept(Unit)
if (!hasFocus) {
closeKeyboard()
} else {
view.inputPassword?.setSelection(view.inputPassword?.length() ?: 0)
}
}

view.fragment_item_edit.setOnTouchListener { _, _ ->
closeKeyboard()
view.clearFocus()
true
}
}

override fun setSaveEnabled(enabled: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ItemDetailFragment : BackableFragment(), ItemDetailView {

override fun showPopup() {
val wrapper = ContextThemeWrapper(context, R.style.PopupKebabMenu)

val popupMenu = PopupMenu(
wrapper,
this.kebabMenuButton,
Expand All @@ -123,7 +124,6 @@ class ItemDetailFragment : BackableFragment(), ItemDetailView {
else -> false
}
}

popupMenu.inflate(R.menu.item_detail_menu)

val builder = popupMenu.menu as MenuBuilder
Expand Down
286 changes: 144 additions & 142 deletions app/src/main/res/layout/fragment_item_detail.xml

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions app/src/main/res/layout/fragment_item_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
android:windowSoftInputMode="adjustPan"
android:fitsSystemWindows="true"
android:windowActionBarOverlay="true"
android:clickable="true"
android:focusable="true"
android:importantForAutofill="noExcludeDescendants"
tools:ignore="UnusedAttribute"
style="@style/EditItemDetail">
Expand Down Expand Up @@ -97,13 +99,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="16dp"
android:clickable="false"
android:focusable="false"
app:layout_constraintTop_toTopOf="parent" >

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/inputLayoutHostname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:clickable="false"
android:focusable="false"
android:colorControlHighlight="@color/black_60_percent"
android:colorControlActivated="@color/black_60_percent"
android:textColorHint="@color/black_60_percent"
Expand All @@ -118,8 +124,11 @@
android:textSize="16sp"
android:fontFamily="sans-serif"
android:textStyle="normal"
android:paddingBottom="13dp"
android:textColor="@color/gray_73_percent"
android:textColorHint="@color/black_60_percent"
android:colorControlHighlight="@color/black_60_percent"
android:colorControlActivated="@color/black_60_percent"
android:letterSpacing="0.01"
android:lineSpacingExtra="8sp"
android:layout_width="match_parent"
Expand All @@ -137,11 +146,11 @@
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>


<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/entryUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foregroundGravity="center_vertical"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/entryHostname" >
Expand All @@ -150,6 +159,7 @@
android:id="@+id/inputLayoutUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="16dp"
android:textColorHint="@color/black_60_percent"
android:colorControlActivated="@color/violet_70"
Expand All @@ -173,11 +183,13 @@
android:inputType="textNoSuggestions"
android:singleLine="true"
android:ellipsize="end"
android:drawablePadding="5dp"
android:paddingBottom="14dp"
android:maxLines="1"
android:clickable="true"
android:focusable="true"
app:backgroundTint="@color/gray_divider"
tools:ignore="Autofill"/>
tools:ignore="Autofill" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Expand All @@ -189,7 +201,6 @@
android:paddingEnd="16dp"
android:fontFamily="sans-serif"
app:layout_constraintTop_toBottomOf="@id/entryUsername" >

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/inputLayoutPassword"
android:layout_width="match_parent"
Expand All @@ -206,18 +217,21 @@

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputPassword"
android:textSize="15sp"
android:textSize="16sp"
android:textStyle="normal"
android:textColor="@color/black_87_percent"
android:lineSpacingExtra="8sp"
android:fontFamily="monospace"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_password"
android:inputType="textNoSuggestions"
android:colorControlActivated="@color/violet_70"
android:singleLine="true"
android:clickable="true"
android:focusable="true"
android:paddingBottom="12dp"
android:foregroundGravity="center_vertical"
app:backgroundTint="@android:color/transparent"
tools:ignore="Autofill"/>
</com.google.android.material.textfield.TextInputLayout>
Expand All @@ -226,8 +240,8 @@
android:id="@+id/btnPasswordToggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="13dp"
android:background="@null"
android:foregroundGravity="center_horizontal|center_vertical"
android:contentDescription="@string/display_password_content_description"
Expand All @@ -241,8 +255,8 @@
android:layout_width="match_parent"
android:background="@color/gray_divider"
android:layout_marginStart="20dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="9dp"
android:layout_marginEnd="4dp"
android:layout_marginTop="9.5dp"
card_view:layout_constraintTop_toBottomOf="@id/btnPasswordToggle" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/res/menu/item_detail_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_detail_menu"
android:theme="@style/PopupKebabMenu"
android:layout_width="wrap_content"
android:dropDownWidth="wrap_content" >
android:popupMenuStyle="@style/PopupKebabMenu"
android:theme="@style/PopupKebabMenu">
<item
android:id="@+id/edit"
android:icon="@drawable/ic_edit"
android:padding="20dp"
android:elevation="15dp"
android:minWidth="82dp"
android:paddingStart="20dp"
android:title="@string/edit"
android:colorBackground="@color/menu_item_selected"
Expand All @@ -24,5 +24,9 @@
<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete"
android:title="@string/delete" />
android:title="@string/delete"
android:minWidth="82dp"
android:colorBackground="@color/menu_item_selected"
android:textColor="@color/black_87_percent"
android:listSelector="@color/menu_item_selected"/>
</menu>
11 changes: 10 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@
<item name="colorAccent">@color/violet_70</item>
<item name="buttonBarButtonStyle">@style/AlertButtonStyle</item>
</style>

<style name="DeleteDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowBackground">@drawable/rounded_corner_bg_white</item>
<item name="android:textColorPrimary">@color/black_60_percent</item>
<item name="android:textColor">@color/black_87_percent</item>
<item name="buttonBarButtonStyle">@style/AlertButtonStyle</item>
<item name="android:lineSpacingExtra">8sp</item>
</style>

<style name="AlertButtonStyle" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">@color/violet_70</item>
<item name="android:letterSpacing">0.09</item>
Expand All @@ -205,13 +207,15 @@
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>

<style name="NavDrawerStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textStyle">normal</item>
<item name="android:lineSpacingExtra">6.5sp</item>
<item name="android:drawableTint">@color/color_primary_dark</item>
</style>

<style name="NavDrawerButtonStyle" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textSize">16sp</item>
<item name="android:textAllCaps">false</item>
Expand All @@ -221,6 +225,7 @@
<item name="android:stateListAnimator">@null</item>
<item name="android:drawableTint">@color/color_primary_dark</item>
</style>

<style name="NoTitleDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
Expand All @@ -229,14 +234,14 @@
<item name="android:background">@android:color/transparent</item>
<item name="android:popupBackground">@android:color/transparent</item>
</style>

<style name="PopupMenu" parent="@style/Widget.AppCompat.PopupWindow">
<item name="android:popupBackground">@null</item>
<item name="android:background">@drawable/rounded_corner_bg_white</item>
<item name="android:popupEnterTransition">@android:transition/slide_top</item>
<item name="android:textColor">@color/black_87_percent</item>
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:dropDownWidth">128dp</item>
<item name="android:textStyle">normal</item>
<item name="android:letterSpacing">0.02</item>
<item name="android:lineSpacingExtra">6sp</item>
Expand All @@ -247,6 +252,7 @@
<item name="android:popupElevation">14dp</item>
<item name="android:elevation">0dp</item>
</style>

<style name="PopupKebabMenu" parent="@style/Widget.AppCompat.PopupWindow">
<item name="android:popupBackground">@null</item>
<item name="android:background">@drawable/rounded_corner_bg_white</item>
Expand All @@ -256,6 +262,7 @@
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:dropDownWidth">wrap_content</item>
<item name="android:minWidth">20dp</item>
<item name="android:textStyle">normal</item>
<item name="android:letterSpacing">0.02</item>
<item name="android:lineSpacingExtra">6sp</item>
Expand All @@ -266,12 +273,14 @@
<item name="android:popupElevation">20dp</item>
<item name="android:elevation">0dp</item>
</style>

<style name="ToastTextAppearance" parent="@style/TextAppearance">
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">@color/text_white</item>
<item name="android:layout_marginStart">20dp</item>
<item name="android:layout_marginEnd">20dp</item>
</style>

<style name="NoConnectivityWarning">
<item name="android:background">@color/color_primary_dark</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ class EditItemPresenterTest {

class FakeView : EditItemDetailView {

val togglePasswordVisibilityStub = PublishSubject.create<Unit>()
private val togglePasswordVisibilityStub = PublishSubject.create<Unit>()
override val togglePasswordVisibility: Observable<Unit>
get() = togglePasswordVisibilityStub

val passwordVisibleStub = false
private val passwordVisibleStub = false
override var isPasswordVisible: Boolean = passwordVisibleStub

val togglePwdClicksStub = PublishSubject.create<Unit>()
private val togglePwdClicksStub = PublishSubject.create<Unit>()
override val togglePasswordClicks: Observable<Unit>
get() = togglePwdClicksStub

val hostnameClicksStub = PublishSubject.create<String>()
private val hostnameClicksStub = PublishSubject.create<String>()
override val hostnameChanged: Observable<String>
get() = hostnameClicksStub

Expand All @@ -73,8 +73,10 @@ class EditItemPresenterTest {
}

var item: ItemDetailViewModel? = null
@StringRes var usernameError: Int? = null
@StringRes var passwordError: Int? = null
@StringRes
var usernameError: Int? = null
@StringRes
var passwordError: Int? = null
var _saveEnabled = true

val closeEntryClicksStub = PublishSubject.create<Unit>()
Expand All @@ -92,9 +94,11 @@ class EditItemPresenterTest {
override fun displayUsernameError(@StringRes errorMessage: Int?) {
usernameError = errorMessage
}

override fun displayPasswordError(@StringRes errorMessage: Int?) {
passwordError = errorMessage
}

override fun setSaveEnabled(enabled: Boolean) {
_saveEnabled = enabled
}
Expand Down Expand Up @@ -173,10 +177,12 @@ class EditItemPresenterTest {
subject.onViewReady()

getStub.onNext(item.asOptional())
listStub.onNext(listOf(
fakeCredential,
fakeCredentialNoUsername
))
listStub.onNext(
listOf(
fakeCredential,
fakeCredentialNoUsername
)
)
}

@Test
Expand Down