Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashpay): add quick voting function #1322

Merged
merged 49 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9461b9d
feat: add firebase events for some dashpay related actions
HashEngineering Oct 21, 2024
374e646
fix: change order of operands to ensure execution
HashEngineering Oct 21, 2024
d41c0d8
fix: use dashj 21.1.2
HashEngineering Oct 21, 2024
ab41f9d
chore: v11.0.1
HashEngineering Oct 21, 2024
582456e
feat: update username voting screen
HashEngineering Oct 25, 2024
637f51a
feat: add keys changes
HashEngineering Oct 25, 2024
8380f24
feat: add keys errors
HashEngineering Oct 25, 2024
c6376ba
feat: enable ANR tracing in logs
HashEngineering Oct 28, 2024
b698f1a
fix: use Dispatchers.IO for RequestUserNameViewModel
HashEngineering Oct 28, 2024
81f6172
refactor: change vote system to return a tuple
HashEngineering Oct 28, 2024
553ebec
refactor: change vote queries to use get_vote_polls
HashEngineering Oct 28, 2024
4fb2216
fix: improve Username Voting screen and voting
HashEngineering Oct 29, 2024
adef6fe
feature: add delete masternode key functionality
HashEngineering Oct 29, 2024
0d3fdfd
rix: remove Dispatchers.IO from checkUsername
HashEngineering Oct 30, 2024
cf38951
rix: remove Dispatchers.IO from checkUsername
HashEngineering Oct 30, 2024
0557194
fix: use withContext(Dispatchers.IO)
HashEngineering Oct 30, 2024
a70ae80
fix: use withContext(Dispatchers.IO)
HashEngineering Oct 30, 2024
435d958
Merge branch 'dashpay-voting' of https://github.com/dashevo/dash-wall…
HashEngineering Oct 30, 2024
b206800
fix: add voting keys fixes
HashEngineering Oct 31, 2024
6b81f00
fix: fix vote click bug
HashEngineering Oct 31, 2024
d84bc96
fix: add vote key again
HashEngineering Oct 31, 2024
02f6608
fix: prevent counting one vote as many
HashEngineering Oct 31, 2024
da7848f
chore: log the wrong vote differently
HashEngineering Oct 31, 2024
93b9b5f
fix: correct duplicate key detection
HashEngineering Oct 31, 2024
292d401
Merge branch 'dashpay-voting' of https://github.com/dashevo/dash-wall…
HashEngineering Nov 7, 2024
19e080b
fix: fix request process state
HashEngineering Nov 7, 2024
7ba3d44
fix: add tools:text for Results on
HashEngineering Nov 7, 2024
f0994a1
chore: remove commented code
HashEngineering Nov 12, 2024
20d9a77
fix: simplify Username Request vote button styles
HashEngineering Nov 12, 2024
be31a0b
fix: delete vote fix
HashEngineering Nov 12, 2024
46ca1a0
feat: add OneVoteLeftDialog
HashEngineering Nov 12, 2024
a7faea4
feat: add blue lightning bolt next to Quick Voting
HashEngineering Nov 12, 2024
430c0b9
feat: add countVotes
HashEngineering Nov 12, 2024
ba15a37
fix: spacing and text on OneVoteLeftDialogFragment
HashEngineering Nov 12, 2024
5249c6e
feat: add new text for Quick Voting
HashEngineering Nov 12, 2024
bffd933
feat: add isQuickVoting for BroadcastUsernameVotes* classes
HashEngineering Nov 12, 2024
2b45314
feat: add isQuickVoting for BroadcastUsernameVotes* classes
HashEngineering Nov 12, 2024
7cb7397
feat: isApproved is based on the last vote
HashEngineering Nov 12, 2024
de02ad7
fix: update voteForAll functiom
HashEngineering Nov 12, 2024
da0dde5
fix: update voteForAll function
HashEngineering Nov 12, 2024
a36f41c
feat: add quick voting support to UsernameRequestsFragment
HashEngineering Nov 13, 2024
6df16b5
feat: improve username search in UsernameRequestsFragment
HashEngineering Nov 13, 2024
299d9bd
feat: improve username search in UsernameRequestsFragment
HashEngineering Nov 13, 2024
8f22dc9
Merge branch 'master' of https://github.com/dashevo/dash-wallet into …
HashEngineering Nov 15, 2024
57168a5
fix: keep track of normalized and regular labels
HashEngineering Nov 18, 2024
c4bf491
fix: some bugs resulting from removing mocking
HashEngineering Nov 19, 2024
15142ab
chore: use platform 1.5.1-SNAPSHOT
HashEngineering Nov 20, 2024
3d351ef
Merge branch 'master' of https://github.com/dashevo/dash-wallet into …
HashEngineering Nov 20, 2024
51f111b
Merge branch 'master' of https://github.com/dashevo/dash-wallet into …
HashEngineering Dec 2, 2024
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
82 changes: 0 additions & 82 deletions common/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -961,87 +961,6 @@
<item name="android:theme">@style/PrimaryButtonTheme.Large.LightBlue</item>
</style>

