Online/Offline State

Change Online/Offline State with german button in value.de
This commit is contained in:
xlazvegaz 2014-02-28 17:14:31 +01:00
parent 9aeb8be893
commit 98431679f5
2 changed files with 76 additions and 31 deletions

View file

@ -741,29 +741,29 @@ public class MessagesController implements NotificationCenter.NotificationCenter
scheduleContactsReload = 0; scheduleContactsReload = 0;
} }
if (ApplicationLoader.lastPauseTime == 0) { // if (ApplicationLoader.lastPauseTime == 0) {
if (lastStatusUpdateTime != -1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSended)) { // if (lastStatusUpdateTime != -1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSended)) {
lastStatusUpdateTime = -1; // lastStatusUpdateTime = -1;
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus(); // TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
req.offline = false; // req.offline = false;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { // ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override // @Override
public void run(TLObject response, TLRPC.TL_error error) { // public void run(TLObject response, TLRPC.TL_error error) {
lastStatusUpdateTime = System.currentTimeMillis(); // lastStatusUpdateTime = System.currentTimeMillis();
} // }
}, null, true, RPCRequest.RPCRequestClassGeneric); // }, null, true, RPCRequest.RPCRequestClassGeneric);
offlineSended = false; // offlineSended = false;
} // }
} else if (!offlineSended && ApplicationLoader.lastPauseTime <= System.currentTimeMillis() - 2000) { // } else if (!offlineSended && ApplicationLoader.lastPauseTime <= System.currentTimeMillis() - 2000) {
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus(); // TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
req.offline = true; // req.offline = true;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() { // ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override // @Override
public void run(TLObject response, TLRPC.TL_error error) { // public void run(TLObject response, TLRPC.TL_error error) {
} // }
}, null, true, RPCRequest.RPCRequestClassGeneric); // }, null, true, RPCRequest.RPCRequestClassGeneric);
offlineSended = true; // offlineSended = true;
} // }
if (updatesStartWaitTime != 0 && updatesStartWaitTime + 1500 < currentTime) { if (updatesStartWaitTime != 0 && updatesStartWaitTime + 1500 < currentTime) {
FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE"); FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE");
@ -837,7 +837,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else { } else {
newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, ApplicationLoader.applicationContext.getString(R.string.AreTyping)))); newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, ApplicationLoader.applicationContext.getString(R.string.AreTyping))));
} }
} else { }
else {
newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, ApplicationLoader.applicationContext.getString(R.string.IsTyping)))); newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, ApplicationLoader.applicationContext.getString(R.string.IsTyping))));
} }
} }

View file

@ -63,6 +63,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int settingsSectionRow; int settingsSectionRow;
int textSizeRow; int textSizeRow;
int enableAnimationsRow; int enableAnimationsRow;
int enableInvisibleRow;
int notificationRow; int notificationRow;
int blockedRow; int blockedRow;
int backgroundRow; int backgroundRow;
@ -77,7 +78,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int photoDownloadSection; int photoDownloadSection;
int photoDownloadChatRow; int photoDownloadChatRow;
int photoDownloadPrivateRow; int photoDownloadPrivateRow;
private long lastStatusUpdateTime = 0;
private boolean offlineSended = false;
@Override @Override
public boolean onFragmentCreate() { public boolean onFragmentCreate() {
super.onFragmentCreate(); super.onFragmentCreate();
@ -146,6 +148,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
numberRow = rowCount++; numberRow = rowCount++;
settingsSectionRow = rowCount++; settingsSectionRow = rowCount++;
enableAnimationsRow = rowCount++; enableAnimationsRow = rowCount++;
enableInvisibleRow = rowCount++;
notificationRow = rowCount++; notificationRow = rowCount++;
blockedRow = rowCount++; blockedRow = rowCount++;
backgroundRow = rowCount++; backgroundRow = rowCount++;
@ -215,7 +218,18 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (listView != null) { if (listView != null) {
listView.invalidateViews(); listView.invalidateViews();
} }
} else if (i == notificationRow) { }
else if (i == enableInvisibleRow) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
boolean visible = preferences.getBoolean("enable_invisible", true);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("enable_invisible", !visible);
editor.commit();
if (listView != null) {
listView.invalidateViews();
}
}
else if (i == notificationRow) {
((ApplicationActivity)parentActivity).presentFragment(new SettingsNotificationsActivity(), "settings_notifications", false); ((ApplicationActivity)parentActivity).presentFragment(new SettingsNotificationsActivity(), "settings_notifications", false);
} else if (i == blockedRow) { } else if (i == blockedRow) {
((ApplicationActivity)parentActivity).presentFragment(new SettingsBlockedUsers(), "settings_blocked", false); ((ApplicationActivity)parentActivity).presentFragment(new SettingsBlockedUsers(), "settings_blocked", false);
@ -425,7 +439,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
return i == textSizeRow || i == enableAnimationsRow || i == blockedRow || i == notificationRow || i == backgroundRow || return i == textSizeRow || i == enableAnimationsRow || i == enableInvisibleRow || i == blockedRow || i == notificationRow || i == backgroundRow ||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == photoDownloadPrivateRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == terminateSessionsRow || i == photoDownloadPrivateRow ||
i == photoDownloadChatRow; i == photoDownloadChatRow;
} }
@ -607,7 +621,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
textView.setText("Unknown"); textView.setText("Unknown");
} }
divider.setVisibility(View.INVISIBLE); divider.setVisibility(View.INVISIBLE);
} else if (i == notificationRow) { }
else if (i == notificationRow) {
textView.setText(getStringEntry(R.string.NotificationsAndSounds)); textView.setText(getStringEntry(R.string.NotificationsAndSounds));
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
} else if (i == blockedRow) { } else if (i == blockedRow) {
@ -644,7 +659,36 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} else { } else {
checkButton.setImageResource(R.drawable.btn_check_off); checkButton.setImageResource(R.drawable.btn_check_off);
} }
} else if (i == sendByEnterRow) { }
else if (i == enableInvisibleRow) {
textView.setText(getStringEntry(R.string.EnableInvisible));
divider.setVisibility(View.VISIBLE);
boolean enabled = preferences.getBoolean("enable_invisible", true);
if (enabled) {
checkButton.setImageResource(R.drawable.btn_check_on);
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
req.offline = false;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
lastStatusUpdateTime = System.currentTimeMillis();
}
}, null, true, RPCRequest.RPCRequestClassGeneric);
offlineSended = false;
} else {
checkButton.setImageResource(R.drawable.btn_check_off);
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
req.offline = true;
ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
lastStatusUpdateTime = System.currentTimeMillis();
}
}, null, true, RPCRequest.RPCRequestClassGeneric);
offlineSended = true;
}
}
else if (i == sendByEnterRow) {
textView.setText(getStringEntry(R.string.SendByEnter)); textView.setText(getStringEntry(R.string.SendByEnter));
divider.setVisibility(View.INVISIBLE); divider.setVisibility(View.INVISIBLE);
boolean enabled = preferences.getBoolean("send_by_enter", false); boolean enabled = preferences.getBoolean("send_by_enter", false);
@ -732,11 +776,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
public int getItemViewType(int i) { public int getItemViewType(int i) {
if (i == profileRow) { if (i == profileRow) {
return 0; return 0;
} else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == photoDownloadSection) { } else if (i == numberSectionRow || i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == photoDownloadSection) {
return 1; return 1;
} else if (i == textSizeRow) { } else if (i == textSizeRow) {
return 5; return 5;
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == photoDownloadChatRow || i == photoDownloadPrivateRow) { } else if (i == enableAnimationsRow || i == enableInvisibleRow || i == sendByEnterRow || i == photoDownloadChatRow || i == photoDownloadPrivateRow) {
return 3; return 3;
} else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow) { } else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow) {
return 2; return 2;