Commit 3b03eaec authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Issue AGILE#198 [WIP] Layout and simple behavior completed


Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent d9ffa6a6
......@@ -394,9 +394,10 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
else
imv_profile.setImageBitmap(null);
} else {
Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
/*Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
startActivity(intent);*/
super.onBackPressed();
finish();
}
}
......
......@@ -37,6 +37,7 @@ 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;
......@@ -52,21 +53,13 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
public class HomeActivity extends AppCompatActivity implements HomeView,
NavigationView.OnNavigationItemSelectedListener {
private HomePresenter presenter;
private ObscuredSharedPreferences osb;
private MenuBuilder menuBuilder;
private ActionMenuView actionMenuView;
private ImageView drawerHamburger, drawerProfilePicture;
private DrawerLayout drawer;
private NavigationView navigationView;
private TextView drawerCitizenName, drawerCityName, homeCitizenWelcome, tv_presentation;
private UserPhotoHelper userPhotoHelper;
private TextView tv_presentation;
private ConfirmationDialog confirmationDialog;
private Button btn_schedule;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -82,11 +75,11 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
toolbar.setTitle(null);
setSupportActionBar(toolbar);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
menuBuilder.setCallback(new Callback() {
......@@ -103,8 +96,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
confirmationDialog = new ConfirmationDialog();
drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
homeCitizenWelcome = (TextView) findViewById(R.id.tv_homeact_welcome);
ImageView drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
TextView homeCitizenWelcome = (TextView) findViewById(R.id.tv_homeact_welcome);
homeCitizenWelcome.setText(String.format(getString(R.string.welcome), citizenName));
tv_presentation = (TextView) findViewById(R.id.tv_homeact_moreinfo);
......@@ -114,13 +107,13 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
View headerView = navigationView.getHeaderView(0);
drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
userPhotoHelper = new UserPhotoHelper(getBaseContext());
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext());
drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
drawerCityName = (TextView) headerView.findViewById(R.id.tv_drawerheader_city_name);
TextView drawerCityName = (TextView) headerView.findViewById(R.id.tv_drawerheader_city_name);
drawerCitizenName.setText(citizenName);
drawerCityName.setText(citizenCity);
......@@ -133,14 +126,14 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
drawerHamburger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(Gravity.LEFT);
drawer.openDrawer(Gravity.START);
}
});
navigationView.setNavigationItemSelectedListener(this);
btn_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
Button btn_schedule = (Button) findViewById(R.id.btn_homeact_schedule);
btn_schedule.setOnClickListener(new View.OnClickListener() {
@Override
......
package br.ufpr.c3sl.agendador.agendador;
import android.support.v7.app.AppCompatActivity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
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.view.GravityCompat;
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.ProgressBar;
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.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.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.ScheduleConfirmationPresenter;
import br.ufpr.c3sl.agendador.agendador.views.ScheduleConfirmationView;
/**
* Created by Lucas B. Cunha on 25/07/17.
*/
public class ScheduleConfirmationActivity extends AppCompatActivity implements ScheduleConfirmationView{
public class ScheduleConfirmationActivity extends AppCompatActivity implements ScheduleConfirmationView, NavigationView.OnNavigationItemSelectedListener{
private ScheduleConfirmationPresenter scheduleConfirmationPresenter;
private ConfirmationDialog confirmationDialog;
private DrawerLayout drawer;
private MenuBuilder menuBuilder;
private ConnectionErrorDialog connectionErrorDialog;
private ProgressBar pb_scheduleConfirmation;
private Button bt_schedule, bt_back;
private static final String EXIT_CONFIRMATION_DIALOG_TAG = "exit_dialog";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState == null){
scheduleConfirmationPresenter = new ScheduleConfirmationPresenter(getBaseContext());
}else{
scheduleConfirmationPresenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
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);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
toolbar.setTitle(null);
setSupportActionBar(toolbar);
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
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) {
}
});
confirmationDialog = new ConfirmationDialog();
ImageView drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.schedule_confirmation_navigation_view);
View headerView = navigationView.getHeaderView(0);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(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(userPhotoHelper.existsPhoto()){
userPhotoHelper.updateImgView(drawerProfilePicture, userPhotoHelper.getPhotoFileUri());
}
drawerHamburger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(Gravity.START);
}
});
navigationView.setNavigationItemSelectedListener(this);
pb_scheduleConfirmation = (ProgressBar) findViewById(R.id.pb_schedule_confirmation);
TextView tv_citizen = (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_schedule = (TextView) findViewById(R.id.tv_schedule_date_content);
tv_sector.setText(sector.getName());
tv_citizen.setText(citizen.getName());
tv_location.setText(location.getmName());
tv_type.setText(type.getmDescription());
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault());
tv_schedule.setText(dateFormat.format(schedule.getStart()));
bt_schedule = (Button) findViewById(R.id.btn_schedule_confirm);
bt_back = (Button) findViewById(R.id.btn_schedule_back);
bt_schedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
scheduleConfirmationPresenter.onScheduleClicked(schedule, citizen);
bt_schedule.setEnabled(false);
bt_back.setEnabled(false);
}
});
bt_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
@Override
protected void onResume() {
super.onResume();
scheduleConfirmationPresenter.bindView(this);
}
@Override
protected void onPause() {
super.onPause();
scheduleConfirmationPresenter.unbindView();
}
@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, TermActivity.class);
item.setChecked(false);
startActivity(intent);
default:
}
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.logout_actionbtn:
confirmationDialog.show(getFragmentManager(), EXIT_CONFIRMATION_DIALOG_TAG);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menuBuilder);
return true;
}
@Override
public void setNoConnection(boolean enabled){
if(enabled){
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
@Override
public void setProgressBar(boolean enabled) {
if (enabled) {
pb_scheduleConfirmation.setVisibility(View.VISIBLE);
} else {
pb_scheduleConfirmation.setVisibility(View.INVISIBLE);
bt_schedule.setEnabled(true);
bt_back.setEnabled(true);
}
}
public static class ConfirmationDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle 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) {
ScheduleConfirmationActivity activity = (ScheduleConfirmationActivity) getActivity();
activity.scheduleConfirmationPresenter.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();
}
}
}
......@@ -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;
......@@ -67,21 +68,13 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private MenuBuilder menuBuilder;
private ActionMenuView actionMenuView;
private ObscuredSharedPreferences osb;
private UserPhotoHelper userPhotoHelper;
private ImageView drawerProfilePicture;
private DrawerLayout drawer;
private ProgressBar pb_scheduling;
private Spinner spnr_sector, spnr_type, spnr_location;
private LinearLayout ll_fields;
private TextView tv_year, tv_day_month, tv_citizen;
private TextView tv_year, tv_day_month;
private Button btn_confirm;
......@@ -91,8 +84,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private ConfirmationDialogFragment confirmationDialogFragment;
private ScheduleTimeDialogFragment scheduleTimeDialogFragment;
private String[] months_short;
private String[] days_short;
......@@ -103,6 +94,10 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private List<SectorInput> sectors;
private List<ServiceLocation> serviceLocations;
private List<ServiceType> serviceTypes;
private ServiceTypeSpinnerListener serviceTypeSpinnerListener;
private LocationSpinnerListener locationSpinnerListener;
......@@ -169,7 +164,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
pb_scheduling = (ProgressBar) findViewById(R.id.pb_scheduling);
actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
ActionMenuView actionMenuView = (ActionMenuView) toolbar.findViewById(R.id.agendador_toolbar_menu);
menuBuilder = (MenuBuilder) actionMenuView.getMenu();
//noinspection RestrictedApi
menuBuilder.setCallback(new MenuBuilder.Callback() {
......@@ -183,9 +178,9 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
}
});
ll_fields = (LinearLayout) findViewById(R.id.ll_scheduling_fields);
LinearLayout ll_fields = (LinearLayout) findViewById(R.id.ll_scheduling_fields);
tv_citizen = (TextView) findViewById(R.id.tv_scheduling_citizen);
TextView tv_citizen = (TextView) findViewById(R.id.tv_scheduling_citizen);
tv_citizen.setText(getResources().getString(R.string.scheduling_citizen) + " " + citizen.getName());
......@@ -197,17 +192,17 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
days_short = getResources().getStringArray(R.array.days_pt);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
ObscuredSharedPreferences osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
final String citizenCity = osb.getString("city.name", null);
NavigationView navigationView = (NavigationView) findViewById(R.id.home_navigation_view);
NavigationView navigationView = (NavigationView) findViewById(R.id.scheduling_navigation_view);
View headerView = navigationView.getHeaderView(0);
drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
ImageView drawerProfilePicture = (ImageView) headerView.findViewById(R.id.img_drawerheader_citizen_photo);
userPhotoHelper = new UserPhotoHelper(getBaseContext());
UserPhotoHelper userPhotoHelper = new UserPhotoHelper(getBaseContext());
TextView drawerCitizenName = (TextView) headerView.findViewById(R.id.tv_drawerheader_citizen_name);
......@@ -217,14 +212,14 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
drawerCityName.setText(citizenCity);
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ImageView drawerHamburger = (ImageView) toolbar.findViewById(R.id.img_toolbar_hamburger);
drawerHamburger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawer.openDrawer(Gravity.LEFT);
drawer.openDrawer(Gravity.START);
}
});
......@@ -261,7 +256,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
spnr_type.setAdapter(hintAdapterType);
spnr_type.setSelection(hintAdapterType.getCount());
String[] locations = {"", getResources().getString(R.string.scheduling_location_hint)};
final String[] locations = {"", getResources().getString(R.string.scheduling_location_hint)};
boolean[] enableView = new boolean[2];
enableView[0] = false;
enableView[1] = true;
......@@ -322,9 +317,13 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
@Override
public void onClick(View v) {
Intent intent = new Intent(SchedulingActivity.this, ScheduleConfirmationActivity.class);
//Bundle bundle = getIntent().getBundleExtra(Utils.SECTORS_BUNDLE);
//bundle.putParcelable(Utils.CITIZEN, citizens.get(position));
//intent.putExtra(Utils.SECTORS_CITIZENS_BUNDLE, bundle);
Bundle bundle = new Bundle();
bundle.putParcelable(Utils.CITIZEN, citizen);
bundle.putParcelable(Utils.SECTOR, sectors.get(spnr_sector.getSelectedItemPosition()));
bundle.putParcelable(Utils.LOCATION, serviceLocations.get(spnr_location.getSelectedItemPosition()));
bundle.putParcelable(Utils.TYPE, serviceTypes.get(spnr_type.getSelectedItemPosition()));
bundle.putParcelable(Utils.SCHEDULE, selectedSchedule);
intent.putExtra(Utils.SCHEDULE_BUNDLE, bundle);
startActivity(intent);
}
});
......@@ -343,11 +342,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
schedulingPresenter.unbindView();
}
@Override
protected void onStart(){
super.onStart();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
......@@ -436,7 +430,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
......@@ -465,7 +459,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
schedules[i] = hourFormat.format(schedulesList.get(i).getStart());
}
bundle.putStringArray(SCHEDULES_TIME_ARRAY, schedules);
scheduleTimeDialogFragment = new ScheduleTimeDialogFragment();
ScheduleTimeDialogFragment scheduleTimeDialogFragment = new ScheduleTimeDialogFragment();
scheduleTimeDialogFragment.setArguments(bundle);
scheduleTimeDialogFragment.show(getSupportFragmentManager(), SCHEDULE_TIME_DIALOG_TAG);
selectedDate = date;
......@@ -500,7 +494,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
locationSpinnerListener.setUserSelect(false);
serviceTypeSpinnerListener.setUserSelect(false);