<style name="VoteButtonTheme">
<item name="cornerRadius">7dp</item>
<item name="titleTextColor">@color/white</item>
<item name="backgroundColor">@color/content_primary</item>
<item name="strokeColor">@color/content_primary</item>
<item name="rippleColor">@color/ripple_light</item>
<item name="disabledBackgroundColor">@color/disabled_button_bg</item>
</style>

<style name="VoteButton" parent="Widget.AppCompat.Button.Borderless">
<item name="fontFamily">@font/inter_semibold</item>
<item name="android:textColor">@color/button_text</item>
<item name="android:background">@drawable/rounded_ripple_background</item>
<item name="android:theme">@style/VoteButtonTheme</item>
<item name="android:textSize">12sp</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingStart">8dp</item>
<item name="android:paddingEnd">8dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:minHeight">40dp</item>
</style>

<style name="Button.Vote" parent="Widget.AppCompat.Button.Borderless">
<item name="fontFamily">@font/inter_semibold</item>
<item name="android:textColor">@color/button_text</item>
<item name="android:background">@drawable/rounded_ripple_background</item>
<item name="android:theme">@style/VoteButtonTheme</item>
<item name="android:textSize">12sp</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingStart">8dp</item>
<item name="android:paddingEnd">8dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:minHeight">40dp</item>
</style>

<style name="VoteButton.LightBlue">
<item name="backgroundColor">@color/dash_blue_0.05</item>
<item name="strokeColor">@android:color/transparent</item>
<item name="titleTextColor">@color/dash_blue</item>
<item name="rippleColor">@color/button_ripple_color</item>
</style>

<style name="Button.Vote.LightBlue">
<item name="android:theme">@style/VoteButton.LightBlue</item>
</style>

<style name="VoteButton.LightRed">
<item name="backgroundColor">@color/red_0.05</item>
<item name="strokeColor">@android:color/transparent</item>
<item name="titleTextColor">@color/red</item>
<item name="rippleColor">@color/button_ripple_color</item>
</style>

<style name="Button.Vote.LightRed">
<item name="android:theme">@style/VoteButton.LightRed</item>
</style>

<style name="VoteButton.Blue">
<item name="backgroundColor">@color/dash_blue</item>
<item name="strokeColor">@android:color/transparent</item>
<item name="titleTextColor">@color/dash_white</item>
<item name="rippleColor">@color/button_ripple_color</item>
</style>

<style name="Button.Vote.Blue">
<item name="android:theme">@style/VoteButton.Blue</item>
</style>

<style name="VoteButton.Red">
<item name="backgroundColor">@color/red</item>
<item name="strokeColor">@android:color/transparent</item>
<item name="titleTextColor">@color/dash_white</item>
<item name="rippleColor">@color/button_ripple_color</item>
</style>

<style name="Button.Vote.Red">
<item name="android:theme">@style/VoteButton.Red</item>
</style>

<style name="Button.Primary.Small">
<item name="android:textSize">13sp</item>
<item name="android:minHeight">30dp</item>
Expand All @@ -1064,7 +983,6 @@
<item name="android:theme">@style/PrimaryButtonTheme.Small.Round</item>
</style>


