2015-06-19 22:02:10 -07:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2018-12-19 08:09:22 -08:00
|
|
|
import org.thoughtcrime.securesms.devicelist.Device;
|
2015-06-19 22:02:10 -07:00
|
|
|
import org.thoughtcrime.securesms.util.DateUtils;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-06-19 22:02:10 -07:00
|
|
|
public class DeviceListItem extends LinearLayout {
|
|
|
|
|
2019-11-20 09:50:40 +11:00
|
|
|
private String deviceId;
|
2015-06-19 22:02:10 -07:00
|
|
|
private TextView name;
|
2019-11-20 15:47:28 +11:00
|
|
|
private TextView shortId;
|
2015-06-19 22:02:10 -07:00
|
|
|
|
|
|
|
public DeviceListItem(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DeviceListItem(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFinishInflate() {
|
|
|
|
super.onFinishInflate();
|
2019-11-20 15:47:28 +11:00
|
|
|
this.name = (TextView) findViewById(R.id.name);
|
|
|
|
this.shortId = (TextView) findViewById(R.id.shortId);
|
2015-06-19 22:02:10 -07:00
|
|
|
}
|
|
|
|
|
2018-12-19 08:09:22 -08:00
|
|
|
public void set(Device deviceInfo, Locale locale) {
|
2015-06-19 22:02:10 -07:00
|
|
|
this.deviceId = deviceInfo.getId();
|
2019-11-20 15:47:28 +11:00
|
|
|
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);
|
2015-06-19 22:02:10 -07:00
|
|
|
}
|
|
|
|
|
2019-11-20 09:50:40 +11:00
|
|
|
public String getDeviceId() {
|
2015-06-19 22:02:10 -07:00
|
|
|
return deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDeviceName() {
|
|
|
|
return name.getText().toString();
|
|
|
|
}
|
|
|
|
|
2019-11-21 10:50:33 +11:00
|
|
|
public boolean hasDeviceName() {
|
|
|
|
return shortId.getVisibility() == VISIBLE;
|
|
|
|
}
|
|
|
|
|
2015-06-19 22:02:10 -07:00
|
|
|
}
|