正在查看: КЛ£ v1.0.0 应用的 NoticeAndSoundSettingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: КЛ£ v1.0.0 应用的 NoticeAndSoundSettingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package im.pggrnmxjgs.ui.settings;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import im.pggrnmxjgs.messenger.AndroidUtilities;
import im.pggrnmxjgs.messenger.FileLog;
import im.pggrnmxjgs.messenger.LocaleController;
import im.pggrnmxjgs.messenger.MessagesController;
import im.pggrnmxjgs.messenger.MessagesStorage;
import im.pggrnmxjgs.messenger.NotificationsController;
import im.pggrnmxjgs.tgnet.ConnectionsManager;
import im.pggrnmxjgs.tgnet.RequestDelegate;
import im.pggrnmxjgs.tgnet.TLObject;
import im.pggrnmxjgs.tgnet.TLRPC;
import im.pggrnmxjgs.ui.NotificationsSettingsActivity;
import im.pggrnmxjgs.ui.actionbar.ActionBar;
import im.pggrnmxjgs.ui.actionbar.AlertDialog;
import im.pggrnmxjgs.ui.actionbar.BaseFragment;
import im.pggrnmxjgs.ui.actionbar.Theme;
import im.pggrnmxjgs.ui.components.AlertsCreator;
import im.pggrnmxjgs.ui.components.toast.ToastUtils;
import im.pggrnmxjgs.ui.hviews.MrySwitch;
import java.util.ArrayList;
public class NoticeAndSoundSettingActivity extends BaseFragment {
private boolean reseting = false;
private ArrayList<NotificationsSettingsActivity.NotificationException> exceptionUsers = null;
private ArrayList<NotificationsSettingsActivity.NotificationException> exceptionChats = null;
private ArrayList<NotificationsSettingsActivity.NotificationException> exceptionChannels = null;
@Override
public boolean onFragmentCreate() {
MessagesController.getInstance(this.currentAccount).loadSignUpNotificationsSettings();
loadExceptions();
return super.onFragmentCreate();
}
private void loadExceptions() {
MessagesStorage.getInstance(this.currentAccount).getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
NoticeAndSoundSettingActivity.this.lambda$loadExceptions$1$NoticeAndSoundSettingActivity();
}
});
}
public void lambda$loadExceptions$1$NoticeAndSoundSettingActivity() {
throw new UnsupportedOperationException("Method not decompiled: im.pggrnmxjgs.ui.settings.NoticeAndSoundSettingActivity.lambda$loadExceptions$1$NoticeAndSoundSettingActivity():void");
}
public void lambda$null$0$NoticeAndSoundSettingActivity(ArrayList users, ArrayList chats, ArrayList encryptedChats, ArrayList usersResult, ArrayList chatsResult, ArrayList channelsResult) {
MessagesController.getInstance(this.currentAccount).putUsers(users, true);
MessagesController.getInstance(this.currentAccount).putChats(chats, true);
MessagesController.getInstance(this.currentAccount).putEncryptedChats(encryptedChats, true);
this.exceptionUsers = usersResult;
this.exceptionChats = chatsResult;
this.exceptionChannels = channelsResult;
}
@Override
public View createView(Context context) {
this.actionBar.setTitle(LocaleController.getString("Notifications", 2131692399));
this.actionBar.setBackButtonImage(2131558496);
this.fragmentView = LayoutInflater.from(context).inflate(2131492967, (ViewGroup) null, false);
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
initView(context);
initGlobalSetting();
initListener();
return this.fragmentView;
}
private void initView(Context context) {
this.fragmentView.findViewById(2131297210).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), 0, 0, Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297195).setBackground(Theme.getSelectorDrawable(true));
this.fragmentView.findViewById(2131297214).setBackground(Theme.getRoundRectSelectorDrawable(0, 0, AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297171).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), 0, 0, Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297170).setBackground(Theme.getSelectorDrawable(true));
this.fragmentView.findViewById(2131297172).setBackground(Theme.getRoundRectSelectorDrawable(0, 0, AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297156).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), 0, 0, Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297155).setBackground(Theme.getSelectorDrawable(true));
this.fragmentView.findViewById(2131297157).setBackground(Theme.getRoundRectSelectorDrawable(0, 0, AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297145).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), 0, 0, Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297144).setBackground(Theme.getSelectorDrawable(true));
this.fragmentView.findViewById(2131297143).setBackground(Theme.getRoundRectSelectorDrawable(0, 0, AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297176).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), 0, 0, Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297185).setBackground(Theme.getRoundRectSelectorDrawable(0, 0, AndroidUtilities.dp(5.0f), AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297190).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
this.fragmentView.findViewById(2131297201).setBackground(Theme.getRoundRectSelectorDrawable(AndroidUtilities.dp(5.0f), Theme.getColor(Theme.key_windowBackgroundWhite)));
}
private void initListener() {
this.actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
NoticeAndSoundSettingActivity.this.finishFragment();
}
}
});
this.fragmentView.findViewById(2131297210).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$3$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297195).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$4$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297214).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$5$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297171).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$7$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297170).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$8$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297172).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$9$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297156).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$11$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297155).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$12$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297157).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$13$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297145).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$14$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297144).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$15$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297143).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$16$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297176).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$17$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297185).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$18$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297190).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$20$NoticeAndSoundSettingActivity(view);
}
});
this.fragmentView.findViewById(2131297201).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NoticeAndSoundSettingActivity.this.lambda$initListener$24$NoticeAndSoundSettingActivity(view);
}
});
}
public void lambda$initListener$3$NoticeAndSoundSettingActivity(View view) {
boolean enabled = getNotificationsController().isGlobalNotificationsEnabled(1);
if (!enabled) {
getNotificationsController().setGlobalNotificationsEnabled(1, 0);
((MrySwitch) this.fragmentView.findViewById(2131297355)).setChecked(!enabled, true);
setPrivateSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297355)).isChecked());
return;
}
AlertsCreator.showCustomNotificationsDialog(this, 0L, 1, this.exceptionUsers, this.currentAccount, new MessagesStorage.IntCallback() {
public final void run(int i) {
NoticeAndSoundSettingActivity.this.lambda$null$2$NoticeAndSoundSettingActivity(i);
}
});
}
public void lambda$null$2$NoticeAndSoundSettingActivity(int param) {
((MrySwitch) this.fragmentView.findViewById(2131297355)).setChecked(getNotificationsController().isGlobalNotificationsEnabled(1), true);
setPrivateSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297355)).isChecked());
}
public void lambda$initListener$4$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnablePreviewAll", true);
editor.putBoolean("EnablePreviewAll", !enabled);
editor.commit();
getNotificationsController().updateServerNotificationsSettings(1);
((MrySwitch) this.fragmentView.findViewById(2131297351)).setChecked(!enabled, true);
}
public void lambda$initListener$5$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
try {
SharedPreferences preferences = getNotificationsSettings();
Intent tmpIntent = new Intent("android.intent.action.RINGTONE_PICKER");
tmpIntent.putExtra("android.intent.extra.ringtone.TYPE", 2);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_DEFAULT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_SILENT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.DEFAULT_URI", RingtoneManager.getDefaultUri(2));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path = preferences.getString("GlobalSoundPath", defaultPath);
if (path != null && !path.equals("NoSound")) {
currentSound = path.equals(defaultPath) ? defaultUri : Uri.parse(path);
}
tmpIntent.putExtra("android.intent.extra.ringtone.EXISTING_URI", currentSound);
startActivityForResult(tmpIntent, 1);
} catch (Exception e) {
FileLog.e(e);
}
}
public void lambda$initListener$7$NoticeAndSoundSettingActivity(View view) {
boolean enabled = getNotificationsController().isGlobalNotificationsEnabled(0);
if (!enabled) {
getNotificationsController().setGlobalNotificationsEnabled(0, 0);
((MrySwitch) this.fragmentView.findViewById(2131297342)).setChecked(!enabled, true);
setGroupSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297342)).isChecked());
return;
}
AlertsCreator.showCustomNotificationsDialog(this, 0L, 0, this.exceptionChats, this.currentAccount, new MessagesStorage.IntCallback() {
public final void run(int i) {
NoticeAndSoundSettingActivity.this.lambda$null$6$NoticeAndSoundSettingActivity(i);
}
});
}
public void lambda$null$6$NoticeAndSoundSettingActivity(int param) {
((MrySwitch) this.fragmentView.findViewById(2131297342)).setChecked(getNotificationsController().isGlobalNotificationsEnabled(0), true);
setGroupSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297342)).isChecked());
}
public void lambda$initListener$8$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnablePreviewGroup", true);
editor.putBoolean("EnablePreviewGroup", !enabled);
editor.commit();
getNotificationsController().updateServerNotificationsSettings(0);
((MrySwitch) this.fragmentView.findViewById(2131297341)).setChecked(!enabled, true);
}
public void lambda$initListener$9$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
try {
SharedPreferences preferences = getNotificationsSettings();
Intent tmpIntent = new Intent("android.intent.action.RINGTONE_PICKER");
tmpIntent.putExtra("android.intent.extra.ringtone.TYPE", 2);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_DEFAULT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_SILENT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.DEFAULT_URI", RingtoneManager.getDefaultUri(2));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path = preferences.getString("GroupSoundPath", defaultPath);
if (path != null && !path.equals("NoSound")) {
currentSound = path.equals(defaultPath) ? defaultUri : Uri.parse(path);
}
tmpIntent.putExtra("android.intent.extra.ringtone.EXISTING_URI", currentSound);
startActivityForResult(tmpIntent, 0);
} catch (Exception e) {
FileLog.e(e);
}
}
public void lambda$initListener$11$NoticeAndSoundSettingActivity(View view) {
boolean enabled = getNotificationsController().isGlobalNotificationsEnabled(2);
if (!enabled) {
getNotificationsController().setGlobalNotificationsEnabled(2, 0);
((MrySwitch) this.fragmentView.findViewById(2131297337)).setChecked(!enabled, true);
setChannelSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297337)).isChecked());
return;
}
AlertsCreator.showCustomNotificationsDialog(this, 0L, 2, this.exceptionChannels, this.currentAccount, new MessagesStorage.IntCallback() {
public final void run(int i) {
NoticeAndSoundSettingActivity.this.lambda$null$10$NoticeAndSoundSettingActivity(i);
}
});
}
public void lambda$null$10$NoticeAndSoundSettingActivity(int param) {
((MrySwitch) this.fragmentView.findViewById(2131297337)).setChecked(getNotificationsController().isGlobalNotificationsEnabled(2), true);
setChannelSettingEnabled(((MrySwitch) this.fragmentView.findViewById(2131297337)).isChecked());
}
public void lambda$initListener$12$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnablePreviewChannel", true);
editor.putBoolean("EnablePreviewChannel", !enabled);
editor.commit();
getNotificationsController().updateServerNotificationsSettings(2);
((MrySwitch) this.fragmentView.findViewById(2131297336)).setChecked(!enabled, true);
}
public void lambda$initListener$13$NoticeAndSoundSettingActivity(View view) {
if (!view.isEnabled()) {
return;
}
try {
SharedPreferences preferences = getNotificationsSettings();
Intent tmpIntent = new Intent("android.intent.action.RINGTONE_PICKER");
tmpIntent.putExtra("android.intent.extra.ringtone.TYPE", 2);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_DEFAULT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.SHOW_SILENT", true);
tmpIntent.putExtra("android.intent.extra.ringtone.DEFAULT_URI", RingtoneManager.getDefaultUri(2));
Uri currentSound = null;
String defaultPath = null;
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
if (defaultUri != null) {
defaultPath = defaultUri.getPath();
}
String path = preferences.getString("ChannelSoundPath", defaultPath);
if (path != null && !path.equals("NoSound")) {
currentSound = path.equals(defaultPath) ? defaultUri : Uri.parse(path);
}
tmpIntent.putExtra("android.intent.extra.ringtone.EXISTING_URI", currentSound);
startActivityForResult(tmpIntent, 2);
} catch (Exception e) {
FileLog.e(e);
}
}
public void lambda$initListener$14$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppSounds", true);
editor.putBoolean("EnableInAppSounds", !enabled);
editor.commit();
((MrySwitch) this.fragmentView.findViewById(2131297332)).setChecked(!enabled, true);
}
public void lambda$initListener$15$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppVibrate", true);
editor.putBoolean("EnableInAppVibrate", !enabled);
editor.commit();
((MrySwitch) this.fragmentView.findViewById(2131297331)).setChecked(!enabled, true);
}
public void lambda$initListener$16$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableInAppPreview", true);
editor.putBoolean("EnableInAppPreview", !enabled);
editor.commit();
((MrySwitch) this.fragmentView.findViewById(2131297330)).setChecked(!enabled, true);
}
public void lambda$initListener$17$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = NotificationsController.getInstance(this.currentAccount).showBadgeMuted;
NotificationsController.getInstance(this.currentAccount).showBadgeMuted = !enabled;
editor.putBoolean("badgeNumberMuted", NotificationsController.getInstance(this.currentAccount).showBadgeMuted);
editor.commit();
NotificationsController.getInstance(this.currentAccount).updateBadge();
((MrySwitch) this.fragmentView.findViewById(2131297344)).setChecked(!enabled, true);
}
public void lambda$initListener$18$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = NotificationsController.getInstance(this.currentAccount).showBadgeMessages;
NotificationsController.getInstance(this.currentAccount).showBadgeMessages = !enabled;
editor.putBoolean("badgeNumberMessages", NotificationsController.getInstance(this.currentAccount).showBadgeMessages);
editor.commit();
NotificationsController.getInstance(this.currentAccount).updateBadge();
((MrySwitch) this.fragmentView.findViewById(2131297348)).setChecked(!enabled, true);
}
public void lambda$initListener$20$NoticeAndSoundSettingActivity(View view) {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
boolean enabled = preferences.getBoolean("EnableContactJoined", true);
MessagesController.getInstance(this.currentAccount).enableJoined = !enabled;
editor.putBoolean("EnableContactJoined", !enabled);
editor.commit();
TLRPC.TL_account_setContactSignUpNotification req = new TLRPC.TL_account_setContactSignUpNotification();
req.silent = enabled;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
NoticeAndSoundSettingActivity.lambda$null$19(tLObject, tL_error);
}
});
((MrySwitch) this.fragmentView.findViewById(2131297349)).setChecked(!enabled, true);
}
static void lambda$null$19(TLObject response, TLRPC.TL_error error) {
}
public void lambda$initListener$24$NoticeAndSoundSettingActivity(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder((Context) getParentActivity());
builder.setMessage(LocaleController.getString("ResetNotificationsAlert", 2131693511));
builder.setTitle(LocaleController.getString("AppName", 2131689827));
builder.setPositiveButton(LocaleController.getString("Reset", 2131693491), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
NoticeAndSoundSettingActivity.this.lambda$null$23$NoticeAndSoundSettingActivity(dialogInterface, i);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", 2131690312), null);
showDialog(builder.create());
}
public void lambda$null$23$NoticeAndSoundSettingActivity(DialogInterface dialogInterface, int i) {
if (this.reseting) {
return;
}
this.reseting = true;
TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
NoticeAndSoundSettingActivity.this.lambda$null$22$NoticeAndSoundSettingActivity(tLObject, tL_error);
}
});
}
public void lambda$null$22$NoticeAndSoundSettingActivity(TLObject response, TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NoticeAndSoundSettingActivity.this.lambda$null$21$NoticeAndSoundSettingActivity();
}
});
}
public void lambda$null$21$NoticeAndSoundSettingActivity() {
MessagesController.getInstance(this.currentAccount).enableJoined = true;
this.reseting = false;
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = preferences.edit();
editor.clear();
editor.commit();
this.exceptionChats.clear();
this.exceptionUsers.clear();
initGlobalSetting();
if (getParentActivity() != null) {
ToastUtils.show(2131693512);
}
}
private void initGlobalSetting() {
StringBuilder builder = new StringBuilder();
SharedPreferences preferences = getNotificationsSettings();
int offUntil = preferences.getInt("EnableAll2", 0);
int currentTime = getConnectionsManager().getCurrentTime();
boolean z = offUntil < currentTime;
boolean enabled = z;
if (z) {
builder.append(LocaleController.getString("NotificationsOn", 2131692428));
} else if (offUntil - 31536000 >= currentTime) {
builder.append(LocaleController.getString("NotificationsOff", 2131692426));
} else {
builder.append(LocaleController.formatString("NotificationsOffUntil", 2131692427, new Object[]{LocaleController.stringForMessageListDate(offUntil)}));
}
((MrySwitch) this.fragmentView.findViewById(2131297355)).setChecked(enabled, true);
setPrivateSettingEnabled(enabled);
((MrySwitch) this.fragmentView.findViewById(2131297351)).setChecked(preferences.getBoolean("EnablePreviewAll", true), true);
String value = preferences.getString("GlobalSound", LocaleController.getString("SoundDefault", 2131694029));
if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", 2131692260);
}
((TextView) this.fragmentView.findViewById(2131297855)).setText(value);
initGroupSetting();
initChannelSetting();
initOtherSetting();
}
private void initGroupSetting() {
StringBuilder builder = new StringBuilder();
SharedPreferences preferences = getNotificationsSettings();
int offUntil = preferences.getInt("EnableGroup2", 0);
int currentTime = getConnectionsManager().getCurrentTime();
boolean z = offUntil < currentTime;
boolean enabled = z;
if (z) {
builder.append(LocaleController.getString("NotificationsOn", 2131692428));
} else if (offUntil - 31536000 >= currentTime) {
builder.append(LocaleController.getString("NotificationsOff", 2131692426));
} else {
builder.append(LocaleController.formatString("NotificationsOffUntil", 2131692427, new Object[]{LocaleController.stringForMessageListDate(offUntil)}));
}
((MrySwitch) this.fragmentView.findViewById(2131297342)).setChecked(enabled, true);
setGroupSettingEnabled(enabled);
((MrySwitch) this.fragmentView.findViewById(2131297341)).setChecked(preferences.getBoolean("EnablePreviewGroup", true), true);
String value = preferences.getString("GroupSound", LocaleController.getString("SoundDefault", 2131694029));
if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", 2131692260);
}
((TextView) this.fragmentView.findViewById(2131297776)).setText(value);
}
private void initChannelSetting() {
StringBuilder builder = new StringBuilder();
SharedPreferences preferences = getNotificationsSettings();
int offUntil = preferences.getInt("EnableChannel2", 0);
int currentTime = getConnectionsManager().getCurrentTime();
boolean z = offUntil < currentTime;
boolean enabled = z;
if (z) {
builder.append(LocaleController.getString("NotificationsOn", 2131692428));
} else if (offUntil - 31536000 >= currentTime) {
builder.append(LocaleController.getString("NotificationsOff", 2131692426));
} else {
builder.append(LocaleController.formatString("NotificationsOffUntil", 2131692427, new Object[]{LocaleController.stringForMessageListDate(offUntil)}));
}
((MrySwitch) this.fragmentView.findViewById(2131297337)).setChecked(enabled, true);
setChannelSettingEnabled(enabled);
((MrySwitch) this.fragmentView.findViewById(2131297336)).setChecked(preferences.getBoolean("EnablePreviewChannel", true), true);
String value = preferences.getString("ChannelSound", LocaleController.getString("SoundDefault", 2131694029));
if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", 2131692260);
}
((TextView) this.fragmentView.findViewById(2131297740)).setText(value);
}
private void initOtherSetting() {
SharedPreferences preferences = MessagesController.getNotificationsSettings(this.currentAccount);
((MrySwitch) this.fragmentView.findViewById(2131297332)).setChecked(preferences.getBoolean("EnableInAppSounds", true), true);
((MrySwitch) this.fragmentView.findViewById(2131297331)).setChecked(preferences.getBoolean("EnableInAppVibrate", true), true);
((MrySwitch) this.fragmentView.findViewById(2131297330)).setChecked(preferences.getBoolean("EnableInAppPreview", true), true);
((MrySwitch) this.fragmentView.findViewById(2131297344)).setChecked(NotificationsController.getInstance(this.currentAccount).showBadgeMuted, true);
((MrySwitch) this.fragmentView.findViewById(2131297348)).setChecked(NotificationsController.getInstance(this.currentAccount).showBadgeMessages, true);
((MrySwitch) this.fragmentView.findViewById(2131297349)).setChecked(preferences.getBoolean("EnableContactJoined", true), true);
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
Ringtone rng;
if (resultCode == -1) {
Uri ringtone = (Uri) data.getParcelableExtra("android.intent.extra.ringtone.PICKED_URI");
String name = null;
if (ringtone != null && (rng = RingtoneManager.getRingtone(getParentActivity(), ringtone)) != null) {
if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
name = LocaleController.getString("SoundDefault", 2131694029);
} else {
name = rng.getTitle(getParentActivity());
}
rng.stop();
}
SharedPreferences preferences = getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
if (requestCode == 1) {
if (name != null && ringtone != null) {
editor.putString("GlobalSound", name);
editor.putString("GlobalSoundPath", ringtone.toString());
} else {
editor.putString("GlobalSound", "NoSound");
editor.putString("GlobalSoundPath", "NoSound");
}
((TextView) this.fragmentView.findViewById(2131297855)).setText(name == null ? LocaleController.getString("NoSound", 2131692260) : name);
} else if (requestCode == 0) {
if (name != null && ringtone != null) {
editor.putString("GroupSound", name);
editor.putString("GroupSoundPath", ringtone.toString());
} else {
editor.putString("GroupSound", "NoSound");
editor.putString("GroupSoundPath", "NoSound");
}
((TextView) this.fragmentView.findViewById(2131297776)).setText(name == null ? LocaleController.getString("NoSound", 2131692260) : name);
} else if (requestCode == 2) {
if (name != null && ringtone != null) {
editor.putString("ChannelSound", name);
editor.putString("ChannelSoundPath", ringtone.toString());
} else {
editor.putString("ChannelSound", "NoSound");
editor.putString("ChannelSoundPath", "NoSound");
}
((TextView) this.fragmentView.findViewById(2131297740)).setText(name == null ? LocaleController.getString("NoSound", 2131692260) : name);
}
editor.commit();
getNotificationsController().updateServerNotificationsSettings(requestCode);
}
}
private void setGroupSettingEnabled(boolean blnEnable) {
this.fragmentView.findViewById(2131297774).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297341).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297775).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297776).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297172).setEnabled(blnEnable);
this.fragmentView.findViewById(2131297170).setEnabled(blnEnable);
}
private void setChannelSettingEnabled(boolean blnEnable) {
this.fragmentView.findViewById(2131297738).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297336).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297739).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297740).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297157).setEnabled(blnEnable);
this.fragmentView.findViewById(2131297155).setEnabled(blnEnable);
}
private void setPrivateSettingEnabled(boolean blnEnable) {
this.fragmentView.findViewById(2131297821).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297351).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297822).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297855).setAlpha(blnEnable ? 1.0f : 0.5f);
this.fragmentView.findViewById(2131297214).setEnabled(blnEnable);
this.fragmentView.findViewById(2131297195).setEnabled(blnEnable);
}
private void setColors() {
this.fragmentView.findViewById(2131297210).setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
}