aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-04 20:49:02 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-04 20:49:02 +0200
commit4842181235241bdc362cfdce17c4ef5b3d2b9572 (patch)
tree73b2e087922809683a3d56338e54b6a9f84b338a /src/main/java/de/pixart
parent573ad6073ac9f0154997232ff39f559d91377994 (diff)
request storage permission when sending gif
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java18
2 files changed, 12 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index bc2e8622e..ef864669d 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -104,6 +104,7 @@ public class ConversationActivity extends XmppActivity
public static final int REQUEST_TRUST_KEYS_TEXT = 0x0208;
public static final int REQUEST_TRUST_KEYS_MENU = 0x0209;
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_TAKE_FROM_CAMERA = 0x0302;
public static final int ATTACHMENT_CHOICE_CHOOSE_FILE = 0x0303;
@@ -144,6 +145,7 @@ public class ConversationActivity extends XmppActivity
private AtomicBoolean mRedirected = new AtomicBoolean(false);
private Pair<Integer, Intent> mPostponedActivityResult;
private boolean mUnprocessedNewIntent = false;
+ public Uri mPendingEditorContent = null;
private boolean showLastSeen = false;
long FirstStartTime = -1;
@@ -814,6 +816,10 @@ public class ConversationActivity extends XmppActivity
if (this.mPendingDownloadableMessage != null) {
startDownloadable(this.mPendingDownloadableMessage);
}
+ } else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) {
+ if (this.mPendingEditorContent != null) {
+ attachImageToConversation(this.mPendingEditorContent);
+ }
} else {
attachFile(requestCode);
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 7dab99278..7832470a4 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -318,16 +318,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
}
- // send the image
- activity.attachImageToConversation(inputContentInfo.getContentUri());
-
- // TODO: revoke permissions?
- // 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
+ if (activity.hasStoragePermission(ConversationActivity.REQUEST_ADD_EDITOR_CONTENT)) {
+ activity.attachImageToConversation(inputContentInfo.getContentUri());
+ } else {
+ activity.mPendingEditorContent = inputContentInfo.getContentUri();
+ }
return true;
}
};
@@ -470,7 +465,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_conversation, container, false);
view.setOnClickListener(null);
- String[] allImagesMimeType = {"image/*"};
mEditMessage = (EditMessage) view.findViewById(R.id.textinput);
mEditMessage.setOnClickListener(new OnClickListener() {
@@ -482,7 +476,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
});
mEditMessage.setOnEditorActionListener(mEditorActionListener);
- mEditMessage.setRichContentListener(allImagesMimeType, mEditorContentListener);
+ mEditMessage.setRichContentListener(new String[]{"image/*"}, mEditorContentListener);
mSendButton = (ImageButton) view.findViewById(R.id.textSendButton);
mSendButton.setOnClickListener(this.mSendButtonListener);