Merge upstream 7.3.1 (2199)

This commit is contained in:
世界 2020-12-26 13:31:10 +08:00
commit b34f56582b
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
22 changed files with 672 additions and 425 deletions

View File

@ -1,8 +1,8 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
def verName = "7.3.0-preview05" def verName = "7.3.1-preview06"
def verCode = 128 def verCode = 130
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -84,10 +84,10 @@ dependencies {
implementation 'org.dizitart:nitrite' implementation 'org.dizitart:nitrite'
implementation 'org.dizitart:nitrite-mvstore-adapter' implementation 'org.dizitart:nitrite-mvstore-adapter'
implementation ('cn.hutool:hutool-http:5.5.4') { implementation('cn.hutool:hutool-http:5.5.4') {
exclude group: "org.apache.poi" exclude group: "org.apache.poi"
} }
implementation ('cn.hutool:hutool-crypto:5.5.4') { implementation('cn.hutool:hutool-crypto:5.5.4') {
exclude module: "hutool-core" exclude module: "hutool-core"
} }
implementation 'com.jakewharton:process-phoenix:2.0.0' implementation 'com.jakewharton:process-phoenix:2.0.0'

View File

@ -31,7 +31,7 @@ public class SQLitePreparedStatement {
public SQLitePreparedStatement(SQLiteDatabase db, String sql) throws SQLiteException { public SQLitePreparedStatement(SQLiteDatabase db, String sql) throws SQLiteException {
sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql); sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql);
if (BuildVars.DEBUG_VERSION) { if (BuildVars.LOGS_ENABLED) {
query = sql; query = sql;
startTime = SystemClock.elapsedRealtime(); startTime = SystemClock.elapsedRealtime();
/*if (hashMap == null) { /*if (hashMap == null) {
@ -101,7 +101,7 @@ public class SQLitePreparedStatement {
if (isFinalized) { if (isFinalized) {
return; return;
} }
if (BuildVars.DEBUG_VERSION) { if (BuildVars.LOGS_ENABLED) {
long diff = SystemClock.elapsedRealtime() - startTime; long diff = SystemClock.elapsedRealtime() - startTime;
if (diff > 500) { if (diff > 500) {
FileLog.d("sqlite query " + query + " took " + diff + "ms"); FileLog.d("sqlite query " + query + " took " + diff + "ms");

View File

@ -3976,24 +3976,24 @@ public class AndroidUtilities {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
final View decorView = window.getDecorView(); final View decorView = window.getDecorView();
int flags = decorView.getSystemUiVisibility(); int flags = decorView.getSystemUiVisibility();
if (NekoConfig.transparentStatusBar) { if (!SharedConfig.noStatusBar && NekoConfig.transparentStatusBar) {
window.setStatusBarColor(Color.TRANSPARENT); window.setStatusBarColor(Color.TRANSPARENT);
} }
if (enable) { if (enable) {
if (!NekoConfig.transparentStatusBar) {
window.setStatusBarColor(0x0f000000);
}
if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) == 0) { if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) == 0) {
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
decorView.setSystemUiVisibility(flags); decorView.setSystemUiVisibility(flags);
if (!SharedConfig.noStatusBar && !NekoConfig.transparentStatusBar) {
window.setStatusBarColor(0x0f000000);
}
} }
} else { } else {
if (!NekoConfig.transparentStatusBar) {
window.setStatusBarColor(0x33000000);
}
if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0) { if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0) {
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
decorView.setSystemUiVisibility(flags); decorView.setSystemUiVisibility(flags);
if (!SharedConfig.noStatusBar && !NekoConfig.transparentStatusBar) {
window.setStatusBarColor(0x33000000);
}
} }
} }
} }

View File

@ -13,7 +13,6 @@ import android.text.TextUtils;
import android.util.SparseArray; import android.util.SparseArray;
import org.telegram.messenger.voip.VoIPService; import org.telegram.messenger.voip.VoIPService;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,18 +53,23 @@ public class ChatObject {
private String nextLoadOffset; private String nextLoadOffset;
public boolean membersLoadEndReached; public boolean membersLoadEndReached;
public boolean loadingMembers; public boolean loadingMembers;
public int currentAccount; public boolean reloadingMembers;
public AccountInstance currentAccount;
public int speakingMembersCount; public int speakingMembersCount;
private Runnable typingUpdateRunnable = () -> { private Runnable typingUpdateRunnable = () -> {
typingUpdateRunnableScheduled = false; typingUpdateRunnableScheduled = false;
checkOnlineParticipants(); checkOnlineParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallTypingsUpdated); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallTypingsUpdated);
}; };
private boolean typingUpdateRunnableScheduled; private boolean typingUpdateRunnableScheduled;
private int lastLoadGuid; private int lastLoadGuid;
private HashSet<Integer> loadingGuids = new HashSet<>(); private HashSet<Integer> loadingGuids = new HashSet<>();
private ArrayList<TLRPC.TL_updateGroupCallParticipants> updatesQueue = new ArrayList<>();
private long updatesStartWaitTime;
public void setCall(int account, int chatId, TLRPC.TL_phone_groupCall groupCall) { private Runnable checkQueueRunnable;
public void setCall(AccountInstance account, int chatId, TLRPC.TL_phone_groupCall groupCall) {
this.chatId = chatId; this.chatId = chatId;
currentAccount = account; currentAccount = account;
call = groupCall.call; call = groupCall.call;
@ -85,19 +89,25 @@ public class ChatObject {
public void migrateToChat(TLRPC.Chat chat) { public void migrateToChat(TLRPC.Chat chat) {
chatId = chat.id; chatId = chat.id;
VoIPService voIPService = VoIPService.getSharedInstance(); VoIPService voIPService = VoIPService.getSharedInstance();
if (voIPService != null && voIPService.getAccount() == currentAccount && voIPService.getChat() != null && voIPService.getChat().id == -chatId) { if (voIPService != null && voIPService.getAccount() == currentAccount.getCurrentAccount() && voIPService.getChat() != null && voIPService.getChat().id == -chatId) {
voIPService.migrateToChat(chat); voIPService.migrateToChat(chat);
} }
} }
public void loadMembers(boolean fromBegin) { public void loadMembers(boolean fromBegin) {
if (fromBegin) { if (fromBegin) {
if (reloadingMembers) {
return;
}
membersLoadEndReached = false; membersLoadEndReached = false;
nextLoadOffset = null; nextLoadOffset = null;
} }
if (membersLoadEndReached) { if (membersLoadEndReached) {
return; return;
} }
if (fromBegin) {
reloadingMembers = true;
}
loadingMembers = true; loadingMembers = true;
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants(); TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
req.call = new TLRPC.TL_inputGroupCall(); req.call = new TLRPC.TL_inputGroupCall();
@ -105,11 +115,14 @@ public class ChatObject {
req.call.access_hash = call.access_hash; req.call.access_hash = call.access_hash;
req.offset = nextLoadOffset != null ? nextLoadOffset : ""; req.offset = nextLoadOffset != null ? nextLoadOffset : "";
req.limit = 20; req.limit = 20;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { currentAccount.getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingMembers = false;
if (fromBegin) {
reloadingMembers = false;
}
if (response != null) { if (response != null) {
loadingMembers = false;
TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response; TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response;
MessagesController.getInstance(currentAccount).putUsers(groupParticipants.users, false); currentAccount.getMessagesController().putUsers(groupParticipants.users, false);
SparseArray<TLRPC.TL_groupCallParticipant> old = null; SparseArray<TLRPC.TL_groupCallParticipant> old = null;
if (TextUtils.isEmpty(req.offset)) { if (TextUtils.isEmpty(req.offset)) {
if (participants.size() != 0) { if (participants.size() != 0) {
@ -151,7 +164,7 @@ public class ChatObject {
call.participants_count = participants.size(); call.participants_count = participants.size();
} }
sortParticipants(); sortParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
} }
})); }));
} }
@ -181,59 +194,68 @@ public class ChatObject {
} }
} }
if (participantsToLoad != null) { if (participantsToLoad != null) {
int guid = ++lastLoadGuid; loadUnknownParticipants(participantsToLoad, true);
loadingGuids.add(guid);
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
req.call = new TLRPC.TL_inputGroupCall();
req.call.id = call.id;
req.call.access_hash = call.access_hash;
req.ids = participantsToLoad;
req.offset = "";
req.limit = 100;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (!loadingGuids.remove(guid)) {
return;
}
if (response != null) {
TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response;
MessagesController.getInstance(currentAccount).putUsers(groupParticipants.users, false);
for (int a = 0, N = groupParticipants.participants.size(); a < N; a++) {
TLRPC.TL_groupCallParticipant participant = groupParticipants.participants.get(a);
TLRPC.TL_groupCallParticipant oldParticipant = participants.get(participant.user_id);
if (oldParticipant != null) {
sortedParticipants.remove(oldParticipant);
participantsBySources.remove(oldParticipant.source);
}
participants.put(participant.user_id, participant);
sortedParticipants.add(participant);
participantsBySources.put(participant.source, participant);
if (invitedUsersMap.contains(participant.user_id)) {
Integer id = participant.user_id;
invitedUsersMap.remove(id);
invitedUsers.remove(id);
}
}
if (call.participants_count < participants.size()) {
call.participants_count = participants.size();
}
sortParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
}
}));
} }
if (updated) { if (updated) {
sortParticipants(); sortParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
} }
} }
private void loadUnknownParticipants(ArrayList<Integer> participantsToLoad, boolean isIds) {
int guid = ++lastLoadGuid;
loadingGuids.add(guid);
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
req.call = new TLRPC.TL_inputGroupCall();
req.call.id = call.id;
req.call.access_hash = call.access_hash;
if (isIds) {
req.ids = participantsToLoad;
} else {
req.sources = participantsToLoad;
}
req.offset = "";
req.limit = 100;
currentAccount.getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (!loadingGuids.remove(guid)) {
return;
}
if (response != null) {
TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response;
currentAccount.getMessagesController().putUsers(groupParticipants.users, false);
for (int a = 0, N = groupParticipants.participants.size(); a < N; a++) {
TLRPC.TL_groupCallParticipant participant = groupParticipants.participants.get(a);
TLRPC.TL_groupCallParticipant oldParticipant = participants.get(participant.user_id);
if (oldParticipant != null) {
sortedParticipants.remove(oldParticipant);
participantsBySources.remove(oldParticipant.source);
}
participants.put(participant.user_id, participant);
sortedParticipants.add(participant);
participantsBySources.put(participant.source, participant);
if (invitedUsersMap.contains(participant.user_id)) {
Integer id = participant.user_id;
invitedUsersMap.remove(id);
invitedUsers.remove(id);
}
}
if (call.participants_count < participants.size()) {
call.participants_count = participants.size();
}
sortParticipants();
currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
}
}));
}
public void processVoiceLevelsUpdate(int[] ssrc, float[] levels, boolean[] voice) { public void processVoiceLevelsUpdate(int[] ssrc, float[] levels, boolean[] voice) {
boolean updated = false; boolean updated = false;
int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime(); int currentTime = currentAccount.getConnectionsManager().getCurrentTime();
ArrayList<Integer> participantsToLoad = null;
for (int a = 0; a < ssrc.length; a++) { for (int a = 0; a < ssrc.length; a++) {
TLRPC.TL_groupCallParticipant participant; TLRPC.TL_groupCallParticipant participant;
if (ssrc[a] == 0) { if (ssrc[a] == 0) {
participant = participants.get(UserConfig.getInstance(currentAccount).getClientUserId()); participant = participants.get(currentAccount.getUserConfig().getClientUserId());
} else { } else {
participant = participantsBySources.get(ssrc[a]); participant = participantsBySources.get(ssrc[a]);
} }
@ -249,34 +271,123 @@ public class ChatObject {
} else { } else {
participant.amplitude = 0; participant.amplitude = 0;
} }
} else {
if (participantsToLoad == null) {
participantsToLoad = new ArrayList<>();
}
participantsToLoad.add(ssrc[a]);
} }
} }
if (participantsToLoad != null) {
loadUnknownParticipants(participantsToLoad, false);
}
if (updated) { if (updated) {
sortParticipants(); sortParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
} }
} }
public void processParticipantsUpdate(AccountInstance accountInstance, TLRPC.TL_updateGroupCallParticipants update) { private int isValidUpdate(TLRPC.TL_updateGroupCallParticipants update) {
boolean versioned = false; if (call.version + 1 == update.version || call.version == update.version) {
for (int a = 0, N = update.participants.size(); a < N; a++) { return 0;
TLRPC.TL_groupCallParticipant participant = update.participants.get(a); } else if (call.version < update.version) {
if (participant.versioned) { return 1;
versioned = true; } else {
break; return 2;
}
}
private void processUpdatesQueue() {
Collections.sort(updatesQueue, (updates, updates2) -> AndroidUtilities.compare(updates.version, updates2.version));
if (updatesQueue != null && !updatesQueue.isEmpty()) {
boolean anyProceed = false;
for (int a = 0; a < updatesQueue.size(); a++) {
TLRPC.TL_updateGroupCallParticipants update = updatesQueue.get(a);
int updateState = isValidUpdate(update);
if (updateState == 0) {
processParticipantsUpdate(update, true);
anyProceed = true;
updatesQueue.remove(a);
a--;
} else if (updateState == 1) {
if (updatesStartWaitTime != 0 && (anyProceed || Math.abs(System.currentTimeMillis() - updatesStartWaitTime) <= 1500)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN GROUP CALL UPDATES QUEUE - will wait more time");
}
if (anyProceed) {
updatesStartWaitTime = System.currentTimeMillis();
}
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN GROUP CALL UPDATES QUEUE - reload participants");
}
updatesStartWaitTime = 0;
updatesQueue.clear();
nextLoadOffset = null;
loadMembers(true);
}
return;
} else {
updatesQueue.remove(a);
a--;
}
}
updatesQueue.clear();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("GROUP CALL UPDATES QUEUE PROCEED - OK");
} }
} }
if (versioned && call.version + 1 < update.version) { updatesStartWaitTime = 0;
nextLoadOffset = null; }
loadMembers(true);
return; private void checkQueue() {
checkQueueRunnable = null;
if (updatesStartWaitTime != 0 && (System.currentTimeMillis() - updatesStartWaitTime) >= 1500) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("QUEUE GROUP CALL UPDATES WAIT TIMEOUT - CHECK QUEUE");
}
processUpdatesQueue();
} }
if (update.version < call.version) { if (!updatesQueue.isEmpty()) {
return; AndroidUtilities.runOnUIThread(checkQueueRunnable = this::checkQueue, 1000);
}
}
public void processParticipantsUpdate(TLRPC.TL_updateGroupCallParticipants update, boolean fromQueue) {
if (!fromQueue) {
boolean versioned = false;
for (int a = 0, N = update.participants.size(); a < N; a++) {
TLRPC.TL_groupCallParticipant participant = update.participants.get(a);
if (participant.versioned) {
versioned = true;
break;
}
}
if (versioned && call.version + 1 < update.version) {
if (reloadingMembers || updatesStartWaitTime == 0 || Math.abs(System.currentTimeMillis() - updatesStartWaitTime) <= 1500) {
if (updatesStartWaitTime == 0) {
updatesStartWaitTime = System.currentTimeMillis();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add TL_updateGroupCallParticipants to queue " + update.version);
}
updatesQueue.add(update);
if (checkQueueRunnable == null) {
AndroidUtilities.runOnUIThread(checkQueueRunnable = this::checkQueue, 1500);
}
} else {
nextLoadOffset = null;
loadMembers(true);
}
return;
}
if (versioned && update.version < call.version) {
return;
}
} }
boolean updated = false; boolean updated = false;
boolean selfUpdated = false; boolean selfUpdated = false;
int selfId = accountInstance.getUserConfig().getClientUserId(); int selfId = currentAccount.getUserConfig().getClientUserId();
for (int a = 0, N = update.participants.size(); a < N; a++) { for (int a = 0, N = update.participants.size(); a < N; a++) {
TLRPC.TL_groupCallParticipant participant = update.participants.get(a); TLRPC.TL_groupCallParticipant participant = update.participants.get(a);
TLRPC.TL_groupCallParticipant oldParticipant = participants.get(participant.user_id); TLRPC.TL_groupCallParticipant oldParticipant = participants.get(participant.user_id);
@ -320,7 +431,7 @@ public class ChatObject {
participantsBySources.put(participant.source, participant); participantsBySources.put(participant.source, participant);
} }
if (participant.user_id == selfId && participant.active_date == 0) { if (participant.user_id == selfId && participant.active_date == 0) {
participant.active_date = accountInstance.getConnectionsManager().getCurrentTime(); participant.active_date = currentAccount.getConnectionsManager().getCurrentTime();
} }
updated = true; updated = true;
} }
@ -330,13 +441,16 @@ public class ChatObject {
} }
if (update.version > call.version) { if (update.version > call.version) {
call.version = update.version; call.version = update.version;
if (!fromQueue) {
processUpdatesQueue();
}
} }
if (call.participants_count < participants.size()) { if (call.participants_count < participants.size()) {
call.participants_count = participants.size(); call.participants_count = participants.size();
} }
if (updated) { if (updated) {
sortParticipants(); sortParticipants();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, selfUpdated); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, selfUpdated);
} }
} }
@ -346,7 +460,7 @@ public class ChatObject {
loadMembers(true); loadMembers(true);
} }
call = update.call; call = update.call;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false); currentAccount.getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, call.id, false);
} }
public TLRPC.TL_inputGroupCall getInputGroupCall() { public TLRPC.TL_inputGroupCall getInputGroupCall() {
@ -376,7 +490,7 @@ public class ChatObject {
typingUpdateRunnableScheduled = false; typingUpdateRunnableScheduled = false;
} }
speakingMembersCount = 0; speakingMembersCount = 0;
int currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime(); int currentTime = currentAccount.getConnectionsManager().getCurrentTime();
int minDiff = Integer.MAX_VALUE; int minDiff = Integer.MAX_VALUE;
for (int a = 0, N = sortedParticipants.size(); a < N; a++) { for (int a = 0, N = sortedParticipants.size(); a < N; a++) {
TLRPC.TL_groupCallParticipant participant = sortedParticipants.get(a); TLRPC.TL_groupCallParticipant participant = sortedParticipants.get(a);

View File

@ -2844,7 +2844,7 @@ public class MessagesController extends BaseController implements NotificationCe
putUsers(groupCall.users, false); putUsers(groupCall.users, false);
ChatObject.Call call = new ChatObject.Call(); ChatObject.Call call = new ChatObject.Call();
call.setCall(currentAccount, chatId, groupCall); call.setCall(getAccountInstance(), chatId, groupCall);
groupCalls.put(groupCall.call.id, call); groupCalls.put(groupCall.call.id, call);
groupCallsByChatId.put(chatId, call); groupCallsByChatId.put(chatId, call);
getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, groupCall.call.id, false); getNotificationCenter().postNotificationName(NotificationCenter.groupCallUpdated, chatId, groupCall.call.id, false);
@ -4902,7 +4902,7 @@ public class MessagesController extends BaseController implements NotificationCe
for (int a = 0; a < updatesQueueChannels.size(); a++) { for (int a = 0; a < updatesQueueChannels.size(); a++) {
int key = updatesQueueChannels.keyAt(a); int key = updatesQueueChannels.keyAt(a);
long updatesStartWaitTime = updatesStartWaitTimeChannels.valueAt(a); long updatesStartWaitTime = updatesStartWaitTimeChannels.valueAt(a);
if (updatesStartWaitTime + 1500 < currentTime) { if (Math.abs(currentTime - updatesStartWaitTime) >= 1500) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("QUEUE CHANNEL " + key + " UPDATES WAIT TIMEOUT - CHECK QUEUE"); FileLog.d("QUEUE CHANNEL " + key + " UPDATES WAIT TIMEOUT - CHECK QUEUE");
} }
@ -4912,7 +4912,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
for (int a = 0; a < 3; a++) { for (int a = 0; a < 3; a++) {
if (getUpdatesStartTime(a) != 0 && getUpdatesStartTime(a) + 1500 < currentTime) { if (getUpdatesStartTime(a) != 0 && Math.abs(currentTime - getUpdatesStartTime(a)) >= 1500) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d(a + " QUEUE UPDATES WAIT TIMEOUT - CHECK QUEUE"); FileLog.d(a + " QUEUE UPDATES WAIT TIMEOUT - CHECK QUEUE");
} }
@ -5972,6 +5972,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("processLoadedMessages size " + messagesRes.messages.size() + " in chat " + dialogId + " count " + count + " max_id " + max_id + " cache " + isCache + " guid " + classGuid + " load_type " + load_type + " last_message_id " + last_message_id + " isChannel " + isChannel + " index " + loadIndex + " firstUnread " + first_unread + " unread_count " + unread_count + " last_date " + last_date + " queryFromServer " + queryFromServer); FileLog.d("processLoadedMessages size " + messagesRes.messages.size() + " in chat " + dialogId + " count " + count + " max_id " + max_id + " cache " + isCache + " guid " + classGuid + " load_type " + load_type + " last_message_id " + last_message_id + " isChannel " + isChannel + " index " + loadIndex + " firstUnread " + first_unread + " unread_count " + unread_count + " last_date " + last_date + " queryFromServer " + queryFromServer);
} }
long startProcessTime = SystemClock.elapsedRealtime();
boolean createDialog = false; boolean createDialog = false;
if (messagesRes instanceof TLRPC.TL_messages_channelMessages) { if (messagesRes instanceof TLRPC.TL_messages_channelMessages) {
int channelId = -(int) dialogId; int channelId = -(int) dialogId;
@ -6090,10 +6091,13 @@ public class MessagesController extends BaseController implements NotificationCe
final ArrayList<Integer> messagesToReload = new ArrayList<>(); final ArrayList<Integer> messagesToReload = new ArrayList<>();
final HashMap<String, ArrayList<MessageObject>> webpagesToReload = new HashMap<>(); final HashMap<String, ArrayList<MessageObject>> webpagesToReload = new HashMap<>();
TLRPC.InputChannel inputChannel = null; TLRPC.InputChannel inputChannel = null;
long fileProcessTime = 0;
for (int a = 0; a < size; a++) { for (int a = 0; a < size; a++) {
TLRPC.Message message = messagesRes.messages.get(a); TLRPC.Message message = messagesRes.messages.get(a);
message.dialog_id = dialogId; message.dialog_id = dialogId;
long checkFileTime = SystemClock.elapsedRealtime();
MessageObject messageObject = new MessageObject(currentAccount, message, usersDict, chatsDict, true, true); MessageObject messageObject = new MessageObject(currentAccount, message, usersDict, chatsDict, true, true);
fileProcessTime += (SystemClock.elapsedRealtime() - checkFileTime);
messageObject.scheduled = mode == 1; messageObject.scheduled = mode == 1;
objects.add(messageObject); objects.add(messageObject);
if (isCache) { if (isCache) {
@ -6118,6 +6122,9 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
} }
if (BuildVars.LOGS_ENABLED) {
FileLog.d("process time = " + (SystemClock.elapsedRealtime() - startProcessTime) + " file time = " + fileProcessTime + " for dialog = " + dialogId);
}
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
putUsers(messagesRes.users, isCache); putUsers(messagesRes.users, isCache);
putChats(messagesRes.chats, isCache); putChats(messagesRes.chats, isCache);
@ -7423,7 +7430,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
} else { } else {
if (newMsg == null && oldMsg.isSent() || newMsg != null && newMsg.messageOwner.date > oldMsg.messageOwner.date) { if (newMsg == null && oldMsg.getId() > 0 || newMsg != null && newMsg.messageOwner.date > oldMsg.messageOwner.date) {
dialogs_dict.put(key, value); dialogs_dict.put(key, value);
dialogMessage.put(key, newMsg); dialogMessage.put(key, newMsg);
if (oldMsg.messageOwner.peer_id.channel_id == 0) { if (oldMsg.messageOwner.peer_id.channel_id == 0) {
@ -12650,7 +12657,7 @@ public class MessagesController extends BaseController implements NotificationCe
TLRPC.TL_updateGroupCallParticipants update = (TLRPC.TL_updateGroupCallParticipants) baseUpdate; TLRPC.TL_updateGroupCallParticipants update = (TLRPC.TL_updateGroupCallParticipants) baseUpdate;
ChatObject.Call call = groupCalls.get(update.call.id); ChatObject.Call call = groupCalls.get(update.call.id);
if (call != null) { if (call != null) {
call.processParticipantsUpdate(getAccountInstance(), update); call.processParticipantsUpdate(update, false);
} }
if (VoIPService.getSharedInstance() != null) { if (VoIPService.getSharedInstance() != null) {
VoIPService.getSharedInstance().onGroupCallParticipantsUpdate(update); VoIPService.getSharedInstance().onGroupCallParticipantsUpdate(update);

View File

@ -9,6 +9,7 @@
package org.telegram.messenger; package org.telegram.messenger;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.SystemClock;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
@ -6042,6 +6043,7 @@ public class MessagesStorage extends BaseController {
boolean isEnd = false; boolean isEnd = false;
int num = dialogId == 777000 ? 10 : 1; int num = dialogId == 777000 ? 10 : 1;
int messagesCount = 0; int messagesCount = 0;
long startLoadTime = SystemClock.elapsedRealtime();
try { try {
ArrayList<Integer> usersToLoad = new ArrayList<>(); ArrayList<Integer> usersToLoad = new ArrayList<>();
ArrayList<Integer> chatsToLoad = new ArrayList<>(); ArrayList<Integer> chatsToLoad = new ArrayList<>();
@ -6724,6 +6726,9 @@ public class MessagesStorage extends BaseController {
res.users.clear(); res.users.clear();
FileLog.e(e); FileLog.e(e);
} }
if (BuildVars.LOGS_ENABLED) {
FileLog.d("messages load time = " + (SystemClock.elapsedRealtime() - startLoadTime) + " for dialog = " + dialogId);
}
int countQueryFinal = count_query; int countQueryFinal = count_query;
int maxIdOverrideFinal = max_id_override; int maxIdOverrideFinal = max_id_override;
int minUnreadIdFinal = min_unread_id; int minUnreadIdFinal = min_unread_id;
@ -8540,7 +8545,7 @@ public class MessagesStorage extends BaseController {
}); });
} }
private long[] updateMessageStateAndIdInternal(long random_id, Integer _oldId, int newId, int date, int channelId, int scheduled) { private long[] updateMessageStateAndIdInternal(long random_id, Long _oldId, int newId, int date, int channelId, int scheduled) {
SQLiteCursor cursor = null; SQLiteCursor cursor = null;
long oldMessageId; long oldMessageId;
long newMessageId = newId; long newMessageId = newId;
@ -8549,7 +8554,7 @@ public class MessagesStorage extends BaseController {
try { try {
cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid FROM randoms WHERE random_id = %d LIMIT 1", random_id)); cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid FROM randoms WHERE random_id = %d LIMIT 1", random_id));
if (cursor.next()) { if (cursor.next()) {
_oldId = cursor.intValue(0); _oldId = cursor.longValue(0);
} }
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
@ -8561,12 +8566,49 @@ public class MessagesStorage extends BaseController {
if (_oldId == null) { if (_oldId == null) {
return null; return null;
} }
if (channelId == 0) {
channelId = (int) (_oldId >> 32);
}
} }
oldMessageId = _oldId; oldMessageId = _oldId;
if (channelId != 0) { if (channelId != 0) {
oldMessageId |= ((long) channelId) << 32; oldMessageId |= ((long) channelId) << 32;
newMessageId |= ((long) channelId) << 32; newMessageId |= ((long) channelId) << 32;
} }
if (_oldId < 0 && scheduled == 1) {
SQLitePreparedStatement state = null;
try {
state = database.executeFast("UPDATE randoms SET mid = ? WHERE random_id = ? and mid = ?");
state.bindLong(1, newMessageId);
state.bindLong(2, random_id);
state.bindLong(3, oldMessageId);
state.step();
} catch (Exception e) {
FileLog.e(e);
} finally {
if (state != null) {
state.dispose();
}
}
} else if (_oldId > 0) {
TLRPC.TL_updateDeleteScheduledMessages update = new TLRPC.TL_updateDeleteScheduledMessages();
update.messages.add((int) oldMessageId);
if (channelId != 0) {
update.peer = new TLRPC.TL_peerChannel();
update.peer.channel_id = channelId;
} else {
update.peer = new TLRPC.TL_peerUser();
}
TLRPC.TL_updates updates = new TLRPC.TL_updates();
updates.updates.add(update);
Utilities.stageQueue.postRunnable(() -> getMessagesController().processUpdates(updates, false));
try {
database.executeFast(String.format(Locale.US, "DELETE FROM randoms WHERE random_id = %d AND mid = %d", random_id, _oldId)).stepThis().dispose();
} catch (Exception e) {
FileLog.e(e);
}
return null;
}
long did = 0; long did = 0;
if (scheduled == -1 || scheduled == 0) { if (scheduled == -1 || scheduled == 0) {
@ -8697,7 +8739,7 @@ public class MessagesStorage extends BaseController {
} }
} }
public long[] updateMessageStateAndId(final long random_id, final Integer _oldId, final int newId, final int date, boolean useQueue, final int channelId, int scheduled) { public long[] updateMessageStateAndId(final long random_id, final Long _oldId, final int newId, final int date, boolean useQueue, final int channelId, int scheduled) {
if (useQueue) { if (useQueue) {
storageQueue.postRunnable(() -> updateMessageStateAndIdInternal(random_id, _oldId, newId, date, channelId, scheduled)); storageQueue.postRunnable(() -> updateMessageStateAndIdInternal(random_id, _oldId, newId, date, channelId, scheduled));
} else { } else {

View File

@ -2562,7 +2562,7 @@ public class NotificationsController extends BaseController {
return; return;
} }
notificationsQueue.postRunnable(() -> { notificationsQueue.postRunnable(() -> {
if (Math.abs(System.currentTimeMillis() - lastSoundPlay) <= 500) { if (Math.abs(SystemClock.elapsedRealtime() - lastSoundPlay) <= 500) {
return; return;
} }
try { try {
@ -2807,20 +2807,54 @@ public class NotificationsController extends BaseController {
protected void ensureGroupsCreated() { protected void ensureGroupsCreated() {
SharedPreferences preferences = getAccountInstance().getNotificationsSettings(); SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
if (groupsCreated == null) { if (groupsCreated == null) {
groupsCreated = preferences.getBoolean("groupsCreated", false); groupsCreated = preferences.getBoolean("groupsCreated4", false);
} }
if (!groupsCreated) { if (!groupsCreated) {
try { try {
String keyStart = currentAccount + "channel"; String keyStart = currentAccount + "channel";
List<NotificationChannel> list = systemNotificationManager.getNotificationChannels(); List<NotificationChannel> list = systemNotificationManager.getNotificationChannels();
int count = list.size(); int count = list.size();
SharedPreferences.Editor editor = null;
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
NotificationChannel channel = list.get(a); NotificationChannel channel = list.get(a);
String id = channel.getId(); String id = channel.getId();
if (id.startsWith(keyStart)) { if (id.startsWith(keyStart)) {
int importance = channel.getImportance();
if (importance != NotificationManager.IMPORTANCE_HIGH && importance != NotificationManager.IMPORTANCE_MAX) { //TODO remove after some time, 7.3.0 bug fix
if (id.contains("_ia_")) {
//do nothing
} else if (id.contains("_channels_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_channel").remove("vibrate_channel").remove("ChannelSoundPath").remove("ChannelSound");
} else if (id.contains("_groups_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_group").remove("vibrate_group").remove("GroupSoundPath").remove("GroupSound");
} else if (id.contains("_private_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_messages");
editor.remove("priority_group").remove("vibrate_messages").remove("GlobalSoundPath").remove("GlobalSound");
} else {
long dialogId = Utilities.parseLong(id.substring(9, id.indexOf('_', 9)));
if (dialogId != 0) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_" + dialogId).remove("vibrate_" + dialogId).remove("sound_path_" + dialogId).remove("sound_" + dialogId);
}
}
}
systemNotificationManager.deleteNotificationChannel(id); systemNotificationManager.deleteNotificationChannel(id);
} }
} }
if (editor != null) {
editor.commit();
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
@ -2834,13 +2868,15 @@ public class NotificationsController extends BaseController {
} else { } else {
userName = ""; userName = "";
} }
systemNotificationManager.createNotificationChannelGroups(Arrays.asList( systemNotificationManager.createNotificationChannelGroups(Arrays.asList(
new NotificationChannelGroup("channels" + currentAccount, LocaleController.getString("NotificationsChannels", R.string.NotificationsChannels) + userName), new NotificationChannelGroup("channels" + currentAccount, LocaleController.getString("NotificationsChannels", R.string.NotificationsChannels) + userName),
new NotificationChannelGroup("groups" + currentAccount, LocaleController.getString("NotificationsGroups", R.string.NotificationsGroups) + userName), new NotificationChannelGroup("groups" + currentAccount, LocaleController.getString("NotificationsGroups", R.string.NotificationsGroups) + userName),
new NotificationChannelGroup("private" + currentAccount, LocaleController.getString("NotificationsPrivateChats", R.string.NotificationsPrivateChats) + userName), new NotificationChannelGroup("private" + currentAccount, LocaleController.getString("NotificationsPrivateChats", R.string.NotificationsPrivateChats) + userName),
new NotificationChannelGroup("other" + currentAccount, LocaleController.getString("NotificationsOther", R.string.NotificationsOther) + userName) new NotificationChannelGroup("other" + currentAccount, LocaleController.getString("NotificationsOther", R.string.NotificationsOther) + userName)
)); ));
preferences.edit().putBoolean("groupsCreated", true).commit();
preferences.edit().putBoolean("groupsCreated4", true).commit();
groupsCreated = true; groupsCreated = true;
} }
} }
@ -2891,184 +2927,192 @@ public class NotificationsController extends BaseController {
StringBuilder newSettings = new StringBuilder(); StringBuilder newSettings = new StringBuilder();
String newSettingsHash = null; String newSettingsHash = null;
if (!isSilent && channelId != null) { if (channelId != null) {
NotificationChannel existingChannel = systemNotificationManager.getNotificationChannel(channelId); NotificationChannel existingChannel = systemNotificationManager.getNotificationChannel(channelId);
if (existingChannel != null) { if (existingChannel != null) {
int channelImportance = existingChannel.getImportance(); if (!isSilent) {
Uri channelSound = existingChannel.getSound(); int channelImportance = existingChannel.getImportance();
long[] channelVibrationPattern = existingChannel.getVibrationPattern(); Uri channelSound = existingChannel.getSound();
int channelLedColor = existingChannel.getLightColor(); long[] channelVibrationPattern = existingChannel.getVibrationPattern();
if (channelVibrationPattern != null) { boolean vibrate = existingChannel.shouldVibrate();
for (int a = 0; a < channelVibrationPattern.length; a++) { if (!vibrate && channelVibrationPattern == null) {
newSettings.append(channelVibrationPattern[a]); channelVibrationPattern = new long[]{0, 0};
} }
} int channelLedColor = existingChannel.getLightColor();
newSettings.append(channelLedColor); if (channelVibrationPattern != null) {
if (channelSound != null) { for (int a = 0; a < channelVibrationPattern.length; a++) {
newSettings.append(channelSound.toString()); newSettings.append(channelVibrationPattern[a]);
}
newSettings.append(channelImportance);
if (secretChat) {
newSettings.append("secret");
}
newSettingsHash = Utilities.MD5(newSettings.toString());
newSettings.setLength(0);
if (!settings.equals(newSettingsHash)) {
SharedPreferences.Editor editor = null;
if (channelImportance == NotificationManager.IMPORTANCE_NONE) {
editor = preferences.edit();
if (isDefault) {
if (!isInApp) {
editor.putInt(getGlobalNotificationsKey(type), Integer.MAX_VALUE);
updateServerNotificationsSettings(type);
}
} else {
editor.putInt("notify2_" + dialogId, 2);
updateServerNotificationsSettings(dialogId, true);
} }
edited = true; }
} else if (channelImportance != importance) { newSettings.append(channelLedColor);
if (!isInApp) { if (channelSound != null) {
newSettings.append(channelSound.toString());
}
newSettings.append(channelImportance);
if (!isDefault && secretChat) {
newSettings.append("secret");
}
newSettingsHash = Utilities.MD5(newSettings.toString());
newSettings.setLength(0);
if (!newSettingsHash.equals(settings)) {
SharedPreferences.Editor editor = null;
if (channelImportance == NotificationManager.IMPORTANCE_NONE) {
editor = preferences.edit(); editor = preferences.edit();
int priority;
if (channelImportance == NotificationManager.IMPORTANCE_HIGH || channelImportance == NotificationManager.IMPORTANCE_MAX) {
priority = 1;
} else if (channelImportance == NotificationManager.IMPORTANCE_MIN) {
priority = 4;
} else if (channelImportance == NotificationManager.IMPORTANCE_LOW) {
priority = 5;
} else {
priority = 0;
}
if (isDefault) { if (isDefault) {
editor.putInt(getGlobalNotificationsKey(type), 0).commit(); if (!isInApp) {
if (type == TYPE_CHANNEL) { editor.putInt(getGlobalNotificationsKey(type), Integer.MAX_VALUE);
editor.putInt("priority_channel", priority); updateServerNotificationsSettings(type);
} else if (type == TYPE_GROUP) {
editor.putInt("priority_group", priority);
} else {
editor.putInt("priority_messages", priority);
} }
} else { } else {
editor.putInt("notify2_" + dialogId, 0); editor.putInt("notify2_" + dialogId, 2);
editor.remove("notifyuntil_" + dialogId); updateServerNotificationsSettings(dialogId, true);
editor.putInt("priority_" + dialogId, priority);
} }
} edited = true;
edited = true; } else if (channelImportance != importance) {
} if (!isInApp) {
if (channelSound == null && sound != null || channelSound != null && (sound == null || !TextUtils.equals(channelSound.toString(), sound.toString()))) {
if (!isInApp) {
if (editor == null) {
editor = preferences.edit(); editor = preferences.edit();
} int priority;
String newSound; if (channelImportance == NotificationManager.IMPORTANCE_HIGH || channelImportance == NotificationManager.IMPORTANCE_MAX) {
if (channelSound == null) { priority = 1;
newSound = "NoSound"; } else if (channelImportance == NotificationManager.IMPORTANCE_MIN) {
priority = 4;
} else if (channelImportance == NotificationManager.IMPORTANCE_LOW) {
priority = 5;
} else {
priority = 0;
}
if (isDefault) { if (isDefault) {
editor.putInt(getGlobalNotificationsKey(type), 0).commit();
if (type == TYPE_CHANNEL) { if (type == TYPE_CHANNEL) {
editor.putString("ChannelSound", "NoSound"); editor.putInt("priority_channel", priority);
} else if (type == TYPE_GROUP) { } else if (type == TYPE_GROUP) {
editor.putString("GroupSound", "NoSound"); editor.putInt("priority_group", priority);
} else { } else {
editor.putString("GlobalSound", "NoSound"); editor.putInt("priority_messages", priority);
} }
} else { } else {
editor.putString("sound_" + dialogId, "NoSound"); editor.putInt("notify2_" + dialogId, 0);
editor.remove("notifyuntil_" + dialogId);
editor.putInt("priority_" + dialogId, priority);
} }
} else { }
newSound = channelSound.toString(); edited = true;
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, channelSound); }
String ringtoneName = null; if (channelSound == null && sound != null || channelSound != null && (sound == null || !TextUtils.equals(channelSound.toString(), sound.toString()))) {
if (rng != null) { if (!isInApp) {
if (channelSound.equals(Settings.System.DEFAULT_RINGTONE_URI)) { if (editor == null) {
ringtoneName = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); editor = preferences.edit();
} else {
ringtoneName = rng.getTitle(ApplicationLoader.applicationContext);
}
rng.stop();
} }
if (ringtoneName != null) { String newSound;
if (channelSound == null) {
newSound = "NoSound";
if (isDefault) { if (isDefault) {
if (type == TYPE_CHANNEL) { if (type == TYPE_CHANNEL) {
editor.putString("ChannelSound", ringtoneName); editor.putString("ChannelSound", "NoSound");
} else if (type == TYPE_GROUP) { } else if (type == TYPE_GROUP) {
editor.putString("GroupSound", ringtoneName); editor.putString("GroupSound", "NoSound");
} else { } else {
editor.putString("GlobalSound", ringtoneName); editor.putString("GlobalSound", "NoSound");
} }
} else { } else {
editor.putString("sound_" + dialogId, ringtoneName); editor.putString("sound_" + dialogId, "NoSound");
}
} else {
newSound = channelSound.toString();
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, channelSound);
String ringtoneName = null;
if (rng != null) {
if (channelSound.equals(Settings.System.DEFAULT_RINGTONE_URI)) {
ringtoneName = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone);
} else {
ringtoneName = rng.getTitle(ApplicationLoader.applicationContext);
}
rng.stop();
}
if (ringtoneName != null) {
if (isDefault) {
if (type == TYPE_CHANNEL) {
editor.putString("ChannelSound", ringtoneName);
} else if (type == TYPE_GROUP) {
editor.putString("GroupSound", ringtoneName);
} else {
editor.putString("GlobalSound", ringtoneName);
}
} else {
editor.putString("sound_" + dialogId, ringtoneName);
}
} }
} }
} if (isDefault) {
if (isDefault) { if (type == TYPE_CHANNEL) {
if (type == TYPE_CHANNEL) { editor.putString("ChannelSoundPath", newSound);
editor.putString("ChannelSoundPath", newSound); } else if (type == TYPE_GROUP) {
} else if (type == TYPE_GROUP) { editor.putString("GroupSoundPath", newSound);
editor.putString("GroupSoundPath", newSound); } else {
editor.putString("GlobalSoundPath", newSound);
}
} else { } else {
editor.putString("GlobalSoundPath", newSound); editor.putString("sound_path_" + dialogId, newSound);
} }
} else {
editor.putString("sound_path_" + dialogId, newSound);
} }
sound = channelSound;
edited = true;
} }
sound = channelSound; boolean hasVibration = !isEmptyVibration(vibrationPattern);
edited = true; if (hasVibration != vibrate) {
} if (!isInApp) {
boolean vibrate = existingChannel.shouldVibrate(); if (editor == null) {
boolean hasVibration = !isEmptyVibration(vibrationPattern); editor = preferences.edit();
if (hasVibration != vibrate) { }
if (!isInApp) { if (isDefault) {
if (editor == null) { if (type == TYPE_CHANNEL) {
editor = preferences.edit(); editor.putInt("vibrate_channel", vibrate ? 0 : 2);
} } else if (type == TYPE_GROUP) {
if (isDefault) { editor.putInt("vibrate_group", vibrate ? 0 : 2);
if (type == TYPE_CHANNEL) { } else {
editor.putInt("vibrate_channel", vibrate ? 0 : 2); editor.putInt("vibrate_messages", vibrate ? 0 : 2);
} else if (type == TYPE_GROUP) { }
editor.putInt("vibrate_group", vibrate ? 0 : 2);
} else { } else {
editor.putInt("vibrate_messages", vibrate ? 0 : 2); editor.putInt("vibrate_" + dialogId, vibrate ? 0 : 2);
} }
} else {
editor.putInt("vibrate_" + dialogId, vibrate ? 0 : 2);
} }
vibrationPattern = channelVibrationPattern;
edited = true;
} }
vibrationPattern = new long[]{}; if (channelLedColor != ledColor) {
edited = true; if (!isInApp) {
} if (editor == null) {
if (channelLedColor != ledColor) { editor = preferences.edit();
if (!isInApp) { }
if (editor == null) { if (isDefault) {
editor = preferences.edit(); if (type == TYPE_CHANNEL) {
} editor.putInt("ChannelLed", channelLedColor);
if (isDefault) { } else if (type == TYPE_GROUP) {
if (type == TYPE_CHANNEL) { editor.putInt("GroupLed", channelLedColor);
editor.putInt("ChannelLed", channelLedColor); } else {
} else if (type == TYPE_GROUP) { editor.putInt("MessagesLed", channelLedColor);
editor.putInt("GroupLed", channelLedColor); }
} else { } else {
editor.putInt("MessagesLed", channelLedColor); editor.putInt("color_" + dialogId, channelLedColor);
} }
} else {
editor.putInt("color_" + dialogId, channelLedColor);
} }
ledColor = channelLedColor;
edited = true;
}
if (editor != null) {
editor.commit();
} }
ledColor = channelLedColor;
edited = true;
}
if (editor != null) {
editor.commit();
} }
} }
} else {
channelId = null;
settings = null;
} }
} }
if (edited && newSettingsHash != null) { if (edited && newSettingsHash != null) {
preferences.edit().putString(key, channelId).putString(key + "_s", newSettingsHash).commit(); preferences.edit().putString(key, channelId).putString(key + "_s", newSettingsHash).commit();
} else if (!isInApp || !isDefault) { } else if (newSettingsHash == null || !isInApp || !isDefault) {
for (int a = 0; a < vibrationPattern.length; a++) { for (int a = 0; a < vibrationPattern.length; a++) {
newSettings.append(vibrationPattern[a]); newSettings.append(vibrationPattern[a]);
} }
@ -3077,12 +3121,12 @@ public class NotificationsController extends BaseController {
newSettings.append(sound.toString()); newSettings.append(sound.toString());
} }
newSettings.append(importance); newSettings.append(importance);
if (secretChat) { if (!isDefault && secretChat) {
newSettings.append("secret"); newSettings.append("secret");
} }
newSettingsHash = Utilities.MD5(newSettings.toString()); newSettingsHash = Utilities.MD5(newSettings.toString());
if (channelId != null && !settings.equals(newSettingsHash)) { if (!isSilent && channelId != null && !settings.equals(newSettingsHash)) {
systemNotificationManager.deleteNotificationChannel(channelId); systemNotificationManager.deleteNotificationChannel(channelId);
channelId = null; channelId = null;
} }
@ -3182,7 +3226,113 @@ public class NotificationsController extends BaseController {
} else { } else {
value = notifyOverride != 2; value = notifyOverride != 2;
} }
if (!notifyAboutLast || !value) {
String name;
String chatName;
boolean replace = true;
if (((chat_id != 0 && chat == null) || user == null) && lastMessageObject.isFcmMessage()) {
chatName = lastMessageObject.localName;
} else if (chat != null) {
chatName = chat.title;
} else {
chatName = UserObject.getUserName(user);
}
boolean passcode = AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter;
if ((int) dialog_id == 0 || pushDialogs.size() > 1 || passcode) {
if (passcode) {
if (chat_id != 0) {
name = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
} else {
name = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
} else {
name = LocaleController.getString("AppName", R.string.AppName);
}
replace = false;
} else {
name = chatName;
}
String detailText;
if (UserConfig.getActivatedAccountsCount() > 1) {
if (pushDialogs.size() == 1) {
detailText = UserObject.getFirstName(getUserConfig().getCurrentUser());
} else {
detailText = UserObject.getFirstName(getUserConfig().getCurrentUser()) + "";
}
} else {
detailText = "";
}
if (pushDialogs.size() != 1 || Build.VERSION.SDK_INT < 23) {
if (pushDialogs.size() == 1) {
detailText += LocaleController.formatPluralString("NewMessages", total_unread_count);
} else {
detailText += LocaleController.formatString("NotificationMessagesPeopleDisplayOrder", R.string.NotificationMessagesPeopleDisplayOrder, LocaleController.formatPluralString("NewMessages", total_unread_count), LocaleController.formatPluralString("FromChats", pushDialogs.size()));
}
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
int silent = 2;
String lastMessage = null;
boolean hasNewMessages = false;
if (pushMessages.size() == 1) {
MessageObject messageObject = pushMessages.get(0);
boolean[] text = new boolean[1];
String message = lastMessage = getStringForMessage(messageObject, false, text, null);
silent = messageObject.messageOwner.silent ? 1 : 0;
if (message == null) {
return;
}
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
if (text[0]) {
message = message.replace(name + ": ", "");
} else {
message = message.replace(name + " ", "");
}
}
}
mBuilder.setContentText(message);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
mBuilder.setContentText(detailText);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(name);
int count = Math.min(10, pushMessages.size());
boolean[] text = new boolean[1];
for (int i = 0; i < count; i++) {
MessageObject messageObject = pushMessages.get(i);
String message = getStringForMessage(messageObject, false, text, null);
if (message == null || messageObject.messageOwner.date <= dismissDate) {
continue;
}
if (silent == 2) {
lastMessage = message;
silent = messageObject.messageOwner.silent ? 1 : 0;
}
if (pushDialogs.size() == 1) {
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
if (text[0]) {
message = message.replace(name + ": ", "");
} else {
message = message.replace(name + " ", "");
}
}
}
}
inboxStyle.addLine(message);
}
inboxStyle.setSummaryText(detailText);
mBuilder.setStyle(inboxStyle);
}
if (!notifyAboutLast || !value || MediaController.getInstance().isRecordingAudio() || silent == 1) {
notifyDisabled = true; notifyDisabled = true;
} }
@ -3199,16 +3349,16 @@ public class NotificationsController extends BaseController {
if (notifyMaxCount != 0) { if (notifyMaxCount != 0) {
Point dialogInfo = smartNotificationsDialogs.get(dialog_id); Point dialogInfo = smartNotificationsDialogs.get(dialog_id);
if (dialogInfo == null) { if (dialogInfo == null) {
dialogInfo = new Point(1, (int) (System.currentTimeMillis() / 1000)); dialogInfo = new Point(1, (int) (SystemClock.elapsedRealtime() / 1000));
smartNotificationsDialogs.put(dialog_id, dialogInfo); smartNotificationsDialogs.put(dialog_id, dialogInfo);
} else { } else {
int lastTime = dialogInfo.y; int lastTime = dialogInfo.y;
if (lastTime + notifyDelay < System.currentTimeMillis() / 1000) { if (lastTime + notifyDelay < SystemClock.elapsedRealtime() / 1000) {
dialogInfo.set(1, (int) (System.currentTimeMillis() / 1000)); dialogInfo.set(1, (int) (SystemClock.elapsedRealtime() / 1000));
} else { } else {
int count = dialogInfo.x; int count = dialogInfo.x;
if (count < notifyMaxCount) { if (count < notifyMaxCount) {
dialogInfo.set(count + 1, (int) (System.currentTimeMillis() / 1000)); dialogInfo.set(count + 1, (int) (SystemClock.elapsedRealtime() / 1000));
} else { } else {
notifyDisabled = true; notifyDisabled = true;
} }
@ -3350,52 +3500,7 @@ public class NotificationsController extends BaseController {
intent.putExtra("currentAccount", currentAccount); intent.putExtra("currentAccount", currentAccount);
PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT);
String name; mBuilder.setContentTitle(name)
String chatName;
boolean replace = true;
if (((chat_id != 0 && chat == null) || user == null) && lastMessageObject.isFcmMessage()) {
chatName = lastMessageObject.localName;
} else if (chat != null) {
chatName = chat.title;
} else {
chatName = UserObject.getUserName(user);
}
boolean passcode = AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter;
if ((int) dialog_id == 0 || pushDialogs.size() > 1 || passcode) {
if (passcode) {
if (chat_id != 0) {
name = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
} else {
name = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
} else {
name = LocaleController.getString("AppName", R.string.AppName);
}
replace = false;
} else {
name = chatName;
}
String detailText;
if (UserConfig.getActivatedAccountsCount() > 1) {
if (pushDialogs.size() == 1) {
detailText = UserObject.getFirstName(getUserConfig().getCurrentUser());
} else {
detailText = UserObject.getFirstName(getUserConfig().getCurrentUser()) + "";
}
} else {
detailText = "";
}
if (pushDialogs.size() != 1 || Build.VERSION.SDK_INT < 23) {
if (pushDialogs.size() == 1) {
detailText += LocaleController.formatPluralString("NewMessages", total_unread_count);
} else {
detailText += LocaleController.formatString("NotificationMessagesPeopleDisplayOrder", R.string.NotificationMessagesPeopleDisplayOrder, LocaleController.formatPluralString("NewMessages", total_unread_count), LocaleController.formatPluralString("FromChats", pushDialogs.size()));
}
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ApplicationLoader.applicationContext)
.setContentTitle(name)
.setSmallIcon(R.drawable.notification) .setSmallIcon(R.drawable.notification)
.setAutoCancel(true) .setAutoCancel(true)
.setNumber(total_unread_count) .setNumber(total_unread_count)
@ -3414,65 +3519,6 @@ public class NotificationsController extends BaseController {
mBuilder.addPerson("tel:+" + user.phone); mBuilder.addPerson("tel:+" + user.phone);
} }
int silent = 2;
String lastMessage = null;
boolean hasNewMessages = false;
if (pushMessages.size() == 1) {
MessageObject messageObject = pushMessages.get(0);
boolean[] text = new boolean[1];
String message = lastMessage = getStringForMessage(messageObject, false, text, null);
silent = messageObject.messageOwner.silent ? 1 : 0;
if (message == null) {
return;
}
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
if (text[0]) {
message = message.replace(name + ": ", "");
} else {
message = message.replace(name + " ", "");
}
}
}
mBuilder.setContentText(message);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
mBuilder.setContentText(detailText);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(name);
int count = Math.min(10, pushMessages.size());
boolean[] text = new boolean[1];
for (int i = 0; i < count; i++) {
MessageObject messageObject = pushMessages.get(i);
String message = getStringForMessage(messageObject, false, text, null);
if (message == null || messageObject.messageOwner.date <= dismissDate) {
continue;
}
if (silent == 2) {
lastMessage = message;
silent = messageObject.messageOwner.silent ? 1 : 0;
}
if (pushDialogs.size() == 1) {
if (replace) {
if (chat != null) {
message = message.replace(" @ " + name, "");
} else {
if (text[0]) {
message = message.replace(name + ": ", "");
} else {
message = message.replace(name + " ", "");
}
}
}
}
inboxStyle.addLine(message);
}
inboxStyle.setSummaryText(detailText);
mBuilder.setStyle(inboxStyle);
}
Intent dismissIntent = new Intent(ApplicationLoader.applicationContext, NotificationDismissReceiver.class); Intent dismissIntent = new Intent(ApplicationLoader.applicationContext, NotificationDismissReceiver.class);
dismissIntent.putExtra("messageDate", lastMessageObject.messageOwner.date); dismissIntent.putExtra("messageDate", lastMessageObject.messageOwner.date);
dismissIntent.putExtra("currentAccount", currentAccount); dismissIntent.putExtra("currentAccount", currentAccount);
@ -3537,29 +3583,27 @@ public class NotificationsController extends BaseController {
} }
mBuilder.setTicker(lastMessage); mBuilder.setTicker(lastMessage);
} }
if (!MediaController.getInstance().isRecordingAudio()) { if (soundPath != null && !soundPath.equals("NoSound")) {
if (soundPath != null && !soundPath.equals("NoSound")) { if (Build.VERSION.SDK_INT >= 26) {
if (Build.VERSION.SDK_INT >= 26) { if (soundPath.equals(defaultPath)) {
if (soundPath.equals(defaultPath)) { sound = Settings.System.DEFAULT_NOTIFICATION_URI;
sound = Settings.System.DEFAULT_NOTIFICATION_URI;
} else {
sound = Uri.parse(soundPath);
}
} else { } else {
if (soundPath.equals(defaultPath)) { sound = Uri.parse(soundPath);
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, AudioManager.STREAM_NOTIFICATION); }
} else { } else {
if (Build.VERSION.SDK_INT >= 24 && soundPath.startsWith("file://") && !AndroidUtilities.isInternalUri(Uri.parse(soundPath))) { if (soundPath.equals(defaultPath)) {
try { mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, AudioManager.STREAM_NOTIFICATION);
Uri uri = FileProvider.getUriForFile(ApplicationLoader.applicationContext, BuildConfig.APPLICATION_ID + ".provider", new File(soundPath.replace("file://", ""))); } else {
ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT >= 24 && soundPath.startsWith("file://") && !AndroidUtilities.isInternalUri(Uri.parse(soundPath))) {
mBuilder.setSound(uri, AudioManager.STREAM_NOTIFICATION); try {
} catch (Exception e) { Uri uri = FileProvider.getUriForFile(ApplicationLoader.applicationContext, BuildConfig.APPLICATION_ID + ".provider", new File(soundPath.replace("file://", "")));
mBuilder.setSound(Uri.parse(soundPath), AudioManager.STREAM_NOTIFICATION); ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
} mBuilder.setSound(uri, AudioManager.STREAM_NOTIFICATION);
} else { } catch (Exception e) {
mBuilder.setSound(Uri.parse(soundPath), AudioManager.STREAM_NOTIFICATION); mBuilder.setSound(Uri.parse(soundPath), AudioManager.STREAM_NOTIFICATION);
} }
} else {
mBuilder.setSound(Uri.parse(soundPath), AudioManager.STREAM_NOTIFICATION);
} }
} }
} }
@ -3567,7 +3611,7 @@ public class NotificationsController extends BaseController {
if (ledColor != 0) { if (ledColor != 0) {
mBuilder.setLights(ledColor, 1000, 1000); mBuilder.setLights(ledColor, 1000, 1000);
} }
if (vibrate == 2 || MediaController.getInstance().isRecordingAudio()) { if (vibrate == 2) {
mBuilder.setVibrate(vibrationPattern = new long[]{0, 0}); mBuilder.setVibrate(vibrationPattern = new long[]{0, 0});
} else if (vibrate == 1) { } else if (vibrate == 1) {
mBuilder.setVibrate(vibrationPattern = new long[]{0, 100, 0, 100}); mBuilder.setVibrate(vibrationPattern = new long[]{0, 100, 0, 100});
@ -3617,7 +3661,7 @@ public class NotificationsController extends BaseController {
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26) {
mBuilder.setChannelId(validateChannelId(dialog_id, chatName, vibrationPattern, ledColor, sound, configImportance, isDefault, isInApp, notifyDisabled, chatType)); mBuilder.setChannelId(validateChannelId(dialog_id, chatName, vibrationPattern, ledColor, sound, configImportance, isDefault, isInApp, notifyDisabled, chatType));
} }
showExtraNotifications(mBuilder, notifyAboutLast, detailText); showExtraNotifications(mBuilder, detailText);
scheduleNotificationRepeat(); scheduleNotificationRepeat();
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
@ -3634,7 +3678,7 @@ public class NotificationsController extends BaseController {
} }
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
private void showExtraNotifications(NotificationCompat.Builder notificationBuilder, boolean notifyAboutLast, String summary) { private void showExtraNotifications(NotificationCompat.Builder notificationBuilder, String summary) {
Notification mainNotification = notificationBuilder.build(); Notification mainNotification = notificationBuilder.build();
if (Build.VERSION.SDK_INT < 18) { if (Build.VERSION.SDK_INT < 18) {
notificationManager.notify(notificationId, mainNotification); notificationManager.notify(notificationId, mainNotification);
@ -4341,10 +4385,10 @@ public class NotificationsController extends BaseController {
} }
notificationsQueue.postRunnable(() -> { notificationsQueue.postRunnable(() -> {
try { try {
if (Math.abs(System.currentTimeMillis() - lastSoundOutPlay) <= 100) { if (Math.abs(SystemClock.elapsedRealtime() - lastSoundOutPlay) <= 100) {
return; return;
} }
lastSoundOutPlay = System.currentTimeMillis(); lastSoundOutPlay = SystemClock.elapsedRealtime();
if (soundPool == null) { if (soundPool == null) {
soundPool = new SoundPool(3, AudioManager.STREAM_SYSTEM, 0); soundPool = new SoundPool(3, AudioManager.STREAM_SYSTEM, 0);
soundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> { soundPool.setOnLoadCompleteListener((soundPool, sampleId, status) -> {

View File

@ -765,7 +765,7 @@ public class SecretChatHelper extends BaseController {
if (isSecretInvisibleMessage(newMsgObj)) { if (isSecretInvisibleMessage(newMsgObj)) {
res.date = 0; res.date = 0;
} }
getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, newMsgObj.id, newMsgObj.id, res.date, false, 0, 0); getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, (long) newMsgObj.id, newMsgObj.id, res.date, false, 0, 0);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, 0L, existFlags, false); getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, 0L, existFlags, false);

View File

@ -1646,7 +1646,7 @@ public boolean retriedToSend;
}); });
} else { } else {
getMessagesStorage().getStorageQueue().postRunnable(() -> { getMessagesStorage().getStorageQueue().postRunnable(() -> {
getMessagesStorage().updateMessageStateAndId(newMsgObj1.random_id, oldId, newMsgObj1.id, 0, false, peer_id.channel_id, scheduleDate != 0 ? 1 : 0); getMessagesStorage().updateMessageStateAndId(newMsgObj1.random_id, (long) oldId, newMsgObj1.id, 0, false, peer_id.channel_id, scheduleDate != 0 ? 1 : 0);
getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduleDate != 0); getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduleDate != 0);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
newMsgObj1.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj1.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
@ -4606,7 +4606,7 @@ public boolean retriedToSend;
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled); getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled);
getMessagesStorage().getStorageQueue().postRunnable(() -> { getMessagesStorage().getStorageQueue().postRunnable(() -> {
getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false, newMsgObj.peer_id.channel_id, scheduled ? 1 : 0); getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, (long) oldId, newMsgObj.id, 0, false, newMsgObj.peer_id.channel_id, scheduled ? 1 : 0);
getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled); getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id); getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id);
@ -4908,7 +4908,7 @@ public boolean retriedToSend;
} else { } else {
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, 0L, existFlags, scheduled); getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, 0L, existFlags, scheduled);
getMessagesStorage().getStorageQueue().postRunnable(() -> { getMessagesStorage().getStorageQueue().postRunnable(() -> {
getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false, newMsgObj.peer_id.channel_id, scheduled ? 1 : 0); getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, (long) oldId, newMsgObj.id, 0, false, newMsgObj.peer_id.channel_id, scheduled ? 1 : 0);
getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled); getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id); getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id);

View File

@ -119,6 +119,7 @@ public class SharedConfig {
public static boolean saveStreamMedia = true; public static boolean saveStreamMedia = true;
public static boolean smoothKeyboard = true; public static boolean smoothKeyboard = true;
public static boolean pauseMusicOnRecord = true; public static boolean pauseMusicOnRecord = true;
public static boolean noStatusBar;
public static boolean sortContactsByName; public static boolean sortContactsByName;
public static boolean sortFilesByName; public static boolean sortFilesByName;
public static boolean shuffleMusic; public static boolean shuffleMusic;
@ -1016,6 +1017,7 @@ public class SharedConfig {
devicePerformanceClass = preferences.getInt("devicePerformanceClass", -1); devicePerformanceClass = preferences.getInt("devicePerformanceClass", -1);
loopStickers = preferences.getBoolean("loopStickers", true); loopStickers = preferences.getBoolean("loopStickers", true);
keepMedia = preferences.getInt("keep_media", 2); keepMedia = preferences.getInt("keep_media", 2);
noStatusBar = preferences.getBoolean("noStatusBar", false);
lastKeepMediaCheckTime = preferences.getInt("lastKeepMediaCheckTime", 0); lastKeepMediaCheckTime = preferences.getInt("lastKeepMediaCheckTime", 0);
searchMessagesAsListHintShows = preferences.getInt("searchMessagesAsListHintShows", 0); searchMessagesAsListHintShows = preferences.getInt("searchMessagesAsListHintShows", 0);
searchMessagesAsListUsed = preferences.getBoolean("searchMessagesAsListUsed", false); searchMessagesAsListUsed = preferences.getBoolean("searchMessagesAsListUsed", false);
@ -1283,6 +1285,14 @@ public class SharedConfig {
editor.commit(); editor.commit();
} }
public static void toggleNoStatusBar() {
noStatusBar = !noStatusBar;
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("noStatusBar", noStatusBar);
editor.commit();
}
public static void toggleLoopStickers() { public static void toggleLoopStickers() {
loopStickers = !loopStickers; loopStickers = !loopStickers;
SharedPreferences preferences = MessagesController.getGlobalMainSettings(); SharedPreferences preferences = MessagesController.getGlobalMainSettings();

View File

@ -35,6 +35,7 @@ import android.widget.Toast;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars; import org.telegram.messenger.BuildVars;
@ -860,32 +861,6 @@ public class VoIPService extends VoIPBaseService {
req.reason = new TLRPC.TL_phoneCallDiscardReasonHangup(); req.reason = new TLRPC.TL_phoneCallDiscardReasonHangup();
break; break;
} }
final boolean wasNotConnected = ConnectionsManager.getInstance(currentAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected;
final Runnable stopper;
if (wasNotConnected) {
if (onDone != null) {
onDone.run();
}
callEnded();
stopper = null;
} else {
stopper = new Runnable() {
private boolean done = false;
@Override
public void run() {
if (done) {
return;
}
done = true;
if (onDone != null) {
onDone.run();
}
callEnded();
}
};
AndroidUtilities.runOnUIThread(stopper, (int) (Instance.getGlobalServerConfig().hangupUiTimeout * 1000));
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (error != null) { if (error != null) {
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
@ -900,13 +875,9 @@ public class VoIPService extends VoIPBaseService {
FileLog.d("phone.discardCall " + response); FileLog.d("phone.discardCall " + response);
} }
} }
if (!wasNotConnected) {
AndroidUtilities.cancelRunOnUIThread(stopper);
if (onDone != null) {
onDone.run();
}
}
}, ConnectionsManager.RequestFlagFailOnServerErrors); }, ConnectionsManager.RequestFlagFailOnServerErrors);
onDestroyRunnable = onDone;
callEnded();
} }
public void onSignalingData(TLRPC.TL_updatePhoneCallSignalingData data) { public void onSignalingData(TLRPC.TL_updatePhoneCallSignalingData data) {
@ -1222,7 +1193,7 @@ public class VoIPService extends VoIPBaseService {
groupCall.call.version = 1; groupCall.call.version = 1;
groupCall.call.can_change_join_muted = true; groupCall.call.can_change_join_muted = true;
groupCall.chatId = chat.id; groupCall.chatId = chat.id;
groupCall.currentAccount = currentAccount; groupCall.currentAccount = AccountInstance.getInstance(currentAccount);
dispatchStateChanged(STATE_CREATING); dispatchStateChanged(STATE_CREATING);
TLRPC.TL_phone_createGroupCall req = new TLRPC.TL_phone_createGroupCall(); TLRPC.TL_phone_createGroupCall req = new TLRPC.TL_phone_createGroupCall();

View File

@ -132,7 +132,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
public int getItemCount() { public int getItemCount() {
ArrayList<TLRPC.Dialog> array = DialogsActivity.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen); ArrayList<TLRPC.Dialog> array = DialogsActivity.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
int dialogsCount = array.size(); int dialogsCount = array.size();
if (dialogsType != 7 && dialogsType != 8 && dialogsCount == 0 && (folderId != 0 || MessagesController.getInstance(currentAccount).isLoadingDialogs(folderId))) { if (dialogsType != 7 && dialogsType != 8 && dialogsCount == 0 && (folderId != 0 || MessagesController.getInstance(currentAccount).isLoadingDialogs(folderId) || !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId))) {
onlineContacts = null; onlineContacts = null;
if (folderId == 1 && showArchiveHint) { if (folderId == 1 && showArchiveHint) {
return (currentCount = 2); return (currentCount = 2);

View File

@ -4879,7 +4879,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
maxPhotoWidth = photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); maxPhotoWidth = photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
} else { } else {
if (currentPhotoObject != null && (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO || messageObject.type == 8) && currentPhotoObject.w >= currentPhotoObject.h) { if (currentPhotoObject != null && (messageObject.type == MessageObject.TYPE_PHOTO || messageObject.type == MessageObject.TYPE_VIDEO || messageObject.type == 8) && currentPhotoObject.w >= currentPhotoObject.h) {
maxPhotoWidth = photoWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(64); maxPhotoWidth = photoWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp((drawAvatar ? 116 : 64) + (checkNeedDrawShareButton(messageObject) ? 10 : 0));
useFullWidth = true; useFullWidth = true;
} else { } else {
maxPhotoWidth = photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); maxPhotoWidth = photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);

View File

@ -843,7 +843,12 @@ public class DialogCell extends BaseCell {
startPadding = statusDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3); startPadding = statusDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3);
} }
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
spannableStringBuilder.append(" ").append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).setSpan(new FixedWidthSpan(startPadding), 0, 1, 0); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && LocaleController.isRTL && (int) currentDialogId < 0) {
spannableStringBuilder.append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).append(" ");
spannableStringBuilder.setSpan(new FixedWidthSpan(startPadding), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);
} else {
spannableStringBuilder.append(" ").append(TextUtils.replace(printingString, new String[]{"..."}, new String[]{""})).setSpan(new FixedWidthSpan(startPadding), 0, 1, 0);
}
messageString = spannableStringBuilder; messageString = spannableStringBuilder;
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex]; currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
checkMessage = false; checkMessage = false;
@ -2432,7 +2437,7 @@ public class DialogCell extends BaseCell {
StatusDrawable statusDrawable = Theme.getChatStatusDrawable(printingStringType); StatusDrawable statusDrawable = Theme.getChatStatusDrawable(printingStringType);
if (statusDrawable != null) { if (statusDrawable != null) {
canvas.save(); canvas.save();
int left = (LocaleController.isRTL || messageLayout.isRtlCharAt(0)) ? messageLeft + messageLayout.getWidth() - statusDrawable.getIntrinsicWidth() : messageLeft; int left = (LocaleController.isRTL || messageLayout.isRtlCharAt(0)) ? getMeasuredWidth() - AndroidUtilities.dp(72) - statusDrawable.getIntrinsicWidth() : messageLeft;
if (printingStringType == 1 || printingStringType == 4) { if (printingStringType == 1 || printingStringType == 4) {
canvas.translate(left, messageTop + (printingStringType == 1 ? AndroidUtilities.dp(1) : 0)); canvas.translate(left, messageTop + (printingStringType == 1 ? AndroidUtilities.dp(1) : 0));
} else { } else {

View File

@ -117,6 +117,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
private int animationIndex = -1; private int animationIndex = -1;
boolean checkCallAfterAnimation; boolean checkCallAfterAnimation;
boolean checkPlayerAfterAnimation;
@Override @Override
public void onAudioSettingsChanged() { public void onAudioSettingsChanged() {
@ -773,7 +774,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
if (VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing()) { if (VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing()) {
checkCall(true); checkCall(true);
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing()) { } else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing() && !isPlayingVoice()) {
checkCall(true); checkCall(true);
} else { } else {
checkPlayer(true); checkPlayer(true);
@ -821,7 +822,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
} }
} else if (id == NotificationCenter.messagePlayingDidStart || id == NotificationCenter.messagePlayingPlayStateChanged || id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.didEndCall) { } else if (id == NotificationCenter.messagePlayingDidStart || id == NotificationCenter.messagePlayingPlayStateChanged || id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.didEndCall) {
if (currentStyle == 3) { if (currentStyle == 3 || currentStyle == 4) {
checkCall(false); checkCall(false);
} }
checkPlayer(false); checkPlayer(false);
@ -1080,7 +1081,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
private void checkPlayer(boolean create) { private void checkPlayer(boolean create) {
if (visible && (currentStyle == 3 || currentStyle == 4)) { if (visible && (currentStyle == 3 || currentStyle == 4 && !isPlayingVoice())) {
return; return;
} }
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
@ -1093,7 +1094,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
if (messageObject == null || messageObject.getId() == 0 || messageObject.isVideo()) { if (messageObject == null || messageObject.getId() == 0 || messageObject.isVideo()) {
lastMessageObject = null; lastMessageObject = null;
boolean callAvailable = supportsCalls && VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing(); boolean callAvailable = supportsCalls && VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing();
if (!callAvailable && fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing()) { if (!isPlayingVoice() && !callAvailable && fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing()) {
callAvailable = true; callAvailable = true;
} }
if (callAvailable) { if (callAvailable) {
@ -1131,7 +1132,11 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet = null; animatorSet = null;
if (checkCallAfterAnimation) { if (checkCallAfterAnimation) {
checkCall(false); checkCall(false);
} else if (checkPlayerAfterAnimation) {
checkPlayer(false);
} }
checkCallAfterAnimation = false;
checkPlayerAfterAnimation = false;
} }
} }
}); });
@ -1141,6 +1146,10 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
setVisibility(View.GONE); setVisibility(View.GONE);
} }
} else { } else {
if (currentStyle != 0 && animatorSet != null && !create) {
checkPlayerAfterAnimation = true;
return;
}
int prevStyle = currentStyle; int prevStyle = currentStyle;
updateStyle(0); updateStyle(0);
if (create && topPadding == 0) { if (create && topPadding == 0) {
@ -1180,7 +1189,11 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet = null; animatorSet = null;
if (checkCallAfterAnimation) { if (checkCallAfterAnimation) {
checkCall(false); checkCall(false);
} else if (checkPlayerAfterAnimation) {
checkPlayer(false);
} }
checkCallAfterAnimation = false;
checkPlayerAfterAnimation = false;
} }
} }
}); });
@ -1235,6 +1248,11 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
} }
private boolean isPlayingVoice() {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
return messageObject != null && messageObject.isVoice();
}
public void checkCall(boolean create) { public void checkCall(boolean create) {
View fragmentView = fragment.getFragmentView(); View fragmentView = fragment.getFragmentView();
if (!create && fragmentView != null) { if (!create && fragmentView != null) {
@ -1253,7 +1271,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
callAvailable = false; callAvailable = false;
} }
groupActive = false; groupActive = false;
if (!GroupCallActivity.groupCallUiVisible && supportsCalls && !callAvailable && fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null) { if (!isPlayingVoice() && !GroupCallActivity.groupCallUiVisible && supportsCalls && !callAvailable && fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null) {
callAvailable = true; callAvailable = true;
groupActive = true; groupActive = true;
} }
@ -1287,13 +1305,17 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet = null; animatorSet = null;
if (checkCallAfterAnimation) { if (checkCallAfterAnimation) {
checkCall(false); checkCall(false);
} else if (checkPlayerAfterAnimation) {
checkPlayer(false);
} }
checkCallAfterAnimation = false;
checkPlayerAfterAnimation = false;
} }
} }
}); });
animatorSet.start(); animatorSet.start();
} }
} else if (currentStyle == -1 || currentStyle == 4 || currentStyle == 3){ } else if (currentStyle == -1 || currentStyle == 4 || currentStyle == 3) {
visible = false; visible = false;
setVisibility(GONE); setVisibility(GONE);
} }
@ -1382,7 +1404,11 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
if (checkCallAfterAnimation) { if (checkCallAfterAnimation) {
checkCall(false); checkCall(false);
} else if (checkPlayerAfterAnimation) {
checkPlayer(false);
} }
checkCallAfterAnimation = false;
checkPlayerAfterAnimation = false;
} }
}); });
animatorSet.start(); animatorSet.start();

View File

@ -48,6 +48,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -848,6 +849,10 @@ public class RecyclerListView extends RecyclerView {
@Override @Override
public void onItemRangeInserted(int positionStart, int itemCount) { public void onItemRangeInserted(int positionStart, int itemCount) {
checkIfEmpty(true); checkIfEmpty(true);
if (pinnedHeader != null && pinnedHeader.getAlpha() == 0) {
currentFirst = -1;
invalidateViews();
}
} }
@Override @Override

View File

@ -630,7 +630,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} }
floatingButton.setBackgroundDrawable(drawable); floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.SRC_IN)); floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.SRC_IN));
floatingButton.setAnimation(R.raw.write_contacts_fab_icon, 52, 52); SharedPreferences preferences = MessagesController.getGlobalMainSettings();
boolean configAnimationsEnabled = preferences.getBoolean("view_animations", true);
floatingButton.setAnimation(configAnimationsEnabled ? R.raw.write_contacts_fab_icon : R.raw.write_contacts_fab_icon_reverse, 52, 52);
floatingButtonContainer.setContentDescription(LocaleController.getString("CreateNewContact", R.string.CreateNewContact)); floatingButtonContainer.setContentDescription(LocaleController.getString("CreateNewContact", R.string.CreateNewContact));
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator(); StateListAnimator animator = new StateListAnimator();

View File

@ -61,7 +61,6 @@ import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject; import org.telegram.messenger.UserObject;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.voip.VoIPBaseService; import org.telegram.messenger.voip.VoIPBaseService;
@ -2125,7 +2124,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
VoIPService.getSharedInstance().hangUp(discard ? 1 : 0); VoIPService.getSharedInstance().hangUp(discard ? 1 : 0);
} }
if (call != null) { if (call != null) {
int selfUserId = UserConfig.getInstance(call.currentAccount).clientUserId; int selfUserId = call.currentAccount.getUserConfig().clientUserId;
TLRPC.TL_groupCallParticipant participant = call.participants.get(selfUserId); TLRPC.TL_groupCallParticipant participant = call.participants.get(selfUserId);
if (participant != null) { if (participant != null) {
call.participants.delete(selfUserId); call.participants.delete(selfUserId);

View File

@ -966,6 +966,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
} }
} }
if (SharedConfig.noStatusBar) {
getWindow().setStatusBarColor(0);
}
} }
public void switchToAccount(int account, boolean removeAll) { public void switchToAccount(int account, boolean removeAll) {

View File

@ -2139,7 +2139,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
view = new GraySectionCell(mContext); view = new GraySectionCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_graySection) & 0xf2ffffff); view.setBackgroundColor(Theme.getColor(Theme.key_graySection) & 0xf2ffffff);
} }
if (sharedMediaData[3].sections.size() == 0 && !sharedMediaData[3].loading) { if (sharedMediaData[3].sections.size() == 0) {
view.setAlpha(0); view.setAlpha(0);
} else if (section < sharedMediaData[3].sections.size()) { } else if (section < sharedMediaData[3].sections.size()) {
view.setAlpha(1f); view.setAlpha(1f);
@ -2271,7 +2271,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
view = new GraySectionCell(mContext); view = new GraySectionCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_graySection) & 0xf2ffffff); view.setBackgroundColor(Theme.getColor(Theme.key_graySection) & 0xf2ffffff);
} }
if (sharedMediaData[currentType].sections.size() == 0 && !sharedMediaData[currentType].loading) { if (sharedMediaData[currentType].sections.size() == 0) {
view.setAlpha(0); view.setAlpha(0);
} else if (section < sharedMediaData[currentType].sections.size()) { } else if (section < sharedMediaData[currentType].sections.size()) {
view.setAlpha(1f); view.setAlpha(1f);
@ -2442,7 +2442,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
view = new SharedMediaSectionCell(mContext); view = new SharedMediaSectionCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite) & 0xe5ffffff); view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite) & 0xe5ffffff);
} }
if (sharedMediaData[0].sections.size() == 0 && !sharedMediaData[0].loading) { if (sharedMediaData[0].sections.size() == 0) {
view.setAlpha(0); view.setAlpha(0);
} else if (section < sharedMediaData[0].sections.size()) { } else if (section < sharedMediaData[0].sections.size()) {
view.setAlpha(1f); view.setAlpha(1f);

View File

@ -2098,7 +2098,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} }
int top = 0; int top = paddingTop;
if (view != null) { if (view != null) {
top = view.getTop(); top = view.getTop();
} }
@ -2107,6 +2107,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
layoutManager.scrollToPositionWithOffset(sharedMediaRow, -paddingTop); layoutManager.scrollToPositionWithOffset(sharedMediaRow, -paddingTop);
layout = true; layout = true;
} else if ((!changed || !allowPullingDown) && view != null) { } else if ((!changed || !allowPullingDown) && view != null) {
if (pos == 0 && !allowPullingDown && top > AndroidUtilities.dp(88)) {
top = AndroidUtilities.dp(88);
}
layoutManager.scrollToPositionWithOffset(pos, top - paddingTop); layoutManager.scrollToPositionWithOffset(pos, top - paddingTop);
layout = true; layout = true;
} }
@ -2861,7 +2864,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs), LocaleController.getString("DebugMenuReadAllDialogs", R.string.DebugMenuReadAllDialogs),
SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic),
BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() && Build.VERSION.SDK_INT >= 23 ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null, BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() && Build.VERSION.SDK_INT >= 23 ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null,
BuildVars.DEBUG_PRIVATE_VERSION ? (SharedConfig.disableVoiceAudioEffects ? "Enable voip audio effects" : "Disable voip audio effects") : null BuildVars.DEBUG_PRIVATE_VERSION ? (SharedConfig.disableVoiceAudioEffects ? "Enable voip audio effects" : "Disable voip audio effects") : null,
Build.VERSION.SDK_INT >= 21 ? (SharedConfig.noStatusBar ? "Show status bar background" : "Hide status bar background") : null
}; };
builder.setItems(items, (dialog, which) -> { builder.setItems(items, (dialog, which) -> {
if (which == 0) { if (which == 0) {
@ -2906,6 +2910,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} else if (which == 13) { } else if (which == 13) {
SharedConfig.toggleDisableVoiceAudioEffects(); SharedConfig.toggleDisableVoiceAudioEffects();
} else if (which == 14) {
SharedConfig.toggleNoStatusBar();
if (getParentActivity() != null) {
if (SharedConfig.noStatusBar) {
getParentActivity().getWindow().setStatusBarColor(0);
} else {
getParentActivity().getWindow().setStatusBarColor(0x33000000);
}
}
} }
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);

View File

@ -1,6 +1,7 @@
package tw.nekomimi.nekogram.database package tw.nekomimi.nekogram.database
import org.dizitart.no2.Nitrite import org.dizitart.no2.Nitrite
import org.dizitart.no2.collection.meta.Attributes
import org.dizitart.no2.mvstore.MVStoreModule import org.dizitart.no2.mvstore.MVStoreModule
import org.telegram.messenger.ApplicationLoader import org.telegram.messenger.ApplicationLoader
import org.telegram.messenger.FileLog import org.telegram.messenger.FileLog
@ -13,18 +14,23 @@ fun mkDatabase(name: String): Nitrite {
FileUtil.initDir(file.parentFile!!) FileUtil.initDir(file.parentFile!!)
fun create() = Nitrite.builder() fun create(): Nitrite {
.loadModule(MVStoreModule.withConfig() val nitrite = Nitrite.builder()
.filePath(file) .loadModule(MVStoreModule.withConfig().filePath(file).build())
.build()) .openOrCreate()!!
.openOrCreate()!!
val test = nitrite.openSharedPreference("shared_preferences")
test.connection.close()
return nitrite
}
runCatching { runCatching {
return create() return create()
}.onFailure { }.onFailure {
FileLog.e(it) FileLog.e(it)
file.deleteRecursively() file.deleteRecursively()
} }
return create() return create()