Commit 3ed09781 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Merge branch 'develop' into 'check_schedules'

# Conflicts:
#   app/build.gradle
#   app/src/main/AndroidManifest.xml
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/HomeActivity.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/SchedulingActivity.java
#   app/src/main/res/layout/appbar_home.xml
#   app/src/main/res/layout/content_scheduling.xml
#   app/src/main/res/values/strings.xml
parents 5aaed849 8e7761f8
......@@ -25,13 +25,17 @@ dependencies {
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'
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'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
......@@ -9,9 +9,15 @@
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"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
......@@ -27,12 +33,31 @@
<activity android:name=".HomeActivity" />
<activity android:name=".CepActivity" />
<activity android:name=".CepNotFoundActivity" />
<activity android:name=".SignupActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".AccountActivity" />
<activity android:name=".ForgotPasswordActivity" />
<activity android:name=".PasswordRetrievalActivity" />
<activity android:name=".DependentsListActivity" />
<service
android:name=".services.ImageUpdateService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<activity android:name=".TermActivity" />
<activity android:name=".SchedulingActivity" />
<activity android:name=".SchedulesActivity"></activity>
<activity
android:name=".SchedulingActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity android:name=".CitizenListActivity" />
<activity android:name=".ScheduleConfirmationActivity" />
<activity android:name=".DependentUpdateActivity" />
<activity android:name=".NewDependentActivity" />
<activity android:name=".RetrievalFailureActivity" />
<activity android:name=".RetrievalSuccessActivity"></activity>
</application>
</manifest>
\ No newline at end of file
......@@ -3,6 +3,7 @@ package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
......@@ -12,7 +13,9 @@ import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.CepPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.CepView;
/**
......@@ -34,6 +37,8 @@ public class CepActivity extends AppCompatActivity implements CepView {
presenter = new CepPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new CepPresenter(this);
}
setContentView(R.layout.activity_cep);
......@@ -43,7 +48,9 @@ public class CepActivity extends AppCompatActivity implements CepView {
pb_waiting = (ProgressBar) findViewById(R.id.pb_cepact);
et_cep = (EditText) findViewById(R.id.et_cepact_cep);
et_cep.addTextChangedListener(Mask.insert("#####-###", et_cep));
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_cep.addTextChangedListener(new CepChangeListener());
tv_invalid_cep = (TextView) findViewById(R.id.tv_cepact_invalid_cep);
......@@ -84,8 +91,8 @@ public class CepActivity extends AppCompatActivity implements CepView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -8,6 +8,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.presenters.CepNotFoundPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.CepNotFoundView;
/**
......@@ -27,6 +28,8 @@ public class CepNotFoundActivity extends AppCompatActivity implements CepNotFoun
presenter = new CepNotFoundPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new CepNotFoundPresenter(this);
}
setContentView(R.layout.activity_cep_not_found);
......@@ -44,7 +47,7 @@ public class CepNotFoundActivity extends AppCompatActivity implements CepNotFoun
String state_name = intent.getStringExtra("statename_su");
if (city_name.equals("null")) {
error_message.setText("Cep inválido");
error_message.setText(getResources().getString(R.string.invalid_cep));
} else {
error_message.setText(String.format(getString(R.string.cep_not_found_message),
city_name, state_name));
......@@ -65,7 +68,7 @@ public class CepNotFoundActivity extends AppCompatActivity implements CepNotFoun
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
}
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.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.CitizensArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.RecyclerViewItemListener;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.presenters.CitizensPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.CitizenView;
/**
* Created by Lucas B. Cunha on 27/06/17.
*/
public class CitizenListActivity extends AppCompatActivity implements CitizenView{
private RecyclerView rv_citizens;
private ProgressBar pb_citizen;
private CitizensPresenter citizensPresenter;
private List<CitizenCompact> citizens;
private ConnectionFailureDialog dg_connection_failure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_citizen);
if (savedInstanceState == null) {
citizensPresenter = new CitizensPresenter(this);
}
else{
citizensPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(citizensPresenter == null){
citizensPresenter = new CitizensPresenter(this);
}
}
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 RecyclerViewItemListener(getApplicationContext(), rv_citizens,
new RecyclerViewItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) {
Intent intent = new Intent(CitizenListActivity.this, TermActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent);
finish();
}
public void onLongClickItem(View v, int position) {
//do nothing.
}
}));
}
@Override
protected void onResume() {
super.onResume();
citizensPresenter.bindView(this);
if(citizens == null)
citizensPresenter.requestCitizens();
}
@Override
protected void onPause() {
super.onPause();
citizensPresenter.unbindView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(citizensPresenter, outState);
super.onSaveInstanceState(outState);
}
public void showLayout(boolean enabled) {
if(enabled){
rv_citizens.setAdapter(new CitizensArrayAdapter(this, citizens));
rv_citizens.setVisibility(View.VISIBLE);
}
}
public void successfulCitizens(List<CitizenCompact> 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, 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();
}
}
}
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.graphics.Bitmap;
import android.os.Bundle;
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;
import android.widget.Toast;
import java.io.IOException;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
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;
/**
* Created by Lucas B. Cunha on 08/08/17.
*/
public class DependentsListActivity extends AppCompatActivity implements DependentsListView {
private DependentsListPresenter presenter;
private ProgressBar pb_dependents;
private RecyclerView rv_dependents;
private ConnectionFailureDialog dg_connection_failure;
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) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new DependentsListPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new DependentsListPresenter(this);
}
setContentView(R.layout.activity_dependents_list);
FloatingActionButton fabNewDependent = (FloatingActionButton) findViewById(R.id.fab_new_dependent);
pb_dependents = (ProgressBar) findViewById(R.id.pb_dependentact);
rv_dependents = (RecyclerView) findViewById(R.id.rv_dependents);
RecyclerView.LayoutManager layout = new LinearLayoutManager(this,
LinearLayoutManager.VERTICAL, false);
rv_dependents.setLayoutManager(layout);
rv_dependents.setVisibility(View.INVISIBLE);
rv_dependents.addOnItemTouchListener(new RecyclerViewItemListener(getApplicationContext(), rv_dependents,
new RecyclerViewItemListener.RecyclerTouchListener() {
public void onClickItem(View v, int position) {
presenter.requestDependentInfo(dependents.get(position).getId());
}
public void onLongClickItem(View v, int position) {
//Do nothing
}
}));
fabNewDependent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(DependentsListActivity.this, NewDependentActivity.class);
startActivityForResult(intent, NEW_DEPENDENT_CODE);
}
});
}
public void successfulDependents(List<Dependent> dependents) {
this.dependents = dependents;
updateList = false;
showLayout(true);
}
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);
startActivityForResult(intent, DEPENDENT_UPDATE_CODE);
}
public void onRequestFailure(){
Bundle bundle = new Bundle();
if(dg_connection_failure == null){
dg_connection_failure = new ConnectionFailureDialog();
}
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_term_error));
dg_connection_failure.setArguments(bundle);
dg_connection_failure.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
@Override
public void afterSuccessfulPicture(Bitmap bitmap, long id){
// TODO: 17/04/17 user messages & error warning
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
try {
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();
}
}
public void afterPictureFailed(){
// TODO: 17/04/17 user messages & error warning
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;
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
@Override
protected void onResume() {
super.onResume();
presenter.bindView(this);
if(dependents == null || updateList)
presenter.requestDependents();
}
@Override
protected void onPause() {
super.onPause();
presenter.unbindView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
private void showLayout(boolean enabled) {
if(enabled){
rv_dependents.setAdapter(new DependentsArrayAdapter(dependents, this));
rv_dependents.setVisibility(View.VISIBLE);
}
}
public void setProgressBar(boolean enabled) {
if (enabled) {
pb_dependents.setVisibility(View.VISIBLE);
rv_dependents.setVisibility(View.INVISIBLE);
} else {
pb_dependents.setVisibility(View.INVISIBLE);
rv_dependents.setVisibility(View.VISIBLE);
}
}
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) {
dismiss();
}
});
return builder.create();
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
Activity activity = getActivity();
activity.onBackPressed();
}
}
}
package br.ufpr.c3sl.agendador.agendador;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.presenters.ForgotPasswordPresenter;
import br.ufpr.c3sl.agendador.agendador.views.ForgotPasswordView;
/**
* Created by Horstmann on 23/02/17.
*/
public class ForgotPasswordActivity extends AppCompatActivity implements ForgotPasswordView {
private ForgotPasswordPresenter presenter;
private Button btn_send;
private EditText et_cpf;
private TextView tv_cpf, tv_cpf_warning;
private ProgressBar pb_waiting;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new ForgotPasswordPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_login);
tv_cpf = (TextView) findViewById(R.id.tv_forgot_password_cpf);
tv_cpf_warning = (TextView) findViewById(R.id.tv_forgot_password_invalid_cpf);
}
@Override
public void setProgressBar(boolean enabled) {
}
}
package br.ufpr.c3sl.agendador.agendador;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.content.res.ResourcesCompat;