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

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>
......
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;
private Button btn_schedule;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -74,12 +79,12 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
citizenName = osb.getString("name", null);
citizenCity = osb.getString("city.name", null);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
......@@ -135,6 +140,16 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
navigationView.setNavigationItemSelectedListener(this);
btn_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, TermActivity.class);
startActivity(intent);
}
});
changeTextColor();
}
......@@ -207,11 +222,14 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
Intent intent;
switch (item.getItemId()) {
case R.id.nav_my_info:
item.setChecked(false);
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
return true;
case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class);
item.setChecked(false);
startActivity(intent);
default:
}
return false;
......
......@@ -94,10 +94,11 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
R.color.colorRed, null));
}
else {
if (ConnectionChecker.hasConnection(getBaseContext()))
if (ConnectionChecker.hasConnection(getBaseContext())) {
btn_login.setEnabled(false);
presenter.onLoginClicked(Mask.unmask(et_cpf.getText().toString()),
et_password.getText().toString());
else {
}else {
if (dg_connection_error == null)
dg_connection_error = new ConnectionErrorDialog();
Bundle bundle = new Bundle();
......@@ -167,6 +168,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void setWrongPassword(boolean enabled) {
btn_login.setEnabled(true);
TextView textView = (TextView) findViewById(R.id.tv_loginact_error);
if (enabled) {
textView.setText(R.string.loginact_error);
......@@ -182,6 +184,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void setNoConnection(boolean enabled) {
if(enabled){
btn_login.setEnabled(true);
Bundle bundle = new Bundle();
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
......
......@@ -18,7 +18,7 @@ import java.util.HashMap;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
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.presenters.SignupPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SignupView;
......@@ -144,7 +144,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
public boolean validateData() {
boolean openDialog = false;
String bDate = DataValidador.stringToDate(et_birthday.getText().toString(), false);
String bDate = DateValidator.stringToDate(et_birthday.getText().toString(), false);
if (et_name.getText().toString().replaceAll("\\s+", "").isEmpty()) {
openDialog = true;
......@@ -157,7 +157,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
tv_cpf_warning.setText(R.string.cpf_empty);
tv_cpf_warning.setVisibility(View.VISIBLE);
} else {
if (DataValidador.isValidCPF(Mask.unmask(et_cpf.getText().toString()))) {
if (DateValidator.isValidCPF(Mask.unmask(et_cpf.getText().toString()))) {
tv_cpf_warning.setVisibility(View.INVISIBLE);
} else {
......@@ -166,7 +166,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
openDialog = true;
}
}
if (bDate.isEmpty() || !DataValidador.isValidBirthDate(bDate)) {
if (bDate.isEmpty() || !DateValidator.isValidBirthDate(bDate)) {
openDialog = true;
tv_birthday_warning.setVisibility(View.VISIBLE);
} else {
......@@ -177,7 +177,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
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);
......@@ -295,7 +295,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
HashMap<String,String> values = new HashMap<String,String>();
values.put("cpf",Mask.unmask(et_cpf.getText().toString()));
values.put("birth_date",DataValidador.stringToDate(et_birthday.getText().toString(),false));
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());
......
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.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.content.ContextCompat;
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.Button;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import java.util.ArrayList;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.SectorArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.presenters.TermPresenter;
import br.ufpr.c3sl.agendador.agendador.views.TermView;
public class TermActivity extends AppCompatActivity implements TermView {
private TermPresenter termPresenter;
private List<SectorInput> sectors;
private RecyclerView rv_sectors;
private ProgressBar pb_term;
private ScrollView sv_term;
private ConnectionFailureDialog dg_connection_failure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
termPresenter = new TermPresenter(this);
} else {
termPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_term);
Button refusal = (Button) findViewById(R.id.btn_term_refusal);
Button accept = (Button) findViewById(R.id.btn_term_accept);
refusal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TermActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
});
accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(TermActivity.this, CitizenActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(Utils.SECTORS_LIST, (ArrayList<? extends Parcelable>) sectors);
intent.putExtra(Utils.SECTORS_BUNDLE, bundle);
startActivity(intent);
finish();
}
});
pb_term = (ProgressBar) findViewById(R.id.pb_termact);
sv_term = (ScrollView) findViewById(R.id.sv_termact);
sv_term.setVisibility(View.INVISIBLE);
rv_sectors = (RecyclerView) findViewById(R.id.rv_term_sectors);
RecyclerView.LayoutManager layout = new LinearLayoutManager(this,
LinearLayoutManager.VERTICAL, false);
rv_sectors.setLayoutManager(layout);
rv_sectors.addItemDecoration(
new DividerItemDecoration(ContextCompat.getDrawable(getApplicationContext(),
R.drawable.item_divider)));
termPresenter.bindView(this);
termPresenter.requestSectors();
}
@Override
protected void onResume() {
super.onResume();
termPresenter.bindView(this);
}
@Override
protected void onPause() {
super.onPause();
termPresenter.unbindView();
}
@Override
public void showLayout(boolean enabled) {
rv_sectors.setAdapter(new SectorArrayAdapter(this, sectors));
sv_term.setVisibility(View.VISIBLE);
}
@Override
public void setProgressBar(boolean enabled) {
if (enabled) {
pb_term.setVisibility(View.VISIBLE);
sv_term.setVisibility(View.INVISIBLE);
} else {
pb_term.setVisibility(View.INVISIBLE);
}
}
public void successfulSectors(List<SectorInput> sectors) {
this.sectors = sectors;
}
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 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();
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
getActivity().onBackPressed();
}
}
/**
* Based on: https://www.survivingwithandroid.com/2016/09/android-recyclerview-tutorial.html
*
*/
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private Drawable mDivider;
public DividerItemDecoration(Drawable divider) {
this.mDivider = divider;
}
@Override
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
}
}
}
package br.ufpr.c3sl.agendador.agendador.helpers;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.R;
/**
* Created by Lucas B. Cunha on 27/06/17.
*/
public class CitizenHolder extends RecyclerView.ViewHolder{
final TextView name;
CitizenHolder(View view) {
super(view);
name = (TextView) view.findViewById(R.id.list_citizen_name);
}
}
package br.ufpr.c3sl.agendador.agendador.helpers;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
/**
* Created by Lucas B. Cunha on 27/06/17.
*/
public class CitizensArrayAdapter extends RecyclerView.Adapter {
private List<UserOutput> citizens;
private Context context;
public CitizensArrayAdapter(Context context, List<UserOutput> citizens){
super();
this.citizens = citizens;
this.context = context;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context)
.inflate(R.layout.item_citizen_list, parent, false);
return new CitizenHolder(view);
}
@Override