aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java14
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java10
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java27
-rw-r--r--src/main/java/eu/siacs/conversations/ui/startUI.java8
4 files changed, 50 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index b34c22b71..c24946fbd 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -677,7 +677,17 @@ public class ConversationActivity extends XmppActivity
return;
}
}
- switch (attachmentChoice) {
+ if (attachmentChoice == ATTACHMENT_CHOICE_RECORD_VOICE) {
+ if (!hasMicPermission(attachmentChoice)) {
+ return;
+ }
+ }
+ if (attachmentChoice == ATTACHMENT_CHOICE_LOCATION) {
+ if (!hasLocationPermission(attachmentChoice)) {
+ return;
+ }
+ }
+ switch (attachmentChoice) {
case ATTACHMENT_CHOICE_LOCATION:
getPreferences().edit().putString("recently_used_quick_action", "location").apply();
break;
@@ -767,7 +777,7 @@ public class ConversationActivity extends XmppActivity
attachFile(requestCode);
}
} else {
- Toast.makeText(this, R.string.no_storage_permission, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, R.string.no_permission, Toast.LENGTH_SHORT).show();
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
index 0956be1a9..a25d2b19c 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
@@ -1,10 +1,13 @@
package eu.siacs.conversations.ui;
+import android.Manifest;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
+import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
@@ -104,7 +107,12 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
@Override
public void onMapReady(GoogleMap googleMap) {
this.mGoogleMap = googleMap;
- this.mGoogleMap.setMyLocationEnabled(true);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
+ || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ this.mGoogleMap.setMyLocationEnabled(true);
+ }
+ }
if (this.mLocation != null) {
this.markAndCenterOnLocation(this.mLocation,this.mLocationName);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 0655c6578..31bf27a1b 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -881,6 +881,33 @@ public abstract class XmppActivity extends Activity {
}
}
+ public boolean hasMicPermission(int requestCode) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, requestCode);
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+
+ public boolean hasLocationPermission(int requestCode) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, requestCode);
+ requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, requestCode);
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+
public void selectPresence(final Conversation conversation,
final OnPresenceSelected listener) {
final Contact contact = conversation.getContact();
diff --git a/src/main/java/eu/siacs/conversations/ui/startUI.java b/src/main/java/eu/siacs/conversations/ui/startUI.java
index c2758054b..e33e75401 100644
--- a/src/main/java/eu/siacs/conversations/ui/startUI.java
+++ b/src/main/java/eu/siacs/conversations/ui/startUI.java
@@ -20,17 +20,13 @@ import eu.siacs.conversations.R;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;
-public class startUI extends AppCompatActivity
+public class StartUI extends AppCompatActivity
implements EasyPermissions.PermissionCallbacks {
private static final int NeededPermissions = 1000;
String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.READ_CONTACTS,
- Manifest.permission.RECORD_AUDIO,
- Manifest.permission.ACCESS_COARSE_LOCATION,
- Manifest.permission.ACCESS_FINE_LOCATION,
};
@Override
@@ -110,4 +106,4 @@ public class startUI extends AppCompatActivity
protected void onDestroy() {
super.onDestroy();
}
-}
+} \ No newline at end of file