Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed Apr 19, 2024
2 parents 7872fd5 + d77111e commit e760560
Show file tree
Hide file tree
Showing 29 changed files with 791 additions and 8 deletions.
504 changes: 504 additions & 0 deletions TMessagesProj/src/main/assets/id_date.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class BuildVars {

public static final boolean IS_BILLING_UNAVAILABLE = true;
public static boolean DEBUG_VERSION = true;
public static boolean DEBUG_VERSION = BuildConfig.BUILD_TYPE.equals("debug");
public static boolean DEBUG_PRIVATE_VERSION = DEBUG_VERSION;
public static boolean LOGS_ENABLED = DEBUG_PRIVATE_VERSION;
public static boolean USE_CLOUD_STRINGS = true;
Expand Down Expand Up @@ -49,7 +49,7 @@ public class BuildVars {
BUILD_VERSION_STRING = BuildConfig.VERSION_NAME;
}

if (!DEBUG_PRIVATE_VERSION && ApplicationLoader.applicationContext != null) {
if (ApplicationLoader.applicationContext != null) {
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
LOGS_ENABLED = DEBUG_VERSION = sharedPreferences.getBoolean("logsEnabled", DEBUG_VERSION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3836,7 +3836,7 @@ private void showOrUpdateNotification(boolean notifyAboutLast) {
}
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
int dismissDate = preferences.getInt("dismissDate", 0);
if (!lastMessageObject.isStoryPush && lastMessageObject.messageOwner.date <= dismissDate) {
if (!lastMessageObject.isStoryPush && (lastMessageObject.messageOwner.date <= dismissDate && NaConfig.INSTANCE.getPushServiceType().Int() != 3)) {
dismissNotification();
return;
}
Expand Down Expand Up @@ -3962,7 +3962,7 @@ private void showOrUpdateNotification(boolean notifyAboutLast) {
for (int i = 0; i < count; i++) {
MessageObject messageObject = pushMessages.get(i);
String message = getStringForMessage(messageObject, false, text, null);
if (message == null || !messageObject.isStoryPush && messageObject.messageOwner.date <= dismissDate) {
if (message == null || !messageObject.isStoryPush && (messageObject.messageOwner.date <= dismissDate && NaConfig.INSTANCE.getPushServiceType().Int() != 3)) {
continue;
}
if (silent == 2) {
Expand Down Expand Up @@ -4454,7 +4454,7 @@ private void showExtraNotifications(NotificationCompat.Builder notificationBuild
long dialog_id = messageObject.getDialogId();
long topicId = MessageObject.getTopicId(currentAccount, messageObject.messageOwner, getMessagesController().isForum(messageObject));
int dismissDate = preferences.getInt("dismissDate" + dialog_id, 0);
if (!messageObject.isStoryPush && messageObject.messageOwner.date <= dismissDate) {
if (!messageObject.isStoryPush && (messageObject.messageOwner.date <= dismissDate && NaConfig.INSTANCE.getPushServiceType().Int() != 3)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,8 @@ public static IPushListenerServiceProvider getProvider() {
if (instance != null)
return instance;
switch (NaConfig.INSTANCE.getPushServiceType().Int()) {
case 1: {
case 1:
case 3: {
instance = new GooglePushListenerServiceProvider();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

public class StickersAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate {

public final static boolean DISABLE_STICKER_EDITOR = !BuildVars.DEBUG_PRIVATE_VERSION;
public final static boolean DISABLE_STICKER_EDITOR = false;

public interface StickersAlertDelegate {
void onStickerSelected(TLRPC.Document sticker, String query, Object parent, MessageObject.SendAnimationData sendAnimationData, boolean clearsInputField, boolean notify, int scheduleDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
import kotlin.Unit;
import libv2ray.Libv2ray;
import tw.nekomimi.nekogram.BackButtonMenuRecent;
import tw.nekomimi.nekogram.helpers.ProfileDateHelper;
import tw.nekomimi.nekogram.helpers.SettingsHelper;
import tw.nekomimi.nekogram.helpers.SettingsSearchResult;
import tw.nekomimi.nekogram.transtale.popupwrapper.AutoTranslatePopupWrapper;
Expand Down Expand Up @@ -9806,7 +9807,11 @@ private void updateProfileData(boolean reload) {
int finalDc = dc;
idTextView.setOnClickListener(v -> {
BottomBuilder builder = new BottomBuilder(getParentActivity());
builder.addTitle(finalId + "");
if (finalId == userId) {
builder.addTitle(finalId + "", ProfileDateHelper.getUserTime(finalId));
} else {
builder.addTitle(finalId + "");
}
builder.addItem(LocaleController.getString("Copy", R.string.Copy), R.drawable.msg_copy, __ -> {
AlertUtil.copyAndAlert(finalId + "");
return Unit.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package tw.nekomimi.nekogram.helpers;

import org.json.JSONArray;
import org.json.JSONObject;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;

public class ProfileDateHelper {
private static String JSON_FILE = "id_date.json";
private static final ArrayList<ProfileDateData> profileDateDataList = new ArrayList<>();

private static void loadData() {
try {
InputStream in = ApplicationLoader.applicationContext.getAssets().open(JSON_FILE);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[10240];
int c;
while ((c = in.read(buffer)) != -1) {
bos.write(buffer, 0, c);
}
bos.close();
in.close();
String json = bos.toString("UTF-8");
JSONObject object = new JSONObject(json);
JSONArray data = object.getJSONArray("data");
profileDateDataList.clear();
for (int i = 0; i<data.length(); i++){
JSONObject o = data.getJSONObject(i);
profileDateDataList.add(new ProfileDateData(o.getLong("id"), o.getLong("date")));
}
} catch (Exception e) {
FileLog.e(e);
}
}

public static String getUserTime(String prefix, long date) {
String st = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)));
return prefix + " " + st;
}

public static String getUserTime(Long userId) {
if (profileDateDataList.isEmpty()) {
loadData();
}
if (profileDateDataList.isEmpty()) {
return "unknown";
}
for (int i = 1; i < profileDateDataList.size(); i++){
ProfileDateData data1 = profileDateDataList.get(i - 1);
ProfileDateData data2 = profileDateDataList.get(i);
if (userId >= data1.getId() && userId <= data2.getId()) {
long idx = userId - data1.getId();
long idxRange = data2.getId() - data1.getId();
double t = (double) idx / idxRange;
long date1 = data1.getDate();
long date2 = data2.getDate();
double date = (date1 + t * (date2 - date1)) * 1000.0;
long dateLong = Math.round(date);
return getUserTime("~", dateLong);
}
}
if (userId <= 1000000) {
return getUserTime("=", 1380326400000L);
}
return getUserTime(">", 1711889200000L);
}

public static class ProfileDateData {
private final long id;
private final long date;

public ProfileDateData(long id, long date) {
this.id = id;
this.date = date;
}

public long getId() {
return id;
}

public long getDate() {
return date;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public class NekoGeneralSettingsActivity extends BaseNekoXSettingsActivity {
LocaleController.getString(R.string.PushServiceTypeInApp),
LocaleController.getString(R.string.PushServiceTypeFCM),
LocaleController.getString(R.string.PushServiceTypeUnified),
LocaleController.getString(R.string.PushServiceTypeMicroG),
}, null));
private final AbstractConfigCell pushServiceTypeInAppDialogRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getPushServiceTypeInAppDialog()));
private final AbstractConfigCell pushServiceTypeUnifiedGatewayRow = cellGroup.appendCell(new ConfigCellTextInput(null, NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway(), null, null, (input) -> input.isEmpty() ? (String) NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway().defaultValue : input));
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-ar-rSA/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@
<string name="StickersChooseShortNameForStickerPack">اختر اسما قصيرا لحزمتك.</string>
<string name="StickersCopyStickerSet">نسخ مجموعة الملصقات</string>
<string name="DisableChannelMuteButton">تعطيل زر كتم القناة</string>
<string name="DisablePreviewVideoSoundShortcut">تعطيل إختصار صوت معاينة الفيديو</string>
<string name="DisablePreviewVideoSoundShortcutNotice">تعطيل مفاتيح الصوت لتمكين معاينة صوت الفيديو</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-cs-rCZ/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@
<string name="StickersChooseShortNameForStickerPack">Choose a short name for your pack.</string>
<string name="StickersCopyStickerSet">Copy Sticker Set</string>
<string name="DisableChannelMuteButton">Zakázat tlačítko ztlumit kanál</string>
<string name="DisablePreviewVideoSoundShortcut">Zakázat zástupce zvuku videa</string>
<string name="DisablePreviewVideoSoundShortcutNotice">Zakázat tlačítka hlasitosti pro zapnutí náhledu zvuku videa</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-da-rDK/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@
<string name="StickersChooseShortNameForStickerPack">Vælg et kort navn til din pakke.</string>
<string name="StickersCopyStickerSet">Kopiér Klistermærke Set</string>
<string name="DisableChannelMuteButton">Deaktivér kanal mute knap</string>
<string name="DisablePreviewVideoSoundShortcut">Deaktivér forhåndsvisning af videolyd genvej</string>
<string name="DisablePreviewVideoSoundShortcutNotice">Deaktivér lydstyrkeknapper for at aktivere forhåndsvisning af videolyd</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-de-rDE/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@
<string name="StickersChooseShortNameForStickerPack">Wähle einen kurzen Namen für dein Paket.</string>
<string name="StickersCopyStickerSet">Sticker-Set kopieren</string>
<string name="DisableChannelMuteButton">Sendermute-Schaltfläche deaktivieren</string>
<string name="DisablePreviewVideoSoundShortcut">Vorschau Video Ton Verknüpfung deaktivieren</string>
<string name="DisablePreviewVideoSoundShortcutNotice">Lautstärketasten deaktivieren, um Videovorschau zu aktivieren</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-el-rGR/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@
<string name="StickersChooseShortNameForStickerPack">Επιλέξτε ένα σύντομο όνομα για το πακέτο σας.</string>
<string name="StickersCopyStickerSet">Αντιγραφή Σετ Αυτοκόλλητων</string>
<string name="DisableChannelMuteButton">Απενεργοποίηση κουμπιού σίγασης καναλιού</string>
<string name="DisablePreviewVideoSoundShortcut">Απενεργοποίηση συντόμευσης ήχου βίντεο προεπισκόπησης</string>
<string name="DisablePreviewVideoSoundShortcutNotice">Απενεργοποίηση πλήκτρων έντασης για ενεργοποίηση προεπισκόπησης ήχου βίντεο</string>
</resources>
Loading

0 comments on commit e760560

Please sign in to comment.