Skip to content

Commit 58fe9a5

Browse files
author
Grigory Fedorov
committed
Merge branch 'release/1.0.170'
2 parents 88d86d5 + 9e741c9 commit 58fe9a5

File tree

131 files changed

+1441
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1441
-288
lines changed

xabber/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
defaultConfig {
1111
minSdkVersion 15
1212
targetSdkVersion 25
13-
versionCode 341
14-
versionName '1.0.169'
13+
versionCode 342
14+
versionName '1.0.170'
1515
}
1616

1717
lintOptions {

xabber/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
3737
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
3838
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
39-
<uses-permission android:name="android.permission.CAMERA" />
4039
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
4140

4241
<application

xabber/src/main/java/com/xabber/android/data/ActivityManager.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ public void clearStack(boolean finishRoot) {
9999
ContactListActivity root = null;
100100
rebuildStack();
101101
for (Activity activity : activities) {
102-
if (!finishRoot && root == null && activity instanceof ContactListActivity)
102+
if (!finishRoot && root == null && activity instanceof ContactListActivity) {
103103
root = (ContactListActivity) activity;
104-
else
104+
} else {
105105
activity.finish();
106+
}
106107
}
107108
rebuildStack();
108109
}
@@ -313,7 +314,12 @@ private void fetchTaskIndex(Activity activity, Intent intent) {
313314

314315
@Override
315316
public void onUnload() {
316-
clearStack(true);
317+
Application.getInstance().runOnUiThread(new Runnable() {
318+
@Override
319+
public void run() {
320+
clearStack(true);
321+
}
322+
});
317323
}
318324

319325
}

xabber/src/main/java/com/xabber/android/data/account/AccountItem.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ public AccountItem(boolean custom, String host,
140140
}
141141

142142
/**
143-
* @return Valid priority value between -128 and 128.
143+
* @return Valid priority value between -128 and 127.
144144
*/
145145
static private int getValidPriority(int priority) {
146-
return Math.min(128, Math.max(-128, priority));
146+
return Math.min(127, Math.max(-128, priority));
147147
}
148148

149149
/**
@@ -310,9 +310,11 @@ else if (statusMode == StatusMode.xa)
310310
priority = SettingsManager.connectionPriorityXa();
311311
else
312312
throw new IllegalStateException();
313-
} else
313+
} else {
314314
priority = this.priority;
315-
return new Presence(Type.available, statusText, priority,
315+
}
316+
317+
return new Presence(Type.available, statusText, AccountItem.getValidPriority(priority),
316318
statusMode.getMode());
317319
}
318320
}

xabber/src/main/java/com/xabber/android/data/account/AccountManager.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.xabber.android.data.OnWipeListener;
3434
import com.xabber.android.data.SettingsManager;
3535
import com.xabber.android.data.account.listeners.OnAccountAddedListener;
36-
import com.xabber.android.data.account.listeners.OnAccountArchiveModeChangedListener;
3736
import com.xabber.android.data.account.listeners.OnAccountChangedListener;
3837
import com.xabber.android.data.account.listeners.OnAccountDisabledListener;
3938
import com.xabber.android.data.account.listeners.OnAccountEnabledListener;
@@ -417,6 +416,10 @@ private Resourcepart generateResource() {
417416
*/
418417
private void removeAccountWithoutCallback(final AccountJid account) {
419418
final AccountItem accountItem = getAccount(account);
419+
if (accountItem == null) {
420+
return;
421+
}
422+
420423
boolean wasEnabled = accountItem.isEnabled();
421424
accountItem.setEnabled(false);
422425
accountItem.disconnect();
@@ -514,12 +517,7 @@ public void updateAccount(AccountJid account, boolean custom, String host, int p
514517
}
515518
}
516519
if (result.getArchiveMode() != archiveMode) {
517-
reconnect = (result.getArchiveMode() == ArchiveMode.server) != (archiveMode == ArchiveMode.server);
518520
result.setArchiveMode(archiveMode);
519-
for (OnAccountArchiveModeChangedListener listener :
520-
application.getManagers(OnAccountArchiveModeChangedListener.class)) {
521-
listener.onAccountArchiveModeChanged(result);
522-
}
523521
}
524522
if (changed && enabled) {
525523
onAccountEnabled(result);
@@ -554,8 +552,10 @@ public void updateAccount(AccountJid account, boolean custom, String host, int p
554552

555553
public void setKeyPair(AccountJid account, KeyPair keyPair) {
556554
AccountItem accountItem = getAccount(account);
557-
accountItem.setKeyPair(keyPair);
558-
requestToWriteAccount(accountItem);
555+
if (accountItem != null) {
556+
accountItem.setKeyPair(keyPair);
557+
requestToWriteAccount(accountItem);
558+
}
559559
}
560560

561561
public void setEnabled(AccountJid account, boolean enabled) {
@@ -568,14 +568,6 @@ public void setEnabled(AccountJid account, boolean enabled) {
568568
requestToWriteAccount(accountItem);
569569
}
570570

571-
public ArchiveMode getArchiveMode(AccountJid account) {
572-
AccountItem accountItem = getAccount(account);
573-
if (accountItem == null) {
574-
return ArchiveMode.available;
575-
}
576-
return accountItem.getArchiveMode();
577-
}
578-
579571
/**
580572
* @return List of enabled accounts.
581573
*/
@@ -816,18 +808,25 @@ public void resendPresence() {
816808

817809
public void setColor(AccountJid accountJid, int colorIndex) {
818810
AccountItem accountItem = getAccount(accountJid);
819-
accountItem.setColorIndex(colorIndex);
820-
requestToWriteAccount(accountItem);
811+
if (accountItem != null) {
812+
accountItem.setColorIndex(colorIndex);
813+
requestToWriteAccount(accountItem);
814+
}
821815
}
822816

823817
public void setClearHistoryOnExit(AccountJid accountJid, boolean clearHistoryOnExit) {
824818
AccountItem accountItem = getAccount(accountJid);
825-
accountItem.setClearHistoryOnExit(clearHistoryOnExit);
826-
requestToWriteAccount(accountItem);
819+
if (accountItem != null) {
820+
accountItem.setClearHistoryOnExit(clearHistoryOnExit);
821+
requestToWriteAccount(accountItem);
822+
}
827823
}
828824

829825
public void setMamDefaultBehaviour(AccountJid accountJid, MamPrefsIQ.DefaultBehavior mamDefaultBehavior) {
830826
AccountItem accountItem = getAccount(accountJid);
827+
if (accountItem == null) {
828+
return;
829+
}
831830

832831
if (!accountItem.getMamDefaultBehaviour().equals(mamDefaultBehavior)) {
833832
accountItem.setMamDefaultBehaviour(mamDefaultBehavior);
@@ -838,6 +837,9 @@ public void setMamDefaultBehaviour(AccountJid accountJid, MamPrefsIQ.DefaultBeha
838837

839838
public void setLoadHistorySettings(AccountJid accountJid, LoadHistorySettings loadHistorySettings) {
840839
AccountItem accountItem = getAccount(accountJid);
840+
if (accountItem == null) {
841+
return;
842+
}
841843

842844
if (!accountItem.getLoadHistorySettings().equals(loadHistorySettings)) {
843845
accountItem.setLoadHistorySettings(loadHistorySettings);

xabber/src/main/java/com/xabber/android/data/account/listeners/OnAccountArchiveModeChangedListener.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

xabber/src/main/java/com/xabber/android/data/connection/ConnectionManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.xabber.android.data.OnCloseListener;
1818
import com.xabber.android.data.OnInitializedListener;
19+
import com.xabber.android.data.account.AccountItem;
1920
import com.xabber.android.data.account.AccountManager;
2021
import com.xabber.android.data.entity.AccountJid;
2122
import com.xabber.android.data.log.LogManager;
@@ -66,7 +67,10 @@ public void onInitialized() {
6667
public void onClose() {
6768
LogManager.i(LOG_TAG, "onClose");
6869
for (AccountJid accountJid : AccountManager.getInstance().getEnabledAccounts()) {
69-
AccountManager.getInstance().getAccount(accountJid).disconnect();
70+
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
71+
if (accountItem != null) {
72+
accountItem.disconnect();
73+
}
7074
}
7175
}
7276

xabber/src/main/java/com/xabber/android/data/connection/ReconnectionManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ private ReconnectionInfo getReconnectionInfo(AccountJid accountJid) {
132132

133133
void resetReconnectionInfo(AccountJid accountJid) {
134134
ReconnectionInfo info = connections.get(accountJid);
135-
info.reset();
135+
if (info != null) {
136+
info.reset();
137+
}
136138
}
137139

138140
@Override

xabber/src/main/java/com/xabber/android/data/connection/StanzaSender.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.support.annotation.NonNull;
44

55
import com.xabber.android.R;
6+
import com.xabber.android.data.account.AccountItem;
67
import com.xabber.android.data.log.LogManager;
78
import com.xabber.android.data.NetworkException;
89
import com.xabber.android.data.account.AccountManager;
@@ -19,7 +20,7 @@ public class StanzaSender {
1920
private static String LOG_TAG = StanzaSender.class.getSimpleName();
2021

2122
/**
22-
* Send stanza to authenticated connection and and acknowledged listener if Stream Management is enabled on server.
23+
* Send stanza to authenticated connection and add acknowledged listener if Stream Management is enabled on server.
2324
*/
2425
public static void sendStanza(AccountJid account, Message stanza, StanzaListener acknowledgedListener) throws NetworkException {
2526
XMPPTCPConnection xmppConnection = getXmppTcpConnection(account);
@@ -58,7 +59,12 @@ private static void sendStanza(@NonNull XMPPTCPConnection xmppConnection, @NonNu
5859
}
5960

6061
private static @NonNull XMPPTCPConnection getXmppTcpConnection(AccountJid account) throws NetworkException {
61-
XMPPTCPConnection returnConnection = AccountManager.getInstance().getAccount(account).getConnection();
62+
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
63+
if (accountItem == null) {
64+
throw new NetworkException(R.string.NOT_CONNECTED);
65+
}
66+
67+
XMPPTCPConnection returnConnection = accountItem.getConnection();
6268
if (!returnConnection.isAuthenticated()) {
6369
throw new NetworkException(R.string.NOT_CONNECTED);
6470
}

xabber/src/main/java/com/xabber/android/data/extension/httpfileupload/HttpFileUploadManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import com.xabber.android.R;
55
import com.xabber.android.data.Application;
6+
import com.xabber.android.data.account.AccountItem;
67
import com.xabber.android.data.account.AccountManager;
78
import com.xabber.android.data.connection.ConnectionItem;
89
import com.xabber.android.data.entity.AccountJid;
@@ -66,6 +67,11 @@ public void uploadFile(final AccountJid account, final UserJid user, final Strin
6667
return;
6768
}
6869

70+
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
71+
if (accountItem == null) {
72+
return;
73+
}
74+
6975
final File file = new File(filePath);
7076

7177
final com.xabber.xmpp.httpfileupload.Request httpFileUpload = new com.xabber.xmpp.httpfileupload.Request();
@@ -74,7 +80,7 @@ public void uploadFile(final AccountJid account, final UserJid user, final Strin
7480
httpFileUpload.setTo(uploadServerUrl);
7581

7682
try {
77-
AccountManager.getInstance().getAccount(account).getConnection().sendIqWithResponseCallback(httpFileUpload, new StanzaListener() {
83+
accountItem.getConnection().sendIqWithResponseCallback(httpFileUpload, new StanzaListener() {
7884
@Override
7985
public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException {
8086
if (!(packet instanceof Slot)) {

0 commit comments

Comments
 (0)