-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashpay): add Balance Mixing Warning before username request
- Loading branch information
1 parent
48576be
commit a526b9e
Showing
8 changed files
with
234 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Copyright (c) 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 <https://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<View | ||
android:id="@+id/drag_indicator" | ||
android:layout_width="40dp" | ||
android:layout_height="4dp" | ||
android:layout_gravity="center" | ||
android:layout_marginTop="15dp" | ||
android:background="@drawable/rounded_background" | ||
android:theme="@style/DragIndicatorBackground" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:background="@color/light_gray" /> | ||
|
||
<ImageButton | ||
android:id="@+id/collapse_button" | ||
style="@style/DialogCloseButton" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
|
||
<LinearLayout | ||
android:id="@+id/text_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="20dp" | ||
android:orientation="vertical" | ||
app:layout_constraintTop_toBottomOf="@id/collapse_button" | ||
app:layout_constraintBottom_toTopOf="@+id/bottom_buttons" | ||
> | ||
<TextView | ||
style="@style/Headline5" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/mix_dash_title" | ||
/> | ||
<TextView | ||
style="@style/Body2" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/mix_dash_message" | ||
/> | ||
|
||
|
||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/bottom_buttons" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:orientation="horizontal" | ||
> | ||
<Button | ||
android:id="@+id/skip_button" | ||
android:layout_marginHorizontal="15dp" | ||
android:layout_marginVertical="15dp" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
style="@style/Button.Tertiary.Blue" | ||
android:text="@string/button_skip" | ||
/> | ||
|
||
<Button | ||
android:id="@+id/mix_button" | ||
android:layout_marginHorizontal="15dp" | ||
android:layout_marginVertical="15dp" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
style="@style/Button.Primary.Blue" | ||
android:text="@string/mix_dash_mix" | ||
/> | ||
</LinearLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
wallet/src/de/schildbach/wallet/ui/more/MixDashFirstDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.schildbach.wallet.ui.more | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.lifecycleScope | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import de.schildbach.wallet.ui.CreateUsernameActivity | ||
import de.schildbach.wallet.ui.coinjoin.CoinJoinActivity | ||
import de.schildbach.wallet_test.R | ||
import de.schildbach.wallet_test.databinding.DialogMixDashFirstBinding | ||
import kotlinx.coroutines.launch | ||
import org.dash.wallet.common.ui.dialogs.OffsetDialogFragment | ||
import org.dash.wallet.common.ui.viewBinding | ||
|
||
@AndroidEntryPoint | ||
class MixDashFirstDialogFragment : OffsetDialogFragment(R.layout.dialog_mix_dash_first) { | ||
private val binding by viewBinding(DialogMixDashFirstBinding::bind) | ||
val viewModel by viewModels<MixDashFirstViewModel>() | ||
private val settingsViewModel: SettingsViewModel by viewModels() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.skipButton.setOnClickListener { | ||
startActivity(Intent(requireContext(), CreateUsernameActivity::class.java)) | ||
viewModel.setMixDashShown() | ||
dismiss() | ||
} | ||
|
||
binding.mixButton.setOnClickListener { | ||
lifecycleScope.launch { | ||
val shouldShowFirstTimeInfo = settingsViewModel.shouldShowCoinJoinInfo() | ||
|
||
if (shouldShowFirstTimeInfo) { | ||
settingsViewModel.setCoinJoinInfoShown() | ||
} | ||
|
||
val intent = Intent(requireActivity(), CoinJoinActivity::class.java) | ||
intent.putExtra(CoinJoinActivity.FIRST_TIME_EXTRA, shouldShowFirstTimeInfo) | ||
startActivity(intent) | ||
viewModel.setMixDashShown() | ||
dismiss() | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
wallet/src/de/schildbach/wallet/ui/more/MixDashFirstViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.schildbach.wallet.ui.more | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import de.schildbach.wallet.Constants | ||
import de.schildbach.wallet.ui.dashpay.utils.DashPayConfig | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import org.bitcoinj.core.Address | ||
import org.bitcoinj.script.ScriptPattern | ||
import org.bitcoinj.wallet.KeyChain | ||
import org.dash.wallet.common.WalletDataProvider | ||
import org.dash.wallet.common.services.BlockchainStateProvider | ||
import org.dash.wallet.common.util.Constants.DASH_CURRENCY | ||
import org.slf4j.LoggerFactory | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MixDashFirstViewModel @Inject constructor( | ||
private val dashPayConfig: DashPayConfig, | ||
) : ViewModel() { | ||
fun setMixDashShown() { | ||
viewModelScope.launch(Dispatchers.IO) { | ||
dashPayConfig.set(DashPayConfig.MIX_DASH_SHOWN, true) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters