5cfce87d9d25d93276bf0d78b878025b78c405c9
1 package be
.nikiroo
.jvcard
.tui
.panes
;
4 import java
.util
.Base64
;
5 import java
.util
.LinkedList
;
8 import javax
.swing
.ImageIcon
;
10 import be
.nikiroo
.jvcard
.Contact
;
11 import be
.nikiroo
.jvcard
.Data
;
12 import be
.nikiroo
.jvcard
.TypeInfo
;
13 import be
.nikiroo
.jvcard
.i18n
.Trans
;
14 import be
.nikiroo
.jvcard
.tui
.ImageTextControl
;
15 import be
.nikiroo
.jvcard
.tui
.KeyAction
;
16 import be
.nikiroo
.jvcard
.tui
.KeyAction
.DataType
;
17 import be
.nikiroo
.jvcard
.tui
.KeyAction
.Mode
;
19 import com
.googlecode
.lanterna
.TerminalSize
;
20 import com
.googlecode
.lanterna
.gui2
.BorderLayout
;
21 import com
.googlecode
.lanterna
.gui2
.Panel
;
22 import com
.googlecode
.lanterna
.input
.KeyType
;
24 public class ContactDetails
extends MainContent
{
25 private Contact contact
;
26 private ImageTextControl txt
;
28 public ContactDetails(Contact contact
) {
29 this.contact
= contact
;
31 BorderLayout blayout
= new BorderLayout();
32 setLayoutManager(blayout
);
34 Panel top
= new Panel();
35 if (contact
!= null) {
36 Data photo
= contact
.getPreferredData("PHOTO");
38 TypeInfo encoding
= null;
40 for (TypeInfo info
: photo
.getTypes()) {
41 if (info
.getName() != null) {
42 if (info
.getName().equalsIgnoreCase("ENCODING"))
44 if (info
.getName().equalsIgnoreCase("TYPE"))
49 if (encoding
!= null && encoding
.getValue() != null
50 && encoding
.getValue().equalsIgnoreCase("b")) {
52 Image img
= new ImageIcon(Base64
.getDecoder().decode(
53 photo
.getValue())).getImage();
55 TerminalSize size
= new TerminalSize(40, 20);
56 size
= new TerminalSize(100, 50);
58 txt
= new ImageTextControl(img
, size
);
59 top
.addComponent(txt
);
64 addComponent(top
, BorderLayout
.Location
.TOP
);
68 public DataType
getDataType() {
73 public List
<KeyAction
> getKeyBindings() {
74 List
<KeyAction
> actions
= new LinkedList
<KeyAction
>();
77 actions
.add(new KeyAction(Mode
.NONE
, KeyType
.Tab
,
78 Trans
.StringId
.KEY_ACTION_SWITCH_FORMAT
) {
80 public boolean onAction() {
88 actions
.add(new KeyAction(Mode
.NONE
, 'i',
89 Trans
.StringId
.DUMMY
) {
91 public boolean onAction() {