/* Tibisay Movil Copyright (C) 2013 Antonio Araujo (aaraujo@cenditel.gob.ve), Jose Ruiz (jruiz@cenditel.gob.ve), Fundacion Centro Nacional de Desarrollo e Investigacion en Tecnologias Libres - CENDITEL. La Fundación CENDITEL concede permiso para usar, copiar, distribuir y/o modificar este programa, reconociendo el derecho que la humanidad posee al libre acceso al conocimiento, bajo los términos de la licencia de software GPL versión 2.0 de la Free Software Foundation. Este programa se distribuye con la esperanza de que sea util, pero SIN NINGUNA GARANTIA; tampoco las implicitas garantias de MERCANTILIDAD o ADECUACION A UN PROPOSITO PARTICULAR. Para mayor información sobre los términos de la licencia ver el archivo llamado "gpl-2.0.txt" en ingles. */ package ve.gob.cenditel.tibisaymovil; import java.io.File; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; public class EncryptionResultActivity extends Activity{ private String fileToEncrypt; private String encryptedFile; private String recipient; private String pathFileSigned; private LinearLayout button_share; private LinearLayout button_finish; @Override protected void onCreate(Bundle savedInstanceState) { //Capturando archivo original fileToEncrypt = getIntent().getExtras().getString("fileToEncrypt"); //Capturando archivo cifrado encryptedFile = getIntent().getExtras().getString("encryptedFile"); //Capturando destinatario recipient = getIntent().getExtras().getString("recipient"); //Estilando la barra de titulo final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_encryption_result); //Estilando Barra de titulo if(customTitleSupported) getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); TextView archivo_original_a_cifrar = (TextView) this.findViewById(R.id.archivo_original_pdf); TextView archivo_cifrado = (TextView) this.findViewById(R.id.archivo_descifrado); TextView destinatario = (TextView) this.findViewById(R.id.destinatario); archivo_original_a_cifrar.setText(fileToEncrypt); archivo_cifrado.setText(encryptedFile); destinatario.setText(recipient); showDialog("Información:", "Archivo cifrado exitosamente"); button_share = (LinearLayout) this.findViewById(R.id.button_remove_certificate_zone); button_finish = (LinearLayout) this.findViewById(R.id.button_add_certificate_zone); button_finish.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent oIntent = new Intent(EncryptionResultActivity.this, TibisayMovilActivity.class); oIntent.setAction(Intent.ACTION_VIEW); oIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(oIntent); finish(); } }); button_share.setOnClickListener(new OnClickListener() { public void onClick(View v) { shareIt(); } }); } // funcion para compartir el documento private void shareIt() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); File file = new File(encryptedFile); Uri uri = Uri.fromFile(file); Log.i("DEBUG", file.getPath()); //Log.d("******", getMimeType(file.getPath())); //shareIntent.setDataAndType(uri, getMimeType(file.getPath())); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("application/*"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share_it_using))); } /** * Crea un dialogo con el titulo y mensaje como argumentos y lo despliega * * @return void */ public void showDialog(String title, String msg) { // 1. Instantiate an AlertDialog.Builder with its constructor AlertDialog.Builder builder = new AlertDialog.Builder(EncryptionResultActivity.this); // 2. Chain together various setter methods to set the dialog characteristics builder.setMessage(msg) .setTitle(title); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button //Toast.makeText(getApplicationContext(), "User clicked OK button", Toast.LENGTH_LONG).show(); } }); // 3. Get the AlertDialog from create() AlertDialog dialog = builder.create(); dialog.show(); } }