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

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,6 +397,7 @@ public class DependentUpdateActivity extends AppCompatActivity implements Depend
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
view.clearFocus();
if(imm != null)
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
......
......@@ -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();
}
}
}
......@@ -21,7 +21,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
......@@ -29,7 +32,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 +98,16 @@ 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 final String DATE_FORMAT = "MM/dd/yyyy HH:mm";
public static final String CALLER_ACTIVITY = "from_activity";
public static final int HISTORY_ACTIVITY = 1;
public static final int SCHEDULES_ACTIVITY = 0;
public static final String REQUEST_FILTER_SECTOR = "q[sector_id]";
public static final String REQUEST_FILTER_TYPE = "q[service_type_id]";
public static final String REQUEST_FILTER_PLACE = "q[service_place_id]";
public static final String REQUEST_FILTER_SITUATION = "q[situation_id]";
public static final String SIZE_LARGE = "large";
public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources();
......@@ -163,4 +176,5 @@ public class Utils {
}
}
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.adapters;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CheckSchedules;
/**
* Created by Lucas B. Cunha on 16/10/17.
* Based on https://www.journaldev.com/12478/android-searchview-example-tutorial
*/
public class SchedulesExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
private List<Pair<String, Long>> expandableListTitle;
private HashMap<String, List<CheckSchedules.Schedule>> expandableListDetail;
private DateFormat dateFormat;
public SchedulesExpandableListAdapter(Context context, List<Pair<String, Long>> expandableListTitle,
HashMap<String, List<CheckSchedules.Schedule>> expandableListDetail) {
this.context = context;
this.expandableListTitle = expandableListTitle;
this.expandableListDetail = expandableListDetail;
dateFormat = new SimpleDateFormat(Utils.DATE_FORMAT, Locale.getDefault());
}
@Override
public Object getChild(int listPosition, int expandedListPosition) {
return this.expandableListDetail.get(this.expandableListTitle.get(listPosition).first)
.get(expandedListPosition);
}
@Override
public long getChildId(int listPosition, int expandedListPosition) {
return this.expandableListDetail.get(this.expandableListTitle.get(listPosition).first)
.get(expandedListPosition).getId();
}
@Override
public View getChildView(int listPosition, final int expandedListPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final CheckSchedules.Schedule schedule = (CheckSchedules.Schedule) getChild(listPosition, expandedListPosition);
final String type = schedule.getServiceTypeName();
final String date = dateFormat.format(schedule.getStartTime());
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.expandable_list_item, null);
}
TextView expandedListTextViewDate = (TextView) convertView
.findViewById(R.id.expandedListItem_date_content);
TextView expandedListTextViewType = (TextView) convertView.findViewById(R.id.expandedListItem_type_content);
expandedListTextViewType.setText(type);
expandedListTextViewDate.setText(date);
return convertView;
}
@Override
public int getChildrenCount(int listPosition) {
return this.expandableListDetail.get(this.expandableListTitle.get(listPosition).first)
.size();
}
@Override
public Object getGroup(int listPosition) {
return this.expandableListTitle.get(listPosition).first;
}
@Override
public int getGroupCount() {
return this.expandableListTitle.size();
}
@Override
public long getGroupId(int listPosition) {
return expandableListTitle.get(listPosition).second;
}
@Override
public View getGroupView(int listPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String listTitle = (String) getGroup(listPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.expandable_list_group, null);
}
TextView listTitleTextView = (TextView) convertView
.findViewById(R.id.listTitle);
listTitleTextView.setText(listTitle);
if(expandableListDetail.get(listTitle).size() > 0){
listTitleTextView.setTypeface(null, Typeface.BOLD);
}
return convertView;
}
@Override