diff options
Diffstat (limited to '')
-rw-r--r-- | build.gradle | 4 | ||||
-rw-r--r-- | src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 14 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java | 10 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 27 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/startUI.java | 8 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
7 files changed, 54 insertions, 12 deletions
diff --git a/build.gradle b/build.gradle index 2a5378a50..07075ffe3 100644 --- a/build.gradle +++ b/build.gradle @@ -73,8 +73,8 @@ android { minSdkVersion 14 targetSdkVersion 23 - versionCode 154 - versionName "1.13.4" + versionCode 155 + versionName "1.13.5 beta (2016-06-21)" archivesBaseName += "-$versionName" applicationId "de.pixart.messenger" diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 61593ed48..37c274962 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -49,7 +49,7 @@ </receiver> <activity - android:name=".ui.startUI" + android:name=".ui.StartUI" android:configChanges="orientation|screenSize" android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:label="@string/app_name" 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 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 778a9d758..f318b7024 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -666,4 +666,5 @@ <string name="request_permissions_message">Pix-Art Messenger will ask you to allow a few permissions. It is important that you allow all these permissions to use all features of this messenger. If you deny any of these permissions the app will close itself.</string> <string name="request_permissions_message_again">You have denied some or all permissions needed for Pix-Art Messenger. Would you like to jump to the settings and allow these permissions? If you denie any of these permissions, the app will close itself.</string> <string name="unable_to_connect_to_keychain">Unable to connect to OpenKeychain</string> + <string name="no_permission">Pix-Art Messenger has no permissions</string> </resources> |