mirror of
https://github.com/m2049r/xmrwallet
synced 2025-09-12 07:10:49 +02:00
Compare commits
76 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
46dbc0659b | ||
![]() |
85622b3958 | ||
![]() |
5a63481c09 | ||
![]() |
1cb558d78e | ||
![]() |
942c80e38b | ||
![]() |
24ec848f0f | ||
![]() |
0d1b1da5f3 | ||
![]() |
0840d2f350 | ||
![]() |
c7d933ea9d | ||
![]() |
c9b1800309 | ||
![]() |
e7b0b5999e | ||
![]() |
47e1871693 | ||
![]() |
900eab70c8 | ||
![]() |
b11357f379 | ||
![]() |
eba0156a6d | ||
![]() |
bf64d8bd89 | ||
![]() |
2d74281b31 | ||
![]() |
668cefb357 | ||
![]() |
1f5061df38 | ||
![]() |
51445f5941 | ||
![]() |
8c01ec36e8 | ||
![]() |
3cf84c599d | ||
![]() |
ead8564688 | ||
![]() |
b71b3badd8 | ||
![]() |
5ad46e2f54 | ||
![]() |
9d6895b60f | ||
![]() |
a8755ee0da | ||
![]() |
f186bc9d4f | ||
![]() |
9cb961a368 | ||
![]() |
aa78541b6f | ||
![]() |
eba6a78004 | ||
![]() |
8587eab41c | ||
![]() |
4271c743c7 | ||
![]() |
5b60987692 | ||
![]() |
e1bd04c945 | ||
![]() |
ef29db62c4 | ||
![]() |
82ce12e27c | ||
![]() |
4211687981 | ||
![]() |
d398416a3d | ||
![]() |
1844d84be8 | ||
![]() |
5101b7da5e | ||
![]() |
3e90f2e22e | ||
![]() |
f01a8eac5d | ||
![]() |
0c13338dc0 | ||
![]() |
78d6fef3e4 | ||
![]() |
cbddcdc92d | ||
![]() |
4289aaac77 | ||
![]() |
fd15da9c84 | ||
![]() |
c3357087d5 | ||
![]() |
47e0bc86fd | ||
![]() |
dbd45ea4f5 | ||
![]() |
90c3e6ef8b | ||
![]() |
bc6a816462 | ||
![]() |
274a1a25f1 | ||
![]() |
9e3a2b102e | ||
![]() |
647ae9a565 | ||
![]() |
2bbd20855f | ||
![]() |
b8fc5f910a | ||
![]() |
01700cf780 | ||
![]() |
2fa6286b0e | ||
![]() |
0ac1680e75 | ||
![]() |
bd9a98e0d8 | ||
![]() |
8a5121e792 | ||
![]() |
5e6d3f3032 | ||
![]() |
65991ff554 | ||
![]() |
b0629e46e8 | ||
![]() |
45ec3198a0 | ||
![]() |
9b66c466f2 | ||
![]() |
d257e183ad | ||
![]() |
10d8e441fe | ||
![]() |
9f9bc4793d | ||
![]() |
8b28e3ea1e | ||
![]() |
e394394538 | ||
![]() |
7424ef07f7 | ||
![]() |
f5ce6ec824 | ||
![]() |
4215a8bf9e |
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -3,6 +3,7 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="disableWrapperSourceDistributionNotification" value="true" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
13
README.md
13
README.md
@@ -22,12 +22,8 @@ Help us translate Monerujo! You can find instructions [On Taiga](https://taiga.g
|
|||||||
You may lose all your Moneroj if you use this App. Be cautious when spending on the mainnet.
|
You may lose all your Moneroj if you use this App. Be cautious when spending on the mainnet.
|
||||||
|
|
||||||
### Random Notes
|
### Random Notes
|
||||||
- Based off monero v0.11.1.0
|
- works on the mainnet & stagenet
|
||||||
- currently only android32 (runs on 64-bit as well)
|
|
||||||
- works on the testnet & mainnet
|
|
||||||
- sync is slow due to 32-bit architecture
|
|
||||||
- use your own daemon - it's easy
|
- use your own daemon - it's easy
|
||||||
- screen stays on until first sync is complete
|
|
||||||
- Monerujo means "Monero Wallet" according to https://www.reddit.com/r/Monero/comments/3exy7t/esperanto_corner/
|
- Monerujo means "Monero Wallet" according to https://www.reddit.com/r/Monero/comments/3exy7t/esperanto_corner/
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
@@ -43,13 +39,8 @@ of the "real" testnet. After creating a new wallet, make a **new** one by recov
|
|||||||
The official monero client shows the same behaviour.
|
The official monero client shows the same behaviour.
|
||||||
|
|
||||||
### HOW TO BUILD
|
### HOW TO BUILD
|
||||||
No need to build. Binaries are included:
|
|
||||||
|
|
||||||
- openssl-1.0.2l
|
See [the instructions](doc/BUILDING-external-libs.md)
|
||||||
- monero-v0.12
|
|
||||||
- boost_1_58_0
|
|
||||||
|
|
||||||
If you want to build them yourself (recommended) check out [the instructions](doc/BUILDING-external-libs.md)
|
|
||||||
|
|
||||||
Then, fire up Android Studio and build the APK.
|
Then, fire up Android Studio and build the APK.
|
||||||
|
|
||||||
|
2
app/.gitignore
vendored
2
app/.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
build
|
build
|
||||||
app.iml
|
app.iml
|
||||||
|
prod
|
||||||
|
alpha
|
||||||
|
@@ -7,13 +7,21 @@ add_library( monerujo
|
|||||||
|
|
||||||
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../external-libs)
|
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../external-libs)
|
||||||
|
|
||||||
|
############
|
||||||
|
# libsodium
|
||||||
|
############
|
||||||
|
|
||||||
|
add_library(sodium STATIC IMPORTED)
|
||||||
|
set_target_properties(sodium PROPERTIES IMPORTED_LOCATION
|
||||||
|
${EXTERNAL_LIBS_DIR}/libsodium/lib/${ANDROID_ABI}/libsodium.a)
|
||||||
|
|
||||||
############
|
############
|
||||||
# OpenSSL
|
# OpenSSL
|
||||||
############
|
############
|
||||||
|
|
||||||
add_library(crypto STATIC IMPORTED)
|
add_library(crypto STATIC IMPORTED)
|
||||||
set_target_properties(crypto PROPERTIES IMPORTED_LOCATION
|
set_target_properties(crypto PROPERTIES IMPORTED_LOCATION
|
||||||
${EXTERNAL_LIBS_DIR}/openssl/lib/${ANDROID_ABI}/libcrypto.a)
|
${EXTERNAL_LIBS_DIR}/openssl/lib/${ANDROID_ABI}/libcrypto.a)
|
||||||
|
|
||||||
add_library(ssl STATIC IMPORTED)
|
add_library(ssl STATIC IMPORTED)
|
||||||
set_target_properties(ssl PROPERTIES IMPORTED_LOCATION
|
set_target_properties(ssl PROPERTIES IMPORTED_LOCATION
|
||||||
@@ -184,5 +192,7 @@ target_link_libraries( monerujo
|
|||||||
ssl
|
ssl
|
||||||
crypto
|
crypto
|
||||||
|
|
||||||
|
sodium
|
||||||
|
|
||||||
${log-lib}
|
${log-lib}
|
||||||
)
|
)
|
||||||
|
@@ -2,13 +2,14 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 27
|
||||||
buildToolsVersion '28.0.2'
|
buildToolsVersion '28.0.3'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.m2049r.xmrwallet"
|
applicationId "com.m2049r.xmrwallet"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 114
|
versionCode 140
|
||||||
versionName "1.6.4 'Nano S'"
|
versionName "1.9.0 'We Comin' Rougher'"
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
@@ -18,6 +19,16 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flavorDimensions "version"
|
||||||
|
productFlavors {
|
||||||
|
alpha {
|
||||||
|
applicationIdSuffix ".alpha"
|
||||||
|
versionNameSuffix " (alpha)"
|
||||||
|
}
|
||||||
|
prod {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
@@ -27,6 +38,7 @@ android {
|
|||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path "CMakeLists.txt"
|
path "CMakeLists.txt"
|
||||||
@@ -61,9 +73,13 @@ android {
|
|||||||
output ->
|
output ->
|
||||||
def abiName = output.getFilter(com.android.build.OutputFile.ABI)
|
def abiName = output.getFilter(com.android.build.OutputFile.ABI)
|
||||||
output.versionCodeOverride = abiCodes.get(abiName, 0) + 10 * variant.versionCode
|
output.versionCodeOverride = abiCodes.get(abiName, 0) + 10 * variant.versionCode
|
||||||
|
//def flavor = output.getFilter(flavor)
|
||||||
|
|
||||||
if (abiName == null) abiName = "universal"
|
if (abiName == null) abiName = "universal"
|
||||||
def v = "${variant.versionName}".replaceFirst(" .*\$", "").replace(".", "x")
|
def v = "${variant.versionName}".replaceFirst(" '.*' ?", "")
|
||||||
|
.replace(".", "x")
|
||||||
|
.replace("(", "-")
|
||||||
|
.replace(")", "")
|
||||||
outputFileName = "$rootProject.ext.apkName-" + v + "_" + abiName + ".apk"
|
outputFileName = "$rootProject.ext.apkName-" + v + "_" + abiName + ".apk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,6 +98,10 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.nulab-inc:zxcvbn:1.2.3'
|
implementation 'com.nulab-inc:zxcvbn:1.2.3'
|
||||||
|
|
||||||
|
implementation 'dnsjava:dnsjava:2.1.8'
|
||||||
|
implementation 'org.jitsi:dnssecjava:1.1.3'
|
||||||
|
implementation 'org.slf4j:slf4j-nop:1.7.25'
|
||||||
|
|
||||||
testImplementation "junit:junit:$rootProject.ext.junitVersion"
|
testImplementation "junit:junit:$rootProject.ext.junitVersion"
|
||||||
testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
|
testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
|
||||||
testImplementation "com.squareup.okhttp3:mockwebserver:$rootProject.ext.okHttpVersion"
|
testImplementation "com.squareup.okhttp3:mockwebserver:$rootProject.ext.okHttpVersion"
|
||||||
|
BIN
app/src/alpha/ic_launcher-web.png
Normal file
BIN
app/src/alpha/ic_launcher-web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
BIN
app/src/alpha/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
app/src/alpha/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
app/src/alpha/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
app/src/alpha/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/alpha/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
app/src/alpha/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
app/src/alpha/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/alpha/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
BIN
app/src/alpha/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
app/src/alpha/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
826
app/src/main/assets/licenses.html
Normal file
826
app/src/main/assets/licenses.html
Normal file
File diff suppressed because it is too large
Load Diff
88
app/src/main/cpp/device_io_monerujo.hpp
Normal file
88
app/src/main/cpp/device_io_monerujo.hpp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
// Copyright (c) 2017-2018, The Monero Project
|
||||||
|
//
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other
|
||||||
|
// materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||||
|
// used to endorse or promote products derived from this software without specific
|
||||||
|
// prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||||
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if defined(HAVE_MONERUJO)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LedgerFind - find Ledger Device and return it's name
|
||||||
|
* @param buffer - buffer for name of found device
|
||||||
|
* @param len - length of buffer
|
||||||
|
* @return 0 - success
|
||||||
|
* -1 - no device connected / found
|
||||||
|
* -2 - JVM not found
|
||||||
|
*/
|
||||||
|
int LedgerFind(char *buffer, size_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LedgerExchange - exchange data with Ledger Device
|
||||||
|
* @param command - buffer for data to send
|
||||||
|
* @param cmd_len - length of send to send
|
||||||
|
* @param response - buffer for received data
|
||||||
|
* @param max_resp_len - size of receive buffer
|
||||||
|
*
|
||||||
|
* @return length of received data in response or -1 if error
|
||||||
|
*/
|
||||||
|
int LedgerExchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "device_io.hpp"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace hw {
|
||||||
|
namespace io {
|
||||||
|
class device_io_monerujo: device_io {
|
||||||
|
public:
|
||||||
|
device_io_monerujo() {};
|
||||||
|
~device_io_monerujo() {};
|
||||||
|
|
||||||
|
void init() {};
|
||||||
|
void release() {};
|
||||||
|
|
||||||
|
void connect(void *params) {};
|
||||||
|
void disconnect() {};
|
||||||
|
bool connected() const {return true;}; // monerujo is always connected before it gets here
|
||||||
|
|
||||||
|
// returns number of bytes read or -1 on error
|
||||||
|
int exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len) {
|
||||||
|
return LedgerExchange(command, cmd_len, response, max_resp_len);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //#if defined(HAVE_MONERUJO)
|
@@ -416,17 +416,20 @@ Java_com_m2049r_xmrwallet_model_WalletManager_verifyWalletPassword(JNIEnv *env,
|
|||||||
|
|
||||||
//virtual int queryWalletHardware(const std::string &keys_file_name, const std::string &password) const = 0;
|
//virtual int queryWalletHardware(const std::string &keys_file_name, const std::string &password) const = 0;
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletHardware(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jobject instance,
|
||||||
jstring keys_file_name,
|
jstring keys_file_name,
|
||||||
jstring password) {
|
jstring password) {
|
||||||
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL);
|
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL);
|
||||||
const char *_password = env->GetStringUTFChars(password, NULL);
|
const char *_password = env->GetStringUTFChars(password, NULL);
|
||||||
int hardwareId =
|
Bitmonero::Wallet::Device device_type;
|
||||||
Bitmonero::WalletManagerFactory::getWalletManager()->
|
bool ok = Bitmonero::WalletManagerFactory::getWalletManager()->
|
||||||
queryWalletHardware(std::string(_keys_file_name), std::string(_password));
|
queryWalletDevice(device_type, std::string(_keys_file_name), std::string(_password));
|
||||||
env->ReleaseStringUTFChars(keys_file_name, _keys_file_name);
|
env->ReleaseStringUTFChars(keys_file_name, _keys_file_name);
|
||||||
env->ReleaseStringUTFChars(password, _password);
|
env->ReleaseStringUTFChars(password, _password);
|
||||||
return static_cast<jint>(hardwareId);
|
if (ok)
|
||||||
|
return static_cast<jint>(device_type);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
JNIEXPORT jobject JNICALL
|
||||||
@@ -686,7 +689,13 @@ Java_com_m2049r_xmrwallet_model_Wallet_initJ(JNIEnv *env, jobject instance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// virtual bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const = 0;
|
// virtual bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const = 0;
|
||||||
// virtual void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) = 0;
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_m2049r_xmrwallet_model_Wallet_setRestoreHeight(JNIEnv *env, jobject instance,
|
||||||
|
jlong height) {
|
||||||
|
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||||
|
wallet->setRefreshFromBlockHeight((uint64_t) height);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getRestoreHeight(JNIEnv *env, jobject instance) {
|
Java_com_m2049r_xmrwallet_model_Wallet_getRestoreHeight(JNIEnv *env, jobject instance) {
|
||||||
@@ -769,16 +778,16 @@ Java_com_m2049r_xmrwallet_model_Wallet_isSynchronized(JNIEnv *env, jobject insta
|
|||||||
return static_cast<jboolean>(wallet->synchronized());
|
return static_cast<jboolean>(wallet->synchronized());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_isKeyOnDevice(JNIEnv *env, jobject instance) {
|
Java_com_m2049r_xmrwallet_model_Wallet_getDeviceTypeJ(JNIEnv *env, jobject instance) {
|
||||||
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||||
bool key_on_device = wallet->isKeyOnDevice();
|
Bitmonero::Wallet::Device device_type = wallet->getDeviceType();
|
||||||
return static_cast<jboolean>(key_on_device);
|
return static_cast<jint>(device_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void cn_slow_hash(const void *data, size_t length, char *hash); // from crypto/hash-ops.h
|
//void cn_slow_hash(const void *data, size_t length, char *hash); // from crypto/hash-ops.h
|
||||||
JNIEXPORT jbyteArray JNICALL
|
JNIEXPORT jbyteArray JNICALL
|
||||||
Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jclass clazz,
|
||||||
jbyteArray data, jint brokenVariant) {
|
jbyteArray data, jint brokenVariant) {
|
||||||
char hash[HASH_SIZE];
|
char hash[HASH_SIZE];
|
||||||
jsize size = env->GetArrayLength(data);
|
jsize size = env->GetArrayLength(data);
|
||||||
@@ -804,13 +813,13 @@ Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jobject claz
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jclass clazz,
|
||||||
jlong amount) {
|
jlong amount) {
|
||||||
return env->NewStringUTF(Bitmonero::Wallet::displayAmount(amount).c_str());
|
return env->NewStringUTF(Bitmonero::Wallet::displayAmount(amount).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jclass clazz,
|
||||||
jstring amount) {
|
jstring amount) {
|
||||||
const char *_amount = env->GetStringUTFChars(amount, NULL);
|
const char *_amount = env->GetStringUTFChars(amount, NULL);
|
||||||
uint64_t x = Bitmonero::Wallet::amountFromString(_amount);
|
uint64_t x = Bitmonero::Wallet::amountFromString(_amount);
|
||||||
@@ -819,18 +828,18 @@ Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jobject
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromDouble(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromDouble(JNIEnv *env, jclass clazz,
|
||||||
jdouble amount) {
|
jdouble amount) {
|
||||||
return Bitmonero::Wallet::amountFromDouble(amount);
|
return Bitmonero::Wallet::amountFromDouble(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_generatePaymentId(JNIEnv *env, jobject clazz) {
|
Java_com_m2049r_xmrwallet_model_Wallet_generatePaymentId(JNIEnv *env, jclass clazz) {
|
||||||
return env->NewStringUTF(Bitmonero::Wallet::genPaymentId().c_str());
|
return env->NewStringUTF(Bitmonero::Wallet::genPaymentId().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass clazz,
|
||||||
jstring payment_id) {
|
jstring payment_id) {
|
||||||
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL);
|
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL);
|
||||||
bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id);
|
bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id);
|
||||||
@@ -839,7 +848,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jobject cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jclass clazz,
|
||||||
jstring address, jint networkType) {
|
jstring address, jint networkType) {
|
||||||
const char *_address = env->GetStringUTFChars(address, NULL);
|
const char *_address = env->GetStringUTFChars(address, NULL);
|
||||||
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
|
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
|
||||||
@@ -849,7 +858,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jobject clazz
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobject clazz,
|
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jclass clazz,
|
||||||
jstring address,
|
jstring address,
|
||||||
jint networkType) {
|
jint networkType) {
|
||||||
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
|
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
|
||||||
@@ -860,7 +869,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobj
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_Wallet_getMaximumAllowedAmount(JNIEnv *env, jobject clazz) {
|
Java_com_m2049r_xmrwallet_model_Wallet_getMaximumAllowedAmount(JNIEnv *env, jclass clazz) {
|
||||||
return Bitmonero::Wallet::maximumAllowedAmount();
|
return Bitmonero::Wallet::maximumAllowedAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1302,7 +1311,7 @@ Java_com_m2049r_xmrwallet_model_PendingTransaction_getTxCount(JNIEnv *env, jobje
|
|||||||
//static void warning(const std::string &category, const std::string &str);
|
//static void warning(const std::string &category, const std::string &str);
|
||||||
//static void error(const std::string &category, const std::string &str);
|
//static void error(const std::string &category, const std::string &str);
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jclass clazz,
|
||||||
jstring argv0,
|
jstring argv0,
|
||||||
jstring default_log_base_name) {
|
jstring default_log_base_name) {
|
||||||
|
|
||||||
@@ -1316,7 +1325,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jobject in
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jclass clazz,
|
||||||
jstring category, jstring message) {
|
jstring category, jstring message) {
|
||||||
|
|
||||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||||
@@ -1329,7 +1338,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jobject inst
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jclass clazz,
|
||||||
jstring category, jstring message) {
|
jstring category, jstring message) {
|
||||||
|
|
||||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||||
@@ -1342,7 +1351,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jobject insta
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jclass clazz,
|
||||||
jstring category, jstring message) {
|
jstring category, jstring message) {
|
||||||
|
|
||||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||||
@@ -1355,7 +1364,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jobject in
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jclass clazz,
|
||||||
jstring category, jstring message) {
|
jstring category, jstring message) {
|
||||||
|
|
||||||
const char *_category = env->GetStringUTFChars(category, NULL);
|
const char *_category = env->GetStringUTFChars(category, NULL);
|
||||||
@@ -1368,7 +1377,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jobject inst
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_m2049r_xmrwallet_model_WalletManager_setLogLevel(JNIEnv *env, jobject instance,
|
Java_com_m2049r_xmrwallet_model_WalletManager_setLogLevel(JNIEnv *env, jclass clazz,
|
||||||
jint level) {
|
jint level) {
|
||||||
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
Bitmonero::WalletManagerFactory::setLogLevel(level);
|
||||||
}
|
}
|
||||||
@@ -1377,24 +1386,22 @@ Java_com_m2049r_xmrwallet_model_WalletManager_setLogLevel(JNIEnv *env, jobject i
|
|||||||
// Ledger Stuff
|
// Ledger Stuff
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "monerujo_ledger.h"
|
#include "device_io_monerujo.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LedgerExchange - exchange data with Ledger Device
|
* @brief LedgerExchange - exchange data with Ledger Device
|
||||||
* @param pbSendBuffer - buffer for data to send
|
* @param command - buffer for data to send
|
||||||
* @param cbSendLength - length of send buffer
|
* @param cmd_len - length of send to send
|
||||||
* @param pbRecvBuffer - buffer for received data
|
* @param response - buffer for received data
|
||||||
* @param pcbRecvLength - pointer to size of receive buffer
|
* @param max_resp_len - size of receive buffer
|
||||||
* gets set with length of received data on successful return
|
*
|
||||||
* @return SCARD_S_SUCCESS - success
|
* @return length of received data in response or -1 if error
|
||||||
* SCARD_E_NO_READERS_AVAILABLE - no device connected / found
|
|
||||||
* SCARD_E_INSUFFICIENT_BUFFER - pbRecvBuffer is too small for the response
|
|
||||||
*/
|
*/
|
||||||
LONG LedgerExchange(
|
int LedgerExchange(
|
||||||
LPCBYTE pbSendBuffer,
|
unsigned char *command,
|
||||||
DWORD cbSendLength,
|
unsigned int cmd_len,
|
||||||
LPBYTE pbRecvBuffer,
|
unsigned char *response,
|
||||||
LPDWORD pcbRecvLength) {
|
unsigned int max_resp_len) {
|
||||||
LOGD("LedgerExchange");
|
LOGD("LedgerExchange");
|
||||||
JNIEnv *jenv;
|
JNIEnv *jenv;
|
||||||
int envStat = attachJVM(&jenv);
|
int envStat = attachJVM(&jenv);
|
||||||
@@ -1402,30 +1409,29 @@ LONG LedgerExchange(
|
|||||||
|
|
||||||
jmethodID exchangeMethod = jenv->GetStaticMethodID(class_Ledger, "Exchange", "([B)[B");
|
jmethodID exchangeMethod = jenv->GetStaticMethodID(class_Ledger, "Exchange", "([B)[B");
|
||||||
|
|
||||||
jsize sendLen = static_cast<jsize>(cbSendLength);
|
jsize sendLen = static_cast<jsize>(cmd_len);
|
||||||
jbyteArray dataSend = jenv->NewByteArray(sendLen);
|
jbyteArray dataSend = jenv->NewByteArray(sendLen);
|
||||||
jenv->SetByteArrayRegion(dataSend, 0, sendLen, (jbyte *) pbSendBuffer);
|
jenv->SetByteArrayRegion(dataSend, 0, sendLen, (jbyte *) command);
|
||||||
jbyteArray dataRecv = (jbyteArray) jenv->CallStaticObjectMethod(class_Ledger, exchangeMethod,
|
jbyteArray dataRecv = (jbyteArray) jenv->CallStaticObjectMethod(class_Ledger, exchangeMethod,
|
||||||
dataSend);
|
dataSend);
|
||||||
jenv->DeleteLocalRef(dataSend);
|
jenv->DeleteLocalRef(dataSend);
|
||||||
if (dataRecv == nullptr) {
|
if (dataRecv == nullptr) {
|
||||||
detachJVM(jenv, envStat);
|
detachJVM(jenv, envStat);
|
||||||
LOGD("LedgerExchange SCARD_E_NO_READERS_AVAILABLE");
|
LOGD("LedgerExchange SCARD_E_NO_READERS_AVAILABLE");
|
||||||
return SCARD_E_NO_READERS_AVAILABLE;
|
return -1;
|
||||||
}
|
}
|
||||||
jsize len = jenv->GetArrayLength(dataRecv);
|
jsize len = jenv->GetArrayLength(dataRecv);
|
||||||
LOGD("LedgerExchange SCARD_S_SUCCESS %ld/%d", cbSendLength, len);
|
LOGD("LedgerExchange SCARD_S_SUCCESS %ld/%d", cmd_len, len);
|
||||||
if (len <= *pcbRecvLength) {
|
if (len <= max_resp_len) {
|
||||||
*pcbRecvLength = static_cast<DWORD>(len);
|
jenv->GetByteArrayRegion(dataRecv, 0, len, (jbyte *) response);
|
||||||
jenv->GetByteArrayRegion(dataRecv, 0, len, (jbyte *) pbRecvBuffer);
|
|
||||||
jenv->DeleteLocalRef(dataRecv);
|
jenv->DeleteLocalRef(dataRecv);
|
||||||
detachJVM(jenv, envStat);
|
detachJVM(jenv, envStat);
|
||||||
return SCARD_S_SUCCESS;
|
return static_cast<int>(len);;
|
||||||
} else {
|
} else {
|
||||||
jenv->DeleteLocalRef(dataRecv);
|
jenv->DeleteLocalRef(dataRecv);
|
||||||
detachJVM(jenv, envStat);
|
detachJVM(jenv, envStat);
|
||||||
LOGE("LedgerExchange SCARD_E_INSUFFICIENT_BUFFER");
|
LOGE("LedgerExchange SCARD_E_INSUFFICIENT_BUFFER");
|
||||||
return SCARD_E_INSUFFICIENT_BUFFER;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2018 m2049r
|
|
||||||
* <p>
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* <p>
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* <p>
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef XMRWALLET_LEDGER_H
|
|
||||||
#define XMRWALLET_LEDGER_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SCARD_S_SUCCESS ((LONG)0x00000000) /**< No error was encountered. */
|
|
||||||
#define SCARD_E_INSUFFICIENT_BUFFER ((LONG)0x80100008) /**< The data buffer to receive returned data is too small for the returned data. */
|
|
||||||
#define SCARD_E_NO_READERS_AVAILABLE ((LONG)0x8010002E) /**< Cannot find a smart card reader. */
|
|
||||||
|
|
||||||
typedef long LONG;
|
|
||||||
typedef unsigned long DWORD;
|
|
||||||
typedef DWORD *LPDWORD;
|
|
||||||
typedef unsigned char BYTE;
|
|
||||||
typedef BYTE *LPBYTE;
|
|
||||||
typedef const BYTE *LPCBYTE;
|
|
||||||
|
|
||||||
typedef char CHAR;
|
|
||||||
typedef CHAR *LPSTR;
|
|
||||||
|
|
||||||
int LedgerFind(char *buffer, size_t len);
|
|
||||||
LONG LedgerExchange(LPCBYTE pbSendBuffer, DWORD cbSendLength, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //XMRWALLET_LEDGER_H
|
|
@@ -145,7 +145,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
|
|
||||||
etWalletName.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletName.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkName()) {
|
if (checkName()) {
|
||||||
etWalletPassword.requestFocus();
|
etWalletPassword.requestFocus();
|
||||||
} // otherwise ignore
|
} // otherwise ignore
|
||||||
@@ -183,7 +184,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
generateWallet();
|
generateWallet();
|
||||||
return true;
|
return true;
|
||||||
@@ -195,7 +197,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
etWalletRestoreHeight.requestFocus();
|
etWalletRestoreHeight.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -205,7 +208,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
} else if (type.equals(TYPE_SEED)) {
|
} else if (type.equals(TYPE_SEED)) {
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
etWalletMnemonic.requestFocus();
|
etWalletMnemonic.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -215,7 +219,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
etWalletMnemonic.setVisibility(View.VISIBLE);
|
etWalletMnemonic.setVisibility(View.VISIBLE);
|
||||||
etWalletMnemonic.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletMnemonic.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkMnemonic()) {
|
if (checkMnemonic()) {
|
||||||
etWalletRestoreHeight.requestFocus();
|
etWalletRestoreHeight.requestFocus();
|
||||||
}
|
}
|
||||||
@@ -227,7 +232,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
} else if (type.equals(TYPE_KEY) || type.equals(TYPE_VIEWONLY)) {
|
} else if (type.equals(TYPE_KEY) || type.equals(TYPE_VIEWONLY)) {
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
etWalletAddress.requestFocus();
|
etWalletAddress.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -239,7 +245,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
|
|
||||||
{
|
{
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkAddress()) {
|
if (checkAddress()) {
|
||||||
etWalletViewKey.requestFocus();
|
etWalletViewKey.requestFocus();
|
||||||
}
|
}
|
||||||
@@ -251,7 +258,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
etWalletViewKey.setVisibility(View.VISIBLE);
|
etWalletViewKey.setVisibility(View.VISIBLE);
|
||||||
etWalletViewKey.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletViewKey.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkViewKey()) {
|
if (checkViewKey()) {
|
||||||
if (type.equals(TYPE_KEY)) {
|
if (type.equals(TYPE_KEY)) {
|
||||||
etWalletSpendKey.requestFocus();
|
etWalletSpendKey.requestFocus();
|
||||||
@@ -271,7 +279,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
|
|
||||||
{
|
{
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkSpendKey()) {
|
if (checkSpendKey()) {
|
||||||
etWalletRestoreHeight.requestFocus();
|
etWalletRestoreHeight.requestFocus();
|
||||||
}
|
}
|
||||||
@@ -285,7 +294,8 @@ public class GenerateFragment extends Fragment {
|
|||||||
etWalletRestoreHeight.setVisibility(View.VISIBLE);
|
etWalletRestoreHeight.setVisibility(View.VISIBLE);
|
||||||
etWalletRestoreHeight.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletRestoreHeight.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
generateWallet();
|
generateWallet();
|
||||||
return true;
|
return true;
|
||||||
|
@@ -200,7 +200,8 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
showProgress();
|
showProgress();
|
||||||
if ((walletPath != null)
|
if ((walletPath != null)
|
||||||
&& (WalletManager.getInstance().queryWalletHardware(walletPath + ".keys", getPassword()) == 1)
|
&& (WalletManager.getInstance().queryWalletDevice(walletPath + ".keys", getPassword())
|
||||||
|
== Wallet.Device.Device_Ledger)
|
||||||
&& (progressCallback != null)) {
|
&& (progressCallback != null)) {
|
||||||
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
||||||
dialogOpened = true;
|
dialogOpened = true;
|
||||||
@@ -231,10 +232,15 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
|
|
||||||
address = wallet.getAddress();
|
address = wallet.getAddress();
|
||||||
seed = wallet.getSeed();
|
seed = wallet.getSeed();
|
||||||
if (wallet.isKeyOnDevice()) {
|
switch (wallet.getDeviceType()) {
|
||||||
viewKey = Ledger.Key();
|
case Device_Ledger:
|
||||||
} else {
|
viewKey = Ledger.Key();
|
||||||
viewKey = wallet.getSecretViewKey();
|
break;
|
||||||
|
case Device_Software:
|
||||||
|
viewKey = wallet.getSecretViewKey();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Hardware backing not supported. At all!");
|
||||||
}
|
}
|
||||||
spendKey = isWatchOnly ? getActivity().getString(R.string.label_watchonly) : wallet.getSecretSpendKey();
|
spendKey = isWatchOnly ? getActivity().getString(R.string.label_watchonly) : wallet.getSecretSpendKey();
|
||||||
isWatchOnly = wallet.isWatchOnly();
|
isWatchOnly = wallet.isWatchOnly();
|
||||||
@@ -594,7 +600,8 @@ public class GenerateReviewFragment extends Fragment {
|
|||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etPasswordB.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPasswordB.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
String newPasswordA = etPasswordA.getEditText().getText().toString();
|
String newPasswordA = etPasswordA.getEditText().getText().toString();
|
||||||
String newPasswordB = etPasswordB.getEditText().getText().toString();
|
String newPasswordB = etPasswordB.getEditText().getText().toString();
|
||||||
// disallow empty passwords
|
// disallow empty passwords
|
||||||
|
@@ -326,7 +326,8 @@ public class LoginActivity extends BaseActivity
|
|||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etRename.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etRename.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
Helper.hideKeyboardAlways(LoginActivity.this);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
String newName = etRename.getText().toString();
|
String newName = etRename.getText().toString();
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
@@ -1170,18 +1171,27 @@ public class LoginActivity extends BaseActivity
|
|||||||
String keyPath = new File(Helper.getWalletRoot(LoginActivity.this),
|
String keyPath = new File(Helper.getWalletRoot(LoginActivity.this),
|
||||||
walletName + ".keys").getAbsolutePath();
|
walletName + ".keys").getAbsolutePath();
|
||||||
// check if we need connected hardware
|
// check if we need connected hardware
|
||||||
int hw = WalletManager.getInstance().queryWalletHardware(keyPath, password);
|
Wallet.Device device =
|
||||||
if ((hw == 1) && (!hasLedger())) {
|
WalletManager.getInstance().queryWalletDevice(keyPath, password);
|
||||||
toast(R.string.open_wallet_ledger_missing);
|
switch (device) {
|
||||||
} else {
|
case Device_Ledger:
|
||||||
// hw could be < 0 meaning the password is wrong - this gets dealt with later
|
if (!hasLedger()) {
|
||||||
startWallet(walletName, password, fingerprintUsed);
|
toast(R.string.open_wallet_ledger_missing);
|
||||||
|
} else {
|
||||||
|
startWallet(walletName, password, fingerprintUsed);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// device could be undefined meaning the password is wrong
|
||||||
|
// this gets dealt with later
|
||||||
|
startWallet(walletName, password, fingerprintUsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else { // this cannot really happen as we prefilter choices
|
} else { // this cannot really happen as we prefilter choices
|
||||||
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// USB Stuff - (Ledger)
|
// USB Stuff - (Ledger)
|
||||||
|
@@ -206,7 +206,8 @@ public class LoginFragment extends Fragment implements WalletInfoAdapter.OnInter
|
|||||||
|
|
||||||
etDaemonAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etDaemonAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
etDummy.requestFocus();
|
etDummy.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
|
@@ -20,7 +20,6 @@ import android.content.Context;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.nfc.NfcAdapter;
|
|
||||||
import android.nfc.NfcManager;
|
import android.nfc.NfcManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -67,9 +66,8 @@ public class ReceiveFragment extends Fragment {
|
|||||||
private ProgressBar pbProgress;
|
private ProgressBar pbProgress;
|
||||||
private TextView tvAddressLabel;
|
private TextView tvAddressLabel;
|
||||||
private TextView tvAddress;
|
private TextView tvAddress;
|
||||||
private TextInputLayout etPaymentId;
|
private TextInputLayout etNotes;
|
||||||
private ExchangeView evAmount;
|
private ExchangeView evAmount;
|
||||||
private Button bPaymentId;
|
|
||||||
private TextView tvQrCode;
|
private TextView tvQrCode;
|
||||||
private ImageView qrCode;
|
private ImageView qrCode;
|
||||||
private ImageView qrCodeFull;
|
private ImageView qrCodeFull;
|
||||||
@@ -97,9 +95,8 @@ public class ReceiveFragment extends Fragment {
|
|||||||
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
|
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
|
||||||
tvAddressLabel = (TextView) view.findViewById(R.id.tvAddressLabel);
|
tvAddressLabel = (TextView) view.findViewById(R.id.tvAddressLabel);
|
||||||
tvAddress = (TextView) view.findViewById(R.id.tvAddress);
|
tvAddress = (TextView) view.findViewById(R.id.tvAddress);
|
||||||
etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId);
|
etNotes = (TextInputLayout) view.findViewById(R.id.etNotes);
|
||||||
evAmount = (ExchangeView) view.findViewById(R.id.evAmount);
|
evAmount = (ExchangeView) view.findViewById(R.id.evAmount);
|
||||||
bPaymentId = (Button) view.findViewById(R.id.bPaymentId);
|
|
||||||
qrCode = (ImageView) view.findViewById(R.id.qrCode);
|
qrCode = (ImageView) view.findViewById(R.id.qrCode);
|
||||||
tvQrCode = (TextView) view.findViewById(R.id.tvQrCode);
|
tvQrCode = (TextView) view.findViewById(R.id.tvQrCode);
|
||||||
qrCodeFull = (ImageView) view.findViewById(R.id.qrCodeFull);
|
qrCodeFull = (ImageView) view.findViewById(R.id.qrCodeFull);
|
||||||
@@ -107,7 +104,6 @@ public class ReceiveFragment extends Fragment {
|
|||||||
bCopyAddress = (ImageButton) view.findViewById(R.id.bCopyAddress);
|
bCopyAddress = (ImageButton) view.findViewById(R.id.bCopyAddress);
|
||||||
bSubaddress = (Button) view.findViewById(R.id.bSubaddress);
|
bSubaddress = (Button) view.findViewById(R.id.bSubaddress);
|
||||||
|
|
||||||
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
|
||||||
etDummy.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etDummy.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
|
|
||||||
bCopyAddress.setOnClickListener(new View.OnClickListener() {
|
bCopyAddress.setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -136,39 +132,32 @@ public class ReceiveFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
final EditText notesEdit = etNotes.getEditText();
|
||||||
|
notesEdit.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
notesEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
if (checkPaymentId()) { // && evAmount.checkXmrAmount(true)) {
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
generateQr();
|
generateQr();
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
etPaymentId.getEditText().addTextChangedListener(new TextWatcher() {
|
notesEdit.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable editable) {
|
|
||||||
clearQR();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
clearQR();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
bPaymentId.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void afterTextChanged(Editable s) {
|
||||||
etPaymentId.getEditText().setText((Wallet.generatePaymentId()));
|
|
||||||
etPaymentId.getEditText().setSelection(etPaymentId.getEditText().getText().length());
|
|
||||||
if (checkPaymentId()) { //&& evAmount.checkXmrAmount(true)) {
|
|
||||||
generateQr();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -192,10 +181,12 @@ public class ReceiveFragment extends Fragment {
|
|||||||
qrCode.setOnClickListener(new View.OnClickListener() {
|
qrCode.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
etDummy.requestFocus();
|
||||||
if (qrValid) {
|
if (qrValid) {
|
||||||
qrCodeFull.setImageBitmap(((BitmapDrawable) qrCode.getDrawable()).getBitmap());
|
qrCodeFull.setImageBitmap(((BitmapDrawable) qrCode.getDrawable()).getBitmap());
|
||||||
qrCodeFull.setVisibility(View.VISIBLE);
|
qrCodeFull.setVisibility(View.VISIBLE);
|
||||||
} else if (checkPaymentId()) {
|
} else {
|
||||||
evAmount.doExchange();
|
evAmount.doExchange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,8 +283,6 @@ public class ReceiveFragment extends Fragment {
|
|||||||
listenerCallback.setTitle(wallet.getName());
|
listenerCallback.setTitle(wallet.getName());
|
||||||
listenerCallback.setSubtitle(wallet.getAccountLabel());
|
listenerCallback.setSubtitle(wallet.getAccountLabel());
|
||||||
tvAddress.setText(wallet.getAddress());
|
tvAddress.setText(wallet.getAddress());
|
||||||
etPaymentId.setEnabled(true);
|
|
||||||
bPaymentId.setEnabled(true);
|
|
||||||
enableCopyAddress(true);
|
enableCopyAddress(true);
|
||||||
hideProgress();
|
hideProgress();
|
||||||
generateQr();
|
generateQr();
|
||||||
@@ -331,7 +320,8 @@ public class ReceiveFragment extends Fragment {
|
|||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
showProgress();
|
showProgress();
|
||||||
if ((walletPath != null)
|
if ((walletPath != null)
|
||||||
&& (WalletManager.getInstance().queryWalletHardware(walletPath + ".keys", password) == 1)
|
&& (WalletManager.getInstance().queryWalletDevice(walletPath + ".keys", password)
|
||||||
|
== Wallet.Device.Device_Ledger)
|
||||||
&& (progressCallback != null)) {
|
&& (progressCallback != null)) {
|
||||||
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
||||||
dialogOpened = true;
|
dialogOpened = true;
|
||||||
@@ -381,18 +371,6 @@ public class ReceiveFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkPaymentId() {
|
|
||||||
String paymentId = etPaymentId.getEditText().getText().toString();
|
|
||||||
boolean ok = paymentId.isEmpty() || Wallet.isPaymentIdValid(paymentId);
|
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
etPaymentId.setError(getString(R.string.receive_paymentid_invalid));
|
|
||||||
} else {
|
|
||||||
etPaymentId.setError(null);
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BarcodeData getBarcodeData() {
|
public BarcodeData getBarcodeData() {
|
||||||
if (qrValid)
|
if (qrValid)
|
||||||
return bcData;
|
return bcData;
|
||||||
@@ -405,15 +383,15 @@ public class ReceiveFragment extends Fragment {
|
|||||||
private void generateQr() {
|
private void generateQr() {
|
||||||
Timber.d("GENQR");
|
Timber.d("GENQR");
|
||||||
String address = tvAddress.getText().toString();
|
String address = tvAddress.getText().toString();
|
||||||
String paymentId = etPaymentId.getEditText().getText().toString();
|
String notes = etNotes.getEditText().getText().toString();
|
||||||
String xmrAmount = evAmount.getAmount();
|
String xmrAmount = evAmount.getAmount();
|
||||||
Timber.d("%s/%s/%s", xmrAmount, paymentId, address);
|
Timber.d("%s/%s/%s", xmrAmount, notes, address);
|
||||||
if ((xmrAmount == null) || !Wallet.isAddressValid(address)) {
|
if ((xmrAmount == null) || !Wallet.isAddressValid(address)) {
|
||||||
clearQR();
|
clearQR();
|
||||||
Timber.d("CLEARQR");
|
Timber.d("CLEARQR");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bcData = new BarcodeData(BarcodeData.Asset.XMR, address, paymentId, xmrAmount);
|
bcData = new BarcodeData(BarcodeData.Asset.XMR, address, null, notes, xmrAmount);
|
||||||
int size = Math.min(qrCode.getHeight(), qrCode.getWidth());
|
int size = Math.min(qrCode.getHeight(), qrCode.getWidth());
|
||||||
Bitmap qr = generate(bcData.getUriString(), size, size);
|
Bitmap qr = generate(bcData.getUriString(), size, size);
|
||||||
if (qr != null) {
|
if (qr != null) {
|
||||||
@@ -536,7 +514,7 @@ public class ReceiveFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
if (wallet.isKeyOnDevice() && (progressCallback != null)) {
|
if ((wallet.getDeviceType() == Wallet.Device.Device_Ledger) && (progressCallback != null)) {
|
||||||
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_SUBADDRESS);
|
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_SUBADDRESS);
|
||||||
dialogOpened = true;
|
dialogOpened = true;
|
||||||
}
|
}
|
||||||
|
@@ -90,6 +90,8 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
private long streetMode = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPasswordChanged(String newPassword) {
|
public void onPasswordChanged(String newPassword) {
|
||||||
password = newPassword;
|
password = newPassword;
|
||||||
@@ -128,6 +130,27 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
return synced;
|
return synced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStreetMode() {
|
||||||
|
return streetMode > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleStreetMode() {
|
||||||
|
if (streetMode == 0) {
|
||||||
|
streetMode = getWallet().getDaemonBlockChainHeight();
|
||||||
|
} else {
|
||||||
|
streetMode = 0;
|
||||||
|
}
|
||||||
|
Timber.e("streetMode=" + streetMode);
|
||||||
|
updateAccountsBalance();
|
||||||
|
forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getStreetModeHeight() {
|
||||||
|
return streetMode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWatchOnly() {
|
public boolean isWatchOnly() {
|
||||||
return getWallet().isWatchOnly();
|
return getWallet().isWatchOnly();
|
||||||
@@ -195,7 +218,14 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
MenuItem renameItem = menu.findItem(R.id.action_rename);
|
MenuItem renameItem = menu.findItem(R.id.action_rename);
|
||||||
if (renameItem != null)
|
if (renameItem != null)
|
||||||
renameItem.setVisible(hasWallet() && getWallet().isSynchronized());
|
renameItem.setVisible(hasWallet() && getWallet().isSynchronized());
|
||||||
return true;
|
MenuItem streetmodeItem = menu.findItem(R.id.action_streetmode);
|
||||||
|
if (streetmodeItem != null)
|
||||||
|
if (isStreetMode()) {
|
||||||
|
streetmodeItem.setIcon(R.drawable.gunther_csi_24dp);
|
||||||
|
} else {
|
||||||
|
streetmodeItem.setIcon(R.drawable.gunther_24dp);
|
||||||
|
}
|
||||||
|
return super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -228,6 +258,15 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
case R.id.action_rename:
|
case R.id.action_rename:
|
||||||
onAccountRename();
|
onAccountRename();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_streetmode:
|
||||||
|
toggleStreetMode();
|
||||||
|
if (isStreetMode()) {
|
||||||
|
toolbar.setBackgroundResource(R.drawable.backgound_toolbar_streetmode);
|
||||||
|
} else {
|
||||||
|
showNet();
|
||||||
|
}
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@@ -273,6 +312,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
break;
|
break;
|
||||||
case Toolbar.BUTTON_CANCEL:
|
case Toolbar.BUTTON_CANCEL:
|
||||||
onDisposeRequest();
|
onDisposeRequest();
|
||||||
|
Helper.hideKeyboard(WalletActivity.this);
|
||||||
WalletActivity.super.onBackPressed();
|
WalletActivity.super.onBackPressed();
|
||||||
break;
|
break;
|
||||||
case Toolbar.BUTTON_CLOSE:
|
case Toolbar.BUTTON_CLOSE:
|
||||||
@@ -323,6 +363,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Wallet getWallet() {
|
public Wallet getWallet() {
|
||||||
if (mBoundService == null) throw new IllegalStateException("WalletService not bound.");
|
if (mBoundService == null) throw new IllegalStateException("WalletService not bound.");
|
||||||
return mBoundService.getWallet();
|
return mBoundService.getWallet();
|
||||||
@@ -460,6 +501,11 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
@Override
|
@Override
|
||||||
public boolean onRefreshed(final Wallet wallet, final boolean full) {
|
public boolean onRefreshed(final Wallet wallet, final boolean full) {
|
||||||
Timber.d("onRefreshed()");
|
Timber.d("onRefreshed()");
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
updateAccountsBalance();
|
||||||
|
}
|
||||||
|
});
|
||||||
if (numAccounts != wallet.getNumAccounts()) {
|
if (numAccounts != wallet.getNumAccounts()) {
|
||||||
numAccounts = wallet.getNumAccounts();
|
numAccounts = wallet.getNumAccounts();
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@@ -515,26 +561,35 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
boolean haveWallet = false;
|
boolean haveWallet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletOpen(final int hardware) {
|
public void onWalletOpen(final Wallet.Device device) {
|
||||||
if (hardware > 0)
|
switch (device) {
|
||||||
runOnUiThread(new Runnable() {
|
case Device_Ledger:
|
||||||
public void run() {
|
runOnUiThread(new Runnable() {
|
||||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
public void run() {
|
||||||
}
|
showLedgerProgressDialog(LedgerProgressDialog.TYPE_RESTORE);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletStarted(final boolean success) {
|
public void onWalletStarted(final Wallet.ConnectionStatus connStatus) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
dismissProgressDialog();
|
dismissProgressDialog();
|
||||||
if (!success) {
|
switch (connStatus) {
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_failed), Toast.LENGTH_LONG).show();
|
case ConnectionStatus_Disconnected:
|
||||||
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_failed), Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
case ConnectionStatus_WrongVersion:
|
||||||
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_connect_wrongversion), Toast.LENGTH_LONG).show();
|
||||||
|
break;
|
||||||
|
case ConnectionStatus_Connected:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!success) {
|
if (connStatus != Wallet.ConnectionStatus.ConnectionStatus_Connected) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
haveWallet = true;
|
haveWallet = true;
|
||||||
@@ -544,6 +599,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
updateAccountsHeader();
|
||||||
if (walletFragment != null) {
|
if (walletFragment != null) {
|
||||||
walletFragment.onLoaded();
|
walletFragment.onLoaded();
|
||||||
}
|
}
|
||||||
@@ -715,7 +771,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
intent.putExtra(WalletService.REQUEST_CMD_TX_TAG, tag);
|
intent.putExtra(WalletService.REQUEST_CMD_TX_TAG, tag);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
Timber.d("CREATE TX request sent");
|
Timber.d("CREATE TX request sent");
|
||||||
if (getWallet().isKeyOnDevice())
|
if (getWallet().getDeviceType() == Wallet.Device.Device_Ledger)
|
||||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_SEND);
|
showLedgerProgressDialog(LedgerProgressDialog.TYPE_SEND);
|
||||||
} else {
|
} else {
|
||||||
Timber.e("Service not bound");
|
Timber.e("Service not bound");
|
||||||
@@ -920,7 +976,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||||
if (fragment instanceof OnBackPressedListener) {
|
if (fragment instanceof OnBackPressedListener) {
|
||||||
if (!((OnBackPressedListener) fragment).onBackPressed()) {
|
if (!((OnBackPressedListener) fragment).onBackPressed()) {
|
||||||
@@ -953,13 +1008,25 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
}
|
}
|
||||||
|
|
||||||
// drawer stuff
|
// drawer stuff
|
||||||
void updateAccountsList() {
|
|
||||||
|
void updateAccountsBalance() {
|
||||||
|
final TextView tvBalance = accountsView.getHeaderView(0).findViewById(R.id.tvBalance);
|
||||||
|
if (!isStreetMode()) {
|
||||||
|
tvBalance.setText(getString(R.string.accounts_balance,
|
||||||
|
Helper.getDisplayAmount(getWallet().getBalanceAll(), 5)));
|
||||||
|
} else {
|
||||||
|
tvBalance.setText(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateAccountsHeader() {
|
||||||
final Wallet wallet = getWallet();
|
final Wallet wallet = getWallet();
|
||||||
final TextView tvName = (TextView) accountsView.getHeaderView(0).findViewById(R.id.tvName);
|
final TextView tvName = (TextView) accountsView.getHeaderView(0).findViewById(R.id.tvName);
|
||||||
tvName.setText(wallet.getName());
|
tvName.setText(wallet.getName());
|
||||||
final TextView tvBalance = (TextView) accountsView.getHeaderView(0).findViewById(R.id.tvBalance);
|
}
|
||||||
tvBalance.setText(getString(R.string.accounts_balance,
|
|
||||||
Helper.getDisplayAmount(wallet.getBalanceAll(), 5)));
|
void updateAccountsList() {
|
||||||
|
final Wallet wallet = getWallet();
|
||||||
Menu menu = accountsView.getMenu();
|
Menu menu = accountsView.getMenu();
|
||||||
menu.removeGroup(R.id.accounts_list);
|
menu.removeGroup(R.id.accounts_list);
|
||||||
final int n = wallet.getNumAccounts();
|
final int n = wallet.getNumAccounts();
|
||||||
@@ -1026,7 +1093,8 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etRename.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etRename.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
Helper.hideKeyboardAlways(WalletActivity.this);
|
Helper.hideKeyboardAlways(WalletActivity.this);
|
||||||
String newName = etRename.getText().toString();
|
String newName = etRename.getText().toString();
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
@@ -1071,12 +1139,17 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
if (getWallet().isKeyOnDevice()) {
|
switch (getWallet().getDeviceType()) {
|
||||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_ACCOUNT);
|
case Device_Ledger:
|
||||||
dialogOpened = true;
|
showLedgerProgressDialog(LedgerProgressDialog.TYPE_ACCOUNT);
|
||||||
} else {
|
dialogOpened = true;
|
||||||
showProgressDialog(R.string.accounts_progress_new);
|
break;
|
||||||
dialogOpened = true;
|
case Device_Software:
|
||||||
|
showProgressDialog(R.string.accounts_progress_new);
|
||||||
|
dialogOpened = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Hardware backing not supported. At all!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,4 +1173,16 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void invalidateOptionsMenu() {
|
||||||
|
// super.invalidateOptionsMenu();
|
||||||
|
// if (isStreetMode()) {
|
||||||
|
// item.setIcon(R.drawable.gunther_csi_24dp);
|
||||||
|
// toolbar.setBackgroundResource(R.drawable.backgound_toolbar_streetmode);
|
||||||
|
// } else {
|
||||||
|
// item.setIcon(R.drawable.gunther_24dp);
|
||||||
|
// showNet();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -47,7 +48,10 @@ import com.m2049r.xmrwallet.util.Helper;
|
|||||||
import com.m2049r.xmrwallet.widget.Toolbar;
|
import com.m2049r.xmrwallet.widget.Toolbar;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
@@ -56,6 +60,8 @@ public class WalletFragment extends Fragment
|
|||||||
private TransactionInfoAdapter adapter;
|
private TransactionInfoAdapter adapter;
|
||||||
private NumberFormat formatter = NumberFormat.getInstance();
|
private NumberFormat formatter = NumberFormat.getInstance();
|
||||||
|
|
||||||
|
private TextView tvStreetView;
|
||||||
|
private LinearLayout llBalance;
|
||||||
private FrameLayout flExchange;
|
private FrameLayout flExchange;
|
||||||
private TextView tvBalance;
|
private TextView tvBalance;
|
||||||
private TextView tvUnconfirmedAmount;
|
private TextView tvUnconfirmedAmount;
|
||||||
@@ -85,28 +91,30 @@ public class WalletFragment extends Fragment
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_wallet, container, false);
|
View view = inflater.inflate(R.layout.fragment_wallet, container, false);
|
||||||
|
|
||||||
flExchange = (FrameLayout) view.findViewById(R.id.flExchange);
|
tvStreetView = view.findViewById(R.id.tvStreetView);
|
||||||
|
llBalance = view.findViewById(R.id.llBalance);
|
||||||
|
flExchange = view.findViewById(R.id.flExchange);
|
||||||
((ProgressBar) view.findViewById(R.id.pbExchange)).getIndeterminateDrawable().
|
((ProgressBar) view.findViewById(R.id.pbExchange)).getIndeterminateDrawable().
|
||||||
setColorFilter(getResources().getColor(R.color.trafficGray),
|
setColorFilter(getResources().getColor(R.color.trafficGray),
|
||||||
android.graphics.PorterDuff.Mode.MULTIPLY);
|
android.graphics.PorterDuff.Mode.MULTIPLY);
|
||||||
|
|
||||||
tvProgress = (TextView) view.findViewById(R.id.tvProgress);
|
tvProgress = view.findViewById(R.id.tvProgress);
|
||||||
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
|
pbProgress = view.findViewById(R.id.pbProgress);
|
||||||
tvBalance = (TextView) view.findViewById(R.id.tvBalance);
|
tvBalance = view.findViewById(R.id.tvBalance);
|
||||||
tvBalance.setText(Helper.getDisplayAmount(0));
|
showBalance(Helper.getDisplayAmount(0));
|
||||||
tvUnconfirmedAmount = (TextView) view.findViewById(R.id.tvUnconfirmedAmount);
|
tvUnconfirmedAmount = view.findViewById(R.id.tvUnconfirmedAmount);
|
||||||
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, Helper.getDisplayAmount(0)));
|
showUnconfirmed(0);
|
||||||
ivSynced = (ImageView) view.findViewById(R.id.ivSynced);
|
ivSynced = view.findViewById(R.id.ivSynced);
|
||||||
|
|
||||||
sCurrency = (Spinner) view.findViewById(R.id.sCurrency);
|
sCurrency = view.findViewById(R.id.sCurrency);
|
||||||
ArrayAdapter currencyAdapter = ArrayAdapter.createFromResource(getContext(), R.array.currency, R.layout.item_spinner_balance);
|
ArrayAdapter currencyAdapter = ArrayAdapter.createFromResource(getContext(), R.array.currency, R.layout.item_spinner_balance);
|
||||||
currencyAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown_item);
|
currencyAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown_item);
|
||||||
sCurrency.setAdapter(currencyAdapter);
|
sCurrency.setAdapter(currencyAdapter);
|
||||||
|
|
||||||
bSend = (Button) view.findViewById(R.id.bSend);
|
bSend = view.findViewById(R.id.bSend);
|
||||||
bReceive = (Button) view.findViewById(R.id.bReceive);
|
bReceive = view.findViewById(R.id.bReceive);
|
||||||
|
|
||||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
|
RecyclerView recyclerView = view.findViewById(R.id.list);
|
||||||
|
|
||||||
this.adapter = new TransactionInfoAdapter(getActivity(), this);
|
this.adapter = new TransactionInfoAdapter(getActivity(), this);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
@@ -145,6 +153,26 @@ public class WalletFragment extends Fragment
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showBalance(String balance) {
|
||||||
|
tvBalance.setText(balance);
|
||||||
|
if (!activityCallback.isStreetMode()) {
|
||||||
|
llBalance.setVisibility(View.VISIBLE);
|
||||||
|
tvStreetView.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
llBalance.setVisibility(View.INVISIBLE);
|
||||||
|
tvStreetView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showUnconfirmed(double unconfirmedAmount) {
|
||||||
|
if (!activityCallback.isStreetMode()) {
|
||||||
|
String unconfirmed = Helper.getFormattedAmount(unconfirmedAmount, true);
|
||||||
|
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, unconfirmed));
|
||||||
|
} else {
|
||||||
|
tvUnconfirmedAmount.setText(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateBalance() {
|
void updateBalance() {
|
||||||
if (isExchanging) return; // wait for exchange to finish - it will fire this itself then.
|
if (isExchanging) return; // wait for exchange to finish - it will fire this itself then.
|
||||||
// at this point selection is XMR in case of error
|
// at this point selection is XMR in case of error
|
||||||
@@ -156,7 +184,7 @@ public class WalletFragment extends Fragment
|
|||||||
} else { // XMR
|
} else { // XMR
|
||||||
displayB = Helper.getFormattedAmount(amountA, true);
|
displayB = Helper.getFormattedAmount(amountA, true);
|
||||||
}
|
}
|
||||||
tvBalance.setText(displayB);
|
showBalance(displayB);
|
||||||
}
|
}
|
||||||
|
|
||||||
String balanceCurrency = Helper.CRYPTO;
|
String balanceCurrency = Helper.CRYPTO;
|
||||||
@@ -165,9 +193,11 @@ public class WalletFragment extends Fragment
|
|||||||
private final ExchangeApi exchangeApi = Helper.getExchangeApi();
|
private final ExchangeApi exchangeApi = Helper.getExchangeApi();
|
||||||
|
|
||||||
void refreshBalance() {
|
void refreshBalance() {
|
||||||
|
double unconfirmedXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance));
|
||||||
|
showUnconfirmed(unconfirmedXmr);
|
||||||
if (sCurrency.getSelectedItemPosition() == 0) { // XMR
|
if (sCurrency.getSelectedItemPosition() == 0) { // XMR
|
||||||
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
||||||
tvBalance.setText(Helper.getFormattedAmount(amountXmr, true));
|
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
||||||
} else { // not XMR
|
} else { // not XMR
|
||||||
String currency = (String) sCurrency.getSelectedItem();
|
String currency = (String) sCurrency.getSelectedItem();
|
||||||
Timber.d(currency);
|
Timber.d(currency);
|
||||||
@@ -223,7 +253,7 @@ public class WalletFragment extends Fragment
|
|||||||
public void exchangeFailed() {
|
public void exchangeFailed() {
|
||||||
sCurrency.setSelection(0, true); // default to XMR
|
sCurrency.setSelection(0, true); // default to XMR
|
||||||
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
double amountXmr = Double.parseDouble(Wallet.getDisplayAmount(unlockedBalance)); // assume this cannot fail!
|
||||||
tvBalance.setText(Helper.getFormattedAmount(amountXmr, true));
|
showBalance(Helper.getFormattedAmount(amountXmr, true));
|
||||||
hideExchanging();
|
hideExchanging();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +289,13 @@ public class WalletFragment extends Fragment
|
|||||||
public void onRefreshed(final Wallet wallet, final boolean full) {
|
public void onRefreshed(final Wallet wallet, final boolean full) {
|
||||||
Timber.d("onRefreshed(%b)", full);
|
Timber.d("onRefreshed(%b)", full);
|
||||||
if (full) {
|
if (full) {
|
||||||
List<TransactionInfo> list = wallet.getHistory().getAll();
|
List<TransactionInfo> list = new ArrayList<>();
|
||||||
|
final long streetHeight = activityCallback.getStreetModeHeight();
|
||||||
|
Timber.d("StreetHeight=%d", streetHeight);
|
||||||
|
for (TransactionInfo info : wallet.getHistory().getAll()) {
|
||||||
|
Timber.d("TxHeight=%d", info.blockheight);
|
||||||
|
if (info.isPending || (info.blockheight >= streetHeight)) list.add(info);
|
||||||
|
}
|
||||||
adapter.setInfos(list);
|
adapter.setInfos(list);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
@@ -324,6 +360,7 @@ public class WalletFragment extends Fragment
|
|||||||
private String walletTitle = null;
|
private String walletTitle = null;
|
||||||
private String walletSubtitle = null;
|
private String walletSubtitle = null;
|
||||||
private long unlockedBalance = 0;
|
private long unlockedBalance = 0;
|
||||||
|
private long balance = 0;
|
||||||
|
|
||||||
private int accountIdx = -1;
|
private int accountIdx = -1;
|
||||||
|
|
||||||
@@ -334,12 +371,9 @@ public class WalletFragment extends Fragment
|
|||||||
accountIdx = wallet.getAccountIndex();
|
accountIdx = wallet.getAccountIndex();
|
||||||
setActivityTitle(wallet);
|
setActivityTitle(wallet);
|
||||||
}
|
}
|
||||||
long balance = wallet.getBalance();
|
balance = wallet.getBalance();
|
||||||
unlockedBalance = wallet.getUnlockedBalance();
|
unlockedBalance = wallet.getUnlockedBalance();
|
||||||
refreshBalance();
|
refreshBalance();
|
||||||
double amountXmr = Double.parseDouble(Helper.getDisplayAmount(balance - unlockedBalance)); // assume this cannot fail!
|
|
||||||
String unconfirmed = Helper.getFormattedAmount(amountXmr, true);
|
|
||||||
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, unconfirmed));
|
|
||||||
String sync = "";
|
String sync = "";
|
||||||
if (!activityCallback.hasBoundService())
|
if (!activityCallback.hasBoundService())
|
||||||
throw new IllegalStateException("WalletService not bound.");
|
throw new IllegalStateException("WalletService not bound.");
|
||||||
@@ -386,6 +420,10 @@ public class WalletFragment extends Fragment
|
|||||||
|
|
||||||
boolean isSynced();
|
boolean isSynced();
|
||||||
|
|
||||||
|
boolean isStreetMode();
|
||||||
|
|
||||||
|
long getStreetModeHeight();
|
||||||
|
|
||||||
boolean isWatchOnly();
|
boolean isWatchOnly();
|
||||||
|
|
||||||
String getTxKey(String txId);
|
String getTxKey(String txId);
|
||||||
@@ -394,6 +432,8 @@ public class WalletFragment extends Fragment
|
|||||||
|
|
||||||
boolean hasWallet();
|
boolean hasWallet();
|
||||||
|
|
||||||
|
Wallet getWallet();
|
||||||
|
|
||||||
void setToolbarButton(int type);
|
void setToolbarButton(int type);
|
||||||
|
|
||||||
void setTitle(String title, String subtitle);
|
void setTitle(String title, String subtitle);
|
||||||
|
@@ -20,6 +20,7 @@ import android.net.Uri;
|
|||||||
|
|
||||||
import com.m2049r.xmrwallet.model.Wallet;
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.util.BitcoinAddressValidator;
|
import com.m2049r.xmrwallet.util.BitcoinAddressValidator;
|
||||||
|
import com.m2049r.xmrwallet.util.OpenAliasHelper;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -27,9 +28,14 @@ import java.util.Map;
|
|||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class BarcodeData {
|
public class BarcodeData {
|
||||||
|
|
||||||
public static final String XMR_SCHEME = "monero:";
|
public static final String XMR_SCHEME = "monero:";
|
||||||
public static final String XMR_PAYMENTID = "tx_payment_id";
|
public static final String XMR_PAYMENTID = "tx_payment_id";
|
||||||
public static final String XMR_AMOUNT = "tx_amount";
|
public static final String XMR_AMOUNT = "tx_amount";
|
||||||
|
public static final String XMR_DESCRIPTION = "tx_description";
|
||||||
|
|
||||||
|
public static final String OA_XMR_ASSET = "xmr";
|
||||||
|
public static final String OA_BTC_ASSET = "btc";
|
||||||
|
|
||||||
static final String BTC_SCHEME = "bitcoin:";
|
static final String BTC_SCHEME = "bitcoin:";
|
||||||
static final String BTC_AMOUNT = "amount";
|
static final String BTC_AMOUNT = "amount";
|
||||||
@@ -38,10 +44,19 @@ public class BarcodeData {
|
|||||||
XMR, BTC
|
XMR, BTC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Security {
|
||||||
|
NORMAL,
|
||||||
|
OA_NO_DNSSEC,
|
||||||
|
OA_DNSSEC
|
||||||
|
}
|
||||||
|
|
||||||
public Asset asset = null;
|
public Asset asset = null;
|
||||||
|
public String addressName = null;
|
||||||
public String address = null;
|
public String address = null;
|
||||||
public String paymentId = null;
|
public String paymentId = null;
|
||||||
public String amount = null;
|
public String amount = null;
|
||||||
|
public String description = null;
|
||||||
|
public Security security = Security.NORMAL;
|
||||||
|
|
||||||
public BarcodeData(String uri) {
|
public BarcodeData(String uri) {
|
||||||
this.asset = asset;
|
this.asset = asset;
|
||||||
@@ -66,6 +81,22 @@ public class BarcodeData {
|
|||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BarcodeData(Asset asset, String address, String paymentId, String description, String amount) {
|
||||||
|
this.asset = asset;
|
||||||
|
this.address = address;
|
||||||
|
this.paymentId = paymentId;
|
||||||
|
this.description = description;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressName(String name) {
|
||||||
|
addressName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecurity(Security security) {
|
||||||
|
this.security = security;
|
||||||
|
}
|
||||||
|
|
||||||
public Uri getUri() {
|
public Uri getUri() {
|
||||||
return Uri.parse(getUriString());
|
return Uri.parse(getUriString());
|
||||||
}
|
}
|
||||||
@@ -80,12 +111,13 @@ public class BarcodeData {
|
|||||||
first = false;
|
first = false;
|
||||||
sb.append(BarcodeData.XMR_PAYMENTID).append('=').append(paymentId);
|
sb.append(BarcodeData.XMR_PAYMENTID).append('=').append(paymentId);
|
||||||
}
|
}
|
||||||
if (!amount.isEmpty()) {
|
if ((description != null) && !description.isEmpty()) {
|
||||||
if (first) {
|
sb.append(first ? "?" : "&");
|
||||||
sb.append("?");
|
first = false;
|
||||||
} else {
|
sb.append(BarcodeData.XMR_DESCRIPTION).append('=').append(Uri.encode(description));
|
||||||
sb.append("&");
|
}
|
||||||
}
|
if ((amount != null) && !amount.isEmpty()) {
|
||||||
|
sb.append(first ? "?" : "&");
|
||||||
sb.append(BarcodeData.XMR_AMOUNT).append('=').append(amount);
|
sb.append(BarcodeData.XMR_AMOUNT).append('=').append(amount);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -102,10 +134,14 @@ public class BarcodeData {
|
|||||||
if (bcData == null) {
|
if (bcData == null) {
|
||||||
bcData = parseBitcoinUri(qrCode);
|
bcData = parseBitcoinUri(qrCode);
|
||||||
}
|
}
|
||||||
// check for naked btc addres
|
// check for naked btc address
|
||||||
if (bcData == null) {
|
if (bcData == null) {
|
||||||
bcData = parseBitcoinNaked(qrCode);
|
bcData = parseBitcoinNaked(qrCode);
|
||||||
}
|
}
|
||||||
|
// check for OpenAlias
|
||||||
|
if (bcData == null) {
|
||||||
|
bcData = parseOpenAlias(qrCode);
|
||||||
|
}
|
||||||
return bcData;
|
return bcData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +162,7 @@ public class BarcodeData {
|
|||||||
String noScheme = uri.substring(XMR_SCHEME.length());
|
String noScheme = uri.substring(XMR_SCHEME.length());
|
||||||
Uri monero = Uri.parse(noScheme);
|
Uri monero = Uri.parse(noScheme);
|
||||||
Map<String, String> parms = new HashMap<>();
|
Map<String, String> parms = new HashMap<>();
|
||||||
String query = monero.getQuery();
|
String query = monero.getEncodedQuery();
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
String[] args = query.split("&");
|
String[] args = query.split("&");
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
@@ -140,6 +176,7 @@ public class BarcodeData {
|
|||||||
}
|
}
|
||||||
String address = monero.getPath();
|
String address = monero.getPath();
|
||||||
String paymentId = parms.get(XMR_PAYMENTID);
|
String paymentId = parms.get(XMR_PAYMENTID);
|
||||||
|
String description = parms.get(XMR_DESCRIPTION);
|
||||||
String amount = parms.get(XMR_AMOUNT);
|
String amount = parms.get(XMR_AMOUNT);
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
try {
|
try {
|
||||||
@@ -158,7 +195,7 @@ public class BarcodeData {
|
|||||||
Timber.d("address invalid");
|
Timber.d("address invalid");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new BarcodeData(Asset.XMR, address, paymentId, amount);
|
return new BarcodeData(Asset.XMR, address, paymentId, description, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public BarcodeData parseMoneroNaked(String address) {
|
static public BarcodeData parseMoneroNaked(String address) {
|
||||||
@@ -226,4 +263,61 @@ public class BarcodeData {
|
|||||||
|
|
||||||
return new BarcodeData(BarcodeData.Asset.BTC, address);
|
return new BarcodeData(BarcodeData.Asset.BTC, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public BarcodeData parseOpenAlias(String oaString) {
|
||||||
|
Timber.d("parseOpenAlias=%s", oaString);
|
||||||
|
if (oaString == null) return null;
|
||||||
|
|
||||||
|
Map<String, String> oaAttrs = OpenAliasHelper.parse(oaString);
|
||||||
|
if (oaAttrs == null) return null;
|
||||||
|
|
||||||
|
String oaAsset = oaAttrs.get(OpenAliasHelper.OA1_ASSET);
|
||||||
|
if (oaAsset == null) return null;
|
||||||
|
|
||||||
|
String address = oaAttrs.get(OpenAliasHelper.OA1_ADDRESS);
|
||||||
|
if (address == null) return null;
|
||||||
|
|
||||||
|
Asset asset;
|
||||||
|
if (OA_XMR_ASSET.equals(oaAsset)) {
|
||||||
|
if (!Wallet.isAddressValid(address)) {
|
||||||
|
Timber.d("XMR address invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
asset = Asset.XMR;
|
||||||
|
} else if (OA_BTC_ASSET.equals(oaAsset)) {
|
||||||
|
if (!BitcoinAddressValidator.validate(address)) {
|
||||||
|
Timber.d("BTC address invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
asset = Asset.BTC;
|
||||||
|
} else {
|
||||||
|
Timber.i("Unsupported OpenAlias asset %s", oaAsset);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String paymentId = oaAttrs.get(OpenAliasHelper.OA1_PAYMENTID);
|
||||||
|
String description = oaAttrs.get(OpenAliasHelper.OA1_DESCRIPTION);
|
||||||
|
if (description == null) {
|
||||||
|
description = oaAttrs.get(OpenAliasHelper.OA1_NAME);
|
||||||
|
}
|
||||||
|
String amount = oaAttrs.get(OpenAliasHelper.OA1_AMOUNT);
|
||||||
|
String addressName = oaAttrs.get(OpenAliasHelper.OA1_NAME);
|
||||||
|
|
||||||
|
if (amount != null) {
|
||||||
|
try {
|
||||||
|
Double.parseDouble(amount);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
Timber.d(ex.getLocalizedMessage());
|
||||||
|
return null; // we have an amount but its not a number!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((paymentId != null) && !Wallet.isPaymentIdValid(paymentId)) {
|
||||||
|
Timber.d("paymentId invalid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BarcodeData bc = new BarcodeData(asset, address, paymentId, description, amount);
|
||||||
|
bc.setAddressName(addressName);
|
||||||
|
return bc;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -32,6 +32,14 @@ import android.widget.TextView;
|
|||||||
import com.m2049r.xmrwallet.BuildConfig;
|
import com.m2049r.xmrwallet.BuildConfig;
|
||||||
import com.m2049r.xmrwallet.R;
|
import com.m2049r.xmrwallet.R;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class AboutFragment extends DialogFragment {
|
public class AboutFragment extends DialogFragment {
|
||||||
static final String TAG = "AboutFragment";
|
static final String TAG = "AboutFragment";
|
||||||
|
|
||||||
@@ -52,7 +60,7 @@ public class AboutFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_about, null);
|
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_about, null);
|
||||||
((TextView) view.findViewById(R.id.tvHelp)).setText(Html.fromHtml(getString(R.string.about_licenses)));
|
((TextView) view.findViewById(R.id.tvHelp)).setText(Html.fromHtml(getLicencesHtml()));
|
||||||
((TextView) view.findViewById(R.id.tvVersion)).setText(getString(R.string.about_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));
|
((TextView) view.findViewById(R.id.tvVersion)).setText(getString(R.string.about_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
@@ -66,4 +74,18 @@ public class AboutFragment extends DialogFragment {
|
|||||||
});
|
});
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLicencesHtml() {
|
||||||
|
try (BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(getContext().getAssets().open("licenses.html"), StandardCharsets.UTF_8))) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null)
|
||||||
|
sb.append(line);
|
||||||
|
return sb.toString();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Timber.e(ex);
|
||||||
|
return ex.getLocalizedMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -25,6 +25,7 @@ import android.text.Editable;
|
|||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -38,10 +39,14 @@ import com.m2049r.xmrwallet.R;
|
|||||||
import com.m2049r.xmrwallet.data.BarcodeData;
|
import com.m2049r.xmrwallet.data.BarcodeData;
|
||||||
import com.m2049r.xmrwallet.data.TxData;
|
import com.m2049r.xmrwallet.data.TxData;
|
||||||
import com.m2049r.xmrwallet.data.TxDataBtc;
|
import com.m2049r.xmrwallet.data.TxDataBtc;
|
||||||
|
import com.m2049r.xmrwallet.model.PendingTransaction;
|
||||||
import com.m2049r.xmrwallet.model.Wallet;
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
|
||||||
import com.m2049r.xmrwallet.util.BitcoinAddressValidator;
|
import com.m2049r.xmrwallet.util.BitcoinAddressValidator;
|
||||||
import com.m2049r.xmrwallet.util.Helper;
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
import com.m2049r.xmrwallet.util.OpenAliasHelper;
|
||||||
|
import com.m2049r.xmrwallet.util.UserNotes;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
@@ -75,6 +80,7 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
private EditText etDummy;
|
private EditText etDummy;
|
||||||
private TextInputLayout etAddress;
|
private TextInputLayout etAddress;
|
||||||
private TextInputLayout etPaymentId;
|
private TextInputLayout etPaymentId;
|
||||||
|
private TextInputLayout etNotes;
|
||||||
private Button bPaymentId;
|
private Button bPaymentId;
|
||||||
private CardView cvScan;
|
private CardView cvScan;
|
||||||
private View tvPaymentIdIntegrated;
|
private View tvPaymentIdIntegrated;
|
||||||
@@ -82,6 +88,8 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
private TextView tvXmrTo;
|
private TextView tvXmrTo;
|
||||||
private View llXmrTo;
|
private View llXmrTo;
|
||||||
|
|
||||||
|
private boolean resolvingOA = false;
|
||||||
|
|
||||||
OnScanListener onScanListener;
|
OnScanListener onScanListener;
|
||||||
|
|
||||||
public interface OnScanListener {
|
public interface OnScanListener {
|
||||||
@@ -105,8 +113,13 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
etAddress.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etAddress.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
etAddress.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etAddress.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
if (checkAddress()) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
|
String dnsOA = dnsFromOpenAlias(etAddress.getEditText().getText().toString());
|
||||||
|
Timber.d("OpenAlias is %s", dnsOA);
|
||||||
|
if (dnsOA != null) {
|
||||||
|
processOpenAlias(dnsOA);
|
||||||
|
} else if (checkAddress()) {
|
||||||
if (llPaymentId.getVisibility() == View.VISIBLE) {
|
if (llPaymentId.getVisibility() == View.VISIBLE) {
|
||||||
etPaymentId.requestFocus();
|
etPaymentId.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
@@ -155,15 +168,14 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId);
|
etPaymentId = (TextInputLayout) view.findViewById(R.id.etPaymentId);
|
||||||
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkPaymentId()) {
|
if (checkPaymentId()) {
|
||||||
etDummy.requestFocus();
|
etNotes.requestFocus();
|
||||||
Helper.hideKeyboard(getActivity());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -193,6 +205,20 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
etNotes = (TextInputLayout) view.findViewById(R.id.etNotes);
|
||||||
|
etNotes.getEditText().setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
etNotes.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
|
etDummy.requestFocus();
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cvScan = (CardView) view.findViewById(R.id.bScan);
|
cvScan = (CardView) view.findViewById(R.id.bScan);
|
||||||
cvScan.setOnClickListener(new View.OnClickListener() {
|
cvScan.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -215,6 +241,38 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processOpenAlias(String dnsOA) {
|
||||||
|
if (resolvingOA) return; // already resolving - just wait
|
||||||
|
if (dnsOA != null) {
|
||||||
|
resolvingOA = true;
|
||||||
|
etAddress.setError(getString(R.string.send_address_resolve_openalias));
|
||||||
|
OpenAliasHelper.resolve(dnsOA, new OpenAliasHelper.OnResolvedListener() {
|
||||||
|
@Override
|
||||||
|
public void onResolved(Map<BarcodeData.Asset, BarcodeData> dataMap) {
|
||||||
|
resolvingOA = false;
|
||||||
|
BarcodeData barcodeData = dataMap.get(BarcodeData.Asset.XMR);
|
||||||
|
if (barcodeData == null) barcodeData = dataMap.get(BarcodeData.Asset.BTC);
|
||||||
|
if (barcodeData != null) {
|
||||||
|
Timber.d("Security=%s, %s", barcodeData.security.toString(), barcodeData.address);
|
||||||
|
processScannedData(barcodeData);
|
||||||
|
etDummy.requestFocus();
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
} else {
|
||||||
|
etAddress.setError(getString(R.string.send_address_not_openalias));
|
||||||
|
Timber.d("NO XMR OPENALIAS TXT FOUND");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure() {
|
||||||
|
resolvingOA = false;
|
||||||
|
etAddress.setError(getString(R.string.send_address_not_openalias));
|
||||||
|
Timber.e("OA FAILED");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // else ignore
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkAddressNoError() {
|
private boolean checkAddressNoError() {
|
||||||
String address = etAddress.getEditText().getText().toString();
|
String address = etAddress.getEditText().getText().toString();
|
||||||
return Wallet.isAddressValid(address)
|
return Wallet.isAddressValid(address)
|
||||||
@@ -261,12 +319,21 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void shakeAddress() {
|
||||||
|
etAddress.startAnimation(Helper.getShakeAnimation(getContext()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onValidateFields() {
|
public boolean onValidateFields() {
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
if (!checkAddressNoError()) {
|
if (!checkAddressNoError()) {
|
||||||
etAddress.startAnimation(Helper.getShakeAnimation(getContext()));
|
shakeAddress();
|
||||||
ok = false;
|
ok = false;
|
||||||
|
String dnsOA = dnsFromOpenAlias(etAddress.getEditText().getText().toString());
|
||||||
|
Timber.d("OpenAlias is %s", dnsOA);
|
||||||
|
if (dnsOA != null) {
|
||||||
|
processOpenAlias(dnsOA);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!checkPaymentId()) {
|
if (!checkPaymentId()) {
|
||||||
etPaymentId.startAnimation(Helper.getShakeAnimation(getContext()));
|
etPaymentId.startAnimation(Helper.getShakeAnimation(getContext()));
|
||||||
@@ -283,6 +350,9 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
txData.setDestinationAddress(etAddress.getEditText().getText().toString());
|
txData.setDestinationAddress(etAddress.getEditText().getText().toString());
|
||||||
txData.setPaymentId(etPaymentId.getEditText().getText().toString());
|
txData.setPaymentId(etPaymentId.getEditText().getText().toString());
|
||||||
}
|
}
|
||||||
|
txData.setUserNotes(new UserNotes(etNotes.getEditText().getText().toString()));
|
||||||
|
txData.setPriority(PendingTransaction.Priority.Priority_Default);
|
||||||
|
txData.setMixin(SendFragment.MIXIN);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -320,19 +390,31 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
String scannedAddress = barcodeData.address;
|
String scannedAddress = barcodeData.address;
|
||||||
if (scannedAddress != null) {
|
if (scannedAddress != null) {
|
||||||
etAddress.getEditText().setText(scannedAddress);
|
etAddress.getEditText().setText(scannedAddress);
|
||||||
checkAddress();
|
if (checkAddress()) {
|
||||||
|
if (barcodeData.security == BarcodeData.Security.OA_NO_DNSSEC)
|
||||||
|
etAddress.setError(getString(R.string.send_address_no_dnssec));
|
||||||
|
else if (barcodeData.security == BarcodeData.Security.OA_DNSSEC)
|
||||||
|
etAddress.setError(getString(R.string.send_address_openalias));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
etAddress.getEditText().getText().clear();
|
etAddress.getEditText().getText().clear();
|
||||||
etAddress.setError(null);
|
etAddress.setError(null);
|
||||||
}
|
}
|
||||||
String scannedPaymenId = barcodeData.paymentId;
|
String scannedPaymentId = barcodeData.paymentId;
|
||||||
if (scannedPaymenId != null) {
|
if (scannedPaymentId != null) {
|
||||||
etPaymentId.getEditText().setText(scannedPaymenId);
|
etPaymentId.getEditText().setText(scannedPaymentId);
|
||||||
checkPaymentId();
|
checkPaymentId();
|
||||||
} else {
|
} else {
|
||||||
etPaymentId.getEditText().getText().clear();
|
etPaymentId.getEditText().getText().clear();
|
||||||
etPaymentId.setError(null);
|
etPaymentId.setError(null);
|
||||||
}
|
}
|
||||||
|
String scannedNotes = barcodeData.description;
|
||||||
|
if (scannedNotes != null) {
|
||||||
|
etNotes.getEditText().setText(scannedNotes);
|
||||||
|
} else {
|
||||||
|
etNotes.getEditText().getText().clear();
|
||||||
|
etNotes.setError(null);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
Timber.d("barcodeData=null");
|
Timber.d("barcodeData=null");
|
||||||
}
|
}
|
||||||
@@ -344,4 +426,14 @@ public class SendAddressWizardFragment extends SendWizardFragment {
|
|||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
etDummy.requestFocus();
|
etDummy.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String dnsFromOpenAlias(String openalias) {
|
||||||
|
Timber.d("checking openalias candidate %s", openalias);
|
||||||
|
if (Patterns.DOMAIN_NAME.matcher(openalias).matches()) return openalias;
|
||||||
|
if (Patterns.EMAIL_ADDRESS.matcher(openalias).matches()) {
|
||||||
|
openalias = openalias.replaceFirst("@", ".");
|
||||||
|
if (Patterns.DOMAIN_NAME.matcher(openalias).matches()) return openalias;
|
||||||
|
}
|
||||||
|
return null; // not an openalias
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -149,8 +149,13 @@ public class SendAmountWizardFragment extends SendWizardFragment {
|
|||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
final long funds = getTotalFunds();
|
final long funds = getTotalFunds();
|
||||||
maxFunds = 1.0 * funds / 1000000000000L;
|
maxFunds = 1.0 * funds / 1000000000000L;
|
||||||
tvFunds.setText(getString(R.string.send_available,
|
if (!sendListener.getActivityCallback().isStreetMode()) {
|
||||||
Wallet.getDisplayAmount(funds)));
|
tvFunds.setText(getString(R.string.send_available,
|
||||||
|
Wallet.getDisplayAmount(funds)));
|
||||||
|
} else {
|
||||||
|
tvFunds.setText(getString(R.string.send_available,
|
||||||
|
getString(R.string.unknown_amount)));
|
||||||
|
}
|
||||||
// getAmount is null if exchange is in progress
|
// getAmount is null if exchange is in progress
|
||||||
if ((evAmount.getAmount() != null) && evAmount.getAmount().isEmpty()) {
|
if ((evAmount.getAmount() != null) && evAmount.getAmount().isEmpty()) {
|
||||||
final BarcodeData data = sendListener.popBarcodeData();
|
final BarcodeData data = sendListener.popBarcodeData();
|
||||||
|
@@ -135,8 +135,13 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment {
|
|||||||
Timber.d("onResumeFragment()");
|
Timber.d("onResumeFragment()");
|
||||||
Helper.hideKeyboard(getActivity());
|
Helper.hideKeyboard(getActivity());
|
||||||
final long funds = getTotalFunds();
|
final long funds = getTotalFunds();
|
||||||
tvFunds.setText(getString(R.string.send_available,
|
if (!sendListener.getActivityCallback().isStreetMode()) {
|
||||||
Wallet.getDisplayAmount(funds)));
|
tvFunds.setText(getString(R.string.send_available,
|
||||||
|
Wallet.getDisplayAmount(funds)));
|
||||||
|
} else {
|
||||||
|
tvFunds.setText(getString(R.string.send_available,
|
||||||
|
getString(R.string.unknown_amount)));
|
||||||
|
}
|
||||||
if ((evAmount.getAmount() == null) || evAmount.getAmount().isEmpty()) {
|
if ((evAmount.getAmount() == null) || evAmount.getAmount().isEmpty()) {
|
||||||
final BarcodeData data = sendListener.popBarcodeData();
|
final BarcodeData data = sendListener.popBarcodeData();
|
||||||
if ((data != null) && (data.amount != null)) {
|
if ((data != null) && (data.amount != null)) {
|
||||||
@@ -178,8 +183,15 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment {
|
|||||||
double availableXmr = 1.0 * funds / 1000000000000L;
|
double availableXmr = 1.0 * funds / 1000000000000L;
|
||||||
maxBtc = Math.min(maxBtc, availableXmr * orderParameters.getPrice());
|
maxBtc = Math.min(maxBtc, availableXmr * orderParameters.getPrice());
|
||||||
|
|
||||||
String availBtcString = df.format(availableXmr * orderParameters.getPrice());
|
String availBtcString;
|
||||||
String availXmrString = df.format(availableXmr);
|
String availXmrString;
|
||||||
|
if (!sendListener.getActivityCallback().isStreetMode()) {
|
||||||
|
availBtcString = df.format(availableXmr * orderParameters.getPrice());
|
||||||
|
availXmrString = df.format(availableXmr);
|
||||||
|
} else {
|
||||||
|
availBtcString = getString(R.string.unknown_amount);
|
||||||
|
availXmrString = availBtcString;
|
||||||
|
}
|
||||||
tvFunds.setText(getString(R.string.send_available_btc,
|
tvFunds.setText(getString(R.string.send_available_btc,
|
||||||
availXmrString,
|
availXmrString,
|
||||||
availBtcString));
|
availBtcString));
|
||||||
|
@@ -421,7 +421,8 @@ public class SendBtcConfirmWizardFragment extends SendWizardFragment implements
|
|||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
String pass = etPassword.getEditText().getText().toString();
|
String pass = etPassword.getEditText().getText().toString();
|
||||||
if (getActivityCallback().verifyWalletPassword(pass)) {
|
if (getActivityCallback().verifyWalletPassword(pass)) {
|
||||||
Helper.hideKeyboardAlways(activity);
|
Helper.hideKeyboardAlways(activity);
|
||||||
|
@@ -302,7 +302,8 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen
|
|||||||
// accept keyboard "ok"
|
// accept keyboard "ok"
|
||||||
etPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
String pass = etPassword.getEditText().getText().toString();
|
String pass = etPassword.getEditText().getText().toString();
|
||||||
if (getActivityCallback().verifyWalletPassword(pass)) {
|
if (getActivityCallback().verifyWalletPassword(pass)) {
|
||||||
Helper.hideKeyboardAlways(activity);
|
Helper.hideKeyboardAlways(activity);
|
||||||
|
@@ -58,11 +58,12 @@ import timber.log.Timber;
|
|||||||
public class SendFragment extends Fragment
|
public class SendFragment extends Fragment
|
||||||
implements SendAddressWizardFragment.Listener,
|
implements SendAddressWizardFragment.Listener,
|
||||||
SendAmountWizardFragment.Listener,
|
SendAmountWizardFragment.Listener,
|
||||||
SendSettingsWizardFragment.Listener,
|
|
||||||
SendConfirmWizardFragment.Listener,
|
SendConfirmWizardFragment.Listener,
|
||||||
SendSuccessWizardFragment.Listener,
|
SendSuccessWizardFragment.Listener,
|
||||||
OnBackPressedListener, OnUriScannedListener {
|
OnBackPressedListener, OnUriScannedListener {
|
||||||
|
|
||||||
|
final static public int MIXIN = 10;
|
||||||
|
|
||||||
private Listener activityCallback;
|
private Listener activityCallback;
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
@@ -70,6 +71,8 @@ public class SendFragment extends Fragment
|
|||||||
|
|
||||||
long getTotalFunds();
|
long getTotalFunds();
|
||||||
|
|
||||||
|
boolean isStreetMode();
|
||||||
|
|
||||||
void onPrepareSend(String tag, TxData data);
|
void onPrepareSend(String tag, TxData data);
|
||||||
|
|
||||||
boolean verifyWalletPassword(String password);
|
boolean verifyWalletPassword(String password);
|
||||||
@@ -301,10 +304,9 @@ public class SendFragment extends Fragment
|
|||||||
public class SpendPagerAdapter extends FragmentStatePagerAdapter {
|
public class SpendPagerAdapter extends FragmentStatePagerAdapter {
|
||||||
private static final int POS_ADDRESS = 0;
|
private static final int POS_ADDRESS = 0;
|
||||||
private static final int POS_AMOUNT = 1;
|
private static final int POS_AMOUNT = 1;
|
||||||
private static final int POS_SETTINGS = 2;
|
private static final int POS_CONFIRM = 2;
|
||||||
private static final int POS_CONFIRM = 3;
|
private static final int POS_SUCCESS = 3;
|
||||||
private static final int POS_SUCCESS = 4;
|
private int numPages = 3;
|
||||||
private int numPages = 4;
|
|
||||||
|
|
||||||
SparseArray<WeakReference<SendWizardFragment>> myFragments = new SparseArray<>();
|
SparseArray<WeakReference<SendWizardFragment>> myFragments = new SparseArray<>();
|
||||||
|
|
||||||
@@ -355,8 +357,6 @@ public class SendFragment extends Fragment
|
|||||||
return SendAddressWizardFragment.newInstance(SendFragment.this);
|
return SendAddressWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_AMOUNT:
|
case POS_AMOUNT:
|
||||||
return SendAmountWizardFragment.newInstance(SendFragment.this);
|
return SendAmountWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_SETTINGS:
|
|
||||||
return SendSettingsWizardFragment.newInstance(SendFragment.this);
|
|
||||||
case POS_CONFIRM:
|
case POS_CONFIRM:
|
||||||
return SendConfirmWizardFragment.newInstance(SendFragment.this);
|
return SendConfirmWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_SUCCESS:
|
case POS_SUCCESS:
|
||||||
@@ -370,8 +370,6 @@ public class SendFragment extends Fragment
|
|||||||
return SendAddressWizardFragment.newInstance(SendFragment.this);
|
return SendAddressWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_AMOUNT:
|
case POS_AMOUNT:
|
||||||
return SendBtcAmountWizardFragment.newInstance(SendFragment.this);
|
return SendBtcAmountWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_SETTINGS:
|
|
||||||
return SendSettingsWizardFragment.newInstance(SendFragment.this);
|
|
||||||
case POS_CONFIRM:
|
case POS_CONFIRM:
|
||||||
return SendBtcConfirmWizardFragment.newInstance(SendFragment.this);
|
return SendBtcConfirmWizardFragment.newInstance(SendFragment.this);
|
||||||
case POS_SUCCESS:
|
case POS_SUCCESS:
|
||||||
@@ -393,8 +391,6 @@ public class SendFragment extends Fragment
|
|||||||
return getString(R.string.send_address_title);
|
return getString(R.string.send_address_title);
|
||||||
case POS_AMOUNT:
|
case POS_AMOUNT:
|
||||||
return getString(R.string.send_amount_title);
|
return getString(R.string.send_amount_title);
|
||||||
case POS_SETTINGS:
|
|
||||||
return getString(R.string.send_settings_title);
|
|
||||||
case POS_CONFIRM:
|
case POS_CONFIRM:
|
||||||
return getString(R.string.send_confirm_title);
|
return getString(R.string.send_confirm_title);
|
||||||
case POS_SUCCESS:
|
case POS_SUCCESS:
|
||||||
@@ -407,7 +403,8 @@ public class SendFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public int getItemPosition(Object object) {
|
public int getItemPosition(Object object) {
|
||||||
Timber.d("getItemPosition %s", String.valueOf(object));
|
Timber.d("getItemPosition %s", String.valueOf(object));
|
||||||
if ((object instanceof SendAddressWizardFragment) || (object instanceof SendSettingsWizardFragment)) {
|
if (object instanceof SendAddressWizardFragment) {
|
||||||
|
// keep these pages
|
||||||
return POSITION_UNCHANGED;
|
return POSITION_UNCHANGED;
|
||||||
} else {
|
} else {
|
||||||
return POSITION_NONE;
|
return POSITION_NONE;
|
||||||
|
@@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017 m2049r
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.m2049r.xmrwallet.fragment.send;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.InputType;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.R;
|
|
||||||
import com.m2049r.xmrwallet.data.TxData;
|
|
||||||
import com.m2049r.xmrwallet.model.PendingTransaction;
|
|
||||||
import com.m2049r.xmrwallet.util.Helper;
|
|
||||||
import com.m2049r.xmrwallet.util.UserNotes;
|
|
||||||
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
public class SendSettingsWizardFragment extends SendWizardFragment {
|
|
||||||
final static public int MIXIN = 6;
|
|
||||||
|
|
||||||
public static SendSettingsWizardFragment newInstance(Listener listener) {
|
|
||||||
SendSettingsWizardFragment instance = new SendSettingsWizardFragment();
|
|
||||||
instance.setSendListener(listener);
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Listener sendListener;
|
|
||||||
|
|
||||||
public SendSettingsWizardFragment setSendListener(Listener listener) {
|
|
||||||
this.sendListener = listener;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Listener {
|
|
||||||
TxData getTxData();
|
|
||||||
}
|
|
||||||
|
|
||||||
final static PendingTransaction.Priority Priorities[] =
|
|
||||||
{PendingTransaction.Priority.Priority_Default,
|
|
||||||
PendingTransaction.Priority.Priority_Low,
|
|
||||||
PendingTransaction.Priority.Priority_Medium,
|
|
||||||
PendingTransaction.Priority.Priority_High}; // must match the layout XML
|
|
||||||
|
|
||||||
private Spinner sPriority;
|
|
||||||
private EditText etNotes;
|
|
||||||
private EditText etDummy;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
|
|
||||||
Timber.d("onCreateView() %s", (String.valueOf(savedInstanceState)));
|
|
||||||
|
|
||||||
View view = inflater.inflate(
|
|
||||||
R.layout.fragment_send_settings, container, false);
|
|
||||||
|
|
||||||
sPriority = (Spinner) view.findViewById(R.id.sPriority);
|
|
||||||
|
|
||||||
etNotes = (EditText) view.findViewById(R.id.etNotes);
|
|
||||||
etNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
|
||||||
etNotes.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
|
|
||||||
etDummy.requestFocus();
|
|
||||||
Helper.hideKeyboard(getActivity());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
etDummy = (EditText) view.findViewById(R.id.etDummy);
|
|
||||||
etDummy.setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onValidateFields() {
|
|
||||||
if (sendListener != null) {
|
|
||||||
TxData txData = sendListener.getTxData();
|
|
||||||
txData.setPriority(Priorities[sPriority.getSelectedItemPosition()]);
|
|
||||||
txData.setMixin(MIXIN);
|
|
||||||
txData.setUserNotes(new UserNotes(etNotes.getText().toString()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResumeFragment() {
|
|
||||||
super.onResumeFragment();
|
|
||||||
Timber.d("onResumeFragment()");
|
|
||||||
Helper.hideKeyboard(getActivity());
|
|
||||||
etDummy.requestFocus();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -34,11 +34,9 @@ import java.io.IOException;
|
|||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class Ledger {
|
public class Ledger {
|
||||||
// lookahead parameters as suggest on
|
// 5:20 is same as wallet2.cpp::restore()
|
||||||
// https://monero.stackexchange.com/a/9902/8977 (Step 8)
|
static public final int LOOKAHEAD_ACCOUNTS = 5;
|
||||||
// by dEBRUYNE
|
static public final int LOOKAHEAD_SUBADDRESSES = 20;
|
||||||
static public final int LOOKAHEAD_ACCOUNTS = 3;
|
|
||||||
static public final int LOOKAHEAD_SUBADDRESSES = 100;
|
|
||||||
static public final String SUBADDRESS_LOOKAHEAD = LOOKAHEAD_ACCOUNTS + ":" + LOOKAHEAD_SUBADDRESSES;
|
static public final String SUBADDRESS_LOOKAHEAD = LOOKAHEAD_ACCOUNTS + ":" + LOOKAHEAD_SUBADDRESSES;
|
||||||
|
|
||||||
public static final int SW_OK = 0x9000;
|
public static final int SW_OK = 0x9000;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user