From 265ee740134347037ac344c5a975f3319416f7c1 Mon Sep 17 00:00:00 2001 From: kcw-grunt Date: Fri, 5 Apr 2024 17:21:54 +0100 Subject: [PATCH] force remove json Signed-off-by: kcw-grunt --- app/build.gradle | 38 +- app/lint-report.html | 5053 +++++++++++++++++ app/lint-report.xml | 424 ++ app/lint-results.txt | 31 + app/src/main/AndroidManifest.xml | 2 +- .../com/breadwallet/di/module/AppModule.kt | 1 - .../com/breadwallet/entities/CountryAudio.kt | 8 +- .../com/breadwallet/entities/IntroLanguage.kt | 8 +- .../entities/IntroLanguageResource.kt | 77 +- .../java/com/breadwallet/entities/Language.kt | 12 +- .../activities/AnnounceUpdatesViewActivity.kt | 6 +- .../presenter/base/BaseFragment.kt | 4 +- .../presenter/base/BasePresenter.kt | 4 +- .../breadwallet/presenter/base/BaseView.kt | 4 + .../presenter/entities/PartnerNames.kt | 9 +- .../fragments/FragmentBalanceSeedReminder.kt | 38 +- .../presenter/fragments/FragmentSend.kt | 457 +- .../presenter/history/HistoryFragment.kt | 4 +- .../language/ChangeLanguageBottomSheet.kt | 51 +- .../presenter/language/LanguageAdapter.kt | 14 +- .../tools/adapter/CountryLanguageAdapter.kt | 22 +- .../tools/manager/ResolutionResult.kt | 14 +- .../breadwallet/tools/util/CountryHelper.kt | 11 +- .../com/breadwallet/tools/util/Extension.kt | 44 +- .../breadwallet/tools/util/LocaleHelper.kt | 29 +- .../ui/RoundedBottomSheetDialogFragment.kt | 4 +- app/src/main/res/values/colors.xml | 1 - gradle.properties | 3 +- 28 files changed, 6006 insertions(+), 367 deletions(-) create mode 100644 app/lint-report.html create mode 100644 app/lint-report.xml create mode 100644 app/lint-results.txt diff --git a/app/build.gradle b/app/build.gradle index dc8a8fc83..9c6370e66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -108,7 +108,7 @@ android { // Specifies two flavor dimensions. flavorDimensions "mode" productFlavors { - loaf { + litewallet { applicationId "com.loafwallet" dimension "mode" resValue "string", "app_name", "Litewallet" @@ -125,7 +125,7 @@ android { } } - loafTestnet { + litewalletTestnet { applicationId "com.loafwallet.testnet" dimension "mode" resValue "string", "app_name", "Litewallet-testnet" @@ -338,7 +338,14 @@ dependencies { implementation 'com.google.android.play:core-ktx:1.8.1' // Ktlint - ktlint 'com.pinterest:ktlint:0.50.0' + ktlint("com.pinterest.ktlint:ktlint-cli:1.2.1") { + attributes { + attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL)) + } + } + // additional 3rd party ruleset(s) can be specified here + // just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and + // ktlint will pick them up //kotlin https://stackoverflow.com/questions/69817925/problem-duplicate-class-androidx-lifecycle-viewmodel-found-in-modules def lifecycle_version = "2.4.0" @@ -346,17 +353,26 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" } -task ktlint(type: JavaExec, group: "verification") { + +tasks.register("ktlintCheck", JavaExec) { + group = "verification" description = "Check Kotlin code style." - main = "com.pinterest.ktlint.Main" classpath = configurations.ktlint - args "src/**/*.kt" + mainClass = "com.pinterest.ktlint.Main" + // see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information + args "src/**/*.kt", "**.kts", "!**/build/**" } -check.dependsOn ktlint -task ktlintFormat(type: JavaExec, group: "formatting") { +tasks.named("check") { + dependsOn tasks.named("ktlintCheck") +} + +tasks.register("ktlintFormat", JavaExec) { + group = "formatting" description = "Fix Kotlin code style deviations." - main = "com.pinterest.ktlint.Main" classpath = configurations.ktlint - args "-F", "src/**/*.kt" -} + mainClass = "com.pinterest.ktlint.Main" + jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" + // see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information + args "-F", "src/**/*.kt", "**.kts", "!**/build/**" +} \ No newline at end of file diff --git a/app/lint-report.html b/app/lint-report.html new file mode 100644 index 000000000..e4c2e1b9c --- /dev/null +++ b/app/lint-report.html @@ -0,0 +1,5053 @@ + + + + + +Lint Report + + + + + + + + +
+
+
+ Lint Report: 30 errors +
+ +
+
+ +
+
+ +
+
+
+

Overview

+
+
+ + + + + + + + + + + + + + + +
Correctness +
2error +MissingSuperCall: Missing Super Call
3error +MissingInflatedId: ID not found in inflated resource
2error +ProtectedPermissions: Using system app permission
12error +RestrictedApi: Restricted API
Correctness:Messages +
11error +TimberArgCount: Formatting argument types incomplete or inconsistent
Included Additional Checks (48) +
Disabled Checks (312) +
+
+
+
+
+
+ + +
+
+
+

Missing Super Call

+
+
+
+
+../../src/main/java/com/breadwallet/presenter/activities/DisabledActivity.java:119: Overriding method should call super.onBackPressed
+ 116     }
+ 117 
+ 118     @Override
+ 119     public void onBackPressed() {                                                                   
+ 120         if (getFragmentManager().getBackStackEntryCount() > 0) {
+ 121             getFragmentManager().popBackStack();
+ 122         } else if (AuthManager.getInstance().isWalletDisabled(DisabledActivity.this)) {
+
+ +../../src/main/java/com/breadwallet/presenter/activities/camera/ScanQRActivity.java:122: Overriding method should call super.onRequestPermissionsResult
+ 119     }
+ 120 
+ 121     @Override
+ 122     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,          
+ 123                                            @NonNull int[] grantResults) {
+ 124         if (requestCode != MY_PERMISSION_REQUEST_CAMERA) {
+ 125             return;
+
+ +
+ +
+
+ + MissingSuperCall + + + Correctness + + + Error + + + Priority 9/10 + +
+
+
+
+
+
+
+
+
+

ID not found in inflated resource

+
+
+
+
+../../src/main/java/com/breadwallet/presenter/activities/settings/DisplayCurrencyActivity.java:62: @layout/activity_display_currency does not contain a declaration with id faq_button
+  59 
+  60   //TODO: all views are using the layout of this button. Views should be refactored without it
+  61   // Hiding until layouts are built.
+  62   ImageButton faq = findViewById(R.id.faq_button);                                            
+  63 
+  64   exchangeText = findViewById(R.id.exchange_text);
+  65   listView = findViewById(R.id.currency_list_view);
+
+ +../../src/main/java/com/breadwallet/presenter/fragments/FragmentTransactionDetails.java:39: @layout/fragment_transaction_details does not contain a declaration with id title
+ 36   // The last two arguments ensure LayoutParams are inflated
+ 37   // properly.
+ 38   View rootView = inflater.inflate(R.layout.fragment_transaction_details, container, false);
+ 39   mTitle = (TextView) rootView.findViewById(R.id.title);                                      
+ 40   backgroundLayout = (LinearLayout) rootView.findViewById(R.id.background_layout);
+ 41   txViewPager = (ViewPager) rootView.findViewById(R.id.tx_list_pager);
+ 42   txViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+
+ +../../src/main/java/com/breadwallet/presenter/activities/settings/SyncBlockchainActivity.java:143: @layout/activity_sync_blockchain does not contain a declaration with id close_button
+ 140             }
+ 141         });
+ 142 
+ 143         closeButton = (ImageButton) findViewById(R.id.close_button);                                
+ 144         closeButton.setOnClickListener(new View.OnClickListener() {
+ 145             @Override
+ 146             public void onClick(View v) {
+
+ +
+ +
+
+ + MissingInflatedId + + + Correctness + + + Error + + + Priority 5/10 + +
+
+
+
+
+
+
+
+
+

Using system app permission

+
+
+
+
+../../src/main/AndroidManifest.xml:21: Permission is only granted to system apps
+  18   <uses-permission android:name="android.permission.USE_BIOMETRIC" />
+  19   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+  20   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+  21   <uses-permission android:name="android.permission.BIND_JOB_SERVICE" />                          
+  22   <uses-permission android:name="com.google.android.gms.permission.AD_ID" /> <!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
+  23   <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <!-- Allows changing locales -->
+  24   <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
+
+ +../../src/main/AndroidManifest.xml:24: Permission is only granted to system apps
+  21   <uses-permission android:name="android.permission.BIND_JOB_SERVICE" />
+  22   <uses-permission android:name="com.google.android.gms.permission.AD_ID" /> <!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
+  23   <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <!-- Allows changing locales -->
+  24   <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />                      
+  25 
+  26   <uses-feature
+  27       android:name="android.hardware.location.gps"
+ +
+ +
+
+ + ProtectedPermissions + + + Correctness + + + Error + + + Priority 5/10 + +
+
+
+
+
+
+
+
+
+

Restricted API

+
+
+
+
+../generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/ChangeLanguageBottomSheetBinding.java:53: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android)
+ 50   @Deprecated
+ 51   public static ChangeLanguageBottomSheetBinding inflate(@NonNull LayoutInflater inflater,
+ 52       @Nullable ViewGroup root, boolean attachToRoot, @Nullable Object component) {
+ 53     return ViewDataBinding.<ChangeLanguageBottomSheetBinding>inflateInternal(inflater, R.layout.change_language_bottom_sheet, root, attachToRoot, component);
+ 54   }
+ 55 
+ 56   @NonNull
+ +../generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/ChangeLanguageBottomSheetBinding.java:72: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android)
+ 69   @Deprecated
+ 70   public static ChangeLanguageBottomSheetBinding inflate(@NonNull LayoutInflater inflater,
+ 71       @Nullable Object component) {
+ 72     return ViewDataBinding.<ChangeLanguageBottomSheetBinding>inflateInternal(inflater, R.layout.change_language_bottom_sheet, null, false, component);
+ 73   }
+ 74 
+ 75   public static ChangeLanguageBottomSheetBinding bind(@NonNull View view) {
+
+ +../generated/source/kapt/litewalletDebug/androidx/databinding/DataBinderMapperImpl.java:3: MergedDataBinderMapper can only be accessed from within the same library (androidx.databinding:databinding-runtime)
+ 1 package androidx.databinding;
+ 2 
+ 3 public class DataBinderMapperImpl extends MergedDataBinderMapper {                                  
+ 4   DataBinderMapperImpl() {
+ 5     addMapper(new com.breadwallet.DataBinderMapperImpl());
+ 6   }
+
+ +../generated/source/kapt/litewalletDebug/androidx/databinding/DataBinderMapperImpl.java:5: MergedDataBinderMapper.addMapper can only be called from within the same library (androidx.databinding:databinding-runtime)
+ 2 
+ 3 public class DataBinderMapperImpl extends MergedDataBinderMapper {
+ 4   DataBinderMapperImpl() {
+ 5     addMapper(new com.breadwallet.DataBinderMapperImpl());                                          
+ 6   }
+ 7 }
+
+ +../generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:21: DataBinderMapper can only be accessed from within the same library (androidx.databinding:databinding-runtime)
+  18 import java.util.HashMap;
+  19 import java.util.List;
+  20 
+  21 public class DataBinderMapperImpl extends DataBinderMapper {                                        
+  22   private static final int LAYOUT_CHANGELANGUAGEBOTTOMSHEET = 1;
+  23 
+  24   private static final int LAYOUT_FRAGMENTHISTORY = 2;
+
+ + + +
+ +
+
+ + RestrictedApi + + + Correctness + + + Error + + + Priority 4/10 + +
+
+
+
+
+
+ + +
+
+
+

Formatting argument types incomplete or inconsistent

+
+
+
+
+../../src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0
+ 376   }
+ 377 
+ 378   public static void onTxAdded(byte[] tx, int blockHeight, long timestamp, final long amount, String hash) {
+ 379       Timber.d("timber: onTxAdded: " + String.format("tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s", tx.length, blockHeight, timestamp, amount, hash));
+ 380 
+ 381       final Context ctx = BreadApp.getBreadContext();
+ 382       if (amount > 0) {
+
+ +../../src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0
+ 376   }
+ 377 
+ 378   public static void onTxAdded(byte[] tx, int blockHeight, long timestamp, final long amount, String hash) {
+ 379       Timber.d("timber: onTxAdded: " + String.format("tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s", tx.length, blockHeight, timestamp, amount, hash));
+ 380 
+ 381       final Context ctx = BreadApp.getBreadContext();
+ 382       if (amount > 0) {
+
+ +../../src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0
+ 376   }
+ 377 
+ 378   public static void onTxAdded(byte[] tx, int blockHeight, long timestamp, final long amount, String hash) {
+ 379       Timber.d("timber: onTxAdded: " + String.format("tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s", tx.length, blockHeight, timestamp, amount, hash));
+ 380 
+ 381       final Context ctx = BreadApp.getBreadContext();
+ 382       if (amount > 0) {
+
+ +../../src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0
+ 376   }
+ 377 
+ 378   public static void onTxAdded(byte[] tx, int blockHeight, long timestamp, final long amount, String hash) {
+ 379       Timber.d("timber: onTxAdded: " + String.format("tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s", tx.length, blockHeight, timestamp, amount, hash));
+ 380 
+ 381       final Context ctx = BreadApp.getBreadContext();
+ 382       if (amount > 0) {
+
+ +../../src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0
+ 376   }
+ 377 
+ 378   public static void onTxAdded(byte[] tx, int blockHeight, long timestamp, final long amount, String hash) {
+ 379       Timber.d("timber: onTxAdded: " + String.format("tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s", tx.length, blockHeight, timestamp, amount, hash));
+ 380 
+ 381       final Context ctx = BreadApp.getBreadContext();
+ 382       if (amount > 0) {
+
+ + + +
+ +
+
+Identifier: jetified-timber-4.7.1
+
+
+ + TimberArgCount + + + Messages + + + Correctness + + + Error + + + Priority 9/10 + +
+
+
+
+
+
+ +
+
+
+

Included Additional Checks

+
+
+This card lists all the extra checks run by lint, provided from libraries, +build configuration and extra flags. This is included to help you verify +whether a particular check is included in analysis when configuring builds. +(Note that the list does not include the hundreds of built-in checks into lint, +only additional ones.) + +
+
+
+
+
+ +
+
+
+

Disabled Checks

+
+
+One or more issues were not run by lint, either +because the check is not enabled by default, or because +it was disabled with a command line flag or via one or +more lint.xml configuration files in the project directories. + +
+
+
+
+
+ +
+
+
+

Suppressing Warnings and Errors

+
+
+Lint errors can be suppressed in a variety of ways:
+
+1. With a @SuppressLint annotation in the Java code
+2. With a tools:ignore attribute in the XML file
+3. With a //noinspection comment in the source code
+4. With ignore flags specified in the build.gradle file, as explained below
+5. With a lint.xml configuration file in the project
+6. With a lint.xml configuration file passed to lint via the --config flag
+7. With the --ignore flag passed to lint.
+
+To suppress a lint warning with an annotation, add a @SuppressLint("id") annotation on the class, method or variable declaration closest to the warning instance you want to disable. The id can be one or more issue id's, such as "UnusedResources" or {"UnusedResources","UnusedIds"}, or it can be "all" to suppress all lint warnings in the given scope.
+
+To suppress a lint warning with a comment, add a //noinspection id comment on the line before the statement with the error.
+
+To suppress a lint warning in an XML file, add a tools:ignore="id" attribute on the element containing the error, or one of its surrounding elements. You also need to define the namespace for the tools prefix on the root element in your document, next to the xmlns:android declaration:
+xmlns:tools="http://schemas.android.com/tools"
+
+To suppress a lint warning in a build.gradle file, add a section like this:
+ +
+android {
+    lintOptions {
+        disable 'TypographyFractions','TypographyQuotes'
+    }
+}
+
+
+Here we specify a comma separated list of issue id's after the disable command. You can also use warning or error instead of disable to change the severity of issues.
+
+To suppress lint warnings with a configuration XML file, create a file named lint.xml and place it at the root directory of the module in which it applies.
+
+The format of the lint.xml file is something like the following:
+ +
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+    <!-- Ignore everything in the test source set -->
+    <issue id="all">
+        <ignore path="\*/test/\*" />
+    </issue>
+
+    <!-- Disable this given check in this project -->
+    <issue id="IconMissingDensityFolder" severity="ignore" />
+
+    <!-- Ignore the ObsoleteLayoutParam issue in the given files -->
+    <issue id="ObsoleteLayoutParam">
+        <ignore path="res/layout/activation.xml" />
+        <ignore path="res/layout-xlarge/activation.xml" />
+        <ignore regexp="(foo|bar)\.java" />
+    </issue>
+
+    <!-- Ignore the UselessLeaf issue in the given file -->
+    <issue id="UselessLeaf">
+        <ignore path="res/layout/main.xml" />
+    </issue>
+
+    <!-- Change the severity of hardcoded strings to "error" -->
+    <issue id="HardcodedText" severity="error" />
+</lint>
+
+
+To suppress lint checks from the command line, pass the --ignore flag with a comma separated list of ids to be suppressed, such as:
+$ lint --ignore UnusedResources,UselessLeaf /my/project/path
+
+For more information, see https://developer.android.com/studio/write/lint.html#config
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/app/lint-report.xml b/app/lint-report.xml new file mode 100644 index 000000000..718fc7fbe --- /dev/null +++ b/app/lint-report.xml @@ -0,0 +1,424 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/lint-results.txt b/app/lint-results.txt new file mode 100644 index 000000000..604b4bf29 --- /dev/null +++ b/app/lint-results.txt @@ -0,0 +1,31 @@ +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/presenter/activities/DisabledActivity.java:119: Error: Overriding method should call super.onBackPressed [MissingSuperCall] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/presenter/activities/camera/ScanQRActivity.java:122: Error: Overriding method should call super.onRequestPermissionsResult [MissingSuperCall] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/presenter/activities/settings/DisplayCurrencyActivity.java:62: Error: @layout/activity_display_currency does not contain a declaration with id faq_button [MissingInflatedId] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/presenter/fragments/FragmentTransactionDetails.java:39: Error: @layout/fragment_transaction_details does not contain a declaration with id title [MissingInflatedId] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/presenter/activities/settings/SyncBlockchainActivity.java:143: Error: @layout/activity_sync_blockchain does not contain a declaration with id close_button [MissingInflatedId] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/AndroidManifest.xml:21: Error: Permission is only granted to system apps [ProtectedPermissions] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/AndroidManifest.xml:24: Error: Permission is only granted to system apps [ProtectedPermissions] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/ChangeLanguageBottomSheetBinding.java:53: Error: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/ChangeLanguageBottomSheetBinding.java:72: Error: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/androidx/databinding/DataBinderMapperImpl.java:3: Error: MergedDataBinderMapper can only be accessed from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/androidx/databinding/DataBinderMapperImpl.java:5: Error: MergedDataBinderMapper.addMapper can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:21: Error: DataBinderMapper can only be accessed from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:34: Error: DataBinderMapper.getDataBinder can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:60: Error: DataBinderMapper.getDataBinder can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:77: Error: DataBinderMapper.getLayoutId can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:86: Error: DataBinderMapper.convertBrIdToString can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/source/kapt/litewalletDebug/com/breadwallet/DataBinderMapperImpl.java:92: Error: DataBinderMapper.collectDependencies can only be called from within the same library (androidx.databinding:databinding-runtime) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/FragmentHistoryBinding.java:48: Error: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/build/generated/data_binding_base_class_source_out/litewalletDebug/out/com/breadwallet/databinding/FragmentHistoryBinding.java:67: Error: ViewDataBinding.inflateInternal can only be called from within the same library group (referenced groupId=androidx.databinding from groupId=litewallet-android) [RestrictedApi] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Error: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Error: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Error: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Error: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:379: Error: Wrong argument count, format string timber: onTxAdded: tx.length: %d, blockHeight: %d, timestamp: %d, amount: %d, hash: %s requires 5 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:433: Error: Wrong argument count, format string timber: onTxUpdated: hash: %s, blockHeight: %d, timestamp: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:433: Error: Wrong argument count, format string timber: onTxUpdated: hash: %s, blockHeight: %d, timestamp: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:433: Error: Wrong argument count, format string timber: onTxUpdated: hash: %s, blockHeight: %d, timestamp: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:444: Error: Wrong argument count, format string timber: onTxDeleted: hash: %s, notifyUser: %d, recommendRescan: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:444: Error: Wrong argument count, format string timber: onTxDeleted: hash: %s, notifyUser: %d, recommendRescan: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +/Users/grunt/crypto_projects/lf-projects/litewallet-android/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java:444: Error: Wrong argument count, format string timber: onTxDeleted: hash: %s, notifyUser: %d, recommendRescan: %d requires 3 but format call supplies 0 [TimberArgCount from jetified-timber-4.7.1] +30 errors, 0 warnings diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ef94694a2..17eaffef0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,7 +55,7 @@ { - return arrayOf ( - IntroLanguage(Language.ENGLISH.title, "The most secure and safest way to use Litecoin.", R.raw.english, "Are you sure you want to change the language to English?"), - IntroLanguage(Language.SPANISH.title, "La forma más segura de usar Litecoin.", R.raw.spanish, "¿Estás seguro de que quieres cambiar el idioma a español?"), - IntroLanguage(Language.INDONESIAN.title, "Cara paling aman dan teraman untuk menggunakan Litecoin.", R.raw.bahasaindonesia, "Yakin ingin mengubah bahasanya ke bahasa Indonesia?"), - IntroLanguage(Language.GERMAN.title, "Die sicherste Option zur Nutzung von Litecoin.", R.raw.deutsch, "Sind Sie sicher, dass Sie die Sprache auf Deutsch ändern möchten?"), - IntroLanguage(Language.UKRAINIAN.title, "Найбезпечніший і найбезпечніший спосіб використання Litecoin.", R.raw.ukrainian, "Ви впевнені, що хочете змінити мову на українську?"), + fun loadResources(): Array { + return arrayOf( + IntroLanguage( + Language.ENGLISH.title, + "The most secure and safest way to use Litecoin.", + R.raw.english, + "Are you sure you want to change the language to English?", + ), + IntroLanguage( + Language.SPANISH.title, + "La forma más segura de usar Litecoin.", + R.raw.spanish, + "¿Estás seguro de que quieres cambiar el idioma a español?", + ), + IntroLanguage( + Language.INDONESIAN.title, + "Cara paling aman dan teraman untuk menggunakan Litecoin.", + R.raw.bahasaindonesia, + "Yakin ingin mengubah bahasanya ke bahasa Indonesia?", + ), + IntroLanguage( + Language.GERMAN.title, + "Die sicherste Option zur Nutzung von Litecoin.", + R.raw.deutsch, + "Sind Sie sicher, dass Sie die Sprache auf Deutsch ändern möchten?", + ), + IntroLanguage( + Language.UKRAINIAN.title, + "Найбезпечніший і найбезпечніший спосіб використання Litecoin.", + R.raw.ukrainian, + "Ви впевнені, що хочете змінити мову на українську?", + ), IntroLanguage(Language.CHINESE_TRADITIONAL.title, "使用萊特幣最安全、最有保障的方式。", R.raw.traditionalchinese, "您確定要將語言改為中文嗎?"), - IntroLanguage(Language.ITALIAN.title, "Il modo più sicuro per usare i Litecoin.", R.raw.italiano, "Sei sicuro di voler cambiare la lingua in italiano?"), + IntroLanguage( + Language.ITALIAN.title, + "Il modo più sicuro per usare i Litecoin.", + R.raw.italiano, + "Sei sicuro di voler cambiare la lingua in italiano?", + ), IntroLanguage(Language.KOREAN.title, "Litecoin을 사용하는 가장 안정되고 안전한 방법.", R.raw.korean, "언어를 한국어로 변경하시겠습니까?"), - IntroLanguage(Language.FRENCH.title, "La façon la plus sécurisée et sûre d'utiliser Litecoin.", R.raw.french, "Êtes-vous sûr de vouloir changer la langue en français ?"), - IntroLanguage(Language.TURKISH.title, "Litecoin'i kullanmanın en güvenli ve en güvenli yolu.", R.raw.turkish, "Dili türkçeye değiştirmek istediğinizden emin misiniz?"), + IntroLanguage( + Language.FRENCH.title, + "La façon la plus sécurisée et sûre d'utiliser Litecoin.", + R.raw.french, + "Êtes-vous sûr de vouloir changer la langue en français ?", + ), + IntroLanguage( + Language.TURKISH.title, + "Litecoin'i kullanmanın en güvenli ve en güvenli yolu.", + R.raw.turkish, + "Dili türkçeye değiştirmek istediğinizden emin misiniz?", + ), IntroLanguage(Language.JAPANESE.title, "最も安全にリテコインを使う手段。", R.raw.japanese, "言語を日本語に変更してもよろしいですか?"), - IntroLanguage(Language.PORTUGUESE.title, "A forma mais protegida e segura de utilizar a Litecoin.", R.raw.portugues, "Tem certeza de que deseja alterar o idioma para português?"), - IntroLanguage(Language.RUSSIAN.title, "Самый надежный и безопасный способ использования биткойна.", R.raw.russian, "Вы уверены, что хотите сменить язык на русский?") + IntroLanguage( + Language.PORTUGUESE.title, + "A forma mais protegida e segura de utilizar a Litecoin.", + R.raw.portugues, + "Tem certeza de que deseja alterar o idioma para português?", + ), + IntroLanguage( + Language.RUSSIAN.title, + "Самый надежный и безопасный способ использования биткойна.", + R.raw.russian, + "Вы уверены, что хотите сменить язык на русский?", + ), ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/entities/Language.kt b/app/src/main/java/com/breadwallet/entities/Language.kt index 9598ac3a0..0428de967 100644 --- a/app/src/main/java/com/breadwallet/entities/Language.kt +++ b/app/src/main/java/com/breadwallet/entities/Language.kt @@ -1,9 +1,5 @@ package com.breadwallet.entities -import com.breadwallet.R -import java.util.Locale - - /** Litewallet * Created by Mohamed Barry on 7/19/21 * email: mosadialiou@gmail.com @@ -12,8 +8,8 @@ import java.util.Locale enum class Language( val code: String, val title: String, - val desc: String - ) { + val desc: String, +) { ENGLISH("en", "English", "Select language"), GERMAN("de", "Deutsch", "Sprache auswählen"), SPANISH("es", "Español", "Seleccione el idioma"), @@ -27,7 +23,9 @@ enum class Language( KOREAN("ko", "한국어", "언어 선택"), JAPANESE("ja", "日本語", "言語を選択する"), CHINESE_SIMPLIFIED("zh-CN", "简化字", "选择语言"), - CHINESE_TRADITIONAL("zh-TW", "繁體字", "選擇語言"); + CHINESE_TRADITIONAL("zh-TW", "繁體字", "選擇語言"), + ; + companion object { fun find(code: String?): Language = values().find { it.code == code } ?: ENGLISH } diff --git a/app/src/main/java/com/breadwallet/presenter/activities/AnnounceUpdatesViewActivity.kt b/app/src/main/java/com/breadwallet/presenter/activities/AnnounceUpdatesViewActivity.kt index b195fec9e..460582971 100644 --- a/app/src/main/java/com/breadwallet/presenter/activities/AnnounceUpdatesViewActivity.kt +++ b/app/src/main/java/com/breadwallet/presenter/activities/AnnounceUpdatesViewActivity.kt @@ -4,12 +4,10 @@ import android.os.Bundle import android.webkit.WebView import android.widget.Button import androidx.appcompat.app.AppCompatActivity -import androidx.navigation.ui.AppBarConfiguration import com.breadwallet.R import com.breadwallet.databinding.ActivityAnnounceUpdatesViewBinding class AnnounceUpdatesViewActivity : AppCompatActivity() { - private lateinit var binding: ActivityAnnounceUpdatesViewBinding private var url: String = "https://litewallet.io/mobile-signup/signup.html" @@ -24,8 +22,8 @@ class AnnounceUpdatesViewActivity : AppCompatActivity() { webView.loadUrl(url) val buttonNoThanks: Button = findViewById(R.id.btnNoThanks) - buttonNoThanks.setOnClickListener{ + buttonNoThanks.setOnClickListener { finish() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/presenter/base/BaseFragment.kt b/app/src/main/java/com/breadwallet/presenter/base/BaseFragment.kt index c74f58680..68d4c3508 100644 --- a/app/src/main/java/com/breadwallet/presenter/base/BaseFragment.kt +++ b/app/src/main/java/com/breadwallet/presenter/base/BaseFragment.kt @@ -30,13 +30,13 @@ abstract class BaseFragment

> : Fragment() { fun showError(error: String) { AlertDialog.Builder(requireContext()).setMessage(error).setPositiveButton( android.R.string.ok, - null + null, ).show() } fun showError(errorId: Int) { showError(getString(errorId)) } - + abstract fun initPresenter(): P } diff --git a/app/src/main/java/com/breadwallet/presenter/base/BasePresenter.kt b/app/src/main/java/com/breadwallet/presenter/base/BasePresenter.kt index 95be5be40..6ebe38f16 100644 --- a/app/src/main/java/com/breadwallet/presenter/base/BasePresenter.kt +++ b/app/src/main/java/com/breadwallet/presenter/base/BasePresenter.kt @@ -1,14 +1,11 @@ package com.breadwallet.presenter.base - /** Litewallet * Created by Mohamed Barry on 6/30/20 * email: mosadialiou@gmail.com * Copyright © 2020 Litecoin Foundation. All rights reserved. */ abstract class BasePresenter(var view: BaseView?) { - - init { inject() } @@ -17,6 +14,7 @@ abstract class BasePresenter(var view: BaseView?) { } abstract fun subscribe() + abstract fun unsubscribe() fun detach() { diff --git a/app/src/main/java/com/breadwallet/presenter/base/BaseView.kt b/app/src/main/java/com/breadwallet/presenter/base/BaseView.kt index aaea410e5..b48d65f2c 100644 --- a/app/src/main/java/com/breadwallet/presenter/base/BaseView.kt +++ b/app/src/main/java/com/breadwallet/presenter/base/BaseView.kt @@ -7,8 +7,12 @@ package com.breadwallet.presenter.base */ interface BaseView { fun showProgress() {} + fun hideProgress() {} + fun onTokenExpired() {} + fun showError(error: String) + fun showError(errorId: Int) } diff --git a/app/src/main/java/com/breadwallet/presenter/entities/PartnerNames.kt b/app/src/main/java/com/breadwallet/presenter/entities/PartnerNames.kt index 96d7c7a14..c4e2c9eca 100644 --- a/app/src/main/java/com/breadwallet/presenter/entities/PartnerNames.kt +++ b/app/src/main/java/com/breadwallet/presenter/entities/PartnerNames.kt @@ -1,10 +1,5 @@ package com.breadwallet.presenter.entities -import com.breadwallet.tools.security.BRKeyStore -import org.json.JSONObject -import java.util.regex.Pattern -import java.io.File - enum class PartnerNames(val key: String) { MOONPAY("moonpay"), BITREFILL("bitrefill"), @@ -12,5 +7,5 @@ enum class PartnerNames(val key: String) { LITEWALLETOPS("litewallet-ops"), LITEWALLETSTART("litewallet-start"), PUSHER("pusher-instance-id"), - PUSHERSTAGING("pusher-staging-instance-id") -} \ No newline at end of file + PUSHERSTAGING("pusher-staging-instance-id"), +} diff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentBalanceSeedReminder.kt b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentBalanceSeedReminder.kt index c8ccdf8e6..fc523031e 100644 --- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentBalanceSeedReminder.kt +++ b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentBalanceSeedReminder.kt @@ -11,11 +11,8 @@ import androidx.fragment.app.Fragment import com.breadwallet.R import com.breadwallet.tools.animation.BRAnimator import com.breadwallet.tools.security.BRKeyStore -import com.breadwallet.tools.util.BRConstants -import com.breadwallet.wallet.BRWalletManager import java.util.* - class FragmentBalanceSeedReminder : Fragment() { private lateinit var backgroundLayout: ScrollView private lateinit var signalLayout: LinearLayout @@ -26,9 +23,8 @@ class FragmentBalanceSeedReminder : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { - val rootView = inflater.inflate(R.layout.fragment_balance_seed_reminder, container, false) backgroundLayout = rootView.findViewById(R.id.background_layout) signalLayout = rootView.findViewById(R.id.signal_layout) @@ -40,7 +36,6 @@ class FragmentBalanceSeedReminder : Fragment() { } private fun setListeners() { - showSeedButton.setOnClickListener { seedPhraseTextView.visibility = View.VISIBLE } @@ -50,26 +45,33 @@ class FragmentBalanceSeedReminder : Fragment() { } } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onViewCreated( + view: View, + savedInstanceState: Bundle?, + ) { super.onViewCreated(view, savedInstanceState) val observer = signalLayout.viewTreeObserver - observer.addOnGlobalLayoutListener(object : OnGlobalLayoutListener { - override fun onGlobalLayout() { - if (observer.isAlive) { - observer.removeOnGlobalLayoutListener(this) + observer.addOnGlobalLayoutListener( + object : OnGlobalLayoutListener { + override fun onGlobalLayout() { + if (observer.isAlive) { + observer.removeOnGlobalLayoutListener(this) + } + BRAnimator.animateBackgroundDim(backgroundLayout, false) + BRAnimator.animateSignalSlide(signalLayout, false) { + } } - BRAnimator.animateBackgroundDim(backgroundLayout, false) - BRAnimator.animateSignalSlide(signalLayout, false) { - } - } - }) + }, + ) setListeners() fetchSeedPhrase() } + fun fetchSeedPhrase() { try { seedPhraseTextView.text = String(BRKeyStore.getPhrase(context, 0)) - } catch (_: UserNotAuthenticatedException) {} + } catch (_: UserNotAuthenticatedException) { + } } private fun animateClose() { @@ -82,4 +84,4 @@ class FragmentBalanceSeedReminder : Fragment() { activity?.onBackPressedDispatcher?.onBackPressed() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentSend.kt b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentSend.kt index fd2a733bc..77107f361 100644 --- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentSend.kt +++ b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentSend.kt @@ -43,7 +43,6 @@ import timber.log.Timber import java.math.BigDecimal import java.util.regex.Pattern - class FragmentSend : Fragment() { private lateinit var backgroundLayout: ScrollView private lateinit var signalLayout: LinearLayout @@ -80,7 +79,7 @@ class FragmentSend : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { val rootView = inflater.inflate(R.layout.fragment_send, container, false) backgroundLayout = rootView.findViewById(R.id.background_layout) @@ -127,12 +126,12 @@ class FragmentSend : Fragment() { showFeeSelectionButtons(feeButtonsShown) } keyboardIndex = signalLayout.indexOfChild(keyboardLayout) - //TODO: all views are using the layout of this button. Views should be refactored without it + // TODO: all views are using the layout of this button. Views should be refactored without it // Hiding until layouts are built. val faq = rootView.findViewById(R.id.faq_button) as ImageButton showKeyboard(false) signalLayout.layoutTransition = BRAnimator.getDefaultTransition() - + return rootView } @@ -162,7 +161,7 @@ class FragmentSend : Fragment() { R.string.FeeSelector_economyTime, R.string.FeeSelector_economyWarning, R.color.red_text, - View.VISIBLE + View.VISIBLE, ) } R.id.luxury_fee_but -> { @@ -172,7 +171,7 @@ class FragmentSend : Fragment() { R.string.FeeSelector_luxuryTime, R.string.FeeSelector_luxuryMessage, R.color.light_gray, - View.VISIBLE + View.VISIBLE, ) } else -> { @@ -185,7 +184,7 @@ class FragmentSend : Fragment() { @StringRes deliveryTime: Int, @StringRes warningStringId: Int, @ColorRes warningColorId: Int, - visibility: Int + visibility: Int, ) { feeDescription.text = getString(R.string.FeeSelector_estimatedDeliver, getString(deliveryTime)) @@ -201,7 +200,7 @@ class FragmentSend : Fragment() { private fun setListeners() { amountEdit.setOnClickListener { showKeyboard(true) - if (amountLabelOn) { //only first time + if (amountLabelOn) { // only first time amountLabelOn = false amountEdit.hint = "0" amountEdit.textSize = 24f @@ -215,17 +214,22 @@ class FragmentSend : Fragment() { amountEdit.scaleX = 0f val tr = AutoTransition() tr.interpolator = OvershootInterpolator() - tr.addListener(object : Transition.TransitionListener { - override fun onTransitionStart(transition: Transition) {} - override fun onTransitionEnd(transition: Transition) { - amountEdit.requestLayout() - amountEdit.animate().setDuration(100).scaleX(scaleX) - } + tr.addListener( + object : Transition.TransitionListener { + override fun onTransitionStart(transition: Transition) {} + + override fun onTransitionEnd(transition: Transition) { + amountEdit.requestLayout() + amountEdit.animate().setDuration(100).scaleX(scaleX) + } + + override fun onTransitionCancel(transition: Transition) {} - override fun onTransitionCancel(transition: Transition) {} - override fun onTransitionPause(transition: Transition) {} - override fun onTransitionResume(transition: Transition) {} - }) + override fun onTransitionPause(transition: Transition) {} + + override fun onTransitionResume(transition: Transition) {} + }, + ) val set = ConstraintSet() set.clone(amountLayout) TransitionManager.beginDelayedTransition(amountLayout, tr) @@ -235,103 +239,111 @@ class FragmentSend : Fragment() { ConstraintSet.TOP, isoText.id, ConstraintSet.BOTTOM, - px4 + px4, ) set.connect( feeText.id, ConstraintSet.TOP, balanceText.id, ConstraintSet.BOTTOM, - px4 + px4, ) set.connect( feeText.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, - px4 + px4, ) set.connect( isoText.id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, - px4 + px4, ) set.connect(isoText.id, ConstraintSet.BOTTOM, -1, ConstraintSet.TOP, -1) set.applyTo(amountLayout) } } - //needed to fix the overlap bug - commentEdit.setOnKeyListener(View.OnKeyListener { v, keyCode, event -> - if (event.action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { - amountLayout.requestLayout() - return@OnKeyListener true - } - false - }) - paste.setOnClickListener(View.OnClickListener { - if (!BRAnimator.isClickAllowed()) return@OnClickListener - val bitcoinUrl = BRClipboardManager.getClipboard(activity) - if (Utils.isNullOrEmpty(bitcoinUrl) || !isInputValid(bitcoinUrl)) { - showClipboardError() - return@OnClickListener - } - val obj = BitcoinUrlHandler.getRequestFromString(bitcoinUrl) - if (obj?.address == null) { - showClipboardError() - return@OnClickListener - } - val address = obj.address - val wm = BRWalletManager.getInstance() - if (BRWalletManager.validateAddress(address)) { - val app: Activity? = activity - if (app == null) { - Timber.e("timber:paste onClick: app is null") + // needed to fix the overlap bug + commentEdit.setOnKeyListener( + View.OnKeyListener { v, keyCode, event -> + if (event.action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { + amountLayout.requestLayout() + return@OnKeyListener true + } + false + }, + ) + paste.setOnClickListener( + View.OnClickListener { + if (!BRAnimator.isClickAllowed()) return@OnClickListener + val bitcoinUrl = BRClipboardManager.getClipboard(activity) + if (Utils.isNullOrEmpty(bitcoinUrl) || !isInputValid(bitcoinUrl)) { + showClipboardError() return@OnClickListener } - BRExecutor.getInstance().forLightWeightBackgroundTasks().execute { - if (wm.addressContainedInWallet(address)) { - app.runOnUiThread(Runnable { - BRDialog.showCustomDialog( - requireActivity(), - "", - resources.getString(R.string.Send_containsAddress), - resources.getString(R.string.AccessibilityLabels_close), - null, - { brDialogView -> brDialogView.dismiss() }, - null, - null, - 0 + val obj = BitcoinUrlHandler.getRequestFromString(bitcoinUrl) + if (obj?.address == null) { + showClipboardError() + return@OnClickListener + } + val address = obj.address + val wm = BRWalletManager.getInstance() + if (BRWalletManager.validateAddress(address)) { + val app: Activity? = activity + if (app == null) { + Timber.e("timber:paste onClick: app is null") + return@OnClickListener + } + BRExecutor.getInstance().forLightWeightBackgroundTasks().execute { + if (wm.addressContainedInWallet(address)) { + app.runOnUiThread( + Runnable { + BRDialog.showCustomDialog( + requireActivity(), + "", + resources.getString(R.string.Send_containsAddress), + resources.getString(R.string.AccessibilityLabels_close), + null, + { brDialogView -> brDialogView.dismiss() }, + null, + null, + 0, + ) + BRClipboardManager.putClipboard(activity, "") + }, ) - BRClipboardManager.putClipboard(activity, "") - }) - } else if (wm.addressIsUsed(address)) { - app.runOnUiThread(Runnable { - BRDialog.showCustomDialog( - requireActivity(), - getString(R.string.Send_UsedAddress_firstLine), - getString(R.string.Send_UsedAddress_secondLIne), - "Ignore", - "Cancel", - { brDialogView -> - brDialogView.dismiss() - addressEdit.setText(address) + } else if (wm.addressIsUsed(address)) { + app.runOnUiThread( + Runnable { + BRDialog.showCustomDialog( + requireActivity(), + getString(R.string.Send_UsedAddress_firstLine), + getString(R.string.Send_UsedAddress_secondLIne), + "Ignore", + "Cancel", + { brDialogView -> + brDialogView.dismiss() + addressEdit.setText(address) + }, + { brDialogView -> brDialogView.dismiss() }, + null, + 0, + ) }, - { brDialogView -> brDialogView.dismiss() }, - null, - 0 ) - }) - } else { - app.runOnUiThread(Runnable { addressEdit.setText(address) }) + } else { + app.runOnUiThread(Runnable { addressEdit.setText(address) }) + } } + } else { + showClipboardError() } - } else { - showClipboardError() - } - }) + }, + ) isoButton.setOnClickListener { selectedIso = if (selectedIso.equals(BRSharedPrefs.getIso(context), ignoreCase = true)) { @@ -341,11 +353,13 @@ class FragmentSend : Fragment() { } updateText() } - scan.setOnClickListener(View.OnClickListener { - if (!BRAnimator.isClickAllowed()) return@OnClickListener - saveMetaData() - BRAnimator.openScanner(activity, BRConstants.SCANNER_REQUEST) - }) + scan.setOnClickListener( + View.OnClickListener { + if (!BRAnimator.isClickAllowed()) return@OnClickListener + saveMetaData() + BRAnimator.openScanner(activity, BRConstants.SCANNER_REQUEST) + }, + ) udLookupButton.setOnClickListener { // Disable the button until the domain string is at least 4 chars long (e.g a.zil) @@ -363,9 +377,10 @@ class FragmentSend : Fragment() { Bundle().apply { putLong( BRConstants.START_TIME, - System.currentTimeMillis() + System.currentTimeMillis(), ) - }) + }, + ) }, doInBackground = { UDResolution().resolve(udDomainEdit.text.trim().toString()) }, onPostExecute = { @@ -375,16 +390,17 @@ class FragmentSend : Fragment() { Bundle().apply { putLong( BRConstants.SUCCESS_TIME, - System.currentTimeMillis() + System.currentTimeMillis(), ) - }) + }, + ) addressEdit.setText(it.address) BRAnimator.showBreadSignal( requireActivity(), getString(R.string.Send_UnstoppableDomains_domainResolved), null, R.drawable.ic_check_mark_white, - null + null, ) } else { AnalyticsManager.logCustomEventWithParams( @@ -392,66 +408,73 @@ class FragmentSend : Fragment() { Bundle().apply { putLong(BRConstants.FAILURE_TIME, System.currentTimeMillis()) putString(BRConstants.ERROR, it.error.localizedMessage) - }) + }, + ) Timber.d(it.error) } udLookupButton.isEnabled = true udLookupButton.hideProgress(R.string.Send_UnstoppableDomains_lookup) - } + }, ) } - send.setOnClickListener(View.OnClickListener { - if (!BRAnimator.isClickAllowed()) { - return@OnClickListener - } - var allFilled = true - val address = addressEdit.text.toString() - val amountStr = amountBuilder.toString() - val iso = selectedIso - val comment = commentEdit.text.toString() - - //get amount in satoshis from any isos - val bigAmount = BigDecimal(if (Utils.isNullOrEmpty(amountStr)) "0" else amountStr) - val satoshiAmount = BRExchange.getSatoshisFromAmount(activity, iso, bigAmount) - if (address.isEmpty() || !BRWalletManager.validateAddress(address)) { - allFilled = false - SpringAnimator.failShakeAnimation(activity, addressEdit) - } - if (amountStr.isEmpty()) { - allFilled = false - SpringAnimator.failShakeAnimation(activity, amountEdit) - } - if (satoshiAmount.toLong() > BRWalletManager.getInstance().getBalance(activity)) { - SpringAnimator.failShakeAnimation(activity, balanceText) - SpringAnimator.failShakeAnimation(activity, feeText) - } - if (allFilled) { - BRSender.getInstance().sendTransaction( - context, - PaymentItem( - arrayOf(address), - null, - satoshiAmount.toLong(), - null, - false, - comment + send.setOnClickListener( + View.OnClickListener { + if (!BRAnimator.isClickAllowed()) { + return@OnClickListener + } + var allFilled = true + val address = addressEdit.text.toString() + val amountStr = amountBuilder.toString() + val iso = selectedIso + val comment = commentEdit.text.toString() + + // get amount in satoshis from any isos + val bigAmount = BigDecimal(if (Utils.isNullOrEmpty(amountStr)) "0" else amountStr) + val satoshiAmount = BRExchange.getSatoshisFromAmount(activity, iso, bigAmount) + if (address.isEmpty() || !BRWalletManager.validateAddress(address)) { + allFilled = false + SpringAnimator.failShakeAnimation(activity, addressEdit) + } + if (amountStr.isEmpty()) { + allFilled = false + SpringAnimator.failShakeAnimation(activity, amountEdit) + } + if (satoshiAmount.toLong() > BRWalletManager.getInstance().getBalance(activity)) { + SpringAnimator.failShakeAnimation(activity, balanceText) + SpringAnimator.failShakeAnimation(activity, feeText) + } + if (allFilled) { + BRSender.getInstance().sendTransaction( + context, + PaymentItem( + arrayOf(address), + null, + satoshiAmount.toLong(), + null, + false, + comment, + ), ) - ) - AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL); - BRSharedPrefs.incrementSendTransactionCount(context) - } - }) - donate.setOnClickListener(View.OnClickListener { - if (!BRAnimator.isClickAllowed()) { - return@OnClickListener - } - BRAnimator.showDynamicDonationFragment(requireActivity()) - }) - backgroundLayout.setOnClickListener(View.OnClickListener { - if (!BRAnimator.isClickAllowed()) return@OnClickListener - animateClose() - }) + AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL) + BRSharedPrefs.incrementSendTransactionCount(context) + } + }, + ) + donate.setOnClickListener( + View.OnClickListener { + if (!BRAnimator.isClickAllowed()) { + return@OnClickListener + } + BRAnimator.showDynamicDonationFragment(requireActivity()) + }, + ) + backgroundLayout.setOnClickListener( + View.OnClickListener { + if (!BRAnimator.isClickAllowed()) return@OnClickListener + animateClose() + }, + ) close.setOnClickListener { animateClose() } @@ -471,10 +494,14 @@ class FragmentSend : Fragment() { signalLayout.removeView(keyboardLayout) } else { Utils.hideKeyboard(activity) - if (signalLayout.indexOfChild(keyboardLayout) == -1) signalLayout.addView( - keyboardLayout, - curIndex - ) else signalLayout.removeView(keyboardLayout) + if (signalLayout.indexOfChild(keyboardLayout) == -1) { + signalLayout.addView( + keyboardLayout, + curIndex, + ) + } else { + signalLayout.removeView(keyboardLayout) + } } } @@ -488,26 +515,31 @@ class FragmentSend : Fragment() { { brDialogView -> brDialogView.dismiss() }, null, null, - 0 + 0, ) BRClipboardManager.putClipboard(activity, "") } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onViewCreated( + view: View, + savedInstanceState: Bundle?, + ) { super.onViewCreated(view, savedInstanceState) val observer = signalLayout.viewTreeObserver - observer.addOnGlobalLayoutListener(object : OnGlobalLayoutListener { - override fun onGlobalLayout() { - if (observer.isAlive) { - observer.removeOnGlobalLayoutListener(this) - } - BRAnimator.animateBackgroundDim(backgroundLayout, false) - BRAnimator.animateSignalSlide(signalLayout, false) { - val bundle = arguments - if (bundle?.getString("url") != null) setUrl(bundle.getString("url")) + observer.addOnGlobalLayoutListener( + object : OnGlobalLayoutListener { + override fun onGlobalLayout() { + if (observer.isAlive) { + observer.removeOnGlobalLayoutListener(this) + } + BRAnimator.animateBackgroundDim(backgroundLayout, false) + BRAnimator.animateSignalSlide(signalLayout, false) { + val bundle = arguments + if (bundle?.getString("url") != null) setUrl(bundle.getString("url")) + } } - } - }) + }, + ) } override fun onStop() { @@ -554,12 +586,15 @@ class FragmentSend : Fragment() { if (BigDecimal(currAmount + dig.toString()).toDouble() <= BRExchange.getMaxAmount(activity, iso).toDouble() ) { - //do not insert 0 if the balance is 0 now + // do not insert 0 if the balance is 0 now if (currAmount.equals("0", ignoreCase = true)) amountBuilder = StringBuilder("") - if (currAmount.contains(".") && currAmount.length - currAmount.indexOf(".") > BRCurrency.getMaxDecimalPlaces( - iso + if (currAmount.contains(".") && currAmount.length - currAmount.indexOf(".") > + BRCurrency.getMaxDecimalPlaces( + iso, ) - ) return + ) { + return + } amountBuilder.append(dig) updateText() } @@ -588,30 +623,39 @@ class FragmentSend : Fragment() { val currencySymbol = BRCurrency.getSymbolByIso(activity, selectedIso) curBalance = BRWalletManager.getInstance().getBalance(activity) if (!amountLabelOn) isoText.text = currencySymbol - isoButton.text = String.format( - "%s(%s)", - BRCurrency.getCurrencyName(activity, selectedIso), - currencySymbol - ) - //Balance depending on ISO - val satoshis = if (Utils.isNullOrEmpty(tmpAmount) || tmpAmount.equals( - ".", - ignoreCase = true + isoButton.text = + String.format( + "%s(%s)", + BRCurrency.getCurrencyName(activity, selectedIso), + currencySymbol, ) - ) 0 else if (selectedIso.equals("btc", ignoreCase = true)) BRExchange.getSatoshisForBitcoin( - activity, - BigDecimal(tmpAmount) - ).toLong() else BRExchange.getSatoshisFromAmount( - activity, - selectedIso, - BigDecimal(tmpAmount) - ).toLong() + // Balance depending on ISO + val satoshis = + if (Utils.isNullOrEmpty(tmpAmount) || + tmpAmount.equals( + ".", + ignoreCase = true, + ) + ) { + 0 + } else if (selectedIso.equals("btc", ignoreCase = true)) { + BRExchange.getSatoshisForBitcoin( + activity, + BigDecimal(tmpAmount), + ).toLong() + } else { + BRExchange.getSatoshisFromAmount( + activity, + selectedIso, + BigDecimal(tmpAmount), + ).toLong() + } val balanceForISO = BRExchange.getAmountFromSatoshis(activity, iso, BigDecimal(curBalance)) Timber.d("timber: updateText: balanceForISO: %s", balanceForISO) - //formattedBalance + // formattedBalance val formattedBalance = BRCurrency.getFormattedCurrencyString(activity, iso, balanceForISO) - //Balance depending on ISO + // Balance depending on ISO var fee: Long if (satoshis == 0L) { fee = 0 @@ -619,25 +663,32 @@ class FragmentSend : Fragment() { fee = BRWalletManager.getInstance().feeForTransactionAmount(satoshis).toLong() if (fee == 0L) { Timber.i("timber: updateText: fee is 0, trying the estimate") - fee = BRWalletManager.getInstance() - .feeForTransaction(addressEdit.text.toString(), satoshis).toLong() + fee = + BRWalletManager.getInstance() + .feeForTransaction(addressEdit.text.toString(), satoshis).toLong() } } - val feeForISO = BRExchange.getAmountFromSatoshis( - activity, - iso, - BigDecimal(if (curBalance == 0L) 0 else fee) - ) + val feeForISO = + BRExchange.getAmountFromSatoshis( + activity, + iso, + BigDecimal(if (curBalance == 0L) 0 else fee), + ) Timber.d("timber: updateText: feeForISO: %s", feeForISO) - //formattedBalance + // formattedBalance val aproxFee = BRCurrency.getFormattedCurrencyString(activity, iso, feeForISO) Timber.d("timber: updateText: aproxFee: %s", aproxFee) if (BigDecimal( - if (tmpAmount.isEmpty() || tmpAmount.equals( + if (tmpAmount.isEmpty() || + tmpAmount.equals( ".", - ignoreCase = true + ignoreCase = true, ) - ) "0" else tmpAmount + ) { + "0" + } else { + tmpAmount + }, ).toDouble() > balanceForISO.toDouble() ) { balanceText.setTextColor(requireContext().getColor(R.color.warning_color)) @@ -668,9 +719,10 @@ class FragmentSend : Fragment() { if (obj.amount != null) { val iso = selectedIso val satoshiAmount = BigDecimal(obj.amount).multiply(BigDecimal(100000000)) - amountBuilder = StringBuilder( - BRExchange.getAmountFromSatoshis(activity, iso, satoshiAmount).toPlainString() - ) + amountBuilder = + StringBuilder( + BRExchange.getAmountFromSatoshis(activity, iso, satoshiAmount).toPlainString(), + ) updateText() } } @@ -741,8 +793,9 @@ class FragmentSend : Fragment() { BRAnimator.animateBackgroundDim(backgroundLayout, true) BRAnimator.animateSignalSlide(signalLayout, true) { close() } } + private fun close() { - if(activity != null && activity?.isFinishing != true) { + if (activity != null && activity?.isFinishing != true) { activity?.onBackPressed() } } @@ -752,4 +805,4 @@ class FragmentSend : Fragment() { private var savedIso: String? = null private var savedAmount: String? = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/presenter/history/HistoryFragment.kt b/app/src/main/java/com/breadwallet/presenter/history/HistoryFragment.kt index 599a2d26d..8aa05d0b5 100644 --- a/app/src/main/java/com/breadwallet/presenter/history/HistoryFragment.kt +++ b/app/src/main/java/com/breadwallet/presenter/history/HistoryFragment.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.breadwallet.R import com.breadwallet.databinding.FragmentHistoryBinding import com.breadwallet.presenter.activities.BreadActivity import com.breadwallet.presenter.base.BaseFragment @@ -30,13 +29,12 @@ class HistoryFragment : OnIsoChangedListener, OnTxAddedListener, HistoryView { - lateinit var binding: FragmentHistoryBinding override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { binding = FragmentHistoryBinding.inflate(inflater, container, false) return binding.root diff --git a/app/src/main/java/com/breadwallet/presenter/language/ChangeLanguageBottomSheet.kt b/app/src/main/java/com/breadwallet/presenter/language/ChangeLanguageBottomSheet.kt index a477e07e5..8092b4d48 100644 --- a/app/src/main/java/com/breadwallet/presenter/language/ChangeLanguageBottomSheet.kt +++ b/app/src/main/java/com/breadwallet/presenter/language/ChangeLanguageBottomSheet.kt @@ -11,32 +11,34 @@ import com.breadwallet.R import com.breadwallet.databinding.ChangeLanguageBottomSheetBinding import com.breadwallet.entities.Language import com.breadwallet.presenter.activities.intro.IntroActivity -import com.breadwallet.ui.RoundedBottomSheetDialogFragment import com.breadwallet.tools.util.LocaleHelper import com.breadwallet.tools.util.Utils import com.breadwallet.tools.util.getString +import com.breadwallet.ui.RoundedBottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog - /** Litewallet * Created by Mohamed Barry on 7/19/21 * email: mosadialiou@gmail.com * Copyright © 2021 Litecoin Foundation. All rights reserved. */ class ChangeLanguageBottomSheet : RoundedBottomSheetDialogFragment() { - lateinit var binding: ChangeLanguageBottomSheetBinding + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { binding = ChangeLanguageBottomSheetBinding.inflate(inflater, container, false) return binding.root } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + override fun onViewCreated( + view: View, + savedInstanceState: Bundle?, + ) { super.onViewCreated(view, savedInstanceState) binding.toolbar.setNavigationOnClickListener { dismiss() } @@ -44,13 +46,14 @@ class ChangeLanguageBottomSheet : RoundedBottomSheetDialogFragment() { val currentLanguage = LocaleHelper.instance.currentLocale binding.toolbar.title = currentLanguage.desc - val adapter = LanguageAdapter(Language.values()).apply { - selectedPosition = currentLanguage.ordinal - onLanguageChecked = { - binding.toolbar.title = it.desc - binding.okButton.text = getString(LocaleHelper.getLocale(it), R.string.Button_ok) + val adapter = + LanguageAdapter(Language.values()).apply { + selectedPosition = currentLanguage.ordinal + onLanguageChecked = { + binding.toolbar.title = it.desc + binding.okButton.text = getString(LocaleHelper.getLocale(it), R.string.Button_ok) + } } - } binding.recyclerView.adapter = adapter binding.recyclerView.post { @@ -78,16 +81,24 @@ class ChangeLanguageBottomSheet : RoundedBottomSheetDialogFragment() { behavior.isFitToContents = false behavior.isHideable = true - behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, slideOffset: Float) { - } + behavior.addBottomSheetCallback( + object : BottomSheetBehavior.BottomSheetCallback() { + override fun onSlide( + bottomSheet: View, + slideOffset: Float, + ) { + } - override fun onStateChanged(bottomSheet: View, newState: Int) { - if (newState == BottomSheetBehavior.STATE_DRAGGING) { - behavior.state = BottomSheetBehavior.STATE_EXPANDED + override fun onStateChanged( + bottomSheet: View, + newState: Int, + ) { + if (newState == BottomSheetBehavior.STATE_DRAGGING) { + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } } - } - }) + }, + ) dialog.setOnShowListener { val bottomSheet: FrameLayout? = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet) @@ -97,4 +108,4 @@ class ChangeLanguageBottomSheet : RoundedBottomSheetDialogFragment() { } return dialog } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/presenter/language/LanguageAdapter.kt b/app/src/main/java/com/breadwallet/presenter/language/LanguageAdapter.kt index a089cb2a0..94a812ca1 100644 --- a/app/src/main/java/com/breadwallet/presenter/language/LanguageAdapter.kt +++ b/app/src/main/java/com/breadwallet/presenter/language/LanguageAdapter.kt @@ -8,24 +8,28 @@ import androidx.recyclerview.widget.RecyclerView import com.breadwallet.R import com.breadwallet.entities.Language - /** Litewallet * Created by Mohamed Barry on 7/19/21 * email: mosadialiou@gmail.com * Copyright © 2021 Litecoin Foundation. All rights reserved. */ class LanguageAdapter(val languages: Array) : RecyclerView.Adapter() { - var selectedPosition = 0 var onLanguageChecked: ((Language) -> Unit)? = null - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): ViewHolder { val view = LayoutInflater.from(parent.context).inflate(R.layout.change_language_item, null) return ViewHolder(view) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { + override fun onBindViewHolder( + holder: ViewHolder, + position: Int, + ) { val language = languages[position] with(holder.lang) { text = language.title @@ -49,4 +53,4 @@ class LanguageAdapter(val languages: Array) : RecyclerView.Adapter) : RecyclerView.Adapter() { +class CountryLanguageAdapter(context: Context, val languages: Array) : RecyclerView.Adapter() { private var mCountryLang: Array? = null private var mInflater: LayoutInflater? = null - private var mSelectedItem = -1; - private var barlowFont : Typeface? = null + private var mSelectedItem = -1 + private var barlowFont: Typeface? = null private var mContext: Context? = null private var mediaPlayer: MediaPlayer? = null @@ -44,7 +40,7 @@ class CountryLanguageAdapter(context: Context,val languages: Array() { +// class AsyncResolution : AsyncTask() { // private val tool: DomainResolution = Resolution() // // override fun doInBackground(vararg params: String?): ResolutionResult { @@ -42,4 +40,4 @@ class UDResolution { // ResolutionResult(err, null) // } // } -//} \ No newline at end of file +// } diff --git a/app/src/main/java/com/breadwallet/tools/util/CountryHelper.kt b/app/src/main/java/com/breadwallet/tools/util/CountryHelper.kt index 7950597cf..d2f8e7350 100644 --- a/app/src/main/java/com/breadwallet/tools/util/CountryHelper.kt +++ b/app/src/main/java/com/breadwallet/tools/util/CountryHelper.kt @@ -9,11 +9,12 @@ import java.util.Locale * Copyright © 2020 Litecoin Foundation. All rights reserved. */ object CountryHelper { - val countries: List = Locale.getISOCountries().map { - with(Locale("", it)) { - Country(displayCountry, it) - } - }.sortedWith(compareBy { it.name }).toList() + val countries: List = + Locale.getISOCountries().map { + with(Locale("", it)) { + Country(displayCountry, it) + } + }.sortedWith(compareBy { it.name }).toList() val usaCountry = Country("United States", "US") } diff --git a/app/src/main/java/com/breadwallet/tools/util/Extension.kt b/app/src/main/java/com/breadwallet/tools/util/Extension.kt index 05c19cb04..3d21f48eb 100644 --- a/app/src/main/java/com/breadwallet/tools/util/Extension.kt +++ b/app/src/main/java/com/breadwallet/tools/util/Extension.kt @@ -14,14 +14,12 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.* - /** Litewallet * Created by Mohamed Barry on 12/24/20 * email: mosadialiou@gmail.com * Copyright © 2020 Litecoin Foundation. All rights reserved. */ - /** * Extension to create and execute an asynchronous task * as we previously did it with the deprecated class [android.os.AsyncTask] @@ -29,12 +27,13 @@ import java.util.* fun CoroutineScope.executeAsyncTask( onPreExecute: () -> Unit, doInBackground: () -> R, - onPostExecute: (R) -> Unit + onPostExecute: (R) -> Unit, ) = launch { onPreExecute() // runs in Main Thread - val result = withContext(Dispatchers.IO) { - doInBackground() // runs in background thread without blocking the Main Thread - } + val result = + withContext(Dispatchers.IO) { + doInBackground() // runs in background thread without blocking the Main Thread + } onPostExecute(result) // runs in Main Thread } @@ -50,7 +49,10 @@ val Int.Companion.NO_ERROR: Int /** * String extension */ -fun String.Companion.join(array: Array, separator: Char?): String { +fun String.Companion.join( + array: Array, + separator: Char?, +): String { if (array.isEmpty()) { return "" } @@ -66,7 +68,9 @@ fun String.Companion.join(array: Array, separator: Char?): String { /** * TextInputLayout extension */ -fun TextInputLayout.onError(@StringRes error: Int) { +fun TextInputLayout.onError( + @StringRes error: Int, +) { this.error = if (error.noError()) null else resources.getString(error) } @@ -78,7 +82,7 @@ fun TextInputLayout.text(): CharSequence = this.editText?.text ?: "" fun FragmentActivity.addFragment( fragment: Fragment, addToBackStack: Boolean = true, - containerId: Int = R.id.fragment_container + containerId: Int = R.id.fragment_container, ) { addFragment(this.supportFragmentManager, fragment, null, addToBackStack, containerId) } @@ -86,7 +90,7 @@ fun FragmentActivity.addFragment( fun FragmentActivity.replaceFragment( fragment: Fragment, addToBackStack: Boolean = true, - containerId: Int = R.id.fragment_container + containerId: Int = R.id.fragment_container, ) { replaceFragment(this.supportFragmentManager, fragment, null, addToBackStack, containerId) } @@ -98,7 +102,7 @@ fun Fragment.addFragment( fragment: Fragment, addToBackStack: Boolean = true, containerId: Int = R.id.fragment_container, - transition: Int? = null + transition: Int? = null, ) { addFragment(this.childFragmentManager, fragment, transition, addToBackStack, containerId) } @@ -107,7 +111,7 @@ fun Fragment.replaceChildFragment( fragment: Fragment, addToBackStack: Boolean = true, containerId: Int = R.id.fragment_container, - transition: Int? = null + transition: Int? = null, ) { replaceFragment(this.childFragmentManager, fragment, transition, addToBackStack, containerId) } @@ -116,15 +120,14 @@ fun Fragment.replaceFragment( fragment: Fragment, addToBackStack: Boolean = true, containerId: Int = R.id.fragment_container, - transition: Int? = null + transition: Int? = null, ) { - replaceFragment( this.requireFragmentManager(), fragment, transition, addToBackStack, - containerId + containerId, ) } @@ -133,7 +136,7 @@ private fun addFragment( fragment: Fragment, transition: Int?, addToBackStack: Boolean = true, - containerId: Int = R.id.fragment_container + containerId: Int = R.id.fragment_container, ) { val transaction = fragmentManager.beginTransaction() transition?.let { transaction.setTransition(it) } @@ -149,7 +152,7 @@ private fun replaceFragment( fragment: Fragment, transition: Int?, addToBackStack: Boolean = true, - containerId: Int = R.id.fragment_container + containerId: Int = R.id.fragment_container, ) { val transaction = fragmentManager.beginTransaction() transition?.let { transaction.setTransition(it) } @@ -164,7 +167,10 @@ private fun replaceFragment( * Context extension */ -fun Fragment.getString(locale: Locale, resId: Int): String { +fun Fragment.getString( + locale: Locale, + resId: Int, +): String { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // use latest api val config = Configuration(resources.configuration) config.setLocale(locale) @@ -184,4 +190,4 @@ fun Fragment.getString(locale: Locale, resId: Int): String { result } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/tools/util/LocaleHelper.kt b/app/src/main/java/com/breadwallet/tools/util/LocaleHelper.kt index 85b5b20c0..4474f56e0 100644 --- a/app/src/main/java/com/breadwallet/tools/util/LocaleHelper.kt +++ b/app/src/main/java/com/breadwallet/tools/util/LocaleHelper.kt @@ -21,10 +21,15 @@ class LocaleHelper private constructor() { fun setLocale(context: Context): Context { return if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) { updateLocale(context, currentLocale) - } else updateLocaleLegacy(context, currentLocale) + } else { + updateLocaleLegacy(context, currentLocale) + } } - private fun updateLocale(context: Context, language: Language): Context { + private fun updateLocale( + context: Context, + language: Language, + ): Context { val locale = getLocale(language) Locale.setDefault(locale) val config = context.resources.configuration @@ -33,7 +38,10 @@ class LocaleHelper private constructor() { } @Suppress("deprecation") - private fun updateLocaleLegacy(context: Context, language: Language): Context { + private fun updateLocaleLegacy( + context: Context, + language: Language, + ): Context { val locale = getLocale(language) Locale.setDefault(locale) val res = context.resources @@ -49,8 +57,8 @@ class LocaleHelper private constructor() { } currentLocale = language sharedPreferences.edit() - .putString(LANGUAGE_PREF_KEY, language.code) - .apply() + .putString(LANGUAGE_PREF_KEY, language.code) + .apply() return true } @@ -63,10 +71,11 @@ class LocaleHelper private constructor() { fun init(context: Context) { instance = LocaleHelper() instance.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) - val code = instance.sharedPreferences.getString( - LANGUAGE_PREF_KEY, - Language.ENGLISH.code - ) + val code = + instance.sharedPreferences.getString( + LANGUAGE_PREF_KEY, + Language.ENGLISH.code, + ) instance.currentLocale = Language.find(code) } @@ -79,4 +88,4 @@ class LocaleHelper private constructor() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/breadwallet/ui/RoundedBottomSheetDialogFragment.kt b/app/src/main/java/com/breadwallet/ui/RoundedBottomSheetDialogFragment.kt index d97dfa14f..1e6fb5dda 100644 --- a/app/src/main/java/com/breadwallet/ui/RoundedBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/breadwallet/ui/RoundedBottomSheetDialogFragment.kt @@ -13,9 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment */ open class RoundedBottomSheetDialogFragment : BottomSheetDialogFragment() { - override fun getTheme(): Int = R.style.BottomSheetDialogTheme - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = - BottomSheetDialog(requireContext(), theme) + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = BottomSheetDialog(requireContext(), theme) } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 073a54616..51f6e8a96 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -76,7 +76,6 @@ #0C3475 #179E27 #b3ffffff - #0C3475 #7c98c7 #f5f5f5 diff --git a/gradle.properties b/gradle.properties index c5a60d6fc..7a1990681 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,14 +10,13 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx4608m +org.gradle.jvmargs=-Xmx10248m # Request a long standing daemon to run so that subsequent gradle commands run faster. org.gradle.daemon=true android.useAndroidX=true android.enableJetifier=true -android.useNewApkCreator=true # Build release info RELEASE_STORE_FILE=/Users/grunt/crypto_projects/lf-projects/loafwallet-signing-binaries/new-upload/keystore.jks