@Override public void detailFragmentClick(int position) { Log.d(thisClass, position + " is choose"); ArrayList<UIFileInfo> children = UIFileInfo.addFileFrom(currentSelectedDir()); if (children != null) { if (position >= children.size()) { throw new RuntimeException("position < childrenCache.get(fatherIndex).size()"); } } else { throw new RuntimeException(""); } UIFileInfo UIFileInfo = children.get(position); if (UIFileInfo.isDir()) { folderFragment.clearListView(); folderFragment.addListView(children).notifyDataSetChanged(); updateDetailFileInfo(UIFileInfo.toFile()); } else { // decrypt file and show it FileEncryption fileEncryption; try { fileEncryption = new FileEncryption(UIFileInfo.toFile(), password); } catch (IOException e) { Log.e(thisClass, "can't read file" + e); return; } DecryptedFile decryptedFile; try { if (fileEncryption.largeLinkedSize()) { decryptedFile = fileEncryption.decryptPart(); } else { fileEncryption.decryptAll(true); } } catch (InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | IOException | UnrecoverableEntryException e) { Log.e(thisClass, " failed: " + e.toString()); } // add file path of to be deleted file delPaths.add(fileEncryption.getEncryptedFilePath()); // start app to view different file // Intent intent = getMyImgIntent(this, fileEncryption); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType( Uri.parse(fileEncryption.getFileUri()), FileUtility.getMimeType(fileEncryption.getLinkedFilePath())); if (IntentUtil.intentSafe(intent, this)) { startActivity(intent); } } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case R.id.with_action_search: File d = new File("/storage/emulated/0/DCIM/Camera/"); File d1 = new File("/storage/emulated/0/DCIM/"); for (File file1 : d.listFiles()) { Log.i(thisClass, file1.getName()); } for (File file1 : d1.listFiles()) { Log.i(thisClass, file1.getName()); } break; case R.id.with_action_add: // show chooser to show file Intent intent = IntentUtil.intentWithChooser(this, Intent.ACTION_GET_CONTENT); if (IntentUtil.intentSafe(intent, this)) { startActivityForResult(intent, PICK_FILE_REQUEST_CODE); Log.i(thisClass, "when will app run to here"); } else { // remind use that no apps to open to add Intent remind = new Intent(this, RemindDialog.class); remind.putExtra(RemindDialog.REMIND_MSG, "no app to get content"); startActivity(remind); } break; case R.id.with_action_settings: break; } return super.onOptionsItemSelected(item); }