Commit d17732ca748b46ab13649c82e31af6669bd3dccb
1 parent
bed80725
Change Button
Showing
8 changed files
with
186 additions
and
48 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/CreatePersonne.java
0 → 100644
... | ... | @@ -0,0 +1,90 @@ |
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 | + | |
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.utils.VolleyUtils; | |
20 | + | |
21 | +import org.json.JSONException; | |
22 | +import org.json.JSONObject; | |
23 | + | |
24 | + | |
25 | +public class CreatePersonne extends DialogFragment { | |
26 | + | |
27 | + EditText mLogin; | |
28 | + EditText mCarte; | |
29 | + EditText mNaissance; | |
30 | + EditText mRole; | |
31 | + ProgressBar mProgressBar; | |
32 | + | |
33 | + | |
34 | + @Override | |
35 | + public Dialog onCreateDialog(Bundle savedInstanceState) { | |
36 | + // Use the Builder class for convenient dialog construction | |
37 | + LayoutInflater inflater = getActivity().getLayoutInflater(); | |
38 | + View view = inflater.inflate(R.layout.fragment_create_personne, null); | |
39 | + mLogin = (EditText) view.findViewById(R.id.create_personne_login); | |
40 | + mCarte = (EditText) view.findViewById(R.id.create_personne_carte); | |
41 | + mRole = (EditText) view.findViewById(R.id.create_personne_role); | |
42 | + mNaissance = (EditText) view.findViewById(R.id.create_personne_naissance); | |
43 | + mProgressBar = (ProgressBar) view.findViewById(R.id.create_personne_progress_bar); | |
44 | + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
45 | + builder | |
46 | + .setTitle(R.string.create_personne) | |
47 | + .setView(view) | |
48 | + .setPositiveButton(R.string.valid, new DialogInterface.OnClickListener() { | |
49 | + public void onClick(DialogInterface dialog, int id) { | |
50 | + | |
51 | + mProgressBar.setVisibility(View.VISIBLE); | |
52 | + mLogin.setVisibility(View.GONE); | |
53 | + mCarte.setVisibility(View.GONE); | |
54 | + mNaissance.setVisibility(View.GONE); | |
55 | + JSONObject jsonObject = new JSONObject(); | |
56 | + try { | |
57 | + jsonObject.put("login", mLogin.getText().toString()); | |
58 | + jsonObject.put("carte", mCarte.getText().toString()); | |
59 | + jsonObject.put("role", mRole.getText().toString()); | |
60 | + jsonObject.put("naissance", mNaissance.getText().toString()); | |
61 | + } catch (JSONException e){ | |
62 | + e.printStackTrace(); | |
63 | + } | |
64 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/personne" ,jsonObject , new Response.Listener<JSONObject>() { | |
65 | + @Override | |
66 | + public void onResponse(JSONObject response) { | |
67 | + mProgressBar.setVisibility(View.GONE); | |
68 | + } | |
69 | + }, new Response.ErrorListener() { | |
70 | + @Override | |
71 | + public void onErrorResponse(VolleyError error) { | |
72 | + mProgressBar.setVisibility(View.GONE); | |
73 | + } | |
74 | + } | |
75 | + ); | |
76 | + | |
77 | + VolleyUtils.getInstance(getContext()).addToRequestQueue(jsonObjectRequest); | |
78 | + } | |
79 | + }) | |
80 | + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
81 | + public void onClick(DialogInterface dialog, int id) { | |
82 | + // User cancelled the dialog | |
83 | + } | |
84 | + }); | |
85 | + // Create the AlertDialog object and return it | |
86 | + return builder.create(); | |
87 | + } | |
88 | + | |
89 | + | |
90 | +} | ... | ... |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonneFragment.java
... | ... | @@ -2,6 +2,7 @@ package net.plil.clubinfo.etunicorn.app.personne; |
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | 4 | import android.os.Bundle; |
5 | +import android.support.design.widget.FloatingActionButton; | |
5 | 6 | import android.support.v7.widget.LinearLayoutManager; |
6 | 7 | import android.support.v7.widget.ListPopupWindow; |
7 | 8 | import android.support.v7.widget.RecyclerView; |
... | ... | @@ -61,11 +62,19 @@ public class PersonneFragment extends FragmentNFC { |
61 | 62 | p.setLoginPoly("bverhaeg"); |
62 | 63 | p.setNaissance(new Date(System.currentTimeMillis())); |
63 | 64 | p.setSolde(45); |
64 | - | |
65 | 65 | personneList.add(p); |
66 | - | |
67 | - recyclerView.setAdapter(new MyPersonneRecyclerViewAdapter(personneList, mListener, getActivity())); | |
68 | 66 | } |
67 | + recyclerView.setAdapter(new MyPersonneRecyclerViewAdapter(personneList, mListener, getActivity())); | |
68 | + | |
69 | + FloatingActionButton fAB = (FloatingActionButton) view.findViewById(R.id.personne_add); | |
70 | + fAB.setOnClickListener(new View.OnClickListener() { | |
71 | + @Override | |
72 | + public void onClick(View v) { | |
73 | + CreatePersonne newFragment = new CreatePersonne(); | |
74 | + newFragment.show(getFragmentManager(), "CreateEvent"); | |
75 | + } | |
76 | + }); | |
77 | + | |
69 | 78 | return view; |
70 | 79 | } |
71 | 80 | ... | ... |
app/src/main/res/layout/fragment_consomation_item_list.xml
... | ... | @@ -25,12 +25,8 @@ |
25 | 25 | android:layout_gravity="bottom|end" |
26 | 26 | android:layout_margin="24dp" |
27 | 27 | android:id="@+id/consomation_add" |
28 | - app:fabSize="auto" | |
29 | - app:srcCompat="@android:drawable/ic_menu_add" | |
30 | - app:backgroundTint="@color/colorPrimaryDark" | |
31 | - app:elevation="6dp" | |
32 | - app:rippleColor="@color/colorAccent" | |
33 | - app:layout_anchor="@id/consomation_list" | |
28 | + app:srcCompat="@android:drawable/ic_input_add" | |
29 | + android:tint="@android:color/white" | |
34 | 30 | app:layout_anchorGravity="bottom|right|end" |
35 | 31 | app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior" /> |
36 | 32 | ... | ... |
app/src/main/res/layout/fragment_create_personne.xml
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +<LinearLayout | |
2 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + xmlns:tools="http://schemas.android.com/tools" | |
4 | + tools:context="net.plil.clubinfo.etunicorn.app.consommation.CreateConsommation" | |
5 | + android:orientation="vertical" | |
6 | + android:layout_width="match_parent" | |
7 | + android:layout_height="match_parent" | |
8 | + > | |
9 | + | |
10 | + <EditText | |
11 | + android:layout_width="match_parent" | |
12 | + android:layout_height="wrap_content" | |
13 | + android:id="@+id/create_personne_login" | |
14 | + android:hint="@string/create_personne_login"/> | |
15 | + | |
16 | + <EditText | |
17 | + android:layout_width="match_parent" | |
18 | + android:layout_height="wrap_content" | |
19 | + android:id="@+id/create_personne_carte" | |
20 | + android:hint="@string/create_personne_carte"/> | |
21 | + | |
22 | + <EditText | |
23 | + android:layout_width="match_parent" | |
24 | + android:layout_height="wrap_content" | |
25 | + android:id="@+id/create_personne_naissance" | |
26 | + android:hint="@string/create_personne_naissance"/> | |
27 | + | |
28 | + <EditText | |
29 | + android:layout_width="match_parent" | |
30 | + android:layout_height="wrap_content" | |
31 | + android:id="@+id/create_personne_role" | |
32 | + android:hint="@string/create_personne_role"/> | |
33 | + | |
34 | + | |
35 | + <ProgressBar | |
36 | + style="?android:attr/progressBarStyle" | |
37 | + android:layout_width="match_parent" | |
38 | + android:layout_height="wrap_content" | |
39 | + android:id="@+id/create_personne_progress_bar" | |
40 | + android:visibility="gone"/> | |
41 | + | |
42 | +</LinearLayout> | |
43 | + | ... | ... |
app/src/main/res/layout/fragment_event_list.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <android.support.design.widget.CoordinatorLayout |
3 | -xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | -xmlns:app="http://schemas.android.com/apk/res-auto" | |
5 | -xmlns:tools="http://schemas.android.com/tools" | |
6 | -android:layout_width="match_parent" | |
7 | -android:layout_height="match_parent"> | |
8 | - | |
9 | -<android.support.v7.widget.RecyclerView | |
10 | - android:id="@+id/event_list" | |
11 | - android:name="net.plil.clubinfo.etunicorn.app.event.EventFragment" | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
5 | + xmlns:tools="http://schemas.android.com/tools" | |
12 | 6 | android:layout_width="match_parent" |
13 | - android:layout_height="match_parent" | |
14 | - android:layout_marginLeft="16dp" | |
15 | - android:layout_marginRight="16dp" | |
16 | - app:layoutManager="LinearLayoutManager" | |
17 | - tools:context="net.plil.clubinfo.etunicorn.app.event.EventFragment" | |
18 | - tools:listitem="@layout/fragment_event" | |
19 | - /> | |
7 | + android:layout_height="match_parent"> | |
8 | + | |
9 | + <android.support.v7.widget.RecyclerView | |
10 | + android:id="@+id/event_list" | |
11 | + android:name="net.plil.clubinfo.etunicorn.app.event.EventFragment" | |
12 | + android:layout_width="match_parent" | |
13 | + android:layout_height="match_parent" | |
14 | + android:layout_marginLeft="16dp" | |
15 | + android:layout_marginRight="16dp" | |
16 | + app:layoutManager="LinearLayoutManager" | |
17 | + tools:context="net.plil.clubinfo.etunicorn.app.event.EventFragment" | |
18 | + tools:listitem="@layout/fragment_event" | |
19 | + /> | |
20 | 20 | |
21 | -<android.support.design.widget.FloatingActionButton | |
22 | - android:layout_width="wrap_content" | |
23 | - android:layout_height="wrap_content" | |
24 | - android:clickable="true" | |
25 | - android:layout_gravity="bottom|end" | |
26 | - android:layout_margin="24dp" | |
27 | - android:id="@+id/event_add" | |
28 | - app:fabSize="auto" | |
29 | - app:srcCompat="@android:drawable/ic_menu_add" | |
30 | - app:backgroundTint="@color/colorPrimaryDark" | |
31 | - app:elevation="6dp" | |
32 | - app:rippleColor="@color/colorAccent" | |
33 | - app:layout_anchor="@id/event_list" | |
34 | - app:layout_anchorGravity="bottom|right|end" | |
35 | - app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior" /> | |
21 | + <android.support.design.widget.FloatingActionButton | |
22 | + android:layout_width="wrap_content" | |
23 | + android:layout_height="wrap_content" | |
24 | + android:clickable="true" | |
25 | + android:layout_margin="24dp" | |
26 | + android:layout_gravity="end|bottom" | |
27 | + android:id="@+id/event_add" | |
28 | + app:srcCompat="@android:drawable/ic_input_add" | |
29 | + android:tint="@android:color/white" | |
30 | + app:elevation="6dp" | |
31 | + android:color="?android:colorControlHighlight" | |
32 | + app:layout_anchorGravity="bottom|end" | |
33 | + app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior" /> | |
36 | 34 | |
37 | 35 | </android.support.design.widget.CoordinatorLayout> |
38 | 36 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_personne_list.xml
... | ... | @@ -21,16 +21,12 @@ |
21 | 21 | android:layout_width="wrap_content" |
22 | 22 | android:layout_height="wrap_content" |
23 | 23 | android:clickable="true" |
24 | - android:layout_gravity="bottom|end" | |
25 | 24 | android:layout_margin="24dp" |
25 | + android:layout_gravity="end|bottom" | |
26 | 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" | |
27 | + app:srcCompat="@android:drawable/ic_input_add" | |
28 | + android:tint="@android:color/white" | |
29 | + app:layout_anchorGravity="bottom|end" | |
34 | 30 | app:layout_behavior="net.plil.clubinfo.etunicorn.utils.ScrollAwareFABBehavior" /> |
35 | 31 | |
36 | 32 | </android.support.design.widget.CoordinatorLayout> |
37 | 33 | \ No newline at end of file | ... | ... |
app/src/main/res/values-fr/strings.xml
... | ... | @@ -35,4 +35,5 @@ |
35 | 35 | <string name="personne">Personne</string> |
36 | 36 | <string name="verif_delete_event">Are you sure ?</string> |
37 | 37 | <string name="verif_delete_personne">Are you sure ?? !!</string> |
38 | + <string name="create_personne">Créer une personne</string> | |
38 | 39 | </resources> |
39 | 40 | \ No newline at end of file | ... | ... |
app/src/main/res/values/strings.xml
... | ... | @@ -36,4 +36,9 @@ |
36 | 36 | <string name="create_event">Create event</string> |
37 | 37 | <string name="personne">Person</string> |
38 | 38 | <string name="verif_delete_personne">Are You Sure ?? !!!</string> |
39 | + <string name="create_personne">Create person</string> | |
40 | + <string name="create_personne_login">Login</string> | |
41 | + <string name="create_personne_carte">Carte ID</string> | |
42 | + <string name="create_personne_naissance">Birthday</string> | |
43 | + <string name="create_personne_role">Role</string> | |
39 | 44 | </resources> | ... | ... |