renamed build flavors

This commit is contained in:
Daniel Gultsch 2018-10-28 12:34:17 +01:00
parent a49a5790c7
commit 87cc53b8b5
44 changed files with 126 additions and 113 deletions

View file

@ -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'
}

View file

@ -0,0 +1,13 @@
package eu.siacs.conversations.services;
public class QuickConversationsService extends AbstractQuickConversationsService {
QuickConversationsService(XmppConnectionService xmppConnectionService) {
super(xmppConnectionService);
}
@Override
public void considerSync() {
}
}

View file

@ -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() {
}
}

View file

@ -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;

View file

@ -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<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) {
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<Jid, JabberIdContact> 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;
}
}

View file

@ -1,8 +0,0 @@
package eu.siacs.conversations.android;
import java.util.Collection;
public interface OnPhoneContactsLoaded<T extends AbstractPhoneContact> {
void onPhoneContactsLoaded(Collection<T> contacts);
}

View file

@ -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);
}
}

View file

@ -1520,11 +1520,11 @@ public class XmppConnectionService extends Service {
public void loadPhoneContacts() {
mContactMergerExecutor.execute(() -> {
JabberIdContact.load(this, contacts -> {
Map<Jid, JabberIdContact> contacts = JabberIdContact.load(this);
Log.d(Config.LOGTAG, "start merging phone contacts with roster");
for (Account account : accounts) {
List<Contact> withSystemAccounts = account.getRoster().getWithSystemAccounts();
for (JabberIdContact jidContact : contacts) {
for (JabberIdContact jidContact : contacts.values()) {
final Contact contact = account.getRoster().getContact(jidContact.getJid());
contact.setSystemAccount(jidContact.getLookupUri());
boolean needsCacheClean = contact.setPhotoUri(jidContact.getPhotoUri());
@ -1546,7 +1546,6 @@ public class XmppConnectionService extends Service {
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() {

View file

@ -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);

View file

@ -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) {

View file

@ -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));

View file

@ -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";
}

View file

@ -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<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) {
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<String, PhoneNumberContact> 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;
}
}

View file

@ -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<OnVerificationRequested> mOnVerificationRequested = 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);
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<String, PhoneNumberContact> contacts = PhoneNumberContact.load(service);
for(Account account : service.getAccounts()) {
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 {

View file

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 117 B

View file

Before

Width:  |  Height:  |  Size: 88 B

After

Width:  |  Height:  |  Size: 88 B

View file

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 117 B

View file

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View file

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B