Add support for remote feature flags.

This commit is contained in:
Greyson Parrelli
2019-12-19 17:41:21 -05:00
parent b8602ee004
commit 55e9f8722f
33 changed files with 403 additions and 58 deletions

View File

@@ -167,7 +167,7 @@ public class Recipient {
} else if (!recipient.isRegistered()) {
db.markRegistered(recipient.getId());
if (FeatureFlags.UUIDS) {
if (FeatureFlags.uuids()) {
Log.i(TAG, "No UUID! Scheduling a fetch.");
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(recipient, false));
}
@@ -175,7 +175,7 @@ public class Recipient {
return resolved(recipient.getId());
} else if (uuid != null) {
if (FeatureFlags.UUIDS || e164 != null) {
if (FeatureFlags.uuids() || e164 != null) {
RecipientId id = db.getOrInsertFromUuid(uuid);
db.markRegistered(id, uuid);
@@ -193,7 +193,7 @@ public class Recipient {
if (!recipient.isRegistered()) {
db.markRegistered(recipient.getId());
if (FeatureFlags.UUIDS) {
if (FeatureFlags.uuids()) {
Log.i(TAG, "No UUID! Scheduling a fetch.");
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(recipient, false));
}
@@ -247,7 +247,7 @@ public class Recipient {
if (UuidUtil.isUuid(identifier)) {
UUID uuid = UuidUtil.parseOrThrow(identifier);
if (FeatureFlags.UUIDS) {
if (FeatureFlags.uuids()) {
id = db.getOrInsertFromUuid(uuid);
} else {
Optional<RecipientId> possibleId = db.getByUuid(uuid);
@@ -383,8 +383,8 @@ public class Recipient {
*/
@Deprecated
public @NonNull String toShortString(@NonNull Context context) {
if (FeatureFlags.PROFILE_DISPLAY) return getDisplayName(context);
else return Optional.fromNullable(getName(context)).or(getSmsAddress()).or("");
if (FeatureFlags.profileDisplay()) return getDisplayName(context);
else return Optional.fromNullable(getName(context)).or(getSmsAddress()).or("");
}
public @NonNull String getDisplayName(@NonNull Context context) {
@@ -408,7 +408,7 @@ public class Recipient {
}
public @NonNull Optional<String> getUsername() {
if (FeatureFlags.USERNAMES) {
if (FeatureFlags.usernames()) {
return Optional.fromNullable(username);
} else {
return Optional.absent();
@@ -529,7 +529,7 @@ public class Recipient {
}
public @Nullable String getCustomLabel() {
if (FeatureFlags.PROFILE_DISPLAY) throw new AssertionError("This method should never be called if PROFILE_DISPLAY is enabled.");
if (FeatureFlags.profileDisplay()) throw new AssertionError("This method should never be called if PROFILE_DISPLAY is enabled.");
return customLabel;
}
@@ -655,10 +655,10 @@ public class Recipient {
* @return True if this recipient can support receiving UUID-only messages, otherwise false.
*/
public boolean isUuidSupported() {
if (FeatureFlags.USERNAMES) {
if (FeatureFlags.usernames()) {
return true;
} else {
return FeatureFlags.UUIDS && uuidSupported;
return FeatureFlags.uuids() && uuidSupported;
}
}

View File

@@ -44,7 +44,7 @@ public class RecipientUtil {
throw new AssertionError(recipient.getId() + " - No UUID or phone number!");
}
if (FeatureFlags.UUIDS && !recipient.getUuid().isPresent()) {
if (FeatureFlags.uuids() && !recipient.getUuid().isPresent()) {
Log.i(TAG, recipient.getId() + " is missing a UUID...");
try {
RegisteredState state = DirectoryHelper.refreshDirectoryFor(context, recipient, false);
@@ -110,7 +110,7 @@ public class RecipientUtil {
@WorkerThread
public static boolean isRecipientMessageRequestAccepted(@NonNull Context context, @Nullable Recipient recipient) {
if (recipient == null || !FeatureFlags.MESSAGE_REQUESTS) return true;
if (recipient == null || !FeatureFlags.messageRequests()) return true;
Recipient resolved = recipient.resolve();