Skip to content

Commit ad055cc

Browse files
Merge pull request #77 from nextcloud/NPEinVersion
if no version info is available use oldest supported
2 parents 1838993 + 6ca2fac commit ad055cc

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/com/owncloud/android/lib/common/accounts/AccountUtils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,15 @@ public static OwnCloudCredentials getCredentialsForAccount(Context context, Acco
207207
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
208208

209209
String username = AccountUtils.getUsernameForAccount(account);
210-
OwnCloudVersion version = new OwnCloudVersion(am.getUserData(account, Constants.KEY_OC_VERSION));
210+
String ocVersion = am.getUserData(account, Constants.KEY_OC_VERSION);
211+
212+
OwnCloudVersion version;
213+
if (ocVersion == null) {
214+
// set to oldest supported version
215+
version = OwnCloudVersion.nextcloud_10;
216+
} else {
217+
version = new OwnCloudVersion(ocVersion);
218+
}
211219

212220
if (isOauth2) {
213221
String accessToken = am.blockingGetAuthToken(

src/com/owncloud/android/lib/resources/status/OwnCloudVersion.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
3838
0x04050000);
3939
public static final OwnCloudVersion nextcloud_9 = new OwnCloudVersion(0x09000000); // 9.0
4040

41+
public static final OwnCloudVersion nextcloud_10 = new OwnCloudVersion(0x0A000000); // 10.0
42+
4143
public static final OwnCloudVersion nextcloud_12 = new OwnCloudVersion(0x0C000000); // 12.0
4244

4345
public static final int MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000; // 4.5
@@ -77,19 +79,19 @@ protected OwnCloudVersion(int version) {
7779
mVersion = version;
7880
mIsValid = true;
7981
}
80-
81-
public OwnCloudVersion(String version){
82-
mVersion = 0;
83-
mIsValid = false;
84-
int countDots = version.length() - version.replace(".", "").length();
85-
86-
// Complete the version. Version must have 3 dots
87-
for (int i = countDots; i < MAX_DOTS; i++) {
88-
version = version + ".0";
89-
}
90-
91-
parseVersion(version);
9282

83+
public OwnCloudVersion(String version) {
84+
mVersion = 0;
85+
mIsValid = false;
86+
int countDots = version.length() - version.replace(".", "").length();
87+
88+
// Complete the version. Version must have 3 dots
89+
StringBuilder versionWithDots = new StringBuilder(version);
90+
for (int i = countDots; i < MAX_DOTS; i++) {
91+
versionWithDots.append(".0");
92+
}
93+
94+
parseVersion(versionWithDots.toString());
9395
}
9496

9597
public String toString() {

0 commit comments

Comments
 (0)