Commit ec35e16d authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Issue AGILE#203: [WP] Implementing NewDependentActivity


Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 532080c0
......@@ -12,6 +12,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.MediaStore;
......@@ -48,9 +49,9 @@ 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.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.PhotoSelectionAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.PhotoSelectionAdapter;
import br.ufpr.c3sl.agendador.agendador.presenters.AccountPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.AccountView;
......@@ -66,7 +67,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
et_city, et_state, et_complement, et_phone, et_phone2,
et_email, et_new_password, et_password_confirmation;
private ImageView imv_profile;
private ImageView imgv_profile;
private ProgressBar pb_account;
private RadioButton rb_no, rb_yes;
private Button btn_update, btn_cancel;
......@@ -86,11 +87,13 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private boolean isPhotoDelete;
private UserPhotoHelper userPhotoHelper;
private UserImgHelper userImgHelper;
private ConnectionErrorDialog connectionErrorDialog;
private long id;
private final int REQUEST_PERMISSIONS = 1;
private final int LOAD_IMAGE_INTENT = 1;
......@@ -131,6 +134,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", "");
id = osb.getLong("id", 0);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_acc);
toolbar.setTitle(citizenName);
......@@ -169,12 +173,12 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
tv_email_warning = (TextView) findViewById(R.id.tv_account_email_warning);
tv_account_new_password_warning = (TextView) findViewById(R.id.tv_account_new_password_warning);
tv_password_confirm_warning = (TextView) findViewById(R.id.tv_account_confirm_password_warning);
imv_profile = (ImageView) findViewById(R.id.img_account_photo);
imgv_profile = (ImageView) findViewById(R.id.img_account_photo);
rb_no = (RadioButton) findViewById(R.id.rb_has_disability_no);
rb_yes = (RadioButton) findViewById(R.id.rb_has_disability_yes);
userPhotoHelper = new UserPhotoHelper(getBaseContext());
userImgHelper = new UserImgHelper(getBaseContext());
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_phone.addTextChangedListener(Mask.insert("(##)####-####", et_phone));
......@@ -199,7 +203,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
float percentage = 1.5f * ((float) Math.abs(verticalOffset) / appBarLayout.getTotalScrollRange());
imv_profile.setAlpha(1 - percentage);
imgv_profile.setAlpha(1 - percentage);
btn_photo.setAlpha(1 - percentage);
}
});
......@@ -306,7 +310,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
@Override
public void onClick(View view) {
if(!userPhotoHelper.existsPhoto() || isPhotoDelete){
if(!userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id) || isPhotoDelete){
checkBuildVersion();
return;
}
......@@ -335,7 +339,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
if(which == 1){
isPhotoDelete = true;
isChangingPhoto = true;
imv_profile.setImageBitmap(null);
imgv_profile.setImageBitmap(null);
}
else{
checkBuildVersion();
......@@ -347,8 +351,8 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
});
if(userPhotoHelper.existsPhoto()){
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id)){
imgv_profile.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
}
isChangingPassword = false;
......@@ -392,10 +396,10 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
clearWarnings();
loadData();
scrollUp();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id))
imgv_profile.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
else
imv_profile.setImageBitmap(null);
imgv_profile.setImageBitmap(null);
} else {
super.onBackPressed();
}
......@@ -430,10 +434,10 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
clearWarnings();
loadData();
scrollUp();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id))
imgv_profile.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
else
imv_profile.setImageBitmap(null);
imgv_profile.setImageBitmap(null);
} else {
onBackPressed();
}
......@@ -540,8 +544,12 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
public void successfulUpdate() {
try{
//has to be done before load data.
if(isChangingPhoto)
userPhotoHelper.confirmUpdate(isPhotoDelete);
if(isChangingPhoto){
if(isPhotoDelete)
userImgHelper.deletePhoto(Utils.USR_PICT_FILE_NAME, id);
else
userImgHelper.copyFromTo(userImgHelper.getTempFileUri(Utils.USR_PICT_FILE_NAME, id), userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id));
}
}catch (Exception e){
// TODO: 04/05/17 user messages & error warning
Toast.makeText(this, "Ocorreu um erro ao salvar a imagem, tente novamente.", Toast.LENGTH_SHORT).show();
......@@ -559,10 +567,10 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
setButtonVisible(false);
clearWarnings();
loadData();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id))
imgv_profile.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
else
imv_profile.setImageBitmap(null);
imgv_profile.setImageBitmap(null);
}
private void loadData() {
......@@ -877,10 +885,10 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
if(isPhotoDelete) {
values.put("photo_type", "delete");
}else {
values.put("photo_content", Utils.getBase64FromFile(userPhotoHelper.getTempFilePath()));
values.put("photo_content", Utils.getBase64FromFile(userImgHelper.getTempFilePath(Utils.USR_PICT_FILE_NAME, id)));
values.put("photo_type", "image/png");
// TODO: 03/05/17 Change here to work with multi photo types
values.put("photo_name", userPhotoHelper.getUserUid() + ".png");
values.put("photo_name", id + ".png");
}
}
......@@ -989,8 +997,8 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
final Intent intent = new Intent(captureIntent);
intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
intent.setPackage(packageName);
intent.putExtra(MediaStore.EXTRA_OUTPUT, userPhotoHelper.getTempFileUri());
getBaseContext().grantUriPermission(packageName, userPhotoHelper.getTempFileUri(), Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(MediaStore.EXTRA_OUTPUT, userImgHelper.getTempFileUri(Utils.USR_PICT_FILE_NAME, id));
getBaseContext().grantUriPermission(packageName, userImgHelper.getTempFileUri(Utils.USR_PICT_FILE_NAME, id), Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
cameraIntents.add(intent);
}
......@@ -1037,36 +1045,35 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
}
//selected image path is returned by data.getData();
try {
if (isCamera) {
userPhotoHelper.convertToPng();
}
else {
userPhotoHelper.copyFileToPrivate(data.getData());
}
} catch (Exception e) {
// TODO: 04/05/17 user messages & error warning
Toast.makeText(this, "Ocorreu um problema ao salvar a imagem", Toast.LENGTH_SHORT).show();
e.printStackTrace();
//selected image path is returned by data.getData();
try {
if (isCamera) {
userImgHelper.convertToPng(Utils.USR_PICT_FILE_NAME, id);
} else {
userImgHelper.copyFileToPrivate(Utils.USR_PICT_FILE_NAME, id, data.getData());
}
} catch (Exception e) {
// TODO: 04/05/17 user messages & error warning
Toast.makeText(this, "Ocorreu um problema ao salvar a imagem", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
isChangingPhoto = true;
isPhotoDelete = false;
Bitmap content = userImgHelper.getRoundBitmap(userImgHelper.getTempFileUri(Utils.USR_PICT_FILE_NAME, id));
//TODO: user messages & error warning (same as above).
if(userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getTempFileUri()))
{
if (content == null) {
//show message if update fails
Toast.makeText(this, "Ocorreu um erro, tem certeza de que é uma imagem?", Toast.LENGTH_SHORT).show();
} else {
imgv_profile.setImageBitmap(content);
}
}
}
}
public void setCurrentPassword(String current_password) {
this.current_password = current_password;
}
......
package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.Dependent;
import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.presenters.DependentsUpdatePresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.DependentsUpdateView;
......@@ -15,7 +20,14 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
private DependentsUpdatePresenter presenter;
private Dependent dependent;
private FullDependent dependent;
private boolean hasChanged;
private ImageView imv_profile;
private ImageButton bt_photo;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -35,8 +47,29 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_acc);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
imv_profile = (ImageView) findViewById(R.id.img_account_photo);
bt_photo = (ImageButton) findViewById(R.id.btn_account_photo);
bt_photo.setVisibility(View.VISIBLE);
final AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar_dependents);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
float percentage = 1.5f * ((float) Math.abs(verticalOffset) / appBarLayout.getTotalScrollRange());
imv_profile.setAlpha(1 - percentage);
bt_photo.setAlpha(1 - percentage);
}
});
try {
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}catch (Exception e){
e.printStackTrace();
}
hasChanged = false;
}
@Override
......@@ -68,4 +101,16 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
return super.onOptionsItemSelected(item);
}
}
private void loadData(){
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
}
......@@ -23,6 +23,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.DependentsArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.RecyclerViewItemListener;
import br.ufpr.c3sl.agendador.agendador.models.Dependent;
import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.presenters.DependentsListPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.DependentsListView;
......@@ -75,11 +76,7 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
rv_dependents.addOnItemTouchListener(new RecyclerViewItemListener(getApplicationContext(), rv_dependents,
new RecyclerViewItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) {
Intent intent = new Intent(DependentsListActivity.this, DependentUpdateActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, dependents.get(position));
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent);
presenter.requestDependentInfo(dependents.get(position).getId());
}
public void onLongClickItem(View v, int position) {
......@@ -102,6 +99,17 @@ public class DependentsListActivity extends AppCompatActivity implements Depende
}
public void onDependentReceived(FullDependent dependent){
Intent intent = new Intent(DependentsListActivity.this, DependentUpdateActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, dependent);
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent);
finish();
}
public void onRequestFailure(){
Bundle bundle = new Bundle();
if(dg_connection_failure == null){
......
......@@ -21,7 +21,6 @@ import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......@@ -32,7 +31,8 @@ import android.widget.TextView;
import android.widget.Toast;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.HomePresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.HomeView;
......@@ -49,13 +49,15 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private DrawerLayout drawer;
private NavigationView navigationView;
private TextView tv_presentation;
private ConfirmationDialog confirmationDialog;
private UserImgHelper userImgHelper;
private ImageView drawerProfilePicture;
private Snackbar snackbar;
public static String SHOW_SCHEDULE_SNACKBAR = "snack_bar";
private long id;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -75,7 +77,7 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
id = osb.getLong("id", 0);
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
......@@ -104,9 +106,9 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
View headerView = navigationView.getHeaderView(0);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext());
userImgHelper = new UserImgHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
......@@ -116,8 +118,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
drawerCityName.setText(citizenCity);
if(userPhotoHelper.existsPhoto()){
userPhotoHelper.updateImgView(drawerProfilePicture, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id)){
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
}
drawerHamburger.setOnClickListener(new View.OnClickListener() {
......@@ -172,8 +174,16 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
protected void onResume() {
super.onResume();
presenter.bindView(this);
MenuItem item = navigationView.getMenu().findItem(R.id.nav_my_info);
item.setChecked(false);
int size = navigationView.getMenu().size();
for (int i = 0; i < size; i++) {
navigationView.getMenu().getItem(i).setChecked(false);
}
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id)){
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
}else{
drawerProfilePicture.setImageBitmap(null);
}
}
@Override
......
......@@ -24,7 +24,8 @@ import java.io.IOException;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.LoginPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.LoginView;
......@@ -207,13 +208,12 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
}
@Override
public void afterSuccessfulPhoto(Bitmap bitmap, String uid){
public void afterSuccessfulPhoto(Bitmap bitmap, long id){
Log.d("AAAAAAAAAa", "CHEGUEI NO PHOTO SUCCESFULL");
// TODO: 17/04/17 user messages & error warning
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext(), uid);
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
try {
userPhotoHelper.saveBitmap(bitmap);
userImgHelper.saveBitmap(bitmap, Utils.USR_PICT_FILE_NAME, id);
} catch (IOException e) {
Toast.makeText(this, "Ocorreu um problema ao atualizar sua foto de perfil", Toast.LENGTH_SHORT).show();
e.printStackTrace();
......
......@@ -30,7 +30,7 @@ import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
......@@ -61,6 +61,8 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
private static final String EXIT_CONFIRMATION_DIALOG_TAG = "exit_dialog";
private long id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -88,6 +90,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
id = osb.getLong("id", 0);
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
......@@ -119,7 +122,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext());
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
......@@ -129,8 +132,8 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
drawerCityName.setText(citizenCity);
if(userPhotoHelper.existsPhoto()){
userPhotoHelper.updateImgView(drawerProfilePicture, userPhotoHelper.getPhotoFileUri());
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id)){
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
}
drawerHamburger.setOnClickListener(new View.OnClickListener() {
......
......@@ -41,7 +41,7 @@ import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.HintAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.HintEnableAdapter;
......@@ -137,6 +137,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array";
private long id;
@Override
......@@ -193,6 +195,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
final String citizenCity = osb.getString("city.name", null);
id = osb.getLong("id", 0);
NavigationView navigationView = (NavigationView) findViewById(R.id.scheduling_navigation_view);
navigationView.getMenu().findItem(R.id.nav_schedule).setChecked(true);
......@@ -201,7 +204,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext());
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
......@@ -225,8 +228,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
confirmationDialogFragment = new ConfirmationDialogFragment();
if (userPhotoHelper.existsPhoto()) {
userPhotoHelper.updateImgView(drawerProfilePicture, userPhotoHelper.getPhotoFileUri());
if (userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id)) {
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, id)));
}
navigationView.setNavigationItemSelectedListener(this);
......
......@@ -10,8 +10,8 @@ import android.graphics.Shader;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import java.io.File;
import java.io.FileDescriptor;
......@@ -25,66 +25,47 @@ import java.io.IOException;
// TODO: 03/05/17 Add multi file extension usage.
public class UserPhotoHelper {
public class UserImgHelper {
private String filePath;