private void importVCardFromSDCard(final List<VCardFile> selectedVCardFileList) { final int size = selectedVCardFileList.size(); String[] uriStrings = new String[size]; int i = 0; for (VCardFile vcardFile : selectedVCardFileList) { uriStrings[i] = "file://" + vcardFile.getCanonicalPath(); i++; } importVCard(uriStrings); }
private Dialog getVCardFileSelectDialog(boolean multipleSelect) { final int size = mAllVCardFileList.size(); final VCardSelectedListener listener = new VCardSelectedListener(multipleSelect); final AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.select_vcard_title) .setPositiveButton(android.R.string.ok, listener) .setOnCancelListener(mCancelListener) .setNegativeButton(android.R.string.cancel, mCancelListener); CharSequence[] items = new CharSequence[size]; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (int i = 0; i < size; i++) { VCardFile vcardFile = mAllVCardFileList.get(i); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); stringBuilder.append(vcardFile.getName()); stringBuilder.append('\n'); int indexToBeSpanned = stringBuilder.length(); // Smaller date text looks better, since each file name becomes easier to read. // The value set to RelativeSizeSpan is arbitrary. You can change it to any other // value (but the value bigger than 1.0f would not make nice appearance :) stringBuilder.append("(" + dateFormat.format(new Date(vcardFile.getLastModified())) + ")"); stringBuilder.setSpan( new RelativeSizeSpan(0.7f), indexToBeSpanned, stringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); items[i] = stringBuilder; } if (multipleSelect) { builder.setMultiChoiceItems(items, (boolean[]) null, listener); } else { builder.setSingleChoiceItems(items, 0, listener); } return builder.create(); }
private void importVCardFromSDCard(final VCardFile vcardFile) { importVCard(new Uri[] {Uri.parse("file://" + vcardFile.getCanonicalPath())}); }