Skip to content

Commit

Permalink
feat(dashpay): redesign userpic and notifications (home screen) (#1180)
Browse files Browse the repository at this point in the history
* chore: apply ktlint

* feat: redesign Home screen userpic/notifications

* chore: refactor synthetics in EditProfileActivity

* chore: cleanup
  • Loading branch information
Syn-McJ authored Aug 3, 2023
1 parent 93da33f commit 9b33c83
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ object AnalyticsConstants {
const val NOTIFICATIONS_ACCEPT_REQUEST = "notifications_accept_contact_request"
const val NOTIFICATIONS_CONTACT_DETAILS = "notifications_contact_details"
const val PROFILE_EDIT_MORE = "profile_edit_from_more"
const val PROFILE_EDIT_HOME = "profile_edit_from_home"
const val PROFILE_CHANGE_NAME = "profile_change_display_name"
const val PROFILE_NAME_LENGTH = "profile_display_name_length"
const val PROFILE_CHANGE_ABOUT_ME = "profile_change_about_me"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ class ProfilePictureDisplay {
}

@JvmStatic
fun display(avatarView: ImageView, avatarUrlStr: String, avatarHash: ByteArray?, username: String,
disableTransition: Boolean, listener: OnResourceReadyListener?) {
fun display(
avatarView: ImageView,
avatarUrlStr: String,
avatarHash: ByteArray?,
username: String,
disableTransition: Boolean,
listener: OnResourceReadyListener?
) {
val fontSize = calcFontSize(avatarView)
if (avatarUrlStr.isNotEmpty()) {
val defaultAvatar: Drawable? = getDrawable(avatarView.context, username[0], fontSize)
Expand All @@ -51,13 +57,23 @@ class ProfilePictureDisplay {
Glide.with(context)
.load(baseAvatarUrl)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
listener?.onResourceReady(null)
return false
}

override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?,
dataSource: DataSource?, isFirstResource: Boolean): Boolean {
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
ProfilePictureHelper.avatarHashAndFingerprint(
context,
baseAvatarUrl,
Expand Down Expand Up @@ -85,7 +101,12 @@ class ProfilePictureDisplay {
displayDefault(avatarView, username, calcFontSize(avatarView), listener)
}

private fun displayDefault(avatarView: ImageView, username: String, fontSize: Int, listener: OnResourceReadyListener?) {
private fun displayDefault(
avatarView: ImageView,
username: String,
fontSize: Int,
listener: OnResourceReadyListener?
) {
val defaultAvatar: Drawable? = getDrawable(avatarView.context, username[0], fontSize)
avatarView.setImageDrawable(defaultAvatar)
listener?.onResourceReady(defaultAvatar)
Expand All @@ -105,12 +126,14 @@ class ProfilePictureDisplay {
private fun removeParameter(uri: Uri, key: String): Uri {
val newUriBuilder = uri.buildUpon().clearQuery()
for (param in uri.queryParameterNames) {
newUriBuilder.appendQueryParameter(param,
newUriBuilder.appendQueryParameter(
param,
if (param == key) {
continue
} else {
uri.getQueryParameter(param)
})
}
)
}
return newUriBuilder.build()
}
Expand All @@ -119,4 +142,4 @@ class ProfilePictureDisplay {
interface OnResourceReadyListener {
fun onResourceReady(resource: Drawable?)
}
}
}
1 change: 1 addition & 0 deletions common/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<color name="dash_blue_0.1">#1A008DE4</color>
<color name="dash_blue_0.05">#0D008DE4</color>
<color name="system_red_0.1">#1AE85C4A</color>
<color name="dash_white_0.25">#40FFFFFF</color>

<color name="blue_50">#F0F8FE</color>
<color name="light_blue">#1A008DE4</color>
Expand Down
22 changes: 22 additions & 0 deletions wallet/res/drawable/ic_new_notifications.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright 2023 Dash Core Group.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<vector android:autoMirrored="true" android:height="20dp"
android:viewportHeight="20" android:viewportWidth="19"
android:width="19dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M1.977,16.089C1.474,16.089 1.073,15.959 0.776,15.698C0.484,15.438 0.338,15.093 0.338,14.665C0.338,14.323 0.422,14.001 0.589,13.696C0.763,13.392 0.98,13.104 1.241,12.83C1.508,12.551 1.781,12.278 2.06,12.011C2.29,11.8 2.464,11.521 2.582,11.173C2.706,10.826 2.799,10.441 2.861,10.019C2.929,9.59 2.988,9.156 3.038,8.715C3.094,7.61 3.252,6.617 3.513,5.736C3.78,4.854 4.168,4.109 4.677,3.501C5.186,2.893 5.838,2.446 6.632,2.16C6.831,1.546 7.178,1.034 7.675,0.624C8.172,0.208 8.761,0 9.444,0C9.947,0 10.397,0.112 10.794,0.335C10.428,0.732 10.136,1.195 9.919,1.723C9.708,2.244 9.602,2.796 9.602,3.38C9.602,4.205 9.807,4.963 10.217,5.652C10.633,6.341 11.182,6.893 11.865,7.309C12.554,7.719 13.314,7.924 14.146,7.924C14.444,7.924 14.73,7.896 15.003,7.84C15.282,7.778 15.552,7.691 15.813,7.579C15.844,7.858 15.872,8.144 15.897,8.436C15.928,8.727 15.952,9.022 15.971,9.32C16.002,9.662 16.049,10.003 16.111,10.344C16.173,10.686 16.263,11.006 16.381,11.304C16.499,11.595 16.654,11.831 16.846,12.011C17.126,12.278 17.396,12.551 17.656,12.83C17.923,13.104 18.14,13.392 18.308,13.696C18.482,14.001 18.569,14.323 18.569,14.665C18.569,15.093 18.42,15.438 18.122,15.698C17.83,15.959 17.433,16.089 16.93,16.089H1.977ZM9.453,20C8.895,20 8.392,19.879 7.945,19.637C7.504,19.401 7.147,19.084 6.874,18.687C6.601,18.296 6.446,17.871 6.409,17.412H12.507C12.464,17.871 12.309,18.296 12.042,18.687C11.775,19.084 11.418,19.401 10.971,19.637C10.524,19.879 10.018,20 9.453,20Z"/>
<path android:fillColor="#E85C4A" android:pathData="M14.155,6.583C13.565,6.583 13.028,6.44 12.544,6.154C12.06,5.863 11.672,5.475 11.38,4.991C11.095,4.5 10.952,3.963 10.952,3.38C10.952,2.796 11.095,2.262 11.38,1.778C11.672,1.288 12.06,0.9 12.544,0.614C13.028,0.323 13.565,0.177 14.155,0.177C14.739,0.177 15.272,0.323 15.757,0.614C16.247,0.9 16.635,1.288 16.92,1.778C17.212,2.262 17.358,2.796 17.358,3.38C17.358,3.963 17.212,4.5 16.92,4.991C16.635,5.475 16.247,5.863 15.757,6.154C15.272,6.44 14.739,6.583 14.155,6.583Z"/>
</vector>
32 changes: 20 additions & 12 deletions wallet/res/drawable/ic_notification_bell.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,0L12,0A12,12 0,0 1,24 12L24,12A12,12 0,0 1,12 24L12,24A12,12 0,0 1,0 12L0,12A12,12 0,0 1,12 0z"
android:fillColor="#90D1FA"/>
<path
android:pathData="m12,18.0002c0.66,0 1.2,-0.5539 1.2,-1.2308h-2.4c0,0.6769 0.534,1.2308 1.2,1.2308zM15.6,14.3074v-3.0769c0,-1.8892 -0.984,-3.4707 -2.7,-3.8892L12.9,6.9228c0,-0.5108 -0.402,-0.9231 -0.8999,-0.9231 -0.498,0 -0.9,0.4123 -0.9,0.9231L11.1001,7.3413C9.378,7.7597 8.4,9.3351 8.4,11.2304v3.0769l-1.2,1.2308v0.6153h9.5999v-0.6153z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<!--
~ Copyright 2023 Dash Core Group.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<vector android:autoMirrored="true" android:height="20dp"
android:viewportHeight="20" android:viewportWidth="19"
android:width="19dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M1.55,16.13C1.068,16.13 0.689,16.011 0.413,15.773C0.138,15.535 0,15.218 0,14.824C0,14.498 0.085,14.185 0.254,13.884C0.429,13.578 0.651,13.283 0.921,13.001C1.19,12.72 1.465,12.444 1.747,12.175C1.966,11.962 2.136,11.683 2.255,11.339C2.374,10.988 2.464,10.606 2.527,10.193C2.59,9.779 2.64,9.369 2.677,8.962C2.721,7.81 2.868,6.779 3.119,5.871C3.376,4.957 3.761,4.19 4.274,3.57C4.788,2.943 5.449,2.483 6.256,2.189C6.451,1.569 6.792,1.049 7.28,0.629C7.769,0.21 8.358,0 9.047,0C9.742,0 10.333,0.21 10.822,0.629C11.311,1.049 11.652,1.569 11.846,2.189C12.654,2.483 13.311,2.943 13.819,3.57C14.332,4.19 14.717,4.957 14.974,5.871C15.231,6.779 15.381,7.81 15.425,8.962C15.463,9.369 15.513,9.779 15.575,10.193C15.638,10.606 15.729,10.988 15.848,11.339C15.967,11.683 16.136,11.962 16.355,12.175C16.637,12.444 16.913,12.72 17.182,13.001C17.451,13.283 17.673,13.578 17.849,13.884C18.024,14.185 18.112,14.498 18.112,14.824C18.112,15.218 17.971,15.535 17.689,15.773C17.413,16.011 17.035,16.13 16.552,16.13H1.55ZM9.047,20C8.495,20 8.001,19.881 7.562,19.643C7.13,19.411 6.779,19.101 6.51,18.713C6.247,18.325 6.097,17.902 6.059,17.445H12.043C11.999,17.902 11.846,18.325 11.583,18.713C11.32,19.101 10.969,19.411 10.531,19.643C10.099,19.881 9.604,20 9.047,20Z"/>
</vector>
89 changes: 18 additions & 71 deletions wallet/res/layout/header_balance_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,91 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dash_blue"
tools:background="@color/blue_background_color"
tools:context="de.schildbach.wallet.ui.main.HeaderBalanceFragment">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/avatar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">

<ImageView
android:id="@+id/dashpay_user_avatar"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="center_horizontal"
android:layout_margin="8dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />

<ImageButton
android:id="@+id/notification_bell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/transparent_button_background"
app:layout_constraintBottom_toBottomOf="@id/dashpay_user_avatar"
app:layout_constraintEnd_toEndOf="@id/horizontal_guideline"
app:layout_constraintStart_toStartOf="@id/horizontal_guideline"
app:srcCompat="@drawable/ic_notification_bell" />

<TextView
android:id="@+id/notifications"
style="@style/Overline.Blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/notifications_button"
android:paddingStart="13dp"
android:paddingTop="5dp"
android:paddingEnd="13dp"
android:paddingBottom="5dp"
app:layout_constraintBottom_toBottomOf="@id/dashpay_user_avatar"
app:layout_constraintEnd_toEndOf="@id/horizontal_guideline"
app:layout_constraintStart_toStartOf="@id/horizontal_guideline"
tools:text="12" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/horizontal_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.60" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
android:id="@+id/syncing_indicator"
style="@style/Overline.White"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/syncing_balance"
android:alpha="0.5"
android:gravity="center"
android:text="@string/syncing_balance"
android:textAlignment="gravity"
android:visibility="invisible"
app:layout_constraintTop_toBottomOf="@id/avatar_container"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />

<ImageView
android:id="@+id/dash_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginTop="4dp"
android:src="@drawable/ic_dash_d_white"
app:layout_constraintTop_toTopOf="@id/wallet_balance_dash"
app:layout_constraintBottom_toBottomOf="@id/wallet_balance_dash"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/wallet_balance_dash"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/wallet_balance_dash"
tools:ignore="ContentDescription" />

<org.dash.wallet.common.ui.CurrencyTextView
Expand All @@ -95,38 +42,38 @@
android:layout_height="wrap_content"
android:layout_marginTop="-2dp"
android:ellipsize="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/dash_icon"
app:layout_constraintTop_toBottomOf="@id/syncing_indicator"
tools:text="0" />
app:layout_constraintStart_toEndOf="@id/dash_icon"
app:layout_constraintEnd_toEndOf="parent"
tools:text="0"/>

<org.dash.wallet.common.ui.CurrencyTextView
android:id="@+id/wallet_balance_local"
style="@style/Body2.White"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/wallet_balance_dash"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/wallet_balance_dash" />
app:layout_constraintEnd_toEndOf="parent" />

<FrameLayout
android:id="@+id/hide_balance_hint"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_marginTop="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/wallet_balance_local">

<TextView
android:id="@+id/hide_balance_hint_text"
style="@style/Overline.White"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.5"
android:text="@string/home_balance_hide_hint"
android:visibility="gone"
android:alpha="0.5"
tools:visibility="visible" />
</FrameLayout>

Expand All @@ -141,11 +88,11 @@
android:layout_width="44dp"
android:layout_height="44dp"
android:background="@drawable/rounded_ripple_background"
android:theme="@style/RevealBalanceBackground"
android:padding="9dp"
android:src="@drawable/ic_show_balance"
android:theme="@style/RevealBalanceBackground"
app:layout_constraintBottom_toBottomOf="@id/hide_balance_hint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/syncing_indicator" />
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 9b33c83

Please sign in to comment.