|
|
|
@ -22,6 +22,7 @@ import android.text.StaticLayout;
|
|
|
|
|
import android.text.TextPaint;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.text.util.Linkify;
|
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
|
import android.util.LruCache;
|
|
|
|
|
import android.util.Pair;
|
|
|
|
@ -106,6 +107,7 @@ import eu.siacs.conversations.databinding.CommandResultFieldBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.CommandSearchListFieldBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.CommandSpinnerFieldBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.CommandTextFieldBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.CommandUnknownBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.CommandWebviewBinding;
|
|
|
|
|
import eu.siacs.conversations.databinding.DialogQuickeditBinding;
|
|
|
|
|
import eu.siacs.conversations.http.HttpConnectionManager;
|
|
|
|
@ -2047,6 +2049,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
binding.text.setMovementMethod(method);
|
|
|
|
|
Linkify.addLinks(binding.text, Linkify.ALL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2170,7 +2173,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
} else {
|
|
|
|
|
filteredOptions = options.stream().filter(o -> o.toString().replaceAll("\\W", "").toLowerCase().contains(q)).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
adapter = new ArrayAdapter(binding.getRoot().getContext(), R.layout.simple_list_item, filteredOptions);
|
|
|
|
|
adapter = new ArrayAdapter(binding.getRoot().getContext(), R.layout.simple_list_item_selectable_text, filteredOptions);
|
|
|
|
|
binding.list.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
int checkedPos = filteredOptions.indexOf(new Option(mValue.getContent(), ""));
|
|
|
|
@ -2394,7 +2397,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (defaultOption == null && !mValue.getContent().equals("")) {
|
|
|
|
|
if (defaultOption == null && mValue.getContent() != null && !mValue.getContent().equals("")) {
|
|
|
|
|
// Synthesize default option for custom value
|
|
|
|
|
defaultOption = new Option(mValue.getContent(), mValue.getContent());
|
|
|
|
|
}
|
|
|
|
@ -2542,6 +2545,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UnknownViewHolder extends ViewHolder<CommandUnknownBinding> {
|
|
|
|
|
public UnknownViewHolder(CommandUnknownBinding binding) { super(binding); }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bind(Item item) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Item {
|
|
|
|
|
protected Element el;
|
|
|
|
|
protected int viewType;
|
|
|
|
@ -2634,7 +2644,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Field mkField(Element el) {
|
|
|
|
|
int viewType = -1;
|
|
|
|
|
int viewType = TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
String formType = responseElement.getAttribute("type");
|
|
|
|
|
if (formType != null) {
|
|
|
|
@ -2666,10 +2676,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (viewType == -1) {
|
|
|
|
|
throw new RuntimeException("Invalid field " + responseElement.getName() + " " + formType + " " + fieldType + " " + el.getName() + " " + el);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Field(eu.siacs.conversations.xmpp.forms.Field.parse(el), viewType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2677,7 +2683,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Item mkItem(Element el, int pos) {
|
|
|
|
|
int viewType = -1;
|
|
|
|
|
int viewType = TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
if (response != null && response.getType() == IqPacket.TYPE.RESULT) {
|
|
|
|
|
if (el.getName().equals("note")) {
|
|
|
|
@ -2693,22 +2699,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
return field;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (viewType == -1) {
|
|
|
|
|
throw new RuntimeException("Invalid element " + el.getName() + " " + el.getNamespace() + " " + el);
|
|
|
|
|
}
|
|
|
|
|
} else if (response != null) {
|
|
|
|
|
viewType = TYPE_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (viewType == -1) {
|
|
|
|
|
if (responseElement == null) {
|
|
|
|
|
throw new RuntimeException("Invalid element - nullable response");
|
|
|
|
|
} else {
|
|
|
|
|
throw new RuntimeException("Invalid element, type " + response.getType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item item = new Item(el, viewType);
|
|
|
|
|
items.put(pos, item);
|
|
|
|
|
return item;
|
|
|
|
@ -2718,7 +2712,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
protected Context ctx;
|
|
|
|
|
|
|
|
|
|
public ActionsAdapter(Context ctx) {
|
|
|
|
|
super(ctx, R.layout.simple_list_item);
|
|
|
|
|
super(ctx, R.layout.simple_list_item_selectable_text);
|
|
|
|
|
this.ctx = ctx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2774,6 +2768,8 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
final int TYPE_ITEM_CARD = 12;
|
|
|
|
|
final int TYPE_BUTTON_GRID_FIELD = 13;
|
|
|
|
|
|
|
|
|
|
final int TYPE_UNKNOWN = 100;
|
|
|
|
|
|
|
|
|
|
protected boolean executing = false;
|
|
|
|
|
protected boolean loading = false;
|
|
|
|
|
protected boolean loadingHasBeenLong = false;
|
|
|
|
@ -3142,6 +3138,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|
|
|
|
CommandProgressBarBinding binding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.command_progress_bar, container, false);
|
|
|
|
|
return new ProgressBarViewHolder(binding);
|
|
|
|
|
}
|
|
|
|
|
case TYPE_UNKNOWN: {
|
|
|
|
|
CommandUnknownBinding binding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.command_unknown, container, false);
|
|
|
|
|
return new UnknownViewHolder(binding);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
throw new IllegalArgumentException("Unknown viewType: " + viewType + " based on: " + response);
|
|
|
|
|
}
|
|
|
|
|