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

Issue AGILE#198 Confirmation done

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 3b03eaec
......@@ -17,7 +17,7 @@
<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"
......
......@@ -255,7 +255,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
else{
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_cep_connection_error));
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
......@@ -285,7 +285,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
scrollUp();
......@@ -394,11 +394,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
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);
startActivity(intent);*/
super.onBackPressed();
finish();
}
}
......@@ -436,10 +432,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
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);
startActivity(intent);
finish();
onBackPressed();
}
return true;
case R.id.btn_edit_account:
......@@ -779,7 +772,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_warningDialog_message) + "\n" +
getString(R.string.signup_warningDialog_message2))
.setTitle(getString(R.string.signup_warningDialog_title))
.setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dismiss();
......@@ -798,7 +791,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.dialog_cep_warning_message) +
getString(R.string.signup_warningDialog_message2))
.setTitle(getString(R.string.signup_warningDialog_title))
.setTitle(getString(R.string.warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -898,7 +891,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
......@@ -912,7 +905,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_cep_connection_error));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
......@@ -926,7 +919,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
......
......@@ -68,12 +68,12 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
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);
Intent intent = new Intent(CitizenActivity.this, TermActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
intent.putExtra(Utils.SECTORS_CITIZENS_BUNDLE, bundle);
intent.putExtra(Utils.CITIZEN_BUNDLE, bundle);
startActivity(intent);
finish();
}
public void onLongClickItem(View v, int position) {
......@@ -81,8 +81,6 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
}
}));
citizensPresenter.bindView(this);
citizensPresenter.requestCitizens();
}
......@@ -91,7 +89,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
protected void onResume() {
super.onResume();
citizensPresenter.bindView(this);
citizensPresenter.requestCitizens();
}
@Override
......@@ -100,6 +98,13 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
citizensPresenter.unbindView();
}
@Override
protected void onStart() {
super.onStart();
}
public void showLayout(boolean enabled) {
rv_citizens.setAdapter(new CitizensArrayAdapter(this, citizens));
......@@ -115,7 +120,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
if(dg_connection_failure == null){
dg_connection_failure = new ConnectionFailureDialog();
}
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_term_error));
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);
......
package br.ufpr.c3sl.agendador.agendador;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
......@@ -12,6 +11,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
......@@ -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;
......@@ -29,16 +28,11 @@ import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
import com.firebase.jobdispatcher.GooglePlayDriver;
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.Utils;
import br.ufpr.c3sl.agendador.agendador.presenters.HomePresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter;
import br.ufpr.c3sl.agendador.agendador.services.ImageUpdateService;
import br.ufpr.c3sl.agendador.agendador.views.HomeView;
/**
......@@ -46,10 +40,6 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
*/
// 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;
......@@ -60,6 +50,10 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
private ConfirmationDialog confirmationDialog;
private Snackbar snackbar;
public static String SHOW_SCHEDULE_SNACKBAR = "snack_bar";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -138,12 +132,20 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, TermActivity.class);
Intent intent = new Intent(HomeActivity.this, CitizenActivity.class);
startActivity(intent);
}
});
snackbar = Snackbar.make(findViewById(R.id.coordinator_home), R.string.snackbar_home_description,Snackbar.LENGTH_LONG)
.setAction(R.string.snackbar_home_action, new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getBaseContext(), "Abrir a tela de agendamentos", Toast.LENGTH_SHORT).show();
}
});
changeTextColor();
showSnackBar(getIntent());
}
@TargetApi(23)
......@@ -217,15 +219,35 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
return true;
break;
case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class);
item.setChecked(false);
intent = new Intent(this, CitizenActivity.class);
startActivity(intent);
break;
default:
break;
}
return true;
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
showSnackBar(intent);
}
private void showSnackBar(Intent intent){
if(intent != null){
Bundle extras = intent.getBundleExtra(SHOW_SCHEDULE_SNACKBAR);
if (extras != null) {
int b = extras.getInt(SHOW_SCHEDULE_SNACKBAR, 0);
if(b != 0){
snackbar.show();
}
}
}
return false;
}
......
......@@ -102,7 +102,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
if (dg_connection_error == null)
dg_connection_error = new ConnectionErrorDialog();
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
setWrongPassword(false);
......@@ -189,7 +189,7 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
}
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
......
......@@ -15,6 +15,7 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......@@ -24,8 +25,6 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
......@@ -34,10 +33,7 @@ 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.Utils;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter;
import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView;
......@@ -46,6 +42,7 @@ import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView;
* Created by Lucas B. Cunha on 25/07/17.
*/
public class ScheduleConfirmationActivity extends AppCompatActivity implements ScheduleConfirmationView, NavigationView.OnNavigationItemSelectedListener{
private ScheduleConfirmationPresenter scheduleConfirmationPresenter;
......@@ -75,12 +72,12 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
setContentView(R.layout.activity_schedule_confirmation);
Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE);
SectorInput sector = bundle.getParcelable(Utils.SECTOR);
final UserOutput citizen = bundle.getParcelable(Utils.CITIZEN);
ServiceLocation location = bundle.getParcelable(Utils.LOCATION);
ServiceType type = bundle.getParcelable(Utils.TYPE);
final ServiceSchedule schedule = bundle.getParcelable(Utils.SCHEDULE);
final ScheduleConfirmation scheduleConfirmation = bundle.getParcelable(Utils.SCHEDULE_CONFIRMATION);
String sectorName = scheduleConfirmation.getSectorName();
String locationName = scheduleConfirmation.getLocationName();
String typeName = scheduleConfirmation.getServiceTypeName();
String address = scheduleConfirmation.getAddressStreet() + ", " + scheduleConfirmation.getAddressNumber();
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null);
......@@ -113,6 +110,8 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.schedule_confirmation_navigation_view);
navigationView.getMenu().findItem(R.id.nav_schedule).setChecked(true);
View headerView = navigationView.getHeaderView(0);
......@@ -148,14 +147,16 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
TextView tv_location = (TextView) findViewById(R.id.tv_schedule_location_content);
TextView tv_type = (TextView) findViewById(R.id.tv_schedule_type_content);
TextView tv_schedule = (TextView) findViewById(R.id.tv_schedule_date_content);
TextView tv_street = (TextView) findViewById(R.id.tv_schedule_street_content);
tv_sector.setText(sector.getName());
tv_sector.setText(sectorName);
tv_citizen.setText(citizen.getName());
tv_location.setText(location.getmName());
tv_type.setText(type.getmDescription());
tv_location.setText(locationName);
tv_type.setText(typeName);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault());
tv_schedule.setText(dateFormat.format(schedule.getStart()));
tv_schedule.setText(dateFormat.format(scheduleConfirmation.getStartTime()));
tv_street.setText(address);
bt_schedule = (Button) findViewById(R.id.btn_schedule_confirm);
......@@ -165,7 +166,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
bt_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
scheduleConfirmationPresenter.onScheduleClicked(schedule, citizen);
scheduleConfirmationPresenter.onScheduleClicked(scheduleConfirmation, citizen);
bt_schedule.setEnabled(false);
bt_back.setEnabled(false);
}
......@@ -199,14 +200,14 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
return true;
break;
case R.id.nav_schedule:
intent = new Intent(this, TermActivity.class);
item.setChecked(false);
startActivity(intent);
//do nothing.
break;
default:
break;
}
return false;
return true;
}
@Override
......@@ -243,12 +244,21 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
public void onSuccess(){
Intent intent = new Intent(ScheduleConfirmationActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putInt(HomeActivity.SHOW_SCHEDULE_SNACKBAR, 1);
intent.putExtra(HomeActivity.SHOW_SCHEDULE_SNACKBAR,bundle);
startActivity(intent);
}
@Override
public void setProgressBar(boolean enabled) {
if (enabled) {
......@@ -262,6 +272,18 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
}
@Override
public void setConnectionError(boolean enabled){
if(enabled){
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
public static class ConfirmationDialog extends DialogFragment {
......
......@@ -105,7 +105,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
Bundle bundle = new Bundle();
if(dg_connection_error == null)
dg_connection_error = new ConnectionErrorDialog();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
......@@ -363,7 +363,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
dg_connection_error = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), "noConnectionDialog");
}
......
......@@ -26,6 +26,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.SectorArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.TermPresenter;
import br.ufpr.c3sl.agendador.agendador.views.TermView;
......@@ -43,7 +44,7 @@ public class TermActivity extends AppCompatActivity implements TermView {
private ConnectionFailureDialog dg_connection_failure;
private UserOutput citizen;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -55,6 +56,10 @@ public class TermActivity extends AppCompatActivity implements TermView {
}
setContentView(R.layout.activity_term);
Bundle bundle = getIntent().getBundleExtra(Utils.CITIZEN_BUNDLE);
citizen = bundle.getParcelable(Utils.CITIZEN);
Button refusal = (Button) findViewById(R.id.btn_term_refusal);
Button accept = (Button) findViewById(R.id.btn_term_accept);
......@@ -65,16 +70,16 @@ public class TermActivity extends AppCompatActivity implements TermView {
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);
Intent intent = new Intent(TermActivity.this, SchedulingActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizen);
bundle.putParcelableArrayList(Utils.SECTORS_LIST, (ArrayList<? extends Parcelable>) sectors);
intent.putExtra(Utils.SECTORS_BUNDLE, bundle);
intent.putExtra(Utils.SECTORS_CITIZENS_BUNDLE, bundle);
startActivity(intent);
finish();
}
......@@ -98,9 +103,8 @@ public class TermActivity extends AppCompatActivity implements TermView {
R.drawable.item_divider)));
termPresenter.bindView(this);
termPresenter.requestSectors();
termPresenter.requestSectors(citizen);
}
@Override
......@@ -116,9 +120,7 @@ public class TermActivity extends AppCompatActivity implements TermView {
termPresenter.unbindView();
}
@Override
@Override
public void showLayout(boolean enabled) {
rv_sectors.setAdapter(new SectorArrayAdapter(this, sectors));
......@@ -140,12 +142,12 @@ public class TermActivity extends AppCompatActivity implements TermView {
this.sectors = sectors;
}
public void onRequestFailure(){
public void onRequestFailure() {
Bundle bundle = new Bundle();
if(dg_connection_failure == null){
if (dg_connection_failure == null) {
dg_connection_failure = new ConnectionFailureDialog();
}
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_term_error));
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);
......@@ -180,13 +182,12 @@ public class TermActivity extends AppCompatActivity implements TermView {
/**
* Based on: https://www.survivingwithandroid.com/2016/09/android-recyclerview-tutorial.html
*
*/
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private class DividerItemDecoration extends RecyclerView.ItemDecoration {
private Drawable mDivider;
public DividerItemDecoration(Drawable divider) {
DividerItemDecoration(Drawable divider) {
this.mDivider = divider;
}
......
......@@ -16,14 +16,18 @@ public class ConnectionErrorDialog extends DialogFragment {
public static final String DIALOG_CONNECTION_ERROR = "connection_error";
public static final String DIALOG_MESSAGE_KEY = "message";
public static final String DIALOG_MESSAGE = "message";
public static final String DIALOG_TITLE = "title";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String title = getArguments().getString(DIALOG_TITLE);
if(title == null)
title = getResources().getString(R.string.warningDialog_title);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getArguments().getString(DIALOG_MESSAGE_KEY))
.setTitle(getString(R.string.warningDialog_title))
builder.setMessage(getArguments().getString(DIALOG_MESSAGE))
.setTitle(title)
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......
......@@ -31,8 +31,6 @@ public class Utils {
public static final String SECTORS_LIST = "sectors_list";
public static final String SECTORS_BUNDLE = "br.ufpr.c3sl.agendador.agendador.sectors_bundle";
public static final String SECTORS_CITIZENS_BUNDLE = "br.ufpr.c3sl.agendador.agendador.sectors_citizens_bundle";
public static final String SCHEDULE_BUNDLE = "br.ufpr.c3sl.agendador.agendador.schedule_confirmation";
......@@ -41,16 +39,20 @@ public class Utils {
public static final String USR_PICT_FILE_NAME = "usr_prof_pic";
public static final String SCHEDULE_CONFIRMATION = "selected_schedule";
public static final String CITIZEN = "citizen_object";
public static final String CITIZEN_BUNDLE = "br.ufpr.c3sl.agendador.agendador.citizen_bundle";
// TODO: 31/07/17 delete if not needed (till merge)
/*
public static final String SECTOR = "selected_sector";
public static final String LOCATION = "selected_location";
public static final String TYPE = "selected_type";
public static final String SCHEDULE = "selected_schedule";
*/
public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources();
......
......@@ -2,8 +2,6 @@ package br.ufpr.c3sl.agendador.agendador.helpers.adapters;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
......@@ -19,17 +17,20 @@ import android.widget.TextView;
public class HintEnableAdapter extends ArrayAdapter<String> {
boolean[] enableView;
private boolean[] paintView;
public HintEnableAdapter(Context context, int resource, String[] objects, boolean[] enableView) {
private int color;
public HintEnableAdapter(Context context, int resource, String[] objects, boolean[] paintView, int color) {
super(context, resource, objects);
this.enableView = enableView;
this.paintView = paintView;
this.color = color;
}
@Override
public boolean isEnabled(int position) {
return enableView[position];
return !paintView[position];
}
......@@ -43,8 +44,8 @@ public class HintEnableAdapter extends ArrayAdapter<String> {
ViewGroup parent) {
View mView = super.getDropDownView(position, convertView, parent);
TextView mTextView = (TextView) mView;
if (!enableView[position])
mTextView.setTextColor(Color.GRAY);
if (paintView[position])
mTextView.setTextColor(color);
else
mTextView.setTextColor(Color.BLACK);
return mView;
......
package br.ufpr.c3sl.agendador.agendador.helpers.adapters;
import android.content.Context;
import android.graphics.Color;
import android.provider.CalendarContract;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;