Skip to content

Commit

Permalink
fix: align with Send Request functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Aug 22, 2024
1 parent 1c03ae1 commit 2ac3001
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 138 deletions.
199 changes: 113 additions & 86 deletions wallet/res/layout/fragment_voting_request_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,68 +54,68 @@
android:layout_marginTop="15dp"
android:orientation="horizontal">

<ImageView
android:id="@+id/create_a_username_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/create_a_username_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/create_a_username_title"
app:srcCompat="@drawable/ic_calendar" />

<TextView
style="@style/Caption.SemiBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:includeFontPadding="false"
android:text="@string/voting"
android:textAlignment="gravity" />

<TextView
android:id="@+id/voting_range"
style="@style/Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:maxLines="1"
android:textAlignment="gravity"
tools:text=" 1 Mar – 15 Mar" />
<!-- <ImageView-->
<!-- android:id="@+id/create_a_username_icon"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintEnd_toStartOf="@id/create_a_username_title"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@+id/create_a_username_title"-->
<!-- app:srcCompat="@drawable/ic_calendar" />-->

<!-- <TextView-->
<!-- style="@style/Caption.SemiBold"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="7dp"-->
<!-- android:includeFontPadding="false"-->
<!-- android:text="@string/voting"-->
<!-- android:textAlignment="gravity" />-->

<!-- <TextView-->
<!-- android:id="@+id/voting_range"-->
<!-- style="@style/Caption"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:includeFontPadding="false"-->
<!-- android:maxLines="1"-->
<!-- android:textAlignment="gravity"-->
<!-- tools:text=" 1 Mar – 15 Mar" />-->
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<ImageView
android:id="@+id/votes_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/create_a_username_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/create_a_username_title"
app:srcCompat="@drawable/ic_thumb_up_fill" />

<TextView
android:id="@+id/votes_number"
style="@style/Caption.SemiBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:includeFontPadding="false"
android:text="@string/votes"
android:textAlignment="gravity" />

<ImageView
android:id="@+id/votes_arrow"
android:layout_width="wrap_content"
android:layout_height="11dp"
android:layout_gravity="center"
android:src="@drawable/ic_menu_row_arrow"
app:srcCompat="@drawable/ic_menu_row_arrow" />
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="10dp"-->
<!-- android:orientation="horizontal">-->

<!-- <ImageView-->
<!-- android:id="@+id/votes_icon"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintEnd_toStartOf="@id/create_a_username_title"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="@+id/create_a_username_title"-->
<!-- app:srcCompat="@drawable/ic_thumb_up_fill" />-->

<!-- <TextView-->
<!-- android:id="@+id/votes_number"-->
<!-- style="@style/Caption.SemiBold"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="7dp"-->
<!-- android:includeFontPadding="false"-->
<!-- android:text="@string/votes"-->
<!-- android:textAlignment="gravity" />-->

<!-- <ImageView-->
<!-- android:id="@+id/votes_arrow"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="11dp"-->
<!-- android:layout_gravity="center"-->
<!-- android:src="@drawable/ic_menu_row_arrow"-->
<!-- app:srcCompat="@drawable/ic_menu_row_arrow" />-->
<!-- </LinearLayout>-->

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -150,7 +150,7 @@
android:layout_weight="1"
android:gravity="end"
android:textAlignment="textEnd"
tools:text="John Doe" />
tools:text="JohnDoe" />
</LinearLayout>

<LinearLayout
Expand Down Expand Up @@ -187,7 +187,7 @@
android:textAlignment="textEnd" />

<TextView
android:id="@+id/verfiy_now"
android:id="@+id/verify"
style="@style/Overline.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -264,34 +264,61 @@
android:layout_weight="1"
android:gravity="end"
android:textAlignment="textEnd"
tools:text="John Doe" />
tools:text="GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingVertical="15dp">

<TextView
style="@style/Caption.Medium.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:text="@string/results" />

<TextView
android:id="@+id/voting_range"
style="@style/Caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:gravity="end"
android:textAlignment="textEnd"
tools:text="March 31, 2024" />

</LinearLayout>
</LinearLayout>
</LinearLayout>

<Button
android:id="@+id/cancel_request_button"
style="@style/Button.Primary.Large.LightRed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginBottom="15dp"
android:text="@string/cancel_request"
app:layout_constraintBottom_toBottomOf="parent" />

<TextView
android:id="@+id/balance_requirement_disclaimer"
style="@style/Overline.Secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:gravity="center_horizontal"
android:text="@string/if_you_tap_cancel"
android:textAlignment="gravity"
app:layout_constraintBottom_toTopOf="@id/cancel_request_button"
app:layout_constraintEnd_toEndOf="@id/cancel_request_button"
app:layout_constraintStart_toStartOf="@id/cancel_request_button"
tools:visibility="visible" />
<!-- <Button-->
<!-- android:id="@+id/cancel_request_button"-->
<!-- style="@style/Button.Primary.Large.LightRed"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginHorizontal="15dp"-->
<!-- android:layout_marginBottom="15dp"-->
<!-- android:text="@string/cancel_request"-->
<!-- app:layout_constraintBottom_toBottomOf="parent" />-->

