diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index af94d017b..d9181aa95 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -241,15 +241,6 @@ public class XmppConnectionService extends Service { public HttpConnectionManager mHttpConnectionManager = new HttpConnectionManager(this); private ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor(true); private long mLastActivity = 0; - private ContentObserver contactObserver = new ContentObserver(null) { - @Override - public void onChange(boolean selfChange) { - super.onChange(selfChange); - if (restoredFromDatabaseLatch.getCount() == 0) { - loadPhoneContacts(); - } - } - }; private MemorizingTrustManager mMemorizingTrustManager; private NotificationService mNotificationService = new NotificationService(this); private ShortcutService mShortcutService = new ShortcutService(this); @@ -1119,8 +1110,7 @@ public class XmppConnectionService extends Service { restoreFromDatabase(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) { - //TODO get this restarted if users gives permission - getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver); + startContactObserver(); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ContextCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Log.d(Config.LOGTAG, "starting file observer"); @@ -1162,6 +1152,18 @@ public class XmppConnectionService extends Service { } } + public void startContactObserver() { + getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, new ContentObserver(null) { + @Override + public void onChange(boolean selfChange) { + super.onChange(selfChange); + if (restoredFromDatabaseLatch.getCount() == 0) { + loadPhoneContacts(); + } + } + }); + } + @Override public void onTrimMemory(int level) { super.onTrimMemory(level); @@ -1729,7 +1731,7 @@ public class XmppConnectionService extends Service { } Log.d(Config.LOGTAG, "finished merging phone contacts"); mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true)); - updateAccountUi(); + updateRosterUi(); } })); } |