From 74e9278baadfb15ad4bae3050f88fc45c5db4b5f Mon Sep 17 00:00:00 2001 From: m2049r Date: Wed, 16 Sep 2020 17:45:07 +0200 Subject: [PATCH 1/4] MainActivity must be singleTop --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7c28e38..dfdb4e4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,7 +22,7 @@ android:usesCleartextTraffic="true"> From c32d157150047362a939469755ff9fe8332c96f7 Mon Sep 17 00:00:00 2001 From: m2049r Date: Wed, 16 Sep 2020 17:51:47 +0200 Subject: [PATCH 2/4] monero addresses are 95 characters --- app/src/main/res/layout/fragment_send_address.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/fragment_send_address.xml b/app/src/main/res/layout/fragment_send_address.xml index 554ffce..199feaf 100644 --- a/app/src/main/res/layout/fragment_send_address.xml +++ b/app/src/main/res/layout/fragment_send_address.xml @@ -36,7 +36,7 @@ android:layout_alignParentStart="true" android:layout_toStartOf="@+id/bPasteAddress" app:counterEnabled="true" - app:counterMaxLength="16" + app:counterMaxLength="95" app:errorEnabled="true"> Date: Wed, 16 Sep 2020 18:53:32 +0200 Subject: [PATCH 3/4] clean up code --- app/src/main/cpp/monerujo.cpp | 157 +++++++++++++++++----------------- 1 file changed, 80 insertions(+), 77 deletions(-) diff --git a/app/src/main/cpp/monerujo.cpp b/app/src/main/cpp/monerujo.cpp index dc6ac8f..77231f2 100644 --- a/app/src/main/cpp/monerujo.cpp +++ b/app/src/main/cpp/monerujo.cpp @@ -221,7 +221,7 @@ std::vector java2cpp(JNIEnv *env, jobject arrayList) { for (jint i = 0; i < len; i++) { jstring element = static_cast(env->CallObjectMethod(arrayList, java_util_ArrayList_get, i)); - const char *pchars = env->GetStringUTFChars(element, NULL); + const char *pchars = env->GetStringUTFChars(element, nullptr); result.emplace_back(pchars); env->ReleaseStringUTFChars(element, pchars); env->DeleteLocalRef(element); @@ -229,14 +229,15 @@ std::vector java2cpp(JNIEnv *env, jobject arrayList) { return result; } -jobject cpp2java(JNIEnv *env, std::vector vector) { +jobject cpp2java(JNIEnv *env, const std::vector& vector) { jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "", "(I)V"); jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", "(Ljava/lang/Object;)Z"); - jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, vector.size()); - for (std::string &s: vector) { + jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, + static_cast (vector.size())); + for (const std::string &s: vector) { jstring element = env->NewStringUTF(s.c_str()); env->CallBooleanMethod(result, java_util_ArrayList_add, element); env->DeleteLocalRef(element); @@ -260,9 +261,9 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletJ(JNIEnv *env, jobject jstring path, jstring password, jstring language, jint networkType) { - const char *_path = env->GetStringUTFChars(path, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); - const char *_language = env->GetStringUTFChars(language, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); + const char *_language = env->GetStringUTFChars(language, nullptr); Monero::NetworkType _networkType = static_cast(networkType); Bitmonero::Wallet *wallet = @@ -282,8 +283,8 @@ JNIEXPORT jlong JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_openWalletJ(JNIEnv *env, jobject instance, jstring path, jstring password, jint networkType) { - const char *_path = env->GetStringUTFChars(path, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); Monero::NetworkType _networkType = static_cast(networkType); Bitmonero::Wallet *wallet = @@ -303,9 +304,9 @@ Java_com_m2049r_xmrwallet_model_WalletManager_recoveryWalletJ(JNIEnv *env, jobje jstring mnemonic, jint networkType, jlong restoreHeight) { - const char *_path = env->GetStringUTFChars(path, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); - const char *_mnemonic = env->GetStringUTFChars(mnemonic, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); + const char *_mnemonic = env->GetStringUTFChars(mnemonic, nullptr); Monero::NetworkType _networkType = static_cast(networkType); Bitmonero::Wallet *wallet = @@ -331,13 +332,13 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromKeysJ(JNIEnv *env, jstring addressString, jstring viewKeyString, jstring spendKeyString) { - const char *_path = env->GetStringUTFChars(path, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); - const char *_language = env->GetStringUTFChars(language, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); + const char *_language = env->GetStringUTFChars(language, nullptr); Monero::NetworkType _networkType = static_cast(networkType); - const char *_addressString = env->GetStringUTFChars(addressString, NULL); - const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, NULL); - const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, NULL); + const char *_addressString = env->GetStringUTFChars(addressString, nullptr); + const char *_viewKeyString = env->GetStringUTFChars(viewKeyString, nullptr); + const char *_spendKeyString = env->GetStringUTFChars(spendKeyString, nullptr); Bitmonero::Wallet *wallet = Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( @@ -370,11 +371,11 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromDeviceJ(JNIEnv *en jstring deviceName, jlong restoreHeight, jstring subaddressLookahead) { - const char *_path = env->GetStringUTFChars(path, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); Monero::NetworkType _networkType = static_cast(networkType); - const char *_deviceName = env->GetStringUTFChars(deviceName, NULL); - const char *_subaddressLookahead = env->GetStringUTFChars(subaddressLookahead, NULL); + const char *_deviceName = env->GetStringUTFChars(deviceName, nullptr); + const char *_subaddressLookahead = env->GetStringUTFChars(subaddressLookahead, nullptr); Bitmonero::Wallet *wallet = Bitmonero::WalletManagerFactory::getWalletManager()->createWalletFromDevice( @@ -395,7 +396,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_createWalletFromDeviceJ(JNIEnv *en JNIEXPORT jboolean JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_walletExists(JNIEnv *env, jobject instance, jstring path) { - const char *_path = env->GetStringUTFChars(path, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); bool exists = Bitmonero::WalletManagerFactory::getWalletManager()->walletExists(std::string(_path)); env->ReleaseStringUTFChars(path, _path); @@ -407,8 +408,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, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); + const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); bool passwordOk = Bitmonero::WalletManagerFactory::getWalletManager()->verifyWalletPassword( std::string(_keys_file_name), std::string(_password), watch_only); @@ -422,8 +423,8 @@ JNIEXPORT jint JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jobject instance, jstring keys_file_name, jstring password) { - const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, NULL); - const char *_password = env->GetStringUTFChars(password, NULL); + const char *_keys_file_name = env->GetStringUTFChars(keys_file_name, nullptr); + const char *_password = env->GetStringUTFChars(password, nullptr); Bitmonero::Wallet::Device device_type; bool ok = Bitmonero::WalletManagerFactory::getWalletManager()-> queryWalletDevice(device_type, std::string(_keys_file_name), std::string(_password)); @@ -438,7 +439,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_queryWalletDeviceJ(JNIEnv *env, jo JNIEXPORT jobject JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject instance, jstring path) { - const char *_path = env->GetStringUTFChars(path, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); std::vector walletPaths = Bitmonero::WalletManagerFactory::getWalletManager()->findWallets(std::string(_path)); env->ReleaseStringUTFChars(path, _path); @@ -450,7 +451,7 @@ Java_com_m2049r_xmrwallet_model_WalletManager_findWallets(JNIEnv *env, jobject i JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_setDaemonAddressJ(JNIEnv *env, jobject instance, jstring address) { - const char *_address = env->GetStringUTFChars(address, NULL); + const char *_address = env->GetStringUTFChars(address, nullptr); Bitmonero::WalletManagerFactory::getWalletManager()->setDaemonAddress(std::string(_address)); env->ReleaseStringUTFChars(address, _address); } @@ -502,7 +503,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, NULL); + const char *_address = env->GetStringUTFChars(address, nullptr); bool success = Bitmonero::WalletManagerFactory::getWalletManager()->startMining(std::string(_address), background_mining, @@ -520,7 +521,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, NULL); + const char *_address = env->GetStringUTFChars(address, nullptr); bool _dnssec_valid = (bool) dnssec_valid; std::string resolvedAlias = Bitmonero::WalletManagerFactory::getWalletManager()->resolveOpenAlias( @@ -572,7 +573,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, NULL); + const char *_language = env->GetStringUTFChars(language, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); wallet->setSeedLanguage(std::string(_language)); env->ReleaseStringUTFChars(language, _language); @@ -608,7 +609,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_statusWithErrorString(JNIEnv *env, jobjec JNIEXPORT jboolean JNICALL Java_com_m2049r_xmrwallet_model_Wallet_setPassword(JNIEnv *env, jobject instance, jstring password) { - const char *_password = env->GetStringUTFChars(password, NULL); + const char *_password = env->GetStringUTFChars(password, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); bool success = wallet->setPassword(std::string(_password)); env->ReleaseStringUTFChars(password, _password); @@ -642,7 +643,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_nettype(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, NULL); + const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); std::string address = wallet->integratedAddress(_payment_id); env->ReleaseStringUTFChars(payment_id, _payment_id); @@ -664,7 +665,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, NULL); + const char *_path = env->GetStringUTFChars(path, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); bool success = wallet->store(std::string(_path)); if (!success) { @@ -687,9 +688,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, NULL); - const char *_daemon_username = env->GetStringUTFChars(daemon_username, NULL); - const char *_daemon_password = env->GetStringUTFChars(daemon_password, NULL); + const char *_daemon_address = env->GetStringUTFChars(daemon_address, nullptr); + const char *_daemon_username = env->GetStringUTFChars(daemon_username, nullptr); + const char *_daemon_password = env->GetStringUTFChars(daemon_password, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); bool status = wallet->init(_daemon_address, (uint64_t) upper_transaction_size_limit, _daemon_username, @@ -807,7 +808,7 @@ Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jclass clazz return nullptr; } - jbyte *buffer = env->GetByteArrayElements(data, NULL); + jbyte *buffer = env->GetByteArrayElements(data, nullptr); switch (brokenVariant) { case 1: slow_hash_broken(buffer, hash, 1); @@ -833,7 +834,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getDisplayAmount(JNIEnv *env, jclass claz JNIEXPORT jlong JNICALL Java_com_m2049r_xmrwallet_model_Wallet_getAmountFromString(JNIEnv *env, jclass clazz, jstring amount) { - const char *_amount = env->GetStringUTFChars(amount, NULL); + const char *_amount = env->GetStringUTFChars(amount, nullptr); uint64_t x = Bitmonero::Wallet::amountFromString(_amount); env->ReleaseStringUTFChars(amount, _amount); return x; @@ -853,7 +854,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_generatePaymentId(JNIEnv *env, jclass cla JNIEXPORT jboolean JNICALL Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass clazz, jstring payment_id) { - const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); + const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr); bool isValid = Bitmonero::Wallet::paymentIdValid(_payment_id); env->ReleaseStringUTFChars(payment_id, _payment_id); return static_cast(isValid); @@ -862,7 +863,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_isPaymentIdValid(JNIEnv *env, jclass claz JNIEXPORT jboolean JNICALL Java_com_m2049r_xmrwallet_model_Wallet_isAddressValid(JNIEnv *env, jclass clazz, jstring address, jint networkType) { - const char *_address = env->GetStringUTFChars(address, NULL); + const char *_address = env->GetStringUTFChars(address, nullptr); Monero::NetworkType _networkType = static_cast(networkType); bool isValid = Bitmonero::Wallet::addressValid(_address, _networkType); env->ReleaseStringUTFChars(address, _address); @@ -874,7 +875,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_getPaymentIdFromAddress(JNIEnv *env, jcla jstring address, jint networkType) { Monero::NetworkType _networkType = static_cast(networkType); - const char *_address = env->GetStringUTFChars(address, NULL); + const char *_address = env->GetStringUTFChars(address, nullptr); std::string payment_id = Bitmonero::Wallet::paymentIdFromAddress(_address, _networkType); env->ReleaseStringUTFChars(address, _address); return env->NewStringUTF(payment_id.c_str()); @@ -929,8 +930,8 @@ Java_com_m2049r_xmrwallet_model_Wallet_createTransactionJ(JNIEnv *env, jobject i jint priority, jint accountIndex) { - const char *_dst_addr = env->GetStringUTFChars(dst_addr, NULL); - const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); + const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr); + const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr); Bitmonero::PendingTransaction::Priority _priority = static_cast(priority); Bitmonero::Wallet *wallet = getHandle(env, instance); @@ -952,8 +953,8 @@ Java_com_m2049r_xmrwallet_model_Wallet_createSweepTransaction(JNIEnv *env, jobje jint priority, jint accountIndex) { - const char *_dst_addr = env->GetStringUTFChars(dst_addr, NULL); - const char *_payment_id = env->GetStringUTFChars(payment_id, NULL); + const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr); + const char *_payment_id = env->GetStringUTFChars(payment_id, nullptr); Bitmonero::PendingTransaction::Priority _priority = static_cast(priority); Bitmonero::Wallet *wallet = getHandle(env, instance); @@ -1041,8 +1042,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, NULL); - const char *_note = env->GetStringUTFChars(note, NULL); + const char *_txid = env->GetStringUTFChars(txid, nullptr); + const char *_note = env->GetStringUTFChars(note, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); @@ -1058,7 +1059,7 @@ JNIEXPORT jstring JNICALL Java_com_m2049r_xmrwallet_model_Wallet_getUserNote(JNIEnv *env, jobject instance, jstring txid) { - const char *_txid = env->GetStringUTFChars(txid, NULL); + const char *_txid = env->GetStringUTFChars(txid, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); @@ -1072,7 +1073,7 @@ JNIEXPORT jstring JNICALL Java_com_m2049r_xmrwallet_model_Wallet_getTxKey(JNIEnv *env, jobject instance, jstring txid) { - const char *_txid = env->GetStringUTFChars(txid, NULL); + const char *_txid = env->GetStringUTFChars(txid, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); @@ -1087,7 +1088,7 @@ JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_Wallet_addAccount(JNIEnv *env, jobject instance, jstring label) { - const char *_label = env->GetStringUTFChars(label, NULL); + const char *_label = env->GetStringUTFChars(label, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); wallet->addSubaddressAccount(_label); @@ -1114,7 +1115,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_setSubaddressLabel(JNIEnv *env, jobject i jint accountIndex, jint addressIndex, jstring label) { - const char *_label = env->GetStringUTFChars(label, NULL); + const char *_label = env->GetStringUTFChars(label, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); wallet->setSubaddressLabel(accountIndex, addressIndex, _label); @@ -1143,7 +1144,7 @@ Java_com_m2049r_xmrwallet_model_Wallet_addSubaddress(JNIEnv *env, jobject instan jint accountIndex, jstring label) { - const char *_label = env->GetStringUTFChars(label, NULL); + const char *_label = env->GetStringUTFChars(label, nullptr); Bitmonero::Wallet *wallet = getHandle(env, instance); wallet->addSubaddress(accountIndex, _label); env->ReleaseStringUTFChars(label, _label); @@ -1181,21 +1182,22 @@ jobject newTransferInstance(JNIEnv *env, uint64_t amount, const std::string &add jmethodID c = env->GetMethodID(class_Transfer, "", "(JLjava/lang/String;)V"); jstring _address = env->NewStringUTF(address.c_str()); - jobject transfer = env->NewObject(class_Transfer, c, amount, _address); + jobject transfer = env->NewObject(class_Transfer, c, static_cast (amount), _address); env->DeleteLocalRef(_address); return transfer; } jobject newTransferList(JNIEnv *env, Bitmonero::TransactionInfo *info) { const std::vector &transfers = info->transfers(); - if (transfers.size() == 0) { // don't create empty Lists + if (transfers.empty()) { // don't create empty Lists return nullptr; } // make new ArrayList jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "", "(I)V"); jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", "(Ljava/lang/Object;)Z"); - jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, transfers.size()); + jobject result = env->NewObject(class_ArrayList, java_util_ArrayList_, + static_cast (transfers.size())); // create Transfer objects and stick them in the List for (const Bitmonero::TransactionInfo::Transfer &s: transfers) { jobject element = newTransferInstance(env, s.amount, s.address); @@ -1219,15 +1221,15 @@ jobject newTransactionInfo(JNIEnv *env, Bitmonero::TransactionInfo *info) { info->direction(), info->isPending(), info->isFailed(), - info->amount(), - info->fee(), - info->blockHeight(), + static_cast (info->amount()), + static_cast (info->fee()), + static_cast (info->blockHeight()), _hash, static_cast (info->timestamp()), _paymentId, - info->subaddrAccount(), - subaddrIndex, - info->confirmations(), + static_cast (info->subaddrAccount()), + static_cast (subaddrIndex), + static_cast (info->confirmations()), _label, transfers); env->DeleteLocalRef(transfers); @@ -1239,13 +1241,14 @@ jobject newTransactionInfo(JNIEnv *env, Bitmonero::TransactionInfo *info) { #include #include -jobject cpp2java(JNIEnv *env, std::vector vector) { +jobject cpp2java(JNIEnv *env, const std::vector& vector) { jmethodID java_util_ArrayList_ = env->GetMethodID(class_ArrayList, "", "(I)V"); jmethodID java_util_ArrayList_add = env->GetMethodID(class_ArrayList, "add", "(Ljava/lang/Object;)Z"); - jobject arrayList = env->NewObject(class_ArrayList, java_util_ArrayList_, vector.size()); + jobject arrayList = env->NewObject(class_ArrayList, java_util_ArrayList_, + static_cast (vector.size())); for (Bitmonero::TransactionInfo *s: vector) { jobject info = newTransactionInfo(env, s); env->CallBooleanMethod(arrayList, java_util_ArrayList_add, info); @@ -1281,7 +1284,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, NULL); + const char *_filename = env->GetStringUTFChars(filename, nullptr); Bitmonero::PendingTransaction *tx = getHandle(env, instance); bool success = tx->commit(_filename, overwrite); @@ -1338,8 +1341,8 @@ Java_com_m2049r_xmrwallet_model_WalletManager_initLogger(JNIEnv *env, jclass cla jstring argv0, jstring default_log_base_name) { - const char *_argv0 = env->GetStringUTFChars(argv0, NULL); - const char *_default_log_base_name = env->GetStringUTFChars(default_log_base_name, NULL); + const char *_argv0 = env->GetStringUTFChars(argv0, nullptr); + const char *_default_log_base_name = env->GetStringUTFChars(default_log_base_name, nullptr); Bitmonero::Wallet::init(_argv0, _default_log_base_name); @@ -1351,8 +1354,8 @@ JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_logDebug(JNIEnv *env, jclass clazz, jstring category, jstring message) { - const char *_category = env->GetStringUTFChars(category, NULL); - const char *_message = env->GetStringUTFChars(message, NULL); + const char *_category = env->GetStringUTFChars(category, nullptr); + const char *_message = env->GetStringUTFChars(message, nullptr); Bitmonero::Wallet::debug(_category, _message); @@ -1364,8 +1367,8 @@ JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_logInfo(JNIEnv *env, jclass clazz, jstring category, jstring message) { - const char *_category = env->GetStringUTFChars(category, NULL); - const char *_message = env->GetStringUTFChars(message, NULL); + const char *_category = env->GetStringUTFChars(category, nullptr); + const char *_message = env->GetStringUTFChars(message, nullptr); Bitmonero::Wallet::info(_category, _message); @@ -1377,8 +1380,8 @@ JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_logWarning(JNIEnv *env, jclass clazz, jstring category, jstring message) { - const char *_category = env->GetStringUTFChars(category, NULL); - const char *_message = env->GetStringUTFChars(message, NULL); + const char *_category = env->GetStringUTFChars(category, nullptr); + const char *_message = env->GetStringUTFChars(message, nullptr); Bitmonero::Wallet::warning(_category, _message); @@ -1390,8 +1393,8 @@ JNIEXPORT void JNICALL Java_com_m2049r_xmrwallet_model_WalletManager_logError(JNIEnv *env, jclass clazz, jstring category, jstring message) { - const char *_category = env->GetStringUTFChars(category, NULL); - const char *_message = env->GetStringUTFChars(message, NULL); + const char *_category = env->GetStringUTFChars(category, nullptr); + const char *_message = env->GetStringUTFChars(message, nullptr); Bitmonero::Wallet::error(_category, _message); @@ -1480,7 +1483,7 @@ int LedgerFind(char *buffer, size_t len) { int ret; if (name != nullptr) { - const char *_name = jenv->GetStringUTFChars(name, NULL); + const char *_name = jenv->GetStringUTFChars(name, nullptr); strncpy(buffer, _name, len); jenv->ReleaseStringUTFChars(name, _name); buffer[len - 1] = 0; // terminate in case _name is bigger From c060a2ab88d129e233c9390c266dd1ab0c83b7cc Mon Sep 17 00:00:00 2001 From: m2049r Date: Wed, 16 Sep 2020 19:59:58 +0200 Subject: [PATCH 4/4] don't show onboarding every time --- app/src/main/java/com/m2049r/xmrwallet/MainActivity.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/MainActivity.java b/app/src/main/java/com/m2049r/xmrwallet/MainActivity.java index cff572d..1d2b889 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/MainActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/MainActivity.java @@ -24,13 +24,11 @@ import android.support.v7.app.AppCompatActivity; import com.m2049r.xmrwallet.onboarding.OnBoardingActivity; import com.m2049r.xmrwallet.onboarding.OnBoardingManager; -import timber.log.Timber; - public class MainActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (OnBoardingManager.shouldShowOnBoarding(getApplicationContext()) || BuildConfig.DEBUG) { + if (OnBoardingManager.shouldShowOnBoarding(getApplicationContext())) { startActivity(new Intent(this, OnBoardingActivity.class)); } else { startActivity(new Intent(this, LoginActivity.class));