2015-06-20 05:02:10 +00: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 16:09:22 +00:00
|
|
|
import org.thoughtcrime.securesms.devicelist.Device;
|
2015-06-20 05:02:10 +00:00
|
|
|
import org.thoughtcrime.securesms.util.DateUtils;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-06-20 05:02:10 +00:00
|
|
|
public class DeviceListItem extends LinearLayout {
|
|
|
|
|
2019-11-19 22:50:40 +00:00
|
|
|
private String deviceId;
|
2015-06-20 05:02:10 +00:00
|
|
|
private TextView name;
|
2019-11-20 04:47:28 +00:00
|
|
|
private TextView shortId;
|
2015-06-20 05:02:10 +00: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 04:47:28 +00:00
|
|
|
this.name = (TextView) findViewById(R.id.name);
|
|
|
|
this.shortId = (TextView) findViewById(R.id.shortId);
|
2015-06-20 05:02:10 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 16:09:22 +00:00
|
|
|
public void set(Device deviceInfo, Locale locale) {
|
2015-06-20 05:02:10 +00:00
|
|
|
this.deviceId = deviceInfo.getId();
|
2019-11-20 04:47:28 +00: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-20 05:02:10 +00:00
|
|
|
}
|
|
|
|
|
2019-11-19 22:50:40 +00:00
|
|
|
public String getDeviceId() {
|
2015-06-20 05:02:10 +00:00
|
|
|
return deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDeviceName() {
|
|
|
|
return name.getText().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|