Skip to content

Commit

Permalink
Remove custom logic for sizing autofill overflow menu popup
Browse files Browse the repository at this point in the history
  • Loading branch information
CDRussell committed Jan 27, 2025
1 parent 925a86d commit 5245b57
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package com.duckduckgo.autofill.impl.ui.credential.management

import android.annotation.SuppressLint
import android.content.Context
import android.content.res.Configuration
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -192,23 +190,14 @@ class AutofillManagementRecyclerAdapter(
context: Context,
loginCredentials: LoginCredentials,
): PopupMenu {
return PopupMenu(LayoutInflater.from(context), R.layout.overflow_menu_list_item, width = getPopupMenuWidth(context)).apply {
return PopupMenu(LayoutInflater.from(context), R.layout.overflow_menu_list_item).apply {
onMenuItemClicked(contentView.findViewById(R.id.item_overflow_edit)) { onContextMenuItemClicked(Edit(loginCredentials)) }
onMenuItemClicked(contentView.findViewById(R.id.item_overflow_delete)) { onContextMenuItemClicked(Delete(loginCredentials)) }
onMenuItemClicked(contentView.findViewById(R.id.item_copy_username)) { onContextMenuItemClicked(CopyUsername(loginCredentials)) }
onMenuItemClicked(contentView.findViewById(R.id.item_copy_password)) { onContextMenuItemClicked(CopyPassword(loginCredentials)) }
}
}

private fun getPopupMenuWidth(context: Context): Int {
val orientation = context.resources.configuration.orientation
return if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
LayoutParams.WRAP_CONTENT
} else {
context.resources.getDimensionPixelSize(R.dimen.credentialManagementListItemPopupMenuWidth)
}
}

private fun ItemRowAutofillCredentialsManagementScreenBinding.updateFavicon(credentials: LoginCredentials) {
lifecycleOwner.lifecycleScope.launch {
val url = credentials.domain.orEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
-->

<resources>
<dimen name="credentialManagementListItemPopupMenuWidth">200dp</dimen>
<dimen name="autofillBottomSheetBottomPadding">30dp</dimen>
<dimen name="autofillBottomSheetContentMaxWidth">480dp</dimen>
</resources>

0 comments on commit 5245b57

Please sign in to comment.