Minor fixes

This commit is contained in:
世界 2020-11-22 02:57:43 +00:00
parent 3b7d360a53
commit c24b9b1fe6
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
11 changed files with 82 additions and 68 deletions

View File

@ -2,8 +2,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def verName = "7.2.1-rc08"
def verCode = 115
def verName = "7.2.1-rc09"
def verCode = 116
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -225,6 +225,7 @@ android {
debuggable true
jniDebuggable true
multiDexEnabled true
zipAlignEnabled true
}
releaseNoGcm {
@ -233,6 +234,7 @@ android {
minifyEnabled true
shrinkResources true
multiDexEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
signingConfig signingConfigs.release
@ -245,6 +247,7 @@ android {
minifyEnabled true
shrinkResources true
multiDexEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
signingConfig signingConfigs.release
@ -256,6 +259,7 @@ android {
minifyEnabled true
shrinkResources true
multiDexEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
matchingFallbacks = ['debug']
}

View File

@ -4878,7 +4878,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
closePinned.setVisibility(View.GONE);
}
if (Build.VERSION.SDK_INT >= 21) {
closePinned.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_inappPlayerClose) & 0x19ffffff, 1, AndroidUtilities.dp(14)));
closePinned.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 1, AndroidUtilities.dp(14)));
}
pinnedMessageView.addView(closePinned, LayoutHelper.createFrame(36, 48, Gravity.RIGHT | Gravity.TOP, 0, 0, 2, 0));
closePinned.setOnClickListener(v -> {

View File

@ -3154,7 +3154,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
recordAudioVideoRunnable.run();
recordCircle.sendButtonVisible = true;
startLockTransition(false);
});
cell.setMinimumWidth(AndroidUtilities.dp(196));
@ -4297,7 +4296,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
isInInput = use;
if (duration == 0 && (hasBotCommands || botReplyMarkup != null)) {
if (duration == 0 && checkBotButton()) {
botButton.setVisibility(use ? View.GONE : View.VISIBLE);
}
@ -4415,7 +4414,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
AnimatorSet attachIconAnimator = null;
AnimatorSet botIconAnimator = null;
if (attachButton != null) {
if (attachButton != null && NekoConfig.useChatAttachMediaMenu) {
checkAttachButton(false, 150);
if (!attachButton.isShown()) {
attachButton.setAlpha(0f);
@ -4475,12 +4474,20 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
recordPannelAnimation = new AnimatorSet();
if (attachIconAnimator != null) {
recordPannelAnimation.playTogether(
exitAnimation,
attachIconAnimator,
botIconAnimator,
iconsEndAnimator
);
if (botIconAnimator != null) {
recordPannelAnimation.playTogether(
exitAnimation,
attachIconAnimator,
botIconAnimator,
iconsEndAnimator
);
} else {
recordPannelAnimation.playTogether(
exitAnimation,
attachIconAnimator,
iconsEndAnimator
);
}
} else {
recordPannelAnimation.playTogether(
exitAnimation,
@ -4710,7 +4717,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
runningAnimation = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
if (botButton.getVisibility() == VISIBLE) {
if (NekoConfig.useChatAttachMediaMenu && botButton.getVisibility() == VISIBLE) {
animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_X, 0.1f));
animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 0.1f));
animators.add(ObjectAnimator.ofFloat(botButton, View.ALPHA, 0.0f));
@ -4896,7 +4903,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
runningAnimation = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
if (botButton.getVisibility() == VISIBLE) {
if (NekoConfig.useChatAttachMediaMenu && botButton.getVisibility() == VISIBLE) {
animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_X, 0.1f));
animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 0.1f));
animators.add(ObjectAnimator.ofFloat(botButton, View.ALPHA, 0.0f));

View File

@ -45,6 +45,8 @@ import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.Theme;
import java.util.List;
import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.transtale.TranslateDb;
@ -52,8 +54,6 @@ import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.transtale.TranslatorKt;
import tw.nekomimi.nekogram.utils.AlertUtil;
import java.util.List;
public class EditTextCaption extends EditTextBoldCursor {
private static final int ACCESSIBILITY_ACTION_SHARE = 0x10000000;
@ -497,6 +497,9 @@ public class EditTextCaption extends EditTextBoldCursor {
} else if (itemId == R.id.menu_link) {
makeSelectedUrl();
return true;
} else if (itemId == R.id.menu_mention) {
makeSelectedMention();
return true;
} else if (itemId == R.id.menu_strike) {
makeSelectedStrike();
return true;

View File

@ -921,17 +921,9 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
Locale current = ConfigurationCompat.getLocales(getParentActivity().getResources().getConfiguration()).get(0);
boolean disableAdvOptions = !NekoXConfig.developerMode && "cn".equals(current.getCountry().toLowerCase());
if (!disableAdvOptions) {
otherItem.addSubItem(4, R.drawable.list_bot, LocaleController.getString("BotLogin", R.string.BotLogin));
}
otherItem.addSubItem(4, R.drawable.list_bot, LocaleController.getString("BotLogin", R.string.BotLogin));
otherItem.addSubItem(menu_custom_api, R.drawable.baseline_vpn_key_24, LocaleController.getString("CustomApi", R.string.CustomApi));
if (!disableAdvOptions) {
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24, LocaleController.getString("CustomBackend", R.string.CustomBackend));
}
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24, LocaleController.getString("CustomBackend", R.string.CustomBackend));
actionBar.setAllowOverlayTitle(true);
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

View File

@ -7,10 +7,10 @@ import org.apache.commons.lang3.LocaleUtils
import org.telegram.messenger.LocaleController
import org.telegram.messenger.R
import tw.nekomimi.nekogram.NekoConfig
import tw.nekomimi.nekogram.PopupBuilder
import tw.nekomimi.nekogram.transtale.source.GoogleWebTranslator
import tw.nekomimi.nekogram.transtale.source.LingoTranslator
import tw.nekomimi.nekogram.transtale.source.YandexTranslator
import tw.nekomimi.nekogram.PopupBuilder
import tw.nekomimi.nekogram.utils.UIUtil
import tw.nekomimi.nekogram.utils.receive
import tw.nekomimi.nekogram.utils.receiveLazy
@ -50,17 +50,16 @@ val String.transDbByCode by receive<String, TranslateDb> { code2Locale.transDb }
interface Translator {
fun doTranslate(from: String, to: String, query: String): String
suspend fun doTranslate(from: String, to: String, query: String): String
companion object {
@Throws(Exception::class)
@JvmStatic
fun translate(query: String) = translate(NekoConfig.translateToLang?.code2Locale ?: LocaleController.getInstance().currentLocale, query)
suspend fun translate(query: String) = translate(NekoConfig.translateToLang?.code2Locale
?: LocaleController.getInstance().currentLocale, query)
@Throws(Exception::class)
@JvmStatic
fun translate(to: Locale, query: String): String {
suspend fun translate(to: Locale, query: String): String {
var toLang = to.language
@ -173,7 +172,7 @@ interface Translator {
@JvmOverloads
fun translate(to: Locale = NekoConfig.translateToLang?.code2Locale ?: LocaleController.getInstance().currentLocale, query: String, translateCallBack: TranslateCallBack) {
UIUtil.runOnIoDispatcher(Runnable {
UIUtil.runOnIoDispatcher {
runCatching {
@ -191,7 +190,7 @@ interface Translator {
}
})
}
}

View File

@ -12,7 +12,7 @@ import tw.nekomimi.nekogram.utils.HttpUtil
object GoogleCloudTranslator : Translator {
override fun doTranslate(from: String, to: String, query: String): String {
override suspend fun doTranslate(from: String, to: String, query: String): String {
if (to !in targetLanguages) {

View File

@ -1,25 +1,23 @@
package tw.nekomimi.nekogram.transtale.source
import android.text.TextUtils
import cn.hutool.core.util.StrUtil
import kotlinx.coroutines.delay
import okhttp3.Request
import org.json.JSONArray
import org.telegram.messenger.LocaleController
import org.telegram.messenger.R
import tw.nekomimi.nekogram.NekoConfig
import tw.nekomimi.nekogram.NekoXPushService
import tw.nekomimi.nekogram.transtale.TransUtils
import tw.nekomimi.nekogram.transtale.Translator
import tw.nekomimi.nekogram.utils.HttpUtil
import tw.nekomimi.nekogram.utils.applyUserAgent
import java.util.*
import java.util.regex.Pattern
object GoogleWebTranslator : Translator {
lateinit var tkk: LongArray
override fun doTranslate(from: String, to: String, query: String): String {
override suspend fun doTranslate(from: String, to: String, query: String): String {
if (NekoConfig.translationProvider != 2 && StrUtil.isNotBlank(NekoConfig.googleCloudTranslateKey)) return GoogleCloudTranslator.doTranslate(from, to, query)
@ -29,38 +27,50 @@ object GoogleWebTranslator : Translator {
}
if (!GoogleWebTranslator::tkk.isInitialized) {
for (index in 0 until 4) {
val url = "https://translate.google." + if (NekoConfig.translationProvider == 2) "cn" else "com"
if (!GoogleWebTranslator::tkk.isInitialized) {
val response = runCatching {
(if (NekoConfig.translationProvider == 2) HttpUtil.okHttpClientNoDoh else HttpUtil.okHttpClient).newCall(Request.Builder().url(url).applyUserAgent().build()).execute()
}.recoverCatching {
HttpUtil.okHttpClientWithCurrProxy.newCall(Request.Builder().url(url).applyUserAgent().build()).execute()
}.getOrThrow()
val url = "https://translate.google." + if (NekoConfig.translationProvider == 2) "cn" else "com"
if (response.code != 200) {
val response = runCatching {
(if (NekoConfig.translationProvider == 2) HttpUtil.okHttpClientNoDoh else HttpUtil.okHttpClient).newCall(Request.Builder().url(url).applyUserAgent().build()).execute()
}.recoverCatching {
HttpUtil.okHttpClientWithCurrProxy.newCall(Request.Builder().url(url).applyUserAgent().build()).execute()
}.getOrThrow()
error("HTTP ${response.code} : ${response.body?.string()}")
if (response.code != 200) {
error("HTTP ${response.code} : ${response.body?.string()}")
}
val html = response.body?.string()
if (html.isNullOrBlank()) {
error("Tkk init failed")
}
val matcher = Pattern.compile("tkk\\s*[:=]\\s*['\"]([0-9]+)\\.([0-9]+)['\"]", Pattern.CASE_INSENSITIVE or Pattern.UNICODE_CASE).matcher(html)
tkk = if (matcher.find() && matcher.group(1) != null && matcher.group(2) != null) {
longArrayOf(matcher.group(1).toLong(), matcher.group(2).toLong())
} else {
delay(1000L)
continue
}
break
}
val html = response.body?.string()
if (html.isNullOrBlank()) {
error("Tkk init failed")
}
val matcher = Pattern.compile("tkk\\s*[:=]\\s*['\"]([0-9]+)\\.([0-9]+)['\"]", Pattern.CASE_INSENSITIVE or Pattern.UNICODE_CASE).matcher(html)
tkk = if (matcher.find() && matcher.group(1) != null && matcher.group(2) != null) {
longArrayOf(matcher.group(1).toLong(), matcher.group(2).toLong())
} else error("Tkk match failed")
}
if (!GoogleWebTranslator::tkk.isInitialized) error("Tkk match failed")
val tk = TransUtils.signWeb(query, tkk[0], tkk[1])
val url = "https://translate.google." + (if (NekoConfig.translationProvider == 2) "cn" else "com") + "/translate_a/single?client=webapp&dt=t&sl=auto" +

View File

@ -11,7 +11,7 @@ import tw.nekomimi.nekogram.utils.applyUserAgent
object LingoTranslator : Translator {
override fun doTranslate(from: String, to: String, query: String): String {
override suspend fun doTranslate(from: String, to: String, query: String): String {
if (to !in listOf("zh", "en", "es", "fr", "ja", "ru")) {

View File

@ -4,7 +4,6 @@ import cn.hutool.core.lang.UUID
import okhttp3.FormBody
import okhttp3.Request
import org.json.JSONObject
import tw.nekomimi.nekogram.NekoConfig
import tw.nekomimi.nekogram.transtale.Translator
import tw.nekomimi.nekogram.utils.HttpUtil
import tw.nekomimi.nekogram.utils.applyUserAgent
@ -13,7 +12,7 @@ object YandexTranslator : Translator {
val uuid = UUID.fastUUID().toString(true)
override fun doTranslate(from: String, to: String, query: String): String {
override suspend fun doTranslate(from: String, to: String, query: String): String {
val uuid2 = UUID.fastUUID().toString(true)

View File

@ -1,6 +1,6 @@
#Mon Sep 21 05:52:10 UTC 2020
#Fri Nov 20 09:53:27 UTC 2020
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME