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

New arch/capabilities #246

Merged
merged 3 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
davigonz marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -32,11 +32,12 @@
* 3 - Shared by public link
* 4 - Shared by e-mail
* 5 - Shared by contact
* 6 - Federated
*
* @author masensio
*/

public enum ShareType {
enum class ShareType constructor(val value: Int) {
NO_SHARED(-1),
USER(0),
GROUP(1),
Expand All @@ -45,33 +46,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? {
davigonz marked this conversation as resolved.
Show resolved Hide resolved
return when (value) {
-1 -> NO_SHARED
0 -> USER
1 -> GROUP
3 -> PUBLIC_LINK
4 -> EMAIL
5 -> CONTACT
6 -> FEDERATED
else -> 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? {
davigonz marked this conversation as resolved.
Show resolved Hide resolved
return when (value) {
-1 -> UNKNOWN
0 -> FALSE
1 -> TRUE
else -> 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