mirror of https://github.com/M66B/FairEmail.git
Check for contacts permission
This commit is contained in:
parent
5a49e9a32a
commit
d0de9d5ee7
|
@ -19,6 +19,7 @@ package eu.faircode.email;
|
|||
Copyright 2018 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -28,6 +29,7 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.IntentSender;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -101,6 +103,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -718,8 +721,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
|
||||
ShortcutManager sm = (ShortcutManager) getSystemService(Context.SHORTCUT_SERVICE);
|
||||
|
||||
Cursor cursor = null;
|
||||
List<ShortcutInfo> shortcuts = new ArrayList<>();
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
// https://developer.android.com/guide/topics/providers/contacts-provider#ObsoleteData
|
||||
cursor = getContentResolver().query(
|
||||
|
@ -785,6 +791,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
sm.setDynamicShortcuts(shortcuts);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package eu.faircode.email;
|
|||
Copyright 2018 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
|
@ -636,6 +637,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
}
|
||||
|
||||
if (!TextUtils.isEmpty(message.avatar)) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = getContentResolver().query(
|
||||
|
@ -665,6 +668,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
mbuilder.addPerson(new Person.Builder()
|
||||
|
|
Loading…
Reference in New Issue