From 910b08642bfe9f168cdd054a3905cf0bd20ba70c Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 29 Jul 2021 23:56:59 +0300 Subject: [PATCH 001/122] Nil currencyCode crash fix --- cosmos-core/src/iosMain/kotlin/com/brd/util/CommonLocale.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cosmos-core/src/iosMain/kotlin/com/brd/util/CommonLocale.kt b/cosmos-core/src/iosMain/kotlin/com/brd/util/CommonLocale.kt index 78ae566b8..54e266678 100644 --- a/cosmos-core/src/iosMain/kotlin/com/brd/util/CommonLocale.kt +++ b/cosmos-core/src/iosMain/kotlin/com/brd/util/CommonLocale.kt @@ -13,7 +13,7 @@ import platform.Foundation.* actual typealias CommonLocale = NSLocale actual val CommonLocale.currencyCode: String - get() = checkNotNull(currencyCode()) + get() = currencyCode() ?: "usd" actual val CommonLocale.countryCode: String get() = countryCode() ?: "" From 713dd012e48871060ce084a5da56c4d041e27fac Mon Sep 17 00:00:00 2001 From: Amit Goel Date: Thu, 29 Jul 2021 21:09:47 +0000 Subject: [PATCH 002/122] DROID-2013: Adds flipper debug tool --- .../tools/manager/BRSharedPrefs.kt | 6 +++ .../src/main/java/com/platform/APIClient.kt | 12 +----- brd-android/app/build.gradle.kts | 3 ++ .../app/src/debug/java/DebugAppHooks.kt | 35 ++++++++++++++++++ .../main/java/com/breadwallet/app/BreadApp.kt | 37 +++++++++++++------ .../breadwallet/ui/BaseMobiusController.kt | 4 +- .../ui/settings/SettingsController.kt | 2 +- .../breadwallet/ui/settings/SettingsOption.kt | 1 + .../breadwallet/ui/settings/SettingsScreen.kt | 1 + .../ui/settings/SettingsScreenHandler.kt | 12 ++++++ .../breadwallet/ui/settings/SettingsUpdate.kt | 1 + .../ui/wallet/BrdWalletController.kt | 3 +- .../app/src/release/java/ReleaseAppHooks.kt | 6 +++ buildSrc/src/main/kotlin/brd/Libs.kt | 8 ++++ 14 files changed, 104 insertions(+), 27 deletions(-) diff --git a/brd-android/app-core/src/main/java/com/breadwallet/tools/manager/BRSharedPrefs.kt b/brd-android/app-core/src/main/java/com/breadwallet/tools/manager/BRSharedPrefs.kt index 15a52505e..4a48c8703 100644 --- a/brd-android/app-core/src/main/java/com/breadwallet/tools/manager/BRSharedPrefs.kt +++ b/brd-android/app-core/src/main/java/com/breadwallet/tools/manager/BRSharedPrefs.kt @@ -102,6 +102,7 @@ object BRSharedPrefs { private const val APP_RATE_PROMPT_DONT_ASK_AGAIN = "app-rate-prompt-dont-ask-again" private const val APP_RATE_PROMPT_SHOULD_PROMPT = "app-rate-prompt-should-prompt" private const val APP_RATE_PROMPT_SHOULD_PROMPT_DEBUG = "app-rate-prompt-should-prompt-debug" + private const val FLIPPER_ENABLED_DEBUG = "flipper-enabled-debug" const val APP_FOREGROUNDED_COUNT = "appForegroundedCount" const val APP_RATE_PROMPT_HAS_RATED = "appReviewPromptHasRated" @@ -611,6 +612,11 @@ object BRSharedPrefs { set(value) = brdPrefs.edit { putBoolean(APP_RATE_PROMPT_DONT_ASK_AGAIN, value) } .also { promptChangeChannel.offer(Unit) } + var flipperEnabledDebug: Boolean + get() = brdPrefs.getBoolean(FLIPPER_ENABLED_DEBUG, false) + set(value) = brdPrefs.edit { putBoolean(FLIPPER_ENABLED_DEBUG, value) } + .also { promptChangeChannel.offer(Unit) } + fun promptChanges(): Flow = promptChangeChannel.asFlow() .onStart { emit(Unit) } diff --git a/brd-android/app-core/src/main/java/com/platform/APIClient.kt b/brd-android/app-core/src/main/java/com/platform/APIClient.kt index ff6ee0538..fbc6a51cb 100644 --- a/brd-android/app-core/src/main/java/com/platform/APIClient.kt +++ b/brd-android/app-core/src/main/java/com/platform/APIClient.kt @@ -60,6 +60,7 @@ class APIClient( private var context: Context, private val userManager: BrdUserManager, private val brdPreferences: BrdPreferences, + private val okHttpClient: OkHttpClient, headers: Map ) { @@ -83,15 +84,6 @@ class APIClient( private var mIsFetchingToken: Boolean = false - private val mHTTPClient: OkHttpClient by lazy { - OkHttpClient.Builder() - .followRedirects(false) - .connectTimeout(CONNECTION_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS) - .readTimeout(CONNECTION_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS) - .writeTimeout(CONNECTION_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS) - .build() - } - private var mIsPlatformUpdating = false private val mItemsLeftToUpdate = AtomicInteger(0) @@ -193,7 +185,7 @@ class APIClient( val rawResponse: Response try { - rawResponse = mHTTPClient.newCall(request).execute() + rawResponse = okHttpClient.newCall(request).execute() } catch (e: IOException) { logError("sendRequest: ", e) val message = e.message ?: "" diff --git a/brd-android/app/build.gradle.kts b/brd-android/app/build.gradle.kts index 90d7bde36..6533e9aae 100644 --- a/brd-android/app/build.gradle.kts +++ b/brd-android/app/build.gradle.kts @@ -248,6 +248,9 @@ dependencies { // Debugging/Monitoring debugImplementation(Libs.LeakCanary.Core) debugImplementation(Libs.AnrWatchdog.Core) + debugImplementation(Libs.Flipper.flipper) + debugImplementation(Libs.Flipper.flipperNetwork) + debugImplementation(Libs.Flipper.flipperSo) compileOnly(Libs.Redacted.Annotation) diff --git a/brd-android/app/src/debug/java/DebugAppHooks.kt b/brd-android/app/src/debug/java/DebugAppHooks.kt index 2bbca0a30..9d5639b5d 100644 --- a/brd-android/app/src/debug/java/DebugAppHooks.kt +++ b/brd-android/app/src/debug/java/DebugAppHooks.kt @@ -8,9 +8,44 @@ */ package com.breadwallet +import android.content.Context import com.breadwallet.app.BreadApp +import com.breadwallet.tools.manager.BRSharedPrefs import com.github.anrwatchdog.ANRWatchDog +import com.facebook.flipper.android.AndroidFlipperClient +import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin +import com.facebook.flipper.plugins.inspector.DescriptorMapping +import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin +import com.facebook.flipper.plugins.navigation.NavigationFlipperPlugin +import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor +import com.facebook.flipper.plugins.network.NetworkFlipperPlugin +import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin +import com.facebook.soloader.SoLoader +import okhttp3.Interceptor internal fun BreadApp.installHooks() { ANRWatchDog().start() } + +fun initializeFlipper(context: Context) { + if (BRSharedPrefs.flipperEnabledDebug) { + // Flipper init + SoLoader.init(context, false) + AndroidFlipperClient.getInstance(context).apply { + addPlugin( + InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()) + ) + addPlugin(networkFlipperPlugin) + addPlugin(SharedPreferencesFlipperPlugin(context)) + addPlugin(NavigationFlipperPlugin.getInstance()) + addPlugin(DatabasesFlipperPlugin(context)) + }.also { it.start() } + } +} + +private val networkFlipperPlugin = NetworkFlipperPlugin() + +@Suppress("RedundantNullableReturnType") +fun getFlipperOkhttpInterceptor(): Interceptor? { + return FlipperOkhttpInterceptor(networkFlipperPlugin) +} diff --git a/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt b/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt index 4f5dca17e..3f2d8410c 100644 --- a/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt +++ b/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt @@ -225,7 +225,13 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { } bind() with singleton { - APIClient(this@BreadApp, direct.instance(), direct.instance(), createHttpHeaders()) + APIClient( + context = this@BreadApp, + userManager = direct.instance(), + brdPreferences = direct.instance(), + okHttpClient = direct.instance(), + headers = createHttpHeaders() + ) } bind() with singleton { @@ -246,7 +252,14 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { bind() with singleton { metaDataManager } - bind() with singleton { OkHttpClient() } + bind() with singleton { + OkHttpClient().newBuilder().apply { + // conditionally apply flipper interceptor on debug builds + getFlipperOkhttpInterceptor()?.let { + addNetworkInterceptor(it) + } + }.build() + } bind() with singleton { val httpClient = instance() @@ -266,6 +279,7 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { bind() with singleton { HttpClient(OkHttp) { engine { + preconfigured = instance() config { retryOnConnectionFailure(true) } @@ -283,11 +297,11 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { bind() with singleton { CoreBreadBox( - File(filesDir, WALLETKIT_DATA_DIR_NAME), - !BuildConfig.BITCOIN_TESTNET, - instance(), - instance(), - instance() + storageFile = File(filesDir, WALLETKIT_DATA_DIR_NAME), + isMainnet = !BuildConfig.BITCOIN_TESTNET, + walletProvider = instance(), + blockchainDb = instance(), + userManager = instance() ) } @@ -297,9 +311,9 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { bind() with singleton { RatesFetcher( - instance(), - instance(), - this@BreadApp + accountMetaData = instance(), + okhttp = instance(), + context = this@BreadApp ) } @@ -579,8 +593,7 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { .firstOrNull() // The BRD server expects the following user agent: appName/appVersion engine/engineVersion plaform/plaformVersion - val brdUserAgent = - "${APIClient.UA_APP_NAME}${BuildConfig.VERSION_CODE} $deviceUserAgent ${APIClient.UA_PLATFORM}${Build.VERSION.RELEASE}" + val brdUserAgent = "${APIClient.UA_APP_NAME}${BuildConfig.VERSION_CODE} $deviceUserAgent ${APIClient.UA_PLATFORM}${Build.VERSION.RELEASE}" return mapOf( APIClient.HEADER_IS_INTERNAL to if (BuildConfig.IS_INTERNAL_BUILD) BRConstants.TRUE else BRConstants.FALSE, diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/BaseMobiusController.kt b/brd-android/app/src/main/java/com/breadwallet/ui/BaseMobiusController.kt index 457b81267..1d1613fc0 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/BaseMobiusController.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/BaseMobiusController.kt @@ -226,11 +226,11 @@ abstract class BaseMobiusController( } private fun connectView(loop: MobiusLoop) { - val legacyDispose = bindView(Consumer { event -> + val legacyDispose = bindView { event -> if (isLoopActive.get()) { loop.dispatchEvent(event) } - }) + } val job = SupervisorJob() val scope = CoroutineScope(job + Dispatchers.Main + errorHandler("modelConsumer")) diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsController.kt b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsController.kt index 601588c13..ba6d48ec4 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsController.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsController.kt @@ -139,7 +139,7 @@ class SettingsController( settingsList.adapter = adapter } ifChanged(M::isLoading) { - loadingView.root.visibility = if(isLoading) View.VISIBLE else View.GONE + loadingView.root.isVisible = isLoading } } } diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsOption.kt b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsOption.kt index 6012542cc..db8b95838 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsOption.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsOption.kt @@ -52,6 +52,7 @@ enum class SettingsOption { COPY_PAPER_KEY, METADATA_VIEWER, NATIVE_EXCHANGE_UI, + ENABLE_FLIPPER_CLIENT, // BTC REDEEM_PRIVATE_KEY, diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreen.kt b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreen.kt index 12a3757b9..8f62271a5 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreen.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreen.kt @@ -81,6 +81,7 @@ object SettingsScreen { object RefreshTokens : F() object DetailedLogging : F() object CopyPaperKey : F() + object ToggleFlipperClientEnabled : F() data class SetApiServer(val host: String) : F() data class SetPlatformDebugUrl(val url: String) : F() diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreenHandler.kt b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreenHandler.kt index 0a31226f8..cd8512e7a 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreenHandler.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsScreenHandler.kt @@ -27,6 +27,7 @@ import com.breadwallet.crypto.Wallet import com.breadwallet.crypto.WalletManagerMode import com.breadwallet.crypto.WalletManagerState import com.breadwallet.ext.throttleLatest +import com.breadwallet.initializeFlipper import com.breadwallet.logger.Logger import com.breadwallet.logger.logDebug import com.breadwallet.model.Experiments @@ -218,6 +219,11 @@ class SettingsScreenHandler( brdPreferences.hydraActivated = true brdClient.host = BrdApiHost.hostFor(BuildConfig.DEBUG, true) } + F.ToggleFlipperClientEnabled -> { + BRSharedPrefs.flipperEnabledDebug = + !BRSharedPrefs.flipperEnabledDebug + initializeFlipper(context) + } } } @@ -398,6 +404,7 @@ class SettingsScreenHandler( "" } val toggleRateAppPromptAddOn = BRSharedPrefs.appRatePromptShouldPromptDebug + val toggleFlipperDebugAddOn = BRSharedPrefs.flipperEnabledDebug return listOf( SettingsItem( "Copy Paper Key", @@ -460,6 +467,11 @@ class SettingsScreenHandler( SettingsItem( "Activate Hydra (Native Exchange UI)", SettingsOption.NATIVE_EXCHANGE_UI, + ), + SettingsItem( + "Toggle Flipper Debug Client", + SettingsOption.ENABLE_FLIPPER_CLIENT, + addOn = "enabled=$toggleFlipperDebugAddOn" ) ) + getHiddenOptions() } diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsUpdate.kt b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsUpdate.kt index 514a6b695..c8d1fff4b 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsUpdate.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/settings/SettingsUpdate.kt @@ -150,6 +150,7 @@ object SettingsUpdate : Update, SettingsScreenUpdateSpec { SettingsOption.NATIVE_EXCHANGE_UI -> F.EnableNativeExchangeUI SettingsOption.ORDER_HISTORY -> F.GoToOrderHistory SettingsOption.REGION_PREFERENCES -> F.GoToRegionPreferences + SettingsOption.ENABLE_FLIPPER_CLIENT -> F.ToggleFlipperClientEnabled } ) ) diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/wallet/BrdWalletController.kt b/brd-android/app/src/main/java/com/breadwallet/ui/wallet/BrdWalletController.kt index 91ff644cc..a966fcb80 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/wallet/BrdWalletController.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/wallet/BrdWalletController.kt @@ -154,8 +154,7 @@ class BrdWalletController : WalletController("BRD") { companion object { private val CONFETTI_VIDEO_URI = Uri.parse( - "android.resource://" - + BuildConfig.APPLICATION_ID + File.separator + R.raw.confetti + "android.resource://${BuildConfig.APPLICATION_ID}${File.separator}${R.raw.confetti}" ) private const val UNINITIALIZED_POSITION = -1 private const val COLLAPSE_REWARDS_DELAY_MILLISECONDS = 6000 diff --git a/brd-android/app/src/release/java/ReleaseAppHooks.kt b/brd-android/app/src/release/java/ReleaseAppHooks.kt index ba808539a..25850ee8e 100644 --- a/brd-android/app/src/release/java/ReleaseAppHooks.kt +++ b/brd-android/app/src/release/java/ReleaseAppHooks.kt @@ -8,8 +8,14 @@ */ package com.breadwallet +import android.content.Context import com.breadwallet.app.BreadApp +import okhttp3.Interceptor internal fun BreadApp.installHooks() { } + +fun initializeFlipper(context: Context) = Unit // No-Op for Release builds + +fun getFlipperOkhttpInterceptor(): Interceptor? = null diff --git a/buildSrc/src/main/kotlin/brd/Libs.kt b/buildSrc/src/main/kotlin/brd/Libs.kt index 22edcea4a..d8ca391a8 100644 --- a/buildSrc/src/main/kotlin/brd/Libs.kt +++ b/buildSrc/src/main/kotlin/brd/Libs.kt @@ -67,6 +67,8 @@ const val COMPOSE_VERSION = "1.0.0-beta02" private const val ACCOMPANIST_VERSION = "0.6.2" private const val MOBIUSKT_VERSION = "0.1.9" private const val BLOCKSET_VERSION = "0.1.3.1" +private const val FLIPPER_VERSION = "0.100.0" +private const val FLIPPER_SO_VERSION = "0.10.1" object Libs { @@ -267,4 +269,10 @@ object Libs { const val Android = "org.drewcarlson:mobiuskt-android:$MOBIUSKT_VERSION" const val Coroutines = "org.drewcarlson:mobiuskt-coroutines:$MOBIUSKT_VERSION" } + + object Flipper { + const val flipper = "com.facebook.flipper:flipper:$FLIPPER_VERSION" + const val flipperNetwork = "com.facebook.flipper:flipper-network-plugin:$FLIPPER_VERSION" + const val flipperSo = "com.facebook.soloader:soloader:$FLIPPER_SO_VERSION" + } } From 4087e11a2c87dd786c16991e40d26d3df4bfa2d6 Mon Sep 17 00:00:00 2001 From: Drew Carlson Date: Thu, 29 Jul 2021 22:03:20 +0000 Subject: [PATCH 003/122] DROID-1955: Lazy init BrdPreferences --- brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt b/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt index 3f2d8410c..3632e4f82 100644 --- a/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt +++ b/brd-android/app/src/main/java/com/breadwallet/app/BreadApp.kt @@ -379,7 +379,7 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { private val accountMetaData by instance() private val conversionTracker by instance() private val connectivityStateProvider by instance() - private val brdPreferences = direct.instance() + private val brdPreferences by instance() override fun onCreate() { super.onCreate() @@ -407,7 +407,6 @@ class BreadApp : Application(), KodeinAware, CameraXConfig.Provider { TokenUtil.initialize(mInstance, false, !BuildConfig.BITCOIN_TESTNET) } - val brdPreferences = direct.instance() if (brdPreferences.hydraActivated) { direct.instance().fetchData() } else { From 87fbb0046a36cda86291719a0ef39a9f667fa7a4 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 30 Jul 2021 20:18:39 +0300 Subject: [PATCH 004/122] adding plists back so that xcode compiles after checkout --- .gitignore | 1 + .../Cosmos.xcframework/Info.plist | 43 +++++++++++++++++++ .../Cosmos.framework/Info.plist | 35 +++++++++++++++ .../Cosmos.framework/Info.plist | 31 +++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 cosmos-bundled/build-frameworks/Cosmos.xcframework/Info.plist create mode 100644 cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64-simulator/Cosmos.framework/Info.plist create mode 100644 cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-x86_64-simulator/Cosmos.framework/Info.plist diff --git a/.gitignore b/.gitignore index eafc358e2..a8c5b47df 100644 --- a/.gitignore +++ b/.gitignore @@ -137,4 +137,5 @@ DerivedData/ cosmos-bundled/build-frameworks/ !cosmos-bundled/build-frameworks/Cosmos.xcframework/Info.plist !cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64/Cosmos.framework/Info.plist +!cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64-simulator/Cosmos.framework/Info.plist !cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-x86_64-simulator/Cosmos.framework/Info.plist diff --git a/cosmos-bundled/build-frameworks/Cosmos.xcframework/Info.plist b/cosmos-bundled/build-frameworks/Cosmos.xcframework/Info.plist new file mode 100644 index 000000000..fe790bf39 --- /dev/null +++ b/cosmos-bundled/build-frameworks/Cosmos.xcframework/Info.plist @@ -0,0 +1,43 @@ + + + + + AvailableLibraries + + + DebugSymbolsPath + dSYMs + LibraryIdentifier + ios-x86_64-simulator + LibraryPath + Cosmos.framework + SupportedArchitectures + + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + DebugSymbolsPath + dSYMs + LibraryIdentifier + ios-arm64 + LibraryPath + Cosmos.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64-simulator/Cosmos.framework/Info.plist b/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64-simulator/Cosmos.framework/Info.plist new file mode 100644 index 000000000..4a8cf4f13 --- /dev/null +++ b/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-arm64-simulator/Cosmos.framework/Info.plist @@ -0,0 +1,35 @@ + + + + + CFBundleExecutable + Cosmos + CFBundleIdentifier + com.brd.Cosmos + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Cosmos + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + iPhoneSimulator + + CFBundleVersion + 1 + MinimumOSVersion + 9.0 + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + arm64 + + + diff --git a/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-x86_64-simulator/Cosmos.framework/Info.plist b/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-x86_64-simulator/Cosmos.framework/Info.plist new file mode 100644 index 000000000..3deb45b06 --- /dev/null +++ b/cosmos-bundled/build-frameworks/Cosmos.xcframework/ios-x86_64-simulator/Cosmos.framework/Info.plist @@ -0,0 +1,31 @@ + + + + + CFBundleExecutable + Cosmos + CFBundleIdentifier + com.brd.Cosmos + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Cosmos + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + iPhoneSimulator + + CFBundleVersion + 1 + MinimumOSVersion + 9.0 + UIDeviceFamily + + 1 + 2 + + + \ No newline at end of file From dcf1596b671b3c159f29c8d350b8da09e6d1f197 Mon Sep 17 00:00:00 2001 From: Amit Goel Date: Tue, 3 Aug 2021 20:13:09 +0000 Subject: [PATCH 005/122] DROID-2014: Removes BaseTextView and moves line spacing attr to styles --- .../presenter/customviews/BaseTextView.java | 44 --- .../customviews/AutoResizeTextView.java | 321 ------------------ .../customviews/BRNotificationBar.java | 10 +- .../com/breadwallet/ui/home/HomeController.kt | 16 +- .../layout/activity_in_app_notification.xml | 5 +- .../main/res/layout/activity_notification.xml | 11 +- .../src/main/res/layout/activity_web_view.xml | 12 +- .../src/main/res/layout/add_wallets_item.xml | 9 +- .../app/src/main/res/layout/baker_view.xml | 20 +- .../app/src/main/res/layout/base_prompt.xml | 8 +- .../main/res/layout/bread_alert_dialog.xml | 16 +- .../main/res/layout/bread_spinner_item.xml | 7 +- .../app/src/main/res/layout/chart_view.xml | 33 +- .../src/main/res/layout/controller_about.xml | 37 +- .../res/layout/controller_add_wallets.xml | 6 +- .../res/layout/controller_alert_dialog.xml | 6 +- .../controller_confirm_gift_details.xml | 40 +-- .../controller_confirm_trade_details.xml | 37 +- .../layout/controller_confirm_tx_details.xml | 46 +-- .../main/res/layout/controller_disabled.xml | 11 +- .../layout/controller_display_currency.xml | 2 +- .../res/layout/controller_enable_segwit.xml | 17 +- .../main/res/layout/controller_fast_sync.xml | 6 +- .../controller_fingerprint_settings.xml | 6 +- .../src/main/res/layout/controller_home.xml | 20 +- .../res/layout/controller_import_password.xml | 6 +- .../res/layout/controller_import_wallet.xml | 10 +- .../src/main/res/layout/controller_intro.xml | 4 +- .../res/layout/controller_intro_recover.xml | 5 +- .../res/layout/controller_legacy_address.xml | 8 +- .../src/main/res/layout/controller_login.xml | 5 +- .../res/layout/controller_node_selector.xml | 22 +- .../controller_notification_settings.xml | 8 +- .../res/layout/controller_onboarding_page.xml | 6 +- .../main/res/layout/controller_paper_key.xml | 9 +- .../res/layout/controller_paper_key_prove.xml | 10 +- .../src/main/res/layout/controller_pin.xml | 8 +- .../main/res/layout/controller_pin_input.xml | 5 +- .../main/res/layout/controller_receive.xml | 12 +- .../res/layout/controller_recovery_key.xml | 29 +- .../res/layout/controller_select_baker.xml | 2 +- .../main/res/layout/controller_send_sheet.xml | 17 +- .../main/res/layout/controller_settings.xml | 8 +- .../main/res/layout/controller_share_data.xml | 7 +- .../main/res/layout/controller_share_gift.xml | 10 +- .../src/main/res/layout/controller_signal.xml | 7 +- .../main/res/layout/controller_staking.xml | 12 +- .../res/layout/controller_sync_blockchain.xml | 17 +- .../src/main/res/layout/controller_wallet.xml | 2 +- .../res/layout/controller_wipe_wallet.xml | 6 +- .../main/res/layout/controller_write_down.xml | 5 +- .../app/src/main/res/layout/currency_item.xml | 5 +- .../main/res/layout/currency_list_item.xml | 3 +- .../main/res/layout/dialog_bch_welcome.xml | 16 +- .../app/src/main/res/layout/email_prompt.xml | 11 +- .../src/main/res/layout/fragment_support.xml | 4 +- .../main/res/layout/fragment_word_item.xml | 2 +- .../src/main/res/layout/market_data_view.xml | 30 +- .../src/main/res/layout/notification_bar.xml | 7 +- .../app/src/main/res/layout/prompt_item.xml | 6 +- .../src/main/res/layout/rate_app_prompt.xml | 8 +- .../res/layout/rewards_announcement_view.xml | 10 +- .../main/res/layout/settings_list_item.xml | 8 +- .../app/src/main/res/layout/staking_view.xml | 3 +- .../src/main/res/layout/token_list_item.xml | 10 +- .../main/res/layout/transaction_details.xml | 72 ++-- .../app/src/main/res/layout/tx_item.xml | 24 +- .../main/res/layout/view_delisted_token.xml | 4 +- .../src/main/res/layout/wallet_list_item.xml | 21 +- .../res/layout/wallet_sync_progress_view.xml | 2 +- .../src/main/res/layout/wallet_toolbar.xml | 3 +- .../theme/src/main/res/values/styles.xml | 1 + 72 files changed, 352 insertions(+), 884 deletions(-) delete mode 100644 brd-android/app-core/src/main/java/com/breadwallet/legacy/presenter/customviews/BaseTextView.java delete mode 100644 brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/AutoResizeTextView.java diff --git a/brd-android/app-core/src/main/java/com/breadwallet/legacy/presenter/customviews/BaseTextView.java b/brd-android/app-core/src/main/java/com/breadwallet/legacy/presenter/customviews/BaseTextView.java deleted file mode 100644 index 4d928c467..000000000 --- a/brd-android/app-core/src/main/java/com/breadwallet/legacy/presenter/customviews/BaseTextView.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.breadwallet.legacy.presenter.customviews; - -import android.annotation.SuppressLint; -import android.content.Context; -import androidx.annotation.Nullable; -import android.util.AttributeSet; -import android.widget.TextView; - -/** - * BreadWallet - * - * Created by Mihail Gutan on 5/3/17. - * Copyright (c) 2021 Breadwinner AG - * - * SPDX-License-Identifier: BUSL-1.1 - */ -@SuppressLint("AppCompatCustomView") // we don't need to support older versions -public class BaseTextView extends TextView { - private static final float DEFAULT_LINE_SPACING = 1.3f; - - public BaseTextView(Context context) { - super(context); - } - - public BaseTextView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public BaseTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - public BaseTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - setLineSpacing(0, DEFAULT_LINE_SPACING); - } - -} diff --git a/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/AutoResizeTextView.java b/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/AutoResizeTextView.java deleted file mode 100644 index 31cd23efe..000000000 --- a/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/AutoResizeTextView.java +++ /dev/null @@ -1,321 +0,0 @@ -package com.breadwallet.legacy.presenter.customviews; - -/** - * DO WHAT YOU WANT TO PUBLIC LICENSE - * Version 2, December 2004 - * - * Copyright (C) 2004 Sam Hocevar - * - * Everyone is permitted to copy and distribute verbatim or modified - * copies of this license document, and changing it is allowed as long - * as the name is changed. - * - * DO WHAT YOU WANT TO PUBLIC LICENSE - * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - * - * 0. You just DO WHAT YOU WANT TO. - */ - -import android.content.Context; -import android.text.Layout.Alignment; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.widget.TextView; - -/** - * Text view that auto adjusts text size to fit within the view. - * If the text size equals the minimum text size and still does not - * fit, append with an ellipsis. - * - * @author Chase Colburn - * @since Apr 4, 2011 - */ -public class AutoResizeTextView extends BaseTextView { - - // Minimum text size for this text view - private static final float MIN_TEXT_SIZE = 20; - - // Interface for resize notifications - public interface OnTextResizeListener { - void onTextResize(TextView textView, float oldSize, float newSize); - } - - // Our ellipse string - private static final String mEllipsis = "..."; - - // Registered resize listener - private OnTextResizeListener mTextResizeListener; - - // Flag for text and/or size changes to force a resize - private boolean mNeedsResize = false; - - // Text size that is set from code. This acts as a starting point for resizing - private float mTextSize; - - // Temporary upper bounds on the starting text size - private float mMaxTextSize = 0; - - // Lower bounds for text size - private float mMinTextSize = MIN_TEXT_SIZE; - - // Text view line spacing multiplier - private float mSpacingMult = 1.0f; - - // Text view additional line spacing - private float mSpacingAdd = 0.0f; - - // Add ellipsis to text that overflows at the smallest text size - private boolean mAddEllipsis = true; - - // Default constructor override - public AutoResizeTextView(Context context) { - this(context, null); - } - - // Default constructor when inflating from XML file - public AutoResizeTextView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - // Default constructor override - public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - mTextSize = getTextSize(); - } - - /** - * When text changes, set the force resize flag to true and reset the text size. - */ - @Override - protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) { - mNeedsResize = true; - // Since this view may be reused, it is good to reset the text size - resetTextSize(); - } - - /** - * If the text view size changed, set the force resize flag to true - */ - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - if (w != oldw || h != oldh) { - mNeedsResize = true; - } - } - - /** - * Register listener to receive resize notifications - * @param listener - */ - public void setOnResizeListener(OnTextResizeListener listener) { - mTextResizeListener = listener; - } - - /** - * Override the set text size to update our internal reference values - */ - @Override - public void setTextSize(float size) { - super.setTextSize(size); - mTextSize = getTextSize(); - } - - /** - * Override the set text size to update our internal reference values - */ - @Override - public void setTextSize(int unit, float size) { - super.setTextSize(unit, size); - mTextSize = getTextSize(); - } - - /** - * Override the set line spacing to update our internal reference values - */ - @Override - public void setLineSpacing(float add, float mult) { - super.setLineSpacing(add, mult); - mSpacingMult = mult; - mSpacingAdd = add; - } - - /** - * Set the upper text size limit and invalidate the view - * @param maxTextSize - */ - public void setMaxTextSize(float maxTextSize) { - mMaxTextSize = maxTextSize; - requestLayout(); - invalidate(); - } - - /** - * Return upper text size limit - * @return - */ - public float getMaxTextSize() { - return mMaxTextSize; - } - - /** - * Set the lower text size limit and invalidate the view - * @param minTextSize - */ - public void setMinTextSize(float minTextSize) { - mMinTextSize = minTextSize; - requestLayout(); - invalidate(); - } - - /** - * Return lower text size limit - * @return - */ - public float getMinTextSize() { - return mMinTextSize; - } - - /** - * Set flag to add ellipsis to text that overflows at the smallest text size - * @param addEllipsis - */ - public void setAddEllipsis(boolean addEllipsis) { - mAddEllipsis = addEllipsis; - } - - /** - * Return flag to add ellipsis to text that overflows at the smallest text size - * @return - */ - public boolean getAddEllipsis() { - return mAddEllipsis; - } - - /** - * Reset the text to the original size - */ - private void resetTextSize() { - if (mTextSize > 0) { - super.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); - mMaxTextSize = mTextSize; - } - } - - /** - * Resize text after measuring - */ - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (changed || mNeedsResize) { - int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight(); - int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop(); - resizeText(widthLimit, heightLimit); - } - super.onLayout(changed, left, top, right, bottom); - } - - /** - * Resize the text size with default width and height - */ - public void resizeText() { - - int heightLimit = getHeight() - getPaddingBottom() - getPaddingTop(); - int widthLimit = getWidth() - getPaddingLeft() - getPaddingRight(); - resizeText(widthLimit, heightLimit); - } - - /** - * Resize the text size with specified width and height - * @param width - * @param height - */ - private void resizeText(int width, int height) { - CharSequence text = getText(); - // Do not resize if the view does not have dimensions or there is no text - if (text == null || text.length() == 0 || height <= 0 || width <= 0 || mTextSize == 0) { - return; - } - - if (getTransformationMethod() != null) { - text = getTransformationMethod().getTransformation(text, this); - } - - // Get the text view's paint object - TextPaint textPaint = getPaint(); - - // Store the current text size - float oldTextSize = textPaint.getTextSize(); - // If there is a max text size set, use the lesser of that and the default text size - float targetTextSize = mMaxTextSize > 0 ? Math.min(mTextSize, mMaxTextSize) : mTextSize; - - // Get the required text height - int textHeight = getTextHeight(text, textPaint, width, targetTextSize); - - // Until we either fit within our text view or we had reached our min text size, incrementally try smaller sizes - while (textHeight > height && targetTextSize > mMinTextSize) { - targetTextSize = Math.max(targetTextSize - 2, mMinTextSize); - textHeight = getTextHeight(text, textPaint, width, targetTextSize); - } - - // If we had reached our minimum text size and still don't fit, append an ellipsis - if (mAddEllipsis && targetTextSize == mMinTextSize && textHeight > height) { - // Draw using a static layout - // modified: use a copy of TextPaint for measuring - TextPaint paint = new TextPaint(textPaint); - // Draw using a static layout - StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false); - // Check that we have a least one line of rendered text - if (layout.getLineCount() > 0) { - // Since the line at the specific vertical position would be cut off, - // we must trim up to the previous line - int lastLine = layout.getLineForVertical(height) - 1; - // If the text would not even fit on a single line, clear it - if (lastLine < 0) { - setText(""); - } - // Otherwise, trim to the previous line and add an ellipsis - else { - int start = layout.getLineStart(lastLine); - int end = layout.getLineEnd(lastLine); - float lineWidth = layout.getLineWidth(lastLine); - float ellipseWidth = textPaint.measureText(mEllipsis); - - // Trim characters off until we have enough room to draw the ellipsis - while (width < lineWidth + ellipseWidth) { - lineWidth = textPaint.measureText(text.subSequence(start, --end + 1).toString()); - } - setText(String.valueOf(text.subSequence(0, end)).concat(mEllipsis)); - } - } - } - - // Some devices try to auto adjust line spacing, so force default line spacing - // and invalidate the layout as a side effect - setTextSize(TypedValue.COMPLEX_UNIT_PX, targetTextSize); - setLineSpacing(mSpacingAdd, mSpacingMult); - - // Notify the listener if registered - if (mTextResizeListener != null) { - mTextResizeListener.onTextResize(this, oldTextSize, targetTextSize); - } - - // Reset force resize flag - mNeedsResize = false; - } - - // Set the text size of the text paint object and use a static layout to render text off screen before measuring - private int getTextHeight(CharSequence source, TextPaint paint, int width, float textSize) { - // modified: make a copy of the original TextPaint object for measuring - // (apparently the object gets modified while measuring, see also the - // docs for TextView.getPaint() (which states to access it read-only) - TextPaint paintCopy = new TextPaint(paint); - // Update the text paint object - paintCopy.setTextSize(textSize); - // Measure using a static layout - StaticLayout layout = new StaticLayout(source, paintCopy, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true); - return layout.getHeight(); - } - -} \ No newline at end of file diff --git a/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/BRNotificationBar.java b/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/BRNotificationBar.java index 1b491ee56..125f9c4c7 100644 --- a/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/BRNotificationBar.java +++ b/brd-android/app/src/main/java/com/breadwallet/legacy/presenter/customviews/BRNotificationBar.java @@ -4,6 +4,7 @@ import android.content.res.TypedArray; import androidx.annotation.Nullable; import android.util.AttributeSet; +import android.widget.TextView; import com.breadwallet.R; @@ -17,11 +18,6 @@ */ public class BRNotificationBar extends androidx.appcompat.widget.Toolbar { - private static final String TAG = BRNotificationBar.class.getName(); - - private BaseTextView description; - private BRButton close; - public BRNotificationBar(Context context) { super(context); init(null); @@ -39,8 +35,8 @@ public BRNotificationBar(Context context, @Nullable AttributeSet attrs, int defS private void init(AttributeSet attrs) { inflate(getContext(), R.layout.notification_bar, this); - description = findViewById(R.id.description); - close = findViewById(R.id.cancel_button); + TextView description = findViewById(R.id.description); + BRButton close = findViewById(R.id.cancel_button); TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.BRNotificationBar); final int N = attributes.getIndexCount(); diff --git a/brd-android/app/src/main/java/com/breadwallet/ui/home/HomeController.kt b/brd-android/app/src/main/java/com/breadwallet/ui/home/HomeController.kt index a8352e80f..63624962d 100644 --- a/brd-android/app/src/main/java/com/breadwallet/ui/home/HomeController.kt +++ b/brd-android/app/src/main/java/com/breadwallet/ui/home/HomeController.kt @@ -10,10 +10,7 @@ package com.breadwallet.ui.home import android.os.Bundle import android.view.View -import android.widget.Button -import android.widget.CheckBox -import android.widget.ImageButton -import android.widget.ImageView +import android.widget.* import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.recyclerview.widget.ItemTouchHelper @@ -23,7 +20,6 @@ import com.breadwallet.R import com.breadwallet.databinding.ControllerHomeBinding import com.breadwallet.legacy.presenter.customviews.BRButton import com.breadwallet.legacy.presenter.customviews.BREdit -import com.breadwallet.legacy.presenter.customviews.BaseTextView import com.breadwallet.repository.RatesRepository import com.breadwallet.tools.animation.SpringAnimator import com.breadwallet.tools.manager.BRSharedPrefs @@ -200,8 +196,8 @@ class HomeController( val act = checkNotNull(activity) val baseLayout = act.layoutInflater.inflate(R.layout.base_prompt, null) - val title = baseLayout.findViewById(R.id.prompt_title) - val description = baseLayout.findViewById(R.id.prompt_description) + val title = baseLayout.findViewById(R.id.prompt_title) + val description = baseLayout.findViewById(R.id.prompt_description) val continueButton = baseLayout.findViewById