mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-23 23:51:02 +00:00
Display profile name in when appropriate
Display in conversation list, conversation actionbar, group messages, and group members list when address is not in system contacts // FREEBIE
This commit is contained in:
@@ -162,17 +162,22 @@ public class DirectoryHelper {
|
||||
List<Address> newUsers = DatabaseFactory.getContactsDatabase(context)
|
||||
.setRegisteredUsers(account.get().getAccount(), activeAddresses, removeMissing);
|
||||
|
||||
Cursor cursor = ContactAccessor.getInstance().getAllSystemContacts(context);
|
||||
Cursor cursor = ContactAccessor.getInstance().getAllSystemContacts(context);
|
||||
RecipientPreferenceDatabase.BulkOperationsHandle handle = DatabaseFactory.getRecipientPreferenceDatabase(context).resetAllDisplayNames();
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
|
||||
try {
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
|
||||
|
||||
if (!TextUtils.isEmpty(number)) {
|
||||
Address address = Address.fromExternal(context, number);
|
||||
String displayName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
|
||||
if (!TextUtils.isEmpty(number)) {
|
||||
Address address = Address.fromExternal(context, number);
|
||||
String displayName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
|
||||
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setSystemDisplayName(address, displayName);
|
||||
handle.setDisplayName(address, displayName);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
handle.finish();
|
||||
}
|
||||
|
||||
return new RefreshResult(newUsers, account.get().isFresh());
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.thoughtcrime.securesms.util.spans;
|
||||
|
||||
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.MetricAffectingSpan;
|
||||
|
||||
public class CenterAlignedRelativeSizeSpan extends MetricAffectingSpan {
|
||||
|
||||
private final float relativeSize;
|
||||
|
||||
public CenterAlignedRelativeSizeSpan(float relativeSize) {
|
||||
this.relativeSize = relativeSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
updateDrawState(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setTextSize(tp.getTextSize() * relativeSize);
|
||||
tp.baselineShift += (int) (tp.ascent() * relativeSize) / 4;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user