Skip to content

Commit

Permalink
fix: photo caption translate
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Sep 14, 2023
1 parent 7ee7c6e commit d49552b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
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;
Expand Down Expand Up @@ -295,8 +296,15 @@ public void makeSelectedTranslate() {
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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ public void scrollTo(int x, int y) {
}
}
};
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());
Expand Down

0 comments on commit d49552b

Please sign in to comment.