From 89fcf18e94b2be4c21098f1c0188cec03be0c22b Mon Sep 17 00:00:00 2001 From: Alexey Koloskov Date: Fri, 27 Apr 2018 01:07:38 +0300 Subject: [PATCH] Fixed incorrect prices for some pair and statistics. --- app/build.gradle | 144 +++++++++--------- app/proguard-rules.pro | 16 +- app/src/main/AndroidManifest.xml | 7 + .../wallet/BlockchainApplication.java | 39 +++++ .../wallet/payload/ExchangeTransaction.java | 6 +- .../wallet/ui/assets/IssueViewModel.java | 12 ++ .../wallet/ui/auth/EnvironmentManager.java | 2 +- .../wallet/ui/auth/PinEntryFragment.java | 10 ++ .../ui/balance/TransactionsFragment.java | 26 ++++ .../ui/balance/TransactionsViewModel.java | 19 +++ .../dex/details/order/PlaceOrderActivity.java | 32 ++-- .../details/order/PlaceOrderViewModel.java | 5 +- .../wallet/ui/send/SendViewModel.java | 11 ++ .../wallet/util/PersistentPrefs.java | 1 + .../wavesplatform/wallet/util/PrefsUtil.java | 4 +- app/src/main/res/values/strings.xml | 5 + build.gradle | 11 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 18 files changed, 263 insertions(+), 91 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 44da0eb98..685bb892c 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,19 +7,22 @@ android { signingConfigs { config { keyAlias 'WavesWallet' + keyPassword '' + storeFile file('') + storePassword '' } } - compileSdkVersion 25 - buildToolsVersion '26.0.2' + compileSdkVersion 26 + buildToolsVersion '27.0.3' flavorDimensions "default" dexOptions { javaMaxHeapSize "3g" } defaultConfig { applicationId "com.wavesplatform.wallet" - targetSdkVersion 25 - versionCode 335 - versionName "1.1.5" + targetSdkVersion 26 + versionCode 340 + versionName "1.1.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true archivesBaseName = "waves-wallet-$versionName" @@ -56,9 +59,6 @@ android { signingConfig signingConfigs.config } dev { - // For everyday work, setting minSdkVersion to 21 bypasses MultiDex, resulting in - // much faster builds - minSdkVersion 21 } } compileOptions { @@ -90,94 +90,98 @@ android { } ext { - supportVersion = '25.3.1' - googleServicesVersion = '10.0.1' + supportVersion = '26.1.0' + googleServicesVersion = '15.0.0' rxJavaVersion = '2.0.4' rxAndroidVersion = '2.0.1' daggerVersion = '2.8' - retrofitVersion = '2.1.0' + retrofitVersion = '2.4.0' okHttpVersion = '3.5.0' } dependencies { - implementation 'com.android.support.constraint:constraint-layout:1.0.2' - compile fileTree(include: ['*.jar'], dir: 'libs') - compile "com.android.support:appcompat-v7:$supportVersion" - compile "com.android.support:recyclerview-v7:$supportVersion" - compile "com.android.support:cardview-v7:$supportVersion" - compile "com.android.support:design:$supportVersion" - compile "com.android.support:support-v13:$supportVersion" - compile "com.android.support:preference-v7:$supportVersion" - compile "com.android.support:preference-v14:$supportVersion" + implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "com.android.support:appcompat-v7:$supportVersion" + implementation "com.android.support:recyclerview-v7:$supportVersion" + implementation "com.android.support:cardview-v7:$supportVersion" + implementation "com.android.support:design:$supportVersion" + implementation "com.android.support:support-v13:$supportVersion" + implementation "com.android.support:preference-v7:$supportVersion" + implementation "com.android.support:preference-v14:$supportVersion" + // Enable crash reporting only for release version - compile 'com.google.firebase:firebase-database:10.0.1' - releaseCompile "com.google.firebase:firebase-crash:$googleServicesVersion" - compile "com.google.firebase:firebase-messaging:$googleServicesVersion" - compile 'commons-io:commons-io:2.4' + implementation 'com.google.firebase:firebase-database:15.0.0' + releaseImplementation "com.google.firebase:firebase-crash:$googleServicesVersion" + implementation "com.google.firebase:firebase-messaging:$googleServicesVersion" + implementation 'commons-io:commons-io:2.4' + // Keep at 1.3 to match Android implementation - compile 'commons-codec:commons-codec:1.3' - compile 'org.apache.commons:commons-lang3:3.4' - compile 'com.android.support:multidex:1.0.1' - compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0' - compile 'com.neovisionaries:nv-websocket-client:1.19' - compile('com.google.zxing:core:3.3.0') { transitive = true } - compile 'com.github.mukeshsolanki:country-picker-android:1.1.6' - compile 'com.aurelhubert:ahbottomnavigation:2.0.2' - // RxJava - compile "io.reactivex.rxjava2:rxjava:$rxJavaVersion" - compile "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" - compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0' - // Retrofit - compile "com.squareup.retrofit2:retrofit:$retrofitVersion" - compile "com.squareup.retrofit2:converter-jackson:$retrofitVersion" - compile "com.squareup.retrofit2:converter-gson:$retrofitVersion" - compile "com.squareup.retrofit2:adapter-rxjava2:2.3.0-SNAPSHOT" + implementation 'commons-codec:commons-codec:1.6' + implementation 'org.apache.commons:commons-lang3:3.4' + implementation 'com.android.support:multidex:1.0.3' + implementation 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0' + implementation 'com.neovisionaries:nv-websocket-client:1.19' + implementation('com.google.zxing:core:3.3.0') { transitive = true } + implementation 'com.github.mukeshsolanki:country-picker-android:1.1.6' + implementation 'com.aurelhubert:ahbottomnavigation:2.0.2' - compile "org.whispersystems:curve25519-java:0.3.0" - compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' + // RxJava + implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" + implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" + implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0' - compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.22' + // Retrofit + implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-jackson:$retrofitVersion" + implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" + implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" + implementation 'org.whispersystems:curve25519-java:0.3.0' + implementation 'com.bignerdranch.android:recyclerview-multiselect:0.2' + implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.22' // OkHttp - compile "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" - compile 'com.github.ihsanbal:LoggingInterceptor:1.0.5' - compile "com.squareup.okhttp3:okhttp:$okHttpVersion" - // Dagger2 - compile "com.google.dagger:dagger:$daggerVersion" - - compile 'com.github.rubensousa:bottomsheetbuilder:1.6.0' - - compile 'com.github.vihtarb:tooltip:0.1.9' - compile 'com.madgag.spongycastle:core:1.52.0.0' - compile 'com.google.guava:guava:20.0' - compile 'com.github.ihsanbal:LoggingInterceptor:1.0.5' + implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" + implementation 'com.github.ihsanbal:LoggingInterceptor:1.0.5' + implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" + // Dagger2 + implementation "com.google.dagger:dagger:$daggerVersion" + implementation 'com.github.rubensousa:bottomsheetbuilder:1.6.0' + implementation 'com.github.vihtarb:tooltip:0.1.9' + implementation 'com.madgag.spongycastle:core:1.52.0.0' + implementation 'com.google.guava:guava:22.0' + implementation 'com.github.ihsanbal:LoggingInterceptor:1.0.5' annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion" - annotationProcessor 'com.google.guava:guava:20.0' + annotationProcessor 'com.google.guava:guava:22.0' // Fingerprint authentication - compile 'com.mtramin:rxfingerprint:2.0.1' + implementation 'com.mtramin:rxfingerprint:2.0.1' + // UI/Instrumentation Tests - androidTestCompile 'junit:junit:4.12' - androidTestCompile 'org.mockito:mockito-core:1.9.5' - androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.3' - androidTestCompile "com.android.support:support-annotations:$supportVersion" - androidTestCompile 'com.android.support.test:rules:0.5' - androidTestCompile('com.android.support.test:runner:0.5') { + androidTestImplementation 'junit:junit:4.12' + androidTestImplementation 'org.mockito:mockito-core:1.10.19' + androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3' + androidTestImplementation "com.android.support:support-annotations:$supportVersion" + androidTestImplementation 'com.android.support.test:rules:1.0.2' + androidTestImplementation('com.android.support.test:runner:0.5') { exclude module: 'support-annotations' } - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') { + androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2') { exclude group: 'javax.inject', module: 'support-annotations' } + // Unit Tests - testCompile 'org.json:json:20140107' - testCompile 'org.mockito:mockito-core:1.9.5' - testCompile 'org.hamcrest:hamcrest-junit:2.0.0.0' - testCompile('org.robolectric:robolectric:3.1.4') { + testImplementation 'org.json:json:20140107' + testImplementation 'org.mockito:mockito-core:1.10.19' + testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0' + testImplementation('org.robolectric:robolectric:3.1.4') { exclude group: 'com.google.guava' exclude group: 'com.google.protobuf' } - compile 'com.github.PhilJay:MPAndroidChart:v3.0.2' + implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2' + implementation 'com.appsflyer:af-android-sdk:4.8.9' + implementation 'com.android.installreferrer:installreferrer:1.0' } buildscript { diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 0346f5621..7932b897b 100755 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -116,6 +116,13 @@ -keepclasseswithmembers class * { @retrofit.http.* ; } +# Platform calls Class.forName on types which do not exist on Android to determine platform. +-dontnote retrofit2.Platform +# Platform used when running on Java 8 VMs. Will not be used at runtime. +-dontwarn retrofit2.Platform$Java8 +# Retain declared checked exceptions for use by a Proxy instance. +-keepattributes Exceptions + -keep class com.google.gson.** { *; } -keep class com.google.inject.** { *; } -keep class org.apache.http.** { *; } @@ -134,7 +141,6 @@ -keepattributes Signature -keepattributes *Annotation* --keepattributes Signature # slf4j -dontwarn org.slf4j.** @@ -155,8 +161,6 @@ # Only necessary if you downloaded the SDK jar directly instead of from maven. -keep class com.shaded.fasterxml.jackson.** { *; } --keepattributes Signature --keepattributes *Annotation* -keepattributes EnclosingMethod -keepattributes InnerClasses @@ -164,3 +168,9 @@ -keepclassmembers class com.wavesplatform.wallet.data.services.** {*;} -keep class com.wavesplatform.wallet.data.access.** {*;} -keepclassmembers class com.wavesplatform.wallet.data.access.** {*;} + +-dontwarn com.android.installreferrerCopy +-dontwarn com.appsflyer.* + +-keep class com.appsflyer.** { *; } +-keep class om.android.installreferrerCopy.** { *; } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5739b2ef7..237fe3a9c 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/wavesplatform/wallet/BlockchainApplication.java b/app/src/main/java/com/wavesplatform/wallet/BlockchainApplication.java index ac0eaec4f..eefb5740f 100644 --- a/app/src/main/java/com/wavesplatform/wallet/BlockchainApplication.java +++ b/app/src/main/java/com/wavesplatform/wallet/BlockchainApplication.java @@ -7,6 +7,8 @@ import android.support.v7.app.AppCompatDelegate; import android.util.Log; +import com.appsflyer.AppsFlyerConversionListener; +import com.appsflyer.AppsFlyerLib; import com.wavesplatform.wallet.data.access.AccessState; import com.wavesplatform.wallet.data.access.DexAccessState; import com.wavesplatform.wallet.data.connectivity.ConnectivityManager; @@ -20,6 +22,8 @@ import com.wavesplatform.wallet.util.annotations.Thunk; import com.wavesplatform.wallet.util.exceptions.LoggingExceptionHandler; +import java.util.Map; + import javax.inject.Inject; import io.reactivex.plugins.RxJavaPlugins; @@ -96,6 +100,41 @@ public void onBecameBackground() { AccessState.getInstance().removeWavesWallet(); } }); + + initAppsFlyer(); + } + + private static final String AF_DEV_KEY = "4di8SsYap4CM4XYMdh8uT6"; + + void initAppsFlyer() { + AppsFlyerConversionListener conversionDataListener = + new AppsFlyerConversionListener() { + @Override + public void onInstallConversionDataLoaded(Map conversionData) { + for (String attrName : conversionData.keySet()) { + Log.d(AppsFlyerLib.LOG_TAG, "attribute: " + attrName + " = " + conversionData.get(attrName)); + } + } + + @Override + public void onInstallConversionFailure(String errorMessage) { + Log.d(AppsFlyerLib.LOG_TAG, "error getting conversion data: " + errorMessage); + } + + @Override + public void onAppOpenAttribution(Map attributionData) { + for (String attrName : attributionData.keySet()) { + Log.d(AppsFlyerLib.LOG_TAG, "attribute: " + attrName + " = " + attributionData.get(attrName)); + } + } + + @Override + public void onAttributionFailure(String errorMessage) { + Log.d(AppsFlyerLib.LOG_TAG, "error onAttributionFailure : " + errorMessage); + } + }; + AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionDataListener, getApplicationContext()); + AppsFlyerLib.getInstance().startTracking(this); } /** diff --git a/app/src/main/java/com/wavesplatform/wallet/payload/ExchangeTransaction.java b/app/src/main/java/com/wavesplatform/wallet/payload/ExchangeTransaction.java index 11839cf6a..f5bf013bf 100644 --- a/app/src/main/java/com/wavesplatform/wallet/payload/ExchangeTransaction.java +++ b/app/src/main/java/com/wavesplatform/wallet/payload/ExchangeTransaction.java @@ -68,6 +68,10 @@ private AssetBalance getAssetBallance() { return NodeManager.get().getAssetBalance(getAmountAssetId()); } + private AssetBalance getPriceAssetBallance() { + return NodeManager.get().getAssetBalance(getPriceAssetId()); + } + public long getTransactionFee(){ if (getMyOrder().orderType.equals(OrderType.buy)){ return buyMatcherFee; @@ -99,7 +103,7 @@ public int getPriceDecimals() { if (getMyOrder().assetPair.priceAsset == null) { return 8; } - return getAssetBallance().issueTransaction.decimals; + return getPriceAssetBallance().issueTransaction.decimals; } @Override diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/assets/IssueViewModel.java b/app/src/main/java/com/wavesplatform/wallet/ui/assets/IssueViewModel.java index 913ab0c27..2c5d5a78c 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/assets/IssueViewModel.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/assets/IssueViewModel.java @@ -5,6 +5,7 @@ import android.support.annotation.StringRes; import android.util.Log; +import com.appsflyer.AppsFlyerLib; import com.google.common.base.Charsets; import com.google.common.primitives.Ints; import com.wavesplatform.wallet.BR; @@ -19,6 +20,9 @@ import com.wavesplatform.wallet.ui.customviews.ToastCustom; import com.wavesplatform.wallet.util.MoneyUtil; +import java.util.HashMap; +import java.util.Map; + @SuppressWarnings("WeakerAccess") public class IssueViewModel extends BaseViewModel { @@ -142,9 +146,17 @@ public boolean signTransaction() { } } + private void trackIssueAsset(IssueTransactionRequest request) { + Map eventValue = new HashMap(); + eventValue.put("af_asset_name", request.name); + eventValue.put("af_asset_id", request.id); + AppsFlyerLib.getInstance().trackEvent(context, "af_issue_tx", eventValue); + } + public void submitIssue() { NodeManager.get().broadcastIssue(request) .compose(RxUtil.applySchedulersToObservable()).subscribe(tx -> { + trackIssueAsset(tx); if (dataListener != null) dataListener.onShowTransactionSuccess(request); }, err -> { diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/auth/EnvironmentManager.java b/app/src/main/java/com/wavesplatform/wallet/ui/auth/EnvironmentManager.java index ddee68f40..ef244da68 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/auth/EnvironmentManager.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/auth/EnvironmentManager.java @@ -50,7 +50,7 @@ public void setCurrent(Environment current) { public enum Environment { PRODUCTION(KEY_ENV_PROD, "https://nodes.wavesplatform.com", "https://matcher.wavesplatform.com/", "https://marketdata.wavesplatform.com/api/", 'W'), - TESTNET(KEY_ENV_TESTNET, "http://52.30.47.67:6869", "http://52.30.47.67:6886/", "https://marketdata.wavesplatform.com/api/", 'T'); + TESTNET(KEY_ENV_TESTNET, "http://pool.testnet.wavesnodes.com:6869", "http://pool.testnet.wavesnodes.com:6886/", "https://marketdata.wavesplatform.com/api/", 'T'); private String name; private String nodeUrl; diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/auth/PinEntryFragment.java b/app/src/main/java/com/wavesplatform/wallet/ui/auth/PinEntryFragment.java index 4c6ec0b3d..8b1c3c32a 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/auth/PinEntryFragment.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/auth/PinEntryFragment.java @@ -20,6 +20,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.ImageView; +import com.appsflyer.AppsFlyerLib; import com.wavesplatform.wallet.R; import com.wavesplatform.wallet.data.connectivity.ConnectivityStatus; import com.wavesplatform.wallet.databinding.FragmentPinEntryBinding; @@ -31,6 +32,9 @@ import com.wavesplatform.wallet.util.ViewUtils; import com.wavesplatform.wallet.util.annotations.Thunk; +import java.util.HashMap; +import java.util.Map; + import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; @@ -285,6 +289,11 @@ public void onResume() { viewModel.checkFingerprintStatus(); } + private void trackNewWallet() { + Map eventValue = new HashMap(); + AppsFlyerLib.getInstance().trackEvent(getContext(), "af_new_wallet", eventValue); + } + @Override public void finishWithResultOk(String password) { Bundle bundle = new Bundle(); @@ -292,6 +301,7 @@ public void finishWithResultOk(String password) { Intent intent = new Intent(); intent.putExtras(bundle); getActivity().setResult(RESULT_OK, intent); + trackNewWallet(); getActivity().finish(); } diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsFragment.java b/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsFragment.java index b9b9f10c0..1145927f0 100755 --- a/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsFragment.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsFragment.java @@ -50,6 +50,7 @@ import com.wavesplatform.wallet.ui.transactions.UnknownDetailActivity; import com.wavesplatform.wallet.util.DateUtil; import com.wavesplatform.wallet.util.ListUtil; +import com.wavesplatform.wallet.util.PrefsUtil; import com.wavesplatform.wallet.util.ViewUtils; import com.wavesplatform.wallet.util.annotations.Thunk; @@ -224,6 +225,31 @@ public void showBackupPromptDialog(boolean showNeverAgain) { } } + @Override + public void showSendStatistics() { + SecurityPromptDialog securityPromptDialog = SecurityPromptDialog.newInstance( + R.string.statistics_send_title, + getString(R.string.statistics_send_message), + R.drawable.bad_backup, + R.string.yes, + true, + false); + + securityPromptDialog.setPositiveButtonListener(v -> { + viewModel.allowSendStats(true); + securityPromptDialog.dismiss(); + }); + + securityPromptDialog.setNegativeButtonListener(v -> { + viewModel.allowSendStats(false); + securityPromptDialog.dismiss(); + }); + + if (getActivity() != null && !getActivity().isFinishing() && isAdded()) { + securityPromptDialog.showDialog(getActivity().getSupportFragmentManager()); + } + } + @Override public void onSaveInstanceState(Bundle outState) { diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsViewModel.java b/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsViewModel.java index 7045f3ed6..1586c7bb8 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsViewModel.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/balance/TransactionsViewModel.java @@ -8,6 +8,7 @@ import android.text.Spannable; import android.text.style.RelativeSizeSpan; +import com.appsflyer.AppsFlyerLib; import com.google.common.collect.HashBiMap; import com.wavesplatform.wallet.BR; import com.wavesplatform.wallet.R; @@ -59,6 +60,12 @@ public PrefsUtil getPrefsUtil() { return prefsUtil; } + public void allowSendStats(boolean isAlow) { + prefsUtil.setValue(PrefsUtil.KEY_SEND_USAGE_STATS, isAlow ? 1 : 0); + AppsFlyerLib.getInstance().stopTracking(!isAlow, context); + + } + public interface DataListener { void onRefreshAccounts(); @@ -68,6 +75,8 @@ public interface DataListener { void showBackupPromptDialog(boolean showNeverAgain); + void showSendStatistics(); + void setTopBalance(Spannable spannable); } @@ -91,8 +100,18 @@ private void showBackupPromtIfNeede() { } } + private void showSendStatsIfNeeded() { + int sendStats = prefsUtil.getValue(PrefsUtil.KEY_SEND_USAGE_STATS, -1); + if (sendStats == -1) { + dataListener.showSendStatistics(); + } else { + AppsFlyerLib.getInstance().stopTracking(sendStats == 0, context); + } + } + public void onViewReady() { showBackupPromtIfNeede(); + showSendStatsIfNeeded(); } public void neverPromptBackup() { diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderActivity.java b/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderActivity.java index b3ed646a7..12a65acc3 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderActivity.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderActivity.java @@ -22,11 +22,15 @@ import android.widget.CheckBox; import android.widget.EditText; +import com.appsflyer.AppsFlyerLib; import com.google.gson.internal.LinkedTreeMap; import com.wavesplatform.wallet.R; import com.wavesplatform.wallet.databinding.ActivityPlaceOrderBinding; +import com.wavesplatform.wallet.payload.AmountAssetInfo; import com.wavesplatform.wallet.payload.Price; +import com.wavesplatform.wallet.payload.PriceAssetInfo; import com.wavesplatform.wallet.payload.WatchMarket; +import com.wavesplatform.wallet.request.OrderRequest; import com.wavesplatform.wallet.request.OrderType; import com.wavesplatform.wallet.ui.auth.PinEntryActivity; import com.wavesplatform.wallet.ui.base.BaseAuthActivity; @@ -38,6 +42,8 @@ import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -365,15 +371,23 @@ public void onShowToast(String message, @ToastCustom.ToastType String toastType) } @Override - public void showBalanceFromPair(LinkedTreeMap stringIntegerHashMap) { - ArrayList assets = new ArrayList<>(stringIntegerHashMap.values()); - if (stringIntegerHashMap.keySet().toArray()[0].equals(placeOrderViewModel.placeOrderModel.getWatchMarket().market.amountAsset)) { - binding.textAmountAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledText(assets.get(0), placeOrderViewModel.placeOrderModel.getWatchMarket().market.getAmountAssetInfo().decimals))); - binding.textPriceAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledPrice(assets.get(1), placeOrderViewModel.placeOrderModel.getWatchMarket().market.getAmountAssetInfo().decimals, placeOrderViewModel.placeOrderModel.getWatchMarket().market.getPriceAssetInfo().decimals))); - } else { - binding.textAmountAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledText(assets.get(1), placeOrderViewModel.placeOrderModel.getWatchMarket().market.getAmountAssetInfo().decimals))); - binding.textPriceAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledPrice(assets.get(0), placeOrderViewModel.placeOrderModel.getWatchMarket().market.getAmountAssetInfo().decimals, placeOrderViewModel.placeOrderModel.getWatchMarket().market.getPriceAssetInfo().decimals))); - } + public void trackPlaceOrder(OrderRequest order) { + Map eventValue = new HashMap(); + eventValue.put("af_order_pair", order.assetPair.getKey()); + eventValue.put("af_order_type", order.orderType.toString()); + eventValue.put("af_order_price", order.price); + eventValue.put("af_order_amount", order.amount); + AppsFlyerLib.getInstance().trackEvent(getApplicationContext(), "af_place_order", eventValue); + } + + @Override + public void showBalanceFromPair(LinkedTreeMap balances) { + AmountAssetInfo amountAssetInfo = placeOrderViewModel.placeOrderModel.getWatchMarket().market.getAmountAssetInfo(); + String amountAsset = placeOrderViewModel.placeOrderModel.getWatchMarket().market.amountAsset; + PriceAssetInfo priceAssetInfo = placeOrderViewModel.placeOrderModel.getWatchMarket().market.getPriceAssetInfo(); + String priceAsset = placeOrderViewModel.placeOrderModel.getWatchMarket().market.priceAsset; + binding.textAmountAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledText(balances.get(amountAsset), amountAssetInfo.decimals))); + binding.textPriceAssetValue.setText(MoneyUtil.getTextStripZeros(MoneyUtil.getScaledText(balances.get(priceAsset), priceAssetInfo.decimals))); } @Override diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderViewModel.java b/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderViewModel.java index 308262409..b152335cc 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderViewModel.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/dex/details/order/PlaceOrderViewModel.java @@ -7,8 +7,8 @@ import com.wavesplatform.wallet.R; import com.wavesplatform.wallet.api.NodeManager; import com.wavesplatform.wallet.api.mather.MatherManager; -import com.wavesplatform.wallet.data.access.AccessState; import com.wavesplatform.wallet.data.Events; +import com.wavesplatform.wallet.data.access.AccessState; import com.wavesplatform.wallet.data.exception.RetrofitException; import com.wavesplatform.wallet.data.rxjava.RxUtil; import com.wavesplatform.wallet.injection.Injector; @@ -77,6 +77,8 @@ public interface DataListener { void showProgressDialog(@StringRes int messageId, @Nullable String suffix); void dismissProgressDialog(); + + void trackPlaceOrder(OrderRequest signed); } public void getMatcherKey() { @@ -106,6 +108,7 @@ public void placeOrder() { .subscribe(o -> { if (dataListener != null){ mRxEventBus.post(new Events.NeedUpdateDataAfterPlaceOrder()); + dataListener.trackPlaceOrder(mOrderRequest); dataListener.afterSuccessfullyPlaceOrder(); dataListener.dismissProgressDialog(); } diff --git a/app/src/main/java/com/wavesplatform/wallet/ui/send/SendViewModel.java b/app/src/main/java/com/wavesplatform/wallet/ui/send/SendViewModel.java index df98ada28..2f54b7d98 100644 --- a/app/src/main/java/com/wavesplatform/wallet/ui/send/SendViewModel.java +++ b/app/src/main/java/com/wavesplatform/wallet/ui/send/SendViewModel.java @@ -5,6 +5,7 @@ import android.support.annotation.StringRes; import android.util.Log; +import com.appsflyer.AppsFlyerLib; import com.wavesplatform.wallet.R; import com.wavesplatform.wallet.api.NodeManager; import com.wavesplatform.wallet.data.access.AccessState; @@ -25,7 +26,9 @@ import com.wavesplatform.wallet.util.annotations.Thunk; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.inject.Inject; @@ -268,9 +271,17 @@ public TransferTransactionRequest signTransaction() { } } + private void trackSendPayment(TransferTransactionRequest request) { + Map eventValue = new HashMap(); + eventValue.put("af_amount", request.amount); + eventValue.put("af_asset_id", request.assetId); + AppsFlyerLib.getInstance().trackEvent(context, "af_transfer_tx", eventValue); + } + public void submitPayment(TransferTransactionRequest signed) { NodeManager.get().broadcastTransfer(signed) .compose(RxUtil.applySchedulersToObservable()).subscribe(tx -> { + trackSendPayment(signed); if (dataListener != null) dataListener.onShowTransactionSuccess(signed); }, err -> { diff --git a/app/src/main/java/com/wavesplatform/wallet/util/PersistentPrefs.java b/app/src/main/java/com/wavesplatform/wallet/util/PersistentPrefs.java index 9551ca02b..45b75c082 100644 --- a/app/src/main/java/com/wavesplatform/wallet/util/PersistentPrefs.java +++ b/app/src/main/java/com/wavesplatform/wallet/util/PersistentPrefs.java @@ -20,6 +20,7 @@ interface PersistentPrefs { String KEY_LAST_BACKUP_PROMPT = "last_backup_prompt"; String KEY_SECURITY_BACKUP_NEVER = "security_backup_never"; String KEY_ENCRYPTED_PIN_CODE = "encrypted_pin_code"; + String KEY_SEND_USAGE_STATS = "send_usage_stats"; String KEY_FINGERPRINT_ENABLED = "fingerprint_enabled"; String KEY_SHARED_KEY = "sharedKey"; diff --git a/app/src/main/java/com/wavesplatform/wallet/util/PrefsUtil.java b/app/src/main/java/com/wavesplatform/wallet/util/PrefsUtil.java index 391ac6e2a..f1360006e 100755 --- a/app/src/main/java/com/wavesplatform/wallet/util/PrefsUtil.java +++ b/app/src/main/java/com/wavesplatform/wallet/util/PrefsUtil.java @@ -48,7 +48,7 @@ public int getValue(String name, int value) { } private int getValueInternal(String name, int value) { - return preferenceManager.getInt(name, 0); + return preferenceManager.getInt(name, value); } public void setValue(String name, int value) { @@ -66,7 +66,7 @@ public long getValue(String name, long value) { } private long getValueInternal(String name, long value) { - return preferenceManager.getLong(name, 0L); + return preferenceManager.getLong(name, value); } public void setValue(String name, long value) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 946711ec2..7a58b8695 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -647,4 +647,9 @@ It looks like you scan address QR-code instead of seed. Please use correct QR-code. + + + Send usage statistics + Help to improve the Waves platform by sending anonymous usage statistics to the developers. + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6f7434de9..4ffad3900 100644 --- a/build.gradle +++ b/build.gradle @@ -4,18 +4,25 @@ buildscript { repositories { jcenter() + mavenCentral() maven { url "https://jitpack.io" } google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0' - classpath 'com.google.gms:google-services:3.0.0' + classpath 'com.google.gms:google-services:3.2.0' classpath 'io.realm:realm-gradle-plugin:3.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } + + configurations.all { + resolutionStrategy { + force 'net.sf.proguard:proguard-gradle:6.0.2' + } + } } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f10208fba..ced028534 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 29 13:45:25 MSK 2018 +#Thu Apr 26 23:07:07 MSK 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip