[37467be] | 1 | package ve.gob.cenditel.tibisaymovil; |
---|
| 2 | |
---|
| 3 | import java.io.File; |
---|
[67541a6] | 4 | import java.io.FileInputStream; |
---|
| 5 | import java.io.InputStream; |
---|
[37467be] | 6 | import java.text.SimpleDateFormat; |
---|
| 7 | import java.util.ArrayList; |
---|
| 8 | import java.util.Collections; |
---|
| 9 | import java.util.Date; |
---|
[67541a6] | 10 | |
---|
| 11 | import javax.ws.rs.core.MediaType; |
---|
| 12 | |
---|
| 13 | import com.sun.jersey.multipart.file.DefaultMediaTypePredictor; |
---|
| 14 | |
---|
[37467be] | 15 | import ve.gob.cenditel.tibisaymovil.R; |
---|
| 16 | import android.app.Activity; |
---|
[a8bb2bb] | 17 | import android.app.AlertDialog; |
---|
[67541a6] | 18 | import android.content.Context; |
---|
| 19 | import android.content.ContextWrapper; |
---|
[a8bb2bb] | 20 | import android.content.DialogInterface; |
---|
| 21 | import android.content.Intent; |
---|
[67541a6] | 22 | import android.content.SharedPreferences; |
---|
[37467be] | 23 | import android.graphics.drawable.Drawable; |
---|
[a8bb2bb] | 24 | import android.net.Uri; |
---|
[37467be] | 25 | import android.os.Bundle; |
---|
[67541a6] | 26 | import android.preference.PreferenceManager; |
---|
[37467be] | 27 | import android.util.Log; |
---|
| 28 | import android.view.LayoutInflater; |
---|
| 29 | import android.view.View; |
---|
| 30 | import android.view.ViewGroup; |
---|
| 31 | import android.view.View.OnClickListener; |
---|
| 32 | import android.view.Window; |
---|
[a8bb2bb] | 33 | import android.webkit.MimeTypeMap; |
---|
[37467be] | 34 | import android.widget.AdapterView; |
---|
[a8bb2bb] | 35 | import android.widget.ArrayAdapter; |
---|
[37467be] | 36 | import android.widget.BaseAdapter; |
---|
| 37 | import android.widget.ImageView; |
---|
| 38 | import android.widget.LinearLayout; |
---|
| 39 | import android.widget.ListView; |
---|
[a8bb2bb] | 40 | import android.widget.RadioButton; |
---|
[37467be] | 41 | import android.widget.TextView; |
---|
| 42 | import android.widget.AdapterView.OnItemClickListener; |
---|
[a8bb2bb] | 43 | import android.widget.Toast; |
---|
[37467be] | 44 | |
---|
| 45 | public class FileToSignHandwrittenSignatureActivity extends Activity implements OnItemClickListener, OnClickListener { |
---|
| 46 | |
---|
| 47 | private File cwd; |
---|
[a8bb2bb] | 48 | private File selected; |
---|
[37467be] | 49 | private FileBrowserView viewHolder; |
---|
| 50 | private FileListAdapter listAdapter; |
---|
[a8bb2bb] | 51 | private String filterMImeType = "application/pdf"; |
---|
[67541a6] | 52 | |
---|
[37467be] | 53 | |
---|
| 54 | @Override |
---|
| 55 | protected void onCreate(Bundle savedInstanceState) { |
---|
| 56 | //Estilando la barra de titulo |
---|
| 57 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
| 58 | |
---|
| 59 | super.onCreate(savedInstanceState); |
---|
| 60 | |
---|
| 61 | this.viewHolder = new FileBrowserView(); |
---|
| 62 | |
---|
| 63 | if (savedInstanceState != null) { |
---|
[a8bb2bb] | 64 | if(savedInstanceState.getString("selected") != null) |
---|
| 65 | this.selected = new File(savedInstanceState.getString("selected")); |
---|
[37467be] | 66 | |
---|
[a8bb2bb] | 67 | if (this.selected != null) { |
---|
[37467be] | 68 | |
---|
| 69 | FileToSignHandwrittenSignatureActivity.this.updateButton |
---|
| 70 | (FileToSignHandwrittenSignatureActivity.this.viewHolder.accept,true); |
---|
| 71 | |
---|
| 72 | } |
---|
[a8bb2bb] | 73 | |
---|
[37467be] | 74 | this.cwd = new File(savedInstanceState.getString("cwd")); |
---|
[a8bb2bb] | 75 | this.viewHolder.fileList.setAdapter(this.listAdapter = new FileListAdapter(this.cwd.getAbsolutePath(), filterMImeType)); |
---|
[37467be] | 76 | |
---|
| 77 | } else { |
---|
[a8bb2bb] | 78 | this.selected = null; |
---|
[37467be] | 79 | this.viewHolder.fileList.setAdapter(this.listAdapter = new FileListAdapter()); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | boolean enabled = false; |
---|
[a8bb2bb] | 84 | if (this.selected != null) |
---|
[37467be] | 85 | enabled = this.viewHolder.accept.isEnabled(); |
---|
| 86 | |
---|
| 87 | FileToSignHandwrittenSignatureActivity.this.updateButton |
---|
| 88 | (FileToSignHandwrittenSignatureActivity.this.viewHolder.accept,enabled); |
---|
| 89 | |
---|
| 90 | //Estilando Barra de titulo |
---|
| 91 | if(customTitleSupported) |
---|
| 92 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
[67541a6] | 93 | |
---|
| 94 | |
---|
[37467be] | 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * Provides the data to be shown in the file browser ListView. |
---|
| 100 | * |
---|
| 101 | * @author José M. Prieto (jmprieto@emergya.com) |
---|
| 102 | */ |
---|
| 103 | private class FileListAdapter extends BaseAdapter { |
---|
| 104 | |
---|
| 105 | private final ArrayList<File> directories; |
---|
| 106 | private final ArrayList<File> files; |
---|
| 107 | |
---|
| 108 | private FileListAdapter() { |
---|
[a8bb2bb] | 109 | this("/",filterMImeType); |
---|
[37467be] | 110 | } |
---|
| 111 | |
---|
| 112 | private FileListAdapter(String location) { |
---|
[a8bb2bb] | 113 | this(location, ""); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | private FileListAdapter(String location, String filterMimeType) { |
---|
[37467be] | 117 | |
---|
| 118 | directories = new ArrayList<File>(); |
---|
| 119 | files = new ArrayList<File>(); |
---|
| 120 | |
---|
| 121 | //Obtiene etiqueta que se colocará antes del path que visualizará el usuario |
---|
| 122 | String toPathText = FileToSignHandwrittenSignatureActivity.this.getString(R.string.pathstring)+": "; |
---|
| 123 | //Coloca el texto de la etiqueta en la vista |
---|
| 124 | FileToSignHandwrittenSignatureActivity.this.viewHolder.pathString.setText(toPathText); |
---|
| 125 | //Coloca el texto con el path actual |
---|
| 126 | FileToSignHandwrittenSignatureActivity.this.viewHolder.path.setText(location); |
---|
| 127 | //Crea un objeto file cwd con la ubicacion dada en location |
---|
| 128 | FileToSignHandwrittenSignatureActivity.this.cwd = new File(location); |
---|
| 129 | //Obtiene el directorio padre del objeto file cwd |
---|
| 130 | File parent = FileToSignHandwrittenSignatureActivity.this.cwd.getParentFile(); |
---|
[a8bb2bb] | 131 | //Si tiene un padre, lo agrega en la posición cero de la lista de directorios |
---|
| 132 | |
---|
[37467be] | 133 | if (parent != null) { |
---|
| 134 | directories.add(0, parent); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | //Crea un arreglo con las lista de archivos contenidos en el directorio cwd |
---|
| 138 | File[] ls = FileToSignHandwrittenSignatureActivity.this.cwd.listFiles(); |
---|
| 139 | if (ls != null) { |
---|
| 140 | for (File f : ls) { //recorre todos los archivos contenidos en el directorio |
---|
[a8bb2bb] | 141 | |
---|
[37467be] | 142 | if (FsUtils.isHiddenOrNotReadable(f)) { // Si son ocultos no hace nada |
---|
| 143 | continue; |
---|
| 144 | } |
---|
| 145 | // Si son directorios los agrega a la lista de directorios a partir de la posición 1 |
---|
| 146 | // En la posición 0 se encuentra el directorio padre |
---|
| 147 | if (f.isDirectory()) { |
---|
| 148 | directories.add(f); |
---|
| 149 | } else // De lo contrario lo agrega a la lista de archivos |
---|
| 150 | { |
---|
[a8bb2bb] | 151 | //Valida tipo de archivo a mostrar |
---|
| 152 | Uri selectedUri = Uri.fromFile(f); |
---|
| 153 | String fileExtension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString()); |
---|
| 154 | String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); |
---|
| 155 | |
---|
| 156 | // Toast.makeText(FileToSignHandwrittenSignatureActivity.this, |
---|
| 157 | // "FileExtension: " + fileExtension + "\n" + |
---|
| 158 | // "MimeType: " + mimeType, |
---|
| 159 | // Toast.LENGTH_LONG).show(); |
---|
| 160 | |
---|
| 161 | //Filtra por mimeType |
---|
| 162 | if(filterMimeType.isEmpty() || filterMimeType == mimeType) |
---|
| 163 | files.add(f); |
---|
| 164 | |
---|
[37467be] | 165 | } |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | Collections.sort(directories); // Ordena los directorios alfabeticamente |
---|
| 170 | Collections.sort(files); // Ordena los archivos alfabeticamente |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | /** |
---|
| 174 | * Retorna cantidad total de elementos que se listarán en el directorio. |
---|
| 175 | */ |
---|
| 176 | @Override |
---|
| 177 | public int getCount() { |
---|
| 178 | |
---|
| 179 | return directories.size() + files.size(); |
---|
| 180 | |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | /** |
---|
| 184 | * Dada una posición en el listado del directorio, retorna un archivo o directorio |
---|
| 185 | * según corresponda. |
---|
| 186 | */ |
---|
| 187 | @Override |
---|
| 188 | public File getItem(int position) { |
---|
| 189 | |
---|
| 190 | if (position < directories.size()) { |
---|
| 191 | return directories.get(position); |
---|
| 192 | } else { |
---|
| 193 | return files.get(position - directories.size()); |
---|
| 194 | } |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | /** |
---|
| 198 | * Retorna un código hash para el archivo, permite comparar si dos archivos son los mismos |
---|
| 199 | */ |
---|
| 200 | @Override |
---|
| 201 | public long getItemId(int position) { |
---|
| 202 | |
---|
| 203 | return getItem(position).hashCode(); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | /** |
---|
| 207 | * Crea la visualización de cada item del fileBrowser |
---|
| 208 | */ |
---|
| 209 | @Override |
---|
| 210 | public View getView(int position, View convertView, ViewGroup parent) { |
---|
| 211 | |
---|
| 212 | //Crea la vista de cada fila del filebrowser a partir del layout |
---|
| 213 | if (convertView == null) { |
---|
| 214 | LayoutInflater inflater = LayoutInflater.from(FileToSignHandwrittenSignatureActivity.this); |
---|
[a8bb2bb] | 215 | convertView = inflater.inflate(R.layout.file_to_sign_handwritten_signature_item, parent, false); |
---|
[37467be] | 216 | } |
---|
| 217 | |
---|
| 218 | // Se enlaza a cada componente del layout |
---|
| 219 | ImageView image = (ImageView) convertView.findViewById(R.id.type_image); |
---|
| 220 | TextView fileName = (TextView) convertView.findViewById(R.id.filename_text); |
---|
| 221 | TextView modified = (TextView) convertView.findViewById(R.id.filename_modified); |
---|
| 222 | |
---|
| 223 | // Se obtiene el archivo ubicado en position |
---|
| 224 | File file = getItem(position); |
---|
| 225 | |
---|
[a8bb2bb] | 226 | //RadioButton |
---|
| 227 | RadioButton radio = (RadioButton) convertView.findViewById(R.id.file_radio); |
---|
| 228 | radio.setFocusable(false); |
---|
[37467be] | 229 | |
---|
[a8bb2bb] | 230 | // Se asignan los iconos según el tipo de archivo y se oculta el radio en los directorios |
---|
[37467be] | 231 | if (file.isDirectory()) { |
---|
| 232 | image.setImageResource(R.drawable.ic_carpeta); |
---|
[a8bb2bb] | 233 | radio.setVisibility(View.INVISIBLE); |
---|
| 234 | radio.setChecked(false); |
---|
[37467be] | 235 | } else { |
---|
| 236 | image.setImageResource(R.drawable.ic_archivo); |
---|
[a8bb2bb] | 237 | radio.setVisibility(View.VISIBLE); |
---|
| 238 | |
---|
| 239 | if (FileToSignHandwrittenSignatureActivity.this.selected == null || |
---|
| 240 | FileToSignHandwrittenSignatureActivity.this.selected.hashCode() != file.hashCode()){ |
---|
| 241 | radio.setChecked(false); |
---|
[37467be] | 242 | } else{ |
---|
[a8bb2bb] | 243 | radio.setChecked(true); |
---|
| 244 | } |
---|
[37467be] | 245 | } |
---|
| 246 | |
---|
| 247 | // Si es el directorio que hace referencia al padre le coloca como nombre ".." |
---|
| 248 | if (file.isDirectory() && position == 0 && ! "/".equals(FileToSignHandwrittenSignatureActivity.this.cwd.getAbsolutePath())) { |
---|
| 249 | fileName.setText(".."); |
---|
| 250 | } else { |
---|
| 251 | fileName.setText(file.getName()); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | //Datos de modificación del archivo |
---|
| 256 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
---|
| 257 | Date date = new Date(file.lastModified()); |
---|
| 258 | |
---|
| 259 | String dateString = FileToSignHandwrittenSignatureActivity.this.getString(R.string.modified)+": "; |
---|
| 260 | if (file.lastModified()>0) |
---|
| 261 | modified.setText(dateString+sdf.format(date)); |
---|
| 262 | else |
---|
| 263 | modified.setText(dateString+"-"); |
---|
| 264 | |
---|
| 265 | return convertView; |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | /** |
---|
| 269 | * Controla la selección de cada item del fileBrowser |
---|
| 270 | */ |
---|
| 271 | public void select(ListView parent, int position) { |
---|
| 272 | |
---|
| 273 | File item = getItem(position); |
---|
| 274 | //Si es un directorio el seleccionado se hace un llamado del fileBrowser del directorio |
---|
| 275 | if (item.isDirectory()) { |
---|
[a8bb2bb] | 276 | parent.setAdapter(FileToSignHandwrittenSignatureActivity.this.listAdapter = new FileListAdapter(item.getAbsolutePath(), filterMImeType)); |
---|
[37467be] | 277 | } else { // Si es un archivo |
---|
| 278 | |
---|
[a8bb2bb] | 279 | //Se agrega el archivo a la lista de seleccionados si no se encuentra en la misma |
---|
| 280 | if (FileToSignHandwrittenSignatureActivity.this.selected == null || |
---|
| 281 | FileToSignHandwrittenSignatureActivity.this.selected.hashCode() != item.hashCode()){ |
---|
[37467be] | 282 | |
---|
[a8bb2bb] | 283 | FileToSignHandwrittenSignatureActivity.this.selected = item; |
---|
[37467be] | 284 | |
---|
[a8bb2bb] | 285 | FileToSignHandwrittenSignatureActivity.this.updateButton(FileToSignHandwrittenSignatureActivity.this.viewHolder.accept,true); |
---|
| 286 | |
---|
| 287 | } |
---|
| 288 | else{ // De lo contrario se elimina de la lista de seleccionados |
---|
[37467be] | 289 | |
---|
[a8bb2bb] | 290 | FileToSignHandwrittenSignatureActivity.this.selected = null; |
---|
| 291 | FileToSignHandwrittenSignatureActivity.this.updateButton(FileToSignHandwrittenSignatureActivity.this.viewHolder.accept,false); |
---|
| 292 | |
---|
[37467be] | 293 | } |
---|
| 294 | notifyDataSetChanged(); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
[a8bb2bb] | 299 | |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | @Override |
---|
| 303 | protected void onSaveInstanceState(Bundle outState) { |
---|
| 304 | super.onSaveInstanceState(outState); |
---|
| 305 | |
---|
| 306 | outState.putParcelable("intent", this.getIntent()); |
---|
| 307 | outState.putString("cwd", this.cwd.getAbsolutePath()); |
---|
| 308 | if(this.selected != null) |
---|
| 309 | outState.putString("selected", this.selected.getAbsolutePath()); |
---|
| 310 | |
---|
| 311 | } |
---|
[37467be] | 312 | |
---|
| 313 | private void updateButton(View v, boolean bool) { |
---|
| 314 | try{ |
---|
| 315 | |
---|
| 316 | v.setEnabled(bool); |
---|
| 317 | if (v instanceof TextView){ |
---|
| 318 | Drawable icon = ((TextView)v).getCompoundDrawables()[1]; |
---|
| 319 | if (icon!=null) |
---|
| 320 | if (bool) |
---|
| 321 | icon.setAlpha(255); |
---|
| 322 | else |
---|
| 323 | icon.setAlpha(127); |
---|
| 324 | } |
---|
| 325 | if (v instanceof ImageView){ |
---|
| 326 | ImageView result = (ImageView) v; |
---|
| 327 | if (bool) |
---|
| 328 | result.setAlpha(255); |
---|
| 329 | else |
---|
| 330 | result.setAlpha(127); |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | }catch(NullPointerException e){} |
---|
| 334 | |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | private void updateButton(LinearLayout layout, boolean bool) { |
---|
| 338 | try{ |
---|
| 339 | layout.setEnabled(bool); |
---|
| 340 | for (int i=0; i<layout.getChildCount();i++){ |
---|
| 341 | this.updateButton(layout.getChildAt(i), bool); |
---|
| 342 | } |
---|
| 343 | }catch(NullPointerException e){} |
---|
| 344 | |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | |
---|
| 348 | |
---|
| 349 | /** |
---|
| 350 | * Holds references to view objects. |
---|
| 351 | * |
---|
| 352 | * @author José M. Prieto (jmprieto@emergya.com) |
---|
| 353 | */ |
---|
| 354 | private class FileBrowserView { |
---|
| 355 | |
---|
| 356 | public ListView fileList; |
---|
| 357 | public TextView path; |
---|
| 358 | public LinearLayout accept; |
---|
| 359 | public LinearLayout clear; |
---|
| 360 | public TextView pathString; |
---|
| 361 | |
---|
| 362 | public FileBrowserView() { |
---|
| 363 | |
---|
| 364 | setContentView(R.layout.activity_file_to_sign_handwritten_signature); |
---|
| 365 | this.path = (TextView) findViewById(R.id.path); |
---|
| 366 | this.pathString = (TextView) findViewById(R.id.pathstring); |
---|
| 367 | |
---|
| 368 | this.fileList = (ListView) findViewById(R.id.file_list); |
---|
| 369 | this.fileList.setOnItemClickListener(FileToSignHandwrittenSignatureActivity.this); |
---|
| 370 | this.fileList.setItemsCanFocus(true); |
---|
| 371 | |
---|
| 372 | |
---|
| 373 | this.clear = (LinearLayout) findViewById(R.id.button_clear_zone); |
---|
| 374 | this.clear.setOnClickListener(FileToSignHandwrittenSignatureActivity.this); |
---|
| 375 | |
---|
| 376 | this.accept = (LinearLayout) findViewById(R.id.button_accept_zone); |
---|
| 377 | this.accept.setOnClickListener(FileToSignHandwrittenSignatureActivity.this); |
---|
| 378 | |
---|
| 379 | } |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | @Override |
---|
| 383 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
---|
| 384 | |
---|
| 385 | |
---|
| 386 | if (parent.getId() == R.id.file_list) { // user selects a file |
---|
| 387 | this.listAdapter.select((ListView) parent, position); |
---|
| 388 | |
---|
| 389 | } else { // user de-selects a file |
---|
| 390 | //this.listAdapter.addIfSameDirectory(selectedAdapter.doUnselect((ListView) parent, position)); |
---|
| 391 | |
---|
| 392 | } |
---|
| 393 | //this.viewHolder.numSelected.setText(Integer.toString(this.selected.size())); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | @Override |
---|
| 397 | public void onClick(View v) { |
---|
| 398 | |
---|
| 399 | switch (v.getId()) { |
---|
| 400 | |
---|
| 401 | |
---|
| 402 | case R.id.button_clear_zone: |
---|
| 403 | |
---|
[a8bb2bb] | 404 | this.selected = null; |
---|
[37467be] | 405 | this.listAdapter.notifyDataSetChanged(); |
---|
| 406 | |
---|
| 407 | //this.viewHolder.numSelected.setText(""+this.selected.size()); |
---|
| 408 | this.updateButton(this.viewHolder.accept, false); |
---|
| 409 | break; |
---|
[a8bb2bb] | 410 | |
---|
| 411 | |
---|
| 412 | |
---|
| 413 | case R.id.button_accept_zone: |
---|
| 414 | |
---|
| 415 | //Crear dialogo de opciones para firmar |
---|
| 416 | final AlertDialog image_dialog = selectImageOptionsDialog(); |
---|
| 417 | image_dialog.show(); |
---|
| 418 | |
---|
| 419 | break; |
---|
| 420 | |
---|
[37467be] | 421 | } |
---|
| 422 | } |
---|
[a8bb2bb] | 423 | |
---|
| 424 | |
---|
| 425 | //Crea dialogo de opciones para seleccion de imagen de firma |
---|
| 426 | public AlertDialog selectImageOptionsDialog() { |
---|
[67541a6] | 427 | |
---|
| 428 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); |
---|
| 429 | |
---|
| 430 | final String imagePath = prefs.getString(PreferencesActivity.imageKey, ""); |
---|
| 431 | final String[] option; |
---|
| 432 | //---- |
---|
| 433 | if (imagePath.equals("")) { |
---|
| 434 | option = new String[] {getString(R.string.firmar_man_capt_img), getString(R.string.firmar_man_exist_img)}; |
---|
| 435 | } |
---|
| 436 | else { |
---|
| 437 | option = new String[] {getString(R.string.firmar_man_capt_img), getString(R.string.firmar_man_exist_img), getString(R.string.firmar_man_prefer_img) }; |
---|
| 438 | } |
---|
| 439 | |
---|
[a8bb2bb] | 440 | ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, |
---|
| 441 | android.R.layout.select_dialog_item, option); |
---|
| 442 | AlertDialog.Builder builder = new AlertDialog.Builder(this); |
---|
| 443 | |
---|
| 444 | builder.setTitle(getString(R.string.seleccione_opcion_firmar_man_img)); |
---|
| 445 | builder.setAdapter(adapter, new DialogInterface.OnClickListener() { |
---|
| 446 | |
---|
| 447 | public void onClick(DialogInterface dialog, int which) { |
---|
| 448 | |
---|
| 449 | switch (which) { |
---|
| 450 | case 0: // Capturar imágen |
---|
| 451 | Intent intent = new Intent(FileToSignHandwrittenSignatureActivity.this, CaptureImgHandwrittenSignatureActivity.class); |
---|
| 452 | intent.putExtra("FILE_TO_SIGN", FileToSignHandwrittenSignatureActivity.this.selected.getAbsolutePath()); |
---|
| 453 | Log.i("DEBUG", FileToSignHandwrittenSignatureActivity.this.selected.getAbsolutePath()); |
---|
| 454 | startActivity(intent); |
---|
| 455 | |
---|
| 456 | break; |
---|
| 457 | case 1: // Buscar en archivos |
---|
[288126d] | 458 | Intent intent1 = new Intent(FileToSignHandwrittenSignatureActivity.this, SelectImgHandwrittenSignatureActivity.class); |
---|
| 459 | intent1.putExtra("FILE_TO_SIGN", FileToSignHandwrittenSignatureActivity.this.selected.getAbsolutePath()); |
---|
| 460 | startActivity(intent1); |
---|
[a8bb2bb] | 461 | |
---|
| 462 | break; |
---|
| 463 | case 2: // Usar predeterminada |
---|
[67541a6] | 464 | Intent intent2 = new Intent(FileToSignHandwrittenSignatureActivity.this, SelectSignUbicationHandwrittenSignatureActivity.class); |
---|
| 465 | intent2.putExtra("FILE_TO_SIGN", FileToSignHandwrittenSignatureActivity.this.selected.getAbsolutePath()); |
---|
| 466 | intent2.putExtra("IMAGE_CAPTURED", imagePath); |
---|
| 467 | startActivity(intent2); |
---|
[a8bb2bb] | 468 | |
---|
| 469 | break; |
---|
| 470 | |
---|
| 471 | default: |
---|
| 472 | break; |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | }); |
---|
| 477 | |
---|
| 478 | return builder.create(); |
---|
| 479 | } |
---|
[37467be] | 480 | |
---|
| 481 | } |
---|