Commit 8a8bc493 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#218: Done layout for Schedule visualization

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent a34c10d8
......@@ -33,9 +33,8 @@ dependencies {
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.android.support.constraint:constraint-layout:1.0.2'
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'
}
......@@ -58,7 +58,9 @@
<activity android:name=".DependentUpdateActivity" />
<activity android:name=".NewDependentActivity" />
<activity android:name=".RetrievalFailureActivity" />
<activity android:name=".RetrievalSuccessActivity"/>
<activity android:name=".RetrievalSuccessActivity" />
<activity android:name=".SchedulesHistoryActivity" />
<activity android:name=".ScheduleInfoActivity"></activity>
</application>
</manifest>
\ No newline at end of file
......@@ -132,9 +132,9 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
navigationView.setNavigationItemSelectedListener(this);
Button btn_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
Button bt_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
btn_schedule.setOnClickListener(new View.OnClickListener() {
bt_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, CitizenListActivity.class);
......@@ -142,11 +142,21 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
}
});
Button bt_checkSchedules = (Button) findViewById(R.id.btn_homeact_check);
bt_checkSchedules.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, SchedulesActivity.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();
Intent intent = new Intent(HomeActivity.this, SchedulesActivity.class);
startActivity(intent);
}
});
changeTextColor();
......@@ -242,6 +252,10 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
intent = new Intent(this, DependentsListActivity.class);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
startActivity(intent);
break;
default:
break;
}
......
......@@ -217,6 +217,18 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
case R.id.nav_schedule:
//do nothing.
break;
case R.id.nav_check_schedules:
intent = new Intent(this, SchedulesActivity.class);
startActivity(intent);
break;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
startActivity(intent);
break;
default:
break;
}
......
package br.ufpr.c3sl.agendador.agendador;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.DialogFragment;
import android.support.v4.widget.DrawerLayout;
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.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;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CheckSchedules;
public class ScheduleInfoActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
private MenuBuilder menuBuilder;
private ConfirmationDialogFragment confirmationDialogFragment;
private NavigationView navigationView;
private long id;
private CheckSchedules.Schedule schedule;
private static final String EXIT_CONFIRMATION_DIALOG_TAG = "exit_dialog";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedule_info);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
ImageView drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
final DrawerLayout drawer;
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationView = (NavigationView) findViewById(R.id.schedule_info_navigation_view);
View headerView = navigationView.getHeaderView(0);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
TextView drawerCityName = (TextView) headerView.findViewById(R.id.tv_drawerheader_city_name);
drawerCitizenName.setText(citizenName);
drawerCityName.setText(citizenCity);
confirmationDialogFragment = new ConfirmationDialogFragment();
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, osb.getLong(Utils.ID, 0))){
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, osb.getLong(Utils.ID, 0))));
}
drawerHamburger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(Gravity.START);
}
});
navigationView.setCheckedItem(R.id.nav_check_schedules);
navigationView.setNavigationItemSelectedListener(this);
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
menuBuilder.setCallback(new MenuBuilder.Callback() {
@Override
public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
return onOptionsItemSelected(item);
}
@Override
public void onMenuModeChange(MenuBuilder menu) {
}
});
Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE);
if(bundle != null){
DateFormat df = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault());
String name = bundle.getString(Utils.NAME);
id = bundle.getLong(Utils.ID);
schedule = bundle.getParcelable(Utils.SCHEDULE);
TextView tv_name = (TextView) findViewById(R.id.tv_schedule_citizen_content);
TextView tv_sector = (TextView) findViewById(R.id.tv_schedule_sector_content);
TextView tv_location = (TextView) findViewById(R.id.tv_schedule_location_content);
TextView tv_type = (TextView) findViewById(R.id.tv_schedule_type_content);
TextView tv_date = (TextView) findViewById(R.id.tv_schedule_date_content);
TextView tv_address = (TextView) findViewById(R.id.tv_schedule_street_content);
tv_name.setText(name);
tv_sector.setText(schedule.getSectorName());
tv_location.setText(schedule.getLocationName());
tv_type.setText(schedule.getServiceTypeName());
tv_date.setText(df.format(schedule.getStartTime()));
String address = schedule.getAddressStreet() + ", " + schedule.getAddressNumber();
tv_address.setText(address);
}
Button bt_back = (Button) findViewById(R.id.btn_schedule_info_back);
bt_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
break;
case R.id.nav_schedule:
intent = new Intent(this, CitizenListActivity.class);
startActivity(intent);
break;
case R.id.nav_check_schedules:
break;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
startActivity(intent);
break;
default:
}
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menuBuilder);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.logout_actionbtn:
confirmationDialogFragment.show(getSupportFragmentManager(), EXIT_CONFIRMATION_DIALOG_TAG);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public static class ConfirmationDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.signout_confirmation)
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SchedulesActivity activity = (SchedulesActivity) getActivity();
// TODO: 05/10/17 fix here
//activity.presenter.onSignOutClicked();
}
})
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}
}
package br.ufpr.c3sl.agendador.agendador;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
// TODO: 27/09/17 Implement the behavior of this view
public class SchedulesHistoryActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
private NavigationView navigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedules_history);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv_schedules);
/*RecyclerView.LayoutManager layoutMngr = new LinearLayoutManager(this,
LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutMngr);
RecyclerView.Adapter adapter = new RecyclerView.Adapter() {
String datas[] = {"23/05/2017 - Dra. Júlia","13/07/2017 - Dr. Leonardo", "30/03/2017 - Dra. Júlia"};
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(getBaseContext())
.inflate(R.layout.item_schedules_list, parent, false);
return new ScheduleHolder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
ScheduleHolder scheduleHolder = (ScheduleHolder) holder;
String myHolder = datas[position];
scheduleHolder.date.setText(myHolder);
}
@Override
public int getItemCount() {
return datas.length;
}
};
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setAdapter(adapter);
//so that activity starts with default focus
recyclerView.setFocusable(false);
*/
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
MenuBuilder menuBuilder;
final DrawerLayout drawer;
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
menuBuilder.setCallback(new MenuBuilder.Callback() {
@Override
public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
return onOptionsItemSelected(item);
}
@Override
public void onMenuModeChange(MenuBuilder menu) {
}
});
ImageView drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
navigationView = (NavigationView) findViewById(R.id.home_navigation_view);
View headerView = navigationView.getHeaderView(0);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserImgHelper userImgHelper = new UserImgHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
TextView drawerCityName = (TextView) headerView.findViewById(R.id.tv_drawerheader_city_name);
drawerCitizenName.setText(citizenName);
drawerCityName.setText(citizenCity);
if(userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, osb.getLong(Utils.ID, 0))){
drawerProfilePicture.setImageBitmap(userImgHelper.getRoundBitmap(userImgHelper.getFileUri(Utils.USR_PICT_FILE_NAME, osb.getLong(Utils.ID, 0))));
}
drawerHamburger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(Gravity.START);
}
});
navigationView.setCheckedItem(R.id.nav_check_schedules);
navigationView.setNavigationItemSelectedListener(this);
}
private void updateSpinners(){
// TODO: 25/09/2017 keep spinners state, when one is changed, update the others.
}
@Override
protected void onResume() {
super.onResume();
navigationView.setCheckedItem(R.id.nav_schedules_history);
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
startActivity(intent);
return true;
case R.id.nav_schedule:
intent = new Intent(this, CitizenListActivity.class);
startActivity(intent);
return true;
case R.id.nav_check_schedules:
return true;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
startActivity(intent);
return true;
case R.id.nav_schedules_history:
break;
default:
}
return false;
}
}
......@@ -56,7 +56,6 @@ 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.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SchedulingView;
......@@ -138,9 +137,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array";
private long id;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -197,7 +193,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);
long id = osb.getLong("id", 0);
NavigationView navigationView = (NavigationView) findViewById(R.id.scheduling_navigation_view);
navigationView.getMenu().findItem(R.id.nav_schedule).setChecked(true);
......@@ -375,10 +371,19 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
intent = new Intent(this, TermActivity.class);
item.setChecked(false);
startActivity(intent);
break;
case R.id.nav_check_schedules:
intent = new Intent(this, SchedulesActivity.class);
startActivity(intent);
return true;
break;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
startActivity(intent);
break;
default:
break;
}
......@@ -462,6 +467,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
// TODO: 02/10/17 Click on a date without schedules clean the selection
if( (spnr_location.getSelectedItemPosition() != spnr_location.getCount())
&& selected
&& listOfScheduleDays.get(spnr_location.getSelectedItemPosition()).containsKey(dateFormat.format(date.getDate()))) {
......@@ -494,7 +500,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_connection_error_message));
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
......@@ -529,7 +535,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
spnr_type.setSelection(hintAdapterType.getCount());
}
public void setServiceLocationList(List<ServiceLocation> serviceLocations){
int i;
int max = 0;
......@@ -684,6 +689,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
}
}
@Override
public void showConflictDialog(){
if(connectionErrorDialog == null){
......
......@@ -29,7 +29,7 @@ import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
* Created by Lucas B. Cunha on 31/03/17.
*/
public class Utils {
public abstract class Utils {
public final static String SERVICE_UPDATE_IMAGE = "br.c3sl.ufpr.image_update";
......@@ -95,6 +95,7 @@ public class Utils {
public static final String PHONE_MASK = "(##)#####-####";
public static final String CPF_MASK = "###.###.###-##";
public static final String BIRTH_DAY_MASK = "##/##/####";
public static final String SCHEDULE = "schedule";
public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources();
......
package br.ufpr.c3sl.agendador.agendador.helpers.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import br.ufpr.c3sl.agendador.agendador.R;
/**
* Created by lbc16 on 26/09/17.
*/
public class ScheduleHolder extends RecyclerView.ViewHolder {
public TextView date;
TextView type;
TextView location;
public ScheduleHolder(View itemView) {
super(itemView);
date = (TextView) itemView.findViewById(R.id.list_schedule_date);
type = (TextView) itemView.findViewById(R.id.list_schedule_type);
location = (TextView) itemView.findViewById(R.id.list_schedule_location);
}
}
package br.ufpr.c3sl.agendador.agendador.helpers.decorators;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.models.CheckSchedules;
/**
* Created by lbc16 on 02/10/17.
*/
public class CheckSchedulesDecorator implements DayViewDecorator {
private Drawable background;
private DateFormat dateFormat;
private HashMap<String,ArrayList<CheckSchedules.Schedule>> hashMap;
public CheckSchedulesDecorator(HashMap<String,ArrayList<CheckSchedules.Schedule>> hashMap, Context context) {
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
this.hashMap = hashMap;
this.background = ContextCompat.getDrawable(context, R.drawable.date_highlight);
}
/**
* Determine if a specific day should be decorated
*
* @param day {@linkplain CalendarDay} to possibly decorate
* @return true if this decorator should be applied to the provided day
*/
@Override
public boolean shouldDecorate(CalendarDay day) {
return hashMap.containsKey(dateFormat.format(day.getDate()));
}
/**
* Set decoration options onto a facade to be applied to all relevant days