<style name="Button.Primary.ExtraSmall">
<item name="android:theme">@style/PrimaryButtonTheme.ExtraSmall</item>
<item name="android:textSize">11sp</item>
Expand Down
9 changes: 9 additions & 0 deletions wallet/res/drawable/ic_blue_bolt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="10dp"
android:height="16dp"
android:viewportWidth="10"
android:viewportHeight="16">
<path
android:pathData="M0.5,8.81C0.5,8.666 0.562,8.52 0.685,8.371L6.753,0.915C6.872,0.771 6.999,0.681 7.135,0.647C7.275,0.613 7.4,0.626 7.51,0.686C7.621,0.745 7.697,0.841 7.74,0.972C7.786,1.1 7.774,1.254 7.701,1.437L5.734,6.696H9.491C9.639,6.696 9.76,6.743 9.854,6.836C9.951,6.926 10,7.04 10,7.18C10,7.329 9.941,7.477 9.822,7.626L3.754,15.076C3.635,15.224 3.505,15.316 3.365,15.349C3.229,15.384 3.106,15.371 2.996,15.311C2.886,15.252 2.807,15.156 2.76,15.025C2.718,14.893 2.731,14.736 2.799,14.554L4.772,9.294H1.009C0.865,9.294 0.744,9.25 0.646,9.16C0.549,9.067 0.5,8.95 0.5,8.81Z"
android:fillColor="#008DE4"/>
</vector>
102 changes: 102 additions & 0 deletions wallet/res/layout/dialog_one_vote_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<View
android:id="@+id/drag_indicator"
android:layout_width="35dp"
android:layout_height="4dp"
android:layout_gravity="center"
android:layout_marginVertical="7dp"
android:background="@drawable/rounded_background"
android:theme="@style/DragIndicatorBackground"
tools:background="@color/light_gray" />

<TextView
style="@style/Headline5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:gravity="center_horizontal"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:text="@string/one_vote_left_title" />

<TextView
android:id="@+id/subtitle"
style="@style/Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:text="@string/quick_vote_subtitle" />

<TextView
android:id="@+id/show_usernames"
style="@style/Caption.Medium.Blue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:text="@string/one_vote_left_show_usernames" />

<TextView
android:id="@+id/username_list"
style="@style/Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:textAlignment="gravity"
android:layout_marginHorizontal="20dp"
android:visibility="invisible"
tools:visibility="visible"
tools:text="@string/one_vote_left_username_examples" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="15dp">

<Button
android:id="@+id/dismiss_btn"
style="@style/Button.Primary.Large.Grey"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:text="@string/cancel" />

<Button
android:id="@+id/ok_button"
style="@style/Button.Primary.Large.Blue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="15dp"
android:layout_weight="1"
android:text="@string/button_ok" />
</LinearLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion wallet/res/layout/fragment_more.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
style="@style/MenuRowSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/requested_voting_duration" />
tools:text="Results on 10/12/2024" />
</LinearLayout>

<LinearLayout
Expand Down
31 changes: 22 additions & 9 deletions wallet/res/layout/fragment_username_requests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,29 @@
app:navigationIcon="@drawable/ic_arrow_back"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<TextView
<LinearLayout
android:id="@+id/quick_vote_button"
style="@style/Subtitle2.Blue"
android:paddingVertical="4dp"
android:paddingHorizontal="12dp"
android:textSize="13sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="end"
android:text="@string/quick_vote" />
android:paddingVertical="4dp"
android:paddingHorizontal="12dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:src="@drawable/ic_blue_bolt"
android:layout_gravity="center_vertical"
/>
<TextView
style="@style/Subtitle2.Blue"
android:textSize="13sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/quick_vote" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
Expand Down Expand Up @@ -198,11 +211,11 @@
android:id="@+id/request_groups"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:paddingBottom="15dp"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingBottom="15dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_panel"
Expand Down
15 changes: 2 additions & 13 deletions wallet/res/layout/username_request_group_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@
app:layout_constraintTop_toTopOf="@id/link_badge"
app:layout_constraintStart_toEndOf="@id/link_badge" />

<!-- <TextView-->
<!-- android:id="@+id/block_votes"-->
<!-- style="@style/Body2.Medium.Red"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingVertical="17dp"-->
<!-- android:layout_marginStart="15dp"-->
<!-- app:layout_constraintStart_toEndOf="@id/username"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- tools:text="(1s Blocks)" />-->

<TextView
android:id="@+id/requests_amount"
style="@style/Overline.Tertiary"
Expand All @@ -92,7 +81,7 @@

<Button
android:id="@+id/blocks_button"
style="@style/Button.Vote.LightRed"
style="@style/Button.Primary.Large.LightRed"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"
Expand All @@ -105,7 +94,7 @@

