Commit be13b83840bf6760282709be2fd78df0c4dbcb8c
1 parent
831665f7
Create personne menu
Showing
7 changed files
with
373 additions
and
7 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/DeletePersonne.java
0 → 100644
@@ -0,0 +1,96 @@ | @@ -0,0 +1,96 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app.personne; | ||
2 | + | ||
3 | +import android.app.Dialog; | ||
4 | +import android.content.DialogInterface; | ||
5 | +import android.os.Bundle; | ||
6 | +import android.support.v4.app.DialogFragment; | ||
7 | +import android.support.v7.app.AlertDialog; | ||
8 | +import android.view.LayoutInflater; | ||
9 | +import android.view.View; | ||
10 | +import android.widget.ProgressBar; | ||
11 | +import android.widget.Toast; | ||
12 | + | ||
13 | +import com.android.volley.Request; | ||
14 | +import com.android.volley.Response; | ||
15 | +import com.android.volley.VolleyError; | ||
16 | +import com.android.volley.toolbox.JsonObjectRequest; | ||
17 | + | ||
18 | +import net.plil.clubinfo.etunicorn.R; | ||
19 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
20 | +import net.plil.clubinfo.etunicorn.data.Personne; | ||
21 | +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
22 | + | ||
23 | +import org.json.JSONObject; | ||
24 | + | ||
25 | + | ||
26 | +public class DeletePersonne extends DialogFragment { | ||
27 | + | ||
28 | + ProgressBar mProgressBar; | ||
29 | + | ||
30 | + public DeletePersonne(){} | ||
31 | + | ||
32 | + /** | ||
33 | + * Create a new instance of MyDialogFragment, providing "num" | ||
34 | + * as an argument. | ||
35 | + */ | ||
36 | + public static DeletePersonne newInstance(Personne personne) { | ||
37 | + DeletePersonne f = new DeletePersonne(); | ||
38 | + | ||
39 | + // Supply num input as an argument. | ||
40 | + Bundle args = new Bundle(); | ||
41 | + args.putSerializable("personne", personne); | ||
42 | + f.setArguments(args); | ||
43 | + | ||
44 | + return f; | ||
45 | + } | ||
46 | + | ||
47 | + | ||
48 | + @Override | ||
49 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
50 | + // Use the Builder class for convenient dialog construction | ||
51 | + LayoutInflater inflater = getActivity().getLayoutInflater(); | ||
52 | + View view = inflater.inflate(R.layout.fragment_delete_personne, null); | ||
53 | + | ||
54 | + mProgressBar = (ProgressBar) view.findViewById(R.id.delete_consommation_progress_bar); | ||
55 | + final Personne personne = (Personne) getArguments().getSerializable("personne"); | ||
56 | + | ||
57 | + | ||
58 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
59 | + builder | ||
60 | + .setTitle(R.string.verif_delete_personne) | ||
61 | + .setView(view) | ||
62 | + .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { | ||
63 | + @Override | ||
64 | + public void onClick(DialogInterface dialog, int which) { | ||
65 | + mProgressBar.setVisibility(View.VISIBLE); | ||
66 | + | ||
67 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.DELETE, VolleyUtils.baseUri + "/personne/" + personne.getIdPersonne(), null, new Response.Listener<JSONObject>() { | ||
68 | + @Override | ||
69 | + public void onResponse(JSONObject response) { | ||
70 | + mProgressBar.setVisibility(View.GONE); | ||
71 | + Toast.makeText(getContext(), R.string.delete_done, Toast.LENGTH_LONG).show(); | ||
72 | + dismiss(); | ||
73 | + } | ||
74 | + }, new Response.ErrorListener() { | ||
75 | + @Override | ||
76 | + public void onErrorResponse(VolleyError error) { | ||
77 | + mProgressBar.setVisibility(View.GONE); | ||
78 | + Toast.makeText(getContext(), R.string.delete_refused, Toast.LENGTH_LONG).show(); | ||
79 | + dismiss(); | ||
80 | + } | ||
81 | + } | ||
82 | + ); | ||
83 | + | ||
84 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | ||
85 | + } | ||
86 | + }) | ||
87 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | ||
88 | + public void onClick(DialogInterface dialog, int id) { | ||
89 | + | ||
90 | + } | ||
91 | + }); | ||
92 | + return builder.create(); | ||
93 | + } | ||
94 | + | ||
95 | + | ||
96 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/ModifyPersonne.java
0 → 100644
@@ -0,0 +1,119 @@ | @@ -0,0 +1,119 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.app.personne; | ||
2 | + | ||
3 | +import android.app.Dialog; | ||
4 | +import android.content.DialogInterface; | ||
5 | +import android.os.Bundle; | ||
6 | +import android.support.v4.app.DialogFragment; | ||
7 | +import android.support.v7.app.AlertDialog; | ||
8 | +import android.view.LayoutInflater; | ||
9 | +import android.view.View; | ||
10 | +import android.widget.EditText; | ||
11 | +import android.widget.ProgressBar; | ||
12 | +import android.widget.Toast; | ||
13 | + | ||
14 | +import com.android.volley.Request; | ||
15 | +import com.android.volley.Response; | ||
16 | +import com.android.volley.VolleyError; | ||
17 | +import com.android.volley.toolbox.JsonObjectRequest; | ||
18 | + | ||
19 | +import net.plil.clubinfo.etunicorn.R; | ||
20 | +import net.plil.clubinfo.etunicorn.data.Event; | ||
21 | +import net.plil.clubinfo.etunicorn.data.Personne; | ||
22 | +import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
23 | + | ||
24 | +import org.json.JSONException; | ||
25 | +import org.json.JSONObject; | ||
26 | + | ||
27 | +import java.util.Locale; | ||
28 | + | ||
29 | + | ||
30 | +public class ModifyPersonne extends DialogFragment { | ||
31 | + | ||
32 | + EditText mCarte; | ||
33 | + EditText mNaissance; | ||
34 | + EditText mLogin; | ||
35 | + EditText mRole; | ||
36 | + ProgressBar mProgressBar; | ||
37 | + | ||
38 | + public static ModifyPersonne newInstance(Personne personne) { | ||
39 | + ModifyPersonne f = new ModifyPersonne(); | ||
40 | + | ||
41 | + // Supply num input as an argument. | ||
42 | + Bundle args = new Bundle(); | ||
43 | + args.putSerializable("event", personne); | ||
44 | + f.setArguments(args); | ||
45 | + | ||
46 | + return f; | ||
47 | + } | ||
48 | + | ||
49 | + | ||
50 | + @Override | ||
51 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
52 | + // Use the Builder class for convenient dialog construction | ||
53 | + LayoutInflater inflater = getActivity().getLayoutInflater(); | ||
54 | + View view = inflater.inflate(R.layout.fragment_modify_personne, null); | ||
55 | + mLogin = (EditText) view.findViewById(R.id.modify_personne_login); | ||
56 | + mCarte = (EditText) view.findViewById(R.id.modify_personne_carte); | ||
57 | + mNaissance = (EditText) view.findViewById(R.id.modify_personne_naissance); | ||
58 | + mRole = (EditText) view.findViewById(R.id.modify_personne_role); | ||
59 | + mProgressBar = (ProgressBar) view.findViewById(R.id.modify_event_progress_bar); | ||
60 | + | ||
61 | + final Personne personne = (Personne) getArguments().getSerializable("personne"); | ||
62 | + | ||
63 | + mRole.setText(personne.getRole().getName()); | ||
64 | + mCarte.setText(personne.getIdCarte()); | ||
65 | + mLogin.setText(personne.getLoginPoly()); | ||
66 | + mNaissance.setText(personne.getNaissance().toString()); | ||
67 | + | ||
68 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
69 | + builder | ||
70 | + .setTitle(R.string.modify) | ||
71 | + .setView(view) | ||
72 | + .setPositiveButton(R.string.modify, new DialogInterface.OnClickListener() { | ||
73 | + public void onClick(DialogInterface dialog, int id) { | ||
74 | + | ||
75 | + mProgressBar.setVisibility(View.VISIBLE); | ||
76 | + mRole.setVisibility(View.GONE); | ||
77 | + mLogin.setVisibility(View.GONE); | ||
78 | + mCarte.setVisibility(View.GONE); | ||
79 | + mNaissance.setVisibility(View.GONE); | ||
80 | + JSONObject jsonObject = new JSONObject(); | ||
81 | + try { | ||
82 | + jsonObject.put("carte", mCarte.getText().toString()); | ||
83 | + jsonObject.put("login", mLogin.getText().toString()); | ||
84 | + jsonObject.put("role", mRole.getText().toString()); | ||
85 | + jsonObject.put("naissance", mNaissance.getText().toString()); | ||
86 | + } catch (JSONException e){ | ||
87 | + e.printStackTrace(); | ||
88 | + } | ||
89 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/personne/" + personne.getIdPersonne() ,jsonObject , new Response.Listener<JSONObject>() { | ||
90 | + @Override | ||
91 | + public void onResponse(JSONObject response) { | ||
92 | + mProgressBar.setVisibility(View.GONE); | ||
93 | + Toast.makeText(getContext(), R.string.modify_done, Toast.LENGTH_LONG).show(); | ||
94 | + | ||
95 | + } | ||
96 | + }, new Response.ErrorListener() { | ||
97 | + @Override | ||
98 | + public void onErrorResponse(VolleyError error) { | ||
99 | + mProgressBar.setVisibility(View.GONE); | ||
100 | + Toast.makeText(getContext(), R.string.modify_refused, Toast.LENGTH_LONG).show(); | ||
101 | + | ||
102 | + } | ||
103 | + } | ||
104 | + ); | ||
105 | + | ||
106 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | ||
107 | + } | ||
108 | + }) | ||
109 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | ||
110 | + public void onClick(DialogInterface dialog, int id) { | ||
111 | + // User cancelled the dialog | ||
112 | + } | ||
113 | + }); | ||
114 | + // Create the AlertDialog object and return it | ||
115 | + return builder.create(); | ||
116 | + } | ||
117 | + | ||
118 | + | ||
119 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Personne.java
1 | package net.plil.clubinfo.etunicorn.data; | 1 | package net.plil.clubinfo.etunicorn.data; |
2 | 2 | ||
3 | 3 | ||
4 | +import java.io.Serializable; | ||
4 | import java.sql.Date; | 5 | import java.sql.Date; |
6 | +import java.util.ArrayList; | ||
7 | +import java.util.List; | ||
5 | 8 | ||
6 | -public class Personne { | 9 | +public class Personne implements Serializable{ |
7 | private int idPersonne; | 10 | private int idPersonne; |
8 | - private int idCarte; | 11 | + private String idCarte; |
9 | private Date naissance; | 12 | private Date naissance; |
10 | - private int solde = 0; | 13 | + private double solde = 0; |
11 | private String loginPoly; | 14 | private String loginPoly; |
15 | + private Role role = new Role(); | ||
12 | 16 | ||
13 | public Personne() { | 17 | public Personne() { |
14 | } | 18 | } |
15 | 19 | ||
20 | + public Role getRole() { | ||
21 | + return role; | ||
22 | + } | ||
23 | + | ||
24 | + public void setRole(Role role) { | ||
25 | + this.role = role; | ||
26 | + } | ||
27 | + | ||
16 | public int getIdPersonne() { | 28 | public int getIdPersonne() { |
17 | return idPersonne; | 29 | return idPersonne; |
18 | } | 30 | } |
@@ -21,11 +33,11 @@ public class Personne { | @@ -21,11 +33,11 @@ public class Personne { | ||
21 | this.idPersonne = idPersonne; | 33 | this.idPersonne = idPersonne; |
22 | } | 34 | } |
23 | 35 | ||
24 | - public int getIdCarte() { | 36 | + public String getIdCarte() { |
25 | return idCarte; | 37 | return idCarte; |
26 | } | 38 | } |
27 | 39 | ||
28 | - public void setIdCarte(int idCarte) { | 40 | + public void setIdCarte(String idCarte) { |
29 | this.idCarte = idCarte; | 41 | this.idCarte = idCarte; |
30 | } | 42 | } |
31 | 43 | ||
@@ -37,11 +49,11 @@ public class Personne { | @@ -37,11 +49,11 @@ public class Personne { | ||
37 | this.naissance = naissance; | 49 | this.naissance = naissance; |
38 | } | 50 | } |
39 | 51 | ||
40 | - public int getSolde() { | 52 | + public double getSolde() { |
41 | return solde; | 53 | return solde; |
42 | } | 54 | } |
43 | 55 | ||
44 | - public void setSolde(int solde) { | 56 | + public void setSolde(double solde) { |
45 | this.solde = solde; | 57 | this.solde = solde; |
46 | } | 58 | } |
47 | 59 |
app/src/main/res/layout/fragment_delete_personne.xml
0 → 100644
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | + xmlns:tools="http://schemas.android.com/tools" | ||
3 | + android:layout_width="match_parent" | ||
4 | + android:layout_height="match_parent" | ||
5 | + tools:context="net.plil.clubinfo.etunicorn.app.consommation.DeleteConsommation" | ||
6 | + android:orientation="vertical"> | ||
7 | + | ||
8 | + | ||
9 | + <ProgressBar | ||
10 | + style="?android:attr/progressBarStyle" | ||
11 | + android:layout_width="wrap_content" | ||
12 | + android:layout_height="wrap_content" | ||
13 | + android:id="@+id/delete_personne_progress_bar" | ||
14 | + android:visibility="gone" | ||
15 | + android:layout_gravity="center" /> | ||
16 | + | ||
17 | +</LinearLayout> |
app/src/main/res/layout/fragment_modify_personne.xml
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | + xmlns:tools="http://schemas.android.com/tools" | ||
3 | + android:layout_width="match_parent" | ||
4 | + android:layout_height="match_parent" | ||
5 | + tools:context="net.plil.clubinfo.etunicorn.app.consommation.ModifyConsommation" | ||
6 | + android:orientation="vertical"> | ||
7 | + | ||
8 | + <EditText | ||
9 | + android:layout_width="match_parent" | ||
10 | + android:layout_height="wrap_content" | ||
11 | + android:id="@+id/modify_personne_carte" /> | ||
12 | + | ||
13 | + <EditText | ||
14 | + android:layout_width="match_parent" | ||
15 | + android:layout_height="wrap_content" | ||
16 | + android:id="@+id/modify_personne_login"/> | ||
17 | + <EditText | ||
18 | + android:layout_width="match_parent" | ||
19 | + android:layout_height="wrap_content" | ||
20 | + android:id="@+id/modify_personne_role"/> | ||
21 | + <EditText | ||
22 | + android:layout_width="match_parent" | ||
23 | + android:layout_height="wrap_content" | ||
24 | + android:id="@+id/modify_personne_naissance"/> | ||
25 | + | ||
26 | + <ProgressBar | ||
27 | + style="?android:attr/progressBarStyle" | ||
28 | + android:layout_width="match_parent" | ||
29 | + android:layout_height="wrap_content" | ||
30 | + android:id="@+id/modify_consommation_progress_bar" | ||
31 | + android:layout_gravity="center" | ||
32 | + android:visibility="gone"/> | ||
33 | + | ||
34 | + | ||
35 | +</LinearLayout> |
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + android:layout_width="wrap_content" | ||
4 | + android:layout_height="wrap_content" | ||
5 | + xmlns:tools="http://schemas.android.com/tools" | ||
6 | + android:orientation="horizontal" | ||
7 | + android:foreground="?attr/selectableItemBackground"> | ||
8 | + | ||
9 | + | ||
10 | + <TextView | ||
11 | + android:id="@+id/personne_login" | ||
12 | + android:layout_width="wrap_content" | ||
13 | + android:layout_height="wrap_content" | ||
14 | + android:layout_margin="@dimen/text_margin" | ||
15 | + android:textAppearance="?attr/textAppearanceListItem" /> | ||
16 | + <TextView | ||
17 | + android:id="@+id/personne_carte" | ||
18 | + android:layout_width="wrap_content" | ||
19 | + android:layout_height="wrap_content" | ||
20 | + android:layout_margin="@dimen/text_margin" | ||
21 | + android:textAppearance="?attr/textAppearanceListItem" | ||
22 | + android:layout_toEndOf="@id/personne_login"/> | ||
23 | + <TextView | ||
24 | + android:id="@+id/personne_role" | ||
25 | + android:layout_width="wrap_content" | ||
26 | + android:layout_height="wrap_content" | ||
27 | + android:layout_margin="@dimen/text_margin" | ||
28 | + android:textAppearance="?attr/textAppearanceListItem" | ||
29 | + android:layout_toEndOf="@id/personne_carte"/> | ||
30 | + <TextView | ||
31 | + android:id="@+id/personne_solde" | ||
32 | + android:layout_width="wrap_content" | ||
33 | + android:layout_height="wrap_content" | ||
34 | + android:layout_margin="@dimen/text_margin" | ||
35 | + android:textAppearance="?attr/textAppearanceListItem" | ||
36 | + android:layout_toEndOf="@id/personne_solde"/> | ||
37 | + | ||
38 | + <TextView | ||
39 | + android:id="@+id/personne_options" | ||
40 | + android:layout_width="wrap_content" | ||
41 | + android:layout_height="wrap_content" | ||
42 | + android:paddingRight="@dimen/activity_horizontal_margin" | ||
43 | + android:paddingLeft="@dimen/activity_horizontal_margin" | ||
44 | + android:text="⋮" | ||
45 | + android:textAppearance="?android:textAppearanceLarge" | ||
46 | + tools:ignore="RtlHardcoded,RtlSymmetry" | ||
47 | + android:textStyle="normal|bold" | ||
48 | + android:translationY="10dp" | ||
49 | + android:layout_alignParentRight="true" /> | ||
50 | + | ||
51 | +</RelativeLayout> |
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<android.support.design.widget.CoordinatorLayout | ||
2 | + xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + xmlns:tools="http://schemas.android.com/tools" | ||
5 | + android:layout_width="match_parent" | ||
6 | + android:layout_height="match_parent"> | ||
7 | + | ||
8 | + <android.support.v7.widget.RecyclerView | ||
9 | + android:id="@+id/personne_list" | ||
10 | + android:name="net.plil.clubinfo.etunicorn.app.personne.PersonneFragment" | ||
11 | + android:layout_width="match_parent" | ||
12 | + android:layout_height="match_parent" | ||
13 | + android:layout_marginLeft="16dp" | ||
14 | + android:layout_marginRight="16dp" | ||
15 | + app:layoutManager="LinearLayoutManager" | ||
16 | + tools:context="net.plil.clubinfo.etunicorn.app.personne.PersonneFragment" | ||
17 | + tools:listitem="@layout/fragment_personne" | ||
18 | + /> | ||
19 | + | ||
20 | + <android.support.design.widget.FloatingActionButton | ||
21 | + android:layout_width="wrap_content" | ||
22 | + android:layout_height="wrap_content" | ||
23 | + android:clickable="true" | ||
24 | + android:layout_gravity="bottom|end" | ||
25 | + android:layout_margin="24dp" | ||
26 | + android:id="@+id/personne_add" | ||
27 | + app:fabSize="auto" | ||
28 | + app:srcCompat="@android:drawable/ic_menu_add" | ||
29 | + app:backgroundTint="@color/colorPrimaryDark" | ||
30 | + app:elevation="6dp" | ||
31 | + app:rippleColor="@color/colorAccent" | ||
32 | + app:layout_anchor="@id/personne_list" | ||
33 | + app:layout_anchorGravity="bottom|right|end" | ||
34 | + app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior" /> | ||
35 | + | ||
36 | +</android.support.design.widget.CoordinatorLayout> | ||
0 | \ No newline at end of file | 37 | \ No newline at end of file |