118 lines
4.2 KiB
Java
118 lines
4.2 KiB
Java
package com.discord.widgets.chat.input;
|
|
|
|
import android.widget.TextView;
|
|
import com.discord.widgets.chat.input.MessageDraftsRepo;
|
|
import com.lytefast.flexinput.widget.FlexEditText;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.subjects.BehaviorSubject;
|
|
import rx.subjects.Subject;
|
|
/* compiled from: WidgetChatInputEditText.kt */
|
|
public final class WidgetChatInputEditText {
|
|
public static final Companion Companion = new Companion(null);
|
|
private long channelId;
|
|
private final FlexEditText editText;
|
|
private final Subject<Boolean, Boolean> emptyTextSubject;
|
|
private long lastTypingEmissionMillis;
|
|
private final MessageDraftsRepo messageDraftsRepo;
|
|
private Function0<Unit> onSendListener;
|
|
|
|
/* compiled from: WidgetChatInputEditText.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final String toStringSafe(TextView textView) {
|
|
m.checkNotNullParameter(textView, "textView");
|
|
try {
|
|
return textView.getText().toString();
|
|
} catch (Exception unused) {
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public WidgetChatInputEditText(FlexEditText flexEditText, MessageDraftsRepo messageDraftsRepo) {
|
|
m.checkNotNullParameter(flexEditText, "editText");
|
|
m.checkNotNullParameter(messageDraftsRepo, "messageDraftsRepo");
|
|
this.editText = flexEditText;
|
|
this.messageDraftsRepo = messageDraftsRepo;
|
|
BehaviorSubject k0 = BehaviorSubject.k0(Boolean.TRUE);
|
|
m.checkNotNullExpressionValue(k0, "BehaviorSubject.create(true)");
|
|
this.emptyTextSubject = k0;
|
|
setOnTextChangedListener();
|
|
setSoftwareKeyboardSendBehavior();
|
|
setHardwareKeyboardSendBehavior();
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ WidgetChatInputEditText(FlexEditText flexEditText, MessageDraftsRepo messageDraftsRepo, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(flexEditText, (i & 2) != 0 ? MessageDraftsRepo.Provider.INSTANCE.get() : messageDraftsRepo);
|
|
}
|
|
|
|
public static final /* synthetic */ Subject access$getEmptyTextSubject$p(WidgetChatInputEditText widgetChatInputEditText) {
|
|
return widgetChatInputEditText.emptyTextSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getLastTypingEmissionMillis$p(WidgetChatInputEditText widgetChatInputEditText) {
|
|
return widgetChatInputEditText.lastTypingEmissionMillis;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setLastTypingEmissionMillis$p(WidgetChatInputEditText widgetChatInputEditText, long j) {
|
|
widgetChatInputEditText.lastTypingEmissionMillis = j;
|
|
}
|
|
|
|
private final void setHardwareKeyboardSendBehavior() {
|
|
this.editText.setOnKeyListener(new WidgetChatInputEditText$setHardwareKeyboardSendBehavior$1(this));
|
|
}
|
|
|
|
private final void setOnTextChangedListener() {
|
|
this.editText.addTextChangedListener(new WidgetChatInputEditText$setOnTextChangedListener$1(this));
|
|
}
|
|
|
|
private final void setSoftwareKeyboardSendBehavior() {
|
|
this.editText.setOnEditorActionListener(new WidgetChatInputEditText$setSoftwareKeyboardSendBehavior$1(this));
|
|
}
|
|
|
|
public final void clearLastTypingEmission() {
|
|
this.lastTypingEmissionMillis = 0;
|
|
}
|
|
|
|
public final long getChannelId() {
|
|
return this.channelId;
|
|
}
|
|
|
|
public final Function0<Unit> getOnSendListener() {
|
|
return this.onSendListener;
|
|
}
|
|
|
|
public final String getText() {
|
|
return Companion.toStringSafe(this.editText);
|
|
}
|
|
|
|
public final void saveText() {
|
|
this.messageDraftsRepo.setTextChannelInput(this.channelId, this.editText.getText());
|
|
}
|
|
|
|
public final void setChannelId(long j) {
|
|
this.channelId = j;
|
|
}
|
|
|
|
public final void setChannelId(long j, boolean z2) {
|
|
if (z2) {
|
|
saveText();
|
|
}
|
|
this.channelId = j;
|
|
}
|
|
|
|
public final void setOnSendListener(Function0<Unit> function0) {
|
|
this.onSendListener = function0;
|
|
}
|
|
}
|