- Now the user can change the profile photo
- Transaction List toolbar look improved
This commit is contained in:
parent
78fc4fbf0b
commit
1a527658ab
9 changed files with 248 additions and 11 deletions
|
@ -58,11 +58,13 @@ dependencies {
|
||||||
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
|
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
|
||||||
compile 'de.hdodenhof:circleimageview:2.2.0'
|
compile 'de.hdodenhof:circleimageview:2.2.0'
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
//testCompile 'junit:junit: 4.12'
|
||||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||||
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
|
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
|
||||||
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
|
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
|
||||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||||
|
|
||||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||||
|
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.11.1'
|
||||||
|
compile 'id.zelory:compressor:2.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,28 @@ import android.app.Activity;
|
||||||
import android.arch.lifecycle.LiveData;
|
import android.arch.lifecycle.LiveData;
|
||||||
import android.arch.lifecycle.Observer;
|
import android.arch.lifecycle.Observer;
|
||||||
import android.arch.lifecycle.ViewModelProviders;
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.FileObserver;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.esafirm.imagepicker.features.ImagePicker;
|
||||||
|
import com.esafirm.imagepicker.model.Image;
|
||||||
|
//import com.nicdahlquist.pngquant.LibPngQuant;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
|
@ -19,6 +35,8 @@ import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.AccountSeedListViewModel;
|
||||||
import cy.agorise.crystalwallet.views.AccountSeedListView;
|
import cy.agorise.crystalwallet.views.AccountSeedListView;
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
import id.zelory.compressor.Compressor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by xd on 1/9/18.
|
* Created by xd on 1/9/18.
|
||||||
|
@ -36,6 +54,13 @@ public class AccountsActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.vAccountSeedList)
|
@BindView(R.id.vAccountSeedList)
|
||||||
AccountSeedListView vAccountSeedList;
|
AccountSeedListView vAccountSeedList;
|
||||||
|
|
||||||
|
@BindView(R.id.user_img)
|
||||||
|
CircleImageView userImg;
|
||||||
|
|
||||||
|
static final int NEW_PICTURE_REQUEST_CODE = 1;
|
||||||
|
|
||||||
|
FileObserver fileObserver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -52,6 +77,30 @@ public class AccountsActivity extends AppCompatActivity {
|
||||||
vAccountSeedList.setData(accountSeeds);
|
vAccountSeedList.setData(accountSeeds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
loadUserImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
loadUserImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadUserImage(){
|
||||||
|
//Search for a existing photo
|
||||||
|
ContextWrapper cw = new ContextWrapper(getApplicationContext());
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.tvSettings)
|
@OnClick(R.id.tvSettings)
|
||||||
|
@ -65,4 +114,55 @@ public class AccountsActivity extends AppCompatActivity {
|
||||||
public void cancel(){
|
public void cancel(){
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.user_img)
|
||||||
|
public void loadUserImageSetting(){
|
||||||
|
ImagePicker.create(this)
|
||||||
|
.single()
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
|
||||||
|
// Get a list of picked images
|
||||||
|
List<Image> images = ImagePicker.getImages(data);
|
||||||
|
// or get a single image only
|
||||||
|
Image image = ImagePicker.getFirstImageOrNull(data);
|
||||||
|
|
||||||
|
if (image != null){
|
||||||
|
ContextWrapper cw = new ContextWrapper(getApplicationContext());
|
||||||
|
File directory = cw.getDir("profile", Context.MODE_PRIVATE);
|
||||||
|
if (!directory.exists()) {
|
||||||
|
directory.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
File imageCompressed = new Compressor(this)
|
||||||
|
.setCompressFormat(Bitmap.CompressFormat.PNG)
|
||||||
|
.setMaxWidth(320)
|
||||||
|
.setMaxHeight(480)
|
||||||
|
.compressToFile(new File(image.getPath()));
|
||||||
|
imageCompressed.renameTo(new File(directory + File.separator + "photo.png"));
|
||||||
|
|
||||||
|
|
||||||
|
if (imageCompressed.exists()){
|
||||||
|
imageCompressed.delete();
|
||||||
|
}
|
||||||
|
imageCompressed.createNewFile();
|
||||||
|
//File inputPngFile = new File(image.getPath());
|
||||||
|
//File outputPngFile = new File("photo.png");
|
||||||
|
//new LibPngQuant().pngQuantFile(inputPngFile, outputPngFile);
|
||||||
|
|
||||||
|
//Bitmap bitmapDecoded= BitmapFactory.decodeFile(image.getPath());
|
||||||
|
//Bitmap bitmapResized = Bitmap.createScaledBitmap(bitmapDecoded, 320, 480, false);
|
||||||
|
//resizedbitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
||||||
|
//fos.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//Log.e("SAVE_IMAGE", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,11 +2,18 @@ package cy.agorise.crystalwallet.activities;
|
||||||
|
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.arch.lifecycle.ViewModelProviders;
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.FileObserver;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -23,6 +30,7 @@ import android.view.View;
|
||||||
import android.view.animation.LinearInterpolator;
|
import android.view.animation.LinearInterpolator;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -77,6 +85,8 @@ public class BoardActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.triangle)
|
@BindView(R.id.triangle)
|
||||||
public ImageView triangle;
|
public ImageView triangle;
|
||||||
|
|
||||||
|
File photoDirectory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -176,6 +186,30 @@ public class BoardActivity extends AppCompatActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ContextWrapper cw = new ContextWrapper(getApplicationContext());
|
||||||
|
photoDirectory = cw.getDir("profile", Context.MODE_PRIVATE);
|
||||||
|
if (!photoDirectory.exists()) {
|
||||||
|
photoDirectory.mkdir();
|
||||||
|
}
|
||||||
|
loadUserImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
loadUserImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadUserImage(){
|
||||||
|
//Search for a existing photo
|
||||||
|
File photoFile = new File(photoDirectory + File.separator + "photo.png");
|
||||||
|
|
||||||
|
if (photoFile.exists()){
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(photoFile.getPath());
|
||||||
|
userImage.setImageBitmap(bitmap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package cy.agorise.crystalwallet.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
import butterknife.OnTextChanged;
|
||||||
|
import cy.agorise.crystalwallet.R;
|
||||||
|
import cy.agorise.crystalwallet.util.ChildViewPager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by henry varona on 4/17/18.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProfileSettingsFragment extends Fragment {
|
||||||
|
|
||||||
|
@BindView(R.id.etProfileEmail)
|
||||||
|
EditText etProfileEmail;
|
||||||
|
|
||||||
|
public ProfileSettingsFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileSettingsFragment newInstance() {
|
||||||
|
ProfileSettingsFragment fragment = new ProfileSettingsFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View v = inflater.inflate(R.layout.fragment_profile_settings, container, false);
|
||||||
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@OnTextChanged(value = R.id.etProfileEmail,
|
||||||
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
|
void afterEmailChanged(Editable editable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,7 +66,9 @@ public class TransactionOrderSpinnerAdapter extends ArrayAdapter<TransactionOrde
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||||
return getView(position, convertView, parent);
|
View v = getView(position, convertView, parent);
|
||||||
|
v.setVisibility(View.VISIBLE);
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,6 +83,7 @@ public class TransactionOrderSpinnerAdapter extends ArrayAdapter<TransactionOrde
|
||||||
TransactionOrderSpinnerItem transactionOrderSpinnerItem = getItem(position);
|
TransactionOrderSpinnerItem transactionOrderSpinnerItem = getItem(position);
|
||||||
tvTransactionOrderLabel.setText(transactionOrderSpinnerItem.getLabel());
|
tvTransactionOrderLabel.setText(transactionOrderSpinnerItem.getLabel());
|
||||||
|
|
||||||
|
v.setVisibility(View.GONE);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
app/src/main/res/drawable/sort_transactions_icon.xml
Normal file
5
app/src/main/res/drawable/sort_transactions_icon.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@android:drawable/ic_menu_sort_by_size"
|
||||||
|
android:tileMode="disabled" />
|
29
app/src/main/res/layout/fragment_profile_settings.xml
Normal file
29
app/src/main/res/layout/fragment_profile_settings.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvProfileEmail"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Email"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etProfileEmail"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/tvProfileEmail"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvProfileEmail" />
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
|
@ -17,20 +17,24 @@
|
||||||
android:id="@+id/etTransactionSearch"
|
android:id="@+id/etTransactionSearch"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
/>
|
android:layout_toLeftOf="@+id/btnTransactionsFilterDisplay" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnTransactionsFilterDisplay"
|
android:id="@+id/btnTransactionsFilterDisplay"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="40dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dip"
|
||||||
android:visibility="gone" />
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_toStartOf="@+id/spTransactionsOrder" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spTransactionsOrder"
|
android:id="@+id/spTransactionsOrder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="40dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dip"
|
||||||
android:text="order"
|
android:layout_alignParentEnd="true"
|
||||||
/>
|
android:background="@drawable/sort_transactions_icon"
|
||||||
|
android:text="order" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/transactionListView"
|
android:id="@+id/transactionListView"
|
||||||
|
|
|
@ -19,11 +19,13 @@ allprojects {
|
||||||
maven {
|
maven {
|
||||||
// For Room Persistence Library
|
// For Room Persistence Library
|
||||||
url "https://maven.google.com"
|
url "https://maven.google.com"
|
||||||
|
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
url 'http://www.idescout.com/maven/repo/'
|
url 'http://www.idescout.com/maven/repo/'
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue