use of org.awesomeapp.messenger.util.SystemServices.FileInfo in project Zom-Android by zom.
the class ImUrlActivity method sendOtrInBand.
private void sendOtrInBand(String username, long providerId, long accountId) {
try {
IImConnection conn = ((ImApp) getApplication()).getConnection(providerId, accountId);
if (conn == null)
// can't send without a connection
return;
mChatSessionManager = conn.getChatSessionManager();
IChatSession session = getChatSession(username);
if (mSendText != null)
session.sendMessage(mSendText, false);
else if (mSendUri != null) {
try {
String offerId = UUID.randomUUID().toString();
// Log.i(TAG, "mSendUrl " +mSendUrl);
Uri vfsUri = null;
if (SecureMediaStore.isVfsUri(mSendUri)) {
vfsUri = mSendUri;
boolean sent = session.offerData(offerId, vfsUri.toString(), mSendType);
if (sent)
return;
} else {
InputStream is = getContentResolver().openInputStream(mSendUri);
String fileName = mSendUri.getLastPathSegment();
FileInfo importInfo = SystemServices.getFileInfoFromURI(this, mSendUri);
if (!TextUtils.isEmpty(importInfo.type)) {
if (importInfo.type.startsWith("image"))
vfsUri = SecureMediaStore.resizeAndImportImage(this, session.getId() + "", mSendUri, importInfo.type);
else
vfsUri = SecureMediaStore.importContent(session.getId() + "", fileName, is);
boolean sent = session.offerData(offerId, vfsUri.toString(), importInfo.type);
if (sent)
return;
}
}
} catch (Exception e) {
Log.e(TAG, "error sending external file", e);
}
Toast.makeText(this, R.string.unable_to_securely_share_this_file, Toast.LENGTH_LONG).show();
}
} catch (RemoteException e) {
Log.e(TAG, "Error sending data", e);
}
}
Aggregations