Commit bda0317b9a568a6f163dfe3dcac4ddd9f85e5b18
1 parent
9fe436b8
LOGIN OK
Showing
17 changed files
with
148 additions
and
94 deletions
Show diff stats
app/src/main/java/net/plil/clubinfo/etunicorn/app/LoginActivity.java
@@ -37,17 +37,27 @@ import com.android.volley.Response; | @@ -37,17 +37,27 @@ import com.android.volley.Response; | ||
37 | import com.android.volley.VolleyError; | 37 | import com.android.volley.VolleyError; |
38 | import com.android.volley.toolbox.JsonObjectRequest; | 38 | import com.android.volley.toolbox.JsonObjectRequest; |
39 | import com.google.gson.Gson; | 39 | import com.google.gson.Gson; |
40 | +import com.google.gson.GsonBuilder; | ||
41 | +import com.google.gson.JsonDeserializationContext; | ||
42 | +import com.google.gson.JsonDeserializer; | ||
43 | +import com.google.gson.JsonElement; | ||
44 | +import com.google.gson.JsonParseException; | ||
40 | 45 | ||
41 | import net.plil.clubinfo.etunicorn.R; | 46 | import net.plil.clubinfo.etunicorn.R; |
42 | import net.plil.clubinfo.etunicorn.data.Permission; | 47 | import net.plil.clubinfo.etunicorn.data.Permission; |
43 | import net.plil.clubinfo.etunicorn.data.Personne; | 48 | import net.plil.clubinfo.etunicorn.data.Personne; |
49 | +import net.plil.clubinfo.etunicorn.data.Session; | ||
44 | import net.plil.clubinfo.etunicorn.data.User; | 50 | import net.plil.clubinfo.etunicorn.data.User; |
51 | +import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | ||
52 | +import net.plil.clubinfo.etunicorn.utils.JsonCoverter; | ||
45 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 53 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
46 | 54 | ||
47 | import org.json.JSONException; | 55 | import org.json.JSONException; |
48 | import org.json.JSONObject; | 56 | import org.json.JSONObject; |
49 | 57 | ||
58 | +import java.lang.reflect.Type; | ||
50 | import java.util.ArrayList; | 59 | import java.util.ArrayList; |
60 | +import java.util.Date; | ||
51 | import java.util.List; | 61 | import java.util.List; |
52 | 62 | ||
53 | import static android.Manifest.permission.READ_CONTACTS; | 63 | import static android.Manifest.permission.READ_CONTACTS; |
@@ -169,46 +179,30 @@ public class LoginActivity extends AppCompatActivity { | @@ -169,46 +179,30 @@ public class LoginActivity extends AppCompatActivity { | ||
169 | private void tryLogin (String username, String password){ | 179 | private void tryLogin (String username, String password){ |
170 | User user = new User(); | 180 | User user = new User(); |
171 | user.setPassword(password); | 181 | user.setPassword(password); |
172 | - user.setUsername(username); | 182 | + user.setLogin(username); |
173 | JsonObjectRequest jsonObjectRequest = null; | 183 | JsonObjectRequest jsonObjectRequest = null; |
174 | try { | 184 | try { |
175 | - jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/login" , new JSONObject(new Gson().toJson(user)), new Response.Listener<JSONObject>() { | 185 | + |
186 | + jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, VolleyUtils.baseUri + "/login" , new JSONObject(JsonCoverter.getConverter().toJson(user)), new Response.Listener<JSONObject>() { | ||
176 | @Override | 187 | @Override |
177 | public void onResponse(JSONObject response) { | 188 | public void onResponse(JSONObject response) { |
178 | showProgress(false); | 189 | showProgress(false); |
179 | - | ||
180 | - Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show(); | ||
181 | Intent intent = new Intent(getApplicationContext(), MainActivity.class); | 190 | Intent intent = new Intent(getApplicationContext(), MainActivity.class); |
182 | - //TODO real interpretation when login work | ||
183 | - //Personne p = new Gson().fromJson(String.valueOf(response), Personne.class); | ||
184 | - Personne p = new Personne(); | ||
185 | - Permission permission = new Permission(); | ||
186 | - permission.setNom("ROLE_ADMIN"); | ||
187 | - p.getRole().getPermissions().add(permission); | ||
188 | - intent.putExtra("user", p); | 191 | + Session s = JsonCoverter.getConverter().fromJson(String.valueOf(response), Session.class); |
192 | + intent.putExtra("session", s); | ||
189 | startActivity(intent); | 193 | startActivity(intent); |
190 | } | 194 | } |
191 | }, new Response.ErrorListener() { | 195 | }, new Response.ErrorListener() { |
192 | @Override | 196 | @Override |
193 | public void onErrorResponse(VolleyError error) { | 197 | public void onErrorResponse(VolleyError error) { |
194 | showProgress(false); | 198 | showProgress(false); |
195 | - Toast.makeText(getApplicationContext(), "error : " + error.getCause(), Toast.LENGTH_SHORT).show(); | ||
196 | - Intent intent = new Intent(getApplicationContext(), MainActivity.class); | ||
197 | - | ||
198 | - Personne p = new Personne(); | ||
199 | - Permission permission = new Permission(); | ||
200 | - permission.setNom("ROLE_ADMIN"); | ||
201 | - p.getRole().getPermissions().add(permission); | ||
202 | - intent.putExtra("user", p); | ||
203 | - | ||
204 | - startActivity(intent); | 199 | + Toast.makeText(getApplicationContext(), "error : " + ConvertBytesToString.bytesToStringVolLey(error.networkResponse.data), Toast.LENGTH_SHORT).show(); |
205 | } | 200 | } |
206 | } | 201 | } |
207 | ); | 202 | ); |
208 | } catch (JSONException e) { | 203 | } catch (JSONException e) { |
209 | e.printStackTrace(); | 204 | e.printStackTrace(); |
210 | } | 205 | } |
211 | - | ||
212 | VolleyUtils.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectRequest); | 206 | VolleyUtils.getInstance(getApplicationContext()).addToRequestQueue(jsonObjectRequest); |
213 | } | 207 | } |
214 | } | 208 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/app/MainActivity.java
@@ -11,13 +11,11 @@ import android.support.design.widget.TabLayout; | @@ -11,13 +11,11 @@ import android.support.design.widget.TabLayout; | ||
11 | import android.support.v4.app.Fragment; | 11 | import android.support.v4.app.Fragment; |
12 | import android.support.v4.app.FragmentManager; | 12 | import android.support.v4.app.FragmentManager; |
13 | import android.support.v4.app.FragmentPagerAdapter; | 13 | import android.support.v4.app.FragmentPagerAdapter; |
14 | -import android.support.v4.app.FragmentTransaction; | ||
15 | import android.support.v4.view.ViewPager; | 14 | import android.support.v4.view.ViewPager; |
16 | import android.support.v7.app.AppCompatActivity; | 15 | import android.support.v7.app.AppCompatActivity; |
17 | import android.support.v7.widget.Toolbar; | 16 | import android.support.v7.widget.Toolbar; |
18 | import android.view.Menu; | 17 | import android.view.Menu; |
19 | import android.view.MenuItem; | 18 | import android.view.MenuItem; |
20 | -import android.widget.Toast; | ||
21 | 19 | ||
22 | import net.plil.clubinfo.etunicorn.R; | 20 | import net.plil.clubinfo.etunicorn.R; |
23 | import net.plil.clubinfo.etunicorn.app.credit.Crediter; | 21 | import net.plil.clubinfo.etunicorn.app.credit.Crediter; |
@@ -31,11 +29,8 @@ import net.plil.clubinfo.etunicorn.app.personne.PersonneFragment; | @@ -31,11 +29,8 @@ import net.plil.clubinfo.etunicorn.app.personne.PersonneFragment; | ||
31 | import net.plil.clubinfo.etunicorn.data.Consommation; | 29 | import net.plil.clubinfo.etunicorn.data.Consommation; |
32 | import net.plil.clubinfo.etunicorn.data.Event; | 30 | import net.plil.clubinfo.etunicorn.data.Event; |
33 | import net.plil.clubinfo.etunicorn.data.Personne; | 31 | import net.plil.clubinfo.etunicorn.data.Personne; |
32 | +import net.plil.clubinfo.etunicorn.data.Session; | ||
34 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; | 33 | import net.plil.clubinfo.etunicorn.utils.ConvertBytesToString; |
35 | -import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
36 | - | ||
37 | -import java.util.ArrayList; | ||
38 | -import java.util.List; | ||
39 | 34 | ||
40 | 35 | ||
41 | public class MainActivity extends AppCompatActivity | 36 | public class MainActivity extends AppCompatActivity |
@@ -64,7 +59,7 @@ public class MainActivity extends AppCompatActivity | @@ -64,7 +59,7 @@ public class MainActivity extends AppCompatActivity | ||
64 | private Toolbar toolbar; | 59 | private Toolbar toolbar; |
65 | private AppBarLayout appBarLayout; | 60 | private AppBarLayout appBarLayout; |
66 | 61 | ||
67 | - private Personne p; | 62 | + private Session s; |
68 | 63 | ||
69 | NfcAdapter mAdapter; | 64 | NfcAdapter mAdapter; |
70 | PendingIntent mPendingIntent; | 65 | PendingIntent mPendingIntent; |
@@ -73,22 +68,19 @@ public class MainActivity extends AppCompatActivity | @@ -73,22 +68,19 @@ public class MainActivity extends AppCompatActivity | ||
73 | protected void onCreate(Bundle savedInstanceState) { | 68 | protected void onCreate(Bundle savedInstanceState) { |
74 | super.onCreate(savedInstanceState); | 69 | super.onCreate(savedInstanceState); |
75 | 70 | ||
76 | - // config tabbed pan | ||
77 | Intent intent = this.getIntent(); | 71 | Intent intent = this.getIntent(); |
78 | - p = (Personne) intent.getSerializableExtra("user"); | ||
79 | - //TODO remove this line | ||
80 | - Toast.makeText(getApplicationContext(), p.getRole().getPermissions().get(0).getNom(), Toast.LENGTH_SHORT).show(); | ||
81 | - if (p.getRole().getPermissions().get(0).getNom().equals("ROLE_ADMIN")){ | 72 | + s = (Session) intent.getSerializableExtra("session"); |
73 | + if (s.getPersonne().getRole().getNom().equals("admin")){ | ||
82 | nbPages = 5; | 74 | nbPages = 5; |
83 | Action.CONSOMATION.setValue(2); | 75 | Action.CONSOMATION.setValue(2); |
84 | Action.EVENT.setValue(3); | 76 | Action.EVENT.setValue(3); |
85 | Action.PERSONNE.setValue(4); | 77 | Action.PERSONNE.setValue(4); |
86 | - } else if (p.getRole().getPermissions().get(0).getNom().equals("ROLE_BDE")){ | 78 | + } else if (s.getPersonne().getRole().getNom().equals("bde")){ |
87 | nbPages = 4; | 79 | nbPages = 4; |
88 | Action.CONSOMATION.setValue(-1); | 80 | Action.CONSOMATION.setValue(-1); |
89 | Action.EVENT.setValue(2); | 81 | Action.EVENT.setValue(2); |
90 | Action.PERSONNE.setValue(3); | 82 | Action.PERSONNE.setValue(3); |
91 | - } else if (p.getRole().getPermissions().get(0).getNom().equals("ROLE_BAR")){ | 83 | + } else if (s.getPersonne().getRole().getNom().equals("bar")){ |
92 | nbPages = 3; | 84 | nbPages = 3; |
93 | Action.CONSOMATION.setValue(2); | 85 | Action.CONSOMATION.setValue(2); |
94 | Action.EVENT.setValue(-1); | 86 | Action.EVENT.setValue(-1); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/credit/Crediter.java
@@ -73,7 +73,7 @@ public class Crediter extends FragmentNFC { | @@ -73,7 +73,7 @@ public class Crediter extends FragmentNFC { | ||
73 | JSONObject jsonObject = new JSONObject(); | 73 | JSONObject jsonObject = new JSONObject(); |
74 | try { | 74 | try { |
75 | Personne p = new Personne(); | 75 | Personne p = new Personne(); |
76 | - p.setIdCarte(idCardUser); | 76 | + p.setCarte(idCardUser); |
77 | jsonObject.put("participant", p); | 77 | jsonObject.put("participant", p); |
78 | jsonObject.put("prix", Double.parseDouble(mMoneyEditText.getText().toString())); | 78 | jsonObject.put("prix", Double.parseDouble(mMoneyEditText.getText().toString())); |
79 | } catch (JSONException e){ | 79 | } catch (JSONException e){ |
app/src/main/java/net/plil/clubinfo/etunicorn/app/debit/Debiter.java
@@ -78,7 +78,7 @@ public class Debiter extends FragmentNFC { | @@ -78,7 +78,7 @@ public class Debiter extends FragmentNFC { | ||
78 | //TODO verifier champ complet avant de construire la requete | 78 | //TODO verifier champ complet avant de construire la requete |
79 | try { | 79 | try { |
80 | Personne p = new Personne(); | 80 | Personne p = new Personne(); |
81 | - p.setIdCarte(iDCardUser); | 81 | + p.setCarte(iDCardUser); |
82 | jsonObject.put("participant", p); | 82 | jsonObject.put("participant", p); |
83 | jsonObject.put("prix", -Double.parseDouble(mMoneyEditText.getText().toString())); | 83 | jsonObject.put("prix", -Double.parseDouble(mMoneyEditText.getText().toString())); |
84 | mMoneyEditText.setError(null); | 84 | mMoneyEditText.setError(null); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/CreatePersonne.java
@@ -23,7 +23,6 @@ import com.android.volley.Response; | @@ -23,7 +23,6 @@ import com.android.volley.Response; | ||
23 | import com.android.volley.VolleyError; | 23 | import com.android.volley.VolleyError; |
24 | import com.android.volley.toolbox.JsonObjectRequest; | 24 | import com.android.volley.toolbox.JsonObjectRequest; |
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | -import com.google.gson.JsonArray; | ||
27 | 26 | ||
28 | import net.plil.clubinfo.etunicorn.R; | 27 | import net.plil.clubinfo.etunicorn.R; |
29 | import net.plil.clubinfo.etunicorn.data.Role; | 28 | import net.plil.clubinfo.etunicorn.data.Role; |
@@ -32,7 +31,6 @@ import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | @@ -32,7 +31,6 @@ import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | ||
32 | import org.json.JSONArray; | 31 | import org.json.JSONArray; |
33 | import org.json.JSONException; | 32 | import org.json.JSONException; |
34 | import org.json.JSONObject; | 33 | import org.json.JSONObject; |
35 | -import org.w3c.dom.Text; | ||
36 | 34 | ||
37 | import java.text.SimpleDateFormat; | 35 | import java.text.SimpleDateFormat; |
38 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
@@ -76,7 +74,7 @@ public class CreatePersonne extends DialogFragment { | @@ -76,7 +74,7 @@ public class CreatePersonne extends DialogFragment { | ||
76 | mRole = (Spinner) view.findViewById(R.id.create_personne_role); | 74 | mRole = (Spinner) view.findViewById(R.id.create_personne_role); |
77 | arraySpinnerRole = new ArrayList<>(); | 75 | arraySpinnerRole = new ArrayList<>(); |
78 | Role r = new Role(); | 76 | Role r = new Role(); |
79 | - r.setName("Role"); | 77 | + r.setNom("Role"); |
80 | arraySpinnerRole.add(r); | 78 | arraySpinnerRole.add(r); |
81 | adapterRole = new ArrayAdapter<>(getActivity(), | 79 | adapterRole = new ArrayAdapter<>(getActivity(), |
82 | R.layout.simple_item_layout, arraySpinnerRole); | 80 | R.layout.simple_item_layout, arraySpinnerRole); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/DeletePersonne.java
@@ -75,7 +75,7 @@ public class DeletePersonne extends DialogFragment { | @@ -75,7 +75,7 @@ public class DeletePersonne extends DialogFragment { | ||
75 | public void onClick(View v) { | 75 | public void onClick(View v) { |
76 | mProgressBar.setVisibility(View.VISIBLE); | 76 | mProgressBar.setVisibility(View.VISIBLE); |
77 | 77 | ||
78 | - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.DELETE, VolleyUtils.baseUri + "/personne/" + personne.getIdPersonne(), null, new Response.Listener<JSONObject>() { | 78 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.DELETE, VolleyUtils.baseUri + "/personne/" + personne.getId(), null, new Response.Listener<JSONObject>() { |
79 | @Override | 79 | @Override |
80 | public void onResponse(JSONObject response) { | 80 | public void onResponse(JSONObject response) { |
81 | mProgressBar.setVisibility(View.GONE); | 81 | mProgressBar.setVisibility(View.GONE); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/ModifyPersonne.java
@@ -25,8 +25,6 @@ import com.android.volley.toolbox.JsonObjectRequest; | @@ -25,8 +25,6 @@ import com.android.volley.toolbox.JsonObjectRequest; | ||
25 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
26 | 26 | ||
27 | import net.plil.clubinfo.etunicorn.R; | 27 | import net.plil.clubinfo.etunicorn.R; |
28 | -import net.plil.clubinfo.etunicorn.app.event.ModifyEvent; | ||
29 | -import net.plil.clubinfo.etunicorn.data.Event; | ||
30 | import net.plil.clubinfo.etunicorn.data.Personne; | 28 | import net.plil.clubinfo.etunicorn.data.Personne; |
31 | import net.plil.clubinfo.etunicorn.data.Role; | 29 | import net.plil.clubinfo.etunicorn.data.Role; |
32 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; | 30 | import net.plil.clubinfo.etunicorn.utils.VolleyUtils; |
@@ -90,8 +88,8 @@ public class ModifyPersonne extends DialogFragment { | @@ -90,8 +88,8 @@ public class ModifyPersonne extends DialogFragment { | ||
90 | 88 | ||
91 | final Personne personne = (Personne) getArguments().getSerializable("personne"); | 89 | final Personne personne = (Personne) getArguments().getSerializable("personne"); |
92 | 90 | ||
93 | - mCarte.setText(personne.getIdCarte()); | ||
94 | - mLogin.setText(personne.getLoginPoly()); | 91 | + mCarte.setText(personne.getCarte()); |
92 | + mLogin.setText(personne.getLogin()); | ||
95 | 93 | ||
96 | arraySpinnerRole = new ArrayList<>(); | 94 | arraySpinnerRole = new ArrayList<>(); |
97 | arraySpinnerRole.add(personne.getRole()); | 95 | arraySpinnerRole.add(personne.getRole()); |
@@ -148,7 +146,7 @@ public class ModifyPersonne extends DialogFragment { | @@ -148,7 +146,7 @@ public class ModifyPersonne extends DialogFragment { | ||
148 | } catch (JSONException e){ | 146 | } catch (JSONException e){ |
149 | e.printStackTrace(); | 147 | e.printStackTrace(); |
150 | } | 148 | } |
151 | - JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT, VolleyUtils.baseUri + "/personne/" + personne.getIdPersonne() ,jsonObject , new Response.Listener<JSONObject>() { | 149 | + JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT, VolleyUtils.baseUri + "/personne/" + personne.getId() ,jsonObject , new Response.Listener<JSONObject>() { |
152 | @Override | 150 | @Override |
153 | public void onResponse(JSONObject response) { | 151 | public void onResponse(JSONObject response) { |
154 | mProgressBar.setVisibility(View.GONE); | 152 | mProgressBar.setVisibility(View.GONE); |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/MyPersonneRecyclerViewAdapter.java
@@ -39,9 +39,9 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPerson | @@ -39,9 +39,9 @@ public class MyPersonneRecyclerViewAdapter extends RecyclerView.Adapter<MyPerson | ||
39 | @Override | 39 | @Override |
40 | public void onBindViewHolder(final ViewHolder holder, int position) { | 40 | public void onBindViewHolder(final ViewHolder holder, int position) { |
41 | holder.mItem = mValues.get(position); | 41 | holder.mItem = mValues.get(position); |
42 | - holder.mLogin.setText(mValues.get(position).getLoginPoly()); | ||
43 | - holder.mCarte.setText(mValues.get(position).getIdCarte()); | ||
44 | - holder.mRole.setText(mValues.get(position).getRole().getName()); | 42 | + holder.mLogin.setText(mValues.get(position).getLogin()); |
43 | + holder.mCarte.setText(mValues.get(position).getCarte()); | ||
44 | + holder.mRole.setText(mValues.get(position).getRole().getNom()); | ||
45 | holder.mSolde.setText(String.format(Locale.FRANCE, "%.2f", mValues.get(position).getSolde())); | 45 | holder.mSolde.setText(String.format(Locale.FRANCE, "%.2f", mValues.get(position).getSolde())); |
46 | 46 | ||
47 | holder.mView.setOnClickListener(new View.OnClickListener() { | 47 | holder.mView.setOnClickListener(new View.OnClickListener() { |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonOverviewFragment.java
@@ -59,11 +59,11 @@ public class PersonOverviewFragment extends DialogFragment{ | @@ -59,11 +59,11 @@ public class PersonOverviewFragment extends DialogFragment{ | ||
59 | mRole = (TextView) view.findViewById(R.id.personne_overview_role); | 59 | mRole = (TextView) view.findViewById(R.id.personne_overview_role); |
60 | 60 | ||
61 | assert personne != null; | 61 | assert personne != null; |
62 | - mCarte.setText(personne.getIdCarte()); | ||
63 | - mRole.setText(personne.getRole().getName()); | 62 | + mCarte.setText(personne.getCarte()); |
63 | + mRole.setText(personne.getRole().getNom()); | ||
64 | mSolde.setText(String.format(Locale.FRANCE, "%.2f",personne.getSolde())); | 64 | mSolde.setText(String.format(Locale.FRANCE, "%.2f",personne.getSolde())); |
65 | mNaissance.setText(personne.getNaissance().toString()); | 65 | mNaissance.setText(personne.getNaissance().toString()); |
66 | - mLogin.setText(personne.getLoginPoly()); | 66 | + mLogin.setText(personne.getLogin()); |
67 | 67 | ||
68 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | 68 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); |
69 | builder | 69 | builder |
app/src/main/java/net/plil/clubinfo/etunicorn/app/personne/PersonneFragment.java
@@ -4,7 +4,6 @@ import android.content.Context; | @@ -4,7 +4,6 @@ import android.content.Context; | ||
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.support.design.widget.FloatingActionButton; | 5 | import android.support.design.widget.FloatingActionButton; |
6 | import android.support.v7.widget.LinearLayoutManager; | 6 | import android.support.v7.widget.LinearLayoutManager; |
7 | -import android.support.v7.widget.ListPopupWindow; | ||
8 | import android.support.v7.widget.RecyclerView; | 7 | import android.support.v7.widget.RecyclerView; |
9 | import android.view.LayoutInflater; | 8 | import android.view.LayoutInflater; |
10 | import android.view.View; | 9 | import android.view.View; |
@@ -18,7 +17,6 @@ import net.plil.clubinfo.etunicorn.data.Role; | @@ -18,7 +17,6 @@ import net.plil.clubinfo.etunicorn.data.Role; | ||
18 | 17 | ||
19 | import java.sql.Date; | 18 | import java.sql.Date; |
20 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
21 | -import java.util.Calendar; | ||
22 | import java.util.List; | 20 | import java.util.List; |
23 | 21 | ||
24 | /** | 22 | /** |
@@ -59,7 +57,7 @@ public class PersonneFragment extends FragmentNFC { | @@ -59,7 +57,7 @@ public class PersonneFragment extends FragmentNFC { | ||
59 | 57 | ||
60 | List<Personne> personneList = new ArrayList<>(); | 58 | List<Personne> personneList = new ArrayList<>(); |
61 | Role r = new Role(); | 59 | Role r = new Role(); |
62 | - r.setName("ADMIN_TEST"); | 60 | + r.setNom("ADMIN_TEST"); |
63 | Permission p = new Permission(); | 61 | Permission p = new Permission(); |
64 | p.setNom("Lire"); | 62 | p.setNom("Lire"); |
65 | r.getPermissions().add(p); | 63 | r.getPermissions().add(p); |
@@ -68,8 +66,8 @@ public class PersonneFragment extends FragmentNFC { | @@ -68,8 +66,8 @@ public class PersonneFragment extends FragmentNFC { | ||
68 | r.getPermissions().add(p); | 66 | r.getPermissions().add(p); |
69 | for (int i = 0;i<150;++i){ | 67 | for (int i = 0;i<150;++i){ |
70 | Personne personne = new Personne(); | 68 | Personne personne = new Personne(); |
71 | - personne.setIdCarte("15245698547856"); | ||
72 | - personne.setLoginPoly("bverhaeg"); | 69 | + personne.setCarte("15245698547856"); |
70 | + personne.setLogin("bverhaeg"); | ||
73 | personne.setNaissance(new Date(System.currentTimeMillis())); | 71 | personne.setNaissance(new Date(System.currentTimeMillis())); |
74 | personne.setSolde(45); | 72 | personne.setSolde(45); |
75 | personne.setRole(r); | 73 | personne.setRole(r); |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Personne.java
@@ -3,42 +3,40 @@ package net.plil.clubinfo.etunicorn.data; | @@ -3,42 +3,40 @@ package net.plil.clubinfo.etunicorn.data; | ||
3 | 3 | ||
4 | import java.io.Serializable; | 4 | import java.io.Serializable; |
5 | import java.sql.Date; | 5 | import java.sql.Date; |
6 | -import java.util.ArrayList; | ||
7 | -import java.util.List; | ||
8 | 6 | ||
9 | public class Personne implements Serializable{ | 7 | public class Personne implements Serializable{ |
10 | - private int idPersonne; | ||
11 | - private String idCarte; | 8 | + private int id; |
9 | + private String carte; | ||
12 | private Date naissance; | 10 | private Date naissance; |
13 | private double solde = 0; | 11 | private double solde = 0; |
14 | - private String loginPoly; | ||
15 | - private Role role = new Role(); | 12 | + private String login; |
13 | + private Role role; | ||
16 | 14 | ||
17 | public Personne() { | 15 | public Personne() { |
18 | } | 16 | } |
19 | 17 | ||
20 | - public Role getRole() { | ||
21 | - return role; | 18 | + public int getId() { |
19 | + return id; | ||
22 | } | 20 | } |
23 | 21 | ||
24 | - public void setRole(Role role) { | ||
25 | - this.role = role; | 22 | + public void setId(int id) { |
23 | + this.id = id; | ||
26 | } | 24 | } |
27 | 25 | ||
28 | - public int getIdPersonne() { | ||
29 | - return idPersonne; | 26 | + public Role getRole() { |
27 | + return role; | ||
30 | } | 28 | } |
31 | 29 | ||
32 | - public void setIdPersonne(int idPersonne) { | ||
33 | - this.idPersonne = idPersonne; | 30 | + public void setRole(Role role) { |
31 | + this.role = role; | ||
34 | } | 32 | } |
35 | 33 | ||
36 | - public String getIdCarte() { | ||
37 | - return idCarte; | 34 | + public String getCarte() { |
35 | + return carte; | ||
38 | } | 36 | } |
39 | 37 | ||
40 | - public void setIdCarte(String idCarte) { | ||
41 | - this.idCarte = idCarte; | 38 | + public void setCarte(String carte) { |
39 | + this.carte = carte; | ||
42 | } | 40 | } |
43 | 41 | ||
44 | public Date getNaissance() { | 42 | public Date getNaissance() { |
@@ -57,11 +55,11 @@ public class Personne implements Serializable{ | @@ -57,11 +55,11 @@ public class Personne implements Serializable{ | ||
57 | this.solde = solde; | 55 | this.solde = solde; |
58 | } | 56 | } |
59 | 57 | ||
60 | - public String getLoginPoly() { | ||
61 | - return loginPoly; | 58 | + public String getLogin() { |
59 | + return login; | ||
62 | } | 60 | } |
63 | 61 | ||
64 | - public void setLoginPoly(String loginPoly) { | ||
65 | - this.loginPoly = loginPoly; | 62 | + public void setLogin(String login) { |
63 | + this.login = login; | ||
66 | } | 64 | } |
67 | } | 65 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Role.java
@@ -9,17 +9,17 @@ import java.util.List; | @@ -9,17 +9,17 @@ import java.util.List; | ||
9 | */ | 9 | */ |
10 | public class Role implements Serializable{ | 10 | public class Role implements Serializable{ |
11 | private List<Permission> permissions = new ArrayList<>(); | 11 | private List<Permission> permissions = new ArrayList<>(); |
12 | - private String name; | 12 | + private String nom; |
13 | 13 | ||
14 | public Role() { | 14 | public Role() { |
15 | } | 15 | } |
16 | 16 | ||
17 | - public String getName() { | ||
18 | - return name; | 17 | + public String getNom() { |
18 | + return nom; | ||
19 | } | 19 | } |
20 | 20 | ||
21 | - public void setName(String name) { | ||
22 | - this.name = name; | 21 | + public void setNom(String nom) { |
22 | + this.nom = nom; | ||
23 | } | 23 | } |
24 | 24 | ||
25 | public List<Permission> getPermissions() { | 25 | public List<Permission> getPermissions() { |
@@ -32,6 +32,6 @@ public class Role implements Serializable{ | @@ -32,6 +32,6 @@ public class Role implements Serializable{ | ||
32 | 32 | ||
33 | @Override | 33 | @Override |
34 | public String toString(){ | 34 | public String toString(){ |
35 | - return getName(); | 35 | + return getNom(); |
36 | } | 36 | } |
37 | } | 37 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/data/Session.java
0 → 100644
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.data; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import java.util.Date; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by badetitou on 05/02/2017. | ||
8 | + */ | ||
9 | + | ||
10 | +public class Session implements Serializable { | ||
11 | + | ||
12 | + private static final int SESSION_DURATION = 10 * 60; | ||
13 | + private Personne personne; | ||
14 | + private String token; | ||
15 | + private Date validity; | ||
16 | + | ||
17 | + | ||
18 | + public Session() { | ||
19 | + } | ||
20 | + | ||
21 | + public Personne getPersonne() { | ||
22 | + return personne; | ||
23 | + } | ||
24 | + | ||
25 | + public void setPersonne(Personne personne) { | ||
26 | + this.personne = personne; | ||
27 | + } | ||
28 | + | ||
29 | + public String getToken() { | ||
30 | + return token; | ||
31 | + } | ||
32 | + | ||
33 | + public void setToken(String token) { | ||
34 | + this.token = token; | ||
35 | + } | ||
36 | + | ||
37 | + public Date getValidity() { | ||
38 | + return validity; | ||
39 | + } | ||
40 | + | ||
41 | + public void setValidity(Date validity) { | ||
42 | + this.validity = validity; | ||
43 | + } | ||
44 | + | ||
45 | +} |
app/src/main/java/net/plil/clubinfo/etunicorn/data/User.java
@@ -5,18 +5,18 @@ package net.plil.clubinfo.etunicorn.data; | @@ -5,18 +5,18 @@ package net.plil.clubinfo.etunicorn.data; | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | public class User { | 7 | public class User { |
8 | - private String username; | 8 | + private String login; |
9 | private String password; | 9 | private String password; |
10 | 10 | ||
11 | public User() { | 11 | public User() { |
12 | } | 12 | } |
13 | 13 | ||
14 | - public String getUsername() { | ||
15 | - return username; | 14 | + public String getLogin() { |
15 | + return login; | ||
16 | } | 16 | } |
17 | 17 | ||
18 | - public void setUsername(String username) { | ||
19 | - this.username = username; | 18 | + public void setLogin(String login) { |
19 | + this.login = login; | ||
20 | } | 20 | } |
21 | 21 | ||
22 | public String getPassword() { | 22 | public String getPassword() { |
app/src/main/java/net/plil/clubinfo/etunicorn/utils/ConvertBytesToString.java
1 | package net.plil.clubinfo.etunicorn.utils; | 1 | package net.plil.clubinfo.etunicorn.utils; |
2 | 2 | ||
3 | +import java.io.UnsupportedEncodingException; | ||
4 | + | ||
3 | /** | 5 | /** |
4 | * Created by badetitou on 04/02/2017. | 6 | * Created by badetitou on 04/02/2017. |
5 | */ | 7 | */ |
@@ -23,4 +25,12 @@ public class ConvertBytesToString { | @@ -23,4 +25,12 @@ public class ConvertBytesToString { | ||
23 | return stringBuilder.toString(); | 25 | return stringBuilder.toString(); |
24 | } | 26 | } |
25 | 27 | ||
28 | + public static String bytesToStringVolLey(byte[] bytes){ | ||
29 | + try { | ||
30 | + return new String(bytes, "UTF-8"); | ||
31 | + } catch (UnsupportedEncodingException e) { | ||
32 | + return "Can't read error"; | ||
33 | + } | ||
34 | + } | ||
35 | + | ||
26 | } | 36 | } |
app/src/main/java/net/plil/clubinfo/etunicorn/utils/JsonCoverter.java
0 → 100644
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +package net.plil.clubinfo.etunicorn.utils; | ||
2 | + | ||
3 | +import com.google.gson.Gson; | ||
4 | +import com.google.gson.GsonBuilder; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by badetitou on 05/02/2017. | ||
8 | + */ | ||
9 | + | ||
10 | +public class JsonCoverter { | ||
11 | + | ||
12 | + private static Gson gson; | ||
13 | + | ||
14 | + public static Gson getConverter(){ | ||
15 | + if (gson != null) | ||
16 | + return gson; | ||
17 | + | ||
18 | + gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); | ||
19 | + return gson; | ||
20 | + } | ||
21 | +} |
app/src/main/res/values-fr/strings.xml
@@ -41,13 +41,13 @@ | @@ -41,13 +41,13 @@ | ||
41 | <string name="create_personne_naissance">Date de naissance</string> | 41 | <string name="create_personne_naissance">Date de naissance</string> |
42 | <string name="create_personne_role">Role</string> | 42 | <string name="create_personne_role">Role</string> |
43 | <string name="error_enter_debit">Veuillez entrer une valeur avant d\'utiliser la carte NFC</string> | 43 | <string name="error_enter_debit">Veuillez entrer une valeur avant d\'utiliser la carte NFC</string> |
44 | - <string name="error_create_consomation_input_nom">Entrer le nom</string> | 44 | + <string name="error_create_consomation_input_nom">Entrer le name</string> |
45 | <string name="error_create_consomation_input_price">Entrer le prix</string> | 45 | <string name="error_create_consomation_input_price">Entrer le prix</string> |
46 | <string name="create_event_date_input">Date</string> | 46 | <string name="create_event_date_input">Date</string> |
47 | <string name="error_create_event_date">Entrer la date</string> | 47 | <string name="error_create_event_date">Entrer la date</string> |
48 | - <string name="error_create_event_input_nom">Entrer le nom</string> | 48 | + <string name="error_create_event_input_nom">Entrer le name</string> |
49 | <string name="error_create_event_input_price">Entrer le prix</string> | 49 | <string name="error_create_event_input_price">Entrer le prix</string> |
50 | - <string name="error_modify_consommation_input_nom">Entrer le nouveau nom</string> | 50 | + <string name="error_modify_consommation_input_nom">Entrer le nouveau name</string> |
51 | <string name="error_modify_consommation_input_price">Entrer le nouveau prix</string> | 51 | <string name="error_modify_consommation_input_price">Entrer le nouveau prix</string> |
52 | <string name="modify_consomation_hint_name">Nom</string> | 52 | <string name="modify_consomation_hint_name">Nom</string> |
53 | <string name="modify_consomation_hint_price">Prix</string> | 53 | <string name="modify_consomation_hint_price">Prix</string> |