Commit 21f011f1727307367d44861a7977be8d83946600

Authored by rcavalie
1 parent 2d1b24f6

mot de passe telechargement ok

app/src/main/AndroidManifest.xml
@@ -50,6 +50,10 @@ @@ -50,6 +50,10 @@
50 android:label="@string/app_name" 50 android:label="@string/app_name"
51 /> 51 />
52 <activity 52 <activity
  53 + android:name=".activity_val"
  54 + android:label="@string/app_name"
  55 + />
  56 + <activity
53 android:name=".plan_hospital" 57 android:name=".plan_hospital"
54 android:label="@string/app_name" 58 android:label="@string/app_name"
55 android:screenOrientation="landscape" /> 59 android:screenOrientation="landscape" />
app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/MainActivity.java
1 package ssrmarcsautelet.automation.appli.ssrmarcsautelet; 1 package ssrmarcsautelet.automation.appli.ssrmarcsautelet;
2 2
3 -import android.app.Dialog;  
4 -import android.app.ProgressDialog;  
5 import android.content.Intent; 3 import android.content.Intent;
6 -import android.os.AsyncTask;  
7 import android.os.Bundle; 4 import android.os.Bundle;
8 -import android.os.Environment;  
9 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
10 -import android.util.Log;  
11 import android.view.View; 6 import android.view.View;
12 import android.widget.Button; 7 import android.widget.Button;
13 8
14 -import java.io.BufferedInputStream;  
15 -import java.io.File;  
16 -import java.io.FileOutputStream;  
17 -import java.io.InputStream;  
18 -import java.io.OutputStream;  
19 -import java.net.URL;  
20 -import java.net.URLConnection;  
21 -  
22 public class MainActivity extends AppCompatActivity 9 public class MainActivity extends AppCompatActivity
23 { 10 {
24 - public static final int DIALOG_DOWNLOAD_PROGRESS = 1; 11 + //public static final int DIALOG_DOWNLOAD_PROGRESS = 1;
25 private Button startBtn; 12 private Button startBtn;
26 - private ProgressDialog progressDialog; 13 + /*private ProgressDialog progressDialog;
27 final String url = "http://192.168.43.197/documents/"; 14 final String url = "http://192.168.43.197/documents/";
28 15
29 public static File CreateFile() 16 public static File CreateFile()
@@ -157,20 +144,22 @@ public class MainActivity extends AppCompatActivity @@ -157,20 +144,22 @@ public class MainActivity extends AppCompatActivity
157 "psy3.png", 144 "psy3.png",
158 "psychomo1.png", 145 "psychomo1.png",
159 "secret1.png", 146 "secret1.png",
160 - "secret2.png"}; 147 + "secret2.png"};*/
161 148
162 @Override 149 @Override
163 protected void onCreate(Bundle savedInstanceState) { 150 protected void onCreate(Bundle savedInstanceState) {
164 super.onCreate(savedInstanceState); 151 super.onCreate(savedInstanceState);
165 setContentView(R.layout.activity_main); 152 setContentView(R.layout.activity_main);
166 153
167 - startBtn = (Button) findViewById(R.id.telechargement);  
168 - startBtn.setOnClickListener(new View.OnClickListener() { 154 + //startBtn = (Button) findViewById(R.id.telechargement);
  155 + //startBtn.setOnClickListener(new View.OnClickListener() {
169 156
170 - @Override  
171 - public void onClick(View v) { 157 + // @Override
  158 + //public void onClick(View v) {
172 // TODO Auto-generated method stub 159 // TODO Auto-generated method stub
173 - CreateFile(); 160 + // Intent activity_val = new Intent(MainActivity.this, activity_val.class);
  161 + //startActivity(activity_val);
  162 + /*CreateFile();
174 new DownloadFileAsync().execute( 163 new DownloadFileAsync().execute(
175 url+dir[0] ,url+dir[1], url+dir[2], url+dir[3], url+dir[4], url+dir[5], 164 url+dir[0] ,url+dir[1], url+dir[2], url+dir[3], url+dir[4], url+dir[5],
176 url+dir[6], url+dir[7], url+dir[8], url+dir[9], url+dir[10], url+dir[11], 165 url+dir[6], url+dir[7], url+dir[8], url+dir[9], url+dir[10], url+dir[11],
@@ -190,11 +179,13 @@ public class MainActivity extends AppCompatActivity @@ -190,11 +179,13 @@ public class MainActivity extends AppCompatActivity
190 url+dir[98], url+dir[99], url+dir[100], url+dir[101], url+dir[102], url+dir[103], url+dir[104], 179 url+dir[98], url+dir[99], url+dir[100], url+dir[101], url+dir[102], url+dir[103], url+dir[104],
191 url+dir[105], url+dir[106], url+dir[107], url+dir[108],url + dir[109] ,url+dir[110], url+dir[111], url+dir[112], 180 url+dir[105], url+dir[106], url+dir[107], url+dir[108],url + dir[109] ,url+dir[110], url+dir[111], url+dir[112],
192 url+dir[113], url+dir[114], url+dir[115], url+dir[116], url+dir[117], url+dir[118], 181 url+dir[113], url+dir[114], url+dir[115], url+dir[116], url+dir[117], url+dir[118],
193 - url+dir[119], url+dir[120], url+dir[121], url+dir[122]);//OK  
194 - }  
195 - });  
196 - } 182 + url+dir[119], url+dir[120], url+dir[121], url+dir[122]);//OK*/
197 183
  184 +
  185 + // }
  186 + //});
  187 + }
  188 + /*
198 @Override 189 @Override
199 @Deprecated 190 @Deprecated
200 protected Dialog onCreateDialog(int id) { 191 protected Dialog onCreateDialog(int id) {
@@ -272,7 +263,7 @@ public class MainActivity extends AppCompatActivity @@ -272,7 +263,7 @@ public class MainActivity extends AppCompatActivity
272 progressDialog.setProgress(Integer.parseInt(values[0])); 263 progressDialog.setProgress(Integer.parseInt(values[0]));
273 } 264 }
274 265
275 - } 266 + }*/
276 267
277 public void send_savoirplus(View v) 268 public void send_savoirplus(View v)
278 { 269 {
@@ -304,4 +295,10 @@ public class MainActivity extends AppCompatActivity @@ -304,4 +295,10 @@ public class MainActivity extends AppCompatActivity
304 Intent intent4 = new Intent(MainActivity.this, plan_hospital.class); 295 Intent intent4 = new Intent(MainActivity.this, plan_hospital.class);
305 startActivity(intent4); 296 startActivity(intent4);
306 } 297 }
  298 +
  299 + public void demande_mdp(View v)
  300 + {
  301 + Intent intent5 = new Intent(MainActivity.this, activity_val.class);
  302 + startActivity(intent5);
  303 + }
307 } 304 }
308 \ No newline at end of file 305 \ No newline at end of file
app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/activity_val.java 0 → 100644
@@ -0,0 +1,290 @@ @@ -0,0 +1,290 @@
  1 +package ssrmarcsautelet.automation.appli.ssrmarcsautelet;
  2 +
  3 +import android.app.Dialog;
  4 +import android.app.ProgressDialog;
  5 +import android.content.Context;
  6 +import android.os.AsyncTask;
  7 +import android.os.Bundle;
  8 +import android.os.Environment;
  9 +import android.support.v7.app.AppCompatActivity;
  10 +import android.util.Log;
  11 +import android.view.View;
  12 +import android.widget.Button;
  13 +import android.widget.EditText;
  14 +import android.widget.Toast;
  15 +
  16 +import java.io.BufferedInputStream;
  17 +import java.io.File;
  18 +import java.io.FileOutputStream;
  19 +import java.io.InputStream;
  20 +import java.io.OutputStream;
  21 +import java.net.URL;
  22 +import java.net.URLConnection;
  23 +
  24 +/**
  25 + * Created by Robin on 26/04/2017.
  26 + */
  27 +
  28 +public class activity_val extends AppCompatActivity {
  29 +
  30 + public int DIALOG_DOWNLOAD_PROGRESS = 1;
  31 + private ProgressDialog progressDialog;
  32 + public String url = "http://192.168.43.197/documents/";
  33 + public EditText saisie;
  34 + public Button validation;
  35 + public Context context;
  36 + public int duration = Toast.LENGTH_SHORT;
  37 + public String recup_mot;
  38 +
  39 + public static File CreateFile() {
  40 + File path = new File(Environment.getExternalStorageDirectory(), "/SSR_docs/");
  41 + path.mkdirs();
  42 + return path;
  43 + }
  44 +
  45 + String[] dir = {
  46 + "contact_map.html",
  47 + "fiche_amb1.html",
  48 + "fiche_amb2.html",
  49 + "fiche_amb3.html",
  50 + "fiche_ane1.html",
  51 + "fiche_ane2.html",
  52 + "fiche_ane3.html",
  53 + "fiche_assist1.html",
  54 + "fiche_assist2.html",
  55 + "fiche_assist3.html",
  56 + "fiche_educ1.html",
  57 + "fiche_educ2.html",
  58 + "fiche_educ3.html",
  59 + "fiche_ergo1.html",
  60 + "fiche_ergo2.html",
  61 + "fiche_ergo3.html",
  62 + "fiche_inf1.html",
  63 + "fiche_inf2.html",
  64 + "fiche_inf3.html",
  65 + "fiche_kine1.html",
  66 + "fiche_kine2.html",
  67 + "fiche_kine3.html",
  68 + "fiche_medecin1.html",
  69 + "fiche_medecin2.html",
  70 + "fiche_medecin3.html",
  71 + "fiche_ortho1.html",
  72 + "fiche_ortho2.html",
  73 + "fiche_ortho3.html",
  74 + "fiche_orthoptiste1.html",
  75 + "fiche_orthoptiste2.html",
  76 + "fiche_orthoptiste3.html",
  77 + "fiche_psycho1.html",
  78 + "fiche_psycho2.html",
  79 + "fiche_psycho3.html",
  80 + "fiche_secret1.html",
  81 + "fiche_secret2.html",
  82 + "fiche_secret3.html",
  83 + "google_map.html",
  84 + "orga_accueil.html",
  85 + "orga_apa.html",
  86 + "orga_appareilleur.html",
  87 + "orga_assist.html",
  88 + "orga_cadre.html",
  89 + "orga_doc.html",
  90 + "orga_ergo.html",
  91 + "orga_grands.html",
  92 + "orga_inf.html",
  93 + "orga_kine.html",
  94 + "orga_moyens.html",
  95 + "orga_ortho.html",
  96 + "orga_orthoptiste.html",
  97 + "orga_petits.html",
  98 + "orga_psy.html",
  99 + "orga_psychomo.html",
  100 + "orga_secret.html",
  101 + "orga_standard.html",
  102 + "Ambulancier.jpg",
  103 + "Kine.jpg",
  104 + "ane.jpg",
  105 + "assistante.jpg",
  106 + "educateur.jpg",
  107 + "ergo.jpg",
  108 + "inf.jpg",
  109 + "medecin.jpg",
  110 + "ortho.jpg",
  111 + "orthoptiste.jpg",
  112 + "psychologue.jpg",
  113 + "secretaire.jpg",
  114 + "accueil1.png",
  115 + "accueil2.png",
  116 + "accueil3.png",
  117 + "accueil4.png",
  118 + "apa1.png",
  119 + "appareillage1.png",
  120 + "assist1.png",
  121 + "dame1.png",
  122 + "dame2.png",
  123 + "doc1.png",
  124 + "doc2.png",
  125 + "ecole1.png",
  126 + "ecole2.png",
  127 + "ergo1.png",
  128 + "ergo2.png",
  129 + "ergo3.png",
  130 + "ergo4.png",
  131 + "ergo5.png",
  132 + "grands1.png",
  133 + "grands2.png",
  134 + "grands3.png",
  135 + "inf1.png",
  136 + "inf2.png",
  137 + "inf3.png",
  138 + "kine1.png",
  139 + "kine10.png",
  140 + "kine11.png",
  141 + "kine12.png",
  142 + "kine2.png",
  143 + "kine3.png",
  144 + "kine4.png",
  145 + "kine5.png",
  146 + "kine6.png",
  147 + "kine7.png",
  148 + "kine8.png",
  149 + "kine9.png",
  150 + "moyens1.png",
  151 + "moyens2.png",
  152 + "moyens3.png",
  153 + "moyens4.png",
  154 + "moyens5.png",
  155 + "ortho1.png",
  156 + "ortho2.png",
  157 + "ortho3.png",
  158 + "orthopto1.png",
  159 + "pediatre1.png",
  160 + "petits1.png",
  161 + "petits2.png",
  162 + "petits3.png",
  163 + "petits4.png",
  164 + "psy1.png",
  165 + "psy2.png",
  166 + "psy3.png",
  167 + "psychomo1.png",
  168 + "secret1.png",
  169 + "secret2.png"};
  170 +
  171 + @Override
  172 + protected void onCreate(Bundle savedInstanceState) {
  173 + super.onCreate(savedInstanceState);
  174 + setContentView(R.layout.motdepasse);
  175 + saisie = (EditText) findViewById(R.id.texte_mdp);
  176 + validation = (Button) findViewById(R.id.valid);
  177 + validation.setOnClickListener(new View.OnClickListener()
  178 + {
  179 + @Override
  180 + public void onClick(View v) {
  181 + if (saisie.getText().toString().equals("projetima4"))
  182 + {
  183 + CreateFile();
  184 + new activity_val.DownloadFileAsync().execute(
  185 + url + dir[0], url + dir[1], url + dir[2], url + dir[3], url + dir[4], url + dir[5],
  186 + url + dir[6], url + dir[7], url + dir[8], url + dir[9], url + dir[10], url + dir[11],
  187 + url + dir[12], url + dir[13], url + dir[14], url + dir[15], url + dir[16], url + dir[17],
  188 + url + dir[18], url + dir[19], url + dir[20], url + dir[21], url + dir[22],
  189 + url + dir[23], url + dir[24], url + dir[25], url + dir[26], url + dir[27], url + dir[28], url + dir[29],
  190 + url + dir[30], url + dir[31], url + dir[32], url + dir[33], url + dir[34], url + dir[35], url + dir[36],
  191 + url + dir[37], url + dir[38], url + dir[39], url + dir[40], url + dir[41], url + dir[42], url + dir[43],
  192 + url + dir[44], url + dir[45], url + dir[46], url + dir[47], url + dir[48], url + dir[49], url + dir[50],
  193 + url + dir[51], url + dir[52], url + dir[53], url + dir[54], url + dir[55], url + dir[56], url + dir[57], url + dir[58],
  194 + url + dir[59], url + dir[60], url + dir[61], url + dir[62], url + dir[63], url + dir[64],
  195 + url + dir[65], url + dir[66], url + dir[67], url + dir[68], url + dir[69], url + dir[70],
  196 + url + dir[71], url + dir[72], url + dir[73], url + dir[74], url + dir[75], url + dir[76],
  197 + url + dir[77], url + dir[78], url + dir[79], url + dir[80], url + dir[81], url + dir[82], url + dir[83],
  198 + url + dir[84], url + dir[85], url + dir[86], url + dir[87], url + dir[88], url + dir[89], url + dir[90],
  199 + url + dir[91], url + dir[92], url + dir[93], url + dir[94], url + dir[95], url + dir[96], url + dir[97],
  200 + url + dir[98], url + dir[99], url + dir[100], url + dir[101], url + dir[102], url + dir[103], url + dir[104],
  201 + url + dir[105], url + dir[106], url + dir[107], url + dir[108], url + dir[109], url + dir[110], url + dir[111], url + dir[112],
  202 + url + dir[113], url + dir[114], url + dir[115], url + dir[116], url + dir[117], url + dir[118],
  203 + url + dir[119], url + dir[120], url + dir[121], url + dir[122]);//
  204 +
  205 + context = getApplicationContext();
  206 + Toast toast1 = Toast.makeText(context, "Téléchargement en cours", duration);
  207 + toast1.show();
  208 + } else {
  209 + context = getApplicationContext();
  210 + Toast toast2 = Toast.makeText(context, "Mot de passe inconnu", duration);
  211 + toast2.show();
  212 + }
  213 +
  214 + }
  215 + });
  216 + }
  217 +
  218 + @Override
  219 + @Deprecated
  220 + protected Dialog onCreateDialog(int id) {
  221 + // TODO Auto-generated method stub
  222 + switch (id) {
  223 + case 1:
  224 + progressDialog = new ProgressDialog(this);
  225 + progressDialog.setMessage("Téléchargement des fichiers");
  226 + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  227 + progressDialog.setCancelable(false);
  228 + progressDialog.show();
  229 + return progressDialog;
  230 + default:
  231 + return null;
  232 + }
  233 + }
  234 +
  235 + class DownloadFileAsync extends AsyncTask<String, String, String> {
  236 + @Override
  237 + protected String doInBackground(String... params) {
  238 + // TODO Auto-generated method stub
  239 + int count;
  240 + for (int i = 0; i < dir.length; i++) {
  241 + try {
  242 + URL url = new URL(params[i]);
  243 + URLConnection connexion = url.openConnection();
  244 + connexion.connect();
  245 + int lengthofFile = connexion.getContentLength();
  246 + Log.d("ANDRO_ASYNC", "Length of file: " + lengthofFile);
  247 + InputStream input = new BufferedInputStream(url.openStream());
  248 + OutputStream output = new FileOutputStream("/sdcard/SSR_docs/" + dir[i]);
  249 + byte data[] = new byte[1024];
  250 + long total = 0;
  251 + while ((count = input.read(data)) != -1) {
  252 + total += count;
  253 + publishProgress("" + (int) ((total * 100) / lengthofFile));
  254 + output.write(data, 0, count);
  255 + }
  256 + output.flush();
  257 + output.close();
  258 + input.close();
  259 + } catch (Exception e) {
  260 + Log.i("FAIL", "Problème de téléchargement");
  261 + // TODO: handle exception
  262 + }
  263 +
  264 + }
  265 + return null;
  266 + }
  267 +
  268 + @Override
  269 + protected void onPostExecute(String result) {
  270 + // TODO Auto-generated method stub
  271 + dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
  272 + }
  273 +
  274 + @Override
  275 + protected void onPreExecute() {
  276 + // TODO Auto-generated method stub
  277 + super.onPreExecute();
  278 + showDialog(DIALOG_DOWNLOAD_PROGRESS);
  279 + }
  280 +
  281 + @Override
  282 + protected void onProgressUpdate(String... values) {
  283 + // TODO Auto-generated method stub
  284 + Log.d("ANDRO_ASYNC", values[0]);
  285 + progressDialog.setProgress(Integer.parseInt(values[0]));
  286 + }
  287 + }
  288 +
  289 + }
  290 +
app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/educ1.java
1 package ssrmarcsautelet.automation.appli.ssrmarcsautelet; 1 package ssrmarcsautelet.automation.appli.ssrmarcsautelet;
2 2
3 import android.os.Bundle; 3 import android.os.Bundle;
4 -import android.os.Environment;  
5 import android.support.v7.app.AppCompatActivity; 4 import android.support.v7.app.AppCompatActivity;
6 import android.webkit.WebSettings; 5 import android.webkit.WebSettings;
7 import android.webkit.WebView; 6 import android.webkit.WebView;
app/src/main/res/layout/activity_main.xml
@@ -123,7 +123,8 @@ @@ -123,7 +123,8 @@
123 android:text="MàJ" 123 android:text="MàJ"
124 android:layout_alignBottom="@+id/savoir_plus" 124 android:layout_alignBottom="@+id/savoir_plus"
125 android:layout_alignRight="@+id/imageView6" 125 android:layout_alignRight="@+id/imageView6"
126 - android:layout_alignEnd="@+id/imageView6" /> 126 + android:layout_alignEnd="@+id/imageView6"
  127 + android:onClick="demande_mdp"/>
127 128
128 </RelativeLayout> 129 </RelativeLayout>
129 130
app/src/main/res/layout/motdepasse.xml 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:orientation="vertical" android:layout_width="match_parent"
  5 + android:layout_height="match_parent">
  6 +
  7 + <EditText
  8 + android:id="@+id/texte_mdp"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content"
  11 + android:ems="10"
  12 + android:inputType="textPassword"
  13 + android:hint="Mot de passe"
  14 + android:layout_gravity="center_vertical"
  15 + android:layout_above="@+id/valid"
  16 + android:layout_alignParentLeft="true"
  17 + android:layout_alignParentStart="true"
  18 + tools:ignore="HardcodedText" />
  19 +
  20 + <Button
  21 + android:id="@+id/valid"
  22 + android:layout_width="match_parent"
  23 + android:layout_height="wrap_content"
  24 + android:text="valider"
  25 + android:layout_gravity="center_vertical"
  26 + android:layout_alignParentBottom="true"
  27 + android:layout_alignParentLeft="true"
  28 + android:layout_alignParentStart="true"
  29 + android:layout_marginBottom="244dp"
  30 + tools:ignore="HardcodedText" />
  31 +</RelativeLayout>
0 \ No newline at end of file 32 \ No newline at end of file
app/src/main/res/values/strings.xml
@@ -12,4 +12,7 @@ @@ -12,4 +12,7 @@
12 <string name="google_android_map_api_key">AIzaSyD_8f_wI_qo-CcgYz25chhovnKCbZ8nBbw</string> 12 <string name="google_android_map_api_key">AIzaSyD_8f_wI_qo-CcgYz25chhovnKCbZ8nBbw</string>
13 <string name="contactez_nous">Nous Contacter</string> 13 <string name="contactez_nous">Nous Contacter</string>
14 <string name="ok">ok</string> 14 <string name="ok">ok</string>
  15 + <string name="check_mdp">check_mdp</string>
  16 + <string name="mot_de_passe">Mot de passe</string>
  17 + <string name="valider">valider</string>
15 </resources> 18 </resources>