<Button
android:id="@+id/approvals_button"
style="@style/Button.Vote.LightBlue"
style="@style/Button.Primary.Large.LightBlue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"
Expand Down
32 changes: 1 addition & 31 deletions wallet/res/layout/username_request_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

<Button
android:id="@+id/approvals_button"
style="@style/Button.Vote.LightBlue"
style="@style/Button.Primary.Large.LightBlue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginHorizontal="8dp"
Expand All @@ -82,34 +82,4 @@
/>
</androidx.constraintlayout.widget.ConstraintLayout>

<!-- <TextView-->
<!-- android:id="@+id/cancel_approval_button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginEnd="10dp"-->
<!-- style="@style/Button.Tertiary.ExtraSmall"-->
<!-- android:text="@string/cancel_approval"-->
<!-- app:layout_constraintEnd_toStartOf="@id/vote_amount"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- />-->



<!-- <TextView-->
<!-- android:id="@+id/vote_amount"-->
<!-- style="@style/Overline.Tertiary"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="20dp"-->
<!-- android:layout_marginEnd="15dp"-->
<!-- android:minWidth="20dp"-->
<!-- android:paddingHorizontal="7dp"-->
<!-- android:gravity="center"-->
<!-- android:textAlignment="gravity"-->
<!-- android:background="@drawable/rounded_background"-->
<!-- android:theme="@style/InactiveBadgeTheme"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- tools:text="10" />-->
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions wallet/res/values/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@
<string name="add_masternode_key">Add Masternode Voting Key</string>
<string name="dont_ask_again">Don\'t ask me again</string>
<string name="vote_submitting">Submitting your vote for %s username</string>
<string name="quick_vote_submitting">Submitting your votes for all usernames</string>
<string name="vote_submitted">Voted for %s username</string>
<string name="quick_vote_submitted">Successfully voted for all usernames</string>
<string name="cancel_submitting">Canceling your vote for %s username</string>
<string name="cancel_submitted">Canceled vote for %s username</string>
<string name="block_submitting">Blocking for %s username</string>
Expand All @@ -371,6 +373,10 @@
<string name="quick_vote">Quick Voting</string>
<string name="quick_vote_subtitle">By tapping the \"Vote for All\" button, you will automatically vote for all of the filtered usernames (%d) that were submitted first</string>
<string name="vote_for_all">Vote for All</string>
<string name="one_vote_left_title">One Vote Left</string>
<string name="one_vote_left_show_usernames">Show usernames</string>
<string name="one_vote_left_subtitle">You have already voted for the following usernames %d times. You can only cast one more vote for these usernames.</string>
<string name="one_vote_left_username_examples" translatable="false">stargazer101, quantumquirk, dreamchaser22, pixelpioneer, nebulanavigator, echoexplorer, cyberscribe, lunalark, astroaficionado, mysticmuse, solarsage, galacticguru, horizonhunter, cosmiccrafter, celestialseeker, orbitoracle, stellarscribe, novanomad, astroartisan, meteormaverick</string>
<string name="voting_period_active">Username Voting Period Active</string>
<string name="there_was_a_network_error">There was a network error, you can try again at no extra cost</string>
<string name="requested_username_has_been">Username has been requested.</string>
Expand Down
3 changes: 0 additions & 3 deletions wallet/src/de/schildbach/wallet/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public final class Constants {
public static boolean SUPPORTS_PLATFORM;
// TODO: remove all references to this when invites are enabled and functional
public static boolean SUPPORTS_INVITES;
// TODO: remove all references to this when quick voting is enabled and functional
public static final boolean SUPPORTS_QUICKVOTING = false;


public static final EnumSet<MasternodeSync.SYNC_FLAGS> SYNC_FLAGS = MasternodeSync.SYNC_DEFAULT_SPV;
public static final EnumSet<MasternodeSync.VERIFY_FLAGS> VERIFY_FLAGS = MasternodeSync.VERIFY_DEFAULT_SPV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ interface UsernameVoteDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(usernameVote: UsernameVote)

@Query("SELECT COUNT(*) FROM username_votes WHERE username = :username")
suspend fun countVotes(username: String): Int

@Query("SELECT * FROM username_votes WHERE username = :username ORDER BY timestamp")
suspend fun getVotes(username: String): List<UsernameVote>

Expand Down
Loading
Loading