Minor fixes

This commit is contained in:
世界 2021-04-11 08:53:15 +08:00
parent 5d88b7c83e
commit 58942794e3
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
9 changed files with 39 additions and 43 deletions

View File

@ -1326,7 +1326,7 @@ public class MediaDataController extends BaseController {
archivedStickersCount[type] = count;
getNotificationCenter().postNotificationName(NotificationCenter.archivedStickersCountDidLoad, type);
}
} else if (!UserConfig.getInstance(currentAccount).isBot) {
} else if(!getUserConfig().getCurrentUser().bot) {
TLRPC.TL_messages_getArchivedStickers req = new TLRPC.TL_messages_getArchivedStickers();
req.limit = 0;
req.masks = type == TYPE_MASK;
@ -1559,7 +1559,7 @@ public class MediaDataController extends BaseController {
}
processLoadedStickers(type, newStickerArray, true, date, hash);
});
} else if (!UserConfig.getInstance(currentAccount).isBot) {
} else if(!getUserConfig().getCurrentUser().bot) {
if (type == TYPE_FEATURED) {
TLRPC.TL_messages_allStickers response = new TLRPC.TL_messages_allStickers();
response.hash = loadFeaturedHash;

View File

@ -5198,7 +5198,7 @@ public class MessagesController extends BaseController implements NotificationCe
checkDeletingTask(false);
checkReadTasks();
if (getUserConfig().isClientActivated() && !getUserConfig().isBot) {
if (getUserConfig().isClientActivated() && !getUserConfig().getCurrentUser().bot) {
if (!ignoreSetOnline && getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) {
if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000) {
@ -10635,13 +10635,11 @@ public class MessagesController extends BaseController implements NotificationCe
newTaskId = taskId;
}
if (!NekoConfig.unlimitedPinnedDialogs) {
getConnectionsManager().sendRequest(req, (response, error) -> {
if (newTaskId != 0) {
getMessagesStorage().removePendingTask(newTaskId);
}
});
}
if (!NekoConfig.unlimitedPinnedDialogs) getConnectionsManager().sendRequest(req, (response, error) -> {
if (newTaskId != 0) {
getMessagesStorage().removePendingTask(newTaskId);
}
});
}
}
getMessagesStorage().setDialogPinned(did, dialog.pinnedNum);

View File

@ -3539,7 +3539,7 @@ public class NotificationsController extends BaseController {
.setGroupSummary(true)
.setShowWhen(true)
.setWhen(((long) lastMessageObject.messageOwner.date) * 1000)
.setColor(getNotificationColor());
.setColor(NekoConfig.getNotificationColor());
long[] vibrationPattern = null;
Uri sound = null;
@ -4282,7 +4282,7 @@ public class NotificationsController extends BaseController {
.setContentText(text.toString())
.setAutoCancel(true)
.setNumber(messageObjects.size())
.setColor(getNotificationColor())
.setColor(NekoConfig.getNotificationColor())
.setGroupSummary(false)
.setWhen(date)
.setShowWhen(true)
@ -4684,24 +4684,4 @@ public class NotificationsController extends BaseController {
}
}
private int getNotificationColor() {
int color = 0;
Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration();
boolean isDark = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
if (isDark) {
color = 0xffffffff;
} else {
if (Theme.getActiveTheme().hasAccentColors()) {
color = Theme.getActiveTheme().getAccentColor(Theme.getActiveTheme().currentAccentId);
}
if (Theme.getActiveTheme().isDark() || color == 0) {
color = Theme.getColor(Theme.key_actionBarDefault);
}
// too bright
if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) {
color = Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader) | 0xff000000;
}
}
return color;
}
}

View File

