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

Merge Fix


Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parents a2847753 63f7e9d6
......@@ -24,14 +24,17 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.android.support:recyclerview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
......@@ -8,6 +8,12 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
......@@ -15,8 +21,6 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -57,6 +61,12 @@
</intent-filter>
</service>
<activity android:name=".TermActivity" />
<activity android:name=".SchedulingActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize" />
<activity android:name=".CitizenActivity"/>
</application>
......
......@@ -46,10 +46,10 @@ import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.CustomAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.DataValidador;
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.PhotoSelectionAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.AccountPresenter;
......@@ -68,7 +68,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 imgv_profile;
private ImageView imv_profile;
private ProgressBar pb_account;
private RadioButton rb_no, rb_yes;
private Button btn_update, btn_cancel;
......@@ -86,13 +86,12 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private boolean isChangingPassword;
private boolean isChangingPhoto;
private boolean isPhotoDelete;
private boolean isUpdated;
private UserPhotoHelper userPhotoHelper;
private ConnectionErrorDialog dg_connection_error;
private ConnectionErrorDialog connectionErrorDialog;
private final int REQUEST_PERMISSIONS = 1;
......@@ -102,7 +101,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
//TODO: DESIGNER - Define new color to "change photo button" or keep it gray?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -135,8 +133,8 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
String citizenName = osb.getString("name", "");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_acc);
toolbar.setTitle(citizenName);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(citizenName);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
pb_account = (ProgressBar) findViewById(R.id.pb_accountact);
......@@ -171,7 +169,7 @@ 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);
imgv_profile = (ImageView) findViewById(R.id.img_account_photo);
imv_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);
......@@ -201,7 +199,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());
imgv_profile.setAlpha(1 - percentage);
imv_profile.setAlpha(1 - percentage);
btn_photo.setAlpha(1 - percentage);
}
});
......@@ -255,10 +253,22 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
});
} else {
presenter.onCepNotFocused(Mask.unmask(et_cep.getText().toString()));
if(ConnectionChecker.hasConnection(getBaseContext())) {
presenter.onCepNotFocused(Mask.unmask(et_cep.getText().toString()));
}
else{
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
}
});
btn_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -274,6 +284,14 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
else{
setNoConnection(true);
if( connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
scrollUp();
}
}
else{
......@@ -301,7 +319,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
final String[] opts = {getString(R.string.prof_pic_update), getString(R.string.prof_pic_remove)};
int[] drawableIds = {android.R.drawable.ic_menu_camera, android.R.drawable.ic_menu_close_clear_cancel};
final CustomAdapter arrayAdapter = new CustomAdapter(getBaseContext(), opts, drawableIds);
final PhotoSelectionAdapter arrayAdapter = new PhotoSelectionAdapter(getBaseContext(), opts, drawableIds);
builderSingle.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
......@@ -317,7 +335,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
if(which == 1){
isPhotoDelete = true;
isChangingPhoto = true;
imgv_profile.setImageBitmap(null);
imv_profile.setImageBitmap(null);
}
else{
checkBuildVersion();
......@@ -330,13 +348,12 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
});
if(userPhotoHelper.existsPhoto()){
userPhotoHelper.updateImgView(imgv_profile, userPhotoHelper.getPhotoFileUri());
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
}
isChangingPassword = false;
isChangingPhoto = false;
isPhotoDelete = false;
isUpdated = false;
}
......@@ -376,9 +393,9 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
loadData();
scrollUp();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imgv_profile, userPhotoHelper.getPhotoFileUri());
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
else
imgv_profile.setImageBitmap(null);
imv_profile.setImageBitmap(null);
} else {
Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
......@@ -411,6 +428,15 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
case android.R.id.home:
if (editable) {
cancelUpdate();
enableAllFields(false);
setButtonVisible(false);
clearWarnings();
loadData();
scrollUp();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
else
imv_profile.setImageBitmap(null);
} else {
Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
......@@ -428,7 +454,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
return true;
case R.id.btn_sync_account:
Log.d("AccountActivity", "CLIQUEIIIIIIIIIIIIIIIII");
enableButtonSync(false);
presenter.updateCheck();
return true;
......@@ -541,9 +566,9 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
clearWarnings();
loadData();
if(userPhotoHelper.existsPhoto())
userPhotoHelper.updateImgView(imgv_profile, userPhotoHelper.getPhotoFileUri());
userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getPhotoFileUri());
else
imgv_profile.setImageBitmap(null);
imv_profile.setImageBitmap(null);
}
private void loadData() {
......@@ -581,7 +606,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
et_sus_number.setText(osb.getString("sus", null));
et_cep.setText(osb.getString("address.zipcode", null));
et_number.setText(osb.getString("address_number", null));
et_birthdate.setText(DataValidador.stringToDate(osb.getString("birth_date", null), true));
et_birthdate.setText(DateValidator.stringToDate(osb.getString("birth_date", null), true));
et_disability.setText(pcd);
et_address.setText(osb.getString("address.address", null));
et_neighborhood.setText(osb.getString("address.neighborhood", null));
......@@ -605,7 +630,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private boolean validateData() {
clearWarnings();
boolean openDialog = false;
String bDate = DataValidador.stringToDate(et_birthdate.getText().toString(), false);
String bDate = DateValidator.stringToDate(et_birthdate.getText().toString(), false);
if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) {
tv_name_warning.setText(R.string.null_name);
......@@ -615,7 +640,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
tv_name_warning.setVisibility(View.INVISIBLE);
}
if (bDate.isEmpty() || !DataValidador.isValidBirthDate(bDate)) {
if (bDate.isEmpty() || !DateValidator.isValidBirthDate(bDate)) {
tv_birthdate_warning.setText(R.string.invalid_birthdate);
tv_birthdate_warning.setVisibility(View.VISIBLE);
openDialog = true;
......@@ -628,7 +653,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
tv_email_warning.setVisibility(View.VISIBLE);
openDialog = true;
} else {
if (DataValidador.isValidEmail(et_email.getText().toString())) {
if (DateValidator.isValidEmail(et_email.getText().toString())) {
tv_email_warning.setVisibility(View.INVISIBLE);
} else {
tv_email_warning.setText(R.string.invalid_email);
......@@ -689,7 +714,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
PasswordDialog passwordDialog = new PasswordDialog();
passwordDialog.show(manager, "passwordDialog");
return;
}
......@@ -698,7 +722,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
PasswordWarningDialog passwordWarningDialog = new PasswordWarningDialog();
passwordWarningDialog.show(manager, "passwordWarningDialog");
return;
}
......@@ -827,7 +850,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
values.put("name", et_name.getText().toString());
values.put("rg", et_rg.getText().toString());
values.put("birth_date", DataValidador.stringToDate(et_birthdate.getText().toString(), false));
values.put("birth_date", DateValidator.stringToDate(et_birthdate.getText().toString(), false));
if (rb_no.isChecked()) {
values.put("pcd", null);
......@@ -873,27 +896,27 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
@Override
public void setConnectionError(boolean enabled){
if(enabled){
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
@Override
public void setConnectionCepError(boolean enabled){
if(enabled){
Log.d("Aaaa","aaaaaaaa");
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
......@@ -901,13 +924,13 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
public void setNoConnection(boolean enabled){
if(enabled) {
scrollUp();
if (dg_connection_error == null) {
dg_connection_error = new ConnectionErrorDialog();
if (connectionErrorDialog == null) {
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
......@@ -1017,10 +1040,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
isCamera = true;
} else {
final String action = data.getAction();
if (action == null)
isCamera = false;
else
isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
}
//selected image path is returned by data.getData();
......@@ -1040,8 +1060,9 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
isChangingPhoto = true;
isPhotoDelete = false;
// TODO: 04/05/17 user messages & error warning
if(userPhotoHelper.updateImgView(imgv_profile, userPhotoHelper.getTempFileUri()))
//TODO: user messages & error warning (same as above).
if(userPhotoHelper.updateImgView(imv_profile, userPhotoHelper.getTempFileUri()))
{
//show message if update fails
Toast.makeText(this, "Ocorreu um erro, tem certeza de que é uma imagem?", Toast.LENGTH_SHORT).show();
......@@ -1057,9 +1078,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
public void setUpdated(boolean updated) {
isUpdated = updated;
}
......
package br.ufpr.c3sl.agendador.agendador;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ProgressBar;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.CitizensArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.CitizensItemListener;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.CitizensPresenter;
import br.ufpr.c3sl.agendador.agendador.views.CitizenView;
/**
* Created by Lucas B. Cunha on 27/06/17.
*/
public class CitizenActivity extends AppCompatActivity implements CitizenView{
private RecyclerView rv_citizens;
private ProgressBar pb_citizen;
private CitizensPresenter citizensPresenter;
private List<UserOutput> citizens;
private ConnectionFailureDialog dg_connection_failure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
citizensPresenter = new CitizensPresenter(this);
} else {
citizensPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_citizen);
pb_citizen = (ProgressBar) findViewById(R.id.pb_citizenact);
rv_citizens = (RecyclerView) findViewById(R.id.rv_citizens_citizens);
RecyclerView.LayoutManager layout = new LinearLayoutManager(this,
LinearLayoutManager.VERTICAL, false);
rv_citizens.setLayoutManager(layout);
rv_citizens.setVisibility(View.INVISIBLE);
rv_citizens.addOnItemTouchListener(new CitizensItemListener(getApplicationContext(), rv_citizens,
new CitizensItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) {
Intent intent = new Intent(CitizenActivity.this, SchedulingActivity.class);
Bundle bundle = getIntent().getBundleExtra(Utils.SECTORS_BUNDLE);
bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
intent.putExtra(Utils.SECTORS_CITIZENS_BUNDLE, bundle);
startActivity(intent);
}
public void onLongClickItem(View v, int position) {
//do nothing.
}
}));
citizensPresenter.bindView(this);
citizensPresenter.requestCitizens();
}
@Override
protected void onResume() {
super.onResume();
citizensPresenter.bindView(this);
}
@Override
protected void onPause() {
super.onPause();
citizensPresenter.unbindView();
}
public void showLayout(boolean enabled) {
rv_citizens.setAdapter(new CitizensArrayAdapter(this, citizens));
rv_citizens.setVisibility(View.VISIBLE);
}
public void successfulCitizens(List<UserOutput> citizens) {
this.citizens = citizens;
}
public void onRequestFailure(){
Bundle bundle = new Bundle();
if(dg_connection_failure == null){
dg_connection_failure = new ConnectionFailureDialog();
}
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_term_error));
dg_connection_failure.setArguments(bundle);
dg_connection_failure.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
public void setProgressBar(boolean enabled) {
if (enabled) {
pb_citizen.setVisibility(View.VISIBLE);
rv_citizens.setVisibility(View.INVISIBLE);
} else {
pb_citizen.setVisibility(View.INVISIBLE);
}
}
public static class ConnectionFailureDialog extends DialogFragment {
public static final String DIALOG_MESSAGE_KEY = "message";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getArguments().getString(DIALOG_MESSAGE_KEY))
.setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Activity activity = getActivity();
activity.onBackPressed();
}
});
return builder.create();
}
}
}
......@@ -26,6 +26,7 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -43,6 +44,11 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
* Created by Bruno Freitas Tissei on 2/7/17.
*/
// TODO: 03/07/17 Sugestão: após agendamento perguntar se usuário quer visualizar sua lista de agendamentos.
public class HomeActivity extends AppCompatActivity implements HomeView,
NavigationView.OnNavigationItemSelectedListener {
private HomePresenter presenter;
......@@ -55,13 +61,12 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private NavigationView navigationView;
private TextView drawerCitizenName, drawerCityName, homeCitizenWelcome, tv_presentation;
private UserPhotoHelper userPhotoHelper;
private String citizenName, citizenCity;
private ConfirmationDialog confirmationDialog;