Skip to content

Commit

Permalink
Merge pull request #2728 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored May 31, 2021
2 parents 5e0968f + b2b91c1 commit 0320c19
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GEM
faraday (>= 0.8)
git (1.7.0)
rchardet (~> 1.8)
kramdown (2.3.0)
kramdown (2.3.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
Expand All @@ -55,7 +55,7 @@ GEM
open4 (1.3.4)
public_suffix (4.0.6)
rchardet (1.8.0)
rexml (3.2.4)
rexml (3.2.5)
ruby-ll (2.1.2)
ansi
ast
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

## Latest releases 🛠

- Kotlin && New | [v8.4.0](https://github.com/mikepenz/MaterialDrawer/tree/v8.4.0)
- Kotlin && New | [v8.4.1](https://github.com/mikepenz/MaterialDrawer/tree/v8.4.1)
- Kotlin | [v7.0.0](https://github.com/mikepenz/MaterialDrawer/tree/v7.0.0) | (Builder approach like v6.x)
- Java && AndroidX | [v6.1.2](https://github.com/mikepenz/MaterialDrawer/tree/v6.1.2)
- Java && AppCompat | [v6.0.9](https://github.com/mikepenz/MaterialDrawer/tree/v6.0.9)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ buildscript {

ext {
release = [
versionName: "8.4.0",
versionCode: 8040
versionName: "8.4.1",
versionCode: 8041
]

setup = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import java.util.*
* This view offers support to add an account switcher to the [MaterialDrawerSliderView]
* It will hook onto the [MaterialDrawerSliderView] and coordinate updating and showing the proper set of elements
*/
open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, compact: Boolean? = null) : ConstraintLayout(context, attrs, defStyleAttr) {
open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, compact: Boolean? = null) :
ConstraintLayout(context, attrs, defStyleAttr) {
var savedInstanceKey: String = ""

// global references to views we need later
Expand Down Expand Up @@ -221,6 +222,13 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
buildProfiles()
}

// enable to show badges on current profile images
var displayBadgesOnCurrentProfileImage = true
set(value) {
field = value
buildProfiles()
}

// enable to show badges on small profile images
var displayBadgesOnSmallProfileImages = false
set(value) {
Expand Down Expand Up @@ -297,7 +305,7 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
if (onAccountHeaderProfileImageListener != null) {
val profile = v.getTag(R.id.material_drawer_profile_header) as IProfile
return@OnLongClickListener onAccountHeaderProfileImageListener?.invoke(v, profile, true)
?: false
?: false
}
false
}
Expand All @@ -309,7 +317,7 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
if (onAccountHeaderProfileImageListener != null) {
val profile = v.getTag(R.id.material_drawer_profile_header) as IProfile
return@OnLongClickListener onAccountHeaderProfileImageListener?.invoke(v, profile, false)
?: false
?: false
}
false
}
Expand Down Expand Up @@ -394,7 +402,10 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
init {
val headerLayout = context.resolveStyledHeaderValue {
compactStyle = compact ?: it.getBoolean(R.styleable.AccountHeaderView_materialDrawerCompactStyle, false)
it.getResourceId(R.styleable.AccountHeaderView_materialDrawerHeaderLayout, if (compactStyle) R.layout.material_drawer_compact_header else R.layout.material_drawer_header)
it.getResourceId(
R.styleable.AccountHeaderView_materialDrawerHeaderLayout,
if (compactStyle) R.layout.material_drawer_compact_header else R.layout.material_drawer_header
)
}

// the account header
Expand Down Expand Up @@ -480,8 +491,10 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
headerBackground?.applyTo(accountHeaderBackground, DrawerImageLoader.Tags.ACCOUNT_HEADER.name)

// get the text color to use for the text section
val textColor = context.getHeaderSelectionTextColor() // textColor.applyColor(context, R.attr.materialDrawerHeaderSelectionText, R.color.material_drawer_header_selection_text)
val subTextColor = context.getHeaderSelectionSubTextColor() // this.textColor.applyColor(context, R.attr.materialDrawerHeaderSelectionSubtext, R.color.material_drawer_header_selection_subtext)
val textColor =
context.getHeaderSelectionTextColor() // textColor.applyColor(context, R.attr.materialDrawerHeaderSelectionText, R.color.material_drawer_header_selection_text)
val subTextColor =
context.getHeaderSelectionSubTextColor() // this.textColor.applyColor(context, R.attr.materialDrawerHeaderSelectionSubtext, R.color.material_drawer_header_selection_subtext)

if (accountHeaderTextSectionBackgroundResource == -1) {
accountHeaderTextSectionBackgroundResource = context.getSelectableBackgroundRes()
Expand Down Expand Up @@ -533,7 +546,7 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
*/
private val onSelectionClickListener = OnClickListener { v ->
val consumed = onAccountHeaderSelectionViewClickListener?.invoke(v, v.getTag(R.id.material_drawer_profile_header) as IProfile)
?: false
?: false
if (accountSwitcherArrow.visibility == View.VISIBLE && !consumed) {
toggleSelectionList()
}
Expand Down Expand Up @@ -904,11 +917,13 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
currentProfileView.invalidate()

var badgeVisible = false
(mCurrentProfile as? ColorfulBadgeable)?.let { badgeable ->
badgeVisible = StringHolder.applyToOrHide(badgeable.badge, currentProfileBadgeView)
if (badgeVisible) {
badgeable.badgeStyle?.style(currentProfileBadgeView, context.getPrimaryDrawerTextColor())
typeface?.let { typeface -> currentProfileBadgeView.typeface = typeface }
if (displayBadgesOnCurrentProfileImage) {
(mCurrentProfile as? ColorfulBadgeable)?.let { badgeable ->
badgeVisible = StringHolder.applyToOrHide(badgeable.badge, currentProfileBadgeView)
if (badgeVisible) {
badgeable.badgeStyle?.style(currentProfileBadgeView, context.getPrimaryDrawerTextColor())
typeface?.let { typeface -> currentProfileBadgeView.typeface = typeface }
}
}
}
currentProfileBadgeView.visibility = if (badgeVisible) View.VISIBLE else View.GONE
Expand Down Expand Up @@ -1021,7 +1036,7 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
val profile = v.getTag(R.id.material_drawer_profile_header) as IProfile

val consumed = onAccountHeaderProfileImageListener?.invoke(v, profile, current)
?: false
?: false

//if the event was already consumed by the click don't continue. note that this will also stop the profile change event
if (!consumed) {
Expand Down Expand Up @@ -1086,7 +1101,7 @@ open class AccountHeaderView @JvmOverloads constructor(context: Context, attrs:
continue
} else {
selectedPosition = sliderView?.itemAdapter?.getGlobalPosition(position)
?: 0
?: 0
}
}
if (profile is IDrawerItem<*>) {
Expand Down

0 comments on commit 0320c19

Please sign in to comment.