void confirmSubscription(ViewEvent.SubscriptionRequest event) {
    final Contact contact = event.contact;

    WebPanel panel = panel(Tr.tr("Authorization request"), contact);

    String expl = Tr.tr("When accepting, this contact will be able to see your online status.");
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mView.getControl().sendSubscriptionResponse(contact, true);
                break;
              case decline:
                mView.getControl().sendSubscriptionResponse(contact, false);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
  void confirmContactDeletion(final Contact contact) {
    WebPanel panel = panel(Tr.tr("Contact was deleted on server"), contact);

    String expl =
        Tr.tr("Remove this contact from your contact list?") + "\n" + View.REMOVE_CONTACT_NOTE;
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel, NotificationOption.yes, NotificationOption.no, NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case yes:
                mView.getControl().deleteContact(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
  // TODO not used
  private void showNotification() {
    final WebDialog dialog = new WebDialog();
    dialog.setUndecorated(true);
    dialog.setBackground(Color.BLACK);
    dialog.setBackground(StyleConstants.transparent);

    WebNotificationPopup popup = new WebNotificationPopup(PopupStyle.dark);
    popup.setIcon(Utils.getIcon("kontalk_small.png"));
    popup.setMargin(View.MARGIN_DEFAULT);
    popup.setDisplayTime(6000);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {}

          @Override
          public void accepted() {}

          @Override
          public void closed() {
            dialog.dispose();
          }
        });

    // content
    WebPanel panel = new WebPanel();
    panel.setMargin(View.MARGIN_DEFAULT);
    panel.setOpaque(false);
    WebLabel title = new WebLabel("A new Message!");
    title.setFontSize(View.FONT_SIZE_BIG);
    title.setForeground(Color.WHITE);
    panel.add(title, BorderLayout.NORTH);
    String text = "this is some message, and some longer text was added";
    WebLabel message = new WebLabel(text);
    message.setForeground(Color.WHITE);
    panel.add(message, BorderLayout.CENTER);
    popup.setContent(panel);

    // popup.packPopup();
    dialog.setSize(popup.getPreferredSize());

    // set position on screen
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Rectangle screenBounds = gc.getBounds();
    // get height of the task bar
    // doesn't work on all environments
    // Insets toolHeight = toolkit.getScreenInsets(popup.getGraphicsConfiguration());
    int toolHeight = 40;
    dialog.setLocation(
        screenBounds.width - dialog.getWidth() - 10,
        screenBounds.height - toolHeight - dialog.getHeight());

    dialog.setVisible(true);
    NotificationManager.showNotification(dialog, popup);
  }
Ejemplo n.º 4
0
  private void confirmNewKey(final Contact contact, final PGPUtils.PGPCoderKey key) {
    WebPanel panel = new GroupPanel(GAP_DEFAULT, false);
    panel.setOpaque(false);

    panel.add(new WebLabel(Tr.tr("Received new key for contact")).setBoldFont());
    panel.add(new WebSeparator(true, true));

    panel.add(new WebLabel(Tr.tr("Contact:")));
    String contactText = Utils.name(contact) + " " + Utils.jid(contact.getJID(), 30, true);
    panel.add(new WebLabel(contactText).setBoldFont());

    panel.add(new WebLabel(Tr.tr("Key fingerprint:")));
    WebTextArea fpArea = Utils.createFingerprintArea();
    fpArea.setText(Utils.fingerprint(key.fingerprint));
    panel.add(fpArea);

    String expl =
        Tr.tr(
            "When declining the key further communication to and from this contact will be blocked.");
    WebTextArea explArea = new WebTextArea(expl, 3, 30);
    explArea.setEditable(false);
    explArea.setLineWrap(true);
    explArea.setWrapStyleWord(true);
    panel.add(explArea);

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mControl.acceptKey(contact, key);
                break;
              case decline:
                mControl.declineKey(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
  void confirmNewKey(final Contact contact, final PGPUtils.PGPCoderKey key) {
    WebPanel panel = panel(Tr.tr("Received new key for contact"), contact);

    panel.add(new WebLabel(Tr.tr("Key fingerprint:")));
    WebTextArea fpArea = Utils.createFingerprintArea();
    fpArea.setText(Utils.fingerprint(key.fingerprint));
    panel.add(fpArea);

    String expl =
        Tr.tr(
            "When declining the key further communication to and from this contact will be blocked.");
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mView.getControl().acceptKey(contact, key);
                break;
              case decline:
                mView.getControl().declineKey(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }