Commit c7e669c2 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#199: [WP] Done New Dependent, Update Dependent needs check(back-end issue)

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 2c3810a7
......@@ -62,6 +62,7 @@ import br.ufpr.c3sl.agendador.agendador.views.AccountView;
public class AccountActivity extends AppCompatActivity implements AccountView {
private EditText et_name, et_cpf, et_rg, et_birthdate,
et_disability, et_cep, et_address, et_number, et_neighborhood,
et_city, et_state, et_complement, et_phone, et_phone2,
......@@ -317,9 +318,9 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
android.support.v7.app.AlertDialog.Builder builderSingle = new android.support.v7.app.AlertDialog.Builder(AccountActivity.this);
//builderSingle.setIcon(R.drawable.ic_action_search);
//TODO: this message is too long for the dialog.
builderSingle.setTitle(getString(R.string.prof_pic_dialog));
builderSingle.setTitle(getString(R.string.picture_dialog));
final String[] opts = {getString(R.string.prof_pic_update), getString(R.string.prof_pic_remove)};
final String[] opts = {getString(R.string.picture_update), getString(R.string.picture_remove)};
int[] drawableIds = {android.R.drawable.ic_menu_camera, android.R.drawable.ic_menu_close_clear_cancel};
final PhotoSelectionAdapter arrayAdapter = new PhotoSelectionAdapter(getBaseContext(), opts, drawableIds);
......@@ -846,45 +847,45 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
public HashMap<String, String> getValues() {
HashMap<String, String> values = new HashMap<>();
values.put("name", et_name.getText().toString());
values.put("rg", et_rg.getText().toString());
values.put("birth_date", DateValidator.stringToDate(et_birthdate.getText().toString(), false));
values.put(Utils.NAME, et_name.getText().toString());
values.put(Utils.RG, et_rg.getText().toString());
values.put(Utils.BIRTH_DATE, DateValidator.stringToDate(et_birthdate.getText().toString(), false));
if (rb_no.isChecked()) {
values.put("pcd", null);
values.put(Utils.PCD, null);
} else {
if (et_disability.getText().toString().isEmpty()) {
values.put("pcd", null);
values.put(Utils.PCD, null);
} else {
values.put("pcd", et_disability.getText().toString());
values.put(Utils.PCD, et_disability.getText().toString());
}
}
values.put("cep", Mask.unmask(et_cep.getText().toString()));
values.put("address_number", et_number.getText().toString());
values.put("address_complement", et_complement.getText().toString());
values.put(Utils.CEP, Mask.unmask(et_cep.getText().toString()));
values.put(Utils.ADDRESS_NUMBER, et_number.getText().toString());
values.put(Utils.ADDRESS_COMPLEMENT, et_complement.getText().toString());
values.put("phone1", Mask.unmask(et_phone.getText().toString()));
values.put("phone2", Mask.unmask(et_phone2.getText().toString()));
values.put("email", et_email.getText().toString());
values.put(Utils.PHONE_1, Mask.unmask(et_phone.getText().toString()));
values.put(Utils.PHONE_2, Mask.unmask(et_phone2.getText().toString()));
values.put(Utils.EMAIL, et_email.getText().toString());
if (et_new_password.getText().toString().isEmpty() && et_new_password.getText().toString().isEmpty()) {
values.put("password", null);
values.put("password_confirmation", null);
values.put(Utils.PASSWORD, null);
values.put(Utils.PASSWORD_CONFIRMATION, null);
} else {
values.put("current_password", this.current_password);
values.put("password", et_new_password.getText().toString());
values.put("password_confirmation", et_password_confirmation.getText().toString());
values.put(Utils.CURRENT_PASSWORD, this.current_password);
values.put(Utils.PASSWORD, et_new_password.getText().toString());
values.put(Utils.PASSWORD_CONFIRMATION, et_password_confirmation.getText().toString());
}
if(isChangingPhoto) {
if(isPhotoDelete) {
values.put("photo_type", "delete");
values.put(Utils.PHOTO_TYPE, "delete");
}else {
values.put("photo_content", Utils.getBase64FromFile(userImgHelper.getTempFilePath(Utils.USR_PICT_FILE_NAME, id)));
values.put("photo_type", "image/png");
values.put(Utils.PHOTO_CONTENT, Utils.getBase64FromFile(userImgHelper.getTempFilePath(Utils.USR_PICT_FILE_NAME, id)));
values.put(Utils.PHOTO_TYPE, "image/png");
// TODO: 03/05/17 Change here to work with multi photo types
values.put("photo_name", id + ".png");
values.put(Utils.PHOTO_NAME, id + ".png");
}
}
......@@ -978,7 +979,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
// Filesystem.
final Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
galleryIntent.setType("image/*");
chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.prof_pic_chooser));
chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.picture_chooser));
}
if(hasCameraPermission) {
......@@ -999,7 +1000,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
if(!hasReadPermission) {
chooserIntent = Intent.createChooser(cameraIntents.get(cameraIntents.size() - 1), getString(R.string.prof_pic_chooser));
chooserIntent = Intent.createChooser(cameraIntents.get(cameraIntents.size() - 1), getString(R.string.picture_chooser));
cameraIntents.remove(cameraIntents.get(cameraIntents.size() - 1));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
}
......
......@@ -12,6 +12,7 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
......@@ -47,6 +48,12 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
private List<Dependent> dependents;
private boolean updateList;
private static final int DEPENDENT_UPDATE_CODE = 1;
private static final int NEW_DEPENDENT_CODE = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -61,7 +68,7 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
setContentView(R.layout.activity_dependents_list);
FloatingActionButton fab_new_dependent = (FloatingActionButton) findViewById(R.id.fab_new_dependent);
FloatingActionButton fabNewDependent = (FloatingActionButton) findViewById(R.id.fab_new_dependent);
pb_dependents = (ProgressBar) findViewById(R.id.pb_dependentact);
......@@ -87,17 +94,18 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
}
}));
fab_new_dependent.setOnClickListener(new View.OnClickListener() {
fabNewDependent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DependentsListActivity.this, NewDependentActivity.class);
startActivity(intent);
startActivityForResult(intent, NEW_DEPENDENT_CODE);
}
});
}
public void successfulDependents(List<Dependent> dependents) {
this.dependents = dependents;
updateList = false;
showLayout(true);
}
......@@ -108,8 +116,7 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, dependent);
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent);
finish();
startActivityForResult(intent, DEPENDENT_UPDATE_CODE);
}
......@@ -136,8 +143,29 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
}
}
public void afterPictureFailed(){
Toast.makeText(this, "Ocorreu um problema ao carregar sua foto de perfil", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Ocorreu um problema ao carregar a foto", Toast.LENGTH_SHORT).show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode){
case DEPENDENT_UPDATE_CODE:
break;
case NEW_DEPENDENT_CODE:
if(resultCode == Activity.RESULT_OK){
updateList = true;
}
/* do nothing
if (resultCode == Activity.RESULT_CANCELED) {
//Write your code if there's no result
}*/
break;
default:
break;
}
}
......@@ -150,7 +178,7 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
protected void onResume() {
super.onResume();
presenter.bindView(this);
if(dependents == null)
if(dependents == null || updateList)
presenter.requestDependents();
}
......@@ -180,6 +208,7 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
rv_dependents.setVisibility(View.INVISIBLE);
} else {
pb_dependents.setVisibility(View.INVISIBLE);
rv_dependents.setVisibility(View.VISIBLE);
}
}
......
......@@ -20,6 +20,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.DateValidator;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.presenters.SignUpPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SignupView;
......@@ -297,15 +298,15 @@ public class SignUpActivity extends AppCompatActivity implements SignupView {
public HashMap<String,String> getValues(){
HashMap<String,String> values = new HashMap<String,String>();
values.put("cpf",Mask.unmask(et_cpf.getText().toString()));
values.put("birth_date", DateValidator.stringToDate(et_birthday.getText().toString(),false));
values.put("name",et_name.getText().toString());
values.put("cep",Mask.unmask(et_cep.getText().toString()));
values.put("password_confirmation",et_password_confirm.getText().toString());
values.put("password",et_password.getText().toString());
values.put("email",et_email.getText().toString());
values.put("phone1",Mask.unmask(et_phone.getText().toString()));
values.put("rg",et_rg.getText().toString());
values.put(Utils.CPF,Mask.unmask(et_cpf.getText().toString()));
values.put(Utils.BIRTH_DATE, DateValidator.stringToDate(et_birthday.getText().toString(),false));
values.put(Utils.NAME,et_name.getText().toString());
values.put(Utils.CEP,Mask.unmask(et_cep.getText().toString()));
values.put(Utils.PASSWORD_CONFIRMATION,et_password_confirm.getText().toString());
values.put(Utils.PASSWORD,et_password.getText().toString());
values.put(Utils.EMAIL,et_email.getText().toString());
values.put(Utils.PHONE_1,Mask.unmask(et_phone.getText().toString()));
values.put(Utils.RG,et_rg.getText().toString());
return values;
}
......
......@@ -4,6 +4,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Base64;
......@@ -21,6 +23,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
/**
* Created by Lucas B. Cunha on 31/03/17.
*/
......@@ -48,7 +52,44 @@ public class Utils {
public static final String CITIZEN_BUNDLE = "br.ufpr.c3sl.agendador.agendador.citizen_bundle";
public static final String JOB_FILE_NAME = "fileName_tag";
public static final String ADDRESS_NEIGHBORHOOD = "address.neighborhood";
public static final String ADDRESS_NUMBER = "address_number";
public static final String UPDATED_AT = "updated_at";
public static final String ADDRESS_ADDRESS = "address.address";
public static final String AVATAR_UPDATED_AT = "avatar_updated_at";
public static final String ID = "id";
public static final String PHOTO_CONTENT_TYPE = "photo_content_type";
public static final String PHOTO_FILE_NAME = "photo_file_name";
public static final String PHOTO_FILE_SIZE = "photo_file_size";
public static final String NOTE = "note";
public static final String RG = "rg";
public static final String EMAIL = "email";
public static final String PCD = "pcd";
public static final String ACCOUNT_ID = "account_id";
public static final String PHONE_2 = "phone2";
public static final String PHONE_1 = "phone1";
public static final String RESPONSIBLE_ID = "responsible_id";
public static final String ADDRESS_ZIPCODE = "address.zipcode";
public static final String NAME = "name";
public static final String ADDRESS_COMPLEMENT = "address.complement";
public static final String CREATED_AT = "created_at";
public static final String CPF = "cpf";
public static final String BIRTH_DATE = "birth_date";
public static final String CITY_NAME = "city.name";
public static final String STATE_NAME = "state.name";
public static final String STATE_ABBREVIATION = "state.abbreviation";
public static final String CEP = "cep";
public static final String UID = "uid";
public static final String ACCESS_TOKEN = "access-token";
public static final String CLIENT = "client";
public static final String EXPIRY = "expiry";
public static final String PHOTO_CONTENT = "photo_content";
public static final String PHOTO_TYPE = "photo_type";
public static final String PHOTO_NAME = "photo_name";
public static final String ACTIVE = "active";
public static final String PASSWORD = "password";
public static final String PASSWORD_CONFIRMATION = "password_confirmation";
public static final String CURRENT_PASSWORD = "current_password";
public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources();
......
......@@ -4,6 +4,8 @@ import com.google.gson.annotations.SerializedName;
import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
/**
* Created by lbc16 on 30/08/17.
*/
......@@ -68,18 +70,18 @@ public class DependentCreation {
private Image image;
DependentData(Map<String, String> values) {
this.addressNumber = values.get("address_number");
this.rg = values.get("rg");
this.email = values.get("email");
this.pcd = values.get("pcd");
this.phone2 = values.get("phone2");
this.phone1 = values.get("phone1");
this.name = values.get("name");
this.birthDate = values.get("birth_date");
this.cep = values.get("cep");
this.addressComplement = values.get("address_complement");
this.active = values.get("active").equals("true");
this.cpf = values.get("cpf");
this.addressNumber = values.get(Utils.ADDRESS_NUMBER);
this.rg = values.get(Utils.RG);
this.email = values.get(Utils.EMAIL);
this.pcd = values.get(Utils.PCD);
this.phone1 = values.get(Utils.PHONE_1);
this.phone2 = values.get(Utils.PHONE_2);
this.name = values.get(Utils.NAME);
this.birthDate = values.get(Utils.BIRTH_DATE);
this.cep = values.get(Utils.CEP);
this.addressComplement = values.get(Utils.ADDRESS_COMPLEMENT);
this.active = values.get(Utils.ACTIVE).equals("true");
this.cpf = values.get(Utils.CPF);
}
......
......@@ -57,13 +57,17 @@ public class FullDependent implements Parcelable{
dest.writeParcelable(info, flags);
}
@Override
public int describeContents() {
return 0;
}
public UserOutput getInfo() {
return info;
}
public long getId() {
return id;
}
}
......@@ -4,6 +4,8 @@ import com.google.gson.annotations.SerializedName;
import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
/**
* Created by Bruno Freitas Tissei on 2/3/17.
*/
......@@ -47,16 +49,16 @@ public class UserData {
private Image mImage;
public UserData(Map<String, String> values) {
this.mAddress_Number = values.get("address_number");
this.mRg = values.get("rg");
this.mEmail = values.get("email");
this.mPcd = values.get("pcd");
this.mPhone2 = values.get("phone2");
this.mPhone1 = values.get("phone1");
this.mName = values.get("name");
this.mBirth_Date = values.get("birth_date");
this.mCep = values.get("cep");
this.mAddressComplement = values.get("address_complement");
this.mAddress_Number = values.get(Utils.ADDRESS_NUMBER);
this.mRg = values.get(Utils.RG);
this.mEmail = values.get(Utils.EMAIL);
this.mPcd = values.get(Utils.PCD);
this.mPhone1 = values.get(Utils.PHONE_1);
this.mPhone2 = values.get(Utils.PHONE_2);
this.mName = values.get(Utils.NAME);
this.mBirth_Date = values.get(Utils.BIRTH_DATE);
this.mCep = values.get(Utils.CEP);
this.mAddressComplement = values.get(Utils.ADDRESS_COMPLEMENT);
}
......
......@@ -9,6 +9,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
/**
* Created by Bruno Freitas Tissei on 2/3/17.
......@@ -92,16 +93,16 @@ public class UserOutput implements Parcelable {
private String mAddressComplement;
public UserOutput(Map<String,String> values){
this.mAddressNumber = values.get("address_number");
this.mRg = values.get("rg");
this.mEmail = values.get("email");
this.mPcd = values.get("pcd");
this.mPhone2 = values.get("phone2");
this.mPhone1 = values.get("phone1");
this.mName = values.get("name");
this.mBirth_Date = values.get("birth_date");
this.mCep = values.get("cep");
this.mAddressComplement = values.get("address_complement");
this.mAddressNumber = values.get(Utils.ADDRESS_NUMBER);
this.mRg = values.get(Utils.RG);
this.mEmail = values.get(Utils.EMAIL);
this.mPcd = values.get(Utils.PCD);
this.mPhone1 = values.get(Utils.PHONE_1);
this.mPhone2 = values.get(Utils.PHONE_2);
this.mName = values.get(Utils.NAME);
this.mBirth_Date = values.get(Utils.BIRTH_DATE);
this.mCep = values.get(Utils.CEP);
this.mAddressComplement = values.get(Utils.ADDRESS_COMPLEMENT);
}
......@@ -176,40 +177,40 @@ public class UserOutput implements Parcelable {
mAddressComplement = pc.readString();
}
public void save(Context context) {
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(context, "Agendador",
Context.MODE_PRIVATE);
osb.edit().putString("address.neighborhood", this.mAddress.getNeighborhood()).apply();
osb.edit().putString("address_number", this.mAddressNumber).apply();
osb.edit().putString("updated_at", this.mUpdated_At).apply();
osb.edit().putString("address.address", this.mAddress.getAddress()).apply();
osb.edit().putString("avatar_updated_at", this.mPhoto_Update_At).apply();
osb.edit().putLong("id", this.mId).apply();
osb.edit().putString("photo_content_type", this.mPhoto_Content_Type).apply();
osb.edit().putString("photo_file_name", this.mPhoto_File_Name).apply();
osb.edit().putString("photo_file_size", this.mPhoto_File_Size).apply();
osb.edit().putString("note", this.mNote).apply();
osb.edit().putString("rg", this.mRg).apply();
osb.edit().putString("email", this.mEmail).apply();
osb.edit().putString("pcd", this.mPcd).apply();
osb.edit().putInt("account_id", this.mAccount_Id).apply();
osb.edit().putString("phone2", this.mPhone2).apply();
osb.edit().putString("phone1", this.mPhone1).apply();
osb.edit().putInt("responsible_id", this.mResponsible_Id).apply();
osb.edit().putString("address.zipcode", this.mAddress.getZipcode()).apply();
osb.edit().putBoolean("active", this.mActive).apply();
osb.edit().putString("name", this.mName).apply();
osb.edit().putString("address.complement", this.mAddress.getComplement()).apply();
osb.edit().putString("created_at", this.mCreated_At).apply();
osb.edit().putString("cpf", this.mCpf).apply();
osb.edit().putString("birth_date", this.mBirth_Date).apply();
osb.edit().putString("city.name", this.mCity.mName).apply();
osb.edit().putString("state.name", this.mState.mName).apply();
osb.edit().putString("state.abbreviation", this.mState.mAbbreviation).apply();
osb.edit().putString(Utils.ADDRESS_NEIGHBORHOOD, this.mAddress.getNeighborhood()).apply();
osb.edit().putString(Utils.ADDRESS_NUMBER, this.mAddressNumber).apply();
osb.edit().putString(Utils.UPDATED_AT, this.mUpdated_At).apply();
osb.edit().putString(Utils.ADDRESS_ADDRESS, this.mAddress.getAddress()).apply();
osb.edit().putString(Utils.AVATAR_UPDATED_AT, this.mPhoto_Update_At).apply();
osb.edit().putLong(Utils.ID, this.mId).apply();
osb.edit().putString(Utils.PHOTO_CONTENT_TYPE, this.mPhoto_Content_Type).apply();
osb.edit().putString(Utils.PHOTO_FILE_NAME, this.mPhoto_File_Name).apply();
osb.edit().putString(Utils.PHOTO_FILE_SIZE, this.mPhoto_File_Size).apply();
osb.edit().putString(Utils.NOTE, this.mNote).apply();
osb.edit().putString(Utils.RG, this.mRg).apply();
osb.edit().putString(Utils.EMAIL, this.mEmail).apply();
osb.edit().putString(Utils.PCD, this.mPcd).apply();
osb.edit().putInt(Utils.ACCOUNT_ID, this.mAccount_Id).apply();
osb.edit().putString(Utils.PHONE_2, this.mPhone2).apply();
osb.edit().putString(Utils.PHONE_1, this.mPhone1).apply();
osb.edit().putInt(Utils.RESPONSIBLE_ID, this.mResponsible_Id).apply();
osb.edit().putString(Utils.ADDRESS_ZIPCODE, this.mAddress.getZipcode()).apply();
osb.edit().putBoolean(Utils.ACTIVE, this.mActive).apply();
osb.edit().putString(Utils.NAME, this.mName).apply();
osb.edit().putString(Utils.ADDRESS_COMPLEMENT, this.mAddress.getComplement()).apply();
osb.edit().putString(Utils.CREATED_AT, this.mCreated_At).apply();
osb.edit().putString(Utils.CPF, this.mCpf).apply();
osb.edit().putString(Utils.BIRTH_DATE, this.mBirth_Date).apply();
osb.edit().putString(Utils.CITY_NAME, this.mCity.mName).apply();
osb.edit().putString(Utils.STATE_NAME, this.mState.mName).apply();
osb.edit().putString(Utils.STATE_ABBREVIATION, this.mState.mAbbreviation).apply();
}
/**
* Flatten this object in to a Parcel.
*
......@@ -250,21 +251,21 @@ public class UserOutput implements Parcelable {
return this.mName;
}
@Override
public int describeContents() {
return 0;
}
public long getmId() {
return mId;
}
public String getmRg() {
return mRg;
}
public String getmPcd() {
return mPcd;
}
......@@ -308,4 +309,8 @@ public class UserOutput implements Parcelable {
public String getmAddressNumber() {
return mAddressNumber;
}
public String getmPhoto_Update_At() {
return mPhoto_Update_At;
}
}
......@@ -78,6 +78,10 @@ public interface ApiEndpoints {
Call<FullDependent> requestDependentInfo(@Path("id_user") long citizenId, @Path("id_dependent") long dependentId);
@POST("citizens/{id_user}/dependants")
Call<UserOutput> createNewDependent(@Path("id_user") long citizenId, @Body DependentCreation dependent);
Call<FullDependent> createNewDependent(@Path("id_user") long citizenId, @Body DependentCreation dependent);
@PUT("citizens/{id_user}/dependants/{id_dependent}")
Call<FullDependent> updateDependent(@Path("id_user") long citizenId, @Path("id_dependent") long dependentId, @Body DependentCreation dependent);
}
\ No newline at end of file
......@@ -65,9 +65,9 @@ public class AccountPresenter extends BasePresenter<AccountView> {
accountPresenter.view().setProgressBar(true);
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
header.put("access-token", osb.getString("access-token", null));
header.put("client", osb.getString("client", null));
header.put("uid", osb.getString("uid", null));
header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null));
header.put(Utils.CLIENT, osb.getString(Utils.CLIENT, null));
header.put(Utils.UID, osb.getString(Utils.UID, null));
ApiEndpoints service = ApiUtils.request(header);
Call<AccountOutput> listCall = service.requestSelf();
......@@ -119,9 +119,9 @@ public class AccountPresenter extends BasePresenter<AccountView> {
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
header.put("access-token", osb.getString("access-token", null));
header.put("client", osb.getString("client", null));
header.put("uid", osb.getString("uid", null));
header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null));
header.put(Utils.CLIENT, osb.getString(Utils.CLIENT, null));
header.put(Utils.UID, osb.getString(Utils.UID, null));
ApiEndpoints service = ApiUtils.request(header);
Map<String, String> body;
......@@ -129,8 +129,8 @@ public class AccountPresenter extends BasePresenter<AccountView> {
UserData user = new UserData(body);
final AccountUpdate account;
if(body.get("photo_type") != null) {
user.setImage(body.get("photo_type"), body.get("photo_name"), body.get("photo_content"));
if(body.get(Utils.PHOTO_TYPE) != null) {
user.setImage(body.get(Utils.PHOTO_TYPE), body.get(Utils.PHOTO_NAME), body.get(Utils.PHOTO_CONTENT));
isPicUpdate = true;
}
if (body.get("password") == null || body.get("password_confirmation") == null){
......
......@@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import java.lang.ref.WeakReference;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import okhttp3.Headers;
/**
......@@ -45,14 +46,14 @@ public abstract class BasePresenter<V> {
}
protected void updateHeaders(Headers headers) {
if(headers.get("access-token") != null)
osb.edit().putString("access-token", headers.get("access-token")).apply();
if(headers.get("client") != null)
osb.edit().putString("client", headers.get("client")).apply();
if(headers.get("uid") != null)
osb.edit().putString("uid", headers.get("uid")).apply();
if(headers.get("expiry") != null)
osb.edit().putString("expiry", headers.get("expiry")).apply();;
if(headers.get(Utils.ACCESS_TOKEN) != null)
osb.edit().putString(Utils.ACCESS_TOKEN, headers.get(Utils.ACCESS_TOKEN)).apply();
if(headers.get(Utils.CLIENT) != null)
osb.edit().putString(Utils.CLIENT, headers.get(Utils.CLIENT)).apply();
if(headers.get(Utils.UID) != null)
osb.edit().putString(Utils.UID, headers.get(Utils.UID)).apply();
if(headers.get(Utils.EXPIRY) != null)
osb.edit().putString(Utils.EXPIRY, headers.get(Utils.EXPIRY)).apply();;
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.CitizenActivity;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;