<!-- <TextView-->
<!-- android:id="@+id/balance_requirement_disclaimer"-->
<!-- style="@style/Overline.Secondary"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginBottom="12dp"-->
<!-- android:gravity="center_horizontal"-->
<!-- android:text="@string/if_you_tap_cancel"-->
<!-- android:textAlignment="gravity"-->
<!-- app:layout_constraintBottom_toTopOf="@id/cancel_request_button"-->
<!-- app:layout_constraintEnd_toEndOf="@id/cancel_request_button"-->
<!-- app:layout_constraintStart_toStartOf="@id/cancel_request_button"-->
<!-- tools:visibility="visible" />-->

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 2 additions & 1 deletion wallet/res/values/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<string name="only_links">Only requests with links</string>
<string name="only_links_short">With links</string>
<string name="date">Date: %s</string>
<string name="votes">Votes: %s</string>
<string name="votes">Votes: %d</string>

<string-array name="usernames_sort_by_options">
<item>New to old</item>
Expand Down Expand Up @@ -308,6 +308,7 @@
<string name="request_details_subtitle">Review the posting bellow to verify the ownership of this username</string>
<string name="vote_to_approve">Vote to Approve</string>
<string name="identity">Identity</string>
<string name="results">Results</string>
<string name="link">Link</string>
<string name="link_not_provided">Not provided</string>
<string name="cancel_approval">Cancel Approval</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ data class UsernameRequest(
val username: String,
val createdAt: Long,
val identity: String,
val link: String?,
var link: String?,
val votes: Int,
val isApproved: Boolean
)
) {
companion object {
fun getRequestId(identity: String, username: String): String {
return String.format("%s %s", identity, username)
}
}
}
19 changes: 18 additions & 1 deletion wallet/src/de/schildbach/wallet/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import android.view.MenuItem
import android.view.WindowManager
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.annotation.NavigationRes
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import androidx.navigation.findNavController
import com.google.common.collect.ImmutableList
import dagger.hilt.android.AndroidEntryPoint
import de.schildbach.wallet.Constants
Expand Down Expand Up @@ -91,9 +93,19 @@ class MainActivity : AbstractBindServiceActivity(), ActivityCompat.OnRequestPerm

const val EXTRA_RESET_BLOCKCHAIN = "reset_blockchain"
private const val EXTRA_INVITE = "extra_invite"
private const val EXTRA_NAVIGATION_DESTINATION = "extra_destination"

fun createIntent(context: Context): Intent {
return Intent(context, MainActivity::class.java)
return Intent(context, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}

fun createIntent(context: Context, @NavigationRes destination: Int): Intent {
return Intent(context, MainActivity::class.java).apply {
putExtra(EXTRA_NAVIGATION_DESTINATION, destination)
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}

fun createIntent(context: Context, invite: InvitationLinkData): Intent {
Expand Down Expand Up @@ -385,6 +397,11 @@ class MainActivity : AbstractBindServiceActivity(), ActivityCompat.OnRequestPerm
pendingInvite = invite
}
}
if (intent.hasExtra(EXTRA_NAVIGATION_DESTINATION)) {
val destination = intent.extras!!.getInt(EXTRA_NAVIGATION_DESTINATION)
val navController = findNavController(R.id.nav_host_fragment)
navController.navigate(destination)
}
val action = intent.action
val extras = intent.extras
if (NfcAdapter.ACTION_NDEF_DISCOVERED == action) {
Expand Down
2 changes: 1 addition & 1 deletion wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ class MainViewModel @Inject constructor(
}

suspend fun getRequestedUsername(): String =
blockchainIdentityDataDao.get(BlockchainIdentityConfig.REQUESTED_USERNAME) ?: ""
blockchainIdentityDataDao.get(BlockchainIdentityConfig.USERNAME) ?: ""
suspend fun getInviteHistory() = invitationsDao.loadAll()

private fun combineLatestData(): Boolean {
Expand Down
8 changes: 8 additions & 0 deletions wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package de.schildbach.wallet.ui.more
import android.content.Intent
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.text.format.DateFormat
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
Expand Down Expand Up @@ -60,6 +61,7 @@ import org.dash.wallet.common.ui.viewBinding
import org.dash.wallet.common.util.observe
import org.dash.wallet.common.util.safeNavigate
import org.slf4j.LoggerFactory
import java.util.concurrent.TimeUnit
import javax.inject.Inject

@AndroidEntryPoint
Expand Down Expand Up @@ -180,6 +182,12 @@ class MoreFragment : Fragment(R.layout.fragment_more) {
binding.joinDashpayContainer.visibility = View.GONE
binding.requestedUsernameContainer.visibility = View.VISIBLE
binding.requestedUsernameTitle.text = mainActivityViewModel.getRequestedUsername()
val votingPeriod = it.votingPeriodStart?.let { startTime ->
val endTime = startTime + TimeUnit.MILLISECONDS.toDays(14)
val dateFormat = DateFormat.getMediumDateFormat(requireContext())
String.format("%s - %s", dateFormat.format(startTime), dateFormat.format(endTime))
} ?: "Voting Period not found"
binding.requestedUsernameSubtitleTwo.text = getString(R.string.requested_voting_duration, votingPeriod)
} else {
binding.joinDashpayContainer.visibility = View.VISIBLE
binding.requestedUsernameContainer.visibility = View.GONE
Expand Down
Loading

0 comments on commit 2ac3001

Please sign in to comment.