Skip to content

Commit

Permalink
Update to 7.5.0 (2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Feb 23, 2021
1 parent 3480f19 commit 92cfded
Show file tree
Hide file tree
Showing 287 changed files with 21,876 additions and 2,227 deletions.
10 changes: 5 additions & 5 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ dependencies {
compileOnly 'org.checkerframework:checker-qual:2.5.2'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
implementation 'com.google.firebase:firebase-config:20.0.2'
implementation 'com.google.firebase:firebase-datatransport:17.0.10'
implementation 'com.google.firebase:firebase-appindexing:19.1.0'
implementation 'com.google.firebase:firebase-config:20.0.3'
implementation 'com.google.firebase:firebase-datatransport:17.0.11'
implementation 'com.google.firebase:firebase-appindexing:19.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.android.gms:play-services-vision:16.2.0'
Expand Down Expand Up @@ -290,7 +290,7 @@ android {
}
}

defaultConfig.versionCode = 2227
defaultConfig.versionCode = 2243

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand All @@ -309,7 +309,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionName "7.4.2"
versionName "7.5.0"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

Expand Down
3 changes: 3 additions & 0 deletions TMessagesProj/jni/voip/tgcalls/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ void NetworkManager::start() {
if (!_enableP2P) {
flags |= cricket::PORTALLOCATOR_DISABLE_UDP;
flags |= cricket::PORTALLOCATOR_DISABLE_STUN;
uint32_t candidateFilter = _portAllocator->candidate_filter();
candidateFilter &= ~(cricket::CF_REFLEXIVE);
_portAllocator->SetCandidateFilter(candidateFilter);
}

if (_proxy) {
Expand Down
59 changes: 40 additions & 19 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,24 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- <activity-->
<!-- android:name="org.telegram.ui.ShortcutWidgetConfigActivity"-->
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"-->
<!-- android:hardwareAccelerated="@bool/useHardwareAcceleration"-->
<!-- android:windowSoftInputMode="adjustPan">-->
<!-- <intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">-->
<!-- <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>-->
<!-- </intent-filter>-->
<!-- </activity>-->
<activity
android:name="org.telegram.ui.ChatsWidgetConfigActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:windowSoftInputMode="adjustPan">
<intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<activity
android:name="org.telegram.ui.ContactsWidgetConfigActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:windowSoftInputMode="adjustPan">
<intent-filter android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round">
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter>
</activity>
<!-- <activity-->
<!-- android:name="org.telegram.ui.FeedWidgetConfigActivity"-->
<!-- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"-->
Expand Down Expand Up @@ -415,17 +424,29 @@
android:name=".voip.CallNotificationSoundProvider"
android:exported="true"/>

<!-- <receiver android:name=".ShortcutWidgetProvider">-->
<!-- <meta-data android:name="android.appwidget.provider"-->
<!-- android:resource="@xml/shortcut_widget_info" />-->
<!-- <intent-filter>-->
<!-- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<receiver android:name=".ChatsWidgetProvider">
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/chats_widget_info" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
</receiver>

<!-- <service android:name=".ShortcutWidgetService"-->
<!-- android:permission="android.permission.BIND_REMOTEVIEWS"-->
<!-- android:exported="false" />-->
<service android:name=".ChatsWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false" />

<receiver android:name=".ContactsWidgetProvider">
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/contacts_widget_info" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
</receiver>

<service android:name=".ContactsWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:exported="false" />

<!-- <receiver android:name=".FeedWidgetProvider">-->
<!-- <meta-data android:name="android.appwidget.provider"-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public final class QRCodeWriter {
private int imageBlockX;
private int sideQuadSize;

private int imageSize;

public Bitmap encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints, Bitmap bitmap, Context context) throws WriterException {

if (contents.isEmpty()) {
Expand Down Expand Up @@ -118,7 +120,7 @@ public Bitmap encode(String contents, BarcodeFormat format, int width, int heigh
imageBloks++;
}
imageBlockX = (inputWidth - imageBloks) / 2;
int imageSize = imageBloks * multiple - 24;
imageSize = imageBloks * multiple - 24;
int imageX = (size - imageSize) / 2;

for (int a = 0; a < 3; a++) {
Expand Down Expand Up @@ -235,4 +237,8 @@ private boolean has(int x, int y) {
}
return x >= 0 && y >= 0 && x < input.getWidth() && y < input.getHeight() && input.get(x, y) == 1;
}

public int getImageSize() {
return imageSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.IDN;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -2986,6 +2987,9 @@ public static boolean handleProxyIntent(Activity activity, Intent intent) {
if (path != null) {
if (path.startsWith("/socks") || path.startsWith("/proxy")) {
address = data.getQueryParameter("server");
if (AndroidUtilities.checkHostForPunycode(address)) {
address = IDN.toASCII(address, IDN.ALLOW_UNASSIGNED);
}
port = data.getQueryParameter("port");
user = data.getQueryParameter("user");
password = data.getQueryParameter("pass");
Expand All @@ -2999,6 +3003,9 @@ public static boolean handleProxyIntent(Activity activity, Intent intent) {
url = url.replace("tg:proxy", "tg://telegram.org").replace("tg://proxy", "tg://telegram.org").replace("tg://socks", "tg://telegram.org").replace("tg:socks", "tg://telegram.org");
data = Uri.parse(url);
address = data.getQueryParameter("server");
if (AndroidUtilities.checkHostForPunycode(address)) {
address = IDN.toASCII(address, IDN.ALLOW_UNASSIGNED);
}
port = data.getQueryParameter("port");
user = data.getQueryParameter("user");
password = data.getQueryParameter("pass");
Expand Down Expand Up @@ -3558,13 +3565,10 @@ public static void setLightNavigationBar(Window window, boolean enable) {
}
}

public static boolean shouldShowUrlInAlert(String url) {
public static boolean checkHostForPunycode(String url) {
boolean hasLatin = false;
boolean hasNonLatin = false;
try {
Uri uri = Uri.parse(url);
url = uri.getHost();

for (int a = 0, N = url.length(); a < N; a++) {
char ch = url.charAt(a);
if (ch == '.' || ch == '-' || ch == '/' || ch == '+' || ch >= '0' && ch <= '9') {
Expand All @@ -3579,13 +3583,23 @@ public static boolean shouldShowUrlInAlert(String url) {
break;
}
}

} catch (Exception e) {
FileLog.e(e);
}
return hasLatin && hasNonLatin;
}

public static boolean shouldShowUrlInAlert(String url) {
try {
Uri uri = Uri.parse(url);
url = uri.getHost();
return checkHostForPunycode(url);
} catch (Exception e) {
FileLog.e(e);
}
return false;
}

public static void scrollToFragmentRow(ActionBarLayout parentLayout, String rowName) {
if (parentLayout == null || rowName == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static int BUILD_VERSION = 2227;
public static String BUILD_VERSION_STRING = "7.4.0";
public static int BUILD_VERSION = 2243;
public static String BUILD_VERSION_STRING = "7.5.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ public static boolean isCanWriteToChannel(int chatId, int currentAccount) {
}

public static boolean canWriteToChat(TLRPC.Chat chat) {
return !isChannel(chat) || chat.creator || chat.admin_rights != null && chat.admin_rights.post_messages || !chat.broadcast;
return !isChannel(chat) || chat.creator || chat.admin_rights != null && chat.admin_rights.post_messages || !chat.broadcast && !chat.gigagroup || chat.gigagroup && ChatObject.hasAdminRights(chat);
}

public static String getBannedRightsString(TLRPC.TL_chatBannedRights bannedRights) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package org.telegram.messenger;

import android.app.Activity;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.widget.RemoteViews;

import org.telegram.ui.EditWidgetActivity;
import org.telegram.ui.LaunchActivity;

import java.util.ArrayList;

public class ChatsWidgetProvider extends AppWidgetProvider {

@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
}

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
for (int i = 0; i < appWidgetIds.length; i++) {
int appWidgetId = appWidgetIds[i];
updateWidget(context, appWidgetManager, appWidgetId, false);
}
}

@Override
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
updateWidget(context, appWidgetManager, appWidgetId, true);
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
}

@Override
public void onDeleted(Context context, int[] appWidgetIds) {
super.onDeleted(context, appWidgetIds);
SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
for (int a = 0; a < appWidgetIds.length; a++) {
int accountId = preferences.getInt("account" + appWidgetIds[a], -1);
if (accountId >= 0) {
AccountInstance accountInstance = AccountInstance.getInstance(accountId);
accountInstance.getMessagesStorage().clearWidgetDialogs(appWidgetIds[a]);
}
editor.remove("account" + appWidgetIds[a]);
editor.remove("type" + appWidgetIds[a]);
editor.remove("deleted" + appWidgetIds[a]);
}
editor.commit();
}

private static int getCellsForSize(int size) {
int n = 2;
while (70 * n - 30 < size) {
++n;
}
return n - 1;
}

public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean edit) {
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
int rows = getCellsForSize(minHeight);

Intent intent2 = new Intent(context, ChatsWidgetService.class);
intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent2.setData(Uri.parse(intent2.toUri(Intent.URI_INTENT_SCHEME)));

SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
boolean deleted = preferences.getBoolean("deleted" + appWidgetId, false);
int id;
if (!deleted) {
int accountId = preferences.getInt("account" + appWidgetId, -1);
ArrayList<Long> selectedDialogs = new ArrayList<>();
if (accountId >= 0) {
AccountInstance.getInstance(accountId).getMessagesStorage().getWidgetDialogIds(appWidgetId, EditWidgetActivity.TYPE_CHATS, selectedDialogs, null, null, false);
}

if (rows == 1 || selectedDialogs.size() <= 1) {
id = R.layout.shortcut_widget_layout_1;
} else if (rows == 2 || selectedDialogs.size() <= 2) {
id = R.layout.shortcut_widget_layout_2;
} else if (rows == 3 || selectedDialogs.size() <= 3) {
id = R.layout.shortcut_widget_layout_3;
} else {
id = R.layout.shortcut_widget_layout_4;
}
} else {
id = R.layout.shortcut_widget_layout_1;
}
RemoteViews rv = new RemoteViews(context.getPackageName(), id);
rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent2);
rv.setEmptyView(R.id.list_view, R.id.empty_view);

Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

rv.setPendingIntentTemplate(R.id.list_view, contentIntent);
appWidgetManager.updateAppWidget(appWidgetId, rv);
if (edit) {
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_view);
}
}
}
Loading

0 comments on commit 92cfded

Please sign in to comment.