remove address book integration from Conversations on PlayStore
This commit is contained in:
parent
33c63fb562
commit
8598462737
|
@ -105,7 +105,7 @@ android {
|
||||||
def appName = "Conversations"
|
def appName = "Conversations"
|
||||||
resValue "string", "app_name", appName
|
resValue "string", "app_name", appName
|
||||||
buildConfigField "String", "APP_NAME", "\"$appName\""
|
buildConfigField "String", "APP_NAME", "\"$appName\""
|
||||||
buildConfigField "String", "PRIVACY_POLICY", "null"
|
buildConfigField "String", "PRIVACY_POLICY", "\"https://conversations.im/privacy.html\""
|
||||||
}
|
}
|
||||||
|
|
||||||
splits {
|
splits {
|
||||||
|
|
6
src/free/AndroidManifest.xml
Normal file
6
src/free/AndroidManifest.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||||
|
</manifest>
|
|
@ -5,8 +5,6 @@
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.READ_PHONE_STATE"
|
android:name="android.permission.READ_PHONE_STATE"
|
||||||
android:maxSdkVersion="22" />
|
android:maxSdkVersion="22" />
|
||||||
|
|
|
@ -8,28 +8,39 @@ import android.os.Build;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.Config;
|
||||||
|
import eu.siacs.conversations.services.QuickConversationsService;
|
||||||
|
import eu.siacs.conversations.xmpp.Jid;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
|
||||||
import eu.siacs.conversations.xmpp.Jid;
|
|
||||||
|
|
||||||
public class JabberIdContact extends AbstractPhoneContact {
|
public class JabberIdContact extends AbstractPhoneContact {
|
||||||
|
|
||||||
private static final String[] PROJECTION = new String[]{ContactsContract.Data._ID,
|
private static final String[] PROJECTION =
|
||||||
ContactsContract.Data.DISPLAY_NAME,
|
new String[] {
|
||||||
ContactsContract.Data.PHOTO_URI,
|
ContactsContract.Data._ID,
|
||||||
ContactsContract.Data.LOOKUP_KEY,
|
ContactsContract.Data.DISPLAY_NAME,
|
||||||
ContactsContract.CommonDataKinds.Im.DATA
|
ContactsContract.Data.PHOTO_URI,
|
||||||
};
|
ContactsContract.Data.LOOKUP_KEY,
|
||||||
private static final String SELECTION = ContactsContract.Data.MIMETYPE + "=? AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? or (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=? and lower(" + ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL + ")=?))";
|
ContactsContract.CommonDataKinds.Im.DATA
|
||||||
|
};
|
||||||
|
private static final String SELECTION =
|
||||||
|
ContactsContract.Data.MIMETYPE
|
||||||
|
+ "=? AND ("
|
||||||
|
+ ContactsContract.CommonDataKinds.Im.PROTOCOL
|
||||||
|
+ "=? or ("
|
||||||
|
+ ContactsContract.CommonDataKinds.Im.PROTOCOL
|
||||||
|
+ "=? and lower("
|
||||||
|
+ ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL
|
||||||
|
+ ")=?))";
|
||||||
|
|
||||||
private static final String[] SELECTION_ARGS = {
|
private static final String[] SELECTION_ARGS = {
|
||||||
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE,
|
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE,
|
||||||
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER),
|
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER),
|
||||||
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM),
|
String.valueOf(ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM),
|
||||||
"xmpp"
|
"xmpp"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Jid jid;
|
private final Jid jid;
|
||||||
|
@ -37,8 +48,12 @@ public class JabberIdContact extends AbstractPhoneContact {
|
||||||
private JabberIdContact(Cursor cursor) throws IllegalArgumentException {
|
private JabberIdContact(Cursor cursor) throws IllegalArgumentException {
|
||||||
super(cursor);
|
super(cursor);
|
||||||
try {
|
try {
|
||||||
this.jid = Jid.of(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)));
|
this.jid =
|
||||||
} catch (IllegalArgumentException | NullPointerException e) {
|
Jid.of(
|
||||||
|
cursor.getString(
|
||||||
|
cursor.getColumnIndexOrThrow(
|
||||||
|
ContactsContract.CommonDataKinds.Im.DATA)));
|
||||||
|
} catch (final IllegalArgumentException | NullPointerException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,10 +63,20 @@ public class JabberIdContact extends AbstractPhoneContact {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Jid, JabberIdContact> load(Context context) {
|
public static Map<Jid, JabberIdContact> load(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
if (!QuickConversationsService.isFreeOrQuicksyFlavor()
|
||||||
|
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED)) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
try (final Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, SELECTION_ARGS, null)) {
|
try (final Cursor cursor =
|
||||||
|
context.getContentResolver()
|
||||||
|
.query(
|
||||||
|
ContactsContract.Data.CONTENT_URI,
|
||||||
|
PROJECTION,
|
||||||
|
SELECTION,
|
||||||
|
SELECTION_ARGS,
|
||||||
|
null)) {
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ public abstract class AbstractQuickConversationsService {
|
||||||
return "playstore".equals(BuildConfig.FLAVOR_distribution);
|
return "playstore".equals(BuildConfig.FLAVOR_distribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFreeOrQuicksyFlavor() {
|
||||||
|
return "free".equals(BuildConfig.FLAVOR_distribution) || "quicksy".equals(BuildConfig.FLAVOR_mode);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isQuicksyPlayStore() {
|
public static boolean isQuicksyPlayStore() {
|
||||||
return isQuicksy() && isPlayStoreFlavor();
|
return isQuicksy() && isPlayStoreFlavor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1290,7 +1290,11 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
restoreFromDatabase();
|
restoreFromDatabase();
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
if (QuickConversationsService.isFreeOrQuicksyFlavor()
|
||||||
|
&& (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
||||||
|
|| ContextCompat.checkSelfPermission(
|
||||||
|
this, Manifest.permission.READ_CONTACTS)
|
||||||
|
== PackageManager.PERMISSION_GRANTED)) {
|
||||||
startContactObserver();
|
startContactObserver();
|
||||||
}
|
}
|
||||||
FILE_OBSERVER_EXECUTOR.execute(fileBackend::deleteHistoricAvatarPath);
|
FILE_OBSERVER_EXECUTOR.execute(fileBackend::deleteHistoricAvatarPath);
|
||||||
|
|
|
@ -46,6 +46,7 @@ import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.ListItem;
|
import eu.siacs.conversations.entities.ListItem;
|
||||||
import eu.siacs.conversations.services.AbstractQuickConversationsService;
|
import eu.siacs.conversations.services.AbstractQuickConversationsService;
|
||||||
|
import eu.siacs.conversations.services.QuickConversationsService;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
|
||||||
import eu.siacs.conversations.ui.adapter.MediaAdapter;
|
import eu.siacs.conversations.ui.adapter.MediaAdapter;
|
||||||
|
@ -119,13 +120,13 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
private void checkContactPermissionAndShowAddDialog() {
|
private void checkContactPermissionAndShowAddDialog() {
|
||||||
if (hasContactsPermission()) {
|
if (hasContactsPermission()) {
|
||||||
showAddToPhoneBookDialog();
|
showAddToPhoneBookDialog();
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
} else if (QuickConversationsService.isFreeOrQuicksyFlavor() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
|
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasContactsPermission() {
|
private boolean hasContactsPermission() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (QuickConversationsService.isFreeOrQuicksyFlavor() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
return checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED;
|
return checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -523,18 +524,30 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBadgeClick(View view) {
|
private void onBadgeClick(final View view) {
|
||||||
final Uri systemAccount = contact.getSystemAccount();
|
if (QuickConversationsService.isFreeOrQuicksyFlavor()) {
|
||||||
if (systemAccount == null) {
|
final Uri systemAccount = contact.getSystemAccount();
|
||||||
checkContactPermissionAndShowAddDialog();
|
if (systemAccount == null) {
|
||||||
} else {
|
checkContactPermissionAndShowAddDialog();
|
||||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
} else {
|
||||||
intent.setData(systemAccount);
|
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
try {
|
intent.setData(systemAccount);
|
||||||
startActivity(intent);
|
try {
|
||||||
} catch (final ActivityNotFoundException e) {
|
startActivity(intent);
|
||||||
Toast.makeText(this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show();
|
} catch (final ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
R.string.no_application_found_to_view_contact,
|
||||||
|
Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
R.string.contact_list_integration_not_available,
|
||||||
|
Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -761,7 +761,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
}
|
}
|
||||||
|
|
||||||
private void askForContactsPermissions() {
|
private void askForContactsPermissions() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (QuickConversationsService.isFreeOrQuicksyFlavor() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
if (mRequestedContactsPermission.compareAndSet(false, true)) {
|
if (mRequestedContactsPermission.compareAndSet(false, true)) {
|
||||||
if (QuickConversationsService.isQuicksy() || shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
|
if (QuickConversationsService.isQuicksy() || shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
|
||||||
|
@ -840,8 +840,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBackendConnected() {
|
protected void onBackendConnected() {
|
||||||
|
if (QuickConversationsService.isFreeOrQuicksyFlavor()
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
&& (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
||||||
|
|| checkSelfPermission(Manifest.permission.READ_CONTACTS)
|
||||||
|
== PackageManager.PERMISSION_GRANTED)) {
|
||||||
xmppConnectionService.getQuickConversationsService().considerSyncBackground(false);
|
xmppConnectionService.getQuickConversationsService().considerSyncBackground(false);
|
||||||
}
|
}
|
||||||
if (mPostponedActivityResult != null) {
|
if (mPostponedActivityResult != null) {
|
||||||
|
|
|
@ -10,6 +10,8 @@ import android.os.Build;
|
||||||
import android.provider.ContactsContract.Profile;
|
import android.provider.ContactsContract.Profile;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.services.QuickConversationsService;
|
||||||
|
|
||||||
public class PhoneHelper {
|
public class PhoneHelper {
|
||||||
|
|
||||||
@SuppressLint("HardwareIds")
|
@SuppressLint("HardwareIds")
|
||||||
|
@ -18,8 +20,10 @@ public class PhoneHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Uri getProfilePictureUri(final Context context) {
|
public static Uri getProfilePictureUri(final Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
if (!QuickConversationsService.isFreeOrQuicksyFlavor()
|
||||||
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final String[] projection = new String[] {Profile._ID, Profile.PHOTO_URI};
|
final String[] projection = new String[] {Profile._ID, Profile.PHOTO_URI};
|
||||||
|
|
|
@ -1024,4 +1024,5 @@
|
||||||
<string name="report_spam">Report spam</string>
|
<string name="report_spam">Report spam</string>
|
||||||
<string name="report_spam_and_block">Report spam and block spammer</string>
|
<string name="report_spam_and_block">Report spam and block spammer</string>
|
||||||
<string name="privacy_policy">Privacy policy</string>
|
<string name="privacy_policy">Privacy policy</string>
|
||||||
|
<string name="contact_list_integration_not_available">Address book integration is not available</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
|
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
|
||||||
tools:node="remove" />
|
tools:node="remove" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@mipmap/new_launcher"
|
android:icon="@mipmap/new_launcher"
|
||||||
tools:ignore="GoogleAppIndexingWarning"
|
tools:ignore="GoogleAppIndexingWarning"
|
||||||
|
|
Loading…
Reference in a new issue