mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Handle mute settings for 'strangers'-chat
This commit is contained in:
@@ -264,6 +264,13 @@ public class ApplicationLoader extends Application {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
boolean enablePushConnection = preferences.getBoolean("pushConnection", true);
|
||||
|
||||
if( preferences.getInt("notify2_"+MrMailbox.MR_CHAT_ID_STRANGERS, 666)==666 ) {
|
||||
// make sure, the notifications for the "strangers" dialog are muted by default
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("notify2_"+MrMailbox.MR_CHAT_ID_STRANGERS, 2);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
MessagesController.getInstance();
|
||||
ConnectionsManager.getInstance().init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildVars.APP_ID, deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId(), enablePushConnection);
|
||||
if (UserConfig.getCurrentUser() != null) {
|
||||
|
||||
@@ -1838,7 +1838,10 @@ public class NotificationsController {
|
||||
}
|
||||
|
||||
public static void updateServerNotificationsSettings(long dialog_id) {
|
||||
// the following command is needed to reflect the changes in the GUI
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
|
||||
|
||||
/*
|
||||
if ((int) dialog_id == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1862,5 +1865,6 @@ public class NotificationsController {
|
||||
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
private StickersAdapter stickersAdapter;
|
||||
private FrameLayout stickersPanel;
|
||||
private TextView muteItem;
|
||||
private boolean m_canMute;
|
||||
private FrameLayout pagedownButton;
|
||||
private boolean pagedownButtonShowedByScroll;
|
||||
private TextView pagedownButtonCounter;
|
||||
@@ -1026,7 +1027,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
}
|
||||
}
|
||||
*/
|
||||
muteItem = headerItem.addSubItem(mute, null, 0);
|
||||
|
||||
m_canMute = true;
|
||||
if( MrMailbox.MrChatGetId(m_hChat)==MrMailbox.MR_CHAT_ID_STRANGERS
|
||||
&& MrMailbox.MrMailboxGetConfigInt(MrMailbox.hMailbox, "show_strangers", 0)==0 ) {
|
||||
m_canMute = false;
|
||||
}
|
||||
|
||||
if( m_canMute ) {
|
||||
muteItem = headerItem.addSubItem(mute, null, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (currentUser != null && currentEncryptedChat == null && currentUser.bot) {
|
||||
headerItem.addSubItem(bot_settings, LocaleController.getString("BotSettings", R.string.BotSettings), 0);
|
||||
@@ -3835,7 +3847,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
|
||||
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
|
||||
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
|
||||
LocaleController.getString("MuteDisable", R.string.MuteDisable)
|
||||
LocaleController.getString("MuteAlways", R.string.MuteAlways)
|
||||
};
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
@@ -3848,23 +3860,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
//long flags;
|
||||
if (i == 3) {
|
||||
editor.putInt("notify2_" + dialog_id, 2);
|
||||
//flags = 1;
|
||||
} else {
|
||||
editor.putInt("notify2_" + dialog_id, 3);
|
||||
editor.putInt("notifyuntil_" + dialog_id, untilTime);
|
||||
//flags = ((long) untilTime << 32) | 1;
|
||||
}
|
||||
NotificationsController.getInstance().removeNotificationsForDialog(dialog_id);
|
||||
//MessagesStorage.getInstance().setDialogFlags(dialog_id, flags);
|
||||
editor.commit();
|
||||
/*NotificationsController.getInstance().removeNotificationsForDialog(dialog_id);
|
||||
TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
|
||||
if (dialog != null) {
|
||||
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
|
||||
dialog.notify_settings.mute_until = untilTime;
|
||||
}
|
||||
*/
|
||||
NotificationsController.updateServerNotificationsSettings(dialog_id);
|
||||
}
|
||||
}
|
||||
@@ -3875,12 +3884,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("notify2_" + dialog_id, 0);
|
||||
//MessagesStorage.getInstance().setDialogFlags(dialog_id, 0);
|
||||
editor.commit();
|
||||
TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
|
||||
/*TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
|
||||
if (dialog != null) {
|
||||
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
|
||||
}
|
||||
*/
|
||||
NotificationsController.updateServerNotificationsSettings(dialog_id);
|
||||
}
|
||||
}
|
||||
@@ -4400,12 +4409,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
if (avatarContainer == null) {
|
||||
return;
|
||||
}
|
||||
int rightIcon = MessagesController.getInstance().isDialogMuted(dialog_id) ? R.drawable.mute_fixed : 0;
|
||||
|
||||
int rightIcon = 0;
|
||||
if( m_canMute && MessagesController.getInstance().isDialogMuted(dialog_id) ) {
|
||||
rightIcon = R.drawable.mute_fixed;
|
||||
}
|
||||
|
||||
avatarContainer.setTitleIcons(currentEncryptedChat != null ? R.drawable.ic_lock_header : 0, rightIcon);
|
||||
if (rightIcon != 0) {
|
||||
muteItem.setText(LocaleController.getString("UnmuteNotifications", R.string.UnmuteNotifications));
|
||||
} else {
|
||||
muteItem.setText(LocaleController.getString("MuteNotifications", R.string.MuteNotifications));
|
||||
if( muteItem != null ) {
|
||||
if (rightIcon != 0) {
|
||||
muteItem.setText(LocaleController.getString("UnmuteNotifications", R.string.UnmuteNotifications));
|
||||
} else {
|
||||
muteItem.setText(LocaleController.getString("MuteNotifications", R.string.MuteNotifications));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6399,7 +6415,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
if (currentChat != null && (ChatObject.isNotInChat(currentChat) || !ChatObject.canWriteToChat(currentChat)) ||
|
||||
currentUser != null && (UserObject.isDeleted(currentUser) || userBlocked)) {
|
||||
bottomOverlayChat.setVisibility(View.VISIBLE);
|
||||
muteItem.setVisibility(View.GONE);
|
||||
if (muteItem!=null){
|
||||
muteItem.setVisibility(View.GONE);
|
||||
}
|
||||
chatActivityEnterView.setFieldFocused(false);
|
||||
chatActivityEnterView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
@@ -6410,7 +6428,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
chatActivityEnterView.setVisibility(View.VISIBLE);
|
||||
bottomOverlayChat.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
muteItem.setVisibility(View.VISIBLE);
|
||||
if(muteItem!=null) {
|
||||
muteItem.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkRaiseSensors();
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
@@ -232,6 +233,12 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(oldval == 0);
|
||||
}
|
||||
|
||||
// if showing strangers is disabled, also disable notifications for this chat (cannot be displayed otherwise)
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("notify2_" + MrMailbox.MR_CHAT_ID_STRANGERS, oldval==1? 2 /*always muted*/ : 0);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -919,4 +919,5 @@
|
||||
<string name="Strangers">Unbekannte Benutzer</string>
|
||||
<string name="Media">Medien</string>
|
||||
<string name="StrangersInChatlist">Unbekannte Benutzer in Chatliste </string>
|
||||
<string name="MuteAlways">Dauerhaft stumm</string>
|
||||
</resources>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<string name="MuteFor">Silenciar %1$s</string>
|
||||
<string name="UnmuteNotifications">No silenciar</string>
|
||||
<string name="WillUnmuteIn">En %1$s</string>
|
||||
<string name="MuteDisable">Desactivar</string>
|
||||
<string name="Hashtags">HASHTAGS</string>
|
||||
<string name="Recent">RECIENTES</string>
|
||||
<string name="ChatHints">CHATS</string>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<string name="MuteFor">Silenzia per %1$s</string>
|
||||
<string name="UnmuteNotifications">Suona</string>
|
||||
<string name="WillUnmuteIn">Tra %1$s</string>
|
||||
<string name="MuteDisable">Disabilita</string>
|
||||
<string name="Hashtags">HASHTAG</string>
|
||||
<string name="Recent">RECENTI</string>
|
||||
<string name="ChatHints">CHAT</string>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<string name="MuteFor">%1$s stil</string>
|
||||
<string name="UnmuteNotifications">Stil uitschakelen</string>
|
||||
<string name="WillUnmuteIn">Over %1$s</string>
|
||||
<string name="MuteDisable">Uitschakelen</string>
|
||||
<string name="Hashtags">HASHTAGS</string>
|
||||
<string name="Recent">RECENT</string>
|
||||
<string name="ChatHints">CHATS</string>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<string name="MuteFor">Silenciar por %1$s</string>
|
||||
<string name="UnmuteNotifications">Restaurar Som</string>
|
||||
<string name="WillUnmuteIn">Em %1$s</string>
|
||||
<string name="MuteDisable">Desativar</string>
|
||||
<string name="Hashtags">HASHTAGS</string>
|
||||
<string name="Recent">RECENTE</string>
|
||||
<string name="ChatHints">CONVERSAS</string>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<string name="MuteFor">Mute for %1$s</string>
|
||||
<string name="UnmuteNotifications">Unmute</string>
|
||||
<string name="WillUnmuteIn">In %1$s</string>
|
||||
<string name="MuteDisable">Disable</string>
|
||||
<string name="MuteDisable">Always muted</string>
|
||||
<string name="Hashtags">HASHTAGS</string>
|
||||
<string name="Recent">RECENT</string>
|
||||
<string name="ChatHints">CHATS</string>
|
||||
@@ -919,4 +919,5 @@
|
||||
<string name="Strangers">Unknown users</string>
|
||||
<string name="Media">Media</string>
|
||||
<string name="StrangersInChatlist">Show unknown users in chatlist</string>
|
||||
<string name="MuteAlways">Always muted</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user