@ -22,6 +22,8 @@ import android.provider.Settings;
import androidx.core.app.NotificationCompat;
import tw.nekomimi.nekogram.NekoConfig;
public class NotificationsService extends Service {
@Override
@ -45,7 +47,7 @@ public class NotificationsService extends Service {
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification)
.setColor(0xff11acfa)
.setColor(NekoConfig.getNotificationColor())
.setContentTitle(LocaleController.getString("NekogramRunning", R.string.NekogramRunning))
.setContentText(LocaleController.getString("TapToDisable",R.string.TapToDisable))
.setContentIntent(pendingIntent)

View File

@ -66,7 +66,6 @@ public class UserConfig extends BaseController {
public long pendingAppUpdateInstallTime;
public long lastUpdateCheckTime;
public long autoDownloadConfigLoadTime;
public boolean isBot;
public boolean official;
public boolean deviceInfo;
@ -154,7 +153,6 @@ public class UserConfig extends BaseController {
editor.putBoolean("hasValidDialogLoadIds", hasValidDialogLoadIds);
editor.putInt("sharingMyLocationUntil", sharingMyLocationUntil);
editor.putInt("lastMyLocationShareTime", lastMyLocationShareTime);
editor.putBoolean("isBot", isBot);
editor.putBoolean("official", official);
editor.putBoolean("deviceInfo", deviceInfo);
@ -309,7 +307,6 @@ public class UserConfig extends BaseController {
notificationsSignUpSettingsLoaded = preferences.getBoolean("notificationsSignUpSettingsLoaded", false);
autoDownloadConfigLoadTime = preferences.getLong("autoDownloadConfigLoadTime", 0);
hasValidDialogLoadIds = preferences.contains("2dialogsLoadOffsetId") || preferences.getBoolean("hasValidDialogLoadIds", false);
isBot = preferences.getBoolean("isBot", false);
official = preferences.getBoolean("official", false);
deviceInfo = preferences.getBoolean("deviceInfo", true);
@ -498,7 +495,6 @@ public class UserConfig extends BaseController {
loginTime = (int) (System.currentTimeMillis() / 1000);
lastContactsSyncTime = (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60;
lastHintsSyncTime = (int) (System.currentTimeMillis() / 1000) - 25 * 60 * 60;
isBot = false;
resetSavedPassword();
boolean hasActivated = false;
for (int a : SharedConfig.activeAccounts) {

View File

@ -280,7 +280,7 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter imple
return true;
}));
}
if (NekoXConfig.disableStatusUpdate && !UserConfig.getInstance(UserConfig.selectedAccount).isBot) {
if (NekoXConfig.disableStatusUpdate && !UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser().bot) {
boolean online = MessagesController.getInstance(UserConfig.selectedAccount).isOnline();
String message = online ? StrUtil.upperFirst(LocaleController.getString("Online", R.string.Online)) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle);
if (NekoXConfig.keepOnlineStatus) {

View File

@ -19724,7 +19724,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updatePinnedMessageView(true);
updateVisibleRows();
if (!messageObject.scheduled && !UserConfig.getInstance(currentAccount).isBot) {
if (!messageObject.scheduled && !getUserConfig().getCurrentUser().bot) {
TLRPC.TL_messages_getMessageEditData req = new TLRPC.TL_messages_getMessageEditData();
req.peer = getMessagesController().getInputPeer((int) dialog_id);
req.id = messageObject.getId();

View File

@ -355,7 +355,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
ConnectionsManager.getInstance(currentAccount).setUserId(res.user.id);
UserConfig.getInstance(currentAccount).clearConfig();
MessagesController.getInstance(currentAccount).cleanup();
UserConfig.getInstance(currentAccount).isBot = true;
UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
UserConfig.getInstance(currentAccount).saveConfig(true);
@ -364,9 +363,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
users.add(res.user);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
MessagesController.getInstance(currentAccount).putUser(res.user, false);
ContactsController.getInstance(currentAccount).checkAppAccount();
MessagesController.getInstance(currentAccount).getBlockedPeers(true);
MessagesController.getInstance(currentAccount).checkPromoInfo(true);
ConnectionsManager.getInstance(currentAccount).updateDcSettings();
needFinishActivity(false);
} else {

View File

@ -5,14 +5,17 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Typeface;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.NotificationsService;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.Theme;
import java.io.BufferedReader;
import java.io.FileReader;
@ -803,4 +806,25 @@ public class NekoConfig {
return systemEmojiTypeface;
}
public static int getNotificationColor() {
int color = 0;
Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration();
boolean isDark = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
if (isDark) {
color = 0xffffffff;
} else {
if (Theme.getActiveTheme().hasAccentColors()) {
color = Theme.getActiveTheme().getAccentColor(Theme.getActiveTheme().currentAccentId);
}
if (Theme.getActiveTheme().isDark() || color == 0) {
color = Theme.getColor(Theme.key_actionBarDefault);
}
// too bright
if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) {
color = Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader) | 0xff000000;
}
}
return color;
}
}