1 | /* |
---|
2 | Tibisay Movil |
---|
3 | |
---|
4 | Copyright (C) 2013 Antonio Araujo (aaraujo@cenditel.gob.ve), Jose Ruiz |
---|
5 | (jruiz@cenditel.gob.ve), Fundacion Centro Nacional de Desarrollo e |
---|
6 | Investigacion en Tecnologias Libres - CENDITEL. |
---|
7 | |
---|
8 | La Fundación CENDITEL concede permiso para usar, copiar, distribuir y/o |
---|
9 | modificar este programa, reconociendo el derecho que la humanidad posee al |
---|
10 | libre acceso al conocimiento, bajo los términos de la licencia de software |
---|
11 | GPL versión 2.0 de la Free Software Foundation. |
---|
12 | |
---|
13 | Este programa se distribuye con la esperanza de que sea util, pero SIN |
---|
14 | NINGUNA GARANTIA; tampoco las implicitas garantias de MERCANTILIDAD o |
---|
15 | ADECUACION A UN PROPOSITO PARTICULAR. |
---|
16 | |
---|
17 | Para mayor información sobre los términos de la licencia ver el archivo |
---|
18 | llamado "gpl-2.0.txt" en ingles. |
---|
19 | */ |
---|
20 | |
---|
21 | package ve.gob.cenditel.tibisaymovil; |
---|
22 | |
---|
23 | |
---|
24 | import java.io.File; |
---|
25 | |
---|
26 | import android.app.Activity; |
---|
27 | import android.app.AlertDialog; |
---|
28 | import android.content.DialogInterface; |
---|
29 | import android.content.Intent; |
---|
30 | import android.net.Uri; |
---|
31 | import android.os.Bundle; |
---|
32 | import android.util.Log; |
---|
33 | import android.view.View; |
---|
34 | import android.view.View.OnClickListener; |
---|
35 | import android.view.Window; |
---|
36 | import android.widget.LinearLayout; |
---|
37 | import android.widget.TextView; |
---|
38 | import android.widget.Toast; |
---|
39 | |
---|
40 | public class EncryptionResultActivity extends Activity{ |
---|
41 | private String fileToEncrypt; |
---|
42 | private String encryptedFile; |
---|
43 | private String recipient; |
---|
44 | private String pathFileSigned; |
---|
45 | private LinearLayout button_share; |
---|
46 | private LinearLayout button_finish; |
---|
47 | |
---|
48 | @Override |
---|
49 | protected void onCreate(Bundle savedInstanceState) { |
---|
50 | |
---|
51 | //Capturando archivo original |
---|
52 | fileToEncrypt = getIntent().getExtras().getString("fileToEncrypt"); |
---|
53 | |
---|
54 | //Capturando archivo cifrado |
---|
55 | encryptedFile = getIntent().getExtras().getString("encryptedFile"); |
---|
56 | |
---|
57 | //Capturando destinatario |
---|
58 | recipient = getIntent().getExtras().getString("recipient"); |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | //Estilando la barra de titulo |
---|
63 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
64 | |
---|
65 | super.onCreate(savedInstanceState); |
---|
66 | setContentView(R.layout.activity_encryption_result); |
---|
67 | //Estilando Barra de titulo |
---|
68 | if(customTitleSupported) |
---|
69 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
70 | |
---|
71 | TextView archivo_original_a_cifrar = (TextView) this.findViewById(R.id.archivo_original_pdf); |
---|
72 | TextView archivo_cifrado = (TextView) this.findViewById(R.id.archivo_descifrado); |
---|
73 | TextView destinatario = (TextView) this.findViewById(R.id.destinatario); |
---|
74 | |
---|
75 | archivo_original_a_cifrar.setText(fileToEncrypt); |
---|
76 | archivo_cifrado.setText(encryptedFile); |
---|
77 | destinatario.setText(recipient); |
---|
78 | |
---|
79 | |
---|
80 | showDialog("Información:", "Archivo cifrado exitosamente"); |
---|
81 | |
---|
82 | button_share = (LinearLayout) this.findViewById(R.id.button_remove_certificate_zone); |
---|
83 | button_finish = (LinearLayout) this.findViewById(R.id.button_add_certificate_zone); |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | button_finish.setOnClickListener(new OnClickListener() |
---|
88 | { |
---|
89 | public void onClick(View v) |
---|
90 | { |
---|
91 | Intent oIntent = new Intent(EncryptionResultActivity.this, TibisayMovilActivity.class); |
---|
92 | oIntent.setAction(Intent.ACTION_VIEW); |
---|
93 | oIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
---|
94 | startActivity(oIntent); |
---|
95 | finish(); |
---|
96 | } |
---|
97 | }); |
---|
98 | |
---|
99 | button_share.setOnClickListener(new OnClickListener() |
---|
100 | { |
---|
101 | public void onClick(View v) |
---|
102 | { |
---|
103 | shareIt(); |
---|
104 | } |
---|
105 | }); |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | // funcion para compartir el documento |
---|
110 | private void shareIt() { |
---|
111 | |
---|
112 | Intent shareIntent = new Intent(); |
---|
113 | shareIntent.setAction(Intent.ACTION_SEND); |
---|
114 | File file = new File(encryptedFile); |
---|
115 | |
---|
116 | |
---|
117 | Uri uri = Uri.fromFile(file); |
---|
118 | Log.i("DEBUG", file.getPath()); |
---|
119 | //Log.d("******", getMimeType(file.getPath())); |
---|
120 | //shareIntent.setDataAndType(uri, getMimeType(file.getPath())); |
---|
121 | shareIntent.putExtra(Intent.EXTRA_STREAM, uri); |
---|
122 | shareIntent.setType("application/*"); |
---|
123 | startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share_it_using))); |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | /** |
---|
128 | * Crea un dialogo con el titulo y mensaje como argumentos y lo despliega |
---|
129 | * |
---|
130 | * @return void |
---|
131 | */ |
---|
132 | public void showDialog(String title, String msg) { |
---|
133 | |
---|
134 | // 1. Instantiate an AlertDialog.Builder with its constructor |
---|
135 | AlertDialog.Builder builder = new AlertDialog.Builder(EncryptionResultActivity.this); |
---|
136 | |
---|
137 | // 2. Chain together various setter methods to set the dialog characteristics |
---|
138 | builder.setMessage(msg) |
---|
139 | .setTitle(title); |
---|
140 | |
---|
141 | builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { |
---|
142 | public void onClick(DialogInterface dialog, int id) { |
---|
143 | // User clicked OK button |
---|
144 | //Toast.makeText(getApplicationContext(), "User clicked OK button", Toast.LENGTH_LONG).show(); |
---|
145 | |
---|
146 | } |
---|
147 | }); |
---|
148 | |
---|
149 | // 3. Get the AlertDialog from create() |
---|
150 | AlertDialog dialog = builder.create(); |
---|
151 | dialog.show(); |
---|
152 | |
---|
153 | } |
---|
154 | |
---|
155 | } |
---|