2013-10-25 15:19:00 +00:00
|
|
|
/*
|
2013-12-20 19:25:49 +00:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 15:19:00 +00:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2014-05-20 20:22:44 +00:00
|
|
|
import android.app.AlertDialog;
|
2013-10-25 15:19:00 +00:00
|
|
|
import android.content.Context;
|
2014-05-20 20:22:44 +00:00
|
|
|
import android.content.DialogInterface;
|
2013-10-25 15:19:00 +00:00
|
|
|
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.AdapterView;
|
2014-11-11 22:16:17 +00:00
|
|
|
import android.widget.FrameLayout;
|
2013-10-25 15:19:00 +00:00
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
2014-08-22 14:24:33 +00:00
|
|
|
import org.telegram.android.AndroidUtilities;
|
2014-07-02 22:39:05 +00:00
|
|
|
import org.telegram.android.LocaleController;
|
2014-07-19 23:31:49 +00:00
|
|
|
import org.telegram.android.NotificationsController;
|
2014-08-22 14:24:33 +00:00
|
|
|
import org.telegram.android.NotificationCenter;
|
2014-02-28 22:28:25 +00:00
|
|
|
import org.telegram.messenger.TLObject;
|
|
|
|
import org.telegram.messenger.TLRPC;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.ConnectionsManager;
|
2013-12-20 19:25:49 +00:00
|
|
|
import org.telegram.messenger.FileLog;
|
2014-07-02 22:39:05 +00:00
|
|
|
import org.telegram.android.MessagesController;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.RPCRequest;
|
2014-06-20 00:18:13 +00:00
|
|
|
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
2014-11-12 10:41:46 +00:00
|
|
|
import org.telegram.ui.Cells.HeaderCell;
|
|
|
|
import org.telegram.ui.Cells.ShadowSectionCell;
|
2014-11-11 22:16:17 +00:00
|
|
|
import org.telegram.ui.Cells.TextCheckCell;
|
2014-11-12 10:41:46 +00:00
|
|
|
import org.telegram.ui.Cells.TextColorCell;
|
|
|
|
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
2014-11-13 20:10:14 +00:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2014-11-11 22:16:17 +00:00
|
|
|
import org.telegram.ui.Views.AvatarDrawable;
|
2014-06-17 14:45:21 +00:00
|
|
|
import org.telegram.ui.Views.ColorPickerView;
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-11-13 20:10:14 +00:00
|
|
|
public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
2013-10-25 15:19:00 +00:00
|
|
|
private ListView listView;
|
|
|
|
private boolean reseting = false;
|
|
|
|
|
2014-05-20 20:22:44 +00:00
|
|
|
private int notificationsServiceRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int messageSectionRow2;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int messageSectionRow;
|
|
|
|
private int messageAlertRow;
|
|
|
|
private int messagePreviewRow;
|
|
|
|
private int messageVibrateRow;
|
|
|
|
private int messageSoundRow;
|
2014-06-17 14:45:21 +00:00
|
|
|
private int messageLedRow;
|
2014-07-02 22:39:05 +00:00
|
|
|
private int messagePopupNotificationRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int groupSectionRow2;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int groupSectionRow;
|
|
|
|
private int groupAlertRow;
|
|
|
|
private int groupPreviewRow;
|
|
|
|
private int groupVibrateRow;
|
|
|
|
private int groupSoundRow;
|
2014-06-17 14:45:21 +00:00
|
|
|
private int groupLedRow;
|
2014-07-02 22:39:05 +00:00
|
|
|
private int groupPopupNotificationRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int inappSectionRow2;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int inappSectionRow;
|
|
|
|
private int inappSoundRow;
|
|
|
|
private int inappVibrateRow;
|
|
|
|
private int inappPreviewRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int eventsSectionRow2;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int eventsSectionRow;
|
|
|
|
private int contactJoinedRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int otherSectionRow2;
|
2014-07-19 23:31:49 +00:00
|
|
|
private int otherSectionRow;
|
|
|
|
private int badgeNumberRow;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int pebbleAlertRow;
|
2014-11-12 10:41:46 +00:00
|
|
|
private int resetSectionRow2;
|
2014-05-16 23:05:49 +00:00
|
|
|
private int resetSectionRow;
|
|
|
|
private int resetNotificationsRow;
|
|
|
|
private int rowCount = 0;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
2014-05-20 20:22:44 +00:00
|
|
|
notificationsServiceRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
messageSectionRow2 = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
messageSectionRow = rowCount++;
|
|
|
|
messageAlertRow = rowCount++;
|
|
|
|
messagePreviewRow = rowCount++;
|
2014-06-17 14:45:21 +00:00
|
|
|
messageLedRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
messageVibrateRow = rowCount++;
|
2014-07-02 22:39:05 +00:00
|
|
|
messagePopupNotificationRow = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
messageSoundRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
groupSectionRow2 = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
groupSectionRow = rowCount++;
|
|
|
|
groupAlertRow = rowCount++;
|
|
|
|
groupPreviewRow = rowCount++;
|
2014-06-17 14:45:21 +00:00
|
|
|
groupLedRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
groupVibrateRow = rowCount++;
|
2014-07-02 22:39:05 +00:00
|
|
|
groupPopupNotificationRow = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
groupSoundRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
inappSectionRow2 = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
inappSectionRow = rowCount++;
|
|
|
|
inappSoundRow = rowCount++;
|
|
|
|
inappVibrateRow = rowCount++;
|
|
|
|
inappPreviewRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
eventsSectionRow2 = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
eventsSectionRow = rowCount++;
|
|
|
|
contactJoinedRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
otherSectionRow2 = rowCount++;
|
2014-07-19 23:31:49 +00:00
|
|
|
otherSectionRow = rowCount++;
|
|
|
|
badgeNumberRow = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
pebbleAlertRow = rowCount++;
|
2014-11-12 10:41:46 +00:00
|
|
|
resetSectionRow2 = rowCount++;
|
2014-05-16 23:05:49 +00:00
|
|
|
resetSectionRow = rowCount++;
|
|
|
|
resetNotificationsRow = rowCount++;
|
|
|
|
|
2014-08-22 14:24:33 +00:00
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
2014-07-02 22:39:05 +00:00
|
|
|
|
2014-05-16 23:05:49 +00:00
|
|
|
return super.onFragmentCreate();
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:39:05 +00:00
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2014-08-22 14:24:33 +00:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
2014-07-02 22:39:05 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
2014-06-03 23:31:48 +00:00
|
|
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (fragmentView == null) {
|
2014-11-11 22:16:17 +00:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
2014-11-18 05:01:04 +00:00
|
|
|
actionBar.setAllowOverlayTitle(true);
|
2014-11-11 22:16:17 +00:00
|
|
|
actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
|
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
2014-06-03 23:31:48 +00:00
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-11-11 22:16:17 +00:00
|
|
|
fragmentView = new FrameLayout(getParentActivity());
|
|
|
|
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
|
|
|
|
|
|
|
listView = new ListView(getParentActivity());
|
|
|
|
listView.setDivider(null);
|
|
|
|
listView.setDividerHeight(0);
|
|
|
|
listView.setVerticalScrollBarEnabled(false);
|
|
|
|
AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5));
|
|
|
|
frameLayout.addView(listView);
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
|
|
|
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
|
|
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
|
|
|
listView.setLayoutParams(layoutParams);
|
|
|
|
listView.setAdapter(new ListAdapter(getParentActivity()));
|
2013-10-25 15:19:00 +00:00
|
|
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
@Override
|
2014-06-17 14:45:21 +00:00
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messageAlertRow || i == groupAlertRow) {
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
2013-12-20 19:25:49 +00:00
|
|
|
boolean enabled;
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messageAlertRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
enabled = preferences.getBoolean("EnableAll", true);
|
|
|
|
editor.putBoolean("EnableAll", !enabled);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == groupAlertRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
enabled = preferences.getBoolean("EnableGroup", true);
|
|
|
|
editor.putBoolean("EnableGroup", !enabled);
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-07-02 22:39:05 +00:00
|
|
|
updateServerNotificationsSettings(i == groupAlertRow);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == messagePreviewRow || i == groupPreviewRow) {
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
2013-12-20 19:25:49 +00:00
|
|
|
boolean enabled;
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messagePreviewRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
enabled = preferences.getBoolean("EnablePreviewAll", true);
|
|
|
|
editor.putBoolean("EnablePreviewAll", !enabled);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == groupPreviewRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
enabled = preferences.getBoolean("EnablePreviewGroup", true);
|
|
|
|
editor.putBoolean("EnablePreviewGroup", !enabled);
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-07-02 22:39:05 +00:00
|
|
|
updateServerNotificationsSettings(i == groupPreviewRow);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == messageSoundRow || i == groupSoundRow) {
|
2013-12-20 19:25:49 +00:00
|
|
|
try {
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
2014-03-22 22:31:55 +00:00
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
2013-12-20 19:25:49 +00:00
|
|
|
Uri currentSound = null;
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2013-12-20 19:25:49 +00:00
|
|
|
String defaultPath = null;
|
|
|
|
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
|
|
|
if (defaultUri != null) {
|
|
|
|
defaultPath = defaultUri.getPath();
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messageSoundRow) {
|
2013-12-20 19:25:49 +00:00
|
|
|
String path = preferences.getString("GlobalSoundPath", defaultPath);
|
|
|
|
if (path != null && !path.equals("NoSound")) {
|
|
|
|
if (path.equals(defaultPath)) {
|
|
|
|
currentSound = defaultUri;
|
|
|
|
} else {
|
|
|
|
currentSound = Uri.parse(path);
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == groupSoundRow) {
|
2013-12-20 19:25:49 +00:00
|
|
|
String path = preferences.getString("GroupSoundPath", defaultPath);
|
|
|
|
if (path != null && !path.equals("NoSound")) {
|
|
|
|
if (path.equals(defaultPath)) {
|
|
|
|
currentSound = defaultUri;
|
|
|
|
} else {
|
|
|
|
currentSound = Uri.parse(path);
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-20 19:25:49 +00:00
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
2014-09-30 22:36:18 +00:00
|
|
|
startActivityForResult(tmpIntent, i);
|
2013-12-20 19:25:49 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == resetNotificationsRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (reseting) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
reseting = true;
|
|
|
|
TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
|
2014-03-22 22:31:55 +00:00
|
|
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
|
|
|
public void run(TLObject response, TLRPC.TL_error error) {
|
2014-11-06 21:34:47 +00:00
|
|
|
AndroidUtilities.runOnUIThread(new Runnable() {
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2014-03-22 22:31:55 +00:00
|
|
|
MessagesController.getInstance().enableJoined = true;
|
2013-10-25 15:19:00 +00:00
|
|
|
reseting = false;
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
editor.clear();
|
|
|
|
editor.commit();
|
2014-06-10 23:05:54 +00:00
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
if (getParentActivity() != null) {
|
2014-06-14 08:36:01 +00:00
|
|
|
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("ResetNotificationsText", R.string.ResetNotificationsText), Toast.LENGTH_SHORT);
|
2014-06-10 23:05:54 +00:00
|
|
|
toast.show();
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-07-02 22:39:05 +00:00
|
|
|
});
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappSoundRow) {
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("EnableInAppSounds", true);
|
|
|
|
editor.putBoolean("EnableInAppSounds", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappVibrateRow) {
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("EnableInAppVibrate", true);
|
|
|
|
editor.putBoolean("EnableInAppVibrate", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappPreviewRow) {
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("EnableInAppPreview", true);
|
|
|
|
editor.putBoolean("EnableInAppPreview", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == contactJoinedRow) {
|
2014-02-04 18:36:55 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("EnableContactJoined", true);
|
2014-03-22 22:31:55 +00:00
|
|
|
MessagesController.getInstance().enableJoined = !enabled;
|
2014-02-04 18:36:55 +00:00
|
|
|
editor.putBoolean("EnableContactJoined", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == pebbleAlertRow) {
|
2014-03-23 12:12:13 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("EnablePebbleNotifications", false);
|
|
|
|
editor.putBoolean("EnablePebbleNotifications", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
2014-07-19 23:31:49 +00:00
|
|
|
} else if (i == badgeNumberRow) {
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
boolean enabled = preferences.getBoolean("badgeNumber", true);
|
|
|
|
editor.putBoolean("badgeNumber", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
NotificationsController.getInstance().setBadgeEnabled(!enabled);
|
2014-05-20 20:22:44 +00:00
|
|
|
} else if (i == notificationsServiceRow) {
|
|
|
|
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
boolean enabled = preferences.getBoolean("pushService", true);
|
|
|
|
if (!enabled) {
|
|
|
|
final SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
editor.putBoolean("pushService", !enabled);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
ApplicationLoader.startPushService();
|
|
|
|
} else {
|
2014-06-14 08:36:01 +00:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-03 23:31:48 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-05-20 20:22:44 +00:00
|
|
|
builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
ApplicationLoader.stopPushService();
|
|
|
|
final SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
editor.putBoolean("pushService", false);
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2014-05-20 20:22:44 +00:00
|
|
|
}
|
2014-06-17 14:45:21 +00:00
|
|
|
} else if (i == messageLedRow || i == groupLedRow) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
|
|
|
|
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
|
|
|
|
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
if (i == messageLedRow) {
|
|
|
|
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
|
|
|
|
} else if (i == groupLedRow) {
|
|
|
|
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
|
|
|
|
}
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
|
|
|
|
builder.setView(view);
|
|
|
|
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int which) {
|
|
|
|
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
if (i == messageLedRow) {
|
|
|
|
editor.putInt("MessagesLed", colorPickerView.getColor());
|
|
|
|
} else if (i == groupLedRow) {
|
|
|
|
editor.putInt("GroupLed", colorPickerView.getColor());
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
if (i == messageLedRow) {
|
|
|
|
editor.putInt("MessagesLed", 0);
|
|
|
|
} else if (i == groupLedRow) {
|
|
|
|
editor.putInt("GroupLed", 0);
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
showAlertDialog(builder);
|
2014-07-02 22:39:05 +00:00
|
|
|
} else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
|
|
|
|
builder.setItems(new CharSequence[] {
|
|
|
|
LocaleController.getString("NoPopup", R.string.NoPopup),
|
|
|
|
LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
|
|
|
|
LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
|
|
|
|
LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup)
|
|
|
|
}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
if (i == messagePopupNotificationRow) {
|
|
|
|
editor.putInt("popupAll", which);
|
|
|
|
} else if (i == groupPopupNotificationRow) {
|
|
|
|
editor.putInt("popupGroup", which);
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
2014-08-22 14:24:33 +00:00
|
|
|
} else if (i == messageVibrateRow || i == groupVibrateRow) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
|
|
|
|
builder.setItems(new CharSequence[] {
|
|
|
|
LocaleController.getString("Disabled", R.string.Disabled),
|
|
|
|
LocaleController.getString("Default", R.string.Default),
|
|
|
|
LocaleController.getString("Short", R.string.Short),
|
|
|
|
LocaleController.getString("Long", R.string.Long)
|
|
|
|
}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
String param = "vibrate_messages";
|
|
|
|
if (i == groupVibrateRow) {
|
|
|
|
param = "vibrate_group";
|
|
|
|
}
|
|
|
|
if (which == 0) {
|
|
|
|
editor.putInt(param, 2);
|
|
|
|
} else if (which == 1) {
|
|
|
|
editor.putInt(param, 0);
|
|
|
|
} else if (which == 2) {
|
|
|
|
editor.putInt(param, 1);
|
|
|
|
} else if (which == 3) {
|
|
|
|
editor.putInt(param, 3);
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showAlertDialog(builder);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
|
|
if (parent != null) {
|
|
|
|
parent.removeView(fragmentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:39:05 +00:00
|
|
|
public void updateServerNotificationsSettings(boolean group) {
|
2014-07-26 22:28:33 +00:00
|
|
|
//disable global settings sync
|
|
|
|
/*SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2014-07-02 22:39:05 +00:00
|
|
|
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
|
|
|
|
req.settings = new TLRPC.TL_inputPeerNotifySettings();
|
|
|
|
req.settings.sound = "default";
|
|
|
|
req.settings.events_mask = 0;
|
|
|
|
if (!group) {
|
|
|
|
req.peer = new TLRPC.TL_inputNotifyUsers();
|
|
|
|
req.settings.mute_until = preferences.getBoolean("EnableAll", true) ? 0 : Integer.MAX_VALUE;
|
|
|
|
req.settings.show_previews = preferences.getBoolean("EnablePreviewAll", true);
|
|
|
|
} else {
|
|
|
|
req.peer = new TLRPC.TL_inputNotifyChats();
|
|
|
|
req.settings.mute_until = preferences.getBoolean("EnableGroup", true) ? 0 : Integer.MAX_VALUE;
|
|
|
|
req.settings.show_previews = preferences.getBoolean("EnablePreviewGroup", true);
|
|
|
|
}
|
|
|
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
|
|
|
@Override
|
|
|
|
public void run(TLObject response, TLRPC.TL_error error) {
|
|
|
|
|
|
|
|
}
|
2014-07-26 22:28:33 +00:00
|
|
|
});*/
|
2014-07-02 22:39:05 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
2014-03-26 20:16:28 +00:00
|
|
|
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
|
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
|
|
|
String name = null;
|
2014-06-03 23:31:48 +00:00
|
|
|
if (ringtone != null) {
|
|
|
|
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (rng != null) {
|
2014-03-22 22:31:55 +00:00
|
|
|
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
|
|
|
name = LocaleController.getString("Default", R.string.Default);
|
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
name = rng.getTitle(getParentActivity());
|
2014-03-22 22:31:55 +00:00
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
rng.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
|
2014-05-16 23:05:49 +00:00
|
|
|
if (requestCode == messageSoundRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (name != null && ringtone != null) {
|
|
|
|
editor.putString("GlobalSound", name);
|
|
|
|
editor.putString("GlobalSoundPath", ringtone.toString());
|
|
|
|
} else {
|
|
|
|
editor.putString("GlobalSound", "NoSound");
|
|
|
|
editor.putString("GlobalSoundPath", "NoSound");
|
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (requestCode == groupSoundRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (name != null && ringtone != null) {
|
|
|
|
editor.putString("GroupSound", name);
|
|
|
|
editor.putString("GroupSoundPath", ringtone.toString());
|
|
|
|
} else {
|
|
|
|
editor.putString("GroupSound", "NoSound");
|
|
|
|
editor.putString("GroupSoundPath", "NoSound");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:39:05 +00:00
|
|
|
@Override
|
|
|
|
public void didReceivedNotification(int id, Object... args) {
|
2014-08-22 14:24:33 +00:00
|
|
|
if (id == NotificationCenter.notificationsSettingsUpdated) {
|
2014-07-02 22:39:05 +00:00
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 00:18:13 +00:00
|
|
|
private class ListAdapter extends BaseFragmentAdapter {
|
2013-10-25 15:19:00 +00:00
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
public ListAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean areAllItemsEnabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(int i) {
|
2014-11-12 10:41:46 +00:00
|
|
|
return !(i == messageSectionRow || i == groupSectionRow || i == inappSectionRow ||
|
|
|
|
i == eventsSectionRow || i == otherSectionRow || i == resetSectionRow ||
|
|
|
|
i == messageSectionRow2 || i == eventsSectionRow2 || i == groupSectionRow2 ||
|
|
|
|
i == inappSectionRow2 || i == otherSectionRow2 || i == resetSectionRow2);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
2014-05-16 23:05:49 +00:00
|
|
|
return rowCount;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getItem(int i) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getItemId(int i) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasStableIds() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
|
|
|
int type = getItemViewType(i);
|
|
|
|
if (type == 0) {
|
|
|
|
if (view == null) {
|
2014-11-12 10:41:46 +00:00
|
|
|
view = new HeaderCell(mContext);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messageSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("MessageNotifications", R.string.MessageNotifications));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == groupSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("GroupNotifications", R.string.GroupNotifications));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("InAppNotifications", R.string.InAppNotifications));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == eventsSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("Events", R.string.Events));
|
2014-07-19 23:31:49 +00:00
|
|
|
} else if (i == otherSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("PhoneOther", R.string.PhoneOther));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == resetSectionRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
((HeaderCell) view).setText(LocaleController.getString("Reset", R.string.Reset));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} if (type == 1) {
|
|
|
|
if (view == null) {
|
2014-11-11 22:16:17 +00:00
|
|
|
view = new TextCheckCell(mContext);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-11-11 22:16:17 +00:00
|
|
|
TextCheckCell checkCell = (TextCheckCell) view;
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2014-11-12 10:41:46 +00:00
|
|
|
if (i == messageAlertRow) {
|
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("Alert", R.string.Alert), preferences.getBoolean("EnableAll", true), true);
|
|
|
|
} else if (i == groupAlertRow) {
|
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("Alert", R.string.Alert), preferences.getBoolean("EnableGroup", true), true);
|
|
|
|
} else if (i == messagePreviewRow) {
|
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("MessagePreview", R.string.MessagePreview), preferences.getBoolean("EnablePreviewAll", true), true);
|
|
|
|
} else if (i == groupPreviewRow) {
|
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("MessagePreview", R.string.MessagePreview), preferences.getBoolean("EnablePreviewGroup", true), true);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappSoundRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("InAppSounds", R.string.InAppSounds), preferences.getBoolean("EnableInAppSounds", true), true);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappVibrateRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("InAppVibrate", R.string.InAppVibrate), preferences.getBoolean("EnableInAppVibrate", true), true);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == inappPreviewRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("InAppPreview", R.string.InAppPreview), preferences.getBoolean("EnableInAppPreview", true), false);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == contactJoinedRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), false);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == pebbleAlertRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("Pebble", R.string.Pebble), preferences.getBoolean("EnablePebbleNotifications", false), false);
|
2014-05-20 20:22:44 +00:00
|
|
|
} else if (i == notificationsServiceRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), preferences.getBoolean("pushService", true), false);
|
2014-07-19 23:31:49 +00:00
|
|
|
} else if (i == badgeNumberRow) {
|
2014-11-11 22:16:17 +00:00
|
|
|
checkCell.setTextAndCheck(LocaleController.getString("BadgeNumber", R.string.BadgeNumber), preferences.getBoolean("badgeNumber", true), true);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (type == 2) {
|
|
|
|
if (view == null) {
|
2014-11-12 10:41:46 +00:00
|
|
|
view = new TextDetailSettingsCell(mContext);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-11-12 10:41:46 +00:00
|
|
|
|
|
|
|
TextDetailSettingsCell textCell = (TextDetailSettingsCell) view;
|
|
|
|
|
2013-11-04 12:31:01 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2014-05-16 23:05:49 +00:00
|
|
|
|
|
|
|
if (i == messageSoundRow || i == groupSoundRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setMultilineDetail(false);
|
|
|
|
String value = null;
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == messageSoundRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
value = preferences.getString("GlobalSound", LocaleController.getString("Default", R.string.Default));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == groupSoundRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
value = preferences.getString("GroupSound", LocaleController.getString("Default", R.string.Default));
|
2014-05-16 23:05:49 +00:00
|
|
|
}
|
2014-11-12 10:41:46 +00:00
|
|
|
if (value.equals("NoSound")) {
|
|
|
|
value = LocaleController.getString("NoSound", R.string.NoSound);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setTextAndValue(LocaleController.getString("Sound", R.string.Sound), value, false);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == resetNotificationsRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setMultilineDetail(true);
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("ResetAllNotifications", R.string.ResetAllNotifications), LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom), false);
|
2014-07-02 22:39:05 +00:00
|
|
|
} else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setMultilineDetail(false);
|
2014-07-02 22:39:05 +00:00
|
|
|
int option = 0;
|
|
|
|
if (i == messagePopupNotificationRow) {
|
|
|
|
option = preferences.getInt("popupAll", 0);
|
|
|
|
} else if (i == groupPopupNotificationRow) {
|
|
|
|
option = preferences.getInt("popupGroup", 0);
|
|
|
|
}
|
2014-11-12 10:41:46 +00:00
|
|
|
String value;
|
2014-07-02 22:39:05 +00:00
|
|
|
if (option == 0) {
|
2014-11-12 10:41:46 +00:00
|
|
|
value = LocaleController.getString("NoPopup", R.string.NoPopup);
|
2014-07-02 22:39:05 +00:00
|
|
|
} else if (option == 1) {
|
2014-11-12 10:41:46 +00:00
|
|
|
value = LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn);
|
2014-07-02 22:39:05 +00:00
|
|
|
} else if (option == 2) {
|
2014-11-12 10:41:46 +00:00
|
|
|
value = LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff);
|
|
|
|
} else {
|
|
|
|
value = LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup);
|
|
|
|
}
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("PopupNotification", R.string.PopupNotification), value, true);
|
|
|
|
} else if (i == messageVibrateRow || i == groupVibrateRow) {
|
|
|
|
textCell.setMultilineDetail(false);
|
|
|
|
int value = 0;
|
|
|
|
if (i == messageVibrateRow) {
|
|
|
|
value = preferences.getInt("vibrate_messages", 0);
|
|
|
|
} else if (i == groupVibrateRow) {
|
|
|
|
value = preferences.getInt("vibrate_group", 0);
|
|
|
|
}
|
|
|
|
if (value == 0) {
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Default", R.string.Default), true);
|
|
|
|
} else if (value == 1) {
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Short", R.string.Short), true);
|
|
|
|
} else if (value == 2) {
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Disabled", R.string.Disabled), true);
|
|
|
|
} else if (value == 3) {
|
|
|
|
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true);
|
2014-07-02 22:39:05 +00:00
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-06-17 14:45:21 +00:00
|
|
|
} else if (type == 3) {
|
|
|
|
if (view == null) {
|
2014-11-12 10:41:46 +00:00
|
|
|
view = new TextColorCell(mContext);
|
2014-06-17 14:45:21 +00:00
|
|
|
}
|
2014-11-12 10:41:46 +00:00
|
|
|
|
|
|
|
TextColorCell textCell = (TextColorCell) view;
|
|
|
|
|
2014-06-17 14:45:21 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
if (i == messageLedRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), preferences.getInt("MessagesLed", 0xff00ff00), true);
|
2014-06-17 14:45:21 +00:00
|
|
|
} else if (i == groupLedRow) {
|
2014-11-12 10:41:46 +00:00
|
|
|
textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), preferences.getInt("GroupLed", 0xff00ff00), true);
|
2014-06-17 14:45:21 +00:00
|
|
|
}
|
2014-08-22 14:24:33 +00:00
|
|
|
} else if (type == 4) {
|
|
|
|
if (view == null) {
|
2014-11-12 10:41:46 +00:00
|
|
|
view = new ShadowSectionCell(mContext);
|
2014-08-22 14:24:33 +00:00
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int i) {
|
2014-11-12 10:41:46 +00:00
|
|
|
if (i == messageSectionRow || i == groupSectionRow || i == inappSectionRow ||
|
|
|
|
i == eventsSectionRow || i == otherSectionRow || i == resetSectionRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
return 0;
|
2014-11-12 10:41:46 +00:00
|
|
|
} else if (i == messageAlertRow || i == messagePreviewRow || i == groupAlertRow ||
|
|
|
|
i == groupPreviewRow || i == inappSoundRow || i == inappVibrateRow ||
|
|
|
|
i == inappPreviewRow || i == contactJoinedRow || i == pebbleAlertRow ||
|
|
|
|
i == notificationsServiceRow || i == badgeNumberRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
return 1;
|
2014-06-17 14:45:21 +00:00
|
|
|
} else if (i == messageLedRow || i == groupLedRow) {
|
|
|
|
return 3;
|
2014-11-12 10:41:46 +00:00
|
|
|
} else if (i == messageSectionRow2 || i == eventsSectionRow2 || i == groupSectionRow2 ||
|
|
|
|
i == inappSectionRow2 || i == otherSectionRow2 || i == resetSectionRow2) {
|
2014-08-22 14:24:33 +00:00
|
|
|
return 4;
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getViewTypeCount() {
|
2014-08-22 14:24:33 +00:00
|
|
|
return 5;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|