request storage permission when sending gif. fixes #2589
This commit is contained in:
parent
9b4cb37477
commit
26f7702c39
|
@ -85,6 +85,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
public static final int REQUEST_TRUST_KEYS_TEXT = 0x0208;
|
public static final int REQUEST_TRUST_KEYS_TEXT = 0x0208;
|
||||||
public static final int REQUEST_TRUST_KEYS_MENU = 0x0209;
|
public static final int REQUEST_TRUST_KEYS_MENU = 0x0209;
|
||||||
public static final int REQUEST_START_DOWNLOAD = 0x0210;
|
public static final int REQUEST_START_DOWNLOAD = 0x0210;
|
||||||
|
public static final int REQUEST_ADD_EDITOR_CONTENT = 0x0211;
|
||||||
public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
|
public static final int ATTACHMENT_CHOICE_CHOOSE_IMAGE = 0x0301;
|
||||||
public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
|
public static final int ATTACHMENT_CHOICE_TAKE_PHOTO = 0x0302;
|
||||||
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
|
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
|
||||||
|
@ -123,6 +124,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
private AtomicBoolean mRedirected = new AtomicBoolean(false);
|
private AtomicBoolean mRedirected = new AtomicBoolean(false);
|
||||||
private Pair<Integer, Intent> mPostponedActivityResult;
|
private Pair<Integer, Intent> mPostponedActivityResult;
|
||||||
private boolean mUnprocessedNewIntent = false;
|
private boolean mUnprocessedNewIntent = false;
|
||||||
|
public Uri mPendingEditorContent = null;
|
||||||
|
|
||||||
public Conversation getSelectedConversation() {
|
public Conversation getSelectedConversation() {
|
||||||
return this.mSelectedConversation;
|
return this.mSelectedConversation;
|
||||||
|
@ -644,6 +646,10 @@ public class ConversationActivity extends XmppActivity
|
||||||
if (this.mPendingDownloadableMessage != null) {
|
if (this.mPendingDownloadableMessage != null) {
|
||||||
startDownloadable(this.mPendingDownloadableMessage);
|
startDownloadable(this.mPendingDownloadableMessage);
|
||||||
}
|
}
|
||||||
|
} else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) {
|
||||||
|
if (this.mPendingEditorContent != null) {
|
||||||
|
attachImageToConversation(this.mPendingEditorContent);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
attachFile(requestCode);
|
attachFile(requestCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,17 +312,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (activity.hasStoragePermission(ConversationActivity.REQUEST_ADD_EDITOR_CONTENT)) {
|
||||||
// send the image
|
|
||||||
activity.attachImageToConversation(inputContentInfo.getContentUri());
|
activity.attachImageToConversation(inputContentInfo.getContentUri());
|
||||||
|
} else {
|
||||||
// TODO: revoke permissions?
|
activity.mPendingEditorContent = inputContentInfo.getContentUri();
|
||||||
// since uploading an image is async its tough to wire a callback to when
|
}
|
||||||
// the image has finished uploading.
|
|
||||||
// According to the docs: "calling IC#releasePermission() is just to be a
|
|
||||||
// good citizen. Even if we failed to call that method, the system would eventually revoke
|
|
||||||
// the permission sometime after inputContentInfo object gets garbage-collected."
|
|
||||||
// See: https://developer.android.com/samples/CommitContentSampleApp/src/com.example.android.commitcontent.app/MainActivity.html#l164
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -455,7 +449,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
|
final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
|
||||||
view.setOnClickListener(null);
|
view.setOnClickListener(null);
|
||||||
|
|
||||||
String[] allImagesMimeType = {"image/*"};
|
|
||||||
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
|
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
|
||||||
mEditMessage.setOnClickListener(new OnClickListener() {
|
mEditMessage.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@ -466,8 +459,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mEditMessage.setOnEditorActionListener(mEditorActionListener);
|
mEditMessage.setOnEditorActionListener(mEditorActionListener);
|
||||||
mEditMessage.setRichContentListener(allImagesMimeType, mEditorContentListener);
|
mEditMessage.setRichContentListener(new String[]{"image/*"}, mEditorContentListener);
|
||||||
|
|
||||||
mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
|
mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
|
||||||
mSendButton.setOnClickListener(this.mSendButtonListener);
|
mSendButton.setOnClickListener(this.mSendButtonListener);
|
||||||
|
|
Loading…
Reference in New Issue