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 {
|
|
|
|
|
|
|
|
private long deviceId;
|
|
|
|
private TextView name;
|
|
|
|
private TextView created;
|
|
|
|
private TextView lastActive;
|
|
|
|
|
|
|
|
public DeviceListItem(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public DeviceListItem(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFinishInflate() {
|
|
|
|
super.onFinishInflate();
|
|
|
|
this.name = (TextView) findViewById(R.id.name);
|
|
|
|
this.created = (TextView) findViewById(R.id.created);
|
|
|
|
this.lastActive = (TextView) findViewById(R.id.active);
|
|
|
|
}
|
|
|
|
|
2018-12-19 08:09:22 -08:00
|
|
|
public void set(Device deviceInfo, Locale locale) {
|
2015-06-19 22:02:10 -07:00
|
|
|
if (TextUtils.isEmpty(deviceInfo.getName())) this.name.setText(R.string.DeviceListItem_unnamed_device);
|
|
|
|
else this.name.setText(deviceInfo.getName());
|
|
|
|
|
2015-07-28 18:29:57 +09:00
|
|
|
this.created.setText(getContext().getString(R.string.DeviceListItem_linked_s,
|
2015-11-23 16:25:04 -08:00
|
|
|
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
2015-12-02 16:35:07 +09:00
|
|
|
locale,
|
2015-11-23 16:25:04 -08:00
|
|
|
deviceInfo.getCreated())));
|
2015-06-19 22:02:10 -07:00
|
|
|
|
|
|
|
this.lastActive.setText(getContext().getString(R.string.DeviceListItem_last_active_s,
|
2015-11-23 16:25:04 -08:00
|
|
|
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
2015-12-02 16:35:07 +09:00
|
|
|
locale,
|
2015-11-23 16:25:04 -08:00
|
|
|
deviceInfo.getLastSeen())));
|
2015-06-19 22:02:10 -07:00
|
|
|
|
|
|
|
this.deviceId = deviceInfo.getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getDeviceId() {
|
|
|
|
return deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDeviceName() {
|
|
|
|
return name.getText().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|