aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-01-13 17:48:30 +0100
committerChristian S <christian@pix-art.de>2016-01-13 17:48:30 +0100
commit4c2dc7082855581d875c51d97650c7b4a435abe5 (patch)
tree818ebaea4bfa9743e0acf85abc92afca7b51449a /src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
parentc133b1d7e1cc9a3a3426d26e35cc038b508e1691 (diff)
parent3b3aa5b5841494ba02fe327f910558eb40e662b5 (diff)
Merge branch 'siacs/master' into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
index 3313ce318..edd6cf150 100644
--- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
@@ -3,6 +3,7 @@ package eu.siacs.conversations.ui;
import android.app.PendingIntent;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
@@ -137,16 +138,35 @@ public class PublishProfilePictureActivity extends XmppActivity {
@Override
public void onClick(View v) {
- Intent attachFileIntent = new Intent();
- attachFileIntent.setType("image/*");
- attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
- Intent chooser = Intent.createChooser(attachFileIntent, getString(R.string.attach_file));
- startActivityForResult(chooser, REQUEST_CHOOSE_FILE);
+ if (hasStoragePermission(REQUEST_CHOOSE_FILE)) {
+ chooseAvatar();
+ }
+
}
});
this.defaultUri = PhoneHelper.getSefliUri(getApplicationContext());
}
+ private void chooseAvatar() {
+ Intent attachFileIntent = new Intent();
+ attachFileIntent.setType("image/*");
+ attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
+ Intent chooser = Intent.createChooser(attachFileIntent, getString(R.string.attach_file));
+ startActivityForResult(chooser, REQUEST_CHOOSE_FILE);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
+ if (grantResults.length > 0)
+ if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ if (requestCode == REQUEST_CHOOSE_FILE) {
+ chooseAvatar();
+ }
+ } else {
+ Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
+ }
+ }
+
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);