Skip to content

Commit 6f78031

Browse files
committed
Added back "Chats" for Title, Translations; "Send as", Navigation Bar & other Fixes
1 parent f7655ce commit 6f78031

40 files changed

+699
-189
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55

66
Experimental **third-party** Telegram client based on [official sources](https://github.com/DrKLO/Telegram).
77

8-
[![Channel](https://img.shields.io/badge/Channel-Telegram-blue.svg)](https://t.me/exteragram)
8+
[![Channel](https://img.shields.io/badge/Channel-Telegram-blue.svg)](https://t.me/exteraGram)
99
[![Chat](https://img.shields.io/badge/Chat-Telegram-blue.svg)](https://t.me/exteraChat)
10-
[![Downloads](https://img.shields.io/badge/Download%20at%20-%20Telegram-blue.svg)](https://t.me/exterareleases)
10+
[![Downloads](https://img.shields.io/badge/Download%20at%20-%20Telegram-blue.svg)](https://t.me/exteraReleases)
1111

1212
## Importing API hash and keys
1313
- You should get **YOUR OWN API KEY AND HASH** here: https://core.telegram.org/api/obtaining_api_id and create a file called `API_KEYS` in the source root directory.
1414
- Also you should get **YOUR OWN MAPS API KEY** here: https://console.cloud.google.com/google/maps-apis/credentials and add it to this file.
1515
- And you need to generate **SIGNING KEY**: https://developer.android.com/studio/publish/app-signing#generate-key
16-
The contents should look like this:
16+
17+
The file content should look like this:
1718
```
1819
APP_ID = 123456
1920
APP_HASH = abcdef0123456789 (32 chars)
@@ -25,7 +26,7 @@ SIGNING_KEY_STORE_PASSWORD = Z9yXDEFHJ6KRqn7oP
2526
```
2627

2728
## Compilation Guide
28-
1. Clone exteraGram's source code using `git clone https://github.com/exteraSquad/exteraGram/`
29+
1. Clone exteraGram's source code using `git clone https://github.com/exteraSquad/exteraGram.git`
2930
2. Fill out values in `API_KEYS` like [here](https://github.com/exteraSquad/exteraGram#importing-api-hash-and-keys)
3031
3. Open the project in Android Studio. It should be opened, **not imported**
3132
4. You are ready to compile `exteraGram`
@@ -36,10 +37,9 @@ SIGNING_KEY_STORE_PASSWORD = Z9yXDEFHJ6KRqn7oP
3637
```
3738

3839
## exteraGram Localization
39-
Since **exteraGram** is a fork of **Telegram for Android** and most localizations follow translations of **Telegram for Android**, check it out [here](https://translations.telegram.org/en/android/). As for specialized strings for **exteraGram**, we use **Crowdin** to translate **exteraGram**. Join the project at [Crowdin](https://crowdin.com/project/exteralocales)!
40+
Since **exteraGram** is a fork of **Telegram for Android** and most of the localizations follow the translations of **Telegram for Android**, check it out [here](https://translations.telegram.org/en/android/). As for specialized strings for **exteraGram**, we use **Crowdin** to translate **exteraGram**. Join the project on [Crowdin](https://crowdin.com/project/exteralocales)!
4041

4142
## Thanks to:
42-
- [Telegram](https://github.com/DrKLO/Telegram)
43-
- [Catogram](https://github.com/Catogram/Catogram) and [Catogram X](https://github.com/CatogramX/CatogramX)
44-
- [Nekogram](https://gitlab.com/Nekogram/Nekogram) and [Nekogram X](https://github.com/NekoX-Dev/NekoX)
43+
- [Catogram](https://github.com/Catogram/Catogram)
44+
- [Nekogram](https://gitlab.com/Nekogram/Nekogram)
4545
- [OwlGram](https://github.com/OwlGramDev/OwlGram)

TMessagesProj/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ dependencies {
5757

5858
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
5959

60-
// GPT
61-
implementation 'com.theokanning.openai-gpt3-java:service:0.12.0'
62-
6360
implementation files('libs/libgsaverification-client.aar')
6461
}
6562

TMessagesProj/src/main/java/com/exteragram/messenger/components/MessageDetailsPopupWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ public MessageDetailsPopupWrapper(BaseFragment fragment, PopupSwipeBackLayout sw
108108
}
109109
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
110110
stickerSetId = attribute.stickerset.id;
111-
items.add(new Item(SET_OWNER, R.drawable.msg_sticker, LocaleController.getString(R.string.ChannelCreator), LocaleController.getString("Loading", R.string.Loading)));
111+
if (stickerSetId > 0) {
112+
items.add(new Item(SET_OWNER, R.drawable.msg_sticker, LocaleController.getString(R.string.ChannelCreator), LocaleController.getString("Loading", R.string.Loading)));
113+
}
112114
}
113115
}
114116
}

TMessagesProj/src/main/java/com/exteragram/messenger/preferences/AppearancePreferencesActivity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
6464
}, titles = new CharSequence[]{
6565
LocaleController.getString("exteraAppName", R.string.exteraAppName),
6666
LocaleController.getString("ActionBarTitleUsername", R.string.ActionBarTitleUsername),
67-
LocaleController.getString("ActionBarTitleName", R.string.ActionBarTitleName)
67+
LocaleController.getString("ActionBarTitleName", R.string.ActionBarTitleName),
68+
LocaleController.getString("FilterChats", R.string.FilterChats)
6869
}, tabIcons = new CharSequence[]{
6970
LocaleController.getString("TabTitleStyleTextWithIcons", R.string.TabTitleStyleTextWithIcons),
7071
LocaleController.getString("TabTitleStyleTextOnly", R.string.TabTitleStyleTextOnly),
@@ -222,12 +223,13 @@ protected void onItemClick(View view, int position, float x, float y) {
222223
ExteraConfig.editor.putBoolean("centerTitle", ExteraConfig.centerTitle ^= true).apply();
223224
chatListPreviewCell.updateCenteredTitle(true);
224225
((TextCheckCell) view).setChecked(ExteraConfig.centerTitle);
225-
parentLayout.rebuildAllFragmentViews(false, false);
226+
showBulletin();
226227
} else if (position == hideAllChatsRow) {
227228
ExteraConfig.editor.putBoolean("hideAllChats", ExteraConfig.hideAllChats ^= true).apply();
228229
foldersPreviewCell.updateAllChatsTabName(true);
229230
((TextCheckCell) view).setChecked(ExteraConfig.hideAllChats);
230-
parentLayout.rebuildAllFragmentViews(false, false);
231+
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
232+
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
231233
} else if (position == tabCounterRow) {
232234
ExteraConfig.editor.putBoolean("tabCounter", ExteraConfig.tabCounter ^= true).apply();
233235
foldersPreviewCell.updateTabCounter(true);
@@ -306,8 +308,8 @@ protected void onItemClick(View view, int position, float x, float y) {
306308
PopupUtils.showDialog(titles, LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), ExteraConfig.titleText, getContext(), i -> {
307309
ExteraConfig.editor.putInt("titleText", ExteraConfig.titleText = i).apply();
308310
chatListPreviewCell.updateTitle(true);
309-
parentLayout.rebuildAllFragmentViews(false, false);
310311
listAdapter.notifyItemChanged(actionBarTitleRow, payload);
312+
getNotificationCenter().postNotificationName(NotificationCenter.currentUserPremiumStatusChanged);
311313
});
312314
} else if (position == tabTitleRow) {
313315
if (getParentActivity() == null) {

TMessagesProj/src/main/java/com/exteragram/messenger/preferences/MainPreferencesActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected void updateRowsId() {
212212
protected void onItemClick(View view, int position, float x, float y) {
213213
if (position == aboutExteraRow) {
214214
if (!BuildVars.PM_BUILD)
215-
(new UpdaterBottomSheet(getParentActivity(), this, false)).show();
215+
(new UpdaterBottomSheet(getParentActivity(), this, false, null)).show();
216216
} else if (position == sourceCodeRow) {
217217
Browser.openUrl(getParentActivity(), "https://github.com/exteraSquad/exteraGram");
218218
} else if (position == channelRow) {

TMessagesProj/src/main/java/com/exteragram/messenger/preferences/updater/UpdaterBottomSheet.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import android.widget.TextView;
2525

2626
import com.exteragram.messenger.ExteraConfig;
27-
import com.exteragram.messenger.utils.AppUtils;
27+
import com.exteragram.messenger.utils.LocaleUtils;
2828
import com.exteragram.messenger.utils.UpdaterUtils;
2929

3030
import org.telegram.messenger.AndroidUtilities;
@@ -47,8 +47,7 @@ public class UpdaterBottomSheet extends BottomSheet {
4747

4848
private RLottieImageView imageView;
4949

50-
public UpdaterBottomSheet(Context context, BaseFragment fragment, boolean available, String... args) {
51-
// args = {version, changelog, size, downloadUrl, uploadDate}
50+
public UpdaterBottomSheet(Context context, BaseFragment fragment, boolean available, UpdaterUtils.Update update) {
5251
super(context, false);
5352
setOpenNoDelay(true);
5453
fixNavigationBar();
@@ -77,7 +76,7 @@ public UpdaterBottomSheet(Context context, BaseFragment fragment, boolean availa
7776
nameView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
7877
nameView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
7978
nameView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
80-
nameView.setText(available ? LocaleController.getString("UpdateAvailable", R.string.UpdateAvailable) : AppUtils.getAppName());
79+
nameView.setText(available ? LocaleController.getString("UpdateAvailable", R.string.UpdateAvailable) : LocaleUtils.getAppName());
8180
header.addView(nameView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, Gravity.LEFT, available ? 75 : 0, 5, 0, 0));
8281

8382
AnimatedTextView timeView = new AnimatedTextView(context, true, true, false);
@@ -88,13 +87,13 @@ public UpdaterBottomSheet(Context context, BaseFragment fragment, boolean availa
8887
timeView.setTextSize(AndroidUtilities.dp(13));
8988
timeView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_REGULAR));
9089
timeView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
91-
timeView.setText(available ? args[4] : LocaleController.getString("LastCheck", R.string.LastCheck) + ": " + LocaleController.formatDateTime(ExteraConfig.lastUpdateCheckTime / 1000));
90+
timeView.setText(available ? update.uploadDate : LocaleController.getString("LastCheck", R.string.LastCheck) + ": " + LocaleController.formatDateTime(ExteraConfig.lastUpdateCheckTime / 1000));
9291
header.addView(timeView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, Gravity.LEFT, available ? 75 : 0, 35, 0, 0));
9392

9493
TextCell version = new TextCell(context);
9594
version.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 100, 0));
9695
if (available) {
97-
version.setTextAndValueAndIcon(LocaleController.getString("Version", R.string.Version), args[0].replaceAll("v|-beta", ""), R.drawable.msg_info, true);
96+
version.setTextAndValueAndIcon(LocaleController.getString("Version", R.string.Version), update.version.replaceAll("v|-beta|-force", ""), R.drawable.msg_info, true);
9897
} else {
9998
version.setTextAndValueAndIcon(LocaleController.getString("CurrentVersion", R.string.CurrentVersion), BuildVars.BUILD_VERSION_STRING, R.drawable.msg_info, true);
10099
}
@@ -113,7 +112,7 @@ protected void onDraw(Canvas canvas) {
113112
if (available) {
114113
TextCell size = new TextCell(context);
115114
size.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 100, 0));
116-
size.setTextAndValueAndIcon(LocaleController.getString("UpdateSize", R.string.UpdateSize), args[2], R.drawable.msg_sendfile, true);
115+
size.setTextAndValueAndIcon(LocaleController.getString("UpdateSize", R.string.UpdateSize), update.size, R.drawable.msg_sendfile, true);
117116
size.setOnClickListener(v -> copyText(size.getTextView().getText() + ": " + size.getValueTextView().getText()));
118117
linearLayout.addView(size);
119118

@@ -125,7 +124,7 @@ protected void onDraw(Canvas canvas) {
125124

126125
TextInfoPrivacyCell changelogTextView = new TextInfoPrivacyCell(context);
127126
changelogTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
128-
changelogTextView.setText(UpdaterUtils.replaceTags(args[1]));
127+
changelogTextView.setText(UpdaterUtils.replaceTags(update.changelog));
129128
linearLayout.addView(changelogTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
130129

131130
linearLayout.addView(divider, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(1)));
@@ -141,7 +140,7 @@ protected void onDraw(Canvas canvas) {
141140
doneButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
142141
doneButton.setText(LocaleController.getString("AppUpdateDownloadNow", R.string.AppUpdateDownloadNow));
143142
doneButton.setOnClickListener(v -> {
144-
UpdaterUtils.downloadApk(fragment.getContext(), args[3], "exteraGram " + args[0]);
143+
UpdaterUtils.downloadApk(fragment.getContext(), update.downloadURL, "exteraGram " + update.version);
145144
dismiss();
146145
});
147146
linearLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, 0, 16, 15, 16, 5));

TMessagesProj/src/main/java/com/exteragram/messenger/preferences/updater/UpdaterBottomSheet2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import androidx.recyclerview.widget.RecyclerView;
2323

2424
import com.exteragram.messenger.ExteraConfig;
25-
import com.exteragram.messenger.utils.AppUtils;
25+
import com.exteragram.messenger.utils.LocaleUtils;
2626
import com.exteragram.messenger.utils.TranslatorUtils;
2727
import com.exteragram.messenger.utils.UpdaterUtils;
2828

@@ -411,7 +411,7 @@ private UpdaterHeaderCell(Context context) {
411411
nameView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
412412
nameView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
413413
nameView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
414-
nameView.setText(available ? LocaleController.getString("UpdateAvailable", R.string.UpdateAvailable) : AppUtils.getAppName());
414+
nameView.setText(available ? LocaleController.getString("UpdateAvailable", R.string.UpdateAvailable) : LocaleUtils.getAppName());
415415
frame.addView(nameView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, Gravity.LEFT, available ? 75 : 0, 5, 0, 0));
416416

417417
timeView = new AnimatedTextView(context, true, true, false);

TMessagesProj/src/main/java/com/exteragram/messenger/utils/AppUtils.java

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@
1111

1212
package com.exteragram.messenger.utils;
1313

14+
import android.annotation.SuppressLint;
15+
import android.content.pm.PackageInfo;
16+
import android.content.pm.PackageManager;
17+
import android.content.pm.Signature;
18+
import android.util.Base64;
19+
1420
import org.telegram.messenger.ApplicationLoader;
1521
import org.telegram.messenger.BuildVars;
22+
import org.telegram.messenger.FileLog;
1623
import org.telegram.messenger.R;
1724

25+
import java.security.MessageDigest;
1826
import java.util.Calendar;
1927

2028
public class AppUtils {
@@ -23,14 +31,6 @@ public static int getNotificationIconColor() {
2331
return BuildVars.isBetaApp() ? 0xff747f9f : 0xfff54142;
2432
}
2533

26-
public static String getAppName() {
27-
try {
28-
return ApplicationLoader.applicationContext.getString(R.string.exteraAppName);
29-
} catch (Exception e) {
30-
return "exteraGram";
31-
}
32-
}
33-
3434
public static int[] getDrawerIconPack() {
3535
switch (org.telegram.ui.ActionBar.Theme.getEventType()) {
3636
case 0:
@@ -81,4 +81,31 @@ public static boolean isWinter() {
8181
int currentMonth = calendar.get(Calendar.MONTH);
8282
return currentMonth == Calendar.DECEMBER || currentMonth == Calendar.JANUARY || currentMonth == Calendar.FEBRUARY;
8383
}
84+
85+
// do not change or remove this part of the code if you're making public fork
86+
private static final String EXPECTED_SIGNATURE = "tcaLgrODWBN9GQvrHPfGzA==";
87+
private static final String EXPECTED_PACKAGE_NAME = "com.exteragram.messenger";
88+
89+
public static boolean isAppModified() {
90+
try {
91+
@SuppressLint("PackageManagerGetSignatures")
92+
PackageInfo packageInfo = ApplicationLoader.applicationContext.getPackageManager()
93+
.getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), PackageManager.GET_SIGNATURES);
94+
95+
String currentPackageName = packageInfo.packageName;
96+
97+
Signature signature = packageInfo.signatures[0];
98+
99+
MessageDigest md = MessageDigest.getInstance("MD5");
100+
byte[] signatureBytes = signature.toByteArray();
101+
byte[] md5Bytes = md.digest(signatureBytes);
102+
String currentSignature = Base64.encodeToString(md5Bytes, Base64.DEFAULT).trim();
103+
104+
return !EXPECTED_PACKAGE_NAME.equals(currentPackageName)
105+
|| !EXPECTED_SIGNATURE.equals(currentSignature);
106+
} catch (Exception e) {
107+
FileLog.e(e);
108+
}
109+
return true;
110+
}
84111
}

TMessagesProj/src/main/java/com/exteragram/messenger/utils/FontUtils.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @Nekogram
2+
13
package com.exteragram.messenger.utils;
24

35
import android.graphics.Bitmap;
@@ -9,6 +11,9 @@
911
import org.telegram.messenger.FileLog;
1012
import org.telegram.messenger.LocaleController;
1113

14+
import java.io.BufferedReader;
15+
import java.io.File;
16+
import java.io.FileReader;
1217
import java.util.List;
1318

1419
public class FontUtils {
@@ -25,6 +30,9 @@ public class FontUtils {
2530
private static Boolean mediumWeightSupported = null;
2631
private static Boolean italicSupported = null;
2732

33+
public static boolean loadSystemEmojiFailed = false;
34+
private static Typeface systemEmojiTypeface;
35+
2836
static {
2937
if (List.of("zh", "ja", "ko").contains(LocaleController.getInstance().getCurrentLocale().getLanguage())) {
3038
TEST_TEXT = "日";
@@ -66,5 +74,55 @@ private static boolean testTypeface(Typeface typeface) {
6674
AndroidUtilities.recycleBitmaps(List.of(bitmap1, bitmap2));
6775
return supported;
6876
}
77+
78+
public static File getSystemEmojiFontPath() {
79+
try (var br = new BufferedReader(new FileReader("/system/etc/fonts.xml"))) {
80+
String line;
81+
var ignored = false;
82+
while ((line = br.readLine()) != null) {
83+
var trimmed = line.trim();
84+
if (trimmed.startsWith("<family") && trimmed.contains("ignore=\"true\"")) {
85+
ignored = true;
86+
} else if (trimmed.startsWith("</family>")) {
87+
ignored = false;
88+
} else if (trimmed.startsWith("<font") && !ignored) {
89+
var start = trimmed.indexOf(">");
90+
var end = trimmed.indexOf("<", 1);
91+
if (start > 0 && end > 0) {
92+
var font = trimmed.substring(start + 1, end);
93+
if (font.toLowerCase().contains("emoji")) {
94+
File file = new File("/system/fonts/" + font);
95+
if (file.exists()) {
96+
FileLog.d("emoji font file fonts.xml = " + font);
97+
return file;
98+
}
99+
}
100+
}
101+
}
102+
}
103+
br.close();
104+
105+
var fileAOSP = new File("/system/fonts/NotoColorEmoji.ttf");
106+
if (fileAOSP.exists()) {
107+
return fileAOSP;
108+
}
109+
} catch (Exception e) {
110+
FileLog.e(e);
111+
}
112+
return null;
113+
}
114+
115+
public static Typeface getSystemEmojiTypeface() {
116+
if (!loadSystemEmojiFailed && systemEmojiTypeface == null) {
117+
var font = getSystemEmojiFontPath();
118+
if (font != null) {
119+
systemEmojiTypeface = Typeface.createFromFile(font);
120+
}
121+
if (systemEmojiTypeface == null) {
122+
loadSystemEmojiFailed = true;
123+
}
124+
}
125+
return systemEmojiTypeface;
126+
}
69127
}
70128

0 commit comments

Comments
 (0)