fix: photo caption translate

This commit is contained in:
xtaodada 2023-09-14 16:36:28 +08:00
parent dae106b76e
commit 8342c7cdee
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 20 additions and 1 deletions

View File

@ -55,6 +55,7 @@ import org.telegram.ui.ActionBar.AlertDialogDecor;
import org.telegram.ui.ActionBar.Theme;
import java.util.List;
import java.util.Locale;
import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
@ -295,8 +296,15 @@ public class EditTextCaption extends EditTextBoldCursor {
setText(replaceAt(origin, start, end, TranslateDb.currentInputTarget().query(text)));
} else {
Locale to;
Locale toDefault = TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String());
if (delegate != null) {
to = TranslateDb.getChatLanguage(delegate.getCurrentChat(), toDefault);
} else {
to = toDefault;
}
Translator.translate(TranslateDb.getChatLanguage(delegate.getCurrentChat(), TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String())), text, new Translator.Companion.TranslateCallBack() {
Translator.translate(to, text, new Translator.Companion.TranslateCallBack() {
AlertDialog status = AlertUtil.showProgress(getContext());

View File

@ -185,6 +185,17 @@ public class EditTextEmoji extends FrameLayout implements NotificationCenter.Not
}
}
};
editText.setDelegate(new EditTextCaption.EditTextCaptionDelegate() {
@Override
public void onSpansChanged() {
editText.invalidateEffects();
}
@Override
public long getCurrentChat() {
return 0;
}
});
editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
editText.setInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
editText.setFocusable(editText.isEnabled());