Skip to content

Commit

Permalink
upstream: bump version to v10.14.2
Browse files Browse the repository at this point in the history
Signed-off-by: qwq233 <[email protected]>
  • Loading branch information
qwq233 committed Jun 30, 2024
2 parents 935cccc + 59a0bc1 commit 118b11b
Show file tree
Hide file tree
Showing 190 changed files with 19,131 additions and 2,479 deletions.
8 changes: 5 additions & 3 deletions TMessagesProj/jni/TgNetWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,11 @@ class Delegate : public ConnectiosManagerDelegate {
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onPremiumFloodWait, instanceNum, requestToken, isUpload);
}

void onIntegrityCheckClassic(int32_t instanceNum, int32_t requestToken, std::string nonce) {
void onIntegrityCheckClassic(int32_t instanceNum, int32_t requestToken, std::string project, std::string nonce) {
jstring projectStr = jniEnv[instanceNum]->NewStringUTF(project.c_str());
jstring nonceStr = jniEnv[instanceNum]->NewStringUTF(nonce.c_str());
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onIntegrityCheckClassic, instanceNum, requestToken, nonceStr);
jniEnv[instanceNum]->CallStaticVoidMethod(jclass_ConnectionsManager, jclass_ConnectionsManager_onIntegrityCheckClassic, instanceNum, requestToken, projectStr, nonceStr);
jniEnv[instanceNum]->DeleteLocalRef(projectStr);
jniEnv[instanceNum]->DeleteLocalRef(nonceStr);
}

Expand Down Expand Up @@ -663,7 +665,7 @@ extern "C" int registerNativeTgNetFunctions(JavaVM *vm, JNIEnv *env) {
if (jclass_ConnectionsManager_onPremiumFloodWait == 0) {
return JNI_FALSE;
}
jclass_ConnectionsManager_onIntegrityCheckClassic = env->GetStaticMethodID(jclass_ConnectionsManager, "onIntegrityCheckClassic", "(IILjava/lang/String;)V");
jclass_ConnectionsManager_onIntegrityCheckClassic = env->GetStaticMethodID(jclass_ConnectionsManager, "onIntegrityCheckClassic", "(IILjava/lang/String;Ljava/lang/String;)V");
if (jclass_ConnectionsManager_onIntegrityCheckClassic == 0) {
return JNI_FALSE;
}
Expand Down
7 changes: 5 additions & 2 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,12 +1316,15 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
}
} else if (error->error_code == 403 && error->error_message.find(integrityCheckClassic) != std::string::npos) {
discardResponse = true;
std::string nonce = error->error_message.substr(integrityCheckClassic.size(), error->error_message.size() - integrityCheckClassic.size());
std::string err = error->error_message;
int index = err.find('_', integrityCheckClassic.size());
std::string project = err.substr(integrityCheckClassic.size(), index - integrityCheckClassic.size());
std::string nonce = err.substr(integrityCheckClassic.size() + project.size() + 1, err.size() - (integrityCheckClassic.size() + project.size() + 1));
request->awaitingIntegrityCheck = true;
request->startTime = 0;
request->startTimeMillis = 0;
if (delegate != nullptr) {
delegate->onIntegrityCheckClassic(instanceNum, request->requestToken, nonce);
delegate->onIntegrityCheckClassic(instanceNum, request->requestToken, project, nonce);
}
} else {
bool failServerErrors = (request->requestFlags & RequestFlagFailOnServerErrors) == 0 || processEvenFailed;
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/tgnet/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ typedef struct ConnectiosManagerDelegate {
virtual void getHostByName(std::string domain, int32_t instanceNum, ConnectionSocket *socket) = 0;
virtual int32_t getInitFlags(int32_t instanceNum) = 0;
virtual void onPremiumFloodWait(int32_t instanceNum, int32_t requestToken, bool isUpload) = 0;
virtual void onIntegrityCheckClassic(int32_t instanceNum, int32_t requestToken, std::string nonce) = 0;
virtual void onIntegrityCheckClassic(int32_t instanceNum, int32_t requestToken, std::string project, std::string nonce) = 0;
} ConnectiosManagerDelegate;

typedef struct HandshakeDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.fonts.Font;
import android.graphics.fonts.FontFamily;
import android.graphics.fonts.FontStyle;
import android.graphics.fonts.SystemFonts;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -109,7 +110,9 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
Expand Down Expand Up @@ -314,15 +317,25 @@ public static Typeface bold() {
public static Pattern LONG_BAD_CHARS_PATTERN = null;
public static Pattern BAD_CHARS_MESSAGE_PATTERN = null;
public static Pattern BAD_CHARS_MESSAGE_LONG_PATTERN = null;
public static Pattern REMOVE_MULTIPLE_DIACRITICS = null;
private static Pattern singleTagPatter = null;

public static String removeDiacritics(String str) {
if (str == null) return null;
if (REMOVE_MULTIPLE_DIACRITICS == null) return str;
Matcher matcher = REMOVE_MULTIPLE_DIACRITICS.matcher(str);
if (matcher == null) return str;
return matcher.replaceAll("$1");
}

static {
try {
final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
BAD_CHARS_PATTERN = Pattern.compile("[\u2500-\u25ff]");
LONG_BAD_CHARS_PATTERN = Pattern.compile("[\u4e00-\u9fff]");
BAD_CHARS_MESSAGE_LONG_PATTERN = Pattern.compile("[\u0300-\u036f\u2066-\u2067]+");
BAD_CHARS_MESSAGE_LONG_PATTERN = Pattern.compile("[\u0300-\u036f\u2066-\u2067]");
BAD_CHARS_MESSAGE_PATTERN = Pattern.compile("[\u2066-\u2067]+");
REMOVE_MULTIPLE_DIACRITICS = Pattern.compile("([\\u0300-\\u036f]{1,2})[\\u0300-\\u036f]+");
final Pattern IP_ADDRESS = Pattern.compile(
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
Expand Down Expand Up @@ -574,6 +587,34 @@ public void updateDrawState(TextPaint textPaint) {
return spannableStringBuilder;
}


public static SpannableStringBuilder replaceMultipleTags(String str, Runnable ...runnables) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str);
for (int i = 0; i < runnables.length; ++i) {
Runnable runnable = runnables[i];

int start = charSequenceIndexOf(spannableStringBuilder, "**");
int end = charSequenceIndexOf(spannableStringBuilder, "**", start + 2);
if (start < 0 || end < 0) break;

spannableStringBuilder.delete(start, start + 2);
end = end - 2;
spannableStringBuilder.delete(end, end + 2);
spannableStringBuilder.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
@Override
public void onClick(@NonNull View widget) {
if (runnable != null) runnable.run();
}
}, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return spannableStringBuilder;
}

public static SpannableStringBuilder replaceSingleLink(String str, int color) {
return replaceSingleLink(str, color, null);
}
Expand Down Expand Up @@ -1841,13 +1882,17 @@ public String getRawType(boolean first) {
}

public String getType() {
if (type == 5) {
return LocaleController.getString("ContactBirthday", R.string.ContactBirthday);
if (type == 4) {
return LocaleController.getString(R.string.ContactNote);
} else if (type == 3) {
return LocaleController.getString(R.string.ContactUrl);
} else if (type == 5) {
return LocaleController.getString(R.string.ContactBirthday);
} else if (type == 6) {
if ("ORG".equalsIgnoreCase(getRawType(true))) {
return LocaleController.getString("ContactJob", R.string.ContactJob);
return LocaleController.getString(R.string.ContactJob);
} else {
return LocaleController.getString("ContactJobTitle", R.string.ContactJobTitle);
return LocaleController.getString(R.string.ContactJobTitle);
}
}
int idx = fullData.indexOf(':');
Expand Down Expand Up @@ -4662,6 +4707,15 @@ public static void lerp(Rect a, Rect b, float f, Rect to) {
}
}

public static void lerpCentered(RectF a, RectF b, float f, RectF to) {
if (to == null) return;
final float cx = lerp(a.centerX(), b.centerX(), f);
final float cy = lerp(a.centerY(), b.centerY(), f);
final float hw = lerp(a.width(), b.width(), Math.min(1, f)) / 2f;
final float hh = lerp(a.height(), b.height(), Math.min(1, f)) / 2f;
to.set(cx - hw, cy - hh, cx + hw, cy + hh);
}

public static void lerp(int[] a, int[] b, float f, int[] to) {
if (to == null) return;
for (int i = 0; i < to.length; ++i) {
Expand Down Expand Up @@ -5831,4 +5885,71 @@ public static void vibrate(View view) {
} catch (Exception ignore) {}
}

public static void applySpring(Animator anim, float stiffness, float damping) {
applySpring(anim, stiffness, damping, 1);
}

public static void applySpring(Animator anim, float stiffness, float damping, float mass) {
final double delta = damping / (2.0 * Math.sqrt(stiffness * mass));
final double undampedFrequency = Math.sqrt(stiffness / mass);
final double omega_0 = Math.sqrt(stiffness / mass);
final double zeta = damping / (2 * Math.sqrt(stiffness * mass));
final double threshold = 0.0025;
final double duration = Math.log(threshold) / (-zeta * omega_0);
anim.setDuration((long) (duration * 1000L));
anim.setInterpolator(new Interpolator() {
@Override
public float getInterpolation(float t) {
if (delta < 1) {
final double dampedFrequency = undampedFrequency * Math.sqrt(1 - delta * delta);
return (float) (1 - Math.exp(-delta * undampedFrequency * t) *
(Math.cos(dampedFrequency * t) + (delta * undampedFrequency / dampedFrequency) * Math.sin(dampedFrequency * t)));
} else {
final double a = -delta * undampedFrequency * t;
return (float) (1 - (1 + a) * Math.exp(a));
}
}
});
}

public static boolean isWebAppLink(String url) {
if (url == null) return false;
try {
Uri uri = Uri.parse(url);
final String scheme = uri.getScheme();
if (scheme == null) return false;
final String path = uri.getPath();
if (path == null) return false;
switch (scheme) {
case "http":
case "https": {
if (path.isEmpty()) return false;
ArrayList<String> segments = new ArrayList<>(uri.getPathSegments());
if (segments.size() > 0 && segments.get(0).equals("s")) {
segments.remove(0);
}
if (segments.size() > 0) {
if (segments.size() >= 3 && "s".equals(segments.get(1))) {
return false;
} else if (segments.size() > 1) {
return !TextUtils.isEmpty(segments.get(1));
} else if (segments.size() == 1) {
return !TextUtils.isEmpty(uri.getQueryParameter("startapp"));
}
}
break;
}
case "tg": {
if (url.startsWith("tg:resolve") || url.startsWith("tg://resolve")) {
return !TextUtils.isEmpty(uri.getQueryParameter("appname"));
}
break;
}
}
} catch (Exception e) {
FileLog.e(e);
}
return false;
}

}
Loading

0 comments on commit 118b11b

Please sign in to comment.