From ea5789902796027da6c3fd819b2cc79bf5dc3e77 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 29 Nov 2018 10:33:42 -0600 Subject: [PATCH] - Update libraries and remove unused ones. - Update Gradle version and remove unused Gradle plugin. - Remove Picasso images library and replace its usages by Glide. - Fix CreateSeedActivity which was using Buterknife with Kotlin and that stopped working after updating the kotlin version. --- app/build.gradle | 29 ++-- .../activities/CreateSeedActivity.kt | 150 ++++++------------ .../util/CircleTransformation.java | 47 ------ .../views/ContactSelectionViewHolder.java | 13 +- .../views/ContactViewHolder.java | 19 +-- build.gradle | 8 +- 6 files changed, 70 insertions(+), 196 deletions(-) delete mode 100644 app/src/main/java/cy/agorise/crystalwallet/util/CircleTransformation.java diff --git a/app/build.gradle b/app/build.gradle index 36cadea..d8ccce3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,7 +66,7 @@ dependencies { exclude group: 'com.android.support' } implementation 'com.jaredrummler:material-spinner:1.2.5' - implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.60" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" //testCompile 'com.android.support.test:runner:1.0.1' implementation 'com.afollestad.material-dialogs:core:0.9.6.0' implementation 'com.android.support:appcompat-v7:27.1.1' @@ -76,14 +76,13 @@ dependencies { implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'android.arch.lifecycle:runtime:1.1.1' implementation 'android.arch.lifecycle:extensions:1.1.1' - implementation 'android.arch.paging:runtime:1.0.0' + implementation 'android.arch.paging:runtime:1.0.1' implementation 'com.idescout.sql:sqlscout-server:2.0' - implementation 'com.google.code.gson:gson:2.8.0' + implementation 'com.google.code.gson:gson:2.8.4' implementation 'com.squareup.retrofit2:retrofit:2.2.0' implementation 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'org.bitcoinj:bitcoinj-core:0.14.3' implementation 'com.neovisionaries:nv-websocket-client:1.30' - implementation 'org.tukaani:xz:1.6' implementation 'com.jakewharton:butterknife:8.8.1' implementation 'com.github.bilthon:graphenej:0.4.6' implementation 'me.dm7.barcodescanner:zxing:1.9.8' @@ -94,19 +93,15 @@ dependencies { implementation 'de.hdodenhof:circleimageview:2.2.0' //testCompile 'junit:junit: 4.12' - testImplementation 'org.mockito:mockito-core:1.10.19' - implementation 'android.arch.persistence.room:runtime:1.1.0' + testImplementation 'org.mockito:mockito-core:2.19.0' + implementation 'android.arch.persistence.room:runtime:1.1.1' + + kapt 'android.arch.persistence.room:runtime:1.1.1' + kapt 'android.arch.persistence.room:compiler:1.1.1' - kapt 'android.arch.persistence.room:runtime:1.1.0' - annotationProcessor 'android.arch.lifecycle:compiler:1.1.1' kapt 'android.arch.lifecycle:compiler:1.1.1' - annotationProcessor 'android.arch.lifecycle:compiler:1.1.1' - kapt 'android.arch.persistence.room:compiler:1.1.0' - annotationProcessor 'android.arch.persistence.room:compiler:1.1.0' kapt 'com.jakewharton:butterknife-compiler:8.8.1' - annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' - implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'com.github.esafirm.android-image-picker:imagepicker:1.11.1' implementation 'id.zelory:compressor:2.1.0' implementation 'com.vincent.filepicker:MultiTypeFilePicker:1.0.7' @@ -118,16 +113,14 @@ dependencies { exclude group: 'org.json', module: 'json' } - kapt "android.arch.lifecycle:compiler:1.1.1" - kapt "android.arch.persistence.room:compiler:1.1.0" - // Glide dependencies implementation 'com.github.bumptech.glide:glide:4.8.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0' + kapt 'com.github.bumptech.glide:compiler:4.8.0' + // Android Debug Database debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' - implementation 'com.google.zxing:core:3.2.1' + implementation 'com.google.zxing:core:3.3.1' implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar' testImplementation 'org.testng:testng:6.9.6' } diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt index 776dc4c..badb7ed 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt @@ -3,20 +3,17 @@ package cy.agorise.crystalwallet.activities import android.content.Context import android.content.Intent import android.os.Bundle +import android.support.design.widget.TextInputEditText import android.text.Editable -import android.view.View +import android.text.TextWatcher import android.view.inputmethod.InputMethodManager import android.widget.Toast -import butterknife.ButterKnife -import butterknife.OnClick -import butterknife.OnTextChanged import com.thekhaeng.pushdownanim.PushDownAnim import com.vincent.filepicker.ToastUtil import cy.agorise.crystalwallet.R import cy.agorise.crystalwallet.dialogs.material.* import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest -import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest import cy.agorise.crystalwallet.viewmodels.validators.customImpl.interfaces.UIValidatorListener import cy.agorise.crystalwallet.viewmodels.validators.customImpl.validationFields.BitsharesAccountNameValidation import cy.agorise.crystalwallet.viewmodels.validators.customImpl.validationFields.BitsharesAccountNameValidation.OnAccountExist @@ -41,11 +38,6 @@ class CreateSeedActivity : CustomActivity() { * */ setContentView(R.layout.create_seed) - /* - * Initialice butterknife MVC - * */ - ButterKnife.bind(this) - /* * Add the controls to the validator * */ @@ -54,10 +46,10 @@ class CreateSeedActivity : CustomActivity() { this.fieldsValidator.add(tietAccountName) /* - * Integration of library with button efects + * Integration of library with button effects * */ PushDownAnim.setPushDownAnimTo(btnCancel) - .setOnClickListener { cancel() } + .setOnClickListener { finish() } PushDownAnim.setPushDownAnimTo(btnCreate) .setOnClickListener { createSeed() } @@ -97,20 +89,14 @@ class CreateSeedActivity : CustomActivity() { } } - /* - * Create the pin double validation - * */ + //Create the pin double validation val pinDoubleConfirmationValidationField = PinDoubleConfirmationValidationField(this, tietPin, tietPinConfirmation, uiValidatorListener) - /* - * Listener for the validation for success or fail - * */ + // Listener for the validation for success or fail tietPin?.setUiValidator(pinDoubleConfirmationValidationField) //Validator for the field tietPinConfirmation?.setUiValidator(pinDoubleConfirmationValidationField) //Validator for the field - /* - * Account name validator - * */ + // Account name validator val bitsharesAccountNameValidation = BitsharesAccountNameValidation(this, tietAccountName, uiValidatorListener) val onAccountExist = object : OnAccountExist { override fun onAccountExists() { @@ -124,58 +110,49 @@ class CreateSeedActivity : CustomActivity() { tietAccountName?.setUiValidator(bitsharesAccountNameValidation) /*This button should not be enabled till all the fields be correctly filled*/ - disableCreate() + btnCreate.isEnabled = false - /* - * Set the focus on the fisrt field and show keyboard - * */ + // Set the focus on the first field and show keyboard tilPin?.requestFocus() val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.showSoftInput(tilPin, InputMethodManager.SHOW_IMPLICIT) + + tietPin.afterTextChanged { + this.fieldsValidator.validate() + validateFieldsToContinue() + } + + tietPinConfirmation.afterTextChanged { + this.fieldsValidator.validate() + validateFieldsToContinue() + } + + tietAccountName.afterTextChanged { + this.fieldsValidator.validate() + validateFieldsToContinue() + } + + btnCancel.setOnClickListener { finish() } + btnCreate.setOnClickListener { createSeed() } } - @OnTextChanged(value = R.id.tietPin, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) - internal fun afterPinChanged(editable: Editable) { - this.fieldsValidator.validate() - - /* - * Validate continue to create account - * */ - validateFieldsToContinue() + /** + * Extension function to easily add a text watcher + */ + fun TextInputEditText.afterTextChanged(afterTextChanged: (String) -> Unit) { + this.addTextChangedListener(object :TextWatcher { + override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { + } + override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { + } + override fun afterTextChanged(editable: Editable?) { + afterTextChanged.invoke(editable.toString()) + } + }) } - @OnTextChanged(value = R.id.tietPinConfirmation, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) - internal fun afterPinConfirmationChanged(editable: Editable) { - this.fieldsValidator.validate() - - /* - * Validate continue to create account - * */ - validateFieldsToContinue() - } - - @OnTextChanged(value = R.id.tietAccountName, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) - internal fun afterAccountNameChanged(editable: Editable) { - this.fieldsValidator.validate() - - /* - * Validate continue to create account - * */ - validateFieldsToContinue() - } - - @OnClick(R.id.btnCancel) - fun cancel() { - - /* - * Exit of the activity - * */ - this.finish() - } - - @OnClick(R.id.btnCreate) fun createSeed() { /* @@ -191,11 +168,10 @@ class CreateSeedActivity : CustomActivity() { questionDialog.setOnPositive(object : PositiveResponse{ override fun onPositive() { - // Make request to create a bitshare account + // Make request to create a bitshares account var accountName:String = tietAccountName?.getText().toString().trim() val request = ValidateCreateBitsharesAccountRequest(accountName, applicationContext) - //DTVV: Friday 27 July 2018 //Makes dialog to tell the user that the account is been created val creatingAccountMaterialDialog = CrystalDialog(globalActivity) creatingAccountMaterialDialog.setText(globalActivity.resources.getString(R.string.window_create_seed_DialogMessage)) @@ -215,7 +191,7 @@ class CreateSeedActivity : CustomActivity() { } else if (request.status == ValidateCreateBitsharesAccountRequest.StatusCode.ACCOUNT_EXIST) { ToastUtil.getInstance(globalActivity).showToast(globalActivity.getString(R.string.Account_already_exists)) - disableCreate() + btnCreate.isEnabled = false } else { fieldsValidator.validate() @@ -224,10 +200,7 @@ class CreateSeedActivity : CustomActivity() { (object : Thread() { override fun run() { - - /* - * - * Run thread*/ + /* Run thread*/ CryptoNetInfoRequests.getInstance().addRequest(request) } }).start() @@ -253,40 +226,7 @@ class CreateSeedActivity : CustomActivity() { result = true //Validation is correct } - - /* - * If the result is true so the user can continue to the creation of the account - * */ - if (result) { - - enableCreate() - - } else { - - /* - * Disaible button create - * */ - disableCreate() - } - } - - /* - * Enable create button - * */ - private fun enableCreate() { - runOnUiThread(Runnable { - //btnCreate?.setBackgroundColor(resources.getColor(R.color.colorPrimary)) - btnCreate?.setEnabled(true) - }) - } - - /* - * Disable create button - * */ - private fun disableCreate() { - runOnUiThread(Runnable { - btnCreate?.setEnabled(false) - //btnCreate?.setBackground(resources.getDrawable(R.drawable.disable_style)) - }) + // If the result is true so the user can continue to the creation of the account + btnCreate.isEnabled = result } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/util/CircleTransformation.java b/app/src/main/java/cy/agorise/crystalwallet/util/CircleTransformation.java deleted file mode 100644 index e31ce57..0000000 --- a/app/src/main/java/cy/agorise/crystalwallet/util/CircleTransformation.java +++ /dev/null @@ -1,47 +0,0 @@ -package cy.agorise.crystalwallet.util; - -/** - * Created by Henry Varona on 25/2/2018. - */ - -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Paint; - -import com.squareup.picasso.Transformation; - -public class CircleTransformation implements Transformation { - @Override - public Bitmap transform(Bitmap source) { - int size = Math.min(source.getWidth(), source.getHeight()); - - int x = (source.getWidth() - size) / 2; - int y = (source.getHeight() - size) / 2; - - Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); - if (squaredBitmap != source) { - source.recycle(); - } - - Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig()); - - Canvas canvas = new Canvas(bitmap); - Paint paint = new Paint(); - BitmapShader shader = new BitmapShader(squaredBitmap, - BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); - paint.setShader(shader); - paint.setAntiAlias(true); - - float r = size / 2f; - canvas.drawCircle(r, r, r, paint); - - squaredBitmap.recycle(); - return bitmap; - } - - @Override - public String key() { - return "CircleTransformation"; - } -} diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/ContactSelectionViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/ContactSelectionViewHolder.java index 797ae02..a86406f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/ContactSelectionViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/ContactSelectionViewHolder.java @@ -1,21 +1,16 @@ package cy.agorise.crystalwallet.views; import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.request.RequestOptions; import cy.agorise.crystalwallet.R; -import cy.agorise.crystalwallet.activities.CreateContactActivity; -import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.Contact; -import cy.agorise.crystalwallet.util.CircleTransformation; +import cy.agorise.crystalwallet.util.GlideApp; import cy.agorise.crystalwallet.util.MD5Hash; /** @@ -70,9 +65,9 @@ public class ContactSelectionViewHolder extends RecyclerView.ViewHolder { String emailHash = MD5Hash.hash(contact.getEmail()); String gravatarUrl = "http://www.gravatar.com/avatar/" + emailHash + "?s=204&d=404"; - Picasso.with(this.context) + GlideApp.with(this.context) .load(gravatarUrl) - .transform(new CircleTransformation()) + .apply(RequestOptions.circleCropTransform()) .into(ivThumbnail); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java index b37ce0a..d713b14 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/ContactViewHolder.java @@ -3,21 +3,17 @@ package cy.agorise.crystalwallet.views; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.provider.ContactsContract; import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.ThemedSpinnerAdapter; import android.view.View; import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; - import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.activities.CreateContactActivity; import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.Contact; -import cy.agorise.crystalwallet.util.CircleTransformation; +import cy.agorise.crystalwallet.util.GlideApp; import cy.agorise.crystalwallet.util.MD5Hash; /** @@ -33,13 +29,13 @@ public class ContactViewHolder extends RecyclerView.ViewHolder { private ImageView ivDeleteContact; private Context context; - public ContactViewHolder(View itemView) { + ContactViewHolder(View itemView) { super(itemView); //TODO: use ButterKnife to load this - tvName = (TextView) itemView.findViewById(R.id.tvContactName); - ivThumbnail = (ImageView) itemView.findViewById(R.id.ivContactThumbnail); - tvLastPaid = (TextView) itemView.findViewById(R.id.tvLastPaid); - ivDeleteContact = (ImageView) itemView.findViewById(R.id.ivDeleteContact); + tvName = itemView.findViewById(R.id.tvContactName); + ivThumbnail = itemView.findViewById(R.id.ivContactThumbnail); + tvLastPaid = itemView.findViewById(R.id.tvLastPaid); + ivDeleteContact = itemView.findViewById(R.id.ivDeleteContact); this.context = itemView.getContext(); } @@ -76,10 +72,9 @@ public class ContactViewHolder extends RecyclerView.ViewHolder { String emailHash = MD5Hash.hash(contact.getEmail()); String gravatarUrl = "http://www.gravatar.com/avatar/" + emailHash + "?s=204&d=404"; - Picasso.with(this.context) + GlideApp.with(context) .load(gravatarUrl) .placeholder(R.drawable.avatar_placeholder) - //.transform(new CircleTransformation()) .into(ivThumbnail); } diff --git a/build.gradle b/build.gradle index a977936..34634df 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlinVersion = '1.1.51' + ext.kotlin_version = '1.3.0' repositories { jcenter() google() } - ext.kotlin_version = '1.2.51' dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51" + classpath 'com.android.tools.build:gradle:3.2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }