Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Convert capabilities related classes to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
davigonz committed Apr 2, 2019
1 parent 80c2fb2 commit 301d92d
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 729 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ class RemoteShare : Parcelable, Serializable {
const val FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 =
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 + SHARE_PERMISSION_FLAG


const val INIT_EXPIRATION_DATE_IN_MILLIS : Long = 0
const val INIT_SHARED_DATE : Long = 0
const val INIT_EXPIRATION_DATE_IN_MILLIS: Long = 0
const val INIT_SHARED_DATE: Long = 0

/**
* Parcelable Methods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2016 ownCloud GmbH.
* Copyright (C) 2019 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,7 +22,7 @@
*
*/

package com.owncloud.android.lib.resources.shares;
package com.owncloud.android.lib.resources.shares

/**
* Enum for Share Type, with values:
Expand All @@ -36,7 +36,7 @@
* @author masensio
*/

public enum ShareType {
enum class ShareType private constructor(val value: Int) {
NO_SHARED(-1),
USER(0),
GROUP(1),
Expand All @@ -45,33 +45,19 @@ public enum ShareType {
CONTACT(5),
FEDERATED(6);

private int value;
companion object {

private ShareType(int value) {
this.value = value;
}

public static ShareType fromValue(int value) {
switch (value) {
case -1:
return NO_SHARED;
case 0:
return USER;
case 1:
return GROUP;
case 3:
return PUBLIC_LINK;
case 4:
return EMAIL;
case 5:
return CONTACT;
case 6:
return FEDERATED;
fun fromValue(value: Int): ShareType? {
when (value) {
-1 -> return NO_SHARED
0 -> return USER
1 -> return GROUP
3 -> return PUBLIC_LINK
4 -> return EMAIL
5 -> return CONTACT
6 -> return FEDERATED
}
return null
}
return null;
}

public int getValue() {
return value;
}
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ownCloud Android Library is available under MIT license
* Copyright (C) 2016 ownCloud GmbH.
* Copyright (C) 2019 ownCloud GmbH.
* @author masensio
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -22,59 +22,44 @@
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.resources.status;
package com.owncloud.android.lib.resources.status

/**
* Enum for Boolean Type in OCCapability parameters, with values:
* Enum for Boolean Type in RemoteCapability parameters, with values:
* -1 - Unknown
* 0 - False
* 1 - True
*/
public enum CapabilityBooleanType {
enum class CapabilityBooleanType private constructor(val value: Int) {
UNKNOWN(-1),
FALSE(0),
TRUE(1);

private int value;
val isUnknown: Boolean
get() = value == -1

CapabilityBooleanType(int value) {
this.value = value;
}
val isFalse: Boolean
get() = value == 0

public static CapabilityBooleanType fromValue(int value) {
switch (value) {
case -1:
return UNKNOWN;
case 0:
return FALSE;
case 1:
return TRUE;
}
return null;
}
val isTrue: Boolean
get() = value == 1

public static CapabilityBooleanType fromBooleanValue(boolean boolValue) {
if (boolValue) {
return TRUE;
} else {
return FALSE;
companion object {
fun fromValue(value: Int): CapabilityBooleanType? {
when (value) {
-1 -> return UNKNOWN
0 -> return FALSE
1 -> return TRUE
}
return null
}
}

public int getValue() {
return value;
}

public boolean isUnknown() {
return getValue() == -1;
}

public boolean isFalse() {
return getValue() == 0;
}

public boolean isTrue() {
return getValue() == 1;
fun fromBooleanValue(boolValue: Boolean): CapabilityBooleanType {
return if (boolValue) {
TRUE
} else {
FALSE
}
}
}

};
}
Loading

0 comments on commit 301d92d

Please sign in to comment.