From 87cc53b8b5fcad666a981676f522ba07d28c805c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 28 Oct 2018 12:34:17 +0100 Subject: [PATCH] renamed build flavors --- build.gradle | 26 ++++----- .../AndroidManifest.xml | 0 .../services/QuickConversationsService.java | 13 +++++ .../conversations/ui/MagicCreateActivity.java | 0 .../ui/ManageAccountActivity.java | 0 .../ui/ShareViaAccountActivity.java | 0 .../conversations/ui/WelcomeActivity.java | 0 .../ui/adapter/AccountAdapter.java | 0 .../conversations/utils/SignupUtils.java | 0 .../res/layout/activity_manage_accounts.xml | 0 .../res/layout/magic_create.xml | 0 .../res/layout/welcome.xml | 0 .../services/QuickConversationsService.java | 22 -------- .../java/eu/siacs/conversations/Config.java | 4 +- .../android/JabberIdContact.java | 11 ++-- .../android/OnPhoneContactsLoaded.java | 8 --- .../AbstractQuickConversationsService.java | 22 ++++++++ .../services/XmppConnectionService.java | 51 +++++++++--------- .../conversations/ui/EditAccountActivity.java | 13 ++--- .../conversations/ui/LocationActivity.java | 3 +- .../ui/StartConversationActivity.java | 3 +- .../eu/siacs/conversations/xml/Namespace.java | 1 + src/{quick => quicksy}/AndroidManifest.xml | 0 .../android/PhoneNumberContact.java | 11 ++-- .../services/QuickConversationsService.java | 51 ++++++++++++------ .../ui/ChooseCountryActivity.java | 0 .../ui/EnterPhoneNumberActivity.java | 0 .../conversations/ui/VerifyActivity.java | 0 .../ui/adapter/CountryAdapter.java | 0 .../ui/drawable/TextDrawable.java | 0 .../ui/util/ApiDialogHelper.java | 0 .../ui/util/PinEntryWrapper.java | 0 .../utils/PhoneNumberUtilWrapper.java | 0 .../conversations/utils/SignupUtils.java | 0 .../ic_arrow_drop_down_black_18dp.png | Bin .../ic_arrow_drop_down_black_18dp.png | Bin .../ic_arrow_drop_down_black_18dp.png | Bin .../ic_arrow_drop_down_black_18dp.png | Bin .../ic_arrow_drop_down_black_18dp.png | Bin .../res/layout/activity_choose_country.xml | 0 .../res/layout/activity_enter_number.xml | 0 .../res/layout/activity_verify.xml | 0 .../res/layout/country_item.xml | 0 .../res/menu/choose_country.xml | 0 44 files changed, 126 insertions(+), 113 deletions(-) rename src/{full => conversations}/AndroidManifest.xml (100%) create mode 100644 src/conversations/java/eu/siacs/conversations/services/QuickConversationsService.java rename src/{full => conversations}/java/eu/siacs/conversations/ui/MagicCreateActivity.java (100%) rename src/{full => conversations}/java/eu/siacs/conversations/ui/ManageAccountActivity.java (100%) rename src/{full => conversations}/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java (100%) rename src/{full => conversations}/java/eu/siacs/conversations/ui/WelcomeActivity.java (100%) rename src/{full => conversations}/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java (100%) rename src/{full => conversations}/java/eu/siacs/conversations/utils/SignupUtils.java (100%) rename src/{full => conversations}/res/layout/activity_manage_accounts.xml (100%) rename src/{full => conversations}/res/layout/magic_create.xml (100%) rename src/{full => conversations}/res/layout/welcome.xml (100%) delete mode 100644 src/full/java/eu/siacs/conversations/services/QuickConversationsService.java delete mode 100644 src/main/java/eu/siacs/conversations/android/OnPhoneContactsLoaded.java create mode 100644 src/main/java/eu/siacs/conversations/services/AbstractQuickConversationsService.java rename src/{quick => quicksy}/AndroidManifest.xml (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/android/PhoneNumberContact.java (88%) rename src/{quick => quicksy}/java/eu/siacs/conversations/services/QuickConversationsService.java (87%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/ChooseCountryActivity.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/VerifyActivity.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/adapter/CountryAdapter.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/drawable/TextDrawable.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/util/ApiDialogHelper.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/ui/util/PinEntryWrapper.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java (100%) rename src/{quick => quicksy}/java/eu/siacs/conversations/utils/SignupUtils.java (100%) rename src/{quick => quicksy}/res/drawable-hdpi/ic_arrow_drop_down_black_18dp.png (100%) rename src/{quick => quicksy}/res/drawable-mdpi/ic_arrow_drop_down_black_18dp.png (100%) rename src/{quick => quicksy}/res/drawable-xhdpi/ic_arrow_drop_down_black_18dp.png (100%) rename src/{quick => quicksy}/res/drawable-xxhdpi/ic_arrow_drop_down_black_18dp.png (100%) rename src/{quick => quicksy}/res/drawable-xxxhdpi/ic_arrow_drop_down_black_18dp.png (100%) rename src/{quick => quicksy}/res/layout/activity_choose_country.xml (100%) rename src/{quick => quicksy}/res/layout/activity_enter_number.xml (100%) rename src/{quick => quicksy}/res/layout/activity_verify.xml (100%) rename src/{quick => quicksy}/res/layout/country_item.xml (100%) rename src/{quick => quicksy}/res/menu/choose_country.xml (100%) diff --git a/build.gradle b/build.gradle index c344a3ccd..befe8b1c7 100644 --- a/build.gradle +++ b/build.gradle @@ -21,9 +21,9 @@ repositories { configurations { playstoreImplementation compatImplementation - fullFreeCompatImplementation - quickFreeCompatImplementation - quickImplementation + conversationsFreeCompatImplementation + quicksyFreeCompatImplementation + quicksyImplementation } ext { @@ -46,8 +46,8 @@ dependencies { implementation "com.android.support:support-emoji:$supportLibVersion" implementation "com.android.support:design:$supportLibVersion" compatImplementation "com.android.support:support-emoji-appcompat:$supportLibVersion" - fullFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion" - quickFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion" + conversationsFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion" + quicksyFreeCompatImplementation "com.android.support:support-emoji-bundled:$supportLibVersion" implementation 'org.bouncycastle:bcmail-jdk15on:1.58' implementation 'com.google.zxing:core:3.3.0' implementation 'de.measite.minidns:minidns-hla:0.2.4' @@ -60,7 +60,7 @@ dependencies { implementation 'org.osmdroid:osmdroid-android:6.0.1' implementation 'org.hsluv:hsluv:0.2' 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 { @@ -80,6 +80,7 @@ android { applicationId "eu.siacs.conversations" resValue "string", "applicationId", applicationId resValue "string", "app_name", "Conversations" + buildConfigField "String", "LOGTAG", "\"conversations\"" } dataBinding { @@ -101,14 +102,15 @@ android { productFlavors { - quick { + quicksy { dimension "mode" applicationId = "im.conversations.quick" resValue "string", "app_name", "Quicksy" resValue "string", "applicationId", applicationId + buildConfigField "String", "LOGTAG", "\"quicksy\"" } - full { + conversations { dimension "mode" } @@ -131,12 +133,12 @@ android { } sourceSets { - quickFreeCompat { + quicksyFreeCompat { java { srcDirs 'src/freeCompat/java' } } - quickPlaystoreCompat { + quicksyPlaystoreCompat { java { srcDirs 'src/playstoreCompat/java' } @@ -144,12 +146,12 @@ android { srcDir 'src/playstoreCompat/res' } } - fullFreeCompat { + conversationsFreeCompat { java { srcDirs 'src/freeCompat/java' } } - fullPlaystoreCompat { + conversationsPlaystoreCompat { java { srcDirs 'src/playstoreCompat/java' } diff --git a/src/full/AndroidManifest.xml b/src/conversations/AndroidManifest.xml similarity index 100% rename from src/full/AndroidManifest.xml rename to src/conversations/AndroidManifest.xml diff --git a/src/conversations/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/conversations/java/eu/siacs/conversations/services/QuickConversationsService.java new file mode 100644 index 000000000..583e5d947 --- /dev/null +++ b/src/conversations/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -0,0 +1,13 @@ +package eu.siacs.conversations.services; + +public class QuickConversationsService extends AbstractQuickConversationsService { + + QuickConversationsService(XmppConnectionService xmppConnectionService) { + super(xmppConnectionService); + } + + @Override + public void considerSync() { + + } +} \ No newline at end of file diff --git a/src/full/java/eu/siacs/conversations/ui/MagicCreateActivity.java b/src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java similarity index 100% rename from src/full/java/eu/siacs/conversations/ui/MagicCreateActivity.java rename to src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java diff --git a/src/full/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java similarity index 100% rename from src/full/java/eu/siacs/conversations/ui/ManageAccountActivity.java rename to src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java diff --git a/src/full/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java similarity index 100% rename from src/full/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java rename to src/conversations/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java diff --git a/src/full/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java similarity index 100% rename from src/full/java/eu/siacs/conversations/ui/WelcomeActivity.java rename to src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java diff --git a/src/full/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/conversations/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java similarity index 100% rename from src/full/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java rename to src/conversations/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java diff --git a/src/full/java/eu/siacs/conversations/utils/SignupUtils.java b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java similarity index 100% rename from src/full/java/eu/siacs/conversations/utils/SignupUtils.java rename to src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java diff --git a/src/full/res/layout/activity_manage_accounts.xml b/src/conversations/res/layout/activity_manage_accounts.xml similarity index 100% rename from src/full/res/layout/activity_manage_accounts.xml rename to src/conversations/res/layout/activity_manage_accounts.xml diff --git a/src/full/res/layout/magic_create.xml b/src/conversations/res/layout/magic_create.xml similarity index 100% rename from src/full/res/layout/magic_create.xml rename to src/conversations/res/layout/magic_create.xml diff --git a/src/full/res/layout/welcome.xml b/src/conversations/res/layout/welcome.xml similarity index 100% rename from src/full/res/layout/welcome.xml rename to src/conversations/res/layout/welcome.xml diff --git a/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java deleted file mode 100644 index 233499dc6..000000000 --- a/src/full/java/eu/siacs/conversations/services/QuickConversationsService.java +++ /dev/null @@ -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() { - - } -} \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index c09937442..9add37561 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -34,14 +34,14 @@ public final class Config { 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 String DOMAIN_LOCK = null; //only allow account creation for this domain 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 USE_RANDOM_RESOURCE_ON_EVERY_BIND = false; diff --git a/src/main/java/eu/siacs/conversations/android/JabberIdContact.java b/src/main/java/eu/siacs/conversations/android/JabberIdContact.java index 8d7aa90f4..e6488fac3 100644 --- a/src/main/java/eu/siacs/conversations/android/JabberIdContact.java +++ b/src/main/java/eu/siacs/conversations/android/JabberIdContact.java @@ -10,6 +10,7 @@ import android.util.Log; import java.util.Collections; import java.util.HashMap; +import java.util.Map; import eu.siacs.conversations.Config; import rocks.xmpp.addr.Jid; @@ -31,10 +32,9 @@ public class JabberIdContact extends AbstractPhoneContact { return jid; } - public static void load(Context context, OnPhoneContactsLoaded callback) { + public static Map load(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { - callback.onPhoneContactsLoaded(Collections.emptyList()); - return; + return Collections.emptyMap(); } final String[] PROJECTION = new String[]{ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME, @@ -51,8 +51,7 @@ public class JabberIdContact extends AbstractPhoneContact { try { cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null, null); } catch (Exception e) { - callback.onPhoneContactsLoaded(Collections.emptyList()); - return; + return Collections.emptyMap(); } final HashMap contacts = new HashMap<>(); while (cursor != null && cursor.moveToNext()) { @@ -69,6 +68,6 @@ public class JabberIdContact extends AbstractPhoneContact { if (cursor != null) { cursor.close(); } - callback.onPhoneContactsLoaded(contacts.values()); + return contacts; } } diff --git a/src/main/java/eu/siacs/conversations/android/OnPhoneContactsLoaded.java b/src/main/java/eu/siacs/conversations/android/OnPhoneContactsLoaded.java deleted file mode 100644 index f2e8752c3..000000000 --- a/src/main/java/eu/siacs/conversations/android/OnPhoneContactsLoaded.java +++ /dev/null @@ -1,8 +0,0 @@ -package eu.siacs.conversations.android; - -import java.util.Collection; - -public interface OnPhoneContactsLoaded { - - void onPhoneContactsLoaded(Collection contacts); -} diff --git a/src/main/java/eu/siacs/conversations/services/AbstractQuickConversationsService.java b/src/main/java/eu/siacs/conversations/services/AbstractQuickConversationsService.java new file mode 100644 index 000000000..08d4ebf1e --- /dev/null +++ b/src/main/java/eu/siacs/conversations/services/AbstractQuickConversationsService.java @@ -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); + } +} diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 1aa6004c6..44e948a9c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1520,33 +1520,32 @@ public class XmppConnectionService extends Service { public void loadPhoneContacts() { mContactMergerExecutor.execute(() -> { - JabberIdContact.load(this, contacts -> { - Log.d(Config.LOGTAG, "start merging phone contacts with roster"); - for (Account account : accounts) { - List withSystemAccounts = account.getRoster().getWithSystemAccounts(); - for (JabberIdContact jidContact : contacts) { - final Contact contact = account.getRoster().getContact(jidContact.getJid()); - contact.setSystemAccount(jidContact.getLookupUri()); - boolean needsCacheClean = contact.setPhotoUri(jidContact.getPhotoUri()); - needsCacheClean |= contact.setSystemName(jidContact.getDisplayName()); - if (needsCacheClean) { - getAvatarService().clear(contact); - } - withSystemAccounts.remove(contact); + Map contacts = JabberIdContact.load(this); + Log.d(Config.LOGTAG, "start merging phone contacts with roster"); + for (Account account : accounts) { + List withSystemAccounts = account.getRoster().getWithSystemAccounts(); + for (JabberIdContact jidContact : contacts.values()) { + final Contact contact = account.getRoster().getContact(jidContact.getJid()); + contact.setSystemAccount(jidContact.getLookupUri()); + boolean needsCacheClean = contact.setPhotoUri(jidContact.getPhotoUri()); + needsCacheClean |= contact.setSystemName(jidContact.getDisplayName()); + if (needsCacheClean) { + getAvatarService().clear(contact); } - for (Contact contact : withSystemAccounts) { - contact.setSystemAccount(null); - boolean needsCacheClean = contact.setPhotoUri(null); - needsCacheClean |= contact.setSystemName(null); - if (needsCacheClean) { - getAvatarService().clear(contact); - } + withSystemAccounts.remove(contact); + } + for (Contact contact : withSystemAccounts) { + contact.setSystemAccount(null); + boolean needsCacheClean = contact.setPhotoUri(null); + needsCacheClean |= contact.setSystemName(null); + if (needsCacheClean) { + getAvatarService().clear(contact); } } - Log.d(Config.LOGTAG, "finished merging phone contacts"); - mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true)); - updateRosterUi(); - }); + } + Log.d(Config.LOGTAG, "finished merging phone contacts"); + mShortcutService.refresh(mInitialAddressbookSyncCompleted.compareAndSet(false, true)); + updateRosterUi(); mQuickConversationsService.considerSync(); }); } @@ -3323,11 +3322,11 @@ public class XmppConnectionService extends Service { } 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() { - 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() { diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 1085f32d1..760486ce3 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -28,16 +28,9 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; -import android.widget.ImageButton; 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 org.openintents.openpgp.util.OpenPgpUtils; @@ -623,8 +616,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } } SharedPreferences preferences = getPreferences(); - mUseTor = QuickConversationsService.isFull() && 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))); + mUseTor = QuickConversationsService.isConversations() && preferences.getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor)); + 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); } @@ -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.setFocusable(editable); this.binding.accountJid.setFocusableInTouchMode(editable); diff --git a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java index 51ae9399c..60142e809 100644 --- a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java @@ -16,7 +16,6 @@ import android.preference.PreferenceManager; import android.provider.Settings; import android.support.annotation.BoolRes; import android.support.annotation.NonNull; -import android.text.TextUtils; import android.util.Log; import android.view.MenuItem; @@ -104,7 +103,7 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca final IConfigurationProvider config = Configuration.getInstance(); config.load(ctx, getPreferences()); 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 { config.setHttpProxy(HttpConnectionManager.getProxy()); } catch (IOException e) { diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 2f125340d..ab498f934 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -49,7 +49,6 @@ import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -296,7 +295,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne 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)); diff --git a/src/main/java/eu/siacs/conversations/xml/Namespace.java b/src/main/java/eu/siacs/conversations/xml/Namespace.java index 2ef7c3cea..99a9e3dec 100644 --- a/src/main/java/eu/siacs/conversations/xml/Namespace.java +++ b/src/main/java/eu/siacs/conversations/xml/Namespace.java @@ -22,4 +22,5 @@ public final class Namespace { 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 = "storage:bookmarks"; + public static final String SYNCHRONIZATION = "im.quicksy.synchronization"; } diff --git a/src/quick/AndroidManifest.xml b/src/quicksy/AndroidManifest.xml similarity index 100% rename from src/quick/AndroidManifest.xml rename to src/quicksy/AndroidManifest.xml diff --git a/src/quick/java/eu/siacs/conversations/android/PhoneNumberContact.java b/src/quicksy/java/eu/siacs/conversations/android/PhoneNumberContact.java similarity index 88% rename from src/quick/java/eu/siacs/conversations/android/PhoneNumberContact.java rename to src/quicksy/java/eu/siacs/conversations/android/PhoneNumberContact.java index 196063e9a..e044746a7 100644 --- a/src/quick/java/eu/siacs/conversations/android/PhoneNumberContact.java +++ b/src/quicksy/java/eu/siacs/conversations/android/PhoneNumberContact.java @@ -10,6 +10,7 @@ import android.util.Log; import java.util.Collections; import java.util.HashMap; +import java.util.Map; import eu.siacs.conversations.Config; import eu.siacs.conversations.utils.PhoneNumberUtilWrapper; @@ -32,10 +33,9 @@ public class PhoneNumberContact extends AbstractPhoneContact { } } - public static void load(Context context, OnPhoneContactsLoaded callback) { + public static Map load(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { - callback.onPhoneContactsLoaded(Collections.emptyList()); - return; + return Collections.emptyMap(); } final String[] PROJECTION = new String[]{ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME, @@ -46,8 +46,7 @@ public class PhoneNumberContact extends AbstractPhoneContact { try { cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, null); } catch (Exception e) { - callback.onPhoneContactsLoaded(Collections.emptyList()); - return; + return Collections.emptyMap(); } final HashMap contacts = new HashMap<>(); while (cursor != null && cursor.moveToNext()) { @@ -64,6 +63,6 @@ public class PhoneNumberContact extends AbstractPhoneContact { if (cursor != null) { cursor.close(); } - callback.onPhoneContactsLoaded(contacts.values()); + return contacts; } } diff --git a/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java similarity index 87% rename from src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java rename to src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java index 5709b8355..362bace72 100644 --- a/src/quick/java/eu/siacs/conversations/services/QuickConversationsService.java +++ b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -14,8 +14,11 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.UnknownHostException; import java.security.SecureRandom; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.UUID; 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.CryptoHelper; 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 rocks.xmpp.addr.Jid; -public class QuickConversationsService { +public class QuickConversationsService extends AbstractQuickConversationsService { 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 final XmppConnectionService service; - private final Set mOnVerificationRequested = Collections.newSetFromMap(new WeakHashMap<>()); private final Set mOnVerification = Collections.newSetFromMap(new WeakHashMap<>()); @@ -55,7 +60,7 @@ public class QuickConversationsService { private final AtomicBoolean mVerificationRequestInProgress = new AtomicBoolean(false); QuickConversationsService(XmppConnectionService xmppConnectionService) { - this.service = xmppConnectionService; + super(xmppConnectionService); } public void addOnVerificationRequestedListener(OnVerificationRequested onVerificationRequested) { @@ -257,20 +262,32 @@ public class QuickConversationsService { return mVerificationRequestInProgress.get(); } - public static boolean isQuicksy() { - return true; - } - - public static boolean isFull() { - return false; - } - + @Override public void considerSync() { - PhoneNumberContact.load(service, contacts -> { - for(PhoneNumberContact c : contacts) { - Log.d(Config.LOGTAG, "Display Name=" + c.getDisplayName() + ", number=" + c.getPhoneNumber()+", uri="+c.getLookupUri()); - } - }); + Map contacts = PhoneNumberContact.load(service); + for(Account account : service.getAccounts()) { + considerSync(account, contacts); + } + } + + private void considerSync(Account account, Map 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 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 { diff --git a/src/quick/java/eu/siacs/conversations/ui/ChooseCountryActivity.java b/src/quicksy/java/eu/siacs/conversations/ui/ChooseCountryActivity.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/ChooseCountryActivity.java rename to src/quicksy/java/eu/siacs/conversations/ui/ChooseCountryActivity.java diff --git a/src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java b/src/quicksy/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java rename to src/quicksy/java/eu/siacs/conversations/ui/EnterPhoneNumberActivity.java diff --git a/src/quick/java/eu/siacs/conversations/ui/VerifyActivity.java b/src/quicksy/java/eu/siacs/conversations/ui/VerifyActivity.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/VerifyActivity.java rename to src/quicksy/java/eu/siacs/conversations/ui/VerifyActivity.java diff --git a/src/quick/java/eu/siacs/conversations/ui/adapter/CountryAdapter.java b/src/quicksy/java/eu/siacs/conversations/ui/adapter/CountryAdapter.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/adapter/CountryAdapter.java rename to src/quicksy/java/eu/siacs/conversations/ui/adapter/CountryAdapter.java diff --git a/src/quick/java/eu/siacs/conversations/ui/drawable/TextDrawable.java b/src/quicksy/java/eu/siacs/conversations/ui/drawable/TextDrawable.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/drawable/TextDrawable.java rename to src/quicksy/java/eu/siacs/conversations/ui/drawable/TextDrawable.java diff --git a/src/quick/java/eu/siacs/conversations/ui/util/ApiDialogHelper.java b/src/quicksy/java/eu/siacs/conversations/ui/util/ApiDialogHelper.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/util/ApiDialogHelper.java rename to src/quicksy/java/eu/siacs/conversations/ui/util/ApiDialogHelper.java diff --git a/src/quick/java/eu/siacs/conversations/ui/util/PinEntryWrapper.java b/src/quicksy/java/eu/siacs/conversations/ui/util/PinEntryWrapper.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/ui/util/PinEntryWrapper.java rename to src/quicksy/java/eu/siacs/conversations/ui/util/PinEntryWrapper.java diff --git a/src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java b/src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java rename to src/quicksy/java/eu/siacs/conversations/utils/PhoneNumberUtilWrapper.java diff --git a/src/quick/java/eu/siacs/conversations/utils/SignupUtils.java b/src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java similarity index 100% rename from src/quick/java/eu/siacs/conversations/utils/SignupUtils.java rename to src/quicksy/java/eu/siacs/conversations/utils/SignupUtils.java diff --git a/src/quick/res/drawable-hdpi/ic_arrow_drop_down_black_18dp.png b/src/quicksy/res/drawable-hdpi/ic_arrow_drop_down_black_18dp.png similarity index 100% rename from src/quick/res/drawable-hdpi/ic_arrow_drop_down_black_18dp.png rename to src/quicksy/res/drawable-hdpi/ic_arrow_drop_down_black_18dp.png diff --git a/src/quick/res/drawable-mdpi/ic_arrow_drop_down_black_18dp.png b/src/quicksy/res/drawable-mdpi/ic_arrow_drop_down_black_18dp.png similarity index 100% rename from src/quick/res/drawable-mdpi/ic_arrow_drop_down_black_18dp.png rename to src/quicksy/res/drawable-mdpi/ic_arrow_drop_down_black_18dp.png diff --git a/src/quick/res/drawable-xhdpi/ic_arrow_drop_down_black_18dp.png b/src/quicksy/res/drawable-xhdpi/ic_arrow_drop_down_black_18dp.png similarity index 100% rename from src/quick/res/drawable-xhdpi/ic_arrow_drop_down_black_18dp.png rename to src/quicksy/res/drawable-xhdpi/ic_arrow_drop_down_black_18dp.png diff --git a/src/quick/res/drawable-xxhdpi/ic_arrow_drop_down_black_18dp.png b/src/quicksy/res/drawable-xxhdpi/ic_arrow_drop_down_black_18dp.png similarity index 100% rename from src/quick/res/drawable-xxhdpi/ic_arrow_drop_down_black_18dp.png rename to src/quicksy/res/drawable-xxhdpi/ic_arrow_drop_down_black_18dp.png diff --git a/src/quick/res/drawable-xxxhdpi/ic_arrow_drop_down_black_18dp.png b/src/quicksy/res/drawable-xxxhdpi/ic_arrow_drop_down_black_18dp.png similarity index 100% rename from src/quick/res/drawable-xxxhdpi/ic_arrow_drop_down_black_18dp.png rename to src/quicksy/res/drawable-xxxhdpi/ic_arrow_drop_down_black_18dp.png diff --git a/src/quick/res/layout/activity_choose_country.xml b/src/quicksy/res/layout/activity_choose_country.xml similarity index 100% rename from src/quick/res/layout/activity_choose_country.xml rename to src/quicksy/res/layout/activity_choose_country.xml diff --git a/src/quick/res/layout/activity_enter_number.xml b/src/quicksy/res/layout/activity_enter_number.xml similarity index 100% rename from src/quick/res/layout/activity_enter_number.xml rename to src/quicksy/res/layout/activity_enter_number.xml diff --git a/src/quick/res/layout/activity_verify.xml b/src/quicksy/res/layout/activity_verify.xml similarity index 100% rename from src/quick/res/layout/activity_verify.xml rename to src/quicksy/res/layout/activity_verify.xml diff --git a/src/quick/res/layout/country_item.xml b/src/quicksy/res/layout/country_item.xml similarity index 100% rename from src/quick/res/layout/country_item.xml rename to src/quicksy/res/layout/country_item.xml diff --git a/src/quick/res/menu/choose_country.xml b/src/quicksy/res/menu/choose_country.xml similarity index 100% rename from src/quick/res/menu/choose_country.xml rename to src/quicksy/res/menu/choose_country.xml