diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4380773..168cb43 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -50,6 +50,10 @@ android:label="@string/app_name" /> + diff --git a/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/MainActivity.java b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/MainActivity.java index 62b4960..adf55da 100644 --- a/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/MainActivity.java +++ b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/MainActivity.java @@ -1,29 +1,16 @@ package ssrmarcsautelet.automation.appli.ssrmarcsautelet; -import android.app.Dialog; -import android.app.ProgressDialog; import android.content.Intent; -import android.os.AsyncTask; import android.os.Bundle; -import android.os.Environment; import android.support.v7.app.AppCompatActivity; -import android.util.Log; import android.view.View; import android.widget.Button; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; - public class MainActivity extends AppCompatActivity { - public static final int DIALOG_DOWNLOAD_PROGRESS = 1; + //public static final int DIALOG_DOWNLOAD_PROGRESS = 1; private Button startBtn; - private ProgressDialog progressDialog; + /*private ProgressDialog progressDialog; final String url = "http://192.168.43.197/documents/"; public static File CreateFile() @@ -157,20 +144,22 @@ public class MainActivity extends AppCompatActivity "psy3.png", "psychomo1.png", "secret1.png", - "secret2.png"}; + "secret2.png"};*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - startBtn = (Button) findViewById(R.id.telechargement); - startBtn.setOnClickListener(new View.OnClickListener() { + //startBtn = (Button) findViewById(R.id.telechargement); + //startBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + // @Override + //public void onClick(View v) { // TODO Auto-generated method stub - CreateFile(); + // Intent activity_val = new Intent(MainActivity.this, activity_val.class); + //startActivity(activity_val); + /*CreateFile(); new DownloadFileAsync().execute( url+dir[0] ,url+dir[1], url+dir[2], url+dir[3], url+dir[4], url+dir[5], 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 url+dir[98], url+dir[99], url+dir[100], url+dir[101], url+dir[102], url+dir[103], url+dir[104], url+dir[105], url+dir[106], url+dir[107], url+dir[108],url + dir[109] ,url+dir[110], url+dir[111], url+dir[112], url+dir[113], url+dir[114], url+dir[115], url+dir[116], url+dir[117], url+dir[118], - url+dir[119], url+dir[120], url+dir[121], url+dir[122]);//OK - } - }); - } + url+dir[119], url+dir[120], url+dir[121], url+dir[122]);//OK*/ + + // } + //}); + } + /* @Override @Deprecated protected Dialog onCreateDialog(int id) { @@ -272,7 +263,7 @@ public class MainActivity extends AppCompatActivity progressDialog.setProgress(Integer.parseInt(values[0])); } - } + }*/ public void send_savoirplus(View v) { @@ -304,4 +295,10 @@ public class MainActivity extends AppCompatActivity Intent intent4 = new Intent(MainActivity.this, plan_hospital.class); startActivity(intent4); } + + public void demande_mdp(View v) + { + Intent intent5 = new Intent(MainActivity.this, activity_val.class); + startActivity(intent5); + } } \ No newline at end of file diff --git a/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/activity_val.java b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/activity_val.java new file mode 100644 index 0000000..397fab3 --- /dev/null +++ b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/activity_val.java @@ -0,0 +1,290 @@ +package ssrmarcsautelet.automation.appli.ssrmarcsautelet; + +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Environment; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * Created by Robin on 26/04/2017. + */ + +public class activity_val extends AppCompatActivity { + + public int DIALOG_DOWNLOAD_PROGRESS = 1; + private ProgressDialog progressDialog; + public String url = "http://192.168.43.197/documents/"; + public EditText saisie; + public Button validation; + public Context context; + public int duration = Toast.LENGTH_SHORT; + public String recup_mot; + + public static File CreateFile() { + File path = new File(Environment.getExternalStorageDirectory(), "/SSR_docs/"); + path.mkdirs(); + return path; + } + + String[] dir = { + "contact_map.html", + "fiche_amb1.html", + "fiche_amb2.html", + "fiche_amb3.html", + "fiche_ane1.html", + "fiche_ane2.html", + "fiche_ane3.html", + "fiche_assist1.html", + "fiche_assist2.html", + "fiche_assist3.html", + "fiche_educ1.html", + "fiche_educ2.html", + "fiche_educ3.html", + "fiche_ergo1.html", + "fiche_ergo2.html", + "fiche_ergo3.html", + "fiche_inf1.html", + "fiche_inf2.html", + "fiche_inf3.html", + "fiche_kine1.html", + "fiche_kine2.html", + "fiche_kine3.html", + "fiche_medecin1.html", + "fiche_medecin2.html", + "fiche_medecin3.html", + "fiche_ortho1.html", + "fiche_ortho2.html", + "fiche_ortho3.html", + "fiche_orthoptiste1.html", + "fiche_orthoptiste2.html", + "fiche_orthoptiste3.html", + "fiche_psycho1.html", + "fiche_psycho2.html", + "fiche_psycho3.html", + "fiche_secret1.html", + "fiche_secret2.html", + "fiche_secret3.html", + "google_map.html", + "orga_accueil.html", + "orga_apa.html", + "orga_appareilleur.html", + "orga_assist.html", + "orga_cadre.html", + "orga_doc.html", + "orga_ergo.html", + "orga_grands.html", + "orga_inf.html", + "orga_kine.html", + "orga_moyens.html", + "orga_ortho.html", + "orga_orthoptiste.html", + "orga_petits.html", + "orga_psy.html", + "orga_psychomo.html", + "orga_secret.html", + "orga_standard.html", + "Ambulancier.jpg", + "Kine.jpg", + "ane.jpg", + "assistante.jpg", + "educateur.jpg", + "ergo.jpg", + "inf.jpg", + "medecin.jpg", + "ortho.jpg", + "orthoptiste.jpg", + "psychologue.jpg", + "secretaire.jpg", + "accueil1.png", + "accueil2.png", + "accueil3.png", + "accueil4.png", + "apa1.png", + "appareillage1.png", + "assist1.png", + "dame1.png", + "dame2.png", + "doc1.png", + "doc2.png", + "ecole1.png", + "ecole2.png", + "ergo1.png", + "ergo2.png", + "ergo3.png", + "ergo4.png", + "ergo5.png", + "grands1.png", + "grands2.png", + "grands3.png", + "inf1.png", + "inf2.png", + "inf3.png", + "kine1.png", + "kine10.png", + "kine11.png", + "kine12.png", + "kine2.png", + "kine3.png", + "kine4.png", + "kine5.png", + "kine6.png", + "kine7.png", + "kine8.png", + "kine9.png", + "moyens1.png", + "moyens2.png", + "moyens3.png", + "moyens4.png", + "moyens5.png", + "ortho1.png", + "ortho2.png", + "ortho3.png", + "orthopto1.png", + "pediatre1.png", + "petits1.png", + "petits2.png", + "petits3.png", + "petits4.png", + "psy1.png", + "psy2.png", + "psy3.png", + "psychomo1.png", + "secret1.png", + "secret2.png"}; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.motdepasse); + saisie = (EditText) findViewById(R.id.texte_mdp); + validation = (Button) findViewById(R.id.valid); + validation.setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) { + if (saisie.getText().toString().equals("projetima4")) + { + CreateFile(); + new activity_val.DownloadFileAsync().execute( + url + dir[0], url + dir[1], url + dir[2], url + dir[3], url + dir[4], url + dir[5], + url + dir[6], url + dir[7], url + dir[8], url + dir[9], url + dir[10], url + dir[11], + url + dir[12], url + dir[13], url + dir[14], url + dir[15], url + dir[16], url + dir[17], + url + dir[18], url + dir[19], url + dir[20], url + dir[21], url + dir[22], + url + dir[23], url + dir[24], url + dir[25], url + dir[26], url + dir[27], url + dir[28], url + dir[29], + url + dir[30], url + dir[31], url + dir[32], url + dir[33], url + dir[34], url + dir[35], url + dir[36], + url + dir[37], url + dir[38], url + dir[39], url + dir[40], url + dir[41], url + dir[42], url + dir[43], + url + dir[44], url + dir[45], url + dir[46], url + dir[47], url + dir[48], url + dir[49], url + dir[50], + url + dir[51], url + dir[52], url + dir[53], url + dir[54], url + dir[55], url + dir[56], url + dir[57], url + dir[58], + url + dir[59], url + dir[60], url + dir[61], url + dir[62], url + dir[63], url + dir[64], + url + dir[65], url + dir[66], url + dir[67], url + dir[68], url + dir[69], url + dir[70], + url + dir[71], url + dir[72], url + dir[73], url + dir[74], url + dir[75], url + dir[76], + url + dir[77], url + dir[78], url + dir[79], url + dir[80], url + dir[81], url + dir[82], url + dir[83], + url + dir[84], url + dir[85], url + dir[86], url + dir[87], url + dir[88], url + dir[89], url + dir[90], + url + dir[91], url + dir[92], url + dir[93], url + dir[94], url + dir[95], url + dir[96], url + dir[97], + url + dir[98], url + dir[99], url + dir[100], url + dir[101], url + dir[102], url + dir[103], url + dir[104], + url + dir[105], url + dir[106], url + dir[107], url + dir[108], url + dir[109], url + dir[110], url + dir[111], url + dir[112], + url + dir[113], url + dir[114], url + dir[115], url + dir[116], url + dir[117], url + dir[118], + url + dir[119], url + dir[120], url + dir[121], url + dir[122]);// + + context = getApplicationContext(); + Toast toast1 = Toast.makeText(context, "Téléchargement en cours", duration); + toast1.show(); + } else { + context = getApplicationContext(); + Toast toast2 = Toast.makeText(context, "Mot de passe inconnu", duration); + toast2.show(); + } + + } + }); + } + + @Override + @Deprecated + protected Dialog onCreateDialog(int id) { + // TODO Auto-generated method stub + switch (id) { + case 1: + progressDialog = new ProgressDialog(this); + progressDialog.setMessage("Téléchargement des fichiers"); + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setCancelable(false); + progressDialog.show(); + return progressDialog; + default: + return null; + } + } + + class DownloadFileAsync extends AsyncTask { + @Override + protected String doInBackground(String... params) { + // TODO Auto-generated method stub + int count; + for (int i = 0; i < dir.length; i++) { + try { + URL url = new URL(params[i]); + URLConnection connexion = url.openConnection(); + connexion.connect(); + int lengthofFile = connexion.getContentLength(); + Log.d("ANDRO_ASYNC", "Length of file: " + lengthofFile); + InputStream input = new BufferedInputStream(url.openStream()); + OutputStream output = new FileOutputStream("/sdcard/SSR_docs/" + dir[i]); + byte data[] = new byte[1024]; + long total = 0; + while ((count = input.read(data)) != -1) { + total += count; + publishProgress("" + (int) ((total * 100) / lengthofFile)); + output.write(data, 0, count); + } + output.flush(); + output.close(); + input.close(); + } catch (Exception e) { + Log.i("FAIL", "Problème de téléchargement"); + // TODO: handle exception + } + + } + return null; + } + + @Override + protected void onPostExecute(String result) { + // TODO Auto-generated method stub + dismissDialog(DIALOG_DOWNLOAD_PROGRESS); + } + + @Override + protected void onPreExecute() { + // TODO Auto-generated method stub + super.onPreExecute(); + showDialog(DIALOG_DOWNLOAD_PROGRESS); + } + + @Override + protected void onProgressUpdate(String... values) { + // TODO Auto-generated method stub + Log.d("ANDRO_ASYNC", values[0]); + progressDialog.setProgress(Integer.parseInt(values[0])); + } + } + + } + diff --git a/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/educ1.java b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/educ1.java index cff6b08..9e9442e 100644 --- a/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/educ1.java +++ b/app/src/main/java/ssrmarcsautelet/automation/appli/ssrmarcsautelet/educ1.java @@ -1,7 +1,6 @@ package ssrmarcsautelet.automation.appli.ssrmarcsautelet; import android.os.Bundle; -import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.webkit.WebSettings; import android.webkit.WebView; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 74cae80..9030e8f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -123,7 +123,8 @@ android:text="MàJ" android:layout_alignBottom="@+id/savoir_plus" android:layout_alignRight="@+id/imageView6" - android:layout_alignEnd="@+id/imageView6" /> + android:layout_alignEnd="@+id/imageView6" + android:onClick="demande_mdp"/> diff --git a/app/src/main/res/layout/motdepasse.xml b/app/src/main/res/layout/motdepasse.xml new file mode 100644 index 0000000..61d0c6a --- /dev/null +++ b/app/src/main/res/layout/motdepasse.xml @@ -0,0 +1,31 @@ + + + + + +