From 9989fbbb7427893dc449c75c361074dfeda4c174 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Wed, 23 May 2018 21:47:19 -0400 Subject: [PATCH] - Change default profile image - Make some visual elements, not working yet, invisible - Put bitshares icon in balance item title --- .../fragments/ReceiveTransactionFragment.java | 27 ++++++++++++++++ .../fragments/SendTransactionFragment.java | 26 +++++++++++++++ app/src/main/res/layout/activity_accounts.xml | 5 ++- app/src/main/res/layout/balance_list_item.xml | 9 ++++-- app/src/main/res/layout/board.xml | 2 +- .../res/layout/fragment_backups_settings.xml | 32 +++++++++++-------- .../main/res/layout/receive_transaction.xml | 2 +- app/src/main/res/layout/send_transaction.xml | 2 +- 8 files changed, 85 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java index 9398816..b4c6455 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java @@ -4,8 +4,11 @@ import android.app.Dialog; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; import android.arch.lifecycle.ViewModelProviders; +import android.content.Context; +import android.content.ContextWrapper; import android.content.DialogInterface; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; @@ -31,9 +34,12 @@ import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import butterknife.OnClick; +import cy.agorise.crystalwallet.util.CircularImageView; import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountListViewModel; import cy.agorise.crystalwallet.views.CryptoNetAccountAdapter; import cy.agorise.graphenej.Invoice; + +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -72,6 +78,9 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali @BindView(R.id.tvCancel) TextView tvCancel; + @BindView(R.id.gravatar) + CircularImageView userImg; + private Button btnShareQrCode; private Button btnClose; @@ -182,6 +191,8 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali } }); + + loadUserImage(); return dialog; } @@ -193,6 +204,7 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali Window dialogWindow = getDialog().getWindow(); assert dialogWindow != null; dialogWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + loadUserImage(); } @Override @@ -207,6 +219,21 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali }, 400); } + public void loadUserImage(){ + //Search for a existing photo + ContextWrapper cw = new ContextWrapper(this.getActivity().getBaseContext()); + File directory = cw.getDir("profile", Context.MODE_PRIVATE); + if (!directory.exists()) { + directory.mkdir(); + } + File photoFile = new File(directory + File.separator + "photo.png"); + + if (photoFile.exists()){ + Bitmap bitmap = BitmapFactory.decodeFile(photoFile.getPath()); + userImg.setImageBitmap(bitmap); + } + } + @OnItemSelected(R.id.spTo) public void afterToSelected(Spinner spinner, int position) { this.receiveTransactionValidator.validate(); 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 13114be..e47eca9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -4,8 +4,12 @@ import android.app.Dialog; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; import android.arch.lifecycle.ViewModelProviders; +import android.content.Context; +import android.content.ContextWrapper; import android.content.DialogInterface; import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; @@ -29,6 +33,7 @@ import android.widget.TextView; import com.google.zxing.Result; +import java.io.File; import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -51,6 +56,7 @@ import cy.agorise.crystalwallet.models.CryptoCoinBalance; import cy.agorise.crystalwallet.models.CryptoCurrency; import cy.agorise.crystalwallet.models.CryptoNetAccount; import cy.agorise.crystalwallet.models.GrapheneAccount; +import cy.agorise.crystalwallet.util.CircularImageView; import cy.agorise.crystalwallet.viewmodels.ContactViewModel; import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountListViewModel; import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator; @@ -94,6 +100,9 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat ImageView ivPeople; CryptoCurrencyAdapter assetAdapter; + @BindView(R.id.gravatar) + CircularImageView userImg; + Button btnScanQrCode; private long cryptoNetAccountId; @@ -173,6 +182,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat // etFrom.setText(this.grapheneAccount.getName()); } + loadUserImage(); return builder.setView(view).create(); } @@ -190,6 +200,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat Window dialogWindow = getDialog().getWindow(); assert dialogWindow != null; dialogWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + loadUserImage(); } @Override @@ -204,6 +215,21 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat }, 400); } + public void loadUserImage(){ + //Search for a existing photo + ContextWrapper cw = new ContextWrapper(this.getActivity().getBaseContext()); + File directory = cw.getDir("profile", Context.MODE_PRIVATE); + if (!directory.exists()) { + directory.mkdir(); + } + File photoFile = new File(directory + File.separator + "photo.png"); + + if (photoFile.exists()){ + Bitmap bitmap = BitmapFactory.decodeFile(photoFile.getPath()); + userImg.setImageBitmap(bitmap); + } + } + @OnItemSelected(R.id.spFrom) public void afterFromSelected(Spinner spinner, int position) { this.sendTransactionValidator.validate(); diff --git a/app/src/main/res/layout/activity_accounts.xml b/app/src/main/res/layout/activity_accounts.xml index 568b3ef..f1fcd94 100644 --- a/app/src/main/res/layout/activity_accounts.xml +++ b/app/src/main/res/layout/activity_accounts.xml @@ -31,7 +31,7 @@ android:id="@+id/user_img" android:layout_width="90dp" android:layout_height="90dp" - android:src="@drawable/ken_code_gravatar" + android:src="@drawable/gravtr" android:transitionName="gravatarTransition" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -53,6 +53,7 @@ android:textColor="@color/white" android:textSize="16sp" android:textStyle="bold" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="@id/topView" app:layout_constraintEnd_toEndOf="@id/topView" app:layout_constraintStart_toStartOf="@id/topView" @@ -83,6 +84,7 @@ android:layout_height="55dp" android:layout_marginEnd="32dp" android:layout_marginTop="12dp" + android:visibility="gone" app:backgroundTint="@color/colorPrimary" app:fabSize="normal" app:layout_constraintEnd_toEndOf="parent" @@ -115,6 +117,7 @@ android:text="@string/dont_have_multiple_accounts" android:textAlignment="center" android:textSize="16sp" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="@id/vAccountSeedList" app:layout_constraintEnd_toEndOf="@id/vAccountSeedList" app:layout_constraintStart_toStartOf="@id/vAccountSeedList" diff --git a/app/src/main/res/layout/balance_list_item.xml b/app/src/main/res/layout/balance_list_item.xml index f0f5e08..997394a 100644 --- a/app/src/main/res/layout/balance_list_item.xml +++ b/app/src/main/res/layout/balance_list_item.xml @@ -24,14 +24,18 @@ android:id="@+id/ivCryptoNetIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:srcCompat="@drawable/icon_help" /> + android:adjustViewBounds="true" + android:maxHeight="32dp" + android:maxWidth="32dp" + app:srcCompat="@drawable/bts" />