Back to project page AndroidAPP-TorEngine.
The source code is released under:
GNU General Public License
If you think the Android project AndroidAPP-TorEngine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ironwolf.torengine; // ww w .j a v a2s .com import java.io.File; import ironwolf.torengine.R; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class Automatica extends Activity { final static int AUT_DIALOG_ID=21; final static int CUSTOM_DIALOG=150; String titolodialog; int id_bottone; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.autmain); Button ftpaut=(Button) findViewById(R.id.ftpaut); ftpaut.setOnClickListener(new OnClickListener() { public void onClick(View V) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.torengine.it/openftp/automatica")); startActivity(intent); } }); final Button apr3=(Button) findViewById(R.id.apr3); apr3.setOnClickListener(new OnClickListener() { public void onClick(View V) { titolodialog=apr3.getText().toString(); id_bottone=1; showDialog(CUSTOM_DIALOG); } }); Button autgruppi=(Button) findViewById(R.id.autgruppi); autgruppi.setOnClickListener(new OnClickListener() { public void onClick(View V) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.torengine.it/automatica-gruppi/")); startActivity(intent); } }); }//fine onCreate @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.sezmenu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { /*case R.id.check: { //controlla se ? aggiornato il link di tutti i file di Analisi1. }break; */ case R.id.quit: { finish(); TorEngineActivity.a.finish(); }break; case R.id.contatti: { showDialog(AUT_DIALOG_ID); }break; } return true; }; @Override // SWITCH DEL CREATE DELLE ALERT DIALOG protected Dialog onCreateDialog(int id) { Dialog dialog=null; switch(id) { case AUT_DIALOG_ID: { dialog=createGEOMDialog(); }break; case CUSTOM_DIALOG: { dialog=createCustomDialog(); }break; } return dialog; } private Dialog createGEOMDialog() { View view =getLayoutInflater().inflate(R.layout.autdialog, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Sergio Galeani"); builder.setView(view); builder.setCancelable(false); builder.setNegativeButton("email", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent goToAna1C= new Intent (Automatica.this, AutomaticaContatti.class); startActivity(goToAna1C); } }); builder.setNeutralButton("Sito", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent goToSitoAna1= new Intent(Intent.ACTION_VIEW); goToSitoAna1.setData(Uri.parse("http://robot2.disp.uniroma2.it/~galeani/LA/")); startActivity(goToSitoAna1); } }); builder.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(AUT_DIALOG_ID); removeDialog(AUT_DIALOG_ID); } }); AlertDialog alert = builder.create(); return alert; } private Dialog createCustomDialog() { View view=getLayoutInflater().inflate(R.layout.customdialog,null); AlertDialog.Builder builder2=new AlertDialog.Builder(this); builder2.setTitle(titolodialog); builder2.setView(view); builder2.setCancelable(false); switch(id_bottone) { case 1: { builder2.setMessage("Esperimento del 3 Aprile 2012: Sistema di controllo tensioni"); builder2.setNegativeButton("Download", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW); File file= new File("/mnt/sdcard/download/esp3_4_12.pdf"); if(file.exists()) { if(file.delete()) { Toast.makeText(getApplicationContext(), "Il file precedente verr? sovrascritto...",Toast.LENGTH_LONG).show(); } } intent.setData(Uri.parse("http://www.torengine.it/openftp/automatica/esp3_4_12.pdf")); startActivity(intent); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); builder2.setNeutralButton("Apri", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intentFile = new Intent(Intent.ACTION_VIEW); File file = new File("/mnt/sdcard/download/esp3_4_12.pdf"); Uri path = Uri.fromFile(file); if(file.exists()) { intentFile.setDataAndType(path, "application/pdf"); intentFile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intentFile); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } else { Toast.makeText(getApplicationContext(), "file esp3_4_12.pdf non trovato nella cartella /mnt/sdcard/download",Toast.LENGTH_LONG).show(); dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } } }); builder2.setPositiveButton("Indietro", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CUSTOM_DIALOG); removeDialog(CUSTOM_DIALOG); } }); }break; } AlertDialog alert2 = builder2.create(); return alert2; } }