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;
}
if (ApplicationLoader.lastPauseTime == 0) {
if (lastStatusUpdateTime != -1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSended)) {
lastStatusUpdateTime = -1;
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 if (!offlineSended && ApplicationLoader.lastPauseTime <= System.currentTimeMillis() - 2000) {
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) {
}
}, null, true, RPCRequest.RPCRequestClassGeneric);
offlineSended = true;
}
// if (ApplicationLoader.lastPauseTime == 0) {
// if (lastStatusUpdateTime != -1 && (lastStatusUpdateTime == 0 || lastStatusUpdateTime <= System.currentTimeMillis() - 55000 || offlineSended)) {
// lastStatusUpdateTime = -1;
// 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 if (!offlineSended && ApplicationLoader.lastPauseTime <= System.currentTimeMillis() - 2000) {
// 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) {
// }
// }, null, true, RPCRequest.RPCRequestClassGeneric);
// offlineSended = true;
// }
if (updatesStartWaitTime != 0 && updatesStartWaitTime + 1500 < currentTime) {
FileLog.e("tmessages", "UPDATES WAIT TIMEOUT - CHECK QUEUE");
@ -837,7 +837,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else {
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))));
}
}

View file

@ -63,6 +63,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int settingsSectionRow;
int textSizeRow;
int enableAnimationsRow;
int enableInvisibleRow;
int notificationRow;
int blockedRow;
int backgroundRow;
@ -77,7 +78,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
int photoDownloadSection;
int photoDownloadChatRow;
int photoDownloadPrivateRow;
private long lastStatusUpdateTime = 0;
private boolean offlineSended = false;
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
@ -146,6 +148,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
numberRow = rowCount++;
settingsSectionRow = rowCount++;
enableAnimationsRow = rowCount++;
enableInvisibleRow = rowCount++;
notificationRow = rowCount++;
blockedRow = rowCount++;
backgroundRow = rowCount++;
@ -215,7 +218,18 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (listView != null) {
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);
} else if (i == blockedRow) {
((ApplicationActivity)parentActivity).presentFragment(new SettingsBlockedUsers(), "settings_blocked", false);
@ -425,7 +439,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
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 == photoDownloadChatRow;
}
@ -607,7 +621,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
textView.setText("Unknown");
}
divider.setVisibility(View.INVISIBLE);
} else if (i == notificationRow) {
}
else if (i == notificationRow) {
textView.setText(getStringEntry(R.string.NotificationsAndSounds));
divider.setVisibility(View.VISIBLE);
} else if (i == blockedRow) {
@ -644,7 +659,36 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} else {
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));
divider.setVisibility(View.INVISIBLE);
boolean enabled = preferences.getBoolean("send_by_enter", false);
@ -732,11 +776,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
public int getItemViewType(int i) {
if (i == profileRow) {
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;
} else if (i == textSizeRow) {
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;
} else if (i == numberRow || i == notificationRow || i == blockedRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == terminateSessionsRow) {
return 2;