source: dispositivos_moviles/TibisayMovil/src/ve/gob/cenditel/tibisaymovil/EncryptionResultActivity.java @ 0a5cb8c

Last change on this file since 0a5cb8c was 0a5cb8c, checked in by Antonio Araujo Brett <aaraujo@…>, 11 years ago

*- Corrección de error al mostrar resultados del proceso de cifrado y descifrado de un archivo.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1package ve.gob.cenditel.tibisaymovil;
2
3
4import java.io.File;
5
6import android.app.Activity;
7import android.app.AlertDialog;
8import android.content.DialogInterface;
9import android.content.Intent;
10import android.net.Uri;
11import android.os.Bundle;
12import android.util.Log;
13import android.view.View;
14import android.view.View.OnClickListener;
15import android.view.Window;
16import android.widget.LinearLayout;
17import android.widget.TextView;
18import android.widget.Toast;
19
20public class EncryptionResultActivity extends Activity{
21    private String fileToEncrypt;
22    private String encryptedFile;
23    private String recipient;
24    private String pathFileSigned;
25    private LinearLayout button_share;
26    private LinearLayout button_finish;
27       
28        @Override               
29        protected void onCreate(Bundle savedInstanceState) {
30                       
31        //Capturando archivo original
32                fileToEncrypt = getIntent().getExtras().getString("fileToEncrypt");
33
34                //Capturando archivo cifrado
35                encryptedFile = getIntent().getExtras().getString("encryptedFile");
36                               
37        //Capturando destinatario
38        recipient = getIntent().getExtras().getString("recipient");
39       
40       
41               
42                //Estilando la barra de titulo
43                final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
44       
45                super.onCreate(savedInstanceState);
46        setContentView(R.layout.activity_encryption_result);
47            //Estilando Barra de titulo
48                if(customTitleSupported)
49                        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
50               
51        TextView archivo_original_a_cifrar = (TextView) this.findViewById(R.id.archivo_original_pdf);
52        TextView archivo_cifrado = (TextView) this.findViewById(R.id.archivo_descifrado);
53        TextView destinatario = (TextView) this.findViewById(R.id.destinatario);
54
55        archivo_original_a_cifrar.setText(fileToEncrypt);
56        archivo_cifrado.setText(encryptedFile);
57        destinatario.setText(recipient);
58
59       
60        showDialog("Información:", "Archivo cifrado exitosamente");
61       
62        button_share = (LinearLayout) this.findViewById(R.id.button_remove_certificate_zone);
63        button_finish = (LinearLayout) this.findViewById(R.id.button_add_certificate_zone);         
64       
65               
66       
67        button_finish.setOnClickListener(new OnClickListener() 
68        {       
69            public void onClick(View v) 
70            {
71                Intent oIntent = new Intent(EncryptionResultActivity.this, TibisayMovilActivity.class);
72                        oIntent.setAction(Intent.ACTION_VIEW);
73                        oIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
74                        startActivity(oIntent);
75                        finish();
76            }
77        });
78       
79        button_share.setOnClickListener(new OnClickListener() 
80        {       
81            public void onClick(View v) 
82            {
83                shareIt();
84            }
85        });
86        }
87       
88       
89        // funcion para compartir el documento
90        private void shareIt() {
91               
92                Intent shareIntent = new Intent();
93                shareIntent.setAction(Intent.ACTION_SEND);
94                File file = new File(encryptedFile);
95               
96               
97                Uri uri = Uri.fromFile(file);
98                Log.i("DEBUG", file.getPath());
99                //Log.d("******", getMimeType(file.getPath()));
100                //shareIntent.setDataAndType(uri, getMimeType(file.getPath()));
101                shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
102                shareIntent.setType("application/*");
103                startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share_it_using)));
104        }
105       
106       
107        /**
108     * Crea un dialogo con el titulo y mensaje como argumentos y lo despliega 
109     *
110     * @return void
111     */
112    public void showDialog(String title, String msg) {
113       
114        // 1. Instantiate an AlertDialog.Builder with its constructor
115                AlertDialog.Builder builder = new AlertDialog.Builder(EncryptionResultActivity.this);
116
117                // 2. Chain together various setter methods to set the dialog characteristics
118                builder.setMessage(msg)
119                .setTitle(title);
120
121                builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
122            public void onClick(DialogInterface dialog, int id) {
123                // User clicked OK button                                               
124                Toast.makeText(getApplicationContext(), "User clicked OK button", Toast.LENGTH_LONG).show();
125
126            }
127                });
128               
129                // 3. Get the AlertDialog from create()                         
130                AlertDialog dialog = builder.create();
131                dialog.show(); 
132       
133    }
134       
135}
Note: See TracBrowser for help on using the repository browser.