Skip to content

Commit

Permalink
DashPay: Add Send Payment to Pending Contact via QR code (NMA-373) (#503
Browse files Browse the repository at this point in the history
)

* Show Add New Contact if we have not received a request

previous code didn't show Add New Contact if we had sent a request, though we had no contacts.

* Show received request notification on user screen without accept/x buttons

* Do manual layout for user who has made a contact request

* Update layouts with new avatar size and add Accept Contact Request

* DashPayProfileDao: add load profile from username methods

* Phase 1 of supporting scanning QR codes and paying pending contacts and current contacts

* PaymentIntent: Add constructor that for address, identity and amount

* SendCoinsFragment: handle payment intents codes with username that is a contact/pending contact

* Use WorkManager for sending contact requests (#506)

* Show enter amount screen if blockchain is not synced (replaying)

* Tracking the progress of sending contact request

* Simplified tracking of the progress of send contact request operation (#509)

* Simplified tracking of the progress of send contact request operation
Removed some debug code

* Improved exception handling

* Refactored the code of handling payments to pending contact.
Added tracking the progress after sending contact request.

* Major refactoring of DashPayUserActivity and logic responsible for handling status of contact requests.
Fixed issues with sending payments to strangers.

* Minor code refactoring.
Mostly changed the naming convention for Room DAOs (the `Async` suffix should not be used in coroutine based / suspended versions)

* Improvements in tracking status of contact requests

* Improvements in tracking status of contact requests for DashPayUserActivity and UsernameSearchResultsAdapter

* Improvements in tracking status of contact requests for ContactSearchResultsAdapter and NotificationsAdapter

* Remember the state of 'Accept contact request' checkbox user-wise

Co-authored-by: tomasz-ludek <tomasz@dash.org>
  • Loading branch information
HashEngineering and tomasz-ludek authored Sep 29, 2020
1 parent 74c254a commit 0e687ea
Show file tree
Hide file tree
Showing 72 changed files with 2,079 additions and 1,470 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext {
}

buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
ext.ok_http_version = "3.12.3"

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple_dark">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@color/ripple_dark" />
</shape>
<color android:color="@android:color/transparent" />
</item>
</ripple>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/ripple_dark" android:state_pressed="true" />

</selector>
2 changes: 1 addition & 1 deletion wallet/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
<activity
android:name="de.schildbach.wallet.ui.TransactionResultActivity"
android:screenOrientation="portrait"
android:theme="@style/My.Theme.Fullscreen" />
android:theme="@style/My.Theme.ChildActivity" />

<activity android:name="de.schildbach.wallet.ui.ForgotPinActivity"
android:screenOrientation="portrait"
Expand Down
11 changes: 8 additions & 3 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
implementation 'com.google.android:flexbox:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation "androidx.work:work-runtime-ktx:2.4.0"
implementation "org.dashj:dashj-core:$dashjVersion"
implementation 'org.dashevo:dashpay:0.14-SNAPSHOT'
implementation 'org.dashevo:platform-core:0.14-SNAPSHOT'
Expand Down Expand Up @@ -105,6 +106,9 @@ ext {
archivesBaseName = 'dash-wallet'
}

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28

Expand Down Expand Up @@ -219,12 +223,13 @@ android {
dexOptions {
preDexLibraries true
}
kotlinOptions {
jvmTarget = "1.8"
}
}

clean {
file('src/main/jniLibs').deleteDir()
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
360 changes: 33 additions & 327 deletions wallet/res/layout/activity_dashpay_user.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions wallet/res/layout/contact_request_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/displayName"
android:id="@+id/display_name"
style="@style/MontserratSemiBold"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand All @@ -42,9 +42,9 @@
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="@id/displayName"
app:layout_constraintStart_toStartOf="@id/display_name"
app:layout_constraintEnd_toStartOf="@id/buttons"
app:layout_constraintTop_toBottomOf="@id/displayName"
app:layout_constraintTop_toBottomOf="@id/display_name"
tools:text="johndoe_01" />

<LinearLayout
Expand Down
206 changes: 206 additions & 0 deletions wallet/res/layout/contact_request_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<merge 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:animateLayoutChanges="true"
android:background="@color/bg_less_bright"
android:orientation="vertical"
tools:parentTag="android.widget.LinearLayout">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dash_white">

<LinearLayout
android:id="@+id/main_button"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:background="@drawable/blue_button_background"
android:gravity="center"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">

<ImageView
android:id="@+id/main_button_icon"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:srcCompat="@drawable/ic_add_contact_white"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/main_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_contact_request"
android:textColor="@color/dash_white"
android:textSize="14sp" />

</LinearLayout>
</FrameLayout>

<FrameLayout
android:id="@+id/pay_button_pane"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dash_white"
android:paddingTop="32dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:ignore="UselessLeaf" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/bg_less_bright" />

</LinearLayout>

<Button
android:id="@+id/pay_button"
style="@style/DashButton.Blue"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:paddingStart="26dp"
android:paddingEnd="26dp"
android:text="@string/pay" />

</FrameLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/contact_request_received_pane"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="32dp">

<TextView
android:id="@+id/request_received_pane_title"
style="@style/MontserratRegular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="34dp"
android:layout_marginTop="26dp"
android:layout_marginRight="34dp"
android:textColor="@android:color/black"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/contact_request_received_title" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/request_buttons_guide"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"
app:layout_constraintTop_toBottomOf="@id/request_received_pane_title" />

<Button
android:id="@+id/accept"
style="@style/DashButton.AquaGreen"
android:layout_width="100dp"
android:layout_height="39dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="5dp"
android:text="@string/contact_request_accept"
app:layout_constraintEnd_toStartOf="@id/request_buttons_guide"
app:layout_constraintTop_toBottomOf="@id/request_received_pane_title" />

<Button
android:id="@+id/ignore"
style="@style/DashButton.MediumGray"
android:layout_width="100dp"
android:layout_height="39dp"
android:layout_marginStart="5dp"
android:layout_marginTop="14dp"
android:text="@string/contact_request_ignore"
app:layout_constraintStart_toEndOf="@id/request_buttons_guide"
app:layout_constraintTop_toBottomOf="@id/request_received_pane_title" />

</androidx.constraintlayout.widget.ConstraintLayout>

<LinearLayout
android:id="@+id/contact_history_disclaimer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="38dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:background="@drawable/round_corners_white_bg"
android:orientation="vertical">

<ImageView
android:id="@+id/ic_add_stranger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
app:srcCompat="@drawable/ic_add_stranger" />

<TextView
android:id="@+id/contact_history_disclaimer_text"
style="@style/MontserratRegular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="26dp"
android:layout_marginBottom="24dp"
android:gravity="center"
android:textColor="@android:color/black"
android:textSize="16sp"
tools:text="Add Katie Rennie as your contact to Pay Directly to Username and Retain Mutual Transaction History" />

<LinearLayout
android:id="@+id/disclaimer_button"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="24dp"
android:background="@drawable/blue_outline_button_bg"
android:gravity="center"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">

<ImageView
android:id="@+id/disclaimer_button_icon"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:srcCompat="@drawable/inverted_contact_icon"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/disclaimer_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_contact_request"
android:textColor="@color/inverted_button"
android:textSize="14sp" />

</LinearLayout>

</LinearLayout>

</merge>
8 changes: 4 additions & 4 deletions wallet/res/layout/contact_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/displayName"
android:id="@+id/display_name"
style="@style/MontserratSemiBold"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand All @@ -38,9 +38,9 @@
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="@id/displayName"
app:layout_constraintTop_toBottomOf="@id/displayName"
app:layout_constraintEnd_toEndOf="@id/displayName"
app:layout_constraintStart_toStartOf="@id/display_name"
app:layout_constraintTop_toBottomOf="@id/display_name"
app:layout_constraintEnd_toEndOf="@id/display_name"
tools:text="johndoe_01" />

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 0 additions & 3 deletions wallet/res/layout/contacts_list_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@
app:srcCompat="@drawable/ic_search"
tools:visibility="visible" />


<androidx.recyclerview.widget.RecyclerView
android:id="@+id/contacts_rv"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Loading

0 comments on commit 0e687ea

Please sign in to comment.