Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Rayserzor
samourai-wallet-android
Commits
4d8fe141
Verified
Commit
4d8fe141
authored
Nov 21, 2020
by
Sarath
⚔
Browse files
Save payload state after applying Whirlpool SCODE
parent
8f7a4622
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
27 deletions
+47
-27
app/src/main/java/com/samourai/wallet/whirlpool/WhirlpoolMain.java
...ain/java/com/samourai/wallet/whirlpool/WhirlpoolMain.java
+47
-27
No files found.
app/src/main/java/com/samourai/wallet/whirlpool/WhirlpoolMain.java
View file @
4d8fe141
...
...
@@ -21,7 +21,9 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
com.google.android.material.appbar.CollapsingToolbarLayout
;
import
com.google.android.material.dialog.MaterialAlertDialogBuilder
;
import
com.samourai.wallet.R
;
import
com.samourai.wallet.access.AccessFactory
;
import
com.samourai.wallet.api.APIFactory
;
import
com.samourai.wallet.cahoots.Cahoots
;
import
com.samourai.wallet.cahoots.psbt.PSBTUtil
;
...
...
@@ -29,11 +31,13 @@ import com.samourai.wallet.fragments.CameraFragmentBottomSheet;
import
com.samourai.wallet.home.BalanceActivity
;
import
com.samourai.wallet.network.NetworkDashboard
;
import
com.samourai.wallet.network.dojo.DojoUtil
;
import
com.samourai.wallet.payload.PayloadUtil
;
import
com.samourai.wallet.send.FeeUtil
;
import
com.samourai.wallet.send.SendActivity
;
import
com.samourai.wallet.send.cahoots.ManualCahootsActivity
;
import
com.samourai.wallet.service.JobRefreshService
;
import
com.samourai.wallet.util.AppUtil
;
import
com.samourai.wallet.util.CharSequenceX
;
import
com.samourai.wallet.util.FormatsUtil
;
import
com.samourai.wallet.util.LinearLayoutManagerWrapper
;
import
com.samourai.wallet.utxos.PreSelectUtil
;
...
...
@@ -65,6 +69,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import
androidx.recyclerview.widget.DiffUtil
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.CompositeDisposable
;
...
...
@@ -440,6 +445,17 @@ public class WhirlpoolMain extends AppCompatActivity {
return
super
.
onOptionsItemSelected
(
item
);
}
private
void
saveState
(){
new
Thread
(()
->
{
try
{
PayloadUtil
.
getInstance
(
getApplicationContext
()).
saveWalletToJSON
(
new
CharSequenceX
(
AccessFactory
.
getInstance
(
getApplicationContext
()).
getGUID
()
+
AccessFactory
.
getInstance
(
getApplicationContext
()).
getPIN
()));
}
catch
(
Exception
e
)
{
;
}
}).
start
();
}
private
void
doSCODE
()
{
final
EditText
scode
=
new
EditText
(
WhirlpoolMain
.
this
);
...
...
@@ -453,32 +469,36 @@ public class WhirlpoolMain extends AppCompatActivity {
.
setTitle
(
R
.
string
.
app_name
)
.
setMessage
(
R
.
string
.
enter_scode
)
.
setView
(
scode
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
String
strSCODE
=
scode
.
getText
().
toString
().
trim
();
if
(
scode
!=
null
)
{
WhirlpoolMeta
.
getInstance
(
WhirlpoolMain
.
this
).
setSCODE
(
strSCODE
);
WhirlpoolNotificationService
.
stopService
(
getApplicationContext
());
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
Intent
_intent
=
new
Intent
(
WhirlpoolMain
.
this
,
BalanceActivity
.
class
);
_intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
startActivity
(
_intent
);
}
.
setNeutralButton
(
"Remove SCODE"
,
(
dialog
,
which
)
->
{
WhirlpoolMeta
.
getInstance
(
WhirlpoolMain
.
this
).
setSCODE
(
""
);
WhirlpoolNotificationService
.
stopService
(
getApplicationContext
());
saveState
();
new
Handler
().
postDelayed
(()
->
{
Intent
_intent
=
new
Intent
(
WhirlpoolMain
.
this
,
BalanceActivity
.
class
);
_intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
startActivity
(
_intent
);
},
1000L
);
})
.
setPositiveButton
(
R
.
string
.
ok
,
(
dialog
,
whichButton
)
->
{
String
strSCODE
=
scode
.
getText
().
toString
().
trim
();
if
(
scode
!=
null
)
{
WhirlpoolMeta
.
getInstance
(
WhirlpoolMain
.
this
).
setSCODE
(
strSCODE
);
WhirlpoolNotificationService
.
stopService
(
getApplicationContext
());
saveState
();
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
Intent
_intent
=
new
Intent
(
WhirlpoolMain
.
this
,
BalanceActivity
.
class
);
_intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
);
startActivity
(
_intent
);
}
},
1000L
);
},
1000L
);
}
dialog
.
dismiss
();
}
}).
setNegativeButton
(
R
.
string
.
cancel
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
dialog
.
dismiss
();
}
}).
show
();
dialog
.
dismiss
();
}).
setNegativeButton
(
R
.
string
.
cancel
,
(
dialog
,
whichButton
)
->
dialog
.
dismiss
()).
show
();
}
...
...
@@ -596,12 +616,12 @@ public class WhirlpoolMain extends AppCompatActivity {
// prefix with "Mix x/y - "
try
{
int
currentMix
=
whirlpoolUtxo
.
getMixsDone
()
+
1
;
int
currentMix
=
whirlpoolUtxo
.
getMixsDone
()
+
1
;
int
mixsTarget
=
whirlpoolUtxo
.
getMixsTargetOrDefault
(
AndroidWhirlpoolWalletService
.
MIXS_TARGET_DEFAULT
);
String
mixInfo
=
"Mix "
+
currentMix
+
"/"
+
mixsTarget
+
" - "
;
holder
.
mixingProgress
.
setText
(
mixInfo
+
holder
.
mixingProgress
.
getText
());
String
mixInfo
=
"Mix "
+
currentMix
+
"/"
+
mixsTarget
+
" - "
;
holder
.
mixingProgress
.
setText
(
mixInfo
+
holder
.
mixingProgress
.
getText
());
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment