Remove TextSecurePreferences.getProfileName()
This commit is contained in:
parent
a860315587
commit
6aac3baa55
16 changed files with 61 additions and 42 deletions
|
@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.migrations.ApplicationMigrations;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
||||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.registration.RegistrationNavigationActivity;
|
import org.thoughtcrime.securesms.registration.RegistrationNavigationActivity;
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
import org.thoughtcrime.securesms.util.CensorshipUtil;
|
import org.thoughtcrime.securesms.util.CensorshipUtil;
|
||||||
|
@ -187,7 +188,7 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean userMustSetProfileName() {
|
private boolean userMustSetProfileName() {
|
||||||
return !SignalStore.registrationValues().isRegistrationComplete() && TextSecurePreferences.getProfileName(this) == ProfileName.EMPTY;
|
return !SignalStore.registrationValues().isRegistrationComplete() && Recipient.self().getProfileName() == ProfileName.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent getCreatePassphraseIntent() {
|
private Intent getCreatePassphraseIntent() {
|
||||||
|
|
|
@ -21,6 +21,8 @@ import net.sqlcipher.database.SQLiteDatabase;
|
||||||
import net.sqlcipher.database.SQLiteDatabaseHook;
|
import net.sqlcipher.database.SQLiteDatabaseHook;
|
||||||
import net.sqlcipher.database.SQLiteOpenHelper;
|
import net.sqlcipher.database.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
|
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
||||||
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
|
@ -115,8 +117,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||||
private static final int STORAGE_SERVICE_ACTIVE = 50;
|
private static final int STORAGE_SERVICE_ACTIVE = 50;
|
||||||
private static final int GROUPS_V2_RECIPIENT_CAPABILITY = 51;
|
private static final int GROUPS_V2_RECIPIENT_CAPABILITY = 51;
|
||||||
private static final int TRANSFER_FILE_CLEANUP = 52;
|
private static final int TRANSFER_FILE_CLEANUP = 52;
|
||||||
|
private static final int PROFILE_DATA_MIGRATION = 53;
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 52;
|
private static final int DATABASE_VERSION = 53;
|
||||||
private static final String DATABASE_NAME = "signal.db";
|
private static final String DATABASE_NAME = "signal.db";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
@ -545,11 +548,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||||
values.put("phone", localNumber);
|
values.put("phone", localNumber);
|
||||||
values.put("registered", 1);
|
values.put("registered", 1);
|
||||||
values.put("profile_sharing", 1);
|
values.put("profile_sharing", 1);
|
||||||
values.put("signal_profile_name", TextSecurePreferences.getProfileName(context).getGivenName());
|
|
||||||
db.insert("recipient", null, values);
|
db.insert("recipient", null, values);
|
||||||
} else {
|
} else {
|
||||||
db.execSQL("UPDATE recipient SET registered = ?, profile_sharing = ?, signal_profile_name = ? WHERE phone = ?",
|
db.execSQL("UPDATE recipient SET registered = ?, profile_sharing = ? WHERE phone = ?",
|
||||||
new String[] { "1", "1", TextSecurePreferences.getProfileName(context).getGivenName(), localNumber });
|
new String[] { "1", "1", localNumber });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -789,6 +791,17 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < PROFILE_DATA_MIGRATION) {
|
||||||
|
String localNumber = TextSecurePreferences.getLocalNumber(context);
|
||||||
|
if (localNumber != null) {
|
||||||
|
String encodedProfileName = PreferenceManager.getDefaultSharedPreferences(context).getString("pref_profile_name", null);
|
||||||
|
ProfileName profileName = ProfileName.fromSerialized(encodedProfileName);
|
||||||
|
|
||||||
|
db.execSQL("UPDATE recipient SET signal_profile_name = ?, profile_family_name = ?, profile_joined_name = ? WHERE phone = ?",
|
||||||
|
new String[] { profileName.getGivenName(), profileName.getFamilyName(), profileName.toString(), localNumber });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class InsightsRepository implements InsightsDashboardViewModel.Repository
|
||||||
public void getUserAvatar(@NonNull Consumer<InsightsUserAvatar> avatarConsumer) {
|
public void getUserAvatar(@NonNull Consumer<InsightsUserAvatar> avatarConsumer) {
|
||||||
SimpleTask.run(() -> {
|
SimpleTask.run(() -> {
|
||||||
Recipient self = Recipient.self().resolve();
|
Recipient self = Recipient.self().resolve();
|
||||||
String name = Optional.fromNullable(self.getName(context)).or(Optional.fromNullable(TextSecurePreferences.getProfileName(context).toString())).or("");
|
String name = Optional.fromNullable(self.getName(context)).or("");
|
||||||
MaterialColor fallbackColor = self.getColor();
|
MaterialColor fallbackColor = self.getColor();
|
||||||
|
|
||||||
if (fallbackColor == ContactColors.UNKNOWN_COLOR && !TextUtils.isEmpty(name)) {
|
if (fallbackColor == ContactColors.UNKNOWN_COLOR && !TextUtils.isEmpty(name)) {
|
||||||
|
|
|
@ -49,19 +49,19 @@ public final class ProfileUploadJob extends BaseJob {
|
||||||
@Override
|
@Override
|
||||||
protected void onRun() throws Exception {
|
protected void onRun() throws Exception {
|
||||||
ProfileKey profileKey = ProfileKeyUtil.getSelfProfileKey();
|
ProfileKey profileKey = ProfileKeyUtil.getSelfProfileKey();
|
||||||
ProfileName profileName = TextSecurePreferences.getProfileName(context);
|
ProfileName profileName = Recipient.self().getProfileName();
|
||||||
|
String avatarPath = null;
|
||||||
|
|
||||||
try (StreamDetails avatar = AvatarHelper.getSelfProfileAvatarStream(context)) {
|
try (StreamDetails avatar = AvatarHelper.getSelfProfileAvatarStream(context)) {
|
||||||
if (FeatureFlags.VERSIONED_PROFILES) {
|
if (FeatureFlags.VERSIONED_PROFILES) {
|
||||||
accountManager.setVersionedProfile(Recipient.self().getUuid().get(), profileKey, profileName.serialize(), avatar);
|
avatarPath = accountManager.setVersionedProfile(Recipient.self().getUuid().get(), profileKey, profileName.serialize(), avatar);
|
||||||
} else {
|
} else {
|
||||||
accountManager.setProfileName(profileKey, profileName.serialize());
|
accountManager.setProfileName(profileKey, profileName.serialize());
|
||||||
accountManager.setProfileAvatar(profileKey, avatar);
|
avatarPath = accountManager.setProfileAvatar(profileKey, avatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileAndCredential profile = ProfileUtil.retrieveProfile(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE);
|
DatabaseFactory.getRecipientDatabase(context).setProfileAvatar(Recipient.self().getId(), avatarPath);
|
||||||
DatabaseFactory.getRecipientDatabase(context).setProfileAvatar(Recipient.self().getId(), profile.getProfile().getAvatar());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -106,7 +106,6 @@ public class RefreshOwnProfileJob extends BaseJob {
|
||||||
ProfileName profileName = ProfileName.fromSerialized(plaintextName);
|
ProfileName profileName = ProfileName.fromSerialized(plaintextName);
|
||||||
|
|
||||||
DatabaseFactory.getRecipientDatabase(context).setProfileName(Recipient.self().getId(), profileName);
|
DatabaseFactory.getRecipientDatabase(context).setProfileName(Recipient.self().getId(), profileName);
|
||||||
TextSecurePreferences.setProfileName(context, profileName);
|
|
||||||
} catch (InvalidCiphertextException | IOException e) {
|
} catch (InvalidCiphertextException | IOException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,10 +59,10 @@ public class RotateProfileKeyJob extends BaseJob {
|
||||||
if (FeatureFlags.VERSIONED_PROFILES) {
|
if (FeatureFlags.VERSIONED_PROFILES) {
|
||||||
accountManager.setVersionedProfile(self.getUuid().get(),
|
accountManager.setVersionedProfile(self.getUuid().get(),
|
||||||
profileKey,
|
profileKey,
|
||||||
TextSecurePreferences.getProfileName(context).serialize(),
|
Recipient.self().getProfileName().serialize(),
|
||||||
avatarStream);
|
avatarStream);
|
||||||
} else {
|
} else {
|
||||||
accountManager.setProfileName(profileKey, TextSecurePreferences.getProfileName(context).serialize());
|
accountManager.setProfileName(profileKey, Recipient.self().getProfileName().serialize());
|
||||||
accountManager.setProfileAvatar(profileKey, avatarStream);
|
accountManager.setProfileAvatar(profileKey, avatarStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivity;
|
import org.thoughtcrime.securesms.messagerequests.MessageRequestMegaphoneActivity;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.AvatarUtil;
|
import org.thoughtcrime.securesms.util.AvatarUtil;
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
@ -202,7 +203,7 @@ public final class Megaphones {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NonNull Megaphone buildProfileNamesMegaphone(@NonNull Context context) {
|
private static @NonNull Megaphone buildProfileNamesMegaphone(@NonNull Context context) {
|
||||||
short requestCode = TextSecurePreferences.getProfileName(context) != ProfileName.EMPTY
|
short requestCode = Recipient.self().getProfileName() != ProfileName.EMPTY
|
||||||
? ConversationListFragment.PROFILE_NAMES_REQUEST_CODE_CONFIRM_NAME
|
? ConversationListFragment.PROFILE_NAMES_REQUEST_CODE_CONFIRM_NAME
|
||||||
: ConversationListFragment.PROFILE_NAMES_REQUEST_CODE_CREATE_NAME;
|
: ConversationListFragment.PROFILE_NAMES_REQUEST_CODE_CREATE_NAME;
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ public final class Megaphones {
|
||||||
.enableSnooze(null)
|
.enableSnooze(null)
|
||||||
.setImageRequest(AvatarUtil.getSelfAvatarOrFallbackIcon(context, R.drawable.ic_profilename_64));
|
.setImageRequest(AvatarUtil.getSelfAvatarOrFallbackIcon(context, R.drawable.ic_profilename_64));
|
||||||
|
|
||||||
if (TextSecurePreferences.getProfileName(ApplicationDependencies.getApplication()) == ProfileName.EMPTY) {
|
if (Recipient.self().getProfileName() == ProfileName.EMPTY) {
|
||||||
return builder.setTitle(R.string.ProfileNamesMegaphone__add_a_profile_name)
|
return builder.setTitle(R.string.ProfileNamesMegaphone__add_a_profile_name)
|
||||||
.setBody(R.string.ProfileNamesMegaphone__this_will_be_displayed_when_you_start)
|
.setBody(R.string.ProfileNamesMegaphone__this_will_be_displayed_when_you_start)
|
||||||
.setActionButton(R.string.ProfileNamesMegaphone__add_profile_name, (megaphone, listener) -> {
|
.setActionButton(R.string.ProfileNamesMegaphone__add_profile_name, (megaphone, listener) -> {
|
||||||
|
@ -241,7 +242,7 @@ public final class Megaphones {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldShowMessageRequestsMegaphone() {
|
private static boolean shouldShowMessageRequestsMegaphone() {
|
||||||
boolean userHasAProfileName = TextSecurePreferences.getProfileName(ApplicationDependencies.getApplication()) != ProfileName.EMPTY;
|
boolean userHasAProfileName = Recipient.self().getProfileName() != ProfileName.EMPTY;
|
||||||
return FeatureFlags.messageRequests() && !userHasAProfileName;
|
return FeatureFlags.messageRequests() && !userHasAProfileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.megaphone.Megaphones;
|
import org.thoughtcrime.securesms.megaphone.Megaphones;
|
||||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||||
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
@ -53,7 +54,7 @@ public class MessageRequestMegaphoneActivity extends PassphraseRequiredActionBar
|
||||||
|
|
||||||
if (requestCode == EDIT_PROFILE_REQUEST_CODE &&
|
if (requestCode == EDIT_PROFILE_REQUEST_CODE &&
|
||||||
resultCode == RESULT_OK &&
|
resultCode == RESULT_OK &&
|
||||||
TextSecurePreferences.getProfileName(this) != ProfileName.EMPTY) {
|
Recipient.self().getProfileName() != ProfileName.EMPTY) {
|
||||||
ApplicationDependencies.getMegaphoneRepository().markFinished(Megaphones.Event.MESSAGE_REQUESTS);
|
ApplicationDependencies.getMegaphoneRepository().markFinished(Megaphones.Event.MESSAGE_REQUESTS);
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ProfilePreference extends Preference {
|
||||||
if (profileSubtextView == null) return;
|
if (profileSubtextView == null) return;
|
||||||
|
|
||||||
final Recipient self = Recipient.self();
|
final Recipient self = Recipient.self();
|
||||||
final String profileName = TextSecurePreferences.getProfileName(getContext()).toString();
|
final String profileName = Recipient.self().getProfileName().toString();
|
||||||
|
|
||||||
GlideApp.with(getContext().getApplicationContext())
|
GlideApp.with(getContext().getApplicationContext())
|
||||||
.load(new ProfileContactPhoto(self.getId(), String.valueOf(TextSecurePreferences.getProfileAvatarId(getContext()))))
|
.load(new ProfileContactPhoto(self.getId(), String.valueOf(TextSecurePreferences.getProfileAvatarId(getContext()))))
|
||||||
|
|
|
@ -47,7 +47,7 @@ class EditProfileRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getCurrentProfileName(@NonNull Consumer<ProfileName> profileNameConsumer) {
|
void getCurrentProfileName(@NonNull Consumer<ProfileName> profileNameConsumer) {
|
||||||
ProfileName storedProfileName = TextSecurePreferences.getProfileName(context);
|
ProfileName storedProfileName = Recipient.self().getProfileName();
|
||||||
if (!storedProfileName.isEmpty()) {
|
if (!storedProfileName.isEmpty()) {
|
||||||
profileNameConsumer.accept(storedProfileName);
|
profileNameConsumer.accept(storedProfileName);
|
||||||
} else if (!excludeSystem) {
|
} else if (!excludeSystem) {
|
||||||
|
@ -102,7 +102,6 @@ class EditProfileRepository {
|
||||||
|
|
||||||
void uploadProfile(@NonNull ProfileName profileName, @Nullable byte[] avatar, @NonNull Consumer<UploadResult> uploadResultConsumer) {
|
void uploadProfile(@NonNull ProfileName profileName, @Nullable byte[] avatar, @NonNull Consumer<UploadResult> uploadResultConsumer) {
|
||||||
SimpleTask.run(() -> {
|
SimpleTask.run(() -> {
|
||||||
TextSecurePreferences.setProfileName(context, profileName);
|
|
||||||
DatabaseFactory.getRecipientDatabase(context).setProfileName(Recipient.self().getId(), profileName);
|
DatabaseFactory.getRecipientDatabase(context).setProfileName(Recipient.self().getId(), profileName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class RecipientDetails {
|
||||||
this.blocked = settings.isBlocked();
|
this.blocked = settings.isBlocked();
|
||||||
this.expireMessages = settings.getExpireMessages();
|
this.expireMessages = settings.getExpireMessages();
|
||||||
this.participants = participants == null ? new LinkedList<>() : participants;
|
this.participants = participants == null ? new LinkedList<>() : participants;
|
||||||
this.profileName = isLocalNumber ? TextSecurePreferences.getProfileName(context) : settings.getProfileName();
|
this.profileName = settings.getProfileName();
|
||||||
this.defaultSubscriptionId = settings.getDefaultSubscriptionId();
|
this.defaultSubscriptionId = settings.getDefaultSubscriptionId();
|
||||||
this.registered = settings.getRegistered();
|
this.registered = settings.getRegistered();
|
||||||
this.profileKey = settings.getProfileKey();
|
this.profileKey = settings.getProfileKey();
|
||||||
|
|
|
@ -340,7 +340,6 @@ public final class StorageSyncHelper {
|
||||||
DatabaseFactory.getRecipientDatabase(context).applyStorageSyncUpdates(storageId, update);
|
DatabaseFactory.getRecipientDatabase(context).applyStorageSyncUpdates(storageId, update);
|
||||||
DatabaseFactory.getThreadDatabase(context).setArchived(Recipient.self().getId(), update.isNoteToSelfArchived());
|
DatabaseFactory.getThreadDatabase(context).setArchived(Recipient.self().getId(), update.isNoteToSelfArchived());
|
||||||
|
|
||||||
TextSecurePreferences.setProfileName(context, ProfileName.fromParts(update.getGivenName().orNull(), update.getFamilyName().orNull()));
|
|
||||||
TextSecurePreferences.setReadReceiptsEnabled(context, update.isReadReceiptsEnabled());
|
TextSecurePreferences.setReadReceiptsEnabled(context, update.isReadReceiptsEnabled());
|
||||||
TextSecurePreferences.setTypingIndicatorsEnabled(context, update.isTypingIndicatorsEnabled());
|
TextSecurePreferences.setTypingIndicatorsEnabled(context, update.isTypingIndicatorsEnabled());
|
||||||
TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, update.isSealedSenderIndicatorsEnabled());
|
TextSecurePreferences.setShowUnidentifiedDeliveryIndicatorsEnabled(context, update.isSealedSenderIndicatorsEnabled());
|
||||||
|
|
|
@ -61,7 +61,7 @@ public final class AvatarUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable getFallback(@NonNull Context context, @NonNull Recipient recipient) {
|
private static Drawable getFallback(@NonNull Context context, @NonNull Recipient recipient) {
|
||||||
String name = Optional.fromNullable(recipient.getDisplayName(context)).or(Optional.fromNullable(TextSecurePreferences.getProfileName(context).toString())).or("");
|
String name = Optional.fromNullable(recipient.getDisplayName(context)).or("");
|
||||||
MaterialColor fallbackColor = recipient.getColor();
|
MaterialColor fallbackColor = recipient.getColor();
|
||||||
|
|
||||||
if (fallbackColor == ContactColors.UNKNOWN_COLOR && !TextUtils.isEmpty(name)) {
|
if (fallbackColor == ContactColors.UNKNOWN_COLOR && !TextUtils.isEmpty(name)) {
|
||||||
|
|
|
@ -434,14 +434,6 @@ public class TextSecurePreferences {
|
||||||
setBooleanPreference(context, GIF_GRID_LAYOUT, isGrid);
|
setBooleanPreference(context, GIF_GRID_LAYOUT, isGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProfileName(Context context, ProfileName name) {
|
|
||||||
setStringPreference(context, PROFILE_NAME_PREF, name.serialize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProfileName getProfileName(Context context) {
|
|
||||||
return ProfileName.fromSerialized(getStringPreference(context, PROFILE_NAME_PREF, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setProfileAvatarId(Context context, int id) {
|
public static void setProfileAvatarId(Context context, int id) {
|
||||||
setIntegerPrefrence(context, PROFILE_AVATAR_ID_PREF, id);
|
setIntegerPrefrence(context, PROFILE_AVATAR_ID_PREF, id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -641,7 +641,7 @@ public class SignalServiceAccountManager {
|
||||||
this.pushServiceSocket.setProfileName(ciphertextName);
|
this.pushServiceSocket.setProfileName(ciphertextName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfileAvatar(ProfileKey key, StreamDetails avatar)
|
public String setProfileAvatar(ProfileKey key, StreamDetails avatar)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (FeatureFlags.VERSIONED_PROFILES) {
|
if (FeatureFlags.VERSIONED_PROFILES) {
|
||||||
|
@ -657,10 +657,13 @@ public class SignalServiceAccountManager {
|
||||||
new ProfileCipherOutputStreamFactory(key));
|
new ProfileCipherOutputStreamFactory(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushServiceSocket.setProfileAvatar(profileAvatarData);
|
return this.pushServiceSocket.setProfileAvatar(profileAvatarData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersionedProfile(UUID uuid, ProfileKey profileKey, String name, StreamDetails avatar)
|
/**
|
||||||
|
* @return The avatar URL path, if one was written.
|
||||||
|
*/
|
||||||
|
public String setVersionedProfile(UUID uuid, ProfileKey profileKey, String name, StreamDetails avatar)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (!FeatureFlags.VERSIONED_PROFILES) {
|
if (!FeatureFlags.VERSIONED_PROFILES) {
|
||||||
|
@ -680,11 +683,11 @@ public class SignalServiceAccountManager {
|
||||||
new ProfileCipherOutputStreamFactory(profileKey));
|
new ProfileCipherOutputStreamFactory(profileKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion(uuid).serialize(),
|
return this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion(uuid).serialize(),
|
||||||
ciphertextName,
|
ciphertextName,
|
||||||
hasAvatar,
|
hasAvatar,
|
||||||
profileKey.getCommitment(uuid).serialize()),
|
profileKey.getCommitment(uuid).serialize()),
|
||||||
profileAvatarData);
|
profileAvatarData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) throws IOException {
|
public void setUsername(String username) throws IOException {
|
||||||
|
|
|
@ -604,7 +604,7 @@ public class PushServiceSocket {
|
||||||
makeServiceRequest(String.format(PROFILE_PATH, "name/" + (name == null ? "" : URLEncoder.encode(name))), "PUT", "");
|
makeServiceRequest(String.format(PROFILE_PATH, "name/" + (name == null ? "" : URLEncoder.encode(name))), "PUT", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfileAvatar(ProfileAvatarData profileAvatar)
|
public String setProfileAvatar(ProfileAvatarData profileAvatar)
|
||||||
throws NonSuccessfulResponseCodeException, PushNetworkException
|
throws NonSuccessfulResponseCodeException, PushNetworkException
|
||||||
{
|
{
|
||||||
if (FeatureFlags.VERSIONED_PROFILES) {
|
if (FeatureFlags.VERSIONED_PROFILES) {
|
||||||
|
@ -628,10 +628,17 @@ public class PushServiceSocket {
|
||||||
formAttributes.getSignature(), profileAvatar.getData(),
|
formAttributes.getSignature(), profileAvatar.getData(),
|
||||||
profileAvatar.getContentType(), profileAvatar.getDataLength(),
|
profileAvatar.getContentType(), profileAvatar.getDataLength(),
|
||||||
profileAvatar.getOutputStreamFactory(), null, null);
|
profileAvatar.getOutputStreamFactory(), null, null);
|
||||||
|
|
||||||
|
return formAttributes.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeProfile(SignalServiceProfileWrite signalServiceProfileWrite, ProfileAvatarData profileAvatar)
|
/**
|
||||||
|
* @return The avatar URL path, if one was written.
|
||||||
|
*/
|
||||||
|
public String writeProfile(SignalServiceProfileWrite signalServiceProfileWrite, ProfileAvatarData profileAvatar)
|
||||||
throws NonSuccessfulResponseCodeException, PushNetworkException
|
throws NonSuccessfulResponseCodeException, PushNetworkException
|
||||||
{
|
{
|
||||||
if (!FeatureFlags.VERSIONED_PROFILES) {
|
if (!FeatureFlags.VERSIONED_PROFILES) {
|
||||||
|
@ -657,7 +664,11 @@ public class PushServiceSocket {
|
||||||
formAttributes.getSignature(), profileAvatar.getData(),
|
formAttributes.getSignature(), profileAvatar.getData(),
|
||||||
profileAvatar.getContentType(), profileAvatar.getDataLength(),
|
profileAvatar.getContentType(), profileAvatar.getDataLength(),
|
||||||
profileAvatar.getOutputStreamFactory(), null, null);
|
profileAvatar.getOutputStreamFactory(), null, null);
|
||||||
|
|
||||||
|
return formAttributes.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) throws IOException {
|
public void setUsername(String username) throws IOException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue