Skip to content

Commit

Permalink
feat(voting): improve voting button and grouping by date (#1335)
Browse files Browse the repository at this point in the history
* feat: add voting period ends improvements

* feat: use thumbs up/down logos instead

* fix: crash on empty list

* fix: update sorting to match user selection

* feat: improve sorting

* fix: prevent crash after view destroyed

* chore: cleanup and add license
  • Loading branch information
HashEngineering authored Dec 30, 2024
1 parent e60a712 commit 80c8cd0
Show file tree
Hide file tree
Showing 20 changed files with 594 additions and 129 deletions.
25 changes: 25 additions & 0 deletions wallet/res/drawable/ic_thumb_down_red.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ Copyright 2024 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 xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<path
android:pathData="M14.123,0.744H3.823C2.813,0.744 1.953,1.434 1.733,2.454L0.763,8.554C0.663,9.164 0.843,9.784 1.243,10.254C1.643,10.724 2.233,10.994 2.853,10.994H6.103V12.464C6.083,13.184 6.293,13.874 6.713,14.464C7.063,14.964 7.623,15.254 8.223,15.254C8.273,15.254 8.313,15.254 8.363,15.254C9.013,15.204 9.583,14.824 9.883,14.244L11.913,10.214C11.974,10.084 12.113,10.004 12.253,10.004H14.144C15.314,10.004 16.264,9.054 16.264,7.884V2.864C16.264,1.694 15.314,0.744 14.144,0.744H14.123ZM10.774,9.644L8.743,13.674C8.603,13.944 8.353,13.994 8.253,14.004C8.143,14.004 7.893,14.004 7.723,13.754C7.463,13.374 7.323,12.934 7.333,12.474L7.353,10.374C7.353,10.204 7.293,10.044 7.173,9.924C7.053,9.804 6.893,9.734 6.733,9.734H2.853C2.593,9.734 2.363,9.624 2.193,9.434C2.033,9.244 1.953,8.984 1.993,8.734L2.953,2.674C3.043,2.274 3.403,1.984 3.813,1.984H11.253V9.074C11.054,9.224 10.884,9.404 10.774,9.634V9.644ZM14.983,7.874C14.983,8.354 14.594,8.744 14.113,8.744H12.503V1.994H14.113C14.594,1.994 14.983,2.384 14.983,2.864V7.884V7.874Z"
android:fillColor="#EA3943"/>
</vector>
25 changes: 25 additions & 0 deletions wallet/res/drawable/ic_thumb_down_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ Copyright 2024 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 xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<path
android:pathData="M14.123,0.744H3.823C2.813,0.744 1.953,1.434 1.733,2.454L0.763,8.554C0.663,9.164 0.843,9.784 1.243,10.254C1.643,10.724 2.233,10.994 2.853,10.994H6.103V12.464C6.083,13.184 6.293,13.874 6.713,14.464C7.063,14.964 7.623,15.254 8.223,15.254C8.273,15.254 8.313,15.254 8.363,15.254C9.013,15.204 9.583,14.824 9.883,14.244L11.913,10.214C11.974,10.084 12.113,10.004 12.253,10.004H14.144C15.314,10.004 16.264,9.054 16.264,7.884V2.864C16.264,1.694 15.314,0.744 14.144,0.744H14.123ZM10.774,9.644L8.743,13.674C8.603,13.944 8.353,13.994 8.253,14.004C8.143,14.004 7.893,14.004 7.723,13.754C7.463,13.374 7.323,12.934 7.333,12.474L7.353,10.374C7.353,10.204 7.293,10.044 7.173,9.924C7.053,9.804 6.893,9.734 6.733,9.734H2.853C2.593,9.734 2.363,9.624 2.193,9.434C2.033,9.244 1.953,8.984 1.993,8.734L2.953,2.674C3.043,2.274 3.403,1.984 3.813,1.984H11.253V9.074C11.054,9.224 10.884,9.404 10.774,9.634V9.644ZM14.983,7.874C14.983,8.354 14.594,8.744 14.113,8.744H12.503V1.994H14.113C14.594,1.994 14.983,2.384 14.983,2.864V7.884V7.874Z"
android:fillColor="#ffffff"/>
</vector>
25 changes: 25 additions & 0 deletions wallet/res/drawable/ic_thumb_up_blue.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ Copyright 2024 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 xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<path
android:pathData="M2.877,15.256H13.177C14.186,15.256 15.047,14.566 15.267,13.546L16.236,7.446C16.337,6.836 16.156,6.216 15.757,5.746C15.356,5.276 14.767,5.006 14.146,5.006H10.896V3.536C10.917,2.816 10.707,2.126 10.286,1.536C9.937,1.036 9.377,0.746 8.777,0.746C8.727,0.746 8.687,0.746 8.637,0.746C7.987,0.796 7.417,1.176 7.117,1.756L5.087,5.786C5.027,5.916 4.887,5.996 4.747,5.996H2.857C1.687,5.996 0.737,6.946 0.737,8.116V13.136C0.737,14.306 1.687,15.256 2.857,15.256H2.877ZM6.227,6.356L8.257,2.326C8.397,2.056 8.647,2.006 8.747,1.996C8.857,1.996 9.107,1.996 9.277,2.246C9.537,2.626 9.677,3.066 9.667,3.526L9.647,5.626C9.647,5.796 9.707,5.956 9.827,6.076C9.947,6.196 10.106,6.266 10.267,6.266H14.146C14.406,6.266 14.637,6.376 14.807,6.566C14.967,6.756 15.047,7.016 15.007,7.266L14.047,13.326C13.957,13.726 13.597,14.016 13.186,14.016H5.747V6.926C5.947,6.776 6.117,6.596 6.227,6.366V6.356ZM2.017,8.126C2.017,7.646 2.407,7.256 2.887,7.256H4.497V14.006H2.887C2.407,14.006 2.017,13.616 2.017,13.136V8.116V8.126Z"
android:fillColor="#008DE4"/>
</vector>
25 changes: 25 additions & 0 deletions wallet/res/drawable/ic_thumb_up_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ Copyright 2024 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 xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<path
android:pathData="M2.877,15.256H13.177C14.186,15.256 15.047,14.566 15.267,13.546L16.236,7.446C16.337,6.836 16.156,6.216 15.757,5.746C15.356,5.276 14.767,5.006 14.146,5.006H10.896V3.536C10.917,2.816 10.707,2.126 10.286,1.536C9.937,1.036 9.377,0.746 8.777,0.746C8.727,0.746 8.687,0.746 8.637,0.746C7.987,0.796 7.417,1.176 7.117,1.756L5.087,5.786C5.027,5.916 4.887,5.996 4.747,5.996H2.857C1.687,5.996 0.737,6.946 0.737,8.116V13.136C0.737,14.306 1.687,15.256 2.857,15.256H2.877ZM6.227,6.356L8.257,2.326C8.397,2.056 8.647,2.006 8.747,1.996C8.857,1.996 9.107,1.996 9.277,2.246C9.537,2.626 9.677,3.066 9.667,3.526L9.647,5.626C9.647,5.796 9.707,5.956 9.827,6.076C9.947,6.196 10.106,6.266 10.267,6.266H14.146C14.406,6.266 14.637,6.376 14.807,6.566C14.967,6.756 15.047,7.016 15.007,7.266L14.047,13.326C13.957,13.726 13.597,14.016 13.186,14.016H5.747V6.926C5.947,6.776 6.117,6.596 6.227,6.366V6.356ZM2.017,8.126C2.017,7.646 2.407,7.256 2.887,7.256H4.497V14.006H2.887C2.407,14.006 2.017,13.616 2.017,13.136V8.116V8.126Z"
android:fillColor="#ffffff"/>
</vector>
28 changes: 28 additions & 0 deletions wallet/res/layout/dialog_username_request_filters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,40 @@
android:layout_marginTop="5dp"
app:layout_constraintTop_toBottomOf="@id/header">



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="vertical"
android:paddingHorizontal="15dp">
<TextView
android:id="@+id/group_by_label"
style="@style/Caption.Medium.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:text="@string/group_by" />

<androidx.cardview.widget.CardView
android:id="@+id/group_by_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardBackgroundColor="@color/background_secondary"
app:cardCornerRadius="10dp"
app:cardElevation="0dp">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/group_by_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="2"
tools:listitem="@layout/radiobutton_row" />
</androidx.cardview.widget.CardView>

<TextView
android:id="@+id/sort_by_label"
Expand Down
24 changes: 24 additions & 0 deletions wallet/res/layout/fragment_username_request_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@
android:layout_marginTop="2dp"
tools:text="90f95ff7bc2438a748dc8470255b888b2a9ea6837bf518d018dc3d6cddf698" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:orientation="vertical"
android:paddingHorizontal="15dp"
android:paddingVertical="10dp"
android:background="@drawable/rounded_background"
android:theme="@style/GrayPanelBackground">

<TextView
style="@style/Overline.Secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/voting_period" />

<TextView
android:id="@+id/voting_period"
style="@style/Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
tools:text="2024 Dec 1 to 2014 Dec 15" />
</LinearLayout>
</LinearLayout>

<FrameLayout
Expand Down
37 changes: 37 additions & 0 deletions wallet/res/layout/username_request_date_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2024 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/>.
-->
<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="36dp"
tools:context="de.schildbach.wallet.ui.username.adapters.DateViewHolder">

<TextView
android:id="@+id/date_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:maxLines="1"
android:ellipsize="middle"
tools:text="Voting period ends in 14 days"/>
</androidx.constraintlayout.widget.ConstraintLayout>
57 changes: 43 additions & 14 deletions wallet/res/layout/username_request_group_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:id="@+id/link_included"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="link included"
android:text="@string/link_included"
style="@style/Caption.Blue"
app:layout_constraintTop_toTopOf="@id/link_badge"
app:layout_constraintStart_toEndOf="@id/link_badge" />
Expand All @@ -79,32 +79,61 @@
app:layout_constraintBottom_toBottomOf="@id/username"
tools:text="4 requests" />

<Button
android:id="@+id/blocks_button"
<LinearLayout
android:id="@+id/blocks_button_container"
style="@style/Button.Primary.Large.LightRed"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"
android:layout_marginHorizontal="8dp"
app:layout_constraintEnd_toStartOf="@id/approvals_button"
android:layout_marginVertical="5dp"
app:layout_constraintEnd_toStartOf="@id/approvals_button_container"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="1\nBlock"
/>
tools:text="2" >
<TextView
android:id="@+id/blocks_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/system_red"
android:textSize="12sp"
tools:text="2"
/>
<ImageView
android:id="@+id/blocks_button_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:src="@drawable/ic_thumb_down_red"
/>
</LinearLayout>

<Button
android:id="@+id/approvals_button"
<LinearLayout
android:id="@+id/approvals_button_container"
style="@style/Button.Primary.Large.LightBlue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="5dp"
android:layout_marginHorizontal="10dp"
app:layout_constraintEnd_toStartOf="@id/chevron"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="3\nApprovals"
/>

tools:text="2" >
<TextView
android:id="@+id/approvals_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/dash_blue"
android:textSize="12sp"
tools:text="2"
/>
<ImageView
android:id="@+id/approvals_button_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:src="@drawable/ic_thumb_up_blue"
/>
</LinearLayout>
<ImageView
android:id="@+id/chevron"
android:layout_width="11dp"
Expand Down
25 changes: 20 additions & 5 deletions wallet/res/layout/username_request_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
android:id="@+id/link_included"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="link included"
android:text="@string/link_included"
style="@style/Caption.Blue"
app:layout_constraintTop_toTopOf="@id/link_badge"
app:layout_constraintStart_toEndOf="@id/link_badge" />

<Button
android:id="@+id/approvals_button"
<LinearLayout
android:id="@+id/approvals_button_container"
style="@style/Button.Primary.Large.LightBlue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
Expand All @@ -78,8 +78,23 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/info"
app:layout_constraintBottom_toBottomOf="@id/info"
tools:text="2\nApprovals"
/>
tools:text="2" >
<TextView
android:id="@+id/approvals_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/dash_blue"
android:textSize="12sp"
tools:text="2"
/>
<ImageView
android:id="@+id/approvals_button_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:src="@drawable/ic_thumb_up_blue"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 4 additions & 0 deletions wallet/res/navigation/nav_voting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
android:name="requestId"
app:argType="string" />

<argument
android:name="startDate"
app:argType="long" />

<action
android:id="@+id/details_to_votingKeyInput"
app:destination="@id/votingKeyInputFragment"
Expand Down
Loading

0 comments on commit 80c8cd0

Please sign in to comment.