diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c332c51..143d751 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,12 +19,18 @@ - + + - - - - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/model/Event.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/model/Event.java index 7d0265b..84adff0 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/model/Event.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/model/Event.java @@ -7,12 +7,7 @@ import java.util.HashMap; import java.util.Map; -/** - * Created by wilpiron on 28/02/2017. - */ - public class Event { - public String id; public String name; public String start; @@ -35,8 +30,8 @@ public class Event { public Event(){ } - public Event(String uid, String name, String start, String end, String type, String association, - String description, String location, float price, int bail, int seat_number, int logo){ + public Event(String uid,String name, String start, String end, String type, String description, String location, + float price, int bail, int seat_number, String association, int logo){ this.uid=uid; this.name=name; this.start=start; diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/AgendaActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/AgendaActivity.java deleted file mode 100644 index 052a97e..0000000 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/AgendaActivity.java +++ /dev/null @@ -1,27 +0,0 @@ -package fr.paris10.projet.assogenda.assogenda.ui.activites; - -import android.content.Intent; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import fr.paris10.projet.assogenda.assogenda.R; - -public class AgendaActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_agenda); - - Button agendaButton = (Button) findViewById(R.id.activity_agenda_generate_button); - agendaButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(view.getContext(), AgendaGeneratorActivity.class); - startActivity(intent); - } - }); - } -} diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/CreateEventActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/CreateEventActivity.java index 263fac0..26574a0 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/CreateEventActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/CreateEventActivity.java @@ -1,3 +1,4 @@ + package fr.paris10.projet.assogenda.assogenda.ui.activites; import android.app.AlertDialog; @@ -38,6 +39,7 @@ public class CreateEventActivity extends AppCompatActivity { protected EditText eventLocationEditText; protected EditText eventSeatsAvailableEditText; protected EditText eventPriceEditText; + protected Button eventAdvancedButton; protected DatabaseReference database = FirebaseDatabase.getInstance().getReference("events"); @@ -45,6 +47,8 @@ public class CreateEventActivity extends AppCompatActivity { protected DatabaseReference dbAssoc = FirebaseDatabase.getInstance().getReference("associations"); protected String eventAsso; + protected Calendar c; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -52,7 +56,8 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_create_event); eventAsso = getIntent().getStringExtra("assoID"); - + //Initialization + c = Calendar.getInstance(); eventNameEditText = (EditText) findViewById(R.id.activity_create_event_name); eventStartTimeEditText = (EditText) findViewById(R.id.activity_create_event_start_time); eventStartDateEditText = (EditText) findViewById(R.id.activity_create_event_start_date); @@ -64,6 +69,20 @@ protected void onCreate(Bundle savedInstanceState) { eventLocationEditText = (EditText) findViewById(R.id.activity_create_event_location); eventSeatsAvailableEditText = (EditText) findViewById(R.id.activity_create_event_seats_available); eventPriceEditText = (EditText) findViewById(R.id.activity_create_event_price); + eventAdvancedButton = (Button) findViewById(R.id.activity_create_event_advanced_button); + + //Hide advanced options + eventPriceEditText.setVisibility(View.GONE); + eventSeatsAvailableEditText.setVisibility(View.GONE); + eventDescriptionEditText.setVisibility(View.GONE); + + //Default value (date and time) + eventStartDateEditText.setText(new SimpleDateFormat("dd/MM/yyyy").format(c.getTime())); + eventStartTimeEditText.setText(new SimpleDateFormat("kk:mm").format(c.getTime())); + eventEndDateEditText.setText(new SimpleDateFormat("dd/MM/yyyy").format(c.getTime())); + c.setTime(c.getTime()); + c.add(Calendar.HOUR, 1); + eventEndTimeEditText.setText(new SimpleDateFormat("kk:mm").format(c.getTime())); //Sets the spinner's content ArrayAdapter tmpAdapterEventTypes = ArrayAdapter.createFromResource(this,R.array.event_create_event_types, android.R.layout.simple_spinner_item); @@ -98,6 +117,21 @@ public void onClick(View v) { } }); + eventAdvancedButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (eventPriceEditText.getVisibility() == View.GONE){ + eventPriceEditText.setVisibility(View.VISIBLE); + eventSeatsAvailableEditText.setVisibility(View.VISIBLE); + eventDescriptionEditText.setVisibility(View.VISIBLE); + } + else{ + eventPriceEditText.setVisibility(View.GONE); + eventSeatsAvailableEditText.setVisibility(View.GONE); + eventDescriptionEditText.setVisibility(View.GONE); + } + } + }); @@ -108,32 +142,30 @@ public void onClick(View v) { final String eventStart = eventDatesConverter(eventStartTimeEditText, eventStartDateEditText); final String eventEnd = eventDatesConverter(eventEndTimeEditText, eventEndDateEditText); final String eventType = eventTypeSpinner.getItemAtPosition(eventTypeSpinner.getSelectedItemPosition()).toString().trim(); - final String eventDescription = eventDescriptionEditText.getText().toString().trim(); + String eventDescription = eventDescriptionEditText.getText().toString().trim(); final String eventLocation = eventLocationEditText.getText().toString().trim(); - final String eventSeatsAvailable = eventSeatsAvailableEditText.getText().toString().trim(); - final String eventPrice = eventPriceEditText.getText().toString().trim(); + String eventSeatsAvailable = eventSeatsAvailableEditText.getText().toString().trim(); + String eventPrice = eventPriceEditText.getText().toString().trim(); final String eventAssociation = eventAsso; - if (eventName.isEmpty() || eventDescription.isEmpty() || eventStart == null || eventEnd == null - || eventType.isEmpty() || eventLocation.isEmpty() || eventSeatsAvailable.isEmpty() || eventPrice.isEmpty()) { - AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this); - builder.setMessage(R.string.event_create_submit_error_message) - .setTitle(R.string.event_create_submit_error_title) - .setPositiveButton(android.R.string.ok, null); - AlertDialog dialog = builder.create(); - dialog.show(); + //Checking value of optional fields + if (eventDescription.isEmpty()){ + eventDescription = ""; } - else if (Integer.parseInt(eventSeatsAvailable) < 5){ - AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this); - builder.setMessage(R.string.event_create_submit_seats_error_message) - .setTitle(R.string.event_create_submit_error_title) - .setPositiveButton(android.R.string.ok, null); - AlertDialog dialog = builder.create(); - dialog.show(); + //Value to -1 means there are no seats limit + if (eventSeatsAvailable.isEmpty()){ + eventSeatsAvailable = "-1"; + } + //Value to -1 means there are no price, it's free + if (eventPrice.isEmpty()){ + eventPrice = "-1.0"; } - else if(Float.parseFloat(eventPrice) < 0.0){ + + // NOTE : SEATS / PRICE / DESCRIPTION => OPTIONAL + + if (eventName.isEmpty() || eventStart == null || eventEnd == null || eventType.isEmpty() || eventLocation.isEmpty() ) { AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this); - builder.setMessage(R.string.event_create_submit_price_error_message) + builder.setMessage(R.string.event_create_submit_error_message) .setTitle(R.string.event_create_submit_error_title) .setPositiveButton(android.R.string.ok, null); AlertDialog dialog = builder.create(); @@ -151,7 +183,7 @@ else if (!firstDateAnteriorToSecond(eventStart, eventEnd)){ database.push() .setValue(new Event( "", eventName, eventStart, eventEnd, eventType, eventAssociation, eventLocation, Float.parseFloat(eventPrice), Integer.parseInt(eventSeatsAvailable), eventDescription) - .toMap()); + .toMap()); loadMain(); } } @@ -233,4 +265,4 @@ public void loadMain(){ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } -} +} \ No newline at end of file diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/EventInfosActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/EventInfosActivity.java index ca41706..2f83cdc 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/EventInfosActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/EventInfosActivity.java @@ -11,6 +11,8 @@ import android.widget.Toast; import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; @@ -24,16 +26,20 @@ import java.util.HashMap; import fr.paris10.projet.assogenda.assogenda.R; +import fr.paris10.projet.assogenda.assogenda.model.Association; import fr.paris10.projet.assogenda.assogenda.model.Event; -/** - * Event infos page, display event infos. - */ -public class EventInfosActivity extends AppCompatActivity { - private ArrayList> listValues = new ArrayList<>(); +public class EventInfosActivity extends AppCompatActivity { + private ListView listInfos; + private ArrayList> listValues = new ArrayList<>(); + private SimpleAdapter adapter; private String eventUID; + private Event event; private TextView nameEvent; + private TextView nameAsso; + private FirebaseAuth mFirebaseAuth; + private FirebaseUser mFirebaseUser; private String name; private Date eventEndDate; private TextView participateButton; @@ -41,12 +47,16 @@ public class EventInfosActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mFirebaseAuth = FirebaseAuth.getInstance(); + mFirebaseUser = mFirebaseAuth.getCurrentUser(); setContentView(R.layout.activity_event_infos); eventUID = (String) getIntent().getExtras().get("eventUID"); name = (String) getIntent().getExtras().get("eventName"); String eventEnd = (String) getIntent().getExtras().get("eventEndDate"); nameEvent = (TextView) findViewById(R.id.activity_event_infos_name_event); participateButton = (Button) findViewById(R.id.activity_event_infos_participate_button); + nameAsso = (TextView) findViewById(R.id.activity_event_infos_name_asso); + loadEventInfoInBackground(); try { @@ -139,53 +149,68 @@ public void loadEventInfoInBackground() { reference.child(eventUID).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { - Event event; - SimpleAdapter adapter; - ListView listInfos; - - event = dataSnapshot.getValue(Event.class); - event.uid = eventUID; - nameEvent.setText(event.name); - HashMap hashMapValueDateBegin = new HashMap<>(); - hashMapValueDateBegin.put("title_info", "Date de début : "); - hashMapValueDateBegin.put("content_info", event.start); - HashMap hashMapValueDateEnd = new HashMap<>(); - hashMapValueDateEnd.put("title_info", "Date de fin : "); - hashMapValueDateEnd.put("content_info", event.end); - HashMap hashMapValuePrice = new HashMap<>(); - hashMapValuePrice.put("title_info", "Prix : "); - hashMapValuePrice.put("content_info", event.price); - HashMap hashMapValueSpace = new HashMap<>(); - hashMapValueSpace.put("title_info", "Places disponible : "); - hashMapValueSpace.put("content_info", String.valueOf(dataSnapshot.child("seats free").getValue())); - HashMap hashMapValueBail = new HashMap<>(); - hashMapValueBail.put("title_info", "Caution : "); - hashMapValueBail.put("content_info", event.bail); - HashMap hashMapValuePlace = new HashMap<>(); - hashMapValuePlace.put("title_info", "Lieu : "); - hashMapValuePlace.put("content_info", event.location); - HashMap hashMapValueDescription = new HashMap<>(); - hashMapValueDescription.put("title_info", "Description : "); - hashMapValueDescription.put("content_info", event.description); - HashMap hashMapValueCategorie = new HashMap<>(); - hashMapValueCategorie.put("title_info", "Categorie : "); - hashMapValueCategorie.put("content_info", event.type); - - listValues.add(hashMapValueDateBegin); - listValues.add(hashMapValueDateEnd); - listValues.add(hashMapValuePrice); - listValues.add(hashMapValueSpace); - listValues.add(hashMapValueBail); - listValues.add(hashMapValuePlace); - listValues.add(hashMapValueDescription); - listValues.add(hashMapValueCategorie); - - String[] from = new String[]{"title_info", "content_info"}; - int[] to = new int[]{R.id.content_infos_event_title_info, R.id.content_infos_event_content_info}; - - listInfos = (ListView) findViewById(R.id.activity_event_infos_list); - adapter = new SimpleAdapter(EventInfosActivity.this, listValues, R.layout.content_infos_event, from, to); - listInfos.setAdapter(adapter); + if (dataSnapshot.exists()) { + event = dataSnapshot.getValue(Event.class); + event.uid=eventUID; + nameEvent.setText(event.name); + nameAsso.setText(" "); + DatabaseReference references = FirebaseDatabase.getInstance().getReference("association"); + references.child(event.association).addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataS) { + if (dataS.exists()) { + Association a = dataS.getValue(Association.class); + nameAsso.setText(a.name); + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + HashMap hashMapValueDateBegin = new HashMap<>(); + hashMapValueDateBegin.put("title_info","Date de début : "); + hashMapValueDateBegin.put("content_info",event.start); + HashMap hashMapValueDateEnd = new HashMap<>(); + hashMapValueDateEnd.put("title_info","Date de fin : "); + hashMapValueDateEnd.put("content_info",event.end); + HashMap hashMapValuePrice = new HashMap<>(); + hashMapValuePrice.put("title_info","Prix : "); + hashMapValuePrice.put("content_info",event.price+" €"); + HashMap hashMapValueSpace = new HashMap<>(); + hashMapValueSpace.put("title_info","Places disponible : "); + hashMapValueSpace.put("content_info",event.seat_free); + HashMap hashMapValueBail = new HashMap<>(); + hashMapValueBail.put("title_info","Caution : "); + hashMapValueBail.put("content_info",event.bail); + HashMap hashMapValuePlace = new HashMap<>(); + hashMapValuePlace.put("title_info","Lieu : "); + hashMapValuePlace.put("content_info",event.location); + HashMap hashMapValueDescription = new HashMap<>(); + hashMapValueDescription.put("title_info","Description : "); + hashMapValueDescription.put("content_info",event.description); + HashMap hashMapValueCategorie = new HashMap<>(); + hashMapValueCategorie.put("title_info","Categorie : "); + hashMapValueCategorie.put("content_info",event.type); + + listValues.add(hashMapValueDateBegin); + listValues.add(hashMapValueDateEnd); + listValues.add(hashMapValuePrice); + listValues.add(hashMapValueSpace); + listValues.add(hashMapValueBail); + listValues.add(hashMapValuePlace); + listValues.add(hashMapValueDescription); + listValues.add(hashMapValueCategorie); + + String[] from = new String[] {"title_info","content_info"}; + int[] to = new int[] {R.id.content_infos_event_title_info,R.id.content_infos_event_content_info}; + + listInfos = (ListView) findViewById(R.id.activity_event_infos_list); + adapter = new SimpleAdapter(EventInfosActivity.this,listValues,R.layout.content_infos_event,from,to); + listInfos.setAdapter(adapter); + } + updateParticipate(); } diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListAssociationActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListAssociationActivity.java index aca1674..ee925a8 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListAssociationActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListAssociationActivity.java @@ -53,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { loadAllAssociations(); searchView = (SearchView) findViewById(R.id.list_association_activity_search); + searchView.setQueryHint(getString(R.string.list_association_activity_search_hint)); loadSearchListener(); } diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListEventsActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListEventsActivity.java index 497a74e..8611c01 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListEventsActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ListEventsActivity.java @@ -25,6 +25,7 @@ import java.util.List; import fr.paris10.projet.assogenda.assogenda.R; +import fr.paris10.projet.assogenda.assogenda.model.Association; import fr.paris10.projet.assogenda.assogenda.model.Event; public class ListEventsActivity extends AppCompatActivity { @@ -33,6 +34,7 @@ public class ListEventsActivity extends AppCompatActivity { private SimpleAdapter adapter; private List listeEvenements = new ArrayList<>(); private List listEventSort = new ArrayList<>(); + private HashMap listAssociation= new HashMap<>(); @Override protected void onCreate(Bundle savedInstanceState) { @@ -92,6 +94,26 @@ public Boolean compareDate(String event1, String event2) { } public void loadEventInBackground() { + DatabaseReference references = FirebaseDatabase.getInstance().getReference("association"); + references.addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataS) { + if (dataS.exists()) { + for (DataSnapshot e : dataS.getChildren()) { + Association a = e.getValue(Association.class); + a.id = e.getKey(); + if (listAssociation.get(a.id) == null) + listAssociation.put(a.id, a.name); + } + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("events"); reference.addListenerForSingleValueEvent(new ValueEventListener() { @Override @@ -99,6 +121,7 @@ public void onDataChange(DataSnapshot dataSnapshot) { int tailleList; int nbEvent; int eventRestant; + if (dataSnapshot.exists()) { for (DataSnapshot e : dataSnapshot.getChildren()) { Event event = e.getValue(Event.class); @@ -124,13 +147,12 @@ public void onDataChange(DataSnapshot dataSnapshot) { } } + + for (Event event : listEventSort) { HashMap hashMapValuesEvent = new HashMap<>(); hashMapValuesEvent.put("nameEvent", event.name); - if (event.association == null) - hashMapValuesEvent.put("association", "Nom asso"); - else - hashMapValuesEvent.put("association", event.association); + hashMapValuesEvent.put("association", listAssociation.get(event.association)); hashMapValuesEvent.put("dateEventBegin", event.start); hashMapValuesEvent.put("dateEventEnd", event.end); hashMapValuesEvent.put("locationEvent", event.location); diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainActivity.java index f6873e5..f8f1699 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainActivity.java @@ -35,10 +35,28 @@ protected void onCreate(Bundle savedInstanceState) { } else { + Button associationBtn = (Button) findViewById(R.id.activity_main_association_btn); + associationBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), MainAssociationActivity.class); + startActivity(intent); + } + }); + Button eventBtn = (Button) findViewById(R.id.activity_main_events_btn); + eventBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), MainEventActivity.class); + startActivity(intent); + } + }); + + //Sets isAssoMember to true or false - userIsAnAssociationMember(); + //userIsAnAssociationMember(); - Button logoutButton = (Button) findViewById(R.id.activity_main_logout_button); + /*Button logoutButton = (Button) findViewById(R.id.activity_main_logout_button); logoutButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -60,7 +78,7 @@ public void onClick(View view) { agendaButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(view.getContext(), AgendaActivity.class); + Intent intent = new Intent(view.getContext(), AgendaGeneratorActivity.class); startActivity(intent); } }); @@ -101,7 +119,7 @@ public void onClick(View v) { intent.putExtra("followed", true); startActivity(intent); } - }); + });*/ } @@ -114,9 +132,6 @@ protected void onStart() { @Override public void onResume(){ - /*Intent intent = new Intent(this, MainActivity.class); - finish(); - startActivity(intent);*/ super.onResume(); } @@ -138,30 +153,4 @@ protected void loggedOut() { finish(); startActivity(getIntent()); } - - protected void loadCreateEventView(){ - Intent intent = new Intent(this, CreateEventActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - startActivity(intent); - } - - //Updates isAssoMember variable according to association appatenance of the current user - protected void userIsAnAssociationMember(){ - isAssoMember = false; - - database.child(daoUser.getCurrentUserId()).child("isAssoMember").addValueEventListener(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot dataSnapshot) { - if (dataSnapshot.exists()){ - isAssoMember = dataSnapshot.getValue(Boolean.class); - } - } - - @Override - public void onCancelled(DatabaseError databaseError) { - - } - }); - } } diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainAssociationActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainAssociationActivity.java new file mode 100644 index 0000000..8a88e42 --- /dev/null +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainAssociationActivity.java @@ -0,0 +1,95 @@ +package fr.paris10.projet.assogenda.assogenda.ui.activites; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; + +import fr.paris10.projet.assogenda.assogenda.R; +import fr.paris10.projet.assogenda.assogenda.daos.DAOUser; + +public class MainAssociationActivity extends AppCompatActivity { + protected Boolean isAssoMember; + protected DatabaseReference database = FirebaseDatabase.getInstance().getReference("users"); + private DAOUser daoUser; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main_association); + + this.daoUser = DAOUser.getInstance(); + + if(!daoUser.isLoggedIn()){ + redirectIfNotLoggedIn(); + } + userIsAnAssociationMember(); + + Button associationButton = (Button) findViewById(R.id.activity_main_button_association); + associationButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), AssociationDashboardActivity.class); + startActivity(intent); + } + }); + + Button listAssociationsButton = (Button) findViewById(R.id.main_activity_list_asso_button); + listAssociationsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(v.getContext(), ListAssociationActivity.class); + intent.putExtra("followed", false); + startActivity(intent); + } + }); + + Button followedAssoButton = (Button) findViewById(R.id.main_activity_followed_asso_button); + followedAssoButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(v.getContext(), ListAssociationActivity.class); + intent.putExtra("followed", true); + startActivity(intent); + } + }); + } + + //Updates isAssoMember variable according to association appatenance of the current user + protected void userIsAnAssociationMember(){ + isAssoMember = false; + + database.child(daoUser.getCurrentUserId()).child("isAssoMember").addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + if (dataSnapshot.exists()){ + isAssoMember = dataSnapshot.getValue(Boolean.class); + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + } + + protected void loadLogInView() { + Intent intent = new Intent(this, LoginActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + } + + protected void redirectIfNotLoggedIn() { + if (!daoUser.isLoggedIn()) + loadLogInView(); + } +} diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainEventActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainEventActivity.java new file mode 100644 index 0000000..8c7ed16 --- /dev/null +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainEventActivity.java @@ -0,0 +1,45 @@ +package fr.paris10.projet.assogenda.assogenda.ui.activites; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import fr.paris10.projet.assogenda.assogenda.R; + +public class MainEventActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main_event); + + Button agendaButton = (Button) findViewById(R.id.activity_main_calendar_button); + agendaButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), AgendaGeneratorActivity.class); + startActivity(intent); + } + }); + + Button listEventButton = (Button) findViewById(R.id.main_list_events_button); + listEventButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(v.getContext(), ListEventsActivity.class); + startActivity(intent); + } + }); + + Button searchEventButton = (Button) findViewById(R.id.activity_main_event_research_button); + searchEventButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(view.getContext(), EventResearchActivity.class); + startActivity(intent); + } + }); + } +} diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ShowAssociationActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ShowAssociationActivity.java new file mode 100644 index 0000000..edc0da9 --- /dev/null +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/ShowAssociationActivity.java @@ -0,0 +1,87 @@ +package fr.paris10.projet.assogenda.assogenda.ui.activites; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; + +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; +import com.google.firebase.database.ValueEventListener; + + +import fr.paris10.projet.assogenda.assogenda.R; +import fr.paris10.projet.assogenda.assogenda.model.Association; +import fr.paris10.projet.assogenda.assogenda.model.User; + +public class ShowAssociationActivity extends AppCompatActivity { + private String associationID; + private Association association; + private User president; + private TextView nameAsso; + private TextView descAsso; + private Button createEvent; + private ImageView image; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_show_association); + + image = (ImageView) findViewById(R.id.activity_show_association_logo_asso); + image.setImageResource(R.drawable.association_default_icon); + nameAsso = (TextView) findViewById(R.id.activity_show_association_name_asso); + descAsso = (TextView) findViewById(R.id.activity_show_association_description_asso); + createEvent = (Button) findViewById(R.id.activity_show_association_create_event); + associationID = (String) getIntent().getExtras().get("associationID"); + DatabaseReference reference = FirebaseDatabase.getInstance().getReference("association"); + reference.child(associationID).addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + if (dataSnapshot.exists()) { + association = dataSnapshot.getValue(Association.class); + nameAsso.setText(association.name); + descAsso.setText(association.description); + DatabaseReference references = FirebaseDatabase.getInstance().getReference("users"); + references.child(association.president).addListenerForSingleValueEvent(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + if (dataSnapshot.exists()) { + president = dataSnapshot.getValue(User.class); + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + } + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + + createEvent.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(getApplicationContext(), CreateEventActivity.class); + intent.putExtra("assoID", associationID); + startActivity(intent); + } + }); + + + + + + } +} diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/SignUpActivity.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/SignUpActivity.java index e8a8597..31124be 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/SignUpActivity.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/activites/SignUpActivity.java @@ -8,6 +8,7 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; @@ -82,6 +83,7 @@ public void onComplete(@NonNull Task task) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); daoUser.createUser(task.getResult().getUser().getUid(), email, firstName, lastName); startActivity(intent); + Toast.makeText(getApplicationContext(), getString(R.string.signup_toast_connected), Toast.LENGTH_LONG).show(); } else { showAlertDialogError(R.string.signup_error_title, task.getException().getMessage()); } diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/CustomAssociationAdapter.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/CustomAssociationAdapter.java index a8e15f2..ca97652 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/CustomAssociationAdapter.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/CustomAssociationAdapter.java @@ -66,7 +66,7 @@ public View getView(int position, View convertView, ViewGroup parent) { } else { //If association has no logo registered, set default android image - viewHolder.imageAssociationLogo.setImageResource(R.mipmap.ic_launcher); + viewHolder.imageAssociationLogo.setImageResource(R.drawable.association_default_icon); } return view; diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/SearchAssociationAdapter.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/SearchAssociationAdapter.java index 3bf361f..afd4ba2 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/SearchAssociationAdapter.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/adapter/SearchAssociationAdapter.java @@ -121,7 +121,7 @@ public void onClick(View v) { } else { //If association has no logo registered, set default android image - viewHolder.logo.setImageResource(R.mipmap.ic_launcher); + viewHolder.logo.setImageResource(R.drawable.association_default_icon); } return view; diff --git a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/fragment/AssociationMainFragment.java b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/fragment/AssociationMainFragment.java index 5721e25..2a8d33f 100644 --- a/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/fragment/AssociationMainFragment.java +++ b/app/src/main/java/fr/paris10/projet/assogenda/assogenda/ui/fragment/AssociationMainFragment.java @@ -25,6 +25,8 @@ import fr.paris10.projet.assogenda.assogenda.R; import fr.paris10.projet.assogenda.assogenda.model.Association; +import fr.paris10.projet.assogenda.assogenda.ui.activites.EventInfosActivity; +import fr.paris10.projet.assogenda.assogenda.ui.activites.ShowAssociationActivity; import fr.paris10.projet.assogenda.assogenda.ui.activites.CreateEventActivity; import fr.paris10.projet.assogenda.assogenda.ui.adapter.CustomAssociationAdapter; @@ -67,7 +69,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public void onChildAdded(DataSnapshot snapshot, String previousChild) { Association association = snapshot.getValue(Association.class); - association.id = snapshot.getKey(); + association.id=snapshot.getKey(); items.add(association); associationAdapter.notifyDataSetChanged(); } @@ -104,8 +106,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - Intent intent = new Intent(view.getContext(), CreateEventActivity.class); - intent.putExtra("assoID", items.get(position).id); + Intent intent = new Intent(view.getContext(), ShowAssociationActivity.class); + Association association = items.get(position); + intent.putExtra("associationID", association.id); startActivity(intent); } }); diff --git a/app/src/main/res/drawable-hdpi/association_default_icon.png b/app/src/main/res/drawable-hdpi/association_default_icon.png new file mode 100644 index 0000000..c35e782 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/association_default_icon.png differ diff --git a/app/src/main/res/drawable-mdpi/association_default_icon.png b/app/src/main/res/drawable-mdpi/association_default_icon.png new file mode 100644 index 0000000..b832de7 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/association_default_icon.png differ diff --git a/app/src/main/res/drawable-xhdpi/association_default_icon.png b/app/src/main/res/drawable-xhdpi/association_default_icon.png new file mode 100644 index 0000000..2e6a049 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/association_default_icon.png differ diff --git a/app/src/main/res/drawable-xxhdpi/association_default_icon.png b/app/src/main/res/drawable-xxhdpi/association_default_icon.png new file mode 100644 index 0000000..e57bbdf Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/association_default_icon.png differ diff --git a/app/src/main/res/layout/activity_agenda.xml b/app/src/main/res/layout/activity_agenda.xml deleted file mode 100644 index 3fdfa11..0000000 --- a/app/src/main/res/layout/activity_agenda.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - -