Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Jul 12, 2024
2 parents 30b41f7 + 5fa5549 commit 0532e97
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 127 deletions.
8 changes: 4 additions & 4 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ repositories {
}
}

def verName = "10.14.3"
def verCode = 1185
def verName = "10.14.5"
def verCode = 1186


def officialVer = "10.14.3"
def officialCode = 4927
def officialVer = "10.14.5"
def officialCode = 4945

def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")

Expand Down
13 changes: 0 additions & 13 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,6 @@
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="ton"/>
</intent>

<package android:name="com.android.chrome" />
<package android:name="org.mozilla.firefox" />
<package android:name="com.microsoft.emmx" />
<package android:name="com.opera.browser" />
<package android:name="com.opera.mini.native" />
<package android:name="com.brave.browser" />
<package android:name="com.duckduckgo.mobile.android" />
<package android:name="com.sec.android.app.sbrowser" />
<package android:name="com.vivaldi.browser" />
<package android:name="com.kiwibrowser.browser" />
<package android:name="com.UCMobile.intl" />
<package android:name="org.torproject.torbrowser" />
</queries>

<application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
Expand All @@ -36,18 +35,13 @@
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
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;
import android.os.Bundle;
Expand Down Expand Up @@ -79,7 +73,6 @@
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
import android.util.StateSet;
import android.util.TypedValue;
Expand All @@ -101,7 +94,6 @@
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;
Expand All @@ -122,9 +114,7 @@
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.TypefaceCompatUtil;
import androidx.core.math.MathUtils;
import androidx.core.provider.FontRequest;
import androidx.core.widget.NestedScrollView;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
Expand Down Expand Up @@ -3850,7 +3840,7 @@ public static void openDocument(MessageObject message, Activity activity, BaseFr
}
}

public static boolean openForView(File f, String fileName, String mimeType, final Activity activity, Theme.ResourcesProvider resourcesProvider) {
public static boolean openForView(File f, String fileName, String mimeType, final Activity activity, Theme.ResourcesProvider resourcesProvider, boolean restrict) {
if (f != null && f.exists()) {
String realMimeType = null;
Intent intent = new Intent(Intent.ACTION_VIEW);
Expand All @@ -3859,6 +3849,10 @@ public static boolean openForView(File f, String fileName, String mimeType, fina
int idx = fileName.lastIndexOf('.');
if (idx != -1) {
String ext = fileName.substring(idx + 1);
int h = ext.toLowerCase().hashCode();
if (restrict && (h == 0x17a1c || h == 0x3107ab || h == 0x19a1b || h == 0xe55 || h == 0x18417)) {
return true;
}
realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase());
if (realMimeType == null) {
realMimeType = mimeType;
Expand All @@ -3867,9 +3861,12 @@ public static boolean openForView(File f, String fileName, String mimeType, fina
}
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && realMimeType != null && realMimeType.equals("application/vnd.android.package-archive") && !ApplicationLoader.applicationContext.getPackageManager().canRequestPackageInstalls()) {
AlertsCreator.createApkRestrictedDialog(activity, resourcesProvider).show();
return true;
if (realMimeType != null && realMimeType.equals("application/vnd.android.package-archive")) {
if (restrict) return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !ApplicationLoader.applicationContext.getPackageManager().canRequestPackageInstalls()) {
AlertsCreator.createApkRestrictedDialog(activity, resourcesProvider).show();
return true;
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.setDataAndType(FileProvider.getUriForFile(activity, ApplicationLoader.getApplicationId() + ".provider", f), realMimeType != null ? realMimeType : "text/plain");
Expand All @@ -3896,10 +3893,10 @@ public static boolean openForView(File f, String fileName, String mimeType, fina
}

public static boolean openForView(MessageObject message, Activity activity) {
return openForView(message, activity, null);
return openForView(message, activity, null, false);
}

public static boolean openForView(MessageObject message, Activity activity, Theme.ResourcesProvider resourcesProvider) {
public static boolean openForView(MessageObject message, Activity activity, Theme.ResourcesProvider resourcesProvider, boolean restrict) {
File f = null;
if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
f = new File(message.messageOwner.attachPath);
Expand All @@ -3908,13 +3905,13 @@ public static boolean openForView(MessageObject message, Activity activity, Them
f = FileLoader.getInstance(message.currentAccount).getPathToMessage(message.messageOwner);
}
String mimeType = message.type == MessageObject.TYPE_FILE || message.type == MessageObject.TYPE_TEXT ? message.getMimeType() : null;
return openForView(f, message.getFileName(), mimeType, activity, resourcesProvider);
return openForView(f, message.getFileName(), mimeType, activity, resourcesProvider, restrict);
}

public static boolean openForView(TLRPC.Document document, boolean forceCache, Activity activity) {
String fileName = FileLoader.getAttachFileName(document);
File f = FileLoader.getInstance(UserConfig.selectedAccount).getPathToAttach(document, true);
return openForView(f, fileName, document.mime_type, activity, null);
return openForView(f, fileName, document.mime_type, activity, null, false);
}

public static SpannableStringBuilder formatSpannableSimple(CharSequence format, CharSequence... cs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,8 +1573,10 @@ public static String formatPluralStringComma(String key, int plural, char symbol
value = BuildVars.USE_CLOUD_STRINGS ? getInstance().localeValues.get(key + "_other") : null;
}
if (value == null) {
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName());
value = ApplicationLoader.applicationContext.getString(resourceId);
try {
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName());
value = ApplicationLoader.applicationContext.getString(resourceId);
} catch (Exception e2) {}
}
if (value == null) {
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(key + "_other", "string", ApplicationLoader.applicationContext.getPackageName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8463,6 +8463,7 @@ public static boolean isVideoDocument(TLRPC.Document document) {
}
boolean isAnimated = false;
boolean isVideo = false;
String filename = null;
int width = 0;
int height = 0;
for (int a = 0; a < document.attributes.size(); a++) {
Expand All @@ -8476,6 +8477,20 @@ public static boolean isVideoDocument(TLRPC.Document document) {
height = attribute.h;
} else if (attribute instanceof TLRPC.TL_documentAttributeAnimated) {
isAnimated = true;
} else if (attribute instanceof TLRPC.TL_documentAttributeFilename) {
filename = attribute.file_name;
}
}
if (filename != null) {
int index = filename.lastIndexOf(".");
if (index >= 0) {
String ext = filename.substring(index + 1);
switch (ext.toLowerCase().hashCode()) {
case 0x17a1c: case 0x3107ab: case 0x19a1b:
case 0xe55: case 0x18417: case 0x184fe:
case 0x18181:
return false;
}
}
}
if (isAnimated && (width > 1280 || height > 1280)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20250,13 +20250,13 @@ public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment, MessageObj
@Override
public void onMessagesLoaded(boolean fromCache) {
progress.end();
fragment.presentFragment(new ChatActivity(bundle), true);
fragment.presentFragment(new ChatActivity(bundle));
}

@Override
public void onError() {
progress.end();
fragment.presentFragment(new ChatActivity(bundle), true);
fragment.presentFragment(new ChatActivity(bundle));
}
}));
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;

Expand Down Expand Up @@ -264,11 +265,9 @@ public static void openUrl(final Context context, Uri uri, boolean _allowCustom,
boolean[] forceBrowser = new boolean[]{false};
boolean internalUri = isInternalUri(uri, forceBrowser);
String browserPackage = getBrowserPackageName(browser);
if (isBrowserPackageInstalled(context, browserPackage, uri)) {
if (browserPackage != null) {
tryTelegraph = false;
_allowCustom = false;
} else {
browserPackage = null;
}
final boolean allowCustom = _allowCustom;
if (tryTelegraph) {
Expand Down Expand Up @@ -456,7 +455,16 @@ public static void openUrl(final Context context, Uri uri, boolean _allowCustom,
intent.putExtra(LaunchActivity.EXTRA_FORCE_NOT_INTERNAL_APPS, forceNotInternalForApps);
((LaunchActivity) context).onNewIntent(intent, inCaseLoading);
} else {
context.startActivity(intent);
try {
context.startActivity(intent);
} catch (Exception e2) {
if (browserPackage != null) {
intent.setPackage(browserPackage = null);
context.startActivity(intent);
} else {
FileLog.e(e2);
}
}
}
} catch (Exception e) {
FileLog.e(e);
Expand Down Expand Up @@ -620,14 +628,6 @@ public static String getBrowserPackageName(String browser) {
return null;
}

public static boolean isBrowserPackageInstalled(Context context, String packageName, Uri uri) {
if (packageName == null) return false;
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage(packageName);
return packageManager.resolveActivity(intent, 0) != null;
}

public static String replaceHostname(Uri originalUri, String newHostname) {
String scheme = originalUri.getScheme();
String userInfo = originalUri.getUserInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private void openItem(CacheModel.FileInfo fileInfo, CacheCell cacheCell) {
photoEntries.add(new MediaController.PhotoEntry(0, 0, 0, fileInfo.file.getPath(), 0, fileInfo.type == TYPE_VIDEOS, 0, 0, 0));
PhotoViewer.getInstance().openPhotoForSelect(photoEntries, 0, PhotoViewer.SELECT_TYPE_NO_SELECT, false, placeProvider, null);
} else {
AndroidUtilities.openForView(fileInfo.file, fileInfo.file.getName(), null, parentFragment.getParentActivity(), null);
AndroidUtilities.openForView(fileInfo.file, fileInfo.file.getName(), null, parentFragment.getParentActivity(), null, false);
}
}
if (cacheCell.type == TYPE_MUSIC) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19646,7 +19646,7 @@ private void drawCaptionLayout(Canvas canvas, MessageObject.TextLayoutBlocks cap
buttonX -= AndroidUtilities.dp(10);
}
commentButtonRect.set(
buttonX - AndroidUtilities.dp((currentMessageObject == null || !currentMessageObject.isOut()) && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL || pollInstantViewTouchesBottom) ? 6 : 0),
buttonX - AndroidUtilities.dp((currentMessageObject == null || !currentMessageObject.isOutOwner()) && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL || pollInstantViewTouchesBottom) ? 6 : 0),
(int) buttonY,
endX - AndroidUtilities.dp(14),
layoutHeight - AndroidUtilities.dp(h) + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ public void didPressImage(ChatMessageCell cell, float x, float y) {
}
}
try {
AndroidUtilities.openForView(message, getParentActivity(), null);
AndroidUtilities.openForView(message, getParentActivity(), null, false);
} catch (Exception e) {
alertUserOpenError(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public boolean dispatchTouchEvent(MotionEvent event) {
return super.dispatchTouchEvent(event);
}
};
starsBalanceEditTextContainer.setVisibility(GONE);
starsBalanceEditTextContainer.setText(getString(R.string.BotStarsWithdrawPlaceholder));
starsBalanceEditTextContainer.setLeftPadding(dp(14 + 22));
starsBalanceEditText = new EditTextBoldCursor(context) {
Expand Down Expand Up @@ -671,13 +672,14 @@ private void setStarsBalance(long crypto_amount, int blockedUntil) {
starsBalance = crypto_amount;
starsBalanceTitle.setText(ssb);
starsBalanceSubtitle.setText("≈" + BillingController.getInstance().formatCurrency(amount, "USD"));
starsBalanceEditTextContainer.setVisibility(crypto_amount > 0 ? VISIBLE : GONE);
if (starsBalanceEditTextAll) {
starsBalanceEditTextIgnore = true;
starsBalanceEditText.setText(Long.toString(starsBalanceEditTextValue = crypto_amount));
starsBalanceEditText.setSelection(starsBalanceEditText.getText().length());
starsBalanceEditTextIgnore = false;

balanceButton.setEnabled(starsBalanceEditTextValue > 0);
starsBalanceButton.setEnabled(starsBalanceEditTextValue > 0);
}
starsBalanceBlockedUntil = blockedUntil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,10 @@ public long findMinValue(int startXIndex, int endXIndex) {
return minValue;
}

public void setData(T chartData) {
public boolean setData(T chartData) {
boolean updated = false;
if (this.chartData != chartData) {
updated = true;
invalidate();
lines.clear();
if (chartData != null && chartData.lines != null) {
Expand Down Expand Up @@ -1236,6 +1238,7 @@ public void setData(T chartData) {
alphaAnimator.cancel();
}
}
return updated;
}

protected float getMinDistance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public boolean move(int x, int y, int pointer) {
return true;
}

public void set(float start, float end) {
pickerStart = start;
pickerEnd = end;
view.onPickerDataChanged();
}

public boolean uncapture(MotionEvent event, int pointerIndex) {
if (pointerIndex == 0) {
if (tryMoveTo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,14 @@ void drawBottomSignature(Canvas canvas) {


@Override
public void setData(StackLinearChartData chartData) {
super.setData(chartData);
public boolean setData(StackLinearChartData chartData) {
boolean u = super.setData(chartData);
if (chartData != null) {
values = new float[chartData.lines.size()];
darawingValuesPercentage = new float[chartData.lines.size()];
onPickerDataChanged(false, true, false);
}
return u;
}

@Override
Expand Down
Loading

0 comments on commit 0532e97

Please sign in to comment.