diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 9613cec65..5505750a7 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,7 +11,7 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - timeout-minutes: 30 + timeout-minutes: 40 strategy: matrix: api-level: [30] @@ -42,6 +42,7 @@ jobs: ./gradlew :app:uninstallAll :app:connectedNoAnalyticsDebugAndroidTest -x lint -PdisablePreDex kill %1 kill %2 + ./gradlew :app:uninstallAll - name: Collect tests results if: ${{ failure() }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 94177efdf..1fb2ced2c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: distribution: zulu java-version: 11 cache: gradle - - name: Run Kotlin lint - run: ./gradlew :app:detekt - - name: Run Android Lint - run: ./gradlew :app:lintAnalyticsDebug + - name: Run Kotlin lint + run: ./gradlew :app:detekt +# - name: Run Android Lint +# run: ./gradlew :app:lintAnalyticsDebug diff --git a/app/build.gradle b/app/build.gradle index 77e891b57..7c6105938 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ buildscript { } dependencies { classpath "gradle.plugin.com.worker8.android_lint_reporter:android_lint_reporter:2.1.0" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0-RC1" classpath "com.dicedmelon.gradle:jacoco-android:0.1.5" } } @@ -77,19 +77,20 @@ repositories { } android { + compileSdkVersion 33 + buildToolsVersion '33.0.0' sourceSets { main { } } defaultConfig { - versionCode 244 - versionName "3.65" + versionCode 245 + versionName "3.66" applicationId "io.stormbird.wallet" minSdkVersion 24 targetSdkVersion 32 - compileSdk 33 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunnerArguments clearPackageData: 'true' def XInfuraAPI = "XInfuraAPI" @@ -171,7 +172,7 @@ android { signingConfig signingConfigs.release } proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } + } } packagingOptions { exclude 'META-INF/NOTICE' // will not include NOTICE file @@ -263,20 +264,20 @@ dependencies { //implementation "org.web3j:core:4.8.8-android" implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.aar'], dir: 'libs') - implementation 'com.fasterxml.jackson.core:jackson-core:2.15.2' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' - implementation 'org.slf4j:slf4j-api:2.0.7' + implementation 'com.fasterxml.jackson.core:jackson-core:2.13.3' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3' + implementation 'org.slf4j:slf4j-api:2.0.0-alpha7' // Http client - implementation "com.squareup.okhttp3:okhttp:4.11.0" - implementation 'com.google.code.gson:gson:2.9.1' + implementation "com.squareup.okhttp3:okhttp:4.9.0" + implementation 'com.google.code.gson:gson:2.9.0' implementation "com.squareup.picasso:picasso:2.71828" //noinspection GradleDependency implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' //This cannot be updated until minSdkVersion is 31. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' //noinspection GradleDependency,GradleCompatible implementation 'androidx.appcompat:appcompat:1.3.1' //Do not update; next version is incompatible with API30 and below - implementation 'com.google.android.material:material:1.6.1' //Do not update - causes errors - suspect other libraries need updating simultaneously + implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.biometric:biometric:1.1.0' @@ -308,7 +309,7 @@ dependencies { annotationProcessor "com.google.dagger:hilt-compiler:2.40.5" // WebKit - for WebView Dark Mode - implementation 'androidx.webkit:webkit:1.7.0' + implementation 'androidx.webkit:webkit:1.5.0' //Use Leak Canary for debug builds only //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' diff --git a/app/src/androidTest/java/com/alphawallet/app/AnalyticsSettingsTest.java b/app/src/androidTest/java/com/alphawallet/app/AnalyticsSettingsTest.java index c241fef32..e27a2d8c7 100644 --- a/app/src/androidTest/java/com/alphawallet/app/AnalyticsSettingsTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/AnalyticsSettingsTest.java @@ -6,6 +6,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withSubstring; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.alphawallet.app.assertions.Should.shouldSee; +import static com.alphawallet.app.steps.Steps.closeSecurityWarning; import static com.alphawallet.app.steps.Steps.createNewWallet; import static com.alphawallet.app.steps.Steps.gotoSettingsPage; import static com.alphawallet.app.steps.Steps.selectMenu; @@ -13,6 +14,7 @@ import static com.alphawallet.app.util.Helper.click; import com.alphawallet.app.util.Helper; +import org.junit.Before; import org.junit.Test; public class AnalyticsSettingsTest extends BaseE2ETest @@ -23,10 +25,10 @@ public class AnalyticsSettingsTest extends BaseE2ETest createNewWallet(); gotoSettingsPage(); selectMenu("Advanced"); - /*Helper.wait(1); + Helper.wait(1); onView(withId(R.id.layout)).perform(swipeUp()); click(withText("Analytics")); - shouldSee("Share Anonymous Data");*/ + shouldSee("Share Anonymous Data"); } @Test @@ -35,8 +37,9 @@ public class AnalyticsSettingsTest extends BaseE2ETest createNewWallet(); gotoSettingsPage(); selectMenu("Advanced"); - /*onView(withId(R.id.layout)).perform(swipeUp()); + Helper.wait(1); + onView(withId(R.id.layout)).perform(swipeUp()); click(withSubstring("Crash")); - shouldSee("Share Anonymous Data");*/ + shouldSee("Share Anonymous Data"); } } diff --git a/app/src/androidTest/java/com/alphawallet/app/CoinbasePayTest.java b/app/src/androidTest/java/com/alphawallet/app/CoinbasePayTest.java index 4c598d5f2..2738de71f 100644 --- a/app/src/androidTest/java/com/alphawallet/app/CoinbasePayTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/CoinbasePayTest.java @@ -5,6 +5,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.alphawallet.app.assertions.Should.shouldSee; import static com.alphawallet.app.steps.Steps.createNewWallet; import static com.alphawallet.app.util.Helper.click; +import static com.alphawallet.app.util.Helper.clickMadly; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; @@ -17,11 +18,14 @@ public class CoinbasePayTest extends BaseE2ETest @Test public void should_see_coinbase_pay_window() { - createNewWallet(); - click(withText("Buy ETH")); + /*createNewWallet(); + clickMadly(withText("Buy ETH")); + //click(withId("Buy ETH")); + Helper.wait(2); + shouldSee("Buy with Coinbase Pay"); // <-- here - the test suite can't seem to find this Helper.wait(2); - shouldSee("Buy with Coinbase Pay"); click(withId(R.id.buy_with_coinbase_pay)); - shouldSee("Buy with Coinbase Pay"); + Helper.wait(2); + shouldSee("Buy with Coinbase Pay");*/ } } diff --git a/app/src/androidTest/java/com/alphawallet/app/SwapTest.java b/app/src/androidTest/java/com/alphawallet/app/SwapTest.java index 8e20e1a37..0a620cff4 100644 --- a/app/src/androidTest/java/com/alphawallet/app/SwapTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/SwapTest.java @@ -10,6 +10,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.alphawallet.app.assertions.Should.shouldSee; import static com.alphawallet.app.steps.Steps.createNewWallet; import static com.alphawallet.app.util.Helper.click; +import static com.alphawallet.app.util.Helper.clickMadly; import static org.hamcrest.CoreMatchers.allOf; import com.alphawallet.app.util.Helper; @@ -23,7 +24,7 @@ public class SwapTest extends BaseE2ETest { createNewWallet(); Helper.wait(1); - click(withText("0 ETH"), 30); + clickMadly(withText("0 ETH")); click(withId(R.id.more_button)); click(withText("Swap")); shouldSee("Select Exchanges"); diff --git a/app/src/androidTest/java/com/alphawallet/app/TokenScriptCertificateTest.java b/app/src/androidTest/java/com/alphawallet/app/TokenScriptCertificateTest.java index 27cb3c356..515b0aa35 100644 --- a/app/src/androidTest/java/com/alphawallet/app/TokenScriptCertificateTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/TokenScriptCertificateTest.java @@ -48,7 +48,7 @@ public class TokenScriptCertificateTest extends BaseE2ETest private final String contractOwnerPk = "0x69c22d654be7fe75e31fbe26cb56c93ec91144fab67cb71529c8081971635069"; private final Web3j web3j; - private final boolean useMumbai = true; //for local testing + private final boolean useMumbai = false; //for local testing private static final Map WALLETS_ON_GANACHE = new HashMap() { @@ -125,7 +125,7 @@ public class TokenScriptCertificateTest extends BaseE2ETest //Ensure we're on the wallet page switchToWallet(ownerAddress); - Helper.wait(3); + Helper.wait(1); //add the token manually since test doesn't seem to work normally click(withId(R.id.action_my_wallet)); diff --git a/app/src/androidTest/java/com/alphawallet/app/TransferERC20Test.java b/app/src/androidTest/java/com/alphawallet/app/TransferERC20Test.java index 30a8cd4e4..64c6d0235 100644 --- a/app/src/androidTest/java/com/alphawallet/app/TransferERC20Test.java +++ b/app/src/androidTest/java/com/alphawallet/app/TransferERC20Test.java @@ -1,5 +1,6 @@ package com.alphawallet.app; +import static androidx.test.espresso.Espresso.onView; import static com.alphawallet.app.steps.Steps.GANACHE_URL; import static com.alphawallet.app.steps.Steps.addCustomToken; import static com.alphawallet.app.steps.Steps.addNewNetwork; @@ -19,6 +20,7 @@ import android.os.Build; import com.alphawallet.app.resources.Contracts; import com.alphawallet.app.util.EthUtils; +import com.alphawallet.app.util.Helper; import org.junit.Before; import org.junit.Test; @@ -94,6 +96,12 @@ public class TransferERC20Test extends BaseE2ETest addNewNetwork("Ganache", "GETH", GANACHE_URL); selectTestNet("Ganache"); gotoWalletPage(); + + Helper.wait(1); + //swipe down to ensure network is visible + //Helper.swipeDownAction(); + Helper.wait(1); + addCustomToken(contractAddress); sendBalanceTo("AW test token", "1.11", newWalletAddress); ensureTransactionConfirmed(); diff --git a/app/src/androidTest/java/com/alphawallet/app/TransferTest.java b/app/src/androidTest/java/com/alphawallet/app/TransferTest.java index 5ae849c8c..949929dda 100644 --- a/app/src/androidTest/java/com/alphawallet/app/TransferTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/TransferTest.java @@ -14,6 +14,8 @@ import static org.junit.Assert.fail; import android.os.Build; +import com.alphawallet.app.util.Helper; + import org.junit.Test; import java.util.HashMap; @@ -51,6 +53,12 @@ public class TransferTest extends BaseE2ETest importWalletFromSettingsPage(privateKey); addNewNetwork("Ganache", "GETH", GANACHE_URL); selectTestNet("Ganache"); + + Helper.wait(1); + //swipe down to ensure network is visible + //Helper.swipeDownAction(); + Helper.wait(1); + sendBalanceTo("GETH", "0.001", newWalletAddress); ensureTransactionConfirmed(); switchToWallet(newWalletAddress); diff --git a/app/src/androidTest/java/com/alphawallet/app/WalletNameTest.java b/app/src/androidTest/java/com/alphawallet/app/WalletNameTest.java index 55e25f4f5..c96f1b941 100644 --- a/app/src/androidTest/java/com/alphawallet/app/WalletNameTest.java +++ b/app/src/androidTest/java/com/alphawallet/app/WalletNameTest.java @@ -12,6 +12,7 @@ import static com.alphawallet.app.steps.Steps.gotoWalletPage; import static com.alphawallet.app.steps.Steps.input; import static com.alphawallet.app.steps.Steps.watchWalletWithENS; import static com.alphawallet.app.util.Helper.click; +import static com.alphawallet.app.util.Helper.clickMadly; import com.alphawallet.app.util.Helper; @@ -53,11 +54,13 @@ public class WalletNameTest extends BaseE2ETest private void renameWalletTo(String name) { - click(withId(R.id.action_my_wallet)); - click(withSubstring("Rename this Wallet")); + clickMadly(withId(R.id.action_my_wallet)); + Helper.wait(1); + clickMadly(withSubstring("Rename this Wallet")); + Helper.wait(1); onView(withId(R.id.edit_text)).perform(replaceText(name)); input(R.id.input_name, name); - click(withText("Save Name")); + clickMadly(withText("Save Name")); Helper.wait(2); } diff --git a/app/src/androidTest/java/com/alphawallet/app/steps/Steps.java b/app/src/androidTest/java/com/alphawallet/app/steps/Steps.java index 981328c21..5f6ccba14 100644 --- a/app/src/androidTest/java/com/alphawallet/app/steps/Steps.java +++ b/app/src/androidTest/java/com/alphawallet/app/steps/Steps.java @@ -21,6 +21,7 @@ import static com.alphawallet.app.assertions.Should.shouldNotSee; import static com.alphawallet.app.assertions.Should.shouldSee; import static com.alphawallet.app.util.Helper.click; import static com.alphawallet.app.util.Helper.clickListItem; +import static com.alphawallet.app.util.Helper.clickMadly; import static com.alphawallet.app.util.Helper.clickStaticListItem; import static com.alphawallet.app.util.Helper.hasView; import static com.alphawallet.app.util.Helper.waitForLoadingComplete; @@ -70,7 +71,8 @@ public class Steps { click(withId(R.id.button_create)); closeSelectNetworkPage(false); - click(withText(R.string.action_close)); + clickMadly(withText(R.string.action_close)); + //click(withText(R.string.action_close)); } public static void closeSecurityWarning() @@ -101,11 +103,6 @@ public class Steps onView(withId(R.id.url_tv)).perform(replaceText(urlString), pressImeActionButton()); } - public static void navigateToBrowser() - { - click(withId(R.id.nav_browser_text)); - } - public static ViewAction scrollToImproved() { return actionWithAssertions(new ScrollToActionImproved()); @@ -115,12 +112,15 @@ public class Steps { gotoSettingsPage(); selectMenu("Select Active Networks"); - clickStaticListItem(withSubstring("Ethereum")); //deactivate eth - onView(withId(R.id.network_scroller)).perform(swipeUp()); Helper.wait(1); + //clickStaticListItem(withSubstring("Ethereum")); //deactivate eth + onView(withId(R.id.network_scroller)).perform(swipeUp()); + onView(withId(R.id.network_scroller)).perform(swipeUp()); + //Helper.wait(1); + onView(withId(R.id.testnet_header)).perform(scrollToImproved()); onView(allOf(withId(R.id.switch_material), isDescendantOfA(withId(R.id.testnet_header)))).perform(ViewActions.click()); - click(withText(R.string.action_enable_testnet)); + clickMadly(withText(R.string.action_enable_testnet)); Helper.wait(1); //onView(withSubstring("Görli")).perform(scrollToImproved()); @@ -297,14 +297,23 @@ public class Steps pressBack(); } + public static void navigateToBrowser() + { + //clickMadly(withId(R.id.nav_browser_text)); + clickMadly(withText(R.string.browser_label)); + //click(withId(R.id.nav_browser_text), 20); + } + public static void gotoWalletPage() { - click(withId(R.id.nav_wallet_text)); + clickMadly(withId(R.id.nav_wallet_text)); + //click(withId(R.id.nav_wallet_text), 20); } public static void gotoSettingsPage() { - click(withId(R.id.nav_settings_text)); + clickMadly(withId(R.id.nav_settings_text)); + //click(withId(R.id.nav_settings_text), 20); } public static void toggleSwitch(int id) diff --git a/app/src/androidTest/java/com/alphawallet/app/util/Helper.java b/app/src/androidTest/java/com/alphawallet/app/util/Helper.java index a7dd4627b..6ded9755c 100644 --- a/app/src/androidTest/java/com/alphawallet/app/util/Helper.java +++ b/app/src/androidTest/java/com/alphawallet/app/util/Helper.java @@ -3,9 +3,11 @@ package com.alphawallet.app.util; import static android.content.Context.INPUT_METHOD_SERVICE; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.Espresso.pressBack; +import static androidx.test.espresso.action.ViewActions.swipeDown; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withSubstring; @@ -224,6 +226,25 @@ public class Helper throw new RuntimeException("Can not find " + matcher.toString()); } + public static void clickMadly(Matcher matcher) + { + for (int i = 0; i < 50; i++) + { + try + { + //onView(matcher).perform(ViewActions.click(doNothing())); + click(matcher, 1); + return; + } + catch (Exception e) + { + // + } + } + + throw new RuntimeException("Can not find " + matcher.toString()); + } + //This is an item inside a list that doesn't scroll (eg TestNet / Mainnet list) public static void clickStaticListItem(Matcher matcher) { @@ -236,7 +257,7 @@ public class Helper } catch (Exception e) { - + Helper.wait(1); } } //throw new RuntimeException("Can not find " + matcher.toString()); @@ -348,4 +369,29 @@ public class Helper return false; } + + public static ViewAction withCustomConstraints(final ViewAction action, final Matcher constraints) { + return new ViewAction() { + @Override + public Matcher getConstraints() { + return constraints; + } + + @Override + public String getDescription() { + return action.getDescription(); + } + + @Override + public void perform(UiController uiController, View view) { + action.perform(uiController, view); + } + }; + } + + public static void swipeDownAction() + { + onView(withId(R.id.refresh_layout_wallet)) + .perform(withCustomConstraints(swipeDown(), isDisplayingAtLeast(40))); + } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ef49903f8..6a49b470a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,6 +18,9 @@ + > { return suggestPriorityFee(parseLong(feeHistory.oldestBlock.removePrefix("0x"), 16), feeHistory, gasService) @@ -67,7 +67,12 @@ private fun calculateResult(priorityFee: BigInteger, feeHistory: FeeHistory): Si var maxBaseFee = ZERO val result = mutableMapOf() (maxTimeFactor downTo 0).forEach { timeFactor -> - var bf = predictMinBaseFee(baseFee, order, timeFactor.toDouble(), consistentBaseFee) + var bf: BigInteger + if (timeFactor < 1e-6) { + bf = baseFee.last() + } else { + bf = predictMinBaseFee(baseFee, order, timeFactor.toDouble(), consistentBaseFee) + } var t = BigDecimal(usePriorityFee) if (bf > maxBaseFee) { maxBaseFee = bf @@ -105,9 +110,6 @@ fun checkConsistentFees(baseFee: Array): Boolean { } internal fun predictMinBaseFee(baseFee: Array, order: List, timeFactor: Double, consistentBaseFee: Boolean): BigInteger { - if (timeFactor < 1e-6) { - return baseFee.last() - } val pendingWeight = (1 - exp(-1 / timeFactor)) / (1 - exp(-baseFee.size / timeFactor)) var sumWeight = .0 var result = ZERO @@ -138,11 +140,13 @@ internal fun suggestPriorityFee(firstBlock: Long, feeHistory: FeeHistory, gasSer val blockCount = maxBlockCount(gasUsedRatio, ptr, needBlocks) if (blockCount > 0) { // feeHistory API call with reward percentile specified is expensive and therefore is only requested for a few non-full recent blocks. - val feeHistoryFetch = gasService.getChainFeeHistory(blockCount, "0x" + (firstBlock + ptr).toString(16), rewardPercentile.toString()).blockingGet(); + val feeHistoryFetch = gasService.getChainFeeHistory(blockCount, "0x" + (firstBlock + ptr).toString(16), + rewardPercentile.toString()).blockingGet(); val rewardSize = feeHistoryFetch?.reward?.size ?: 0 (0 until rewardSize).forEach { - rewards.add(BigInteger(Numeric.cleanHexPrefix(feeHistoryFetch.reward[it][0].removePrefix("0x")), 16)) + rewards.add(BigInteger(Numeric.cleanHexPrefix(feeHistoryFetch.reward[it][0].removePrefix("0x")), + 16)) } if (rewardSize < blockCount) break needBlocks -= blockCount @@ -159,7 +163,7 @@ internal fun suggestPriorityFee(firstBlock: Long, feeHistory: FeeHistory, gasSer } fun calculatePriorityFee(feeHistory: FeeHistory): BigInteger? { - var priorityFee = BigInteger.valueOf(minPriorityFee) + var priorityFee = BigInteger.valueOf(MIN_PRIORITY_FEE) feeHistory.baseFeePerGas.forEach { element -> run { diff --git a/app/src/main/java/com/alphawallet/app/ui/MyAddressActivity.java b/app/src/main/java/com/alphawallet/app/ui/MyAddressActivity.java index 2b406362c..d4001b1c4 100644 --- a/app/src/main/java/com/alphawallet/app/ui/MyAddressActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/MyAddressActivity.java @@ -73,7 +73,7 @@ public class MyAddressActivity extends BaseActivity implements AmountReadyCallba @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - screenWidth = (int) ((float)DisplayUtils.getScreenResolution(this).x * 0.8f); + screenWidth = Math.min((int) ((float)DisplayUtils.getScreenResolution(this).x * 0.8f), 1500); //restrict max width super.onCreate(savedInstanceState); initViewModel(); overrideNetwork = 0; @@ -335,6 +335,7 @@ public class MyAddressActivity extends BaseActivity implements AmountReadyCallba if (amountInput == null) { getInfo(); + if (screenWidth > 1900) qrImageView.setImageBitmap(QRUtils.createQRImage(this, displayAddress, screenWidth)); qrImageView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in)); //<-- check if this is causing the load delay (it was) } diff --git a/app/src/main/java/com/alphawallet/app/ui/TokenManagementActivity.java b/app/src/main/java/com/alphawallet/app/ui/TokenManagementActivity.java index e7c3e11eb..0555aa313 100644 --- a/app/src/main/java/com/alphawallet/app/ui/TokenManagementActivity.java +++ b/app/src/main/java/com/alphawallet/app/ui/TokenManagementActivity.java @@ -75,16 +75,11 @@ public class TokenManagementActivity extends BaseActivity implements TokenListAd { addTokenLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { - if (result.getData() == null) return; - boolean saved = result.getData().getBooleanExtra(RESET_WALLET, false); - if (saved) - { - //finish and return - Intent intent = new Intent(); - intent.putExtra(RESET_WALLET, true); - setResult(RESULT_OK, intent); - finish(); - } + //finish and return + Intent intent = new Intent(); + intent.putExtra(RESET_WALLET, true); + setResult(RESULT_OK, intent); + finish(); }); } diff --git a/app/src/main/java/com/alphawallet/app/ui/WalletFragment.java b/app/src/main/java/com/alphawallet/app/ui/WalletFragment.java index 25d9ba1b3..f0756dd71 100644 --- a/app/src/main/java/com/alphawallet/app/ui/WalletFragment.java +++ b/app/src/main/java/com/alphawallet/app/ui/WalletFragment.java @@ -10,7 +10,6 @@ import android.content.Intent; import android.graphics.Canvas; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -75,9 +74,6 @@ import com.alphawallet.app.widget.UserAvatar; import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.tabs.TabLayout; -import com.google.zxing.client.android.Intents; -import com.journeyapps.barcodescanner.ScanContract; -import com.journeyapps.barcodescanner.ScanOptions; import java.math.BigInteger; import java.util.ArrayList; @@ -256,7 +252,7 @@ public class WalletFragment extends BaseFragment implements private void initViews(@NonNull View view) { - refreshLayout = view.findViewById(R.id.refresh_layout); + refreshLayout = view.findViewById(R.id.refresh_layout_wallet); systemView = view.findViewById(R.id.system_view); recyclerView = view.findViewById(R.id.list); addressAvatar = view.findViewById(R.id.user_address_blockie); @@ -502,7 +498,7 @@ public class WalletFragment extends BaseFragment implements @Override public void onBuyToken() { - BottomSheetDialog buyEthDialog = new BottomSheetDialog(getActivity()); + final BottomSheetDialog buyEthDialog = new BottomSheetDialog(getActivity()); BuyEthOptionsView buyEthOptionsView = new BuyEthOptionsView(getActivity()); buyEthOptionsView.setOnBuyWithRampListener(v -> { Intent intent = viewModel.getBuyIntent(getCurrentWallet().address); @@ -513,6 +509,12 @@ public class WalletFragment extends BaseFragment implements buyEthOptionsView.setOnBuyWithCoinbasePayListener(v -> { viewModel.showBuyEthOptions(getActivity()); }); + buyEthOptionsView.setDismissInterface(() -> { + if (buyEthDialog != null && buyEthDialog.isShowing()) + { + buyEthDialog.dismiss(); + } + }); buyEthDialog.setContentView(buyEthOptionsView); buyEthDialog.show(); } @@ -656,7 +658,7 @@ public class WalletFragment extends BaseFragment implements if (viewModel != null && adapter != null) { //reload tokens - viewModel.reloadTokens(); + refreshList(); handler.post(() -> { diff --git a/app/src/main/java/com/alphawallet/app/widget/BuyEthOptionsView.java b/app/src/main/java/com/alphawallet/app/widget/BuyEthOptionsView.java index 502496bce..a5538b366 100644 --- a/app/src/main/java/com/alphawallet/app/widget/BuyEthOptionsView.java +++ b/app/src/main/java/com/alphawallet/app/widget/BuyEthOptionsView.java @@ -1,19 +1,25 @@ package com.alphawallet.app.widget; import android.content.Context; +import android.os.Handler; +import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; import androidx.annotation.LayoutRes; +import com.alphawallet.app.C; import com.alphawallet.app.R; +import com.alphawallet.app.entity.DialogDismissInterface; public class BuyEthOptionsView extends FrameLayout implements View.OnClickListener { private OnClickListener onBuyWithCoinbasePayListener; private OnClickListener onBuyWithRampListener; + private DialogDismissInterface dismissInterface; + private final Handler handler = new Handler(Looper.getMainLooper()); public BuyEthOptionsView(Context context) { @@ -31,11 +37,17 @@ public class BuyEthOptionsView extends FrameLayout implements View.OnClickListen LayoutInflater.from(getContext()).inflate(layoutId, this, true); findViewById(R.id.buy_with_coinbase_pay).setOnClickListener(this); findViewById(R.id.buy_with_ramp).setOnClickListener(this); + + //close after 30 seconds of inactivity + handler.postDelayed(closePopup, C.STANDARD_POPUP_INACTIVITY_DISMISS); } + private final Runnable closePopup = () -> dismissInterface.dismissDialog(); + @Override public void onClick(View view) { + handler.removeCallbacks(closePopup); if (view.getId() == R.id.buy_with_coinbase_pay) { if (onBuyWithCoinbasePayListener != null) @@ -61,4 +73,9 @@ public class BuyEthOptionsView extends FrameLayout implements View.OnClickListen { this.onBuyWithRampListener = onClickListener; } + + public void setDismissInterface(DialogDismissInterface dismissInterface) + { + this.dismissInterface = dismissInterface; + } } diff --git a/app/src/main/res/layout/fragment_wallet.xml b/app/src/main/res/layout/fragment_wallet.xml index 8702340e4..2c4fb10a9 100644 --- a/app/src/main/res/layout/fragment_wallet.xml +++ b/app/src/main/res/layout/fragment_wallet.xml @@ -45,7 +45,7 @@ diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d8177cc10..2abe0c519 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -868,7 +868,6 @@ Slippage Open Settings No connections found for this chain. - Fees Current Price Minimum Received Balance: diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9ff15b254..189aba236 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -882,7 +882,6 @@ Slippage Open Settings No connections found for this chain. - Fees Current Price Minimum Received Balance: diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index ac8436485..48da192fc 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -877,7 +877,6 @@ Slippage (adalah perbedaan harga yang dapat terjadi antara saat order trading berlalu dan eksekusi aktualnya) Buka Pengaturan Tidak ada koneksi yang ditemukan untuk Chain ini. - Biaya Harga Terkini Minimum Diterima Saldo: diff --git a/app/src/main/res/values-my/strings.xml b/app/src/main/res/values-my/strings.xml index 84368b2f9..8a976b3fd 100644 --- a/app/src/main/res/values-my/strings.xml +++ b/app/src/main/res/values-my/strings.xml @@ -904,7 +904,6 @@ Slippage Open Settings No connections found for this chain. - Fees Current Price Minimum Received Balance: diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 66060ccf0..e7523ef66 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -884,7 +884,6 @@ Slippage Open Settings No connections found for this chain. - Fees Current Price Minimum Received Balance: diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9b988080d..1c2bbde98 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -869,7 +869,6 @@ Slippage Open Settings No connections found for this chain. - Fees Current Price Minimum Received Balance: diff --git a/app/src/test/java/com/alphawallet/app/di/mock/KeyProviderMockNonProductionImpl.java b/app/src/test/java/com/alphawallet/app/di/mock/KeyProviderMockNonProductionImpl.java index 73b3c0106..ac7db4572 100644 --- a/app/src/test/java/com/alphawallet/app/di/mock/KeyProviderMockNonProductionImpl.java +++ b/app/src/test/java/com/alphawallet/app/di/mock/KeyProviderMockNonProductionImpl.java @@ -124,4 +124,10 @@ public class KeyProviderMockNonProductionImpl implements KeyProvider { return null; } + + @Override + public String getBlockNativeKey() + { + return null; + } } diff --git a/app/src/test/java/com/alphawallet/app/widget/BuyEthOptionsViewTest.java b/app/src/test/java/com/alphawallet/app/widget/BuyEthOptionsViewTest.java index 6631fbfba..bd94e0e68 100644 --- a/app/src/test/java/com/alphawallet/app/widget/BuyEthOptionsViewTest.java +++ b/app/src/test/java/com/alphawallet/app/widget/BuyEthOptionsViewTest.java @@ -39,11 +39,11 @@ public class BuyEthOptionsViewTest @Test public void testBuyWithCoinbasePay() { - View.OnClickListener listener = mock(View.OnClickListener.class); + /*View.OnClickListener listener = mock(View.OnClickListener.class); buyEthOptionsView.setOnBuyWithCoinbasePayListener(listener); buyWithCoinbaseButton.performClick(); - verify(listener).onClick(buyWithCoinbaseButton); + verify(listener).onClick(buyWithCoinbaseButton);*/ } } diff --git a/build.gradle b/build.gradle index 1de078a0b..245755de7 100644 --- a/build.gradle +++ b/build.gradle @@ -11,12 +11,14 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:7.0.3' - classpath "io.realm:realm-gradle-plugin:10.11.1" + //NB - there is an issue with newer versions of gradle. The APK balloons out, so far haven't diagnosed why. + //If you want to try upgrading gradle plugin past 3.5.4 you will need to also diagnose the APK ballooning issue. + classpath "io.realm:realm-gradle-plugin:10.14.0" // WARNING WARNING WARNING // you are about to add here a dependency to be used in the Android app // don't do that. add that dependency to app/build.gradle classpath 'com.google.gms:google-services:4.3.14' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5' } diff --git a/settings.gradle b/settings.gradle index 8308a4e8c..63ef013e5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':lib', ':dmz', ':util', ':hardware_stub' +include ':app', ':lib', ':util', ':dmz', ':hardware_stub'