Commit 520cecde3e41b36d77916108faa96e757c0cd27d
1 parent
93f90e35
Un petit plus, un peu plus de requete HTTP
Mais on a des problemes de clavier qui se montre pas
Showing
19 changed files
with
587 additions
and
72 deletions
Show diff stats
PremiereActivite/.idea/inspectionProfiles/Project_Default.xml
1 | 1 | <component name="InspectionProjectProfileManager"> |
2 | 2 | <profile version="1.0"> |
3 | 3 | <option name="myName" value="Project Default" /> |
4 | + <inspection_tool class="AndroidLintDeprecated" enabled="false" level="WARNING" enabled_by_default="false" /> | |
4 | 5 | <inspection_tool class="AndroidLintPrivateResource" enabled="false" level="WARNING" enabled_by_default="false" /> |
6 | + <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false"> | |
7 | + <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" /> | |
8 | + <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" /> | |
9 | + </inspection_tool> | |
5 | 10 | </profile> |
6 | 11 | </component> |
7 | 12 | \ No newline at end of file | ... | ... |
PremiereActivite/app/build.gradle
PremiereActivite/app/src/main/AndroidManifest.xml
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | |
5 | 5 | <!-- Nécessaire pour utiliser les cartes NFC --> |
6 | 6 | <uses-permission android:name="android.permission.NFC" /> |
7 | + <uses-permission android:name="android.permission.INTERNET" /> | |
7 | 8 | <uses-sdk android:minSdkVersion="20"/> |
8 | 9 | <uses-feature android:name="android.hardware.nfc" android:required="true" /> |
9 | 10 | ... | ... |
PremiereActivite/app/src/main/java/com/example/app_10p5/ASyncResponse.java
0 → 100644
PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java
... | ... | @@ -9,20 +9,56 @@ import android.nfc.tech.MifareClassic; |
9 | 9 | import android.os.Bundle; |
10 | 10 | import android.widget.Toast; |
11 | 11 | |
12 | +import org.json.JSONObject; | |
13 | + | |
12 | 14 | import java.io.IOException; |
15 | +import java.net.URL; | |
16 | +import java.util.HashMap; | |
13 | 17 | |
14 | 18 | /** |
15 | 19 | * Created by beaus on 24/04/2016. |
16 | 20 | */ |
17 | -public class CarteActivite extends Activity { | |
21 | +public class CarteActivite extends Activity implements ASyncResponse { | |
18 | 22 | |
19 | 23 | private NfcAdapter mNfcAdapter; |
24 | + private HashMap<String, String> mParam; | |
25 | + private String mAPI; | |
26 | + | |
27 | + public static final String HOST = "https://10p5.clubinfo.frogeye.fr/"; | |
20 | 28 | |
21 | 29 | @Override |
22 | 30 | protected void onCreate(Bundle savedInstanceState) { |
23 | 31 | super.onCreate(savedInstanceState); |
24 | 32 | setContentView(R.layout.layout_carte); |
25 | 33 | |
34 | + switch (getIntent().getIntExtra("state", MainActivite.STATE_RIEN)) { | |
35 | + | |
36 | + case MainActivite.STATE_COMMANDE: | |
37 | + mParam.put("quantite", String.valueOf(getIntent().getIntExtra("quantite", -1))); | |
38 | + mParam.put("montant", String.valueOf(getIntent().getFloatExtra("montant", -1))); | |
39 | + mParam.put("token", getIntent().getStringExtra("token")); | |
40 | + mAPI = "api/client/payer"; | |
41 | + break; | |
42 | + case MainActivite.STATE_CREATION_COMPTE: | |
43 | + //TODO: param | |
44 | + mAPI = "api/client/ajouter"; | |
45 | + break; | |
46 | + case MainActivite.STATE_RECHARGEMENT: | |
47 | + //TODO: param | |
48 | + mAPI = "api/client/recharger"; | |
49 | + break; | |
50 | + case MainActivite.STATE_VIDANGE: | |
51 | + //TODO: param | |
52 | + mAPI = "api/client/vidange"; | |
53 | + break; | |
54 | + case MainActivite.STATE_CONNEXION: | |
55 | + case MainActivite.STATE_RIEN: | |
56 | + default: | |
57 | + Toast.makeText(this, "WTF, le cancer est dans l'application!!", Toast.LENGTH_LONG).show(); | |
58 | + finish(); | |
59 | + return; | |
60 | + } | |
61 | + | |
26 | 62 | mNfcAdapter = NfcAdapter.getDefaultAdapter(this); |
27 | 63 | |
28 | 64 | if (mNfcAdapter == null) { |
... | ... | @@ -62,11 +98,6 @@ public class CarteActivite extends Activity { |
62 | 98 | handleIntent(intent); |
63 | 99 | } |
64 | 100 | |
65 | - public void taFonction(String id_carte, String login) | |
66 | - { | |
67 | - //code fonction | |
68 | - } | |
69 | - | |
70 | 101 | @Override |
71 | 102 | protected void onPause() { |
72 | 103 | stopForegroundDispatch(this, mNfcAdapter); |
... | ... | @@ -77,6 +108,7 @@ public class CarteActivite extends Activity { |
77 | 108 | if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { |
78 | 109 | Toast toast; |
79 | 110 | String id_carte = ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID)); |
111 | + mParam.put("ID", id_carte); | |
80 | 112 | toast = Toast.makeText(getApplicationContext(), "ID Carte : " + id_carte, Toast.LENGTH_SHORT); |
81 | 113 | toast.show(); |
82 | 114 | |
... | ... | @@ -137,9 +169,9 @@ public class CarteActivite extends Activity { |
137 | 169 | toast.show(); |
138 | 170 | |
139 | 171 | //Éxécution de la fonction |
140 | - taFonction(id_carte, login); | |
172 | + clientAPI(); | |
173 | + } | |
141 | 174 | } |
142 | - } | |
143 | 175 | |
144 | 176 | public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter){ |
145 | 177 | final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); |
... | ... | @@ -151,4 +183,24 @@ public class CarteActivite extends Activity { |
151 | 183 | public static void stopForegroundDispatch(final Activity activity, NfcAdapter adapter) { |
152 | 184 | adapter.disableForegroundDispatch(activity); |
153 | 185 | } |
186 | + | |
187 | + public void clientAPI() { | |
188 | + try { | |
189 | + URL url = new URL(HOST + mAPI); | |
190 | + NetworkThread nt = new NetworkThread(url, mParam); | |
191 | + nt.execute(); | |
192 | + } | |
193 | + catch (Throwable t){ | |
194 | + Toast.makeText(this, "WTF, le cancer est dans l'application!!", Toast.LENGTH_LONG).show(); | |
195 | + finish(); | |
196 | + return; | |
197 | + } | |
198 | + } | |
199 | + | |
200 | + | |
201 | + /* Retour du NetworkThread */ | |
202 | + @Override | |
203 | + public void processFinish(JSONObject output) { | |
204 | + //TODO: faire un retour vers l'activity parente des données reçues. | |
205 | + } | |
154 | 206 | } | ... | ... |
PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java
1 | 1 | package com.example.app_10p5; |
2 | 2 | |
3 | -import android.app.PendingIntent; | |
4 | 3 | import android.content.Intent; |
5 | -import android.content.IntentFilter; | |
6 | -import android.nfc.NfcAdapter; | |
7 | -import android.nfc.Tag; | |
8 | -import android.nfc.tech.MifareClassic; | |
9 | -import android.nfc.tech.NfcA; | |
10 | 4 | import android.os.Bundle; |
11 | 5 | import android.support.design.widget.TabLayout; |
12 | 6 | import android.support.v4.app.FragmentActivity; |
13 | -import android.support.v4.app.FragmentManager; | |
14 | -import android.support.v4.app.Fragment; | |
15 | 7 | import android.support.v4.view.ViewPager; |
16 | 8 | import android.view.View; |
9 | +import android.widget.EditText; | |
17 | 10 | import android.widget.Toast; |
18 | 11 | |
19 | -import java.io.IOException; | |
20 | 12 | |
21 | 13 | /** |
22 | 14 | * Created by beaus on 24/04/2016. |
23 | 15 | */ |
24 | 16 | public class MainActivite extends FragmentActivity { |
25 | 17 | |
18 | + public static final int STATE_RIEN = 0; | |
19 | + public static final int STATE_COMMANDE = 3; | |
20 | + public static final int STATE_VIDANGE = 4; | |
21 | + public static final int STATE_RECHARGEMENT = 2; | |
22 | + public static final int STATE_CREATION_COMPTE = 1; | |
23 | + public static final int STATE_CONNEXION = 5; | |
24 | + public static final long EXPIRATION = 1000*60*10; | |
25 | + | |
26 | + private int mState; | |
27 | + private String mToken; | |
28 | + private long mTimeToken; | |
29 | + | |
26 | 30 | @Override |
27 | 31 | protected void onCreate(Bundle savedInstanceState){ |
28 | 32 | super.onCreate(savedInstanceState); |
29 | 33 | setContentView(R.layout.layout_main); |
34 | + | |
35 | + mState = STATE_RIEN; | |
36 | + mTimeToken = -1; | |
37 | + mToken = ""; | |
38 | + | |
30 | 39 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); |
31 | 40 | tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); |
41 | + tabLayout.addTab(tabLayout.newTab().setText("Connexion")); | |
32 | 42 | tabLayout.addTab(tabLayout.newTab().setText("Commande")); |
33 | 43 | tabLayout.addTab(tabLayout.newTab().setText("Rechargement")); |
34 | 44 | tabLayout.addTab(tabLayout.newTab().setText("Création")); |
35 | 45 | tabLayout.addTab(tabLayout.newTab().setText("Vidange")); |
36 | - tabLayout.addTab(tabLayout.newTab().setText("Admin")); | |
37 | 46 | tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); |
38 | 47 | |
39 | 48 | final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); |
... | ... | @@ -44,7 +53,14 @@ public class MainActivite extends FragmentActivity { |
44 | 53 | tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { |
45 | 54 | @Override |
46 | 55 | public void onTabSelected(TabLayout.Tab tab) { |
47 | - viewPager.setCurrentItem(tab.getPosition()); | |
56 | + if(mToken != "" && System.currentTimeMillis() - mTimeToken < EXPIRATION){ | |
57 | + viewPager.setCurrentItem(tab.getPosition()); | |
58 | + } | |
59 | + else{ | |
60 | + viewPager.setCurrentItem(tab.getPosition()); //Empeche un bug graphique | |
61 | + viewPager.setCurrentItem(0); | |
62 | + Toast.makeText(MainActivite.this, "Veuillez vous connecter.", Toast.LENGTH_LONG).show(); | |
63 | + } | |
48 | 64 | } |
49 | 65 | |
50 | 66 | @Override |
... | ... | @@ -61,8 +77,78 @@ public class MainActivite extends FragmentActivity { |
61 | 77 | |
62 | 78 | public void valideCommande(View v) |
63 | 79 | { |
64 | - Intent intent = new Intent(this, CarteActivite.class); | |
65 | - startActivity(intent); | |
80 | + if((mToken != "") && ((System.currentTimeMillis() - mTimeToken) < EXPIRATION)) { | |
81 | + EditText champMontant = (EditText) findViewById(R.id.commande_prix); | |
82 | + EditText champQuantite = (EditText) findViewById(R.id.commande_quantite); | |
83 | + float montant = Float.parseFloat(champMontant.getText().toString()); | |
84 | + int quantite = Integer.parseInt(champQuantite.getText().toString()); | |
85 | + | |
86 | + if ((montant > 0.0) && (montant < 200.0)) { | |
87 | + mState = STATE_COMMANDE; | |
88 | + Intent intent = new Intent(this, CarteActivite.class); | |
89 | + intent.putExtra("token", mToken); | |
90 | + intent.putExtra("state", mState); | |
91 | + intent.putExtra("montant", montant); | |
92 | + intent.putExtra("quantite", quantite); | |
93 | + startActivityForResult(intent, mState); | |
94 | + } | |
95 | + } | |
96 | + else{ | |
97 | + Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
98 | + final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
99 | + viewPager.setCurrentItem(0); | |
100 | + } | |
101 | + } | |
102 | + | |
103 | + public void valideRechargement(View v) | |
104 | + { | |
105 | + if((mToken != "") && ((System.currentTimeMillis() - mTimeToken) > 0)) { | |
106 | + | |
107 | + } | |
108 | + else{ | |
109 | + Toast.makeText(this, "Veuillez vous reconnecter.", Toast.LENGTH_LONG).show(); | |
110 | + final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
111 | + viewPager.setCurrentItem(0); | |
112 | + } | |
113 | + } | |
114 | + | |
115 | + public void valideConnection(View v) | |
116 | + { | |
117 | + EditText viewUser = (EditText) findViewById(R.id.connection_username); | |
118 | + EditText viewPsw = (EditText) findViewById(R.id.connection_password); | |
119 | + | |
120 | + String user = viewUser.toString(); | |
121 | + String password = viewPsw.toString(); | |
122 | + | |
123 | + if ((user != "") && (password != "")) { | |
124 | + mState = STATE_CONNEXION; | |
125 | + Intent intent = new Intent(this, CarteActivite.class); | |
126 | + intent.putExtra("user", user); | |
127 | + intent.putExtra("state", mState); | |
128 | + intent.putExtra("password", password); | |
129 | + startActivityForResult(intent, mState); | |
130 | + } | |
131 | + } | |
132 | + | |
133 | + @Override | |
134 | + protected void onActivityResult(int requestCode, int resultCode, Intent data){ | |
135 | + //TODO: faire des choses avec ca | |
136 | + switch (requestCode) { | |
137 | + case STATE_COMMANDE: | |
138 | + break; | |
139 | + case STATE_CONNEXION: | |
140 | + break; | |
141 | + case STATE_CREATION_COMPTE: | |
142 | + break; | |
143 | + case STATE_RECHARGEMENT: | |
144 | + break; | |
145 | + case STATE_VIDANGE: | |
146 | + break; | |
147 | + case STATE_RIEN: | |
148 | + default: | |
149 | + Toast.makeText(this, "WTF, le cancer est dans l'application!!", Toast.LENGTH_LONG).show(); | |
150 | + break; | |
151 | + } | |
66 | 152 | } |
67 | 153 | |
68 | 154 | } | ... | ... |
PremiereActivite/app/src/main/java/com/example/app_10p5/NetworkThread.java
0 → 100644
... | ... | @@ -0,0 +1,95 @@ |
1 | +package com.example.app_10p5; | |
2 | + | |
3 | +import android.os.AsyncTask; | |
4 | + | |
5 | +import org.json.JSONObject; | |
6 | + | |
7 | +import java.io.BufferedReader; | |
8 | +import java.io.InputStreamReader; | |
9 | +import java.io.OutputStreamWriter; | |
10 | +import java.net.HttpURLConnection; | |
11 | +import java.net.URL; | |
12 | +import java.util.HashMap; | |
13 | +import java.util.Map; | |
14 | + | |
15 | +import javax.net.ssl.HttpsURLConnection; | |
16 | + | |
17 | +/** | |
18 | + * Created by beaus on 30/04/2016. | |
19 | + */ | |
20 | +public class NetworkThread extends AsyncTask<Void, Void, JSONObject> { | |
21 | + public ASyncResponse delegate = null; | |
22 | + private URL mUrl; | |
23 | + private HashMap<String, String> mParam; | |
24 | + | |
25 | + NetworkThread(URL url, HashMap<String, String> param){ | |
26 | + | |
27 | + mUrl = url; | |
28 | + mParam = param; | |
29 | + } | |
30 | + | |
31 | + @Override | |
32 | + protected void onPreExecute() { | |
33 | + /** | |
34 | + * show dialog | |
35 | + */ | |
36 | + super.onPreExecute(); | |
37 | + } | |
38 | + | |
39 | + @Override | |
40 | + protected JSONObject doInBackground(Void ... params) { | |
41 | + | |
42 | + /** | |
43 | + * Do network related stuff | |
44 | + * return string response. | |
45 | + */ | |
46 | + | |
47 | + JSONObject json = new JSONObject(); | |
48 | + try { | |
49 | + HttpURLConnection httpCo = (HttpURLConnection) mUrl.openConnection(); | |
50 | + httpCo.setDoOutput(true); | |
51 | + | |
52 | + httpCo.connect(); | |
53 | + | |
54 | + OutputStreamWriter wr = new OutputStreamWriter(httpCo.getOutputStream()); | |
55 | + for (Map.Entry<String, String> entry : mParam.entrySet()) { | |
56 | + String key = entry.getKey(); | |
57 | + String value = entry.getValue(); | |
58 | + wr.write(key + "=" + value); | |
59 | + } | |
60 | + wr.flush(); | |
61 | + | |
62 | + String response = ""; | |
63 | + | |
64 | + if (httpCo.getResponseCode() == HttpsURLConnection.HTTP_OK) { | |
65 | + String line; | |
66 | + BufferedReader br = new BufferedReader(new InputStreamReader(httpCo.getInputStream())); | |
67 | + while ((line = br.readLine()) != null) { | |
68 | + response += line; | |
69 | + } | |
70 | + } else { | |
71 | + response = "Erreur"; | |
72 | + } | |
73 | + | |
74 | + json = new JSONObject(response); | |
75 | + | |
76 | + System.out.println(json.getString("status")); | |
77 | + | |
78 | + httpCo.disconnect(); | |
79 | + } catch (Throwable e) { | |
80 | + System.out.println(e.toString()); | |
81 | + } | |
82 | + | |
83 | + return json; | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + protected void onPostExecute(JSONObject result) { | |
88 | + | |
89 | + /** | |
90 | + * update ui thread and remove dialog | |
91 | + */ | |
92 | + super.onPostExecute(result); | |
93 | + delegate.processFinish(result); | |
94 | + } | |
95 | +} | |
0 | 96 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/java/com/example/app_10p5/fonction_API_client.java
0 → 100644
... | ... | @@ -0,0 +1,230 @@ |
1 | + | |
2 | +/* | |
3 | + | |
4 | +public JSON client_ajouter(String logiLille1,String soldeini, String IdCarte, String decouvert){ | |
5 | + try{ | |
6 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/client/ajouter"); | |
7 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
8 | + postParameters.add(new BasicNameValuePair("loginLille1", loginLille1)); | |
9 | + postParameters.add(new BasicNameValuePair("soldeInitial",soldeini)); | |
10 | + postParameters.add(new BasicNameValuePair("idCarte", IdCarte)); | |
11 | + postParameters.add(new BasicNameValuePair("decouvertAutorise",decouvert)); | |
12 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
13 | + | |
14 | + HttpClient httpclient = new DefaultHttpClient(); | |
15 | + HttpResponse responce = httpclient.execute(httppost); | |
16 | + return(responce); | |
17 | + } | |
18 | + catch(Exception e) {} | |
19 | +} | |
20 | + | |
21 | + | |
22 | +public void client_carte(String logiLille1,String newIdCarte){ | |
23 | + try{ | |
24 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/client/carte"); | |
25 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
26 | + postParameters.add(new BasicNameValuePair("loginLille1", loginLille1)); | |
27 | + postParameters.add(new BasicNameValuePair("idCarte",newIdCarte)); | |
28 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
29 | + | |
30 | + HttpClient httpclient = new DefaultHttpClient(); | |
31 | + HttpResponse responce = httpclient.execute(httppost); | |
32 | + } | |
33 | + catch(Exception e) {} | |
34 | +} | |
35 | + | |
36 | +public JSON client_liste(){ | |
37 | + try{ | |
38 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/client/liste"); | |
39 | + | |
40 | + HttpClient httpclient = new DefaultHttpClient(); | |
41 | + HttpResponse responce = httpclient.execute(httppost); | |
42 | + return(responce); | |
43 | + } | |
44 | + catch(Exception e) {} | |
45 | +} | |
46 | + | |
47 | + | |
48 | +public void client_decouvert(String idCarte,String newDecouvertAutorise){ | |
49 | + try{ | |
50 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/client/decouvert"); | |
51 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
52 | + postParameters.add(new BasicNameValuePair("idCarte",idCarte)); | |
53 | + postParameters.add(new BasicNameValuePair("decouvertAutorise", newDecouvertAutorise)); | |
54 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
55 | + | |
56 | + HttpClient httpclient = new DefaultHttpClient(); | |
57 | + httpclient.execute(httppost); | |
58 | + } | |
59 | + catch(Exception e) {} | |
60 | +} | |
61 | + | |
62 | + | |
63 | +public JSON utilisateur_connexion(String login, String mdp, String idCarte, String loginLille1){ | |
64 | + try{ | |
65 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/connexion"); | |
66 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
67 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
68 | + postParameters.add(new BasicNameValuePair("mdp",mdp)); | |
69 | + postParameters.add(new BasicNameValuePair("idCarte",idCarte)); | |
70 | + postParameters.add(new BasicNameValuePair("loginLille1", loginLille1)); | |
71 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
72 | + | |
73 | + HttpClient httpclient = new DefaultHttpClient(); | |
74 | + HttpResponse responce = httpclient.execute(httppost); | |
75 | + return(responce); | |
76 | + } | |
77 | + catch(Exception e) {} | |
78 | +} | |
79 | + | |
80 | +public void utilisateur_deconnexion(){ | |
81 | + try{ | |
82 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/deconnexion"); | |
83 | + | |
84 | + HttpClient httpclient = new DefaultHttpClient(); | |
85 | + httpclient.execute(httppost); | |
86 | + } | |
87 | + catch(Exception e) {} | |
88 | +} | |
89 | + | |
90 | + | |
91 | +public void utilisateur_mdp(String login, String newmdp){ | |
92 | + try{ | |
93 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/mdp"); | |
94 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
95 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
96 | + postParameters.add(new BasicNameValuePair("mdp",newmdp)); | |
97 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
98 | + | |
99 | + HttpClient httpclient = new DefaultHttpClient(); | |
100 | + httpclient.execute(httppost); | |
101 | + } | |
102 | + catch(Exception e) {} | |
103 | +} | |
104 | + | |
105 | + | |
106 | +public void utilisateur_droit(String login, String newdroit){ | |
107 | + try{ | |
108 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/droit"); | |
109 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
110 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
111 | + postParameters.add(new BasicNameValuePair("niveau de droit",newdroit)); | |
112 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
113 | + | |
114 | + HttpClient httpclient = new DefaultHttpClient(); | |
115 | + httpclient.execute(httppost); | |
116 | + } | |
117 | + catch(Exception e) {} | |
118 | +} | |
119 | + | |
120 | +public void utilisateur_ajouter(String login, String mdp, String loginLille1, String idCarte, String droit){ | |
121 | + try{ | |
122 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/ajouter"); | |
123 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
124 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
125 | + postParameters.add(new BasicNameValuePair("mdp",mdp)); | |
126 | + postParameters.add(new BasicNameValuePair("loginLille1", loginLille1)); | |
127 | + postParameters.add(new BasicNameValuePair("idCarte",IdCarte)); | |
128 | + postParameters.add(new BasicNameValuePair("niveau de droit",droit)); | |
129 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
130 | + | |
131 | + HttpClient httpclient = new DefaultHttpClient(); | |
132 | + httpclient.execute(httppost); | |
133 | + } | |
134 | + catch(Exception e) {} | |
135 | +} | |
136 | + | |
137 | + | |
138 | + | |
139 | +public void utilisateur_carte(String login, String loginLille1, String idCarte){ | |
140 | + try{ | |
141 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/carte"); | |
142 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
143 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
144 | + postParameters.add(new BasicNameValuePair("loginLille1", loginLille1)); | |
145 | + postParameters.add(new BasicNameValuePair("idCarte",newIdCarte)); | |
146 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
147 | + | |
148 | + HttpClient httpclient = new DefaultHttpClient(); | |
149 | + httpclient.execute(httppost); | |
150 | + } | |
151 | + catch(Exception e) {} | |
152 | +} | |
153 | + | |
154 | + | |
155 | +public void utilisateur_supprimer(String login){ | |
156 | + try{ | |
157 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/utilisateur/carte"); | |
158 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
159 | + postParameters.add(new BasicNameValuePair("login",idCarte)); | |
160 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
161 | + | |
162 | + HttpClient httpclient = new DefaultHttpClient(); | |
163 | + httpclient.execute(httppost); | |
164 | + } | |
165 | + catch(Exception e) {} | |
166 | +} | |
167 | + | |
168 | + | |
169 | +public JSON transaction_rechargement(String idCarte, String montant){ | |
170 | + try{ | |
171 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/transaction/rechargement"); | |
172 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
173 | + postParameters.add(new BasicNameValuePair("idCarte",idCarte)); | |
174 | + postParameters.add(new BasicNameValuePair("montant",montant)); | |
175 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
176 | + | |
177 | + HttpClient httpclient = new DefaultHttpClient(); | |
178 | + HttpResponse responce = httpclient.execute(httppost); | |
179 | + return(responce); | |
180 | + } | |
181 | + catch(Exception e) {} | |
182 | +} | |
183 | + | |
184 | + | |
185 | +public JSON transaction_paiementt(String idCarte, String montant, String nbConso){ | |
186 | + try{ | |
187 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/transaction/paiement"); | |
188 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
189 | + postParameters.add(new BasicNameValuePair("idCarte",idCarte)); | |
190 | + postParameters.add(new BasicNameValuePair("montant",montant)); | |
191 | + postParameters.add(new BasicNameValuePair("qte",nbConso)); | |
192 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
193 | + | |
194 | + HttpClient httpclient = new DefaultHttpClient(); | |
195 | + HttpResponse responce = httpclient.execute(httppost); | |
196 | + return(responce); | |
197 | + } | |
198 | + catch(Exception e) {} | |
199 | +} | |
200 | + | |
201 | + | |
202 | + | |
203 | +public JSON transaction_vidange(String idCarte){ | |
204 | + try{ | |
205 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/transaction/vidange"); | |
206 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
207 | + postParameters.add(new BasicNameValuePair("idCarte",idCarte)); | |
208 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
209 | + | |
210 | + HttpClient httpclient = new DefaultHttpClient(); | |
211 | + HttpResponse responce = httpclient.execute(httppost); | |
212 | + return(responce); | |
213 | + } | |
214 | + catch(Exception e) {} | |
215 | +} | |
216 | + | |
217 | + | |
218 | +public void transaction_annuler(String idTransac){ | |
219 | + try{ | |
220 | + Httppost httpost = new HttpPost("10p5.clubinfo.frogeye.fr/api/transaction/annuler"); | |
221 | + List<NameValuePair> postParameters = new ArrayList>NameValuePair>(); | |
222 | + postParameters.add(new BasicNameValuePair("id",idTransac)); | |
223 | + httppost.setEntity(new UrlEncodedFormEntity(postParameters)); | |
224 | + | |
225 | + HttpClient httpclient = new DefaultHttpClient(); | |
226 | + httpclient.execute(httppost); | |
227 | + } | |
228 | + catch(Exception e) {} | |
229 | +} | |
230 | +*/ | |
0 | 231 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/res/layout/layout_commande.xml renamed to PremiereActivite/app/src/main/res/layout-v23/layout_commande.xml
... | ... | @@ -12,57 +12,55 @@ |
12 | 12 | android:layout_height="wrap_content" |
13 | 13 | android:inputType="number" |
14 | 14 | android:ems="15" |
15 | - android:id="@+id/nb" | |
15 | + android:id="@+id/commande_quantite" | |
16 | 16 | android:editable="true" |
17 | 17 | android:elegantTextHeight="true" |
18 | 18 | android:enabled="true" |
19 | - android:focusableInTouchMode="true" | |
20 | - android:focusable="true" | |
21 | 19 | android:numeric="integer" |
22 | 20 | android:width="300dp" |
23 | 21 | android:hint="@string/quant" |
24 | 22 | android:textAlignment="center" |
25 | 23 | android:layout_gravity="center_horizontal" |
26 | 24 | android:layout_marginTop="30dp" |
27 | - android:allowUndo="false" | |
28 | 25 | android:height="150dp" |
29 | - android:minHeight="30dp" | |
26 | + android:minHeight="50dp" | |
30 | 27 | android:maxHeight="500dp" |
31 | 28 | android:minWidth="120dp" |
32 | - android:layout_weight="0.04" /> | |
29 | + android:textIsSelectable="true" /> | |
33 | 30 | |
34 | 31 | <EditText |
35 | 32 | android:layout_width="wrap_content" |
36 | - android:layout_height="58dp" | |
33 | + android:layout_height="wrap_content" | |
37 | 34 | android:inputType="number" |
38 | 35 | android:ems="10" |
39 | - android:id="@+id/editText2" | |
36 | + android:id="@+id/commande_prix" | |
40 | 37 | android:editable="true" |
41 | 38 | android:elegantTextHeight="true" |
42 | 39 | android:enabled="true" |
43 | - android:focusableInTouchMode="true" | |
44 | - android:focusable="true" | |
45 | 40 | android:numeric="decimal" |
46 | 41 | android:width="300dp" |
47 | 42 | android:hint="@string/prix" |
48 | 43 | android:textAlignment="center" |
49 | 44 | android:layout_gravity="center_horizontal" |
50 | - android:layout_marginTop="50dp" | |
51 | - android:allowUndo="false" | |
52 | - android:height="250dp" | |
53 | - android:minHeight="80dp" | |
54 | - android:maxHeight="500dp" /> | |
45 | + android:layout_marginTop="20dp" | |
46 | + android:height="80dp" | |
47 | + android:minHeight="50dp" | |
48 | + android:maxHeight="500dp" | |
49 | + android:minWidth="120dp" /> | |
55 | 50 | |
56 | 51 | <Button |
57 | 52 | android:layout_width="wrap_content" |
58 | 53 | android:layout_height="wrap_content" |
59 | 54 | android:text="@string/validate" |
60 | - android:id="@+id/button" | |
55 | + android:id="@+id/commande_validation" | |
61 | 56 | android:layout_gravity="center_horizontal" |
62 | 57 | android:layout_marginTop="40dp" |
63 | - android:width="150dp" | |
58 | + android:width="180dp" | |
64 | 59 | android:height="80dp" |
65 | 60 | android:onClick="valideCommande" |
66 | - android:nestedScrollingEnabled="false" /> | |
61 | + android:nestedScrollingEnabled="false" | |
62 | + android:enabled="true" | |
63 | + android:focusable="true" | |
64 | + android:focusableInTouchMode="true" /> | |
67 | 65 | |
68 | 66 | </LinearLayout> |
69 | 67 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/res/layout/layout_carte.xml
... | ... | @@ -10,11 +10,11 @@ |
10 | 10 | android:layout_width="wrap_content" |
11 | 11 | android:layout_height="wrap_content" |
12 | 12 | android:text="@string/passCarte" |
13 | - android:id="@+id/textView2" | |
13 | + android:id="@+id/textView_carte" | |
14 | 14 | android:layout_gravity="center_horizontal" |
15 | 15 | android:enabled="true" |
16 | - android:inputType="text" | |
17 | 16 | android:textAlignment="center" |
18 | - android:textSize="50dp" | |
19 | - android:layout_marginTop="40dp" /> | |
17 | + android:textSize="50sp" | |
18 | + android:layout_marginTop="40dp" | |
19 | + android:inputType="none" /> | |
20 | 20 | </LinearLayout> |
21 | 21 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/res/layout/layout_connection.xml
... | ... | @@ -15,22 +15,59 @@ |
15 | 15 | android:textSize="@dimen/abc_text_size_large_material" |
16 | 16 | android:textStyle="bold" /> |
17 | 17 | |
18 | - <AutoCompleteTextView | |
19 | - android:layout_width="match_parent" | |
18 | + <EditText | |
19 | + android:layout_width="wrap_content" | |
20 | 20 | android:layout_height="wrap_content" |
21 | - android:text="Identifiant" | |
22 | - android:id="@+id/identifiant_principal" /> | |
21 | + android:inputType="text" | |
22 | + android:ems="15" | |
23 | + android:id="@+id/connection_username" | |
24 | + android:editable="true" | |
25 | + android:elegantTextHeight="true" | |
26 | + android:enabled="true" | |
27 | + android:width="300dp" | |
28 | + android:hint="@string/identifiant" | |
29 | + android:textAlignment="center" | |
30 | + android:layout_gravity="center_horizontal" | |
31 | + android:layout_marginTop="30dp" | |
32 | + android:height="150dp" | |
33 | + android:minHeight="50dp" | |
34 | + android:maxHeight="500dp" | |
35 | + android:minWidth="120dp" | |
36 | + android:textIsSelectable="true" /> | |
23 | 37 | |
24 | - <MultiAutoCompleteTextView | |
25 | - android:layout_width="match_parent" | |
38 | + <EditText | |
39 | + android:layout_width="wrap_content" | |
26 | 40 | android:layout_height="wrap_content" |
27 | - android:text="password" | |
28 | - android:id="@+id/password_principal" /> | |
41 | + android:inputType="textPassword" | |
42 | + android:ems="15" | |
43 | + android:id="@+id/connection_password" | |
44 | + android:editable="true" | |
45 | + android:elegantTextHeight="true" | |
46 | + android:enabled="true" | |
47 | + android:width="300dp" | |
48 | + android:hint="@string/password" | |
49 | + android:textAlignment="center" | |
50 | + android:layout_gravity="center_horizontal" | |
51 | + android:layout_marginTop="30dp" | |
52 | + android:height="150dp" | |
53 | + android:minHeight="50dp" | |
54 | + android:maxHeight="500dp" | |
55 | + android:minWidth="120dp" | |
56 | + android:textIsSelectable="true" /> | |
29 | 57 | |
30 | 58 | <Button |
31 | 59 | android:layout_width="wrap_content" |
32 | 60 | android:layout_height="wrap_content" |
33 | - android:text="Validez" | |
34 | - android:id="@+id/validation_principal" /> | |
61 | + android:text="@string/validate" | |
62 | + android:id="@+id/con_validation" | |
63 | + android:layout_gravity="center_horizontal" | |
64 | + android:layout_marginTop="40dp" | |
65 | + android:width="180dp" | |
66 | + android:height="80dp" | |
67 | + android:onClick="valideConnection" | |
68 | + android:nestedScrollingEnabled="false" | |
69 | + android:enabled="true" | |
70 | + android:focusable="true" | |
71 | + android:focusableInTouchMode="true" /> | |
35 | 72 | |
36 | 73 | </LinearLayout> |
37 | 74 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/res/layout/layout_rechargement.xml
... | ... | @@ -9,15 +9,13 @@ |
9 | 9 | android:layout_height="wrap_content" |
10 | 10 | android:inputType="numberDecimal" |
11 | 11 | android:ems="10" |
12 | - android:id="@+id/montant" | |
12 | + android:id="@+id/rechargement_champ_montant" | |
13 | 13 | android:layout_gravity="center_horizontal" |
14 | 14 | android:layout_marginTop="80dp" |
15 | 15 | android:editable="true" |
16 | 16 | android:elegantTextHeight="true" |
17 | 17 | android:enabled="true" |
18 | - android:focusable="true" | |
19 | - android:focusableInTouchMode="true" | |
20 | - android:height="200dp" | |
18 | + android:height="150dp" | |
21 | 19 | android:maxHeight="500dp" |
22 | 20 | android:maxLength="10" |
23 | 21 | android:maxWidth="600dp" |
... | ... | @@ -25,15 +23,14 @@ |
25 | 23 | android:numeric="decimal" |
26 | 24 | android:width="300dp" |
27 | 25 | android:hint="@string/montant" |
28 | - android:textAlignment="center" /> | |
26 | + android:textAlignment="center" | |
27 | + android:textStyle="bold" /> | |
29 | 28 | |
30 | 29 | <Button |
31 | 30 | android:layout_width="wrap_content" |
32 | 31 | android:layout_height="wrap_content" |
33 | 32 | android:text="@string/validate" |
34 | - android:id="@+id/button2" | |
35 | - android:layout_alignParentTop="true" | |
36 | - android:layout_centerHorizontal="true" | |
33 | + android:id="@+id/rechargement_bouton" | |
37 | 34 | android:layout_marginTop="80dp" |
38 | 35 | android:layout_gravity="center_horizontal" |
39 | 36 | android:minWidth="150dp" |
... | ... | @@ -43,5 +40,9 @@ |
43 | 40 | android:elegantTextHeight="true" |
44 | 41 | android:enabled="true" |
45 | 42 | android:focusable="true" |
46 | - android:focusableInTouchMode="true" /> | |
43 | + android:focusableInTouchMode="true" | |
44 | + android:onClick="valideRechargement" | |
45 | + android:height="80dp" | |
46 | + android:maxHeight="200dp" | |
47 | + android:maxWidth="150dp" /> | |
47 | 48 | </LinearLayout> |
48 | 49 | \ No newline at end of file | ... | ... |
PremiereActivite/app/src/main/res/layout/tab_fragment_1.xml
PremiereActivite/app/src/main/res/layout/tab_fragment_2.xml
PremiereActivite/app/src/main/res/layout/tab_fragment_3.xml
PremiereActivite/app/src/main/res/layout/tab_fragment_4.xml
PremiereActivite/app/src/main/res/layout/tab_fragment_5.xml
PremiereActivite/app/src/main/res/values/strings.xml
1 | 1 | <resources> |
2 | 2 | <string name="app_name">PremiereActivite</string> |
3 | 3 | <string name="action_settings">Settings</string> |
4 | - <string name="identifiant" /> | |
5 | - <string name="password" /> | |
4 | + <string name="identifiant">Identifiant</string> | |
5 | + <string name="password">Mot de passe</string> | |
6 | 6 | <string name="validate">Valider</string> |
7 | 7 | <string name="quant">Quantité</string> |
8 | 8 | <string name="montant">Montant</string> |
9 | 9 | <string name="prix">Prix</string> |
10 | 10 | <string name="vidange">Vidange</string> |
11 | - <string name="passCarte">Passez la carte</string> | |
11 | + <string name="passCarte">Passez la carte du client</string> | |
12 | 12 | |
13 | 13 | </resources> | ... | ... |
PremiereActivite/build.gradle
... | ... | @@ -5,7 +5,7 @@ buildscript { |
5 | 5 | jcenter() |
6 | 6 | } |
7 | 7 | dependencies { |
8 | - classpath 'com.android.tools.build:gradle:2.0.0' | |
8 | + classpath 'com.android.tools.build:gradle:2.1.0' | |
9 | 9 | |
10 | 10 | // NOTE: Do not place your application dependencies here; they belong |
11 | 11 | // in the individual module build.gradle files | ... | ... |