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
deBeauvoir
sentinel-android
Commits
68225a9f
Verified
Commit
68225a9f
authored
Oct 27, 2019
by
Sarath
⚔
Browse files
Merge remote-tracking branch 'origin/staging' into dojo
parents
d983b952
94e7ca65
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
118 deletions
+5
-118
app/src/main/java/com/samourai/sentinel/MainActivity2.java
app/src/main/java/com/samourai/sentinel/MainActivity2.java
+0
-27
app/src/main/java/com/samourai/sentinel/SettingsActivity.java
...src/main/java/com/samourai/sentinel/SettingsActivity.java
+4
-16
app/src/main/java/com/samourai/sentinel/util/ExchangeRateFactory.java
.../java/com/samourai/sentinel/util/ExchangeRateFactory.java
+1
-73
app/src/main/java/com/samourai/sentinel/util/WebUtil.java
app/src/main/java/com/samourai/sentinel/util/WebUtil.java
+0
-2
No files found.
app/src/main/java/com/samourai/sentinel/MainActivity2.java
View file @
68225a9f
...
...
@@ -289,33 +289,6 @@ public class MainActivity2 extends Activity {
e
.
printStackTrace
();
}
response
=
null
;
try
{
response
=
WebUtil
.
getInstance
(
getApplicationContext
()).
getURL
(
WebUtil
.
BTCe_EXCHANGE_URL
+
"btc_usd"
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
setDataBTCe
(
response
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
parseBTCe
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
response
=
null
;
try
{
response
=
WebUtil
.
getInstance
(
getApplicationContext
()).
getURL
(
WebUtil
.
BTCe_EXCHANGE_URL
+
"btc_rur"
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
setDataBTCe
(
response
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
parseBTCe
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
response
=
null
;
try
{
response
=
WebUtil
.
getInstance
(
getApplicationContext
()).
getURL
(
WebUtil
.
BTCe_EXCHANGE_URL
+
"btc_eur"
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
setDataBTCe
(
response
);
ExchangeRateFactory
.
getInstance
(
MainActivity2
.
this
).
parseBTCe
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
response
=
null
;
try
{
response
=
WebUtil
.
getInstance
(
getApplicationContext
()).
getURL
(
WebUtil
.
BFX_EXCHANGE_URL
);
...
...
app/src/main/java/com/samourai/sentinel/SettingsActivity.java
View file @
68225a9f
...
...
@@ -237,7 +237,7 @@ public class SettingsActivity extends PreferenceActivity {
private
void
getExchange
()
{
final
String
[]
exchanges
=
ExchangeRateFactory
.
getInstance
(
this
).
getExchangeLabels
();
final
int
sel
=
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
getValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
0
);
final
int
sel
=
(
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
getValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
0
)
>=
exchanges
.
length
)
?
0
:
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
getValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
0
);
new
AlertDialog
.
Builder
(
SettingsActivity
.
this
)
.
setTitle
(
R
.
string
.
options_currency
)
...
...
@@ -245,7 +245,7 @@ public class SettingsActivity extends PreferenceActivity {
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_EXCHANGE
,
exchanges
[
which
].
substring
(
exchanges
[
which
].
length
()
-
3
));
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
which
);
if
(
which
==
2
)
{
if
(
which
==
1
)
{
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_FIAT
,
"USD"
);
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_FIAT_SEL
,
0
);
dialog
.
dismiss
();
...
...
@@ -263,15 +263,8 @@ public class SettingsActivity extends PreferenceActivity {
private
void
getFiat
()
{
final
int
fxSel
=
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
getValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
0
);
final
String
[]
currencies
;
if
(
fxSel
==
1
)
{
currencies
=
ExchangeRateFactory
.
getInstance
(
this
).
getCurrencyLabelsBTCe
();
}
else
{
currencies
=
ExchangeRateFactory
.
getInstance
(
this
).
getCurrencyLabels
();
}
currencies
=
ExchangeRateFactory
.
getInstance
(
this
).
getCurrencyLabels
();
new
AlertDialog
.
Builder
(
SettingsActivity
.
this
)
.
setTitle
(
R
.
string
.
options_currency
)
...
...
@@ -279,12 +272,7 @@ public class SettingsActivity extends PreferenceActivity {
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
String
selectedCurrency
=
null
;
if
(
currencies
[
which
].
substring
(
currencies
[
which
].
length
()
-
3
).
equals
(
"RUR"
))
{
selectedCurrency
=
"RUB"
;
}
else
{
selectedCurrency
=
currencies
[
which
].
substring
(
currencies
[
which
].
length
()
-
3
);
}
selectedCurrency
=
currencies
[
which
].
substring
(
currencies
[
which
].
length
()
-
3
);
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_FIAT
,
selectedCurrency
);
PrefsUtil
.
getInstance
(
SettingsActivity
.
this
).
setValue
(
PrefsUtil
.
CURRENT_FIAT_SEL
,
which
);
...
...
app/src/main/java/com/samourai/sentinel/util/ExchangeRateFactory.java
View file @
68225a9f
...
...
@@ -14,13 +14,10 @@ public class ExchangeRateFactory {
private
static
Context
context
=
null
;
private
static
String
strDataLBC
=
null
;
private
static
String
strDataBTCe
=
null
;
private
static
String
strDataBFX
=
null
;
private
static
HashMap
<
String
,
Double
>
fxRatesLBC
=
null
;
private
static
HashMap
<
String
,
Double
>
fxRatesBTCe
=
null
;
private
static
HashMap
<
String
,
Double
>
fxRatesBFX
=
null
;
// private static HashMap<String,String> fxSymbols = null;
private
static
ExchangeRateFactory
instance
=
null
;
...
...
@@ -36,15 +33,8 @@ public class ExchangeRateFactory {
"Russian Rouble - RUB"
};
private
static
String
[]
currencyLabelsBTCe
=
{
"United States Dollar - USD"
,
"Euro - EUR"
,
"Russian Rouble - RUR"
};
private
static
String
[]
exchangeLabels
=
{
"LocalBitcoins.com"
,
"WEX (ex-'BTC-e')"
,
"Bitfinex"
,
};
...
...
@@ -56,9 +46,7 @@ public class ExchangeRateFactory {
if
(
instance
==
null
)
{
fxRatesLBC
=
new
HashMap
<
String
,
Double
>();
fxRatesBTCe
=
new
HashMap
<
String
,
Double
>();
fxRatesBFX
=
new
HashMap
<
String
,
Double
>();
// fxSymbols = new HashMap<String,String>();
instance
=
new
ExchangeRateFactory
();
}
...
...
@@ -69,10 +57,8 @@ public class ExchangeRateFactory {
public
double
getAvgPrice
(
String
currency
)
{
int
fxSel
=
PrefsUtil
.
getInstance
(
context
).
getValue
(
PrefsUtil
.
CURRENT_EXCHANGE_SEL
,
0
);
HashMap
<
String
,
Double
>
fxRates
=
null
;
if
(
fxSel
==
1
)
{
fxRates
=
fxRatesBTCe
;
}
else
if
(
fxSel
==
2
)
{
fxRates
=
fxRatesBFX
;
}
else
{
...
...
@@ -96,10 +82,6 @@ public class ExchangeRateFactory {
return
currencyLabels
;
}
public
String
[]
getCurrencyLabelsBTCe
()
{
return
currencyLabelsBTCe
;
}
public
String
[]
getExchangeLabels
()
{
return
exchangeLabels
;
}
...
...
@@ -108,10 +90,6 @@ public class ExchangeRateFactory {
strDataLBC
=
data
;
}
public
void
setDataBTCe
(
String
data
)
{
strDataBTCe
=
data
;
}
public
void
setDataBFX
(
String
data
)
{
strDataBFX
=
data
;
}
...
...
@@ -122,20 +100,6 @@ public class ExchangeRateFactory {
}
}
public
void
parseBTCe
()
{
for
(
int
i
=
0
;
i
<
currencies
.
length
;
i
++)
{
if
(
currencies
[
i
].
equals
(
"GBP"
)
||
currencies
[
i
].
equals
(
"CNY"
))
{
continue
;
}
if
(
currencies
[
i
].
equals
(
"RUB"
))
{
getBTCe
(
"RUR"
);
}
else
{
getBTCe
(
currencies
[
i
]);
}
}
}
public
void
parseBFX
()
{
for
(
int
i
=
0
;
i
<
currencies
.
length
;
i
++)
{
if
(
currencies
[
i
].
equals
(
"USD"
))
{
...
...
@@ -147,19 +111,6 @@ public class ExchangeRateFactory {
}
}
public
double
getBitfinexPrice
(
String
currency
)
{
HashMap
<
String
,
Double
>
fxRates
=
fxRatesBFX
;
if
(
fxRates
.
get
(
currency
)
!=
null
&&
fxRates
.
get
(
currency
)
>
0.0
)
{
PrefsUtil
.
getInstance
(
context
).
setValue
(
"CANNED_"
+
currency
,
Double
.
toString
(
fxRates
.
get
(
currency
)));
return
fxRates
.
get
(
currency
);
}
else
{
return
Double
.
parseDouble
(
PrefsUtil
.
getInstance
(
context
).
getValue
(
"CANNED_"
+
currency
,
"0.0"
));
}
}
private
void
getLBC
(
String
currency
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
strDataLBC
);
...
...
@@ -183,29 +134,6 @@ public class ExchangeRateFactory {
}
}
private
void
getBTCe
(
String
currency
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
strDataBTCe
);
if
(
jsonObject
!=
null
)
{
JSONObject
jsonCurr
=
jsonObject
.
getJSONObject
(
"btc_"
+
currency
.
toLowerCase
());
if
(
jsonCurr
!=
null
)
{
double
avg_price
=
0.0
;
if
(
jsonCurr
.
has
(
"avg"
))
{
avg_price
=
jsonCurr
.
getDouble
(
"avg"
);
}
if
(
currency
.
equals
(
"RUR"
))
{
fxRatesBTCe
.
put
(
"RUB"
,
Double
.
valueOf
(
avg_price
));
}
fxRatesBTCe
.
put
(
currency
,
Double
.
valueOf
(
avg_price
));
// Log.i("ExchangeRateFactory", "BTCe:" + currency + " " + Double.valueOf(avg_price));
}
}
}
catch
(
JSONException
je
)
{
fxRatesBTCe
.
put
(
currency
,
Double
.
valueOf
(-
1.0
));
// fxSymbols.put(currency, null);
}
}
private
void
getBFX
(
String
currency
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
strDataBFX
);
...
...
app/src/main/java/com/samourai/sentinel/util/WebUtil.java
View file @
68225a9f
...
...
@@ -60,9 +60,7 @@ public class WebUtil {
public
static
String
SAMOURAI_API2_TESTNET_TOR
=
SAMOURAI_API2_TESTNET_TOR_DIST
;
public
static
final
String
LBC_EXCHANGE_URL
=
"https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/"
;
public
static
final
String
BTCe_EXCHANGE_URL
=
"https://wex.nz/api/3/ticker/"
;
public
static
final
String
BFX_EXCHANGE_URL
=
"https://api.bitfinex.com/v1/pubticker/btcusd"
;
public
static
final
String
BITCOIND_FEE_URL
=
"https://api.samourai.io/v2/fees"
;
private
static
final
int
DefaultRequestRetry
=
2
;
private
static
final
int
DefaultRequestTimeout
=
60000
;
...
...
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