Skip to content

Commit

Permalink
Added back "Chats" for Title, Translations; "Send as", Navigation Bar…
Browse files Browse the repository at this point in the history
… & other Fixes
  • Loading branch information
immat0x1 committed Jun 2, 2023
1 parent f7655ce commit 6f78031
Show file tree
Hide file tree
Showing 40 changed files with 699 additions and 189 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

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

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

## Importing API hash and keys
- 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.
- 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.
- And you need to generate **SIGNING KEY**: https://developer.android.com/studio/publish/app-signing#generate-key
The contents should look like this:

The file content should look like this:
```
APP_ID = 123456
APP_HASH = abcdef0123456789 (32 chars)
Expand All @@ -25,7 +26,7 @@ SIGNING_KEY_STORE_PASSWORD = Z9yXDEFHJ6KRqn7oP
```

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

## exteraGram Localization
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)!
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)!

## Thanks to:
- [Telegram](https://github.com/DrKLO/Telegram)
- [Catogram](https://github.com/Catogram/Catogram) and [Catogram X](https://github.com/CatogramX/CatogramX)
- [Nekogram](https://gitlab.com/Nekogram/Nekogram) and [Nekogram X](https://github.com/NekoX-Dev/NekoX)
- [Catogram](https://github.com/Catogram/Catogram)
- [Nekogram](https://gitlab.com/Nekogram/Nekogram)
- [OwlGram](https://github.com/OwlGramDev/OwlGram)
3 changes: 0 additions & 3 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ dependencies {

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

// GPT
implementation 'com.theokanning.openai-gpt3-java:service:0.12.0'

implementation files('libs/libgsaverification-client.aar')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public MessageDetailsPopupWrapper(BaseFragment fragment, PopupSwipeBackLayout sw
}
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
stickerSetId = attribute.stickerset.id;
items.add(new Item(SET_OWNER, R.drawable.msg_sticker, LocaleController.getString(R.string.ChannelCreator), LocaleController.getString("Loading", R.string.Loading)));
if (stickerSetId > 0) {
items.add(new Item(SET_OWNER, R.drawable.msg_sticker, LocaleController.getString(R.string.ChannelCreator), LocaleController.getString("Loading", R.string.Loading)));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
}, titles = new CharSequence[]{
LocaleController.getString("exteraAppName", R.string.exteraAppName),
LocaleController.getString("ActionBarTitleUsername", R.string.ActionBarTitleUsername),
LocaleController.getString("ActionBarTitleName", R.string.ActionBarTitleName)
LocaleController.getString("ActionBarTitleName", R.string.ActionBarTitleName),
LocaleController.getString("FilterChats", R.string.FilterChats)
}, tabIcons = new CharSequence[]{
LocaleController.getString("TabTitleStyleTextWithIcons", R.string.TabTitleStyleTextWithIcons),
LocaleController.getString("TabTitleStyleTextOnly", R.string.TabTitleStyleTextOnly),
Expand Down Expand Up @@ -222,12 +223,13 @@ protected void onItemClick(View view, int position, float x, float y) {
ExteraConfig.editor.putBoolean("centerTitle", ExteraConfig.centerTitle ^= true).apply();
chatListPreviewCell.updateCenteredTitle(true);
((TextCheckCell) view).setChecked(ExteraConfig.centerTitle);
parentLayout.rebuildAllFragmentViews(false, false);
showBulletin();
} else if (position == hideAllChatsRow) {
ExteraConfig.editor.putBoolean("hideAllChats", ExteraConfig.hideAllChats ^= true).apply();
foldersPreviewCell.updateAllChatsTabName(true);
((TextCheckCell) view).setChecked(ExteraConfig.hideAllChats);
parentLayout.rebuildAllFragmentViews(false, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
} else if (position == tabCounterRow) {
ExteraConfig.editor.putBoolean("tabCounter", ExteraConfig.tabCounter ^= true).apply();
foldersPreviewCell.updateTabCounter(true);
Expand Down Expand Up @@ -306,8 +308,8 @@ protected void onItemClick(View view, int position, float x, float y) {
PopupUtils.showDialog(titles, LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), ExteraConfig.titleText, getContext(), i -> {
ExteraConfig.editor.putInt("titleText", ExteraConfig.titleText = i).apply();
chatListPreviewCell.updateTitle(true);
parentLayout.rebuildAllFragmentViews(false, false);
listAdapter.notifyItemChanged(actionBarTitleRow, payload);
getNotificationCenter().postNotificationName(NotificationCenter.currentUserPremiumStatusChanged);
});
} else if (position == tabTitleRow) {
if (getParentActivity() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected void updateRowsId() {
protected void onItemClick(View view, int position, float x, float y) {
if (position == aboutExteraRow) {
if (!BuildVars.PM_BUILD)
(new UpdaterBottomSheet(getParentActivity(), this, false)).show();
(new UpdaterBottomSheet(getParentActivity(), this, false, null)).show();
} else if (position == sourceCodeRow) {
Browser.openUrl(getParentActivity(), "https://github.com/exteraSquad/exteraGram");
} else if (position == channelRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import android.widget.TextView;

import com.exteragram.messenger.ExteraConfig;
import com.exteragram.messenger.utils.AppUtils;
import com.exteragram.messenger.utils.LocaleUtils;
import com.exteragram.messenger.utils.UpdaterUtils;

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

private RLottieImageView imageView;

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

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

TextCell version = new TextCell(context);
version.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 100, 0));
if (available) {
version.setTextAndValueAndIcon(LocaleController.getString("Version", R.string.Version), args[0].replaceAll("v|-beta", ""), R.drawable.msg_info, true);
version.setTextAndValueAndIcon(LocaleController.getString("Version", R.string.Version), update.version.replaceAll("v|-beta|-force", ""), R.drawable.msg_info, true);
} else {
version.setTextAndValueAndIcon(LocaleController.getString("CurrentVersion", R.string.CurrentVersion), BuildVars.BUILD_VERSION_STRING, R.drawable.msg_info, true);
}
Expand All @@ -113,7 +112,7 @@ protected void onDraw(Canvas canvas) {
if (available) {
TextCell size = new TextCell(context);
size.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 100, 0));
size.setTextAndValueAndIcon(LocaleController.getString("UpdateSize", R.string.UpdateSize), args[2], R.drawable.msg_sendfile, true);
size.setTextAndValueAndIcon(LocaleController.getString("UpdateSize", R.string.UpdateSize), update.size, R.drawable.msg_sendfile, true);
size.setOnClickListener(v -> copyText(size.getTextView().getText() + ": " + size.getValueTextView().getText()));
linearLayout.addView(size);

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

TextInfoPrivacyCell changelogTextView = new TextInfoPrivacyCell(context);
changelogTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
changelogTextView.setText(UpdaterUtils.replaceTags(args[1]));
changelogTextView.setText(UpdaterUtils.replaceTags(update.changelog));
linearLayout.addView(changelogTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

linearLayout.addView(divider, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(1)));
Expand All @@ -141,7 +140,7 @@ protected void onDraw(Canvas canvas) {
doneButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
doneButton.setText(LocaleController.getString("AppUpdateDownloadNow", R.string.AppUpdateDownloadNow));
doneButton.setOnClickListener(v -> {
UpdaterUtils.downloadApk(fragment.getContext(), args[3], "exteraGram " + args[0]);
UpdaterUtils.downloadApk(fragment.getContext(), update.downloadURL, "exteraGram " + update.version);
dismiss();
});
linearLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, 0, 16, 15, 16, 5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import androidx.recyclerview.widget.RecyclerView;

import com.exteragram.messenger.ExteraConfig;
import com.exteragram.messenger.utils.AppUtils;
import com.exteragram.messenger.utils.LocaleUtils;
import com.exteragram.messenger.utils.TranslatorUtils;
import com.exteragram.messenger.utils.UpdaterUtils;

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

timeView = new AnimatedTextView(context, true, true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@

package com.exteragram.messenger.utils;

import android.annotation.SuppressLint;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;

import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;

import java.security.MessageDigest;
import java.util.Calendar;

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

public static String getAppName() {
try {
return ApplicationLoader.applicationContext.getString(R.string.exteraAppName);
} catch (Exception e) {
return "exteraGram";
}
}

public static int[] getDrawerIconPack() {
switch (org.telegram.ui.ActionBar.Theme.getEventType()) {
case 0:
Expand Down Expand Up @@ -81,4 +81,31 @@ public static boolean isWinter() {
int currentMonth = calendar.get(Calendar.MONTH);
return currentMonth == Calendar.DECEMBER || currentMonth == Calendar.JANUARY || currentMonth == Calendar.FEBRUARY;
}

// do not change or remove this part of the code if you're making public fork
private static final String EXPECTED_SIGNATURE = "tcaLgrODWBN9GQvrHPfGzA==";
private static final String EXPECTED_PACKAGE_NAME = "com.exteragram.messenger";

public static boolean isAppModified() {
try {
@SuppressLint("PackageManagerGetSignatures")
PackageInfo packageInfo = ApplicationLoader.applicationContext.getPackageManager()
.getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), PackageManager.GET_SIGNATURES);

String currentPackageName = packageInfo.packageName;

Signature signature = packageInfo.signatures[0];

MessageDigest md = MessageDigest.getInstance("MD5");
byte[] signatureBytes = signature.toByteArray();
byte[] md5Bytes = md.digest(signatureBytes);
String currentSignature = Base64.encodeToString(md5Bytes, Base64.DEFAULT).trim();

return !EXPECTED_PACKAGE_NAME.equals(currentPackageName)
|| !EXPECTED_SIGNATURE.equals(currentSignature);
} catch (Exception e) {
FileLog.e(e);
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @Nekogram

package com.exteragram.messenger.utils;

import android.graphics.Bitmap;
Expand All @@ -9,6 +11,9 @@
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.List;

public class FontUtils {
Expand All @@ -25,6 +30,9 @@ public class FontUtils {
private static Boolean mediumWeightSupported = null;
private static Boolean italicSupported = null;

public static boolean loadSystemEmojiFailed = false;
private static Typeface systemEmojiTypeface;

static {
if (List.of("zh", "ja", "ko").contains(LocaleController.getInstance().getCurrentLocale().getLanguage())) {
TEST_TEXT = "日";
Expand Down Expand Up @@ -66,5 +74,55 @@ private static boolean testTypeface(Typeface typeface) {
AndroidUtilities.recycleBitmaps(List.of(bitmap1, bitmap2));
return supported;
}

public static File getSystemEmojiFontPath() {
try (var br = new BufferedReader(new FileReader("/system/etc/fonts.xml"))) {
String line;
var ignored = false;
while ((line = br.readLine()) != null) {
var trimmed = line.trim();
if (trimmed.startsWith("<family") && trimmed.contains("ignore=\"true\"")) {
ignored = true;
} else if (trimmed.startsWith("</family>")) {
ignored = false;
} else if (trimmed.startsWith("<font") && !ignored) {
var start = trimmed.indexOf(">");
var end = trimmed.indexOf("<", 1);
if (start > 0 && end > 0) {
var font = trimmed.substring(start + 1, end);
if (font.toLowerCase().contains("emoji")) {
File file = new File("/system/fonts/" + font);
if (file.exists()) {
FileLog.d("emoji font file fonts.xml = " + font);
return file;
}
}
}
}
}
br.close();

var fileAOSP = new File("/system/fonts/NotoColorEmoji.ttf");
if (fileAOSP.exists()) {
return fileAOSP;
}
} catch (Exception e) {
FileLog.e(e);
}
return null;
}

public static Typeface getSystemEmojiTypeface() {
if (!loadSystemEmojiFailed && systemEmojiTypeface == null) {
var font = getSystemEmojiFontPath();
if (font != null) {
systemEmojiTypeface = Typeface.createFromFile(font);
}
if (systemEmojiTypeface == null) {
loadSystemEmojiFailed = true;
}
}
return systemEmojiTypeface;
}
}

Loading

0 comments on commit 6f78031

Please sign in to comment.