From d2d17bb6b40da7cf6a09374c080bd0ff68cdecc4 Mon Sep 17 00:00:00 2001 From: dtvv Date: Fri, 17 Aug 2018 12:08:49 -0500 Subject: [PATCH] =?UTF-8?q?-In=20the=20Send=20Assets=20window=20fix=20the?= =?UTF-8?q?=20=E2=80=9Caccount=20name=20to=E2=80=9D=20to=20get=20better=20?= =?UTF-8?q?visual=20effects=20-Integrate=20nice=20material=20spinner=20int?= =?UTF-8?q?o=20crystal=20proyect=20-Change=20in=20class=20SendTransactionV?= =?UTF-8?q?alidator=20for=20material=20spinner=20-Change=20in=20clas=20Sen?= =?UTF-8?q?dTransactionFragment=20for=20material=20spinner=20-At=20end=20t?= =?UTF-8?q?his=20nice=20spinner=20did=20not=20work=20well=20and=20i=20remo?= =?UTF-8?q?ved=20it=20-Integrate=20this=20new=20nice=20material=20spinner?= =?UTF-8?q?=20into=20crystal=20proyect=20-Modified=20classes:=20SendTransa?= =?UTF-8?q?ctionFragment=20SendTransactionValidator=20ToValidationField=20?= =?UTF-8?q?FromValidationField=20-Create=20the=20first=20bubble=20inicial?= =?UTF-8?q?=20design=20background=20for=20the=20BroadActivity=20window=20-?= =?UTF-8?q?Remove=20the=20transparent=20squares=20in=20the=20BroadActivity?= =?UTF-8?q?=20-In=20the=20window=20of=20BroadActivity=20that=20the=20Tab?= =?UTF-8?q?=20tittles=20increase=20size=20when=20they=20are=20selected=20(?= =?UTF-8?q?tonigth)=20-Integrate=20bubble=20background=20gif=20to=20androi?= =?UTF-8?q?d=20(tonigth)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 + .../activities/BoardActivity.java | 1 + .../fragments/SendTransactionFragment.java | 32 +++++++++++++++---- .../validators/SendTransactionValidator.java | 4 ++- .../validationfields/FromValidationField.java | 12 ++++--- .../validationfields/ToValidationField.java | 12 ++++--- app/src/main/res/layout/board.xml | 1 + app/src/main/res/layout/fragment_balance.xml | 2 +- app/src/main/res/layout/send_transaction.xml | 2 +- 9 files changed, 50 insertions(+), 17 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 92b3254..3dd0576 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,6 +52,7 @@ dependencies { androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { exclude group: 'com.android.support', module: 'support-annotations' }) + implementation 'com.jaredrummler:material-spinner:1.2.5' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" //testCompile 'com.android.support.test:runner:1.0.1' implementation 'com.afollestad.material-dialogs:core:0.9.6.0' //DTVV Thrusday 31 July 2018 diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java index c342c2b..7843f0b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java @@ -120,6 +120,7 @@ public class BoardActivity extends CustomActivity { public void run() { LinearLayout tabLayout = (LinearLayout)((ViewGroup) tabLayoutFinal.getChildAt(0)).getChildAt(tab.getPosition()); + tabLayout.setBackgroundColor(Color.TRANSPARENT); TextView tabTextView = (TextView) tabLayout.getChildAt(1); //tabTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP ,50); Spannable WordtoSpan = new SpannableString(tabTextView.getText()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index e6d96e1..5a89378 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -32,6 +32,7 @@ import android.widget.Spinner; import android.widget.TextView; import com.google.zxing.Result; +import com.jaredrummler.materialspinner.MaterialSpinner; import java.io.File; import java.math.RoundingMode; @@ -73,7 +74,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat SendTransactionValidator sendTransactionValidator; @BindView(R.id.spFrom) - Spinner spFrom; + MaterialSpinner spFrom; @BindView(R.id.tvFromError) TextView tvFromError; @BindView(R.id.etTo) @@ -176,8 +177,27 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat CryptoNetAccountListViewModel cryptoNetAccountListViewModel = ViewModelProviders.of(this).get(CryptoNetAccountListViewModel.class); List cryptoNetAccounts = cryptoNetAccountListViewModel.getCryptoNetAccountList(); CryptoNetAccountAdapter fromSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts); - spFrom.setAdapter(fromSpinnerAdapter); - spFrom.setSelection(0); + + //spFrom.setAdapter(fromSpinnerAdapter); + //spFrom.setSelection(0); + + /* + * Custom material spinner implementation + * */ + spFrom.setItems(cryptoNetAccounts); + spFrom.setSelectedIndex(0); + spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() { + @Override + public void onItemSelected(MaterialSpinner view, int position, long id, CryptoNetAccount item) { + sendTransactionValidator.validate(); + } + }); + spFrom.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { + + @Override public void onNothingSelected(MaterialSpinner spinner) { + + } + }); // etFrom.setText(this.grapheneAccount.getName()); } @@ -230,10 +250,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat } } - @OnItemSelected(R.id.spFrom) + /*@OnItemSelected(R.id.spFrom) public void afterFromSelected(Spinner spinner, int position) { this.sendTransactionValidator.validate(); - } + }*/ @OnTextChanged(value = R.id.etTo, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) @@ -311,7 +331,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat @OnClick(R.id.btnSend) public void sendTransaction(){ if (this.sendTransactionValidator.isValid()) { - CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getSelectedItem(); + CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getItems().get(spFrom.getSelectedIndex()); /* diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/SendTransactionValidator.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/SendTransactionValidator.java index 66565a7..3cd67d9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/SendTransactionValidator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/SendTransactionValidator.java @@ -4,6 +4,8 @@ import android.content.Context; import android.widget.EditText; import android.widget.Spinner; +import com.jaredrummler.materialspinner.MaterialSpinner; + import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.viewmodels.validators.validationfields.AmountValidationField; import cy.agorise.crystalwallet.viewmodels.validators.validationfields.AssetValidationField; @@ -20,7 +22,7 @@ public class SendTransactionValidator extends UIValidator { private CryptoNetAccount account; - public SendTransactionValidator(Context context, CryptoNetAccount account, Spinner fromEdit, EditText toEdit, Spinner assetSpinner, EditText amountEdit, EditText memoEdit){ + public SendTransactionValidator(Context context, CryptoNetAccount account, MaterialSpinner fromEdit, EditText toEdit, Spinner assetSpinner, EditText amountEdit, EditText memoEdit){ super(context); this.account = account; this.addField(new FromValidationField(fromEdit)); diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/FromValidationField.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/FromValidationField.java index a693ba9..4f18033 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/FromValidationField.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/FromValidationField.java @@ -2,7 +2,10 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields; import android.widget.Spinner; +import com.jaredrummler.materialspinner.MaterialSpinner; + import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest; @@ -14,9 +17,9 @@ import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountReq public class FromValidationField extends ValidationField { //private EditText fromField; - private Spinner fromField; + private MaterialSpinner fromField; - public FromValidationField(Spinner fromField){ + public FromValidationField(MaterialSpinner fromField){ super(fromField); this.fromField = fromField; } @@ -24,8 +27,9 @@ public class FromValidationField extends ValidationField { public void validate(){ final String newValue; - if (fromField.getSelectedItem() != null) { - newValue = fromField.getSelectedItem().toString(); + if (fromField.getSelectedIndex() != -1) { + final CryptoNetAccount cryptoNetAccount = (CryptoNetAccount) fromField.getItems().get(fromField.getSelectedIndex()); + newValue = cryptoNetAccount.getName(); } else { newValue = ""; } diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/ToValidationField.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/ToValidationField.java index f2e8702..9c06402 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/ToValidationField.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/ToValidationField.java @@ -3,7 +3,10 @@ package cy.agorise.crystalwallet.viewmodels.validators.validationfields; import android.widget.EditText; import android.widget.Spinner; +import com.jaredrummler.materialspinner.MaterialSpinner; + import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest; @@ -14,10 +17,10 @@ import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountReq public class ToValidationField extends ValidationField { - private Spinner fromField; + private MaterialSpinner fromField; private EditText toField; - public ToValidationField(Spinner fromField, EditText toField){ + public ToValidationField(MaterialSpinner fromField, EditText toField){ super(toField); this.fromField = fromField; this.toField = toField; @@ -25,8 +28,9 @@ public class ToValidationField extends ValidationField { public void validate(){ final String fromNewValue; - if (fromField.getSelectedItem() != null) { - fromNewValue = fromField.getSelectedItem().toString(); + if (fromField.getSelectedIndex() != -1) { + final CryptoNetAccount cryptoNetAccount = (CryptoNetAccount) fromField.getItems().get(fromField.getSelectedIndex()); + fromNewValue = cryptoNetAccount.getName(); } else { fromNewValue = ""; } diff --git a/app/src/main/res/layout/board.xml b/app/src/main/res/layout/board.xml index 4b8f6a9..77bcba9 100644 --- a/app/src/main/res/layout/board.xml +++ b/app/src/main/res/layout/board.xml @@ -99,6 +99,7 @@ diff --git a/app/src/main/res/layout/send_transaction.xml b/app/src/main/res/layout/send_transaction.xml index 0dc5811..34116a5 100644 --- a/app/src/main/res/layout/send_transaction.xml +++ b/app/src/main/res/layout/send_transaction.xml @@ -44,7 +44,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> -