Skip to content

Commit

Permalink
Merge branch 'test' into weblate
Browse files Browse the repository at this point in the history
  • Loading branch information
dic1911 committed Dec 9, 2024
2 parents b66c062 + 64b35d6 commit 38afc92
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Momogram has basic UnifiedPush support(enabled by default), but you need to inst

Here are two easy choices for you:

- [ntfy](https://github.com/binwiederhier/ntfy/releases/latest)
- [ntfy](https://github.com/binwiederhier/ntfy-android/releases/latest)
- [UP-FCM Distributor (relies on Google, but faster)](https://codeberg.org/UnifiedPush/fcm-distributor/releases)

Just choose one of the distributor from above, install and open it at least once to finish setup, then choose it in the notification settings page of Momogram and you're good to go!
Expand All @@ -94,7 +94,7 @@ In case of a rejection, you may ask if a PR is acceptable.

First, join the discussion group and search around to see if anyone reported the same bug (or a test build with bug-fix exists).

Then, make sure you have the latest version installed (check the channel).
Then, make sure you have the latest version installed (check the channel and the discussion group for latest fixes).

Then, if the issue appears in the official Telegram client too, please submit it to the officials, (be careful not to show Momogram in the description and screenshots, the official developers doesn't like us!).

Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ android {
buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + ""
buildConfigField "int", "APP_ID", appId
buildConfigField "String", "APP_HASH", "\"" + appHash + "\""
resValue "string", "package_name", APP_PACKAGE

// ndk {
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public void checkAppAccount() {
Utilities.globalQueue.postRunnable(() -> {
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
try {
Account[] accounts = am.getAccountsByType("org.telegram.messenger");
Account[] accounts = am.getAccountsByType(BuildConfig.APPLICATION_ID);
for (int a = 0; a < accounts.length; a++) {
Account acc = accounts[a];
boolean found = false;
Expand Down Expand Up @@ -429,7 +429,7 @@ public void checkAppAccount() {
readContacts();
if (systemAccount == null && !NekoConfig.disableSystemAccount.Bool()) {
try {
systemAccount = new Account("" + getUserConfig().getClientUserId(), "org.telegram.messenger");
systemAccount = new Account("" + getUserConfig().getClientUserId(), BuildConfig.APPLICATION_ID);
am.addAccountExplicitly(systemAccount, "", null);
} catch (Exception ignore) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.EnvUtil;

public class DownloadController extends BaseController implements NotificationCenter.NotificationCenterDelegate {

Expand Down Expand Up @@ -338,16 +339,19 @@ public void onReceive(Context context, Intent intent) {
checkAutodownloadSettings();
}
};

if (getUserConfig().isClientActivated()) {
checkAutodownloadSettings();
}

if (Boolean.TRUE.equals(EnvUtil.isWaydroid())) return; // workaround to prevent DeadSystemException for waydroid;

IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
if (Build.VERSION.SDK_INT >= 33) {
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
}

if (getUserConfig().isClientActivated()) {
checkAutodownloadSettings();
}
}

public void loadAutoDownloadConfig(boolean force) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.HashSet;
import java.util.Iterator;

import tw.nekomimi.nekogram.utils.EnvUtil;

public class LiteMode {

public static final int FLAG_ANIMATED_STICKERS_KEYBOARD = 1;
Expand Down Expand Up @@ -113,6 +115,7 @@ public static int getValue(boolean ignorePowerSaving) {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static int getBatteryLevel() {
long time = 0;
if (Boolean.TRUE.equals(EnvUtil.isWaydroid())) return 69; // workaround to prevent DeadSystemException for waydroid;
if (lastBatteryLevelCached < 0 || (time = System.currentTimeMillis()) - lastBatteryLevelChecked > 1000 * 12) {
BatteryManager batteryManager = (BatteryManager) ApplicationLoader.applicationContext.getSystemService(Context.BATTERY_SERVICE);
if (batteryManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
} else if (position == unifiedPushDistributorRow) {
String value = UnifiedPush.getAckDistributor(ApplicationLoader.applicationContext);
textCell.setTextAndValue(LocaleController.getString(R.string.UnifiedPushDistributor),
(value == null || value.isEmpty()) ? "None" : value,
(value == null || value.isEmpty()) ? "None/Unknown" : value,
updateUnifiedPushDistributor, false);
updateUnifiedPushDistributor = false;
}
Expand Down
10 changes: 8 additions & 2 deletions TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.LauncherIconController;
import org.unifiedpush.android.connector.UnifiedPush;
Expand Down Expand Up @@ -771,10 +772,13 @@ public static void applyPerformanceClassOverride(Integer c) {
public static void init() {
initStrings();
try {
SharedConfig.loadConfig();
if (lastCrashError.String() != null && !lastCrashError.String().isBlank()) {
final String errStr = lastCrashError.String();
AndroidUtilities.runOnUIThread(() -> {
Context context = LaunchActivity.getLastFragment().getContext();
BaseFragment fragment = LaunchActivity.getLastFragment();
if (fragment == null || SharedConfig.activeAccounts.isEmpty()) return;
Context context = fragment.getContext();
new AlertDialog.Builder(context)
.setTitle(LocaleController.getString(useOldName.Bool() ? R.string.CrashDialogTitle : R.string.CrashDialogMomoTitle))
.setMessage(LocaleController.getString(R.string.CrashDialogMessage))
Expand Down Expand Up @@ -803,7 +807,9 @@ public static void init() {
return;

AndroidUtilities.runOnUIThread(() -> {
Context context = LaunchActivity.getLastFragment().getContext();
BaseFragment fragment = LaunchActivity.getLastFragment();
if (fragment == null || SharedConfig.activeAccounts.isEmpty()) return;
Context context = fragment.getContext();
new AlertDialog.Builder(context)
.setTitle(LocaleController.getString(R.string.SetupUnifiedPush))
.setMessage(LocaleController.getString(R.string.SetupUnifiedPushInfo))
Expand Down
13 changes: 13 additions & 0 deletions TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ object EnvUtil {

}

@JvmStatic
var isWaydroid: Boolean? = null

@JvmStatic
fun checkIsWaydroid(): Boolean {
if (isWaydroid != null) return isWaydroid!!

val waydroidToolsVersion = AndroidUtilities.getSystemProperty("waydroid.tools_version")
val fingerprint = AndroidUtilities.getSystemProperty("ro.build.fingerprint")
isWaydroid = waydroidToolsVersion != null || fingerprint.contains("waydroid")
return isWaydroid!!
}

@JvmStatic
fun doTest() {

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/src/main/res/xml/auth.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="nekox.messenger"
android:accountType="@string/package_name"
android:icon="@mipmap/ic_launcher"
android:smallIcon="@mipmap/ic_launcher"
android:label="@string/AppName"
Expand Down

0 comments on commit 38afc92

Please sign in to comment.