renamed build flavors
26
build.gradle
|
@ -21,9 +21,9 @@ repositories {
|
||||||
configurations {
|
configurations {
|
||||||
playstoreImplementation
|
playstoreImplementation
|
||||||
compatImplementation
|
compatImplementation
|
||||||
fullFreeCompatImplementation
|
conversationsFreeCompatImplementation
|
||||||
quickFreeCompatImplementation
|
quicksyFreeCompatImplementation
|
||||||
quickImplementation
|
quicksyImplementation
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
|
@ -46,8 +46,8 @@ dependencies {
|
||||||
implementation "com.android.support:support-emoji:$supportLibVersion"
|
implementation "com.android.support:support-emoji:$supportLibVersion"
|
||||||
implementation "com.android.support:design:$supportLibVersion"
|
implementation "com.android.support:design:$supportLibVersion"
|
||||||
compatImplementation "com.android.support:support-emoji-appcompat:$supportLibVersion"
|
compatImplementation "com.android.support:support-emoji-appcompat:$supportLibVersion"
|
||||||
fullFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion"
|
conversationsFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion"
|
||||||
quickFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion"
|
quicksyFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion"
|
||||||
implementation 'org.bouncycastle:bcmail-jdk15on:1.58'
|
implementation 'org.bouncycastle:bcmail-jdk15on:1.58'
|
||||||
implementation 'com.google.zxing:core:3.3.0'
|
implementation 'com.google.zxing:core:3.3.0'
|
||||||
implementation 'de.measite.minidns:minidns-hla:0.2.4'
|
implementation 'de.measite.minidns:minidns-hla:0.2.4'
|
||||||
|
@ -60,7 +60,7 @@ dependencies {
|
||||||
implementation 'org.osmdroid:osmdroid-android:6.0.1'
|
implementation 'org.osmdroid:osmdroid-android:6.0.1'
|
||||||
implementation 'org.hsluv:hsluv:0.2'
|
implementation 'org.hsluv:hsluv:0.2'
|
||||||
implementation 'org.conscrypt:conscrypt-android:1.3.0'
|
implementation 'org.conscrypt:conscrypt-android:1.3.0'
|
||||||
quickImplementation 'io.michaelrocks:libphonenumber-android:8.9.14'
|
quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.9.14'
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
|
@ -80,6 +80,7 @@ android {
|
||||||
applicationId "eu.siacs.conversations"
|
applicationId "eu.siacs.conversations"
|
||||||
resValue "string", "applicationId", applicationId
|
resValue "string", "applicationId", applicationId
|
||||||
resValue "string", "app_name", "Conversations"
|
resValue "string", "app_name", "Conversations"
|
||||||
|
buildConfigField "String", "LOGTAG", "\"conversations\""
|
||||||
}
|
}
|
||||||
|
|
||||||
dataBinding {
|
dataBinding {
|
||||||
|
@ -101,14 +102,15 @@ android {
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
|
|
||||||
quick {
|
quicksy {
|
||||||
dimension "mode"
|
dimension "mode"
|
||||||
applicationId = "im.conversations.quick"
|
applicationId = "im.conversations.quick"
|
||||||
resValue "string", "app_name", "Quicksy"
|
resValue "string", "app_name", "Quicksy"
|
||||||
resValue "string", "applicationId", applicationId
|
resValue "string", "applicationId", applicationId
|
||||||
|
buildConfigField "String", "LOGTAG", "\"quicksy\""
|
||||||
}
|
}
|
||||||
|
|
||||||
full {
|
conversations {
|
||||||
dimension "mode"
|
dimension "mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +133,12 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
quickFreeCompat {
|
quicksyFreeCompat {
|
||||||
java {
|
java {
|
||||||
srcDirs 'src/freeCompat/java'
|
srcDirs 'src/freeCompat/java'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
quickPlaystoreCompat {
|
quicksyPlaystoreCompat {
|
||||||
java {
|
java {
|
||||||
srcDirs 'src/playstoreCompat/java'
|
srcDirs 'src/playstoreCompat/java'
|
||||||
}
|
}
|
||||||
|
@ -144,12 +146,12 @@ android {
|
||||||
srcDir 'src/playstoreCompat/res'
|
srcDir 'src/playstoreCompat/res'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fullFreeCompat {
|
conversationsFreeCompat {
|
||||||
java {
|
java {
|
||||||
srcDirs 'src/freeCompat/java'
|
srcDirs 'src/freeCompat/java'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fullPlaystoreCompat {
|
conversationsPlaystoreCompat {
|
||||||
java {
|
java {
|
||||||
srcDirs 'src/playstoreCompat/java'
|
srcDirs 'src/playstoreCompat/java'
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
public class QuickConversationsService extends AbstractQuickConversationsService {
|
||||||
|
|
||||||
|
QuickConversationsService(XmppConnectionService xmppConnectionService) {
|
||||||
|
super(xmppConnectionService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void considerSync() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package eu.siacs.conversations.services;
|
|
||||||
|
|
||||||
public class QuickConversationsService {
|
|
||||||
|
|
||||||
private final XmppConnectionService service;
|
|
||||||
|
|
||||||
QuickConversationsService(XmppConnectionService xmppConnectionService) {
|
|
||||||
this.service = xmppConnectionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isQuicksy() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFull() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void considerSync() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,14 +34,14 @@ public final class Config {
|
||||||
return (ENCRYPTION_MASK & (ENCRYPTION_MASK - 1)) != 0;
|
return (ENCRYPTION_MASK & (ENCRYPTION_MASK - 1)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String LOGTAG = "conversations";
|
public static final String LOGTAG = BuildConfig.LOGTAG;
|
||||||
|
|
||||||
public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im");
|
public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im");
|
||||||
|
|
||||||
|
|
||||||
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
|
||||||
public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
|
public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
|
||||||
public static final String QUICKSY_DOMAIN = "quicksy.im";
|
public static final String QUICKSY_DOMAIN = "venus.fritz.box";
|
||||||
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
|
||||||
|
|
||||||
public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false;
|
public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
@ -31,10 +32,9 @@ public class JabberIdContact extends AbstractPhoneContact {
|
||||||
return jid;
|
return jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(Context context, OnPhoneContactsLoaded<JabberIdContact> callback) {
|
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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
callback.onPhoneContactsLoaded(Collections.emptyList());
|
return Collections.emptyMap();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
final String[] PROJECTION = new String[]{ContactsContract.Data._ID,
|
final String[] PROJECTION = new String[]{ContactsContract.Data._ID,
|
||||||
ContactsContract.Data.DISPLAY_NAME,
|
ContactsContract.Data.DISPLAY_NAME,
|
||||||
|
@ -51,8 +51,7 @@ public class JabberIdContact extends AbstractPhoneContact {
|
||||||
try {
|
try {
|
||||||
cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null, null);
|
cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
callback.onPhoneContactsLoaded(Collections.emptyList());
|
return Collections.emptyMap();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
final HashMap<Jid, JabberIdContact> contacts = new HashMap<>();
|
final HashMap<Jid, JabberIdContact> contacts = new HashMap<>();
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
|
@ -69,6 +68,6 @@ public class JabberIdContact extends AbstractPhoneContact {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
callback.onPhoneContactsLoaded(contacts.values());
|
return contacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package eu.siacs.conversations.android;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface OnPhoneContactsLoaded<T extends AbstractPhoneContact> {
|
|
||||||
|
|
||||||
void onPhoneContactsLoaded(Collection<T> contacts);
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.BuildConfig;
|
||||||
|
|
||||||
|
public abstract class AbstractQuickConversationsService {
|
||||||
|
|
||||||
|
protected final XmppConnectionService service;
|
||||||
|
|
||||||
|
public AbstractQuickConversationsService(XmppConnectionService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void considerSync();
|
||||||
|
|
||||||
|
public static boolean isQuicksy() {
|
||||||
|
return "quicksy".equals(BuildConfig.FLAVOR_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isConversations() {
|
||||||
|
return "conversations".equals(BuildConfig.FLAVOR_mode);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1520,11 +1520,11 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
public void loadPhoneContacts() {
|
public void loadPhoneContacts() {
|
||||||
mContactMergerExecutor.execute(() -> {
|
mContactMergerExecutor.execute(() -> {
|
||||||
JabberIdContact.load(this, contacts -> {
|
Map<Jid, JabberIdContact> contacts = JabberIdContact.load(this);
|
||||||
Log.d(Config.LOGTAG, "start merging phone contacts with roster");
|
Log.d(Config.LOGTAG, "start merging phone contacts with roster");
|
||||||
for (Account account : accounts) {
|
for (Account account : accounts) {
|
||||||
List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts();
|
List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts();
|
||||||
for (JabberIdContact jidContact : contacts) {
|
for (JabberIdContact jidContact : contacts.values()) {
|
||||||
final Contact contact = account.getRoster().getContact(jidContact.getJid());
|
final Contact contact = account.getRoster().getContact(jidContact.getJid());
|
||||||
contact.setSystemAccount(jidContact.getLookupUri());
|
contact.setSystemAccount(jidContact.getLookupUri());
|
||||||
boolean needsCacheClean = contact.setPhotoUri(jidContact.getPhotoUri());
|
boolean needsCacheClean = contact.setPhotoUri(jidContact.getPhotoUri());
|
||||||
|
@ -1546,7 +1546,6 @@ public class XmppConnectionService extends Service {
|
||||||
Log.d(Config.LOGTAG, "finished merging phone contacts");
|
Log.d(Config.LOGTAG, "finished merging phone contacts");
|
||||||
mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true));
|
mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true));
|
||||||
updateRosterUi();
|
updateRosterUi();
|
||||||
});
|
|
||||||
mQuickConversationsService.considerSync();
|
mQuickConversationsService.considerSync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3323,11 +3322,11 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useTorToConnect() {
|
public boolean useTorToConnect() {
|
||||||
return QuickConversationsService.isFull() && getBooleanPreference("use_tor", R.bool.use_tor);
|
return QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showExtendedConnectionOptions() {
|
public boolean showExtendedConnectionOptions() {
|
||||||
return QuickConversationsService.isFull() && getBooleanPreference("show_connection_options", R.bool.show_connection_options);
|
return QuickConversationsService.isConversations() && getBooleanPreference("show_connection_options", R.bool.show_connection_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean broadcastLastActivity() {
|
public boolean broadcastLastActivity() {
|
||||||
|
|
|
@ -28,16 +28,9 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TableLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||||
|
@ -623,8 +616,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SharedPreferences preferences = getPreferences();
|
SharedPreferences preferences = getPreferences();
|
||||||
mUseTor = QuickConversationsService.isFull() && preferences.getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor));
|
mUseTor = QuickConversationsService.isConversations() && preferences.getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor));
|
||||||
this.mShowOptions = mUseTor || (QuickConversationsService.isFull() && preferences.getBoolean("show_connection_options", getResources().getBoolean(R.bool.show_connection_options)));
|
this.mShowOptions = mUseTor || (QuickConversationsService.isConversations() && preferences.getBoolean("show_connection_options", getResources().getBoolean(R.bool.show_connection_options)));
|
||||||
this.binding.namePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
|
this.binding.namePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +881,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && QuickConversationsService.isFull();
|
final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && QuickConversationsService.isConversations();
|
||||||
this.binding.accountJid.setEnabled(editable);
|
this.binding.accountJid.setEnabled(editable);
|
||||||
this.binding.accountJid.setFocusable(editable);
|
this.binding.accountJid.setFocusable(editable);
|
||||||
this.binding.accountJid.setFocusableInTouchMode(editable);
|
this.binding.accountJid.setFocusableInTouchMode(editable);
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.BoolRes;
|
import android.support.annotation.BoolRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca
|
||||||
final IConfigurationProvider config = Configuration.getInstance();
|
final IConfigurationProvider config = Configuration.getInstance();
|
||||||
config.load(ctx, getPreferences());
|
config.load(ctx, getPreferences());
|
||||||
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_CODE);
|
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_CODE);
|
||||||
if (QuickConversationsService.isFull() && getBooleanPreference("use_tor", R.bool.use_tor)) {
|
if (QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor)) {
|
||||||
try {
|
try {
|
||||||
config.setHttpProxy(HttpConnectionManager.getProxy());
|
config.setHttpProxy(HttpConnectionManager.getProxy());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -49,7 +49,6 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -296,7 +295,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
|
|
||||||
final SharedPreferences preferences = getPreferences();
|
final SharedPreferences preferences = getPreferences();
|
||||||
|
|
||||||
this.mHideOfflineContacts = QuickConversationsService.isFull() && preferences.getBoolean("hide_offline", false);
|
this.mHideOfflineContacts = QuickConversationsService.isConversations() && preferences.getBoolean("hide_offline", false);
|
||||||
|
|
||||||
final boolean startSearching = preferences.getBoolean("start_searching",getResources().getBoolean(R.bool.start_searching));
|
final boolean startSearching = preferences.getBoolean("start_searching",getResources().getBoolean(R.bool.start_searching));
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,5 @@ public final class Namespace {
|
||||||
public static final String P1_S3_FILE_TRANSFER = "p1:s3filetransfer";
|
public static final String P1_S3_FILE_TRANSFER = "p1:s3filetransfer";
|
||||||
public static final String BOOKMARKS_CONVERSION = "urn:xmpp:bookmarks-conversion:0";
|
public static final String BOOKMARKS_CONVERSION = "urn:xmpp:bookmarks-conversion:0";
|
||||||
public static final String BOOKMARKS = "storage:bookmarks";
|
public static final String BOOKMARKS = "storage:bookmarks";
|
||||||
|
public static final String SYNCHRONIZATION = "im.quicksy.synchronization";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.util.Log;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
|
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
|
||||||
|
@ -32,10 +33,9 @@ public class PhoneNumberContact extends AbstractPhoneContact {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(Context context, OnPhoneContactsLoaded<PhoneNumberContact> callback) {
|
public static Map<String, PhoneNumberContact> load(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
callback.onPhoneContactsLoaded(Collections.emptyList());
|
return Collections.emptyMap();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
final String[] PROJECTION = new String[]{ContactsContract.Data._ID,
|
final String[] PROJECTION = new String[]{ContactsContract.Data._ID,
|
||||||
ContactsContract.Data.DISPLAY_NAME,
|
ContactsContract.Data.DISPLAY_NAME,
|
||||||
|
@ -46,8 +46,7 @@ public class PhoneNumberContact extends AbstractPhoneContact {
|
||||||
try {
|
try {
|
||||||
cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, null);
|
cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
callback.onPhoneContactsLoaded(Collections.emptyList());
|
return Collections.emptyMap();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
final HashMap<String, PhoneNumberContact> contacts = new HashMap<>();
|
final HashMap<String, PhoneNumberContact> contacts = new HashMap<>();
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
|
@ -64,6 +63,6 @@ public class PhoneNumberContact extends AbstractPhoneContact {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
callback.onPhoneContactsLoaded(contacts.values());
|
return contacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,8 +14,11 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -30,10 +33,14 @@ import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.utils.AccountUtils;
|
import eu.siacs.conversations.utils.AccountUtils;
|
||||||
import eu.siacs.conversations.utils.CryptoHelper;
|
import eu.siacs.conversations.utils.CryptoHelper;
|
||||||
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
|
import eu.siacs.conversations.utils.PhoneNumberUtilWrapper;
|
||||||
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
import eu.siacs.conversations.xml.Namespace;
|
||||||
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
import io.michaelrocks.libphonenumber.android.Phonenumber;
|
||||||
import rocks.xmpp.addr.Jid;
|
import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class QuickConversationsService {
|
public class QuickConversationsService extends AbstractQuickConversationsService {
|
||||||
|
|
||||||
|
|
||||||
public static final int API_ERROR_OTHER = -1;
|
public static final int API_ERROR_OTHER = -1;
|
||||||
|
@ -46,8 +53,6 @@ public class QuickConversationsService {
|
||||||
|
|
||||||
private static final String INSTALLATION_ID = "eu.siacs.conversations.installation-id";
|
private static final String INSTALLATION_ID = "eu.siacs.conversations.installation-id";
|
||||||
|
|
||||||
private final XmppConnectionService service;
|
|
||||||
|
|
||||||
private final Set<OnVerificationRequested> mOnVerificationRequested = Collections.newSetFromMap(new WeakHashMap<>());
|
private final Set<OnVerificationRequested> mOnVerificationRequested = Collections.newSetFromMap(new WeakHashMap<>());
|
||||||
private final Set<OnVerification> mOnVerification = Collections.newSetFromMap(new WeakHashMap<>());
|
private final Set<OnVerification> mOnVerification = Collections.newSetFromMap(new WeakHashMap<>());
|
||||||
|
|
||||||
|
@ -55,7 +60,7 @@ public class QuickConversationsService {
|
||||||
private final AtomicBoolean mVerificationRequestInProgress = new AtomicBoolean(false);
|
private final AtomicBoolean mVerificationRequestInProgress = new AtomicBoolean(false);
|
||||||
|
|
||||||
QuickConversationsService(XmppConnectionService xmppConnectionService) {
|
QuickConversationsService(XmppConnectionService xmppConnectionService) {
|
||||||
this.service = xmppConnectionService;
|
super(xmppConnectionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOnVerificationRequestedListener(OnVerificationRequested onVerificationRequested) {
|
public void addOnVerificationRequestedListener(OnVerificationRequested onVerificationRequested) {
|
||||||
|
@ -257,20 +262,32 @@ public class QuickConversationsService {
|
||||||
return mVerificationRequestInProgress.get();
|
return mVerificationRequestInProgress.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isQuicksy() {
|
@Override
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFull() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void considerSync() {
|
public void considerSync() {
|
||||||
PhoneNumberContact.load(service, contacts -> {
|
Map<String, PhoneNumberContact> contacts = PhoneNumberContact.load(service);
|
||||||
for(PhoneNumberContact c : contacts) {
|
for(Account account : service.getAccounts()) {
|
||||||
Log.d(Config.LOGTAG, "Display Name=" + c.getDisplayName() + ", number=" + c.getPhoneNumber()+", uri="+c.getLookupUri());
|
considerSync(account, contacts);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
private void considerSync(Account account, Map<String, PhoneNumberContact> contacts) {
|
||||||
|
XmppConnection xmppConnection = account.getXmppConnection();
|
||||||
|
Jid syncServer = xmppConnection == null ? null : xmppConnection.findDiscoItemByFeature(Namespace.SYNCHRONIZATION);
|
||||||
|
if (syncServer == null) {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": skipping sync. no sync server found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": sending phone list to "+syncServer);
|
||||||
|
List<Element> entries = new ArrayList<>();
|
||||||
|
for(PhoneNumberContact c : contacts.values()) {
|
||||||
|
entries.add(new Element("entry").setAttribute("number",c.getPhoneNumber()));
|
||||||
|
}
|
||||||
|
Element phoneBook = new Element("phone-book",Namespace.SYNCHRONIZATION);
|
||||||
|
phoneBook.setChildren(entries);
|
||||||
|
IqPacket iqPacket = new IqPacket(IqPacket.TYPE.GET);
|
||||||
|
iqPacket.setTo(syncServer);
|
||||||
|
iqPacket.addChild(phoneBook);
|
||||||
|
service.sendIqPacket(account, iqPacket, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnVerificationRequested {
|
public interface OnVerificationRequested {
|
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 141 B |