mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2025-01-21 01:49:54 +01:00
Fix convert
This commit is contained in:
parent
ce13aa9add
commit
52c4e0ccac
@ -150,6 +150,7 @@ import tw.nekomimi.nekogram.transtale.Translator;
|
||||
import tw.nekomimi.nekogram.transtale.TranslatorKt;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
import tw.nekomimi.nekogram.utils.PGPUtil;
|
||||
import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
|
||||
public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate {
|
||||
|
||||
@ -3252,9 +3253,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
cell.setTextAndIcon(LocaleController.getString("Translate", R.string.OpenCC), R.drawable.ic_translate);
|
||||
ActionBarMenuSubItem finalCell1 = cell;
|
||||
cell.setOnClickListener(v -> {
|
||||
if (menuPopupWindow != null && menuPopupWindow.isShowing()) {
|
||||
menuPopupWindow.dismiss();
|
||||
}
|
||||
String ccTarget = TranslateDb.getChatCCTarget(chatId, NekoConfig.ccInputLang);
|
||||
if (ccTarget == null || StringsKt.isBlank(ccTarget)) {
|
||||
Translator.showCCTargetSelect(finalCell1, (target) -> {
|
||||
@ -3267,6 +3265,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (menuPopupWindow != null && menuPopupWindow.isShowing()) {
|
||||
menuPopupWindow.dismiss();
|
||||
}
|
||||
ccComment(ccTarget);
|
||||
});
|
||||
cell.setOnLongClickListener(v -> {
|
||||
@ -3602,8 +3603,15 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
|
||||
private void ccComment(String target) {
|
||||
String text = messageEditText.getText().toString();
|
||||
text = CCConverter.get(CCTarget.valueOf(target)).convert(text);
|
||||
messageEditText.setText(text);
|
||||
AlertDialog progress = AlertUtil.showProgress(parentActivity);
|
||||
progress.show();
|
||||
UIUtil.runOnIoDispatcher(() -> {
|
||||
String ccText = CCConverter.get(CCTarget.valueOf(target)).convert(text);
|
||||
UIUtil.runOnUIThread(() -> {
|
||||
progress.dismiss();
|
||||
messageEditText.setText(ccText);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isSendButtonVisible() {
|
||||
|
@ -235,8 +235,8 @@ public class NekoConfig {
|
||||
translateToLang = preferences.getString("trans_to_lang", null);
|
||||
translateInputLang = preferences.getString("trans_input_to_lang", "en");
|
||||
|
||||
translateToLang = preferences.getString("opencc_to_lang", null);
|
||||
translateInputLang = preferences.getString("opencc_input_to_lang", null);
|
||||
ccToLang = preferences.getString("opencc_to_lang", null);
|
||||
ccInputLang = preferences.getString("opencc_input_to_lang", null);
|
||||
|
||||
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
|
||||
confirmAVMessage = preferences.getBoolean("confirmAVMessage", false);
|
||||
|
@ -18,19 +18,18 @@ class PopupBuilder @JvmOverloads constructor(anchor: View, dialog: Boolean = fal
|
||||
|
||||
}
|
||||
|
||||
fun setItems(items: Array<CharSequence>, listener: (Int,CharSequence) -> Unit) {
|
||||
fun setItems(items: Array<CharSequence?>, listener: (Int, CharSequence) -> Unit) {
|
||||
|
||||
removeAllSubItems()
|
||||
|
||||
items.forEachIndexed { i, v ->
|
||||
|
||||
addSubItem(i, v)
|
||||
|
||||
for (item in items) {
|
||||
if (item == null) continue
|
||||
addSubItem(items.indexOf(item), item)
|
||||
}
|
||||
|
||||
setDelegate {
|
||||
|
||||
listener(it,items[it])
|
||||
listener(it, items[it]!!)
|
||||
|
||||
}
|
||||
|
||||
|
@ -172,12 +172,13 @@ interface Translator {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showCCTargetSelect(anchor: View, callback: (String) -> Unit) {
|
||||
@JvmOverloads
|
||||
fun showCCTargetSelect(anchor: View, input: Boolean = true, callback: (String) -> Unit) {
|
||||
|
||||
val builder = PopupBuilder(anchor)
|
||||
|
||||
builder.setItems(arrayOf(
|
||||
LocaleController.getString("CCNo", R.string.CCNo),
|
||||
if (!input) LocaleController.getString("CCNo", R.string.CCNo) else null,
|
||||
LocaleController.getString("CCSC", R.string.CCSC),
|
||||
LocaleController.getString("CCSP", R.string.CCSP),
|
||||
LocaleController.getString("CCTC", R.string.CCTC),
|
||||
|
Loading…
x
Reference in New Issue
Block a user