Commit 338c2033 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Merge branch 'list_schedules' into 'develop'

Listar Agendamentos futuros & histórico

See merge request !17
parents a34c10d8 01171135
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "br.ufpr.c3sl.agendador.agendador"
minSdkVersion 19
......@@ -28,14 +28,13 @@ dependencies {
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.google.code.gson:gson:2.8.0'
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.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'
}
......@@ -48,17 +48,16 @@
</service>
<activity android:name=".TermActivity" />
<activity
android:name=".SchedulingActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity android:name=".SchedulingActivity"/>
<activity android:name=".CitizenListActivity" />
<activity android:name=".SchedulesActivity" />
<activity android:name=".ScheduleConfirmationActivity" />
<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
......@@ -116,21 +116,6 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
presenter = new AccountPresenter(this);
}
/*TODO: Check performance of acvitity
if (DEVELOPER_MODE == 1) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
}*/
setContentView(R.layout.activity_account_view);
......
......@@ -162,6 +162,13 @@ public class CitizenListActivity extends AppCompatActivity implements CitizenVie
return builder.create();
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
getActivity().onBackPressed();
}
}
......
......@@ -397,7 +397,8 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
view.clearFocus();
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
if(imm != null)
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
......
......@@ -28,7 +28,6 @@ import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
......@@ -132,9 +131,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.bt_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 +141,32 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
}
});
Button bt_history = (Button) findViewById(R.id.bt_homeact_history);
bt_history.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, SchedulesHistoryActivity.class);
startActivity(intent);
}
});
Button bt_checkSchedules = (Button) findViewById(R.id.bt_homeact_check);
bt_checkSchedules.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this, SchedulesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
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);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
});
changeTextColor();
......@@ -228,18 +248,27 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
switch (item.getItemId()) {
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedule:
intent = new Intent(this, CitizenListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
return true;
case R.id.nav_check_schedules:
intent = new Intent(this, SchedulesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
return true;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
default:
......
......@@ -212,11 +212,27 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
switch (item.getItemId()) {
case R.id.nav_my_info:
intent = new Intent(this, AccountActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedule:
//do nothing.
break;
case R.id.nav_check_schedules:
intent = new Intent(this, SchedulesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedules_history:
intent = new Intent(this, SchedulesHistoryActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
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 org.w3c.dom.Text;
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";
private int caller;
@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);
}
});
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);
TextView tv_situation = (TextView) findViewById(R.id.tv_schedule_situation);
TextView tv_situation_content = (TextView) findViewById(R.id.tv_schedule_situation_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);
caller = bundle.getInt(Utils.CALLER_ACTIVITY);
if(caller == Utils.SCHEDULES_ACTIVITY){
navigationView.setCheckedItem(R.id.nav_check_schedules);
tv_situation.setVisibility(View.GONE);
tv_situation_content.setVisibility(View.GONE);
}else if(caller == Utils.HISTORY_ACTIVITY){
navigationView.setCheckedItem(R.id.nav_schedules_history);
tv_situation_content.setText(schedule.getSituation());
}
}
navigationView.setNavigationItemSelectedListener(this);
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);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedule:
intent = new Intent(this, CitizenListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_check_schedules:
if(caller != Utils.SCHEDULES_ACTIVITY){
intent = new Intent(this, SchedulesActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
break;
case R.id.nav_dependants:
intent = new Intent(this, DependentsListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
break;
case R.id.nav_schedules_history:
if(caller != Utils.HISTORY_ACTIVITY) {
intent = new Intent(this, SchedulesHistoryActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
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.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.RecyclerView;
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.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import com.prolificinteractive.materialcalendarview.OnDateSelectedListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
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.helpers.decorators.CheckSchedulesDecorator;
import br.ufpr.c3sl.agendador.agendador.models.CheckSchedules;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulesPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SchedulesView;
public class SchedulesActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
public class SchedulesActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, OnDateSelectedListener, SchedulesView {
private SchedulesPresenter presenter;
private ProgressBar pb_schedules;
private NavigationView navigationView;
private TextView tv_year, tv_day_month;
private MaterialCalendarView mcv;
private String[] months_short;
private String[] days_short;
private ConnectionErrorDialog connectionErrorDialog;
private ConfirmationDialogFragment confirmationDialogFragment;
private CheckSchedulesDecorator checkSchedulesDecorator;
private HashMap<String,ArrayList<CheckSchedules.Schedule>> hashSchedulesDays;
private List<CheckSchedules.Schedule> selectedSchedulesDay;
private CheckSchedules.Schedule selectedSchedule;
private CheckSchedules schedules;
private Date maxDate;
private DateFormat dateFormat, hourFormat;
private CalendarDay selectedDate;
private MenuBuilder menuBuilder;
private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array";
private static final String SCHEDULE_TIME_DIALOG_TAG = "schedule_dialog";
private static final String EXIT_CONFIRMATION_DIALOG_TAG = "exit_dialog";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedules);
//fazer parecido com o agendador antigo e colocar uma string que diz quantos dias faltam
//arrumar os spinners pra terem duas coisas - ????
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv_schedules);
if (savedInstanceState == null) {
presenter = new SchedulesPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new SchedulesPresenter(this);
}
setContentView(R.layout.activity_schedules);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
setSupportActionBar(toolbar);
......@@ -45,28 +114,16 @@ public class SchedulesActivity extends AppCompatActivity implements NavigationVi
String citizenCity = osb.getString("city.name", null);