1
mirror of https://github.com/m2049r/xmrwallet synced 2025-09-03 08:23:04 +02:00

Compare commits

...

24 Commits

Author SHA1 Message Date
m2049r
0e187d3b20 version 2017-11-02 22:52:13 +01:00
m2049r
716b830b7b Tweaks based on alpha feedback (#110)
* donation+privacy policy screens + bugfixes

* opacity

* mnemonic left aligned

* smaller scan button

* spread out fabs

* doExchnage on lose focus of amount

* specify wallet create type
2017-11-02 22:48:20 +01:00
m2049r
4ac6a03d63 rename fresh wallet (no cachefile) (#109) 2017-11-02 11:46:03 +01:00
m2049r
7eb86ea618 tx details consistent with tx list (#107) 2017-11-01 20:33:58 +01:00
Stephan Hagios
4cfd166ed7 Adjusted visibility of fields and methods. (#102)
* Adjusted visibility of fields and methods.

* Adjusted visibility of fields and methods after rebase
2017-11-01 19:47:24 +01:00
m2049r
44f241f4ee fix progress dialog not showing (#106)
also, new version
2017-11-01 19:26:18 +01:00
m2049r
62b77fc987 no more animation because of OOMs (#105) 2017-11-01 10:56:47 +01:00
m2049r
03c5569f91 Sexy UI (#104)
Version 29/1.1.2-alpha
2017-10-31 22:35:23 +01:00
m2049r
7b1e6a89ba Android Studio 3.0 2017-10-26 09:18:13 +02:00
m2049r
ff8a3ee7c8 JNI_FALSE -> NULL in GetStringUTFChars()
increased version to 26 / 1.0.3
2017-10-22 12:08:38 +02:00
m2049r
dcbaa35b57 avoid calling isAddressValid with null address 2017-10-17 14:48:45 +02:00
Jonathan Cross
3466116e2a Adding note about name of backups folder changing. (#99) 2017-10-07 20:07:58 +02:00
Steve Divskinsy
59e87e2bfe Fixed spelling mistake (#98)
Minor spelling mistake when archiving
2017-10-07 20:05:12 +02:00
m2049r
e8b749af3b Bugfix Service restart after OS kill (#96)
* single open wallet

* prevent WalletService & Activity from restarting
removed stray png
2017-10-03 22:45:03 +02:00
m2049r
f282f01edd wallet updateStatus only when added (#95) 2017-10-03 19:04:45 +02:00
KeeJef
f16afdbb19 Some spelling and grammar changes (#94) 2017-10-03 18:39:29 +02:00
m2049r
ccacec9d0b Added explicit info about keeping mnemonic seed safe (#92) 2017-09-30 09:17:47 +02:00
m2049r
9ebacb8528 corrected backups folder 2017-09-29 23:20:38 +02:00
m2049r
49a9f84226 new version 23 2017-09-29 19:50:59 +02:00
m2049r
91b4aaad60 removed unnecessary permission 2017-09-29 19:44:43 +02:00
m2049r
c4ce12ceff Explain permissions 2017-09-29 19:41:22 +02:00
m2049r
96cf9ee95e new version (#91) 2017-09-29 19:21:11 +02:00
m2049r
00852da9f7 Add some Help (#90)
* simple help for create wallet

* toast that selecting seed or spendkey is not allowed
2017-09-29 19:18:07 +02:00
m2049r
15b90e7ebc instructions now cater for zeromq & non-zermq monero 2017-09-28 09:30:15 +02:00
143 changed files with 6112 additions and 2369 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@
/captures
.externalNativeBuild
.DS_Store
/app/release

1
.idea/.gitignore generated vendored
View File

@@ -1,2 +1,3 @@
workspace.xml
markdown-*
misc.xml

View File

@@ -1,10 +0,0 @@
<component name="libraryTable">
<library name="constraint-layout-1.0.2">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/983cd9976ef510b2538361561f2ee91f1200f245/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/983cd9976ef510b2538361561f2ee91f1200f245/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="constraint-layout-solver-1.0.2">
<CLASSES>
<root url="jar://$USER_HOME$/AppData/Local/Android/Sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/constraint-layout-solver-1.0.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,10 +0,0 @@
<component name="libraryTable">
<library name="core-1.9.8">
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/db7eb580bfa6467818ef12c5f1fa42273b50aa3a/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/db7eb580bfa6467818ef12c5f1fa42273b50aa3a/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="core-3.3.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.zxing/core/3.3.0/73c49077166faa4c3c0059c5f583d1d7bd1475fe/core-3.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.zxing/core/3.3.0/39d966e052e28fc7d83793b02e0af97ccf955745/core-3.3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -1,10 +0,0 @@
<component name="libraryTable">
<library name="zxing-1.9.8">
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/8d8f2e0e10c7af73321454f6fa481e8e5438e654/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/8d8f2e0e10c7af73321454f6fa481e8e5438e654/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

46
.idea/misc.xml generated
View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View File

@@ -14,14 +14,13 @@ You may lose all your Moneroj if you use this App. Be cautious when spending on
- Based off monero v0.11.0.0 with PR #2289 applied
- currently only android32 (runs on 64-bit as well)
- works on the testnet & mainnet
- takes forever to sync due to 32-bit architecture
- sync is slow due to 32-bit architecture
- use your own daemon - it's easy
- screen stays on until first sync is complete
- saves wallet only on first sync and when sending transactions or editing notes
- Monerujo means "Monero Wallet" according to https://www.reddit.com/r/Monero/comments/3exy7t/esperanto_corner/
### TODO
- review visibility of methods/classes
- more sensible error dialogs
### Issues / Pitfalls

View File

@@ -3,13 +3,13 @@ apply plugin: 'witness'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.m2049r.xmrwallet"
minSdkVersion 21
targetSdkVersion 25
versionCode 21
versionName "0.8.0.8"
versionCode 31
versionName "1.1.3-alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {

View File

@@ -3,7 +3,6 @@
package="com.m2049r.xmrwallet">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

View File

@@ -215,7 +215,7 @@ std::vector<std::string> java2cpp(JNIEnv *env, jobject arrayList) {
for (jint i = 0; i < len; i++) {
jstring element = static_cast<jstring>(env->CallObjectMethod(arrayList,
java_util_ArrayList_get, i));
const char *pchars = env->GetStringUTFChars(element, JNI_FALSE);
const char *pchars = env->GetStringUTFChars(element, NULL);
result.emplace_back(pchars);
env->ReleaseStringUTFChars(element, pchars);
env->DeleteLocalRef(element);
@@ -254,9 +254,9 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletJ(JNIEnv *env, jobject
jstring path, jstring password,
jstring language,
jboolean isTestNet) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_password = env->GetStringUTFChars(password, JNI_FALSE);
const char *_language = env->GetStringUTFChars(language, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
const char *_password = env->GetStringUTFChars(password, NULL);
const char *_language = env->GetStringUTFChars(language, NULL);
Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->createWallet(
@@ -275,8 +275,8 @@ JNIEXPORT jlong JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_openWalletJ(JNIEnv *env, jobject instance,
jstring path, jstring password,
jboolean isTestNet) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_password = env->GetStringUTFChars(password, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
const char *_password = env->GetStringUTFChars(password, NULL);
Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->openWallet(
@@ -294,8 +294,8 @@ Java_com_m2049r_xmrwallet_model_WalletManager_recoveryWalletJ(JNIEnv *env, jobje
jstring path, jstring mnemonic,
jboolean isTestNet,
jlong restoreHeight) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_mnemonic = env->GetStringUTFChars(mnemonic, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
const char *_mnemonic = env->GetStringUTFChars(mnemonic, NULL);
Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->recoveryWallet(
@@ -317,11 +317,11 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromKeysJ(JNIEnv *env,
jstring addressString,
jstring viewKeyString,
jstring spendKeyString) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_language = env->GetStringUTFChars(language, JNI_FALSE);
const char *_addressString = env->GetStringUTFChars(addressString, JNI_FALSE);
const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, JNI_FALSE);
const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
const char *_language = env->GetStringUTFChars(language, NULL);
const char *_addressString = env->GetStringUTFChars(addressString, NULL);
const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, NULL);
const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, NULL);
Bitmonero::Wallet *wallet =
Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromKeys(
@@ -344,7 +344,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromKeysJ(JNIEnv *env,
JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_walletExists(JNIEnv *env, jobject instance,
jstring path) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
bool exists =
Bitmonero::WalletManagerFactory::getWalletManager()->walletExists(std::string(_path));
env->ReleaseStringUTFChars(path, _path);
@@ -356,8 +356,8 @@ Java_com_m2049r_xmrwallet_model_WalletManager_verifyWalletPassword(JNIEnv *env,
jstring keys_file_name,
jstring password,
jboolean watch_only) {
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, JNI_FALSE);
const char *_password = env->GetStringUTFChars(password, JNI_FALSE);
const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL);
const char *_password = env->GetStringUTFChars(password, NULL);
bool passwordOk =
Bitmonero::WalletManagerFactory::getWalletManager()->verifyWalletPassword(
std::string(_keys_file_name), std::string(_password), watch_only);
@@ -370,7 +370,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_verifyWalletPassword(JNIEnv *env,
JNIEXPORT jobject JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject instance,
jstring path) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
std::vector<std::string> walletPaths =
Bitmonero::WalletManagerFactory::getWalletManager()->findWallets(std::string(_path));
env->ReleaseStringUTFChars(path, _path);
@@ -388,7 +388,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_getErrorString(JNIEnv *env, jobjec
JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_setDaemonAddressJ(JNIEnv *env, jobject instance,
jstring address) {
const char *_address = env->GetStringUTFChars(address, JNI_FALSE);
const char *_address = env->GetStringUTFChars(address, NULL);
Bitmonero::WalletManagerFactory::getWalletManager()->setDaemonAddress(std::string(_address));
env->ReleaseStringUTFChars(address, _address);
}
@@ -440,7 +440,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_startMining(JNIEnv *env, jobject i
jstring address,
jboolean background_mining,
jboolean ignore_battery) {
const char *_address = env->GetStringUTFChars(address, JNI_FALSE);
const char *_address = env->GetStringUTFChars(address, NULL);
bool success =
Bitmonero::WalletManagerFactory::getWalletManager()->startMining(std::string(_address),
background_mining,
@@ -458,7 +458,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_WalletManager_resolveOpenAlias(JNIEnv *env, jobject instance,
jstring address,
jboolean dnssec_valid) {
const char *_address = env->GetStringUTFChars(address, JNI_FALSE);
const char *_address = env->GetStringUTFChars(address, NULL);
bool _dnssec_valid = (bool) dnssec_valid;
std::string resolvedAlias =
Bitmonero::WalletManagerFactory::getWalletManager()->resolveOpenAlias(
@@ -510,7 +510,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getSeedLanguage(JNIEnv *env, jobject inst
JNIEXPORT void JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setSeedLanguage(JNIEnv *env, jobject instance,
jstring language) {
const char *_language = env->GetStringUTFChars(language, JNI_FALSE);
const char *_language = env->GetStringUTFChars(language, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
wallet->setSeedLanguage(std::string(_language));
env->ReleaseStringUTFChars(language, _language);
@@ -531,7 +531,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getErrorString(JNIEnv *env, jobject insta
JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setPassword(JNIEnv *env, jobject instance,
jstring password) {
const char *_password = env->GetStringUTFChars(password, JNI_FALSE);
const char *_password = env->GetStringUTFChars(password, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool success = wallet->setPassword(std::string(_password));
env->ReleaseStringUTFChars(password, _password);
@@ -562,7 +562,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isTestNet(JNIEnv *env, jobject instance)
JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getIntegratedAddress(JNIEnv *env, jobject instance,
jstring payment_id) {
const char *_payment_id = env->GetStringUTFChars(payment_id, JNI_FALSE);
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
std::string address = wallet->integratedAddress(_payment_id);
env->ReleaseStringUTFChars(payment_id, _payment_id);
@@ -584,7 +584,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getSecretSpendKey(JNIEnv *env, jobject in
JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_store(JNIEnv *env, jobject instance,
jstring path) {
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
const char *_path = env->GetStringUTFChars(path, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool success = wallet->store(std::string(_path));
if (!success) {
@@ -607,9 +607,9 @@ Java_com_m2049r_xmrwallet_model_Wallet_initJ(JNIEnv *env, jobject instance,
jstring daemon_address,
jlong upper_transaction_size_limit,
jstring daemon_username, jstring daemon_password) {
const char *_daemon_address = env->GetStringUTFChars(daemon_address, JNI_FALSE);
const char *_daemon_username = env->GetStringUTFChars(daemon_username, JNI_FALSE);
const char *_daemon_password = env->GetStringUTFChars(daemon_password, JNI_FALSE);
const char *_daemon_address = env->GetStringUTFChars(daemon_address, NULL);
const char *_daemon_username = env->GetStringUTFChars(daemon_username, NULL);
const char *_daemon_password = env->GetStringUTFChars(daemon_password, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
bool status = wallet->init(_daemon_address, upper_transaction_size_limit, _daemon_username,
_daemon_password);
@@ -691,7 +691,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jobject cla
JNIEXPORT jlong JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jobject clazz,
jstring amount) {
const char *_amount = env->GetStringUTFChars(amount, JNI_FALSE);
const char *_amount = env->GetStringUTFChars(amount, NULL);
uint64_t x = Bitmonero::Wallet::amountFromString(_amount);
env->ReleaseStringUTFChars(amount, _amount);
return x;
@@ -711,7 +711,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_generatePaymentId(JNIEnv *env, jobject cl
JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jobject clazz,
jstring payment_id) {
const char *_payment_id = env->GetStringUTFChars(payment_id, JNI_FALSE);
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL);
bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id);
env->ReleaseStringUTFChars(payment_id, _payment_id);
return isValid;
@@ -720,7 +720,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jobject cla
JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jobject clazz,
jstring address, jboolean isTestNet) {
const char *_address = env->GetStringUTFChars(address, JNI_FALSE);
const char *_address = env->GetStringUTFChars(address, NULL);
bool isValid = Bitmonero::Wallet::addressValid(_address, isTestNet);
env->ReleaseStringUTFChars(address, _address);
return isValid;
@@ -732,7 +732,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jobject clazz,
jstring address,
jboolean isTestNet) {
const char *_address = env->GetStringUTFChars(address, JNI_FALSE);
const char *_address = env->GetStringUTFChars(address, NULL);
std::string payment_id = Bitmonero::Wallet::paymentIdFromAddress(_address, isTestNet);
env->ReleaseStringUTFChars(address, _address);
return env->NewStringUTF(payment_id.c_str());
@@ -776,8 +776,8 @@ Java_com_m2049r_xmrwallet_model_Wallet_createTransactionJ(JNIEnv *env, jobject i
jlong amount, jint mixin_count,
jint priority) {
const char *_dst_addr = env->GetStringUTFChars(dst_addr, JNI_FALSE);
const char *_payment_id = env->GetStringUTFChars(payment_id, JNI_FALSE);
const char *_dst_addr = env->GetStringUTFChars(dst_addr, NULL);
const char *_payment_id = env->GetStringUTFChars(payment_id, NULL);
Bitmonero::PendingTransaction::Priority _priority =
static_cast<Bitmonero::PendingTransaction::Priority>(priority);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@@ -862,8 +862,8 @@ JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_setUserNote(JNIEnv *env, jobject instance,
jstring txid, jstring note) {
const char *_txid = env->GetStringUTFChars(txid, JNI_FALSE);
const char *_note = env->GetStringUTFChars(note, JNI_FALSE);
const char *_txid = env->GetStringUTFChars(txid, NULL);
const char *_note = env->GetStringUTFChars(note, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@@ -879,7 +879,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getUserNote(JNIEnv *env, jobject instance,
jstring txid) {
const char *_txid = env->GetStringUTFChars(txid, JNI_FALSE);
const char *_txid = env->GetStringUTFChars(txid, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@@ -893,7 +893,7 @@ JNIEXPORT jstring JNICALL
Java_com_m2049r_xmrwallet_model_Wallet_getTxKey(JNIEnv *env, jobject instance,
jstring txid) {
const char *_txid = env->GetStringUTFChars(txid, JNI_FALSE);
const char *_txid = env->GetStringUTFChars(txid, NULL);
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
@@ -1015,7 +1015,7 @@ JNIEXPORT jboolean JNICALL
Java_com_m2049r_xmrwallet_model_PendingTransaction_commit(JNIEnv *env, jobject instance,
jstring filename, jboolean overwrite) {
const char *_filename = env->GetStringUTFChars(filename, JNI_FALSE);
const char *_filename = env->GetStringUTFChars(filename, NULL);
Bitmonero::PendingTransaction *tx = getHandle<Bitmonero::PendingTransaction>(env, instance);
bool success = tx->commit(_filename, overwrite);
@@ -1060,4 +1060,3 @@ Java_com_m2049r_xmrwallet_model_PendingTransaction_getTxCount(JNIEnv *env, jobje
#ifdef __cplusplus
}
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 245 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -19,17 +19,26 @@ package com.m2049r.xmrwallet;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.layout.Toolbar;
import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.model.WalletManager;
import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
public class GenerateReviewFragment extends Fragment {
@@ -38,6 +47,8 @@ public class GenerateReviewFragment extends Fragment {
static final public String VIEW_TYPE_ACCEPT = "accept";
static final public String VIEW_TYPE_WALLET = "wallet";
ScrollView scrollview;
ProgressBar pbProgress;
TextView tvWalletName;
TextView tvWalletPassword;
@@ -45,14 +56,18 @@ public class GenerateReviewFragment extends Fragment {
TextView tvWalletMnemonic;
TextView tvWalletViewKey;
TextView tvWalletSpendKey;
ImageButton bCopyAddress;
LinearLayout llAdvancedInfo;
Button bAdvancedInfo;
Button bAccept;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.gen_review_fragment, container, false);
View view = inflater.inflate(R.layout.fragment_review, container, false);
scrollview = (ScrollView) view.findViewById(R.id.scrollview);
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
tvWalletName = (TextView) view.findViewById(R.id.tvWalletName);
tvWalletPassword = (TextView) view.findViewById(R.id.tvWalletPassword);
@@ -60,6 +75,9 @@ public class GenerateReviewFragment extends Fragment {
tvWalletViewKey = (TextView) view.findViewById(R.id.tvWalletViewKey);
tvWalletSpendKey = (TextView) view.findViewById(R.id.tvWalletSpendKey);
tvWalletMnemonic = (TextView) view.findViewById(R.id.tvWalletMnemonic);
bCopyAddress = (ImageButton) view.findViewById(R.id.bCopyAddress);
bAdvancedInfo = (Button) view.findViewById(R.id.bAdvancedInfo);
llAdvancedInfo = (LinearLayout) view.findViewById(R.id.llAdvancedInfo);
bAccept = (Button) view.findViewById(R.id.bAccept);
@@ -73,6 +91,36 @@ public class GenerateReviewFragment extends Fragment {
acceptWallet();
}
});
view.findViewById(R.id.bCopyViewKey).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyViewKey();
}
});
bCopyAddress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyAddress();
}
});
view.findViewById(R.id.bCopySeed).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nocopy();
}
});
view.findViewById(R.id.bCopySepndKey).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nocopy();
}
});
view.findViewById(R.id.bAdvancedInfo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAdvancedInfo();
}
});
showProgress();
@@ -85,6 +133,31 @@ public class GenerateReviewFragment extends Fragment {
return view;
}
void copyViewKey() {
Helper.clipBoardCopy(getActivity(), getString(R.string.label_copy_viewkey), tvWalletViewKey.getText().toString());
Toast.makeText(getActivity(), getString(R.string.message_copy_viewkey), Toast.LENGTH_SHORT).show();
}
void copyAddress() {
Helper.clipBoardCopy(getActivity(), getString(R.string.label_copy_address), tvWalletAddress.getText().toString());
Toast.makeText(getActivity(), getString(R.string.message_copy_address), Toast.LENGTH_SHORT).show();
}
void nocopy() {
Toast.makeText(getActivity(), getString(R.string.message_nocopy), Toast.LENGTH_SHORT).show();
}
void showAdvancedInfo() {
llAdvancedInfo.setVisibility(View.VISIBLE);
bAdvancedInfo.setVisibility(View.GONE);
scrollview.post(new Runnable() {
@Override
public void run() {
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
String type;
private void acceptWallet() {
@@ -130,7 +203,7 @@ public class GenerateReviewFragment extends Fragment {
address = wallet.getAddress();
seed = wallet.getSeed();
viewKey = wallet.getSecretViewKey();
spendKey = isWatchOnly ? getActivity().getString(R.string.watchonly_label) : wallet.getSecretSpendKey();
spendKey = isWatchOnly ? getActivity().getString(R.string.label_watchonly) : wallet.getSecretSpendKey();
isWatchOnly = wallet.isWatchOnly();
if (closeWallet) wallet.close();
return true;
@@ -139,6 +212,7 @@ public class GenerateReviewFragment extends Fragment {
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
if (!isAdded()) return; // never mind
tvWalletName.setText(name);
if (result) {
if (type.equals(GenerateReviewFragment.VIEW_TYPE_ACCEPT)) {
@@ -150,9 +224,14 @@ public class GenerateReviewFragment extends Fragment {
tvWalletMnemonic.setText(seed);
tvWalletViewKey.setText(viewKey);
tvWalletSpendKey.setText(spendKey);
bAdvancedInfo.setVisibility(View.VISIBLE);
bCopyAddress.setEnabled(true);
bCopyAddress.setImageResource(R.drawable.ic_content_copy_black_24dp);
activityCallback.setTitle(name, getString(R.string.details_title));
activityCallback.setToolbarButton(
GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type) ? Toolbar.BUTTON_NONE : Toolbar.BUTTON_BACK);
} else {
// TODO show proper error message
// TODO end the fragment
// TODO show proper error message and/or end the fragment?
tvWalletAddress.setText(status.toString());
tvWalletMnemonic.setText(status.toString());
tvWalletViewKey.setText(status.toString());
@@ -162,41 +241,69 @@ public class GenerateReviewFragment extends Fragment {
}
}
GenerateReviewFragment.Listener acceptCallback = null;
GenerateReviewFragment.ListenerWithWallet walletCallback = null;
Listener activityCallback = null;
AcceptListener acceptCallback = null;
ListenerWithWallet walletCallback = null;
public interface Listener {
void setTitle(String title, String subtitle);
void setToolbarButton(int type);
}
public interface AcceptListener {
void onAccept(String name, String password);
}
public interface ListenerWithWallet {
Wallet getWallet();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof GenerateReviewFragment.Listener) {
this.acceptCallback = (GenerateReviewFragment.Listener) context;
} else if (context instanceof GenerateReviewFragment.ListenerWithWallet) {
this.walletCallback = (GenerateReviewFragment.ListenerWithWallet) context;
} else {
throw new ClassCastException(context.toString()
+ " must implement Listener");
if (context instanceof Listener) {
this.activityCallback = (Listener) context;
}
if (context instanceof AcceptListener) {
this.acceptCallback = (AcceptListener) context;
}
if (context instanceof ListenerWithWallet) {
this.walletCallback = (ListenerWithWallet) context;
}
}
@Override
public void onResume() {
super.onResume();
Log.d(TAG, "onResume()");
String name = tvWalletName.getText().toString();
if (name.isEmpty()) name = null;
activityCallback.setTitle(name, getString(R.string.details_title));
activityCallback.setToolbarButton(
GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type) ? Toolbar.BUTTON_NONE : Toolbar.BUTTON_BACK);
}
public void showProgress() {
pbProgress.setIndeterminate(true);
pbProgress.setVisibility(View.VISIBLE);
}
public void hideProgress() {
pbProgress.setVisibility(View.INVISIBLE);
pbProgress.setVisibility(View.GONE);
}
boolean backOk() {
return !type.equals(GenerateReviewFragment.VIEW_TYPE_ACCEPT);
}
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.wallet_details_menu, menu);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -28,14 +28,13 @@ import android.widget.Toast;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.m2049r.xmrwallet.util.BarcodeData;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
public class ScannerFragment extends Fragment implements ZXingScannerView.ResultHandler {
static final String TAG = "ScannerFragment";
Listener activityCallback;
private Listener activityCallback;
public interface Listener {
boolean onAddressScanned(String uri);
@@ -64,7 +63,6 @@ public class ScannerFragment extends Fragment implements ZXingScannerView.Result
@Override
public void handleResult(Result rawResult) {
//Log.d(TAG, rawResult.getBarcodeFormat().toString() + "/" + rawResult.getText());
if ((rawResult.getBarcodeFormat() == BarcodeFormat.QR_CODE) &&
(rawResult.getText().startsWith(QR_SCHEME))) {
if (activityCallback.onAddressScanned(rawResult.getText())) {
@@ -101,7 +99,6 @@ public class ScannerFragment extends Fragment implements ZXingScannerView.Result
@Override
public void onAttach(Context context) {
super.onAttach(context);
//Log.d(TAG, "attaching scan");
if (context instanceof Listener) {
this.activityCallback = (Listener) context;
} else {

File diff suppressed because it is too large Load Diff

View File

@@ -16,19 +16,22 @@
package com.m2049r.xmrwallet;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.layout.Toolbar;
import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Transfer;
import com.m2049r.xmrwallet.model.Wallet;
@@ -54,24 +57,23 @@ public class TxFragment extends Fragment {
TS_FORMATTER.setTimeZone(tz);
}
TextView tvTxTimestamp;
TextView tvTxId;
TextView tvTxKey;
TextView tvDestination;
TextView tvTxPaymentId;
TextView tvTxBlockheight;
TextView tvTxAmount;
TextView tvTxFee;
TextView tvTxTransfers;
TextView etTxNotes;
Button bCopy;
Button bTxNotes;
private TextView tvTxTimestamp;
private TextView tvTxId;
private TextView tvTxKey;
private TextView tvDestination;
private TextView tvTxPaymentId;
private TextView tvTxBlockheight;
private TextView tvTxAmount;
private TextView tvTxFee;
private TextView tvTxTransfers;
private TextView etTxNotes;
private Button bTxNotes;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tx_fragment, container, false);
View view = inflater.inflate(R.layout.fragment_tx_info, container, false);
tvTxTimestamp = (TextView) view.findViewById(R.id.tvTxTimestamp);
tvTxId = (TextView) view.findViewById(R.id.tvTxId);
@@ -83,18 +85,10 @@ public class TxFragment extends Fragment {
tvTxFee = (TextView) view.findViewById(R.id.tvTxFee);
tvTxTransfers = (TextView) view.findViewById(R.id.tvTxTransfers);
etTxNotes = (TextView) view.findViewById(R.id.etTxNotes);
bCopy = (Button) view.findViewById(R.id.bCopy);
bTxNotes = (Button) view.findViewById(R.id.bTxNotes);
etTxNotes.setRawInputType(InputType.TYPE_CLASS_TEXT);
bCopy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
copyToClipboard();
}
});
bTxNotes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -119,28 +113,35 @@ public class TxFragment extends Fragment {
}
}
void copyToClipboard() {
void shareTxInfo() {
if (this.info == null) return;
StringBuffer sb = new StringBuffer();
sb.append(getString(R.string.tx_address)).append(": ");
sb.append(activityCallback.getWalletAddress()).append("\n");
sb.append(getString(R.string.tx_id)).append(": ");
sb.append(info.hash).append("\n");
sb.append(getString(R.string.tx_key)).append(": ");
sb.append(info.txKey.isEmpty() ? "-" : info.txKey).append("\n");
sb.append(getString(R.string.tx_paymentId)).append(": ");
sb.append(info.paymentId).append("\n");
sb.append(getString(R.string.tx_amount)).append(": ");
sb.append(getString(R.string.tx_timestamp)).append(":\n");
sb.append(TS_FORMATTER.format(new Date(info.timestamp * 1000))).append("\n\n");
sb.append(getString(R.string.tx_amount)).append(":\n");
sb.append((info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-"));
sb.append(Wallet.getDisplayAmount(info.amount)).append("\n");
sb.append(getString(R.string.tx_fee)).append(": ");
sb.append(Wallet.getDisplayAmount(info.fee)).append("\n");
sb.append(getString(R.string.tx_notes)).append(": ");
sb.append(getString(R.string.tx_fee)).append(":\n");
sb.append(Wallet.getDisplayAmount(info.fee)).append("\n\n");
sb.append(getString(R.string.tx_notes)).append(":\n");
String oneLineNotes = info.notes.replace("\n", " ; ");
sb.append(oneLineNotes.isEmpty() ? "-" : oneLineNotes).append("\n");
sb.append(getString(R.string.tx_timestamp)).append(": ");
sb.append(TS_FORMATTER.format(new Date(info.timestamp * 1000))).append("\n");
sb.append(getString(R.string.tx_blockheight)).append(": ");
sb.append(oneLineNotes.isEmpty() ? "-" : oneLineNotes).append("\n\n");
sb.append(getString(R.string.tx_destination)).append(":\n");
sb.append(tvDestination.getText()).append("\n\n");
sb.append(getString(R.string.tx_paymentId)).append(":\n");
sb.append(info.paymentId).append("\n\n");
sb.append(getString(R.string.tx_id)).append(":\n");
sb.append(info.hash).append("\n");
sb.append(getString(R.string.tx_key)).append(":\n");
sb.append(info.txKey.isEmpty() ? "-" : info.txKey).append("\n\n");
sb.append(getString(R.string.tx_blockheight)).append(":\n");
if (info.isFailed) {
sb.append(getString(R.string.tx_failed)).append("\n");
} else if (info.isPending) {
@@ -148,7 +149,9 @@ public class TxFragment extends Fragment {
} else {
sb.append(info.blockheight).append("\n");
}
sb.append(getString(R.string.tx_transfers)).append(": ");
sb.append("\n");
sb.append(getString(R.string.tx_transfers)).append(":\n");
if (info.transfers != null) {
boolean comma = false;
for (Transfer transfer : info.transfers) {
@@ -163,12 +166,14 @@ public class TxFragment extends Fragment {
} else {
sb.append("-");
}
sb.append("\n");
ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(getString(R.string.tx_copy_label), sb.toString());
clipboardManager.setPrimaryClip(clip);
Toast.makeText(getActivity(), getString(R.string.tx_copy_message), Toast.LENGTH_SHORT).show();
//Log.d(TAG, sb.toString());
sb.append("\n\n");
//Helper.clipBoardCopy(getActivity(), getString(R.string.tx_copy_label), sb.toString());
//Toast.makeText(getActivity(), getString(R.string.tx_copy_message), Toast.LENGTH_SHORT).show();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, null));
}
TransactionInfo info = null;
@@ -176,17 +181,24 @@ public class TxFragment extends Fragment {
void loadNotes(TransactionInfo info) {
if (info.notes == null) {
info.notes = activityCallback.getTxNotes(info.hash);
//Log.d(TAG, "NOTES:" + info.notes + ":");
}
etTxNotes.setText(info.notes);
}
private void setTxColour(int clr) {
tvTxAmount.setTextColor(clr);
tvTxFee.setTextColor(clr);
}
private void show(TransactionInfo info) {
if (info.txKey == null) {
info.txKey = activityCallback.getTxKey(info.hash);
//Log.d(TAG, "TXKEY:" + info.txKey + ":");
}
loadNotes(info);
activityCallback.setSubtitle(getString(R.string.tx_title));
activityCallback.setToolbarButton(Toolbar.BUTTON_BACK);
tvTxTimestamp.setText(TS_FORMATTER.format(new Date(info.timestamp * 1000)));
tvTxId.setText(info.hash);
tvTxKey.setText(info.txKey.isEmpty() ? "-" : info.txKey);
@@ -199,8 +211,32 @@ public class TxFragment extends Fragment {
tvTxBlockheight.setText("" + info.blockheight);
}
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
long realAmount = info.amount;
if (info.isPending) {
realAmount = realAmount - info.fee;
}
tvTxAmount.setText(sign + Wallet.getDisplayAmount(realAmount));
if ((info.fee > 0)) {
String fee = Wallet.getDisplayAmount(info.fee);
tvTxFee.setText(getString(R.string.tx_list_fee, fee));
} else {
tvTxFee.setText(null);
tvTxFee.setVisibility(View.GONE);
}
if (info.isFailed) {
tvTxAmount.setText(getString(R.string.tx_list_amount_failed, Wallet.getDisplayAmount(info.amount)));
tvTxFee.setText(getString(R.string.tx_list_failed_text));
setTxColour(ContextCompat.getColor(getContext(), R.color.tx_failed));
} else if (info.isPending) {
setTxColour(ContextCompat.getColor(getContext(), R.color.tx_pending));
} else if (info.direction == TransactionInfo.Direction.Direction_In) {
setTxColour(ContextCompat.getColor(getContext(), R.color.tx_green));
} else {
setTxColour(ContextCompat.getColor(getContext(), R.color.tx_red));
}
Set<String> destinations = new HashSet<>();
StringBuffer sb = new StringBuffer();
StringBuffer dstSb = new StringBuffer();
@@ -232,10 +268,21 @@ public class TxFragment extends Fragment {
tvTxTransfers.setText(sb.toString());
tvDestination.setText(dstSb.toString());
this.info = info;
bCopy.setEnabled(true);
}
TxFragment.Listener activityCallback;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.tx_info_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
Listener activityCallback;
public interface Listener {
String getWalletAddress();
@@ -246,6 +293,10 @@ public class TxFragment extends Fragment {
void onSetNote(String txId, String notes);
void setToolbarButton(int type);
void setSubtitle(String subtitle);
}
@Override

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,114 @@
/*
* 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.
*/
/**
* Based on work by Adam Speakman http://speakman.net.nz
*/
package com.m2049r.xmrwallet.dialog;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.BuildConfig;
import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.util.Helper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class DonationFragment extends DialogFragment {
static final String TAG = "DonationFragment";
private static final String FRAGMENT_TAG = "com.m2049r.xmrwalelt.dialog.DonationFragment";
/**
* Creates a new instance of LicensesFragment with no Close button.
*
* @return A new licenses fragment.
*/
public static DonationFragment newInstance() {
return new DonationFragment();
}
/**
* Builds and displays a licenses fragment with no Close button. Requires
* "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be
* present.
*
* @param fm A fragment manager instance used to display this LicensesFragment.
*/
public static void display(FragmentManager fm) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = DonationFragment.newInstance();
newFragment.show(ft, FRAGMENT_TAG);
}
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_donation, null);
((TextView) view.findViewById(R.id.tvCredits)).setText(Html.fromHtml(getString(R.string.donation_credits)));
((ImageButton) view.findViewById(R.id.bCopyAddress)).
setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.clipBoardCopy(getActivity(), getString(R.string.label_copy_address),
((TextView) view.findViewById(R.id.tvWalletAddress)).getText().toString());
Toast.makeText(getActivity(), getString(R.string.message_copy_address), Toast.LENGTH_SHORT).show();
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(view);
builder.setNegativeButton(R.string.about_close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
}

View File

@@ -0,0 +1,161 @@
/**
* Copyright 2013 Adam Speakman, 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.
*/
package com.m2049r.xmrwallet.dialog;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.ProgressBar;
import com.m2049r.xmrwallet.R;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Based on LicensesFragment by Adam Speakman on 24/09/13.
* http://speakman.net.nz
*/
public class HelpFragment extends DialogFragment {
static final String TAG = "HelpFragment";
private static final String FRAGMENT_TAG = "com.m2049r.xmrwallet.dialog.HelpFragment";
private static final String HELP_ID = "HELP_ID";
private AsyncTask<Void, Void, String> loader;
public static HelpFragment newInstance(int helpResourceId) {
HelpFragment fragment = new HelpFragment();
Bundle bundle = new Bundle();
bundle.putInt(HELP_ID, helpResourceId);
fragment.setArguments(bundle);
return fragment;
}
/**
* @param fm A fragment manager instance used to display this LicensesFragment.
*/
public static void displayHelp(FragmentManager fm, int helpResourceId) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
if (prev != null) {
ft.remove(prev);
}
// Create and show the dialog.
DialogFragment newFragment = HelpFragment.newInstance(helpResourceId);
newFragment.show(ft, FRAGMENT_TAG);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int helpId = 0;
Bundle arguments = getArguments();
if (arguments != null) {
helpId = arguments.getInt(HELP_ID);
}
if (helpId > 0)
loadHelp(helpId);
}
@Override
public void onDestroy() {
super.onDestroy();
if (loader != null) {
loader.cancel(true);
}
}
private WebView webView;
private ProgressBar progress;
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View content = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_help, null);
webView = (WebView) content.findViewById(R.id.helpFragmentWebView);
progress = (ProgressBar) content.findViewById(R.id.helpFragmentProgress);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(content);
builder.setNegativeButton(R.string.about_close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
private void loadHelp(final int helpResourceId) {
// Load asynchronously in case of a very large file.
loader = new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
InputStream rawResource = getActivity().getResources().openRawResource(helpResourceId);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(rawResource));
String line;
StringBuilder sb = new StringBuilder();
try {
while ((line = bufferedReader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
bufferedReader.close();
} catch (IOException ex) {
Log.e(TAG, ex.getLocalizedMessage());
}
return sb.toString();
}
@Override
protected void onPostExecute(String licensesBody) {
super.onPostExecute(licensesBody);
if (getActivity() == null || isCancelled()) {
return;
}
progress.setVisibility(View.INVISIBLE);
webView.setVisibility(View.VISIBLE);
webView.loadDataWithBaseURL(null, licensesBody, "text/html", "utf-8", null);
loader = null;
}
}.execute();
}
}

View File

@@ -14,12 +14,7 @@
* limitations under the License.
*/
package com.m2049r.xmrwallet.license;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
package com.m2049r.xmrwallet.dialog;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
@@ -27,11 +22,11 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
//TODO If you don't support Android 2.x, you should use the non-support version!
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
@@ -41,18 +36,23 @@ import android.widget.TextView;
import com.m2049r.xmrwallet.BuildConfig;
import com.m2049r.xmrwallet.R;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Created by Adam Speakman on 24/09/13.
* http://speakman.net.nz
*/
public class LicensesFragment extends DialogFragment {
static final String TAG = "LicensesFragment";
int versionCode = BuildConfig.VERSION_CODE;
String versionName = BuildConfig.VERSION_NAME;
private AsyncTask<Void, Void, String> mLicenseLoader;
private static final String FRAGMENT_TAG = "nz.net.speakman.androidlicensespage.LicensesFragment";
private static final String KEY_SHOW_CLOSE_BUTTON = "keyShowCloseButton";
private static final String FRAGMENT_TAG = "com.m2049r.xmrwalelt.dialog.LicensesFragment";
/**
* Creates a new instance of LicensesFragment with no Close button.
@@ -63,22 +63,6 @@ public class LicensesFragment extends DialogFragment {
return new LicensesFragment();
}
/**
* Creates a new instance of LicensesFragment with an optional Close button.
*
* @param showCloseButton Whether to show a Close button at the bottom of the dialog.
* @return A new licenses fragment.
*/
public static LicensesFragment newInstance(boolean showCloseButton) {
LicensesFragment fragment = new LicensesFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_SHOW_CLOSE_BUTTON, showCloseButton);
fragment.setArguments(bundle);
return fragment;
}
/**
* Builds and displays a licenses fragment with no Close button. Requires
* "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be
@@ -99,27 +83,6 @@ public class LicensesFragment extends DialogFragment {
newFragment.show(ft, FRAGMENT_TAG);
}
/**
* Builds and displays a licenses fragment with or without a Close button.
* Requires "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml"
* to be present.
*
* @param fm A fragment manager instance used to display this LicensesFragment.
* @param showCloseButton Whether to show a Close button at the bottom of the dialog.
*/
public static void displayLicensesFragment(FragmentManager fm, boolean showCloseButton) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = LicensesFragment.newInstance(showCloseButton);
newFragment.show(ft, FRAGMENT_TAG);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -140,30 +103,22 @@ public class LicensesFragment extends DialogFragment {
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View content = LayoutInflater.from(getActivity()).inflate(R.layout.licenses_fragment, null);
View content = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_licenses, null);
mWebView = (WebView) content.findViewById(R.id.licensesFragmentWebView);
mIndeterminateProgress = (ProgressBar) content.findViewById(R.id.licensesFragmentIndeterminateProgress);
boolean showCloseButton = true;
Bundle arguments = getArguments();
if (arguments != null) {
showCloseButton = arguments.getBoolean(KEY_SHOW_CLOSE_BUTTON);
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
TextView text = (TextView) content.findViewById(R.id.text);
TextView text = (TextView) content.findViewById(R.id.licensesFragmentText);
text.setText(getString(R.string.about_text, versionName, versionCode));
builder.setView(content);
if (showCloseButton) {
builder.setNegativeButton(R.string.about_close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
}
builder.setNegativeButton(R.string.about_close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
@@ -186,8 +141,8 @@ public class LicensesFragment extends DialogFragment {
sb.append("\n");
}
bufferedReader.close();
} catch (IOException e) {
// TODO You may want to include some logging here.
} catch (IOException ex) {
Log.e(TAG, ex.getLocalizedMessage());
}
return sb.toString();

View File

@@ -0,0 +1,93 @@
/*
* 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.
*/
/**
* Based on work by Adam Speakman http://speakman.net.nz
*/
package com.m2049r.xmrwallet.dialog;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.util.Helper;
public class PrivacyFragment extends DialogFragment {
static final String TAG = "PrivacyFragment";
private static final String FRAGMENT_TAG = "com.m2049r.xmrwalelt.dialog.PrivacyFragment";
/**
* Creates a new instance of LicensesFragment with no Close button.
*
* @return A new licenses fragment.
*/
public static PrivacyFragment newInstance() {
return new PrivacyFragment();
}
/**
* Builds and displays a licenses fragment with no Close button. Requires
* "/res/raw/licenses.html" and "/res/layout/licenses_fragment.xml" to be
* present.
*
* @param fm A fragment manager instance used to display this LicensesFragment.
*/
public static void display(FragmentManager fm) {
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(FRAGMENT_TAG);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = PrivacyFragment.newInstance();
newFragment.show(ft, FRAGMENT_TAG);
}
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_privacy_policy, null);
((TextView) view.findViewById(R.id.tvCredits)).setText(Html.fromHtml(getString(R.string.privacy_policy)));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(view);
builder.setNegativeButton(R.string.about_close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
return builder.create();
}
}

View File

@@ -0,0 +1,159 @@
/*
* 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.layout;
import android.os.AsyncTask;
import android.util.Log;
import com.m2049r.xmrwallet.util.Helper;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.ref.WeakReference;
public class AsyncExchangeRate extends AsyncTask<String, Void, Boolean> {
static final String TAG = "AsyncExchangeRate";
static final long TIME_REFRESH_INTERVAL = 60000; // refresh exchange rate max every minute
public interface Listener {
void exchangeFailed();
// callback from AsyncExchangeRate when we have a rate
void exchange(String currencyA, String currencyB, double rate);
}
static long RateTime = 0;
static double Rate = 0;
static String Fiat = null;
private final WeakReference<Listener> exchangeViewRef;
public AsyncExchangeRate(Listener exchangeView) {
super();
exchangeViewRef = new WeakReference<>(exchangeView);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
boolean inverse = false;
String currencyA = null;
String currencyB = null;
@Override
protected Boolean doInBackground(String... params) {
if (params.length != 2) return false;
Log.d(TAG, "Getting " + params[0]);
currencyA = params[0];
currencyB = params[1];
String fiat = null;
if (currencyA.equals("XMR")) {
fiat = currencyB;
inverse = false;
}
if (currencyB.equals("XMR")) {
fiat = currencyA;
inverse = true;
}
if (currencyA.equals(currencyB)) {
Fiat = null;
Rate = 1;
RateTime = System.currentTimeMillis();
return true;
}
if (fiat == null) {
Fiat = null;
Rate = 0;
RateTime = 0;
return false;
}
if (!fiat.equals(Fiat)) { // new currency - reset all
Fiat = fiat;
Rate = 0;
RateTime = 0;
}
if (System.currentTimeMillis() > RateTime + TIME_REFRESH_INTERVAL) {
Log.d(TAG, "Fetching " + Fiat);
String closePrice = getExchangeRate(Fiat);
if (closePrice != null) {
try {
Rate = Double.parseDouble(closePrice);
RateTime = System.currentTimeMillis();
return true;
} catch (NumberFormatException ex) {
Rate = 0;
Log.e(TAG, ex.getLocalizedMessage());
return false;
}
} else {
Rate = 0;
Log.e(TAG, "exchange url failed");
return false;
}
}
return true; // no change but still valid
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
Listener exchangeView = exchangeViewRef.get();
if (result) {
Log.d(TAG, "yay! = " + Rate);
if (exchangeView != null) {
exchangeView.exchange(currencyA, currencyB, inverse ? (1 / Rate) : Rate);
}
} else {
Log.d(TAG, "nay!");
if (exchangeView != null) {
exchangeView.exchangeFailed();
}
}
}
// "https://api.kraken.com/0/public/Ticker?pair=XMREUR"
String getExchangeRate(String fiat) {
String jsonResponse =
Helper.getUrl("https://api.kraken.com/0/public/Ticker?pair=XMR" + fiat);
if (jsonResponse == null) return null;
try {
JSONObject response = new JSONObject(jsonResponse);
JSONArray errors = response.getJSONArray("error");
Log.e(TAG, "errors=" + errors.toString());
if (errors.length() == 0) {
JSONObject result = response.getJSONObject("result");
JSONObject pair = result.getJSONObject("XXMRZ" + fiat);
JSONArray close = pair.getJSONArray("c");
String closePrice = close.getString(0);
Log.d(TAG, "closePrice=" + closePrice);
return closePrice;
}
} catch (JSONException ex) {
Log.e(TAG, ex.getLocalizedMessage());
}
return null;
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.
*/
// based on from https://stackoverflow.com/a/45325876 (which did not work for me)
package com.m2049r.xmrwallet.layout;
import android.content.Context;
import android.support.design.widget.TextInputLayout;
import android.util.AttributeSet;
import android.widget.EditText;
public class CTextInputLayout extends TextInputLayout {
public CTextInputLayout(Context context) {
super(context);
}
public CTextInputLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public int getBaseline() {
EditText editText = getEditText();
return editText.getBaseline() - (getMeasuredHeight() - editText.getMeasuredHeight());
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
/*
* 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.
*/
// based on https://code.tutsplus.com/tutorials/creating-compound-views-on-android--cms-22889
package com.m2049r.xmrwallet.layout;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.m2049r.xmrwallet.R;
public class Toolbar extends android.support.v7.widget.Toolbar {
static final String TAG = "Toolbar";
public interface OnButtonListener {
void onButton(int type);
}
OnButtonListener onButtonListener;
public void setOnButtonListener(OnButtonListener listener) {
onButtonListener = listener;
}
ImageView toolbarImage;
TextView toolbarTitle;
TextView toolbarSubtitle;
Button bDonate;
public Toolbar(Context context) {
super(context);
initializeViews(context);
}
public Toolbar(Context context, AttributeSet attrs) {
super(context, attrs);
initializeViews(context);
}
public Toolbar(Context context,
AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
initializeViews(context);
}
/**
* Inflates the views in the layout.
*
* @param context the current context for the view.
*/
private void initializeViews(Context context) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.view_toolbar, this);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
toolbarImage = (ImageView) findViewById(R.id.toolbarImage);
toolbarTitle = (TextView) findViewById(R.id.toolbarTitle);
toolbarSubtitle = (TextView) findViewById(R.id.toolbarSubtitle);
bDonate = (Button) findViewById(R.id.bDonate);
bDonate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (onButtonListener != null) {
onButtonListener.onButton(buttonType);
}
}
});
}
public void setTitle(String title, String subtitle) {
setTitle(title);
setSubtitle(subtitle);
}
public void setTitle(String title) {
toolbarTitle.setText(title);
if (title != null) {
toolbarImage.setVisibility(View.INVISIBLE);
toolbarTitle.setVisibility(View.VISIBLE);
} else {
toolbarImage.setVisibility(View.VISIBLE);
toolbarTitle.setVisibility(View.INVISIBLE);
}
}
public final static int BUTTON_NONE = 0;
public final static int BUTTON_BACK = 1;
public final static int BUTTON_CLOSE = 2;
public final static int BUTTON_DONATE = 3;
int buttonType = BUTTON_DONATE;
public void setButton(int type) {
switch (type) {
case BUTTON_BACK:
Log.d(TAG, "BUTTON_BACK");
bDonate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_arrow_back_white_24dp, 0, 0, 0);
bDonate.setText(null);
bDonate.setVisibility(View.VISIBLE);
break;
case BUTTON_CLOSE:
Log.d(TAG, "BUTTON_CLOSE");
bDonate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_close_white_24dp, 0, 0, 0);
bDonate.setText(R.string.label_close);
bDonate.setVisibility(View.VISIBLE);
break;
case BUTTON_DONATE:
Log.d(TAG, "BUTTON_DONATE");
bDonate.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_favorite_white_24dp, 0, 0, 0);
bDonate.setText(R.string.label_donate);
bDonate.setVisibility(View.VISIBLE);
break;
case BUTTON_NONE:
default:
Log.d(TAG, "BUTTON_NONE");
bDonate.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
bDonate.setText(null);
bDonate.setVisibility(View.INVISIBLE);
}
buttonType = type;
}
public void setSubtitle(String subtitle) {
toolbarSubtitle.setText(subtitle);
if (subtitle != null) {
toolbarSubtitle.setVisibility(View.VISIBLE);
} else {
toolbarSubtitle.setVisibility(View.INVISIBLE);
}
}
}

View File

@@ -17,7 +17,6 @@
package com.m2049r.xmrwallet.layout;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
@@ -28,13 +27,12 @@ import android.widget.TextView;
import com.m2049r.xmrwallet.R;
import com.m2049r.xmrwallet.model.TransactionInfo;
import com.m2049r.xmrwallet.model.Wallet;
import com.m2049r.xmrwallet.util.Helper;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
@@ -49,10 +47,10 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
//static final int TX_PENDING = Color.rgb(72, 53, 176);
//static final int TX_FAILED = Color.rgb(208, 0, 255);
int outboundColour;
int inboundColour;
int pendingColour;
int failedColour;
private int outboundColour;
private int inboundColour;
private int pendingColour;
private int failedColour;
public interface OnInteractionListener {
void onInteraction(View view, TransactionInfo item);
@@ -61,7 +59,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
private final List<TransactionInfo> infoItems;
private final OnInteractionListener listener;
Context context;
private Context context;
public TransactionInfoAdapter(Context context, OnInteractionListener listener) {
this.context = context;
@@ -69,7 +67,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
outboundColour = ContextCompat.getColor(context, R.color.tx_red);
pendingColour = ContextCompat.getColor(context, R.color.tx_pending);
failedColour = ContextCompat.getColor(context, R.color.tx_failed);
this.infoItems = new ArrayList<>();
infoItems = new ArrayList<>();
this.listener = listener;
Calendar cal = Calendar.getInstance();
TimeZone tz = cal.getTimeZone(); //get the local time zone.
@@ -79,7 +77,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.transaction_item, parent, false);
.inflate(R.layout.item_transaction, parent, false);
return new ViewHolder(view);
}
@@ -99,22 +97,8 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
this.infoItems.clear();
if (data != null) {
Log.d(TAG, "setInfos " + data.size());
// sort by block height
Collections.sort(data, new Comparator<TransactionInfo>() {
@Override
public int compare(TransactionInfo o1, TransactionInfo o2) {
long b1 = o1.timestamp;
long b2 = o2.timestamp;
if (b1 > b2) {
return -1;
} else if (b1 < b2) {
return 1;
} else {
return o1.hash.compareTo(o2.hash);
}
}
});
this.infoItems.addAll(data);
infoItems.addAll(data);
Collections.sort(infoItems);
} else {
Log.d(TAG, "setInfos null");
}
@@ -147,36 +131,41 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
void bind(int position) {
this.infoItem = infoItems.get(position);
String displayAmount = Wallet.getDisplayAmount(infoItem.amount);
// TODO fix this with i8n code but cryptonote::print_money always uses '.' for decimal point
String amount = displayAmount.substring(0, displayAmount.length() - (12 - 5));
this.tvAmount.setText(amount);
long realAmount = infoItem.amount;
if (infoItem.isPending) {
realAmount = realAmount - infoItem.fee;
}
String displayAmount = Helper.getDisplayAmount(realAmount, Helper.DISPLAY_DIGITS_INFO);
if (infoItem.direction == TransactionInfo.Direction.Direction_Out) {
this.tvAmount.setText(context.getString(R.string.tx_list_amount_negative, displayAmount));
} else {
this.tvAmount.setText(context.getString(R.string.tx_list_amount_positive, displayAmount));
}
if ((infoItem.fee > 0)) {
String feeAmount = Wallet.getDisplayAmount(infoItem.fee);
String fee = feeAmount.substring(0, feeAmount.length() - (12 - 5));
if (infoItem.isPending) {
this.tvFee.setText(context.getString(R.string.tx_list_fee_pending, fee));
} else {
this.tvFee.setText(context.getString(R.string.tx_list_fee, fee));
}
String fee = Helper.getDisplayAmount(infoItem.fee, 5);
this.tvFee.setText(context.getString(R.string.tx_list_fee, fee));
} else {
this.tvFee.setText("");
}
if (infoItem.isFailed) {
this.tvAmount.setText(context.getString(R.string.tx_list_amount_failed, amount));
this.tvAmount.setText(context.getString(R.string.tx_list_amount_failed, displayAmount));
this.tvFee.setText(context.getString(R.string.tx_list_failed_text));
setTxColour(failedColour);
} else if (infoItem.isPending) {
setTxColour(pendingColour);
if (infoItem.direction == TransactionInfo.Direction.Direction_Out) {
this.tvAmount.setText(context.getString(R.string.tx_list_amount_negative, amount));
}
} else if (infoItem.direction == TransactionInfo.Direction.Direction_In) {
setTxColour(inboundColour);
} else {
setTxColour(outboundColour);
}
this.tvPaymentId.setText(infoItem.paymentId.equals("0000000000000000") ? "" : infoItem.paymentId);
if ((infoItem.notes == null) || (infoItem.notes.isEmpty())) {
this.tvPaymentId.setText(infoItem.paymentId.equals("0000000000000000") ? "" : infoItem.paymentId);
} else {
this.tvPaymentId.setText(infoItem.notes);
}
this.tvDateTime.setText(getDateTime(infoItem.timestamp));
itemView.setOnClickListener(this);

Some files were not shown because too many files have changed in this diff Show More