mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Show name and short id in linked device screen.
This commit is contained in:
parent
e72d5502ce
commit
c3bda57ac1
@ -6,30 +6,36 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp">
|
android:layout_marginEnd="16dp">
|
||||||
|
|
||||||
<TextView android:id="@+id/name"
|
<LinearLayout
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:layout_width="match_parent"
|
||||||
android:textColor="?attr/conversation_list_item_contact_color"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:orientation="vertical"
|
||||||
android:ellipsize="marquee"
|
android:paddingBottom="8dp"
|
||||||
android:layout_marginTop="8dp"
|
>
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<!--
|
<TextView
|
||||||
<TextView android:id="@+id/created"
|
android:id="@+id/name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:layout_marginTop="8dp"
|
||||||
android:textColor="?attr/conversation_list_item_subject_color"
|
android:ellipsize="marquee"
|
||||||
android:fontFamily="sans-serif-light" />
|
android:singleLine="true"
|
||||||
|
android:text="Name"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="?attr/conversation_list_item_contact_color"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/shortId"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="shortId"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="#A2A2A2"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView android:id="@+id/active"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="?attr/conversation_list_item_subject_color"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:layout_marginBottom="8dp" />
|
|
||||||
-->
|
|
||||||
</org.thoughtcrime.securesms.DeviceListItem>
|
</org.thoughtcrime.securesms.DeviceListItem>
|
@ -17,8 +17,7 @@ public class DeviceListItem extends LinearLayout {
|
|||||||
|
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
private TextView name;
|
private TextView name;
|
||||||
private TextView created;
|
private TextView shortId;
|
||||||
private TextView lastActive;
|
|
||||||
|
|
||||||
public DeviceListItem(Context context) {
|
public DeviceListItem(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -31,28 +30,16 @@ public class DeviceListItem extends LinearLayout {
|
|||||||
@Override
|
@Override
|
||||||
public void onFinishInflate() {
|
public void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
this.name = (TextView) findViewById(R.id.name);
|
this.name = (TextView) findViewById(R.id.name);
|
||||||
// this.created = (TextView) findViewById(R.id.created);
|
this.shortId = (TextView) findViewById(R.id.shortId);
|
||||||
// this.lastActive = (TextView) findViewById(R.id.active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Device deviceInfo, Locale locale) {
|
public void set(Device deviceInfo, Locale locale) {
|
||||||
if (TextUtils.isEmpty(deviceInfo.getName())) this.name.setText(R.string.DeviceListItem_unnamed_device);
|
|
||||||
else this.name.setText(deviceInfo.getName());
|
|
||||||
|
|
||||||
/*
|
|
||||||
this.created.setText(getContext().getString(R.string.DeviceListItem_linked_s,
|
|
||||||
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
|
||||||
locale,
|
|
||||||
deviceInfo.getCreated())));
|
|
||||||
|
|
||||||
this.lastActive.setText(getContext().getString(R.string.DeviceListItem_last_active_s,
|
|
||||||
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
|
||||||
locale,
|
|
||||||
deviceInfo.getLastSeen())));
|
|
||||||
*/
|
|
||||||
|
|
||||||
this.deviceId = deviceInfo.getId();
|
this.deviceId = deviceInfo.getId();
|
||||||
|
boolean hasName = !TextUtils.isEmpty(deviceInfo.getName());
|
||||||
|
this.name.setText(hasName ? deviceInfo.getName() : deviceInfo.getShortId());
|
||||||
|
this.shortId.setText(deviceInfo.getShortId());
|
||||||
|
this.shortId.setVisibility(hasName ? VISIBLE : GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
|
@ -7,8 +7,10 @@ import android.text.TextUtils;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||||
|
import org.thoughtcrime.securesms.database.Database;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.devicelist.Device;
|
import org.thoughtcrime.securesms.devicelist.Device;
|
||||||
|
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.MnemonicUtilities;
|
import org.thoughtcrime.securesms.loki.MnemonicUtilities;
|
||||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||||
@ -66,8 +68,9 @@ public class DeviceListLoader extends AsyncLoader<List<Device>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Device mapToDevice(@NonNull String hexEncodedPublicKey) {
|
private Device mapToDevice(@NonNull String hexEncodedPublicKey) {
|
||||||
long now = System.currentTimeMillis();
|
String shortId = MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey);
|
||||||
return new Device(hexEncodedPublicKey, MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey), now, now);
|
String name = DatabaseFactory.getLokiUserDatabase(getContext()).getDisplayName(hexEncodedPublicKey);
|
||||||
|
return new Device(hexEncodedPublicKey, shortId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DeviceComparator implements Comparator<Device> {
|
private static class DeviceComparator implements Comparator<Device> {
|
||||||
|
@ -2,31 +2,19 @@ package org.thoughtcrime.securesms.devicelist;
|
|||||||
|
|
||||||
public class Device {
|
public class Device {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
private final String shortId;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final long created;
|
|
||||||
private final long lastSeen;
|
|
||||||
|
|
||||||
public Device(String id, String name, long created, long lastSeen) {
|
public Device(String id, String shortId, String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.shortId = shortId;
|
||||||
this.created = created;
|
this.name = name;
|
||||||
this.lastSeen = lastSeen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
public String getShortId() { return shortId; }
|
||||||
public String getName() {
|
public String getName() { return name; }
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLastSeen() {
|
|
||||||
return lastSeen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user