├── box-content-sdk ├── .gitignore ├── gradle.properties ├── src │ ├── main │ │ ├── assets │ │ │ ├── offlinepng.png │ │ │ └── offline.html │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ ├── boxlogo_white.png │ │ │ │ ├── boxsdk_dialog_warning.png │ │ │ │ ├── ic_box_contentsdk_add_grey_24dp.png │ │ │ │ └── boxsdk_thumb_background.xml │ │ │ ├── drawable │ │ │ │ ├── ic_box_contentsdk_add_grey_24dp.png │ │ │ │ ├── box_circle_mask.xml │ │ │ │ ├── initials_count_thumb_background.xml │ │ │ │ ├── teal_rectangle.xml │ │ │ │ ├── blue_highlight_rectangle.xml │ │ │ │ └── btn_blue_bordered.xml │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_box_contentsdk_add_grey_24dp.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_box_contentsdk_add_grey_24dp.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── attrs.xml │ │ │ │ ├── not_localized.xml │ │ │ │ └── themes.xml │ │ │ └── layout │ │ │ │ ├── boxsdk_activity_oauth.xml │ │ │ │ ├── boxsdk_avatar_item.xml │ │ │ │ ├── boxsdk_list_item_new_account.xml │ │ │ │ ├── boxsdk_choose_auth_activity.xml │ │ │ │ ├── blocked_ip_error.xml │ │ │ │ ├── boxsdk_list_item_account.xml │ │ │ │ └── boxsdk_alert_dialog_text_entry.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── box │ │ │ │ └── androidsdk │ │ │ │ └── content │ │ │ │ ├── models │ │ │ │ ├── BoxVoid.java │ │ │ │ ├── BoxObject.java │ │ │ │ ├── BoxIteratorUsers.java │ │ │ │ ├── BoxIteratorComments.java │ │ │ │ ├── BoxIteratorCollections.java │ │ │ │ ├── BoxIteratorCollaborations.java │ │ │ │ ├── BoxIteratorFileVersions.java │ │ │ │ ├── BoxIteratorRealTimeServers.java │ │ │ │ ├── BoxMap.java │ │ │ │ ├── BoxEmbedLink.java │ │ │ │ ├── BoxIteratorItems.java │ │ │ │ ├── BoxOrder.java │ │ │ │ ├── BoxIteratorRecentItems.java │ │ │ │ ├── BoxEnterprise.java │ │ │ │ ├── BoxIteratorUploadSessionParts.java │ │ │ │ ├── BoxSimpleMessage.java │ │ │ │ ├── BoxClassification.java │ │ │ │ ├── BoxGroup.java │ │ │ │ ├── BoxIteratorRepresentations.java │ │ │ │ ├── BoxIteratorBoxEntity.java │ │ │ │ ├── BoxSharedLinkSession.java │ │ │ │ ├── BoxCollection.java │ │ │ │ ├── BoxIteratorEvents.java │ │ │ │ ├── BoxIteratorEnterpriseEvents.java │ │ │ │ ├── BoxCollaborator.java │ │ │ │ ├── BoxMetadata.java │ │ │ │ ├── BoxUploadSessionEndpoints.java │ │ │ │ ├── BoxMDMData.java │ │ │ │ ├── BoxUploadSessionPart.java │ │ │ │ ├── BoxRealTimeServer.java │ │ │ │ ├── BoxRecentItem.java │ │ │ │ ├── BoxPermission.java │ │ │ │ ├── BoxUploadEmail.java │ │ │ │ ├── BoxBookmark.java │ │ │ │ ├── BoxExpiringEmbedLinkFile.java │ │ │ │ └── BoxArray.java │ │ │ │ ├── utils │ │ │ │ ├── IStreamPosition.java │ │ │ │ ├── BoxLogUtils.java │ │ │ │ ├── BoxContentProvider.java │ │ │ │ ├── StringMappedThreadPoolExecutor.java │ │ │ │ ├── BoxLogger.java │ │ │ │ ├── Logger.java │ │ │ │ ├── ProgressInputStream.java │ │ │ │ └── ProgressOutputStream.java │ │ │ │ ├── listeners │ │ │ │ ├── DownloadStartListener.java │ │ │ │ └── ProgressListener.java │ │ │ │ ├── auth │ │ │ │ └── BlockedIPErrorActivity.java │ │ │ │ ├── BoxApiSearch.java │ │ │ │ ├── requests │ │ │ │ ├── BoxResponseBatch.java │ │ │ │ ├── BoxCacheableRequest.java │ │ │ │ ├── BoxRequestRecentItems.java │ │ │ │ ├── BoxRequestItemDelete.java │ │ │ │ ├── BoxResponse.java │ │ │ │ ├── BoxRequestList.java │ │ │ │ ├── BoxRequestCollectionUpdate.java │ │ │ │ ├── MultiputResponseHandler.java │ │ │ │ ├── BoxRequestsCollections.java │ │ │ │ ├── BoxHttpRequest.java │ │ │ │ ├── BoxRequestItemRestoreTrashed.java │ │ │ │ ├── BoxRequestItemCopy.java │ │ │ │ └── BoxRequestBatch.java │ │ │ │ ├── views │ │ │ │ └── OfflineAvatarController.java │ │ │ │ ├── BoxApiRecentItems.java │ │ │ │ ├── BoxCache.java │ │ │ │ ├── BoxCacheFutureTask.java │ │ │ │ ├── BoxApi.java │ │ │ │ ├── BoxConstants.java │ │ │ │ ├── BoxApiShare.java │ │ │ │ ├── BoxApiCollection.java │ │ │ │ ├── BoxApiEvent.java │ │ │ │ ├── BoxConfig.java │ │ │ │ ├── BoxApiComment.java │ │ │ │ └── BoxFutureTask.java │ │ ├── project.properties │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── box │ │ │ └── androidsdk │ │ │ └── content │ │ │ ├── testUtil │ │ │ ├── DateUtil.java │ │ │ ├── SessionUtil.java │ │ │ └── PowerMock.java │ │ │ ├── requests │ │ │ ├── BoxCollaborationRequestTest.java │ │ │ ├── URLValidationTest.java │ │ │ └── BoxSearchRequestTest.java │ │ │ └── models │ │ │ ├── BoxBookmarkTest.java │ │ │ └── BoxCommentTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── box │ │ └── androidsdk │ │ └── content │ │ └── models │ │ └── BoxUploadSessionTest.java ├── proguard-rules.pro └── build.gradle ├── box-content-sample ├── .gitignore ├── gradle.properties ├── src │ ├── main │ │ ├── assets │ │ │ └── box_logo.png │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-hdpi │ │ │ │ ├── boxsdk_generic.png │ │ │ │ └── boxsdk_icon_folder_yellow.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── boxsdk_generic.png │ │ │ │ └── boxsdk_icon_folder_yellow.png │ │ │ ├── values │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ └── ic_white_add_24dp.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── boxsdk_list_item.xml │ │ │ └── menu │ │ │ │ └── menu_main.xml │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── box │ │ └── androidsdk │ │ └── sample │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── doc ├── Users.md ├── Events.md ├── Search.md ├── Authentication.md ├── Comments.md ├── Folders.md ├── AppUsers.md └── Collaborations.md ├── CHANGELOG.md ├── .gitignore ├── .utility └── initiate-publish.sh ├── .github ├── ISSUE_TEMPLATE │ ├── enhancement.md │ ├── config.yml │ ├── bug.md │ └── question.md └── workflows │ └── releases.yml ├── gradle.properties ├── .travis.yml ├── CONTRIBUTING.md ├── gradlew.bat └── maven_push.gradle /box-content-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /box-content-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':box-content-sample', ':box-content-sdk' 2 | -------------------------------------------------------------------------------- /box-content-sdk/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Box Android SDK 2 | POM_ARTIFACT_ID=box-android-sdk 3 | POM_PACKAGING=aar 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /box-content-sample/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Android Box Content SDK SAMPLE 2 | POM_ARTIFACT_ID=androidboxcontentsdksample 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /box-content-sample/src/main/assets/box_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/assets/box_logo.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/assets/offlinepng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/assets/offlinepng.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-hdpi/boxlogo_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable-hdpi/boxlogo_white.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/drawable-hdpi/boxsdk_generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/drawable-hdpi/boxsdk_generic.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/drawable-xhdpi/boxsdk_generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/drawable-xhdpi/boxsdk_generic.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-hdpi/boxsdk_dialog_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable-hdpi/boxsdk_dialog_warning.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/ic_box_contentsdk_add_grey_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable/ic_box_contentsdk_add_grey_24dp.png -------------------------------------------------------------------------------- /box-content-sample/src/main/res/drawable-hdpi/boxsdk_icon_folder_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/drawable-hdpi/boxsdk_icon_folder_yellow.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/box_circle_mask.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/drawable-xhdpi/boxsdk_icon_folder_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sample/src/main/res/drawable-xhdpi/boxsdk_icon_folder_yellow.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-hdpi/ic_box_contentsdk_add_grey_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable-hdpi/ic_box_contentsdk_add_grey_24dp.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-xhdpi/ic_box_contentsdk_add_grey_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable-xhdpi/ic_box_contentsdk_add_grey_24dp.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-xxhdpi/ic_box_contentsdk_add_grey_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/box/box-android-sdk/master/box-content-sdk/src/main/res/drawable-xxhdpi/ic_box_contentsdk_add_grey_24dp.png -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/initials_count_thumb_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /doc/Users.md: -------------------------------------------------------------------------------- 1 | Users 2 | ===== 3 | 4 | Get the current User 5 | -------------------- 6 | ```java 7 | BoxApiUser userApi = new BoxApiUser(session); 8 | BoxUser currentUser = userApi.getCurrentUserInfoRequest().send(); 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/assets/offline.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
%s
%s
%s
6 |
7 | 8 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxVoid.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class that represents a void response from the Box API. 5 | */ 6 | public class BoxVoid extends BoxObject { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxObject.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Base class for all Box objects. 7 | */ 8 | public class BoxObject implements Serializable { } 9 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/utils/IStreamPosition.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.utils; 2 | 3 | 4 | /** 5 | * Interface used by APIs that use stream positions. 6 | */ 7 | public interface IStreamPosition{ 8 | public Long getNextStreamPosition(); 9 | } 10 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable-hdpi/boxsdk_thumb_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/teal_rectangle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorUsers.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of Box users. 5 | */ 6 | public class BoxIteratorUsers extends BoxIteratorBoxEntity { 7 | private static final long serialVersionUID = -6123959160296884824L; 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorComments.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of comments. 5 | */ 6 | public class BoxIteratorComments extends BoxIteratorBoxEntity { 7 | private static final long serialVersionUID = 2614335107470674624L; 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorCollections.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of item collections. 5 | */ 6 | public class BoxIteratorCollections extends BoxIteratorBoxEntity { 7 | private static final long serialVersionUID = -4334289842796989974L; 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorCollaborations.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of collaborations. 5 | */ 6 | public class BoxIteratorCollaborations extends BoxIteratorBoxEntity { 7 | private static final long serialVersionUID = -7915638707645944101L; 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorFileVersions.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of versions of a {@link BoxFile}. 5 | */ 6 | public class BoxIteratorFileVersions extends BoxIteratorBoxEntity { 7 | private static final long serialVersionUID = -5641060152622694049L; 8 | } 9 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/drawable/ic_white_add_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/blue_highlight_rectangle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorRealTimeServers.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | /** 4 | * Class representing a list of real time servers. 5 | */ 6 | public class BoxIteratorRealTimeServers extends BoxIteratorBoxEntity { 7 | 8 | private static final long serialVersionUID = -4986489348666966126L; 9 | public static final String FIELD_CHUNK_SIZE = "chunk_size"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /box-content-sample/src/androidTest/java/com/box/androidsdk/sample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.sample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #de000000 4 | #80000000 5 | #00adef 6 | #ffeeeeee 7 | 8 | 9 | #195eae 10 | #80afd2 11 | 12 | 13 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 72dp 5 | 40dp 6 | 16sp 7 | 20sp 8 | 16sp 9 | 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | ## Next Release 5 | 6 | __Breaking Changes:__ 7 | - Fix cross-app scripting vulnerability by removing Activity export of OAuthActivity ([#440](https://github.com/box/box-android-sdk/pull/440)) 8 | 9 | __New Features and Enhancements:__ 10 | 11 | - Add support for the uploader display name field for Files and File Versions ([#424](https://github.com/box/box-android-sdk/pull/424)) 12 | - Add path parameter sanitization ([#428](https://github.com/box/box-android-sdk/pull/428)) 13 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/listeners/DownloadStartListener.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.listeners; 2 | 3 | import com.box.androidsdk.content.models.BoxDownload; 4 | 5 | /** 6 | * Listener that provides information on a download once the download starts. 7 | */ 8 | public interface DownloadStartListener { 9 | 10 | /** 11 | * Callback when download has started 12 | * @param downloadInfo 13 | */ 14 | public void onStart(BoxDownload downloadInfo); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /box-content-sdk/src/test/java/com/box/androidsdk/content/testUtil/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.testUtil; 2 | 3 | 4 | import org.junit.Assert; 5 | 6 | import java.util.Date; 7 | 8 | public class DateUtil { 9 | public static void assertSameDateSecondPrecision(Date expectedDate, Date date) { 10 | long expectedDateTruncated = expectedDate.getTime() / 1000; 11 | long dateTruncated = date.getTime() / 1000; 12 | Assert.assertEquals(expectedDateTruncated, dateTruncated); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/listeners/ProgressListener.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.listeners; 2 | 3 | /** 4 | * The listener interface for monitoring the progress of a long-running API call. 5 | */ 6 | public interface ProgressListener { 7 | 8 | /** 9 | * Invoked when the progress of the API call changes. 10 | * @param numBytes the number of bytes completed. 11 | * @param totalBytes the total number of bytes. 12 | */ 13 | void onProgressChanged(long numBytes, long totalBytes); 14 | } 15 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxMap.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | /** 6 | * Class representing a map of arbitrary keys and values. 7 | */ 8 | public class BoxMap extends BoxJsonObject { 9 | 10 | private static final long serialVersionUID = 162879893465214004L; 11 | 12 | /** 13 | * Constructs an empty map object. 14 | */ 15 | public BoxMap() { 16 | 17 | } 18 | 19 | public BoxMap(JsonObject jsonObject){ 20 | super(jsonObject); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | 28 | # Android Studio 29 | .idea/ 30 | *.iml 31 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 32 | .gradle 33 | build/ 34 | -------------------------------------------------------------------------------- /doc/Events.md: -------------------------------------------------------------------------------- 1 | Events 2 | ====== 3 | 4 | Get Events for the Current User 5 | ------------------------------- 6 | ```java 7 | BoxApiEvent eventApi = new BoxApiEvent(session); 8 | BoxRequestsEvent.GetUserEvents eventRequest = eventApi.getUserEventsRequest(); 9 | 10 | // See API documentation for configuring stream position and stream type: 11 | // https://developers.box.com/docs/#events 12 | eventRequest.setStreamType("all").setStreamPosition("0"); 13 | 14 | BoxIteratorEvents events = eventRequest.send(); 15 | // You will likely want to use events.getNextStreamPosition() for your next request. 16 | ``` 17 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Box Content SDK Sample 3 | 4 | Hello world! 5 | Settings 6 | Accounts 7 | Add account 8 | Upload 9 | Switch Accounts 10 | Log out 11 | Log out all 12 | Log in 13 | 14 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/layout/boxsdk_activity_oauth.xml: -------------------------------------------------------------------------------- 1 | 7 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxEmbedLink.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonArray; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.Iterator; 8 | import java.util.List; 9 | 10 | /** 11 | * An object representing a url link. 12 | */ 13 | public class BoxEmbedLink extends BoxJsonObject { 14 | 15 | private static final String FIELD_URL = "url"; 16 | 17 | 18 | public BoxEmbedLink() { 19 | super(); 20 | } 21 | 22 | public String getUrl(){ 23 | return getPropertyAsString(FIELD_URL); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=true 16 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorItems.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | import org.json.JSONArray; 6 | 7 | /** 8 | * Class representing a list of items in Box (of types {@link BoxFolder}, {@link BoxFile}, and {@link BoxBookmark}). 9 | */ 10 | public class BoxIteratorItems extends BoxIteratorBoxEntity { 11 | private static final long serialVersionUID = 1378358978076482578L; 12 | 13 | public BoxIteratorItems() {super();} 14 | 15 | public BoxIteratorItems(JsonObject object) { 16 | super(object); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /box-content-sdk/src/test/java/com/box/androidsdk/content/testUtil/SessionUtil.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.testUtil; 2 | 3 | import android.content.Context; 4 | 5 | import com.box.androidsdk.content.auth.BoxAuthentication; 6 | import com.box.androidsdk.content.models.BoxSession; 7 | 8 | /** 9 | * Utils for mocking the BoxSession 10 | */ 11 | 12 | public class SessionUtil { 13 | public static BoxSession newMockBoxSession(Context context) { 14 | BoxAuthentication.BoxAuthenticationInfo authenticationInfo = new BoxAuthentication.BoxAuthenticationInfo(); 15 | authenticationInfo.setAccessToken("accessTokenMock"); 16 | return new BoxSession(context, authenticationInfo, null); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /box-content-sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/hkuo/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /doc/Search.md: -------------------------------------------------------------------------------- 1 | Search 2 | ====== 3 | 4 | Search for files and folders 5 | ---------------------------- 6 | 7 | ```java 8 | BoxApiSearch searchApi = new BoxApiSearch(session); 9 | BoxIteratorItems searchResults = searchApi.getSearchRequest("search string") 10 | .setOffset(0) // default is 0 11 | .setLimit(100) // default is 30, max is 200 12 | // Optional: Specify advanced search parameters. See BoxRequestsSearch.Search for the full list of parameters supported. 13 | .limitAncestorFolderIds(new String[]{"folderId1", "folderId2"}) // only items in these folders will be returned. 14 | .limitFileExtensions(new String[]{"jpg", "png"}) // only files with these extensions will be returned. 15 | .send(); 16 | ``` 17 | -------------------------------------------------------------------------------- /box-content-sdk/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Program Files (x86)/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.utility/initiate-publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script initiates the Gradle publishing task when pushes to master occur. 3 | # NOTE: Travis-CI can only publish SNAPSHOT versions. To release a version, you need 4 | # to use the internal Jenkins job. 5 | 6 | echo Repo: $TRAVIS_REPO_SLUG Pull Request: $TRAVIS_PULL_REQUEST Branch: $TRAVIS_BRANCH 7 | if [ "$TRAVIS_REPO_SLUG" == "box/box-android-sdk" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then 8 | export GIT_COUNT=`git rev-list HEAD --count` 9 | echo "Starting publish to Sonatype... $GIT_COUNT" 10 | 11 | ./gradlew uploadArchives 12 | RETVAL=$? 13 | 14 | if [ $RETVAL -eq 0 ]; then 15 | echo 'Completed publish!' 16 | else 17 | echo 'Publish failed.' 18 | return 1 19 | fi 20 | 21 | fi 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement 3 | about: Suggest a new feature or change 4 | title: '' 5 | labels: enhancement 6 | assignees: mwwoda, mhagmajer, antusus, arjankowski, lukaszsocha2, bartlomiejleszczynski 7 | 8 | --- 9 | 10 | ### Is your feature request related to a problem? Please describe. 11 | 12 | 13 | ### Describe the solution you'd like 14 | 15 | 16 | ### Describe alternatives you've considered 17 | 18 | 19 | ### Additional context 20 | 21 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/auth/BlockedIPErrorActivity.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.auth; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | 7 | import com.box.sdk.android.R; 8 | 9 | /** 10 | * Activity to notify the user that their ip was blocked by the admin 11 | */ 12 | public class BlockedIPErrorActivity extends Activity { 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.blocked_ip_error); 17 | findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() { 18 | 19 | @Override 20 | public void onClick(final View view) { 21 | finish(); 22 | } 23 | }); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /box-content-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | applicationId "com.box.androidsdk.sample" 8 | 9 | minSdkVersion 16 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_8 22 | targetCompatibility JavaVersion.VERSION_1_8 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation 'androidx.appcompat:appcompat:1.0.2' 28 | implementation project(':box-content-sdk') 29 | } 30 | 31 | //apply from: '../maven_push.gradle' 32 | -------------------------------------------------------------------------------- /box-content-sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 14 | 15 | 18 | 19 | 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: SDK documentation 4 | url: https://github.com/box/box-android-sdk/tree/master/doc 5 | about: Before creating an issue, I have checked that the SDK documentation doesn't solve my issue. 6 | - name: API documentation 7 | url: https://developer.box.com/docs 8 | about: Before creating an issue, I have checked that the API documentation doesn't solve my issue. 9 | - name: Box Developer Forums 10 | url: https://community.box.com/t5/Platform-and-Development-Forum/bd-p/DeveloperForum 11 | about: Before creating an issue, I have searched the Box Developer Forums and my issue isn't already reported there. 12 | - name: Issues in this repo 13 | url: https://github.com/box/box-android-sdk/search?type=Issues 14 | about: Before creating an issue, I have searched Issues in this repo and my issue isn't already reported. 15 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/drawable/btn_blue_bordered.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.enableJetifier=true 21 | android.useAndroidX=true -------------------------------------------------------------------------------- /.github/workflows/releases.yml: -------------------------------------------------------------------------------- 1 | # A GitHub action that notifies the developer 2 | # changelog repository of any new releases. 3 | 4 | name: Notify changelog 5 | 6 | on: 7 | # Only trigger for a full release, 8 | # ignoring pre-releases and drafts 9 | release: 10 | types: 11 | - released 12 | 13 | jobs: 14 | notify: 15 | # This job can run on the latest Ubuntu 16 | # and it should not take more than 3 minutes 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 3 19 | 20 | steps: 21 | # There's really only 1 step, and i 22 | - name: Notify changelog of new release 23 | uses: peter-evans/repository-dispatch@v1 24 | with: 25 | token: ${{ secrets.DISPATCH_ACCESS_TOKEN }} 26 | repository: box/box-developer-changelog 27 | event-type: new-release-note 28 | client-payload: '{"ref": "${{ github.ref }}", "repository": "${{github.repository}}", "labels": "sdks,android,mobile", "repo_display_name": "Box Android SDK"}' 29 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiSearch.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content; 2 | 3 | import com.box.androidsdk.content.models.BoxSession; 4 | import com.box.androidsdk.content.requests.BoxRequestsSearch; 5 | 6 | /** 7 | * Represents the API of the search endpoint on Box. This class can be used to generate request objects 8 | * for each of the APIs exposed endpoints 9 | */ 10 | public class BoxApiSearch extends BoxApi { 11 | 12 | public BoxApiSearch(BoxSession session) { 13 | super(session); 14 | } 15 | 16 | /** 17 | * Gets a request to search 18 | * 19 | * @param query query to use for search 20 | * @return request to search 21 | */ 22 | public BoxRequestsSearch.Search getSearchRequest(String query) { 23 | BoxRequestsSearch.Search request = new BoxRequestsSearch.Search(query, getSearchUrl(), mSession); 24 | return request; 25 | } 26 | 27 | protected String getSearchUrl() { return String.format("%s/search", getBaseUri()); } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxOrder.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | import com.eclipsesource.json.JsonValue; 5 | 6 | /** 7 | * Class representing an order for a list of objects. 8 | */ 9 | public class BoxOrder extends BoxJsonObject { 10 | 11 | public static final String FIELD_BY = "by"; 12 | public static final String FIELD_DIRECTION = "direction"; 13 | 14 | public static final String DIRECTION_ASCENDING = "ASC"; 15 | public static final String DIRECTION_DESCENDING = "DESC"; 16 | 17 | public static final String SORT_ID = "id"; 18 | public static final String SORT_NAME = "name"; 19 | public static final String SORT_DATE = "date"; 20 | public static final String SORT_SIZE = "size"; 21 | 22 | 23 | public String getBy() { 24 | return getPropertyAsString(FIELD_BY); 25 | } 26 | 27 | public String getDirection() { 28 | return getPropertyAsString(FIELD_DIRECTION); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorRecentItems.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | /** 6 | * A class representing list of BoxRecentItem's 7 | */ 8 | public class BoxIteratorRecentItems extends BoxIterator { 9 | private static final long serialVersionUID = -2642748896882484555L; 10 | 11 | private transient BoxJsonObjectCreator representationCreator; 12 | 13 | public BoxIteratorRecentItems() { 14 | super(); 15 | } 16 | 17 | public BoxIteratorRecentItems(JsonObject jsonObject) { 18 | super(jsonObject); 19 | } 20 | 21 | @Override 22 | protected BoxJsonObjectCreator getObjectCreator() { 23 | if (representationCreator != null){ 24 | return representationCreator; 25 | } 26 | representationCreator = BoxJsonObject.getBoxJsonObjectCreator(BoxRecentItem.class); 27 | return representationCreator; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxEnterprise.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | import com.eclipsesource.json.JsonValue; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Class that represents an enterprise in Box. 10 | */ 11 | public class BoxEnterprise extends BoxEntity { 12 | 13 | private static final long serialVersionUID = -3453999549970888942L; 14 | 15 | public static final String TYPE = "enterprise"; 16 | 17 | public static final String FIELD_NAME = "name"; 18 | 19 | /** 20 | * Constructs an empty BoxEnterprise object. 21 | */ 22 | public BoxEnterprise() { 23 | super(); 24 | } 25 | 26 | public BoxEnterprise(JsonObject jsonObject){ 27 | super(jsonObject); 28 | } 29 | 30 | /** 31 | * Gets the name of the item. 32 | * 33 | * @return the name of the item. 34 | */ 35 | public String getName() { 36 | return getPropertyAsString(FIELD_NAME); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorUploadSessionParts.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | /** 6 | * Class representing a list of BoxUploadSessionPart 7 | */ 8 | public class BoxIteratorUploadSessionParts extends BoxIterator{ 9 | 10 | private static final long serialVersionUID = -4986339348447936122L; 11 | private transient BoxJsonObjectCreator partsCreator; 12 | 13 | public BoxIteratorUploadSessionParts() { 14 | super(); 15 | } 16 | 17 | public BoxIteratorUploadSessionParts(JsonObject jsonObject) { 18 | super(jsonObject); 19 | } 20 | 21 | @Override 22 | protected BoxJsonObjectCreator getObjectCreator() { 23 | if (partsCreator != null){ 24 | return partsCreator; 25 | } 26 | partsCreator = BoxJsonObject.getBoxJsonObjectCreator(BoxUploadSessionPart.class); 27 | return partsCreator; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/requests/BoxResponseBatch.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.requests; 2 | 3 | import com.box.androidsdk.content.models.BoxObject; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Batch response class that contains all the response information for a completed BoxRequestBatch 9 | */ 10 | public class BoxResponseBatch extends BoxObject { 11 | 12 | /** 13 | * Collection of the response objects 14 | */ 15 | protected ArrayList mResponses = new ArrayList(); 16 | 17 | /** 18 | * Returns the collection of response objects 19 | * 20 | * @return collection of response objects 21 | */ 22 | public ArrayList getResponses() { 23 | return mResponses; 24 | } 25 | 26 | /** 27 | * Adds a response to the collection 28 | * 29 | * @param response the response to add 30 | */ 31 | public void addResponse(BoxResponse response) { 32 | mResponses.add(response); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxSimpleMessage.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | import com.eclipsesource.json.JsonValue; 5 | 6 | /** 7 | * Class representing a response from a real time server. 8 | */ 9 | public class BoxSimpleMessage extends BoxJsonObject { 10 | 11 | private static final long serialVersionUID = 1626798809346520004L; 12 | public static final String FIELD_MESSAGE = "message"; 13 | 14 | public static final String MESSAGE_NEW_CHANGE = "new_change"; 15 | public static final String MESSAGE_RECONNECT = "reconnect"; 16 | 17 | /** 18 | * Returns the message from the server. 19 | * 20 | * @return message from the server. 21 | */ 22 | public String getMessage() { 23 | return getPropertyAsString(FIELD_MESSAGE); 24 | } 25 | 26 | /** 27 | * Constructs an empty BoxSimpleMessage object. 28 | */ 29 | public BoxSimpleMessage() { 30 | 31 | } 32 | 33 | public BoxSimpleMessage(JsonObject jsonObject){ 34 | super(jsonObject); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /box-content-sample/src/main/res/layout/boxsdk_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 19 | 20 | 30 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | sudo: required 3 | jdk: oraclejdk8 4 | 5 | env: 6 | global: 7 | - secure: kAObSZVQ6SGgIJsh++UYDWyF8AqvYI5xnAaL2CJRq2NUxAMsOwiJdM9Ey/HiOoSyzzII7Ve7Cyji1YE+YfHYOfs5x9iNMIwSRqQv9l8nry7GlzxLXt4OhFpM0EIeaNokzzwXYjiZ7TTLOtLuYCr7ssGTRGUrFCsBHI/+4dKS68k= 8 | - secure: hLpLbEi5ThL/+qHuEmJvvJkzfBrXbyOjDbd9fSSYESSQuGUoEGH3UM7Ws6eJynv/G0w+xmJIQ4vlDbSBa53vaYwHB2l0Rhcoj3XHHvpMwlckIh/TGA+o4Bd5DHN61Jatm6ja8PFRAhNF4adsLUwObrE6Z9ydepKFYBWSjP4xEws= 9 | 10 | android: 11 | components: 12 | - tools 13 | - platform-tools 14 | 15 | before_install: 16 | - touch $HOME/.android/repositories.cfg 17 | - yes | sdkmanager "platforms;android-28" 18 | - yes | sdkmanager "build-tools;28.0.3" 19 | - sdkmanager "tools" > /dev/null 20 | - sdkmanager "platform-tools" > /dev/null 21 | 22 | before_cache: 23 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 24 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 25 | 26 | cache: 27 | directories: 28 | - $HOME/.m2 29 | - $HOME/.gradle/caches/ 30 | - $HOME/.gradle/wrapper/ 31 | - $HOME/.android/build-cache 32 | 33 | script: "./gradlew clean build" 34 | 35 | after_success: .utility/initiate-publish.sh 36 | 37 | git: 38 | depth: 9999999 -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/values/not_localized.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 308201fd30820166a00302010202044c8a3289300d06092a864886f70d01010505003043310b3009060355040613024341310b3009060355040813024f6e310f300d060355040713064f747461776131163014060355040a130d426974686561647320496e632e301e170d3130303931303133323834315a170d3335303930343133323834315a3043310b3009060355040613024341310b3009060355040813024f6e310f300d060355040713064f747461776131163014060355040a130d426974686561647320496e632e30819f300d06092a864886f70d010101050003818d0030818902818100926a2f83b01d88c31614e8b398b40606aa098949d97922332cee24e7362b77bc8dfd3b3556f0f787042cf1d17ff5fb0dd8672d5d2bfc903a2b1ef330d7323a00b8b6187e000a0d1a34fe0e6dcfdd1bbd021718a5fed5249348f24626b7b2c5d35d70b8c6a1436be8006c8843bcf1b5dea829c9d48aa77d06ebc0eeac294388b70203010001300d06092a864886f70d0101050500038181009170b46b82a7e5529d7e8c9ce45d1ad6ba539a0808c278923e5d8740686f1069f744d2bf18ce239f1f082a3c3c810947c42f972464f1cc9c4e5f39b7eee4282d6a617d4cea94677154d5f58629dcad04fae7540936838d466cd0c08831dba6b4989459a460cccc741f5fe2affffb42ef47943cc2fa7017fecfbf3dfd6cfb07d0 5 | 6 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/views/OfflineAvatarController.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.views; 2 | 3 | import android.content.Context; 4 | 5 | import com.box.androidsdk.content.BoxFutureTask; 6 | import com.box.androidsdk.content.models.BoxDownload; 7 | 8 | import java.io.File; 9 | 10 | /** 11 | * This is a special avatar controller that never makes network calls, and should be able to show avatars 12 | * for other accounts if available. 13 | */ 14 | public class OfflineAvatarController extends DefaultAvatarController { 15 | 16 | 17 | final Context mContext; 18 | 19 | public OfflineAvatarController(Context context){ 20 | super(null); 21 | mContext = context.getApplicationContext(); 22 | } 23 | 24 | @Override 25 | protected File getAvatarDir(String userId) { 26 | File directory = new File(mContext.getFilesDir().getAbsolutePath()+ File.separator + userId + File.separator + "avatar"); 27 | cleanOutOldAvatars(directory, DEFAULT_MAX_AGE); 28 | return directory; 29 | } 30 | 31 | @Override 32 | public BoxFutureTask executeAvatarDownloadRequest(String userId, BoxAvatarView avatarView) { 33 | return null; 34 | } 35 | } -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxClassification.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | public class BoxClassification extends BoxJsonObject { 4 | public static final String FIELD_NAME = "name"; 5 | public static final String FIELD_COLOR = "color"; 6 | public static final String FIELD_DEFINITION= "definition"; 7 | 8 | /** 9 | * Gets the name of the classification. 10 | * 11 | * @return the name of the classification. 12 | */ 13 | public String getName() { 14 | return getPropertyAsString(FIELD_NAME); 15 | } 16 | 17 | /** 18 | * Gets the hexcode color of the classification. 19 | * 20 | * @return the hexcode color of the classification. 21 | */ 22 | public String getColor() { 23 | return getPropertyAsString(FIELD_COLOR); 24 | } 25 | 26 | /** 27 | * Gets the definition of the classification. 28 | * 29 | * @return the definition of the classification. 30 | */ 31 | public String getDefinition() { 32 | return getPropertyAsString(FIELD_DEFINITION); 33 | } 34 | 35 | public String toString() { 36 | return "Classification " + getName() + " " + getColor() + " " + getDefinition(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/layout/boxsdk_avatar_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 19 | 29 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/requests/BoxCacheableRequest.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.requests; 2 | 3 | import com.box.androidsdk.content.BoxException; 4 | import com.box.androidsdk.content.BoxFutureTask; 5 | import com.box.androidsdk.content.models.BoxObject; 6 | 7 | /** 8 | * Interface that adds the ability for requests to retrieve data from the cache instead of over the 9 | * network. 10 | * 11 | * @param The results of the request 12 | */ 13 | public interface BoxCacheableRequest { 14 | 15 | /** 16 | * Sends the request to fetch results from cache synchronously. 17 | * 18 | * @return the cached results of the request 19 | * @throws BoxException thrown if there is no implementation of BoxCache set in BoxConfig, or if 20 | * there was another issue getting cached results. 21 | */ 22 | T sendForCachedResult() throws BoxException; 23 | 24 | /** 25 | * Converts the request to a BoxCacheFutureTask that can be used to execute the request 26 | * asynchronously. 27 | * 28 | * @return a task that will fetch the results from the cache 29 | * @throws BoxException thrown if there is no implementation of BoxCache set in BoxConfig. 30 | */ 31 | BoxFutureTask toTaskForCachedResult() throws BoxException; 32 | } -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/utils/BoxLogUtils.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.utils; 2 | 3 | import java.util.Map; 4 | 5 | public class BoxLogUtils { 6 | 7 | private static Logger sLogger = new BoxLogger(); 8 | 9 | public static void setLogger(Logger logger) { 10 | sLogger = logger; 11 | } 12 | 13 | public static Logger getLogger(Logger logger) { 14 | return sLogger; 15 | } 16 | 17 | public static boolean getIsLoggingEnabled() { 18 | return sLogger.getIsLoggingEnabled(); 19 | } 20 | 21 | public static void i(String tag, String msg) { 22 | sLogger.i(tag, msg); 23 | } 24 | 25 | public static void i(String tag, String msg, Map map) { 26 | sLogger.i(tag, msg, map); 27 | } 28 | 29 | public static void d(String tag, String msg) { 30 | sLogger.d(tag, msg); 31 | } 32 | 33 | public static void e(String tag, String msg) { 34 | sLogger.e(tag, msg); 35 | } 36 | 37 | public static void e(String tag, Throwable t) { 38 | sLogger.e(tag, t); 39 | } 40 | 41 | public static void e(String tag, String msg, Throwable t) { 42 | sLogger.e(tag, msg, t); 43 | } 44 | 45 | public static void nonFatalE(String tag, String msg, Throwable t) { 46 | sLogger.nonFatalE(tag, msg, t); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /doc/Authentication.md: -------------------------------------------------------------------------------- 1 | Authentication 2 | ============== 3 | 4 | Single User Mode 5 | --------------------- 6 | The SDK can take care of all UI interaction for authenticating a user. If necessary, a WebView will be presented from your app's activity to collect credentials from the user. 7 | ```java 8 | BoxSession session = new BoxSession(context); 9 | session.authenticate(); 10 | ``` 11 | 12 | When you no longer need the session, it is a good practice to logout. 13 | ```java 14 | session.logout(); 15 | ``` 16 | 17 | Multi-Account Mode 18 | ------------------------ 19 | To support account switching, create a session with the userId explicitly set to null. This will launch an account chooser to select an authenticated account or log in to a different account. 20 | ```java 21 | BoxSession session = new BoxSession(context, null); 22 | session.authenticate(); 23 | ``` 24 | 25 | Log all users out. 26 | 27 | ```java 28 | BoxAuthentication.getInstance().logoutAllUsers(context); 29 | ``` 30 | 31 | Security 32 | ------------------------ 33 | The SDK stores authentication information in shared preferences by default. It is recommended that you create your own implementation of `BoxAuthentication.AuthStorage` to provide additional security as needed. You can set the authentication storage as follows: 34 | ```java 35 | BoxAuthentication.getInstance().setAuthStorage(new CustomAuthStorage()); 36 | ``` 37 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiRecentItems.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content; 2 | 3 | import com.box.androidsdk.content.models.BoxSession; 4 | import com.box.androidsdk.content.requests.BoxRequestRecentItems; 5 | 6 | /** 7 | * Represents the API of the Recent Items endpoint on Box. 8 | */ 9 | public class BoxApiRecentItems extends BoxApi { 10 | private static final String ENDPOINT_NAME = "recent_items"; 11 | 12 | /** 13 | * Constructs a BoxApi with the provided BoxSession. 14 | * 15 | * @param session authenticated session to use with the BoxApi. 16 | */ 17 | public BoxApiRecentItems(BoxSession session) { 18 | super(session); 19 | } 20 | 21 | /** 22 | * Gets the URL for getting the recent items 23 | * 24 | * @return the URL string for getting the recent items 25 | */ 26 | protected String getRecentItemsUrl() { 27 | return String.format("%s/" + ENDPOINT_NAME, getBaseUri()); 28 | } 29 | 30 | /** 31 | * Gets a request that gets users recent items 32 | * 33 | * @return request to get users recent items 34 | */ 35 | public BoxRequestRecentItems.GetRecentItems getRecentItemsRequest() { 36 | BoxRequestRecentItems.GetRecentItems request = new BoxRequestRecentItems.GetRecentItems(getRecentItemsUrl(), mSession); 37 | return request; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/layout/boxsdk_list_item_new_account.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 15 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /doc/Comments.md: -------------------------------------------------------------------------------- 1 | Comments 2 | ======== 3 | 4 | Get the existing Comments of a Box File 5 | --------------------------------------- 6 | ```java 7 | BoxApiFile fileApi = new BoxApiFile(session); 8 | BoxIteratorComments comments = fileApi.getCommentsRequest("fileId").send(); 9 | ``` 10 | 11 | Get the info of an existing Comment 12 | ----------------------------------- 13 | ```java 14 | BoxApiComment commentApi = new BoxApiComment(session); 15 | BoxComment comment = commentApi.getInfoRequest("commentId").send(); 16 | ``` 17 | 18 | Add a new Comment to a Box File 19 | ------------------------------- 20 | ```java 21 | BoxApiFile fileApi = new BoxApiFile(session); 22 | BoxComment newComment = fileApi.getAddCommentRequest("fileId", "Comment message").send(); 23 | ``` 24 | 25 | Reply to an Existing Comment 26 | ---------------------------- 27 | ```java 28 | BoxApiComment commentApi = new BoxApiComment(session); 29 | BoxComment replyComment = commentApi.getAddCommentReplyRequest("commentId", "Comment message").send(); 30 | ``` 31 | 32 | Update an existing Comment 33 | -------------------------- 34 | ```java 35 | BoxApiComment commentApi = new BoxApiComment(session); 36 | BoxComment updatedComment = commentApi.getUpdateRequest("commentId", "Updated message").send(); 37 | ``` 38 | 39 | Delete a Comment 40 | ---------------- 41 | ```java 42 | BoxApiComment commentApi = new BoxApiComment(session); 43 | commentApi.getDeleteRequest("commentId").send(); 44 | ``` 45 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxGroup.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Class that represents a group of Box users. 10 | */ 11 | public class BoxGroup extends BoxCollaborator { 12 | 13 | private static final long serialVersionUID = 5872741782856508553L; 14 | public static final String TYPE = "group"; 15 | 16 | /** 17 | * Constructs an empty BoxGroup. 18 | */ 19 | public BoxGroup() { 20 | super(); 21 | } 22 | 23 | /** 24 | * Constructs a BoxGroup with the provided map values. 25 | * @param object json object representing this object 26 | */ 27 | public BoxGroup(JsonObject object) { 28 | super(object); 29 | } 30 | 31 | /** 32 | * A convenience method to create an empty group with just the id and type fields set. This allows 33 | * the ability to interact with the content sdk in a more descriptive and type safe manner 34 | * 35 | * @param groupId the id of group to create 36 | * @return an empty BoxGroup object that only contains id and type information 37 | */ 38 | public static BoxGroup createFromId(String groupId) { 39 | JsonObject object = new JsonObject(); 40 | object.add(BoxCollaborator.FIELD_ID, groupId); 41 | object.add(BoxCollaborator.FIELD_TYPE, BoxUser.TYPE); 42 | return new BoxGroup(object); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/BoxCache.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content; 2 | 3 | import com.box.androidsdk.content.models.BoxObject; 4 | import com.box.androidsdk.content.requests.BoxCacheableRequest; 5 | import com.box.androidsdk.content.requests.BoxRequest; 6 | import com.box.androidsdk.content.requests.BoxResponse; 7 | 8 | /** 9 | * Interface providing local storage to save fetched remote data. 10 | */ 11 | 12 | public interface BoxCache { 13 | 14 | /** 15 | * Returns the last cached BoxObject for this BoxRequest. 16 | * @param request - The BoxRequest object that can be used for fetching remote data. 17 | * @param A child of BoxObject 18 | * @param A child of BoxRequest that implements BoxCacheableRequest 19 | * @return a BoxObject associated with the request type. 20 | * @throws BoxException thrown if the request fails. 21 | */ 22 | T get(R request) throws BoxException; 23 | 24 | /** 25 | * Stores the BoxResponse object in the local store. The original request should included in the 26 | * response object. 27 | * 28 | * @param response - BoxResponse object obtained from a BoxRequest sent using the Box Android SDK. 29 | * @param A child of BoxObject 30 | * @throws BoxException - Exception that should be thrown if there is an issue with storing response. 31 | */ 32 | void put(BoxResponse response) throws BoxException; 33 | } 34 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorRepresentations.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Class representing a list of representations. 9 | */ 10 | public class BoxIteratorRepresentations extends BoxIterator { 11 | 12 | private static final long serialVersionUID = -4986439348667936122L; 13 | 14 | private transient BoxJsonObjectCreator representationCreator; 15 | 16 | public BoxIteratorRepresentations() { 17 | } 18 | 19 | public BoxIteratorRepresentations(JsonObject jsonObject) { 20 | super(jsonObject); 21 | } 22 | 23 | @Override 24 | protected BoxJsonObjectCreator getObjectCreator() { 25 | if (representationCreator != null){ 26 | return representationCreator; 27 | } 28 | representationCreator = BoxJsonObject.getBoxJsonObjectCreator(BoxRepresentation.class); 29 | return representationCreator; 30 | } 31 | 32 | @Deprecated 33 | public Long offset() { 34 | return null; 35 | } 36 | 37 | @Deprecated 38 | public Long limit() { 39 | return null; 40 | } 41 | 42 | @Deprecated 43 | public Long fullSize() { 44 | return null; 45 | } 46 | 47 | @Deprecated 48 | public ArrayList getSortOrders() { 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 15 | 16 | 21 | 22 | 26 | 27 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /box-content-sdk/src/test/java/com/box/androidsdk/content/requests/BoxCollaborationRequestTest.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.requests; 2 | 3 | import com.box.androidsdk.content.BoxApiCollaboration; 4 | import com.box.androidsdk.content.BoxException; 5 | import com.box.androidsdk.content.models.BoxCollaboration; 6 | import com.box.androidsdk.content.models.BoxFile; 7 | import com.box.androidsdk.content.models.BoxUser; 8 | import com.box.androidsdk.content.testUtil.PowerMock; 9 | 10 | import junit.framework.Assert; 11 | 12 | import org.junit.Test; 13 | 14 | import java.io.UnsupportedEncodingException; 15 | import java.lang.reflect.InvocationTargetException; 16 | import java.text.ParseException; 17 | 18 | public class BoxCollaborationRequestTest extends PowerMock { 19 | 20 | @Test 21 | public void testAddCollaborationRequestTest() throws NoSuchMethodException, BoxException, InvocationTargetException, IllegalAccessException, UnsupportedEncodingException, ParseException { 22 | 23 | String expected = "{\"item\":{\"id\":\"testFileId\",\"type\":\"file\"},\"accessible_by\":{\"id\":\"testUserId\",\"type\":\"user\"},\"role\":\"editor\"}"; 24 | BoxApiCollaboration apiCollaboration = new BoxApiCollaboration(null); 25 | BoxUser user = BoxUser.createFromId("testUserId"); 26 | BoxRequestsShare.AddCollaboration collabRequest = apiCollaboration.getAddRequest(BoxFile.createFromId("testFileId"), BoxCollaboration.Role.EDITOR, user); 27 | String actual = collabRequest.getStringBody(); 28 | Assert.assertEquals(expected, actual); 29 | } 30 | } -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/utils/BoxContentProvider.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.utils; 2 | 3 | import android.content.ContentProvider; 4 | import android.content.ContentValues; 5 | import android.database.Cursor; 6 | import android.net.Uri; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | 11 | import com.box.androidsdk.content.BoxConfig; 12 | 13 | 14 | public class BoxContentProvider extends ContentProvider { 15 | 16 | @Override 17 | public boolean onCreate() { 18 | BoxConfig.APPLICATION_CONTEXT = getContext(); 19 | return true; 20 | } 21 | 22 | @Nullable 23 | @Override 24 | public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, 25 | @Nullable String[] selectionArgs, @Nullable String sortOrder) { 26 | return null; 27 | } 28 | 29 | @Nullable 30 | @Override 31 | public String getType(@NonNull Uri uri) { 32 | return null; 33 | } 34 | 35 | @Nullable 36 | @Override 37 | public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) { 38 | return null; 39 | } 40 | 41 | @Override 42 | public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) { 43 | return 0; 44 | } 45 | 46 | @Override 47 | public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, 48 | @Nullable String[] selectionArgs) { 49 | return 0; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /box-content-sdk/src/androidTest/java/com/box/androidsdk/content/models/BoxUploadSessionTest.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import junit.framework.TestCase; 4 | 5 | 6 | public class BoxUploadSessionTest extends TestCase { 7 | 8 | public void testParseJson() { 9 | String sessionJson = "{\"total_parts\":2," + 10 | "\"part_size\":8388608," + 11 | "\"session_endpoints\":{" + 12 | "\"list_parts\":\"https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD/parts\"," + 13 | "\"commit\":\"https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD/commit\"," + 14 | "\"upload_part\":\"https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD\"," + 15 | "\"status\":\"https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD\"," + 16 | "\"abort\":\"https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD\"" + 17 | "}," + 18 | "\"session_expires_at\":\"2017-04-18T01:45:15Z\"," + 19 | "\"id\":\"F971964745A5CD0C001BBE4E58196BFD\"," + 20 | "\"type\":\"upload_session\"," + 21 | "\"num_parts_processed\":0" + 22 | "}"; 23 | BoxUploadSession session = new BoxUploadSession(); 24 | session.createFromJson(sessionJson); 25 | String json = session.toJson(); 26 | System.out.println(json); 27 | assertEquals(sessionJson, json); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/BoxCacheFutureTask.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content; 2 | 3 | import com.box.androidsdk.content.models.BoxObject; 4 | import com.box.androidsdk.content.requests.BoxCacheableRequest; 5 | import com.box.androidsdk.content.requests.BoxRequest; 6 | import com.box.androidsdk.content.requests.BoxResponse; 7 | 8 | import java.util.concurrent.Callable; 9 | 10 | /** 11 | * A {@link BoxFutureTask} that indicates the results will be fetched from the cache instead of the 12 | * server 13 | */ 14 | public class BoxCacheFutureTask extends BoxFutureTask { 15 | 16 | 17 | /** 18 | * Creates a new instance of a task that will fetch results from the cache 19 | * 20 | * @param clazz the class of the return type 21 | * @param request the request to execute against the cache 22 | * @param cache The implementation of BoxCache to be used to store results of this task. 23 | */ 24 | public BoxCacheFutureTask(final Class clazz, final R request, final BoxCache cache) { 25 | super(new Callable>() { 26 | @Override 27 | public BoxResponse call() throws Exception { 28 | T result = null; 29 | Exception ex = null; 30 | try { 31 | result = cache.get(request); 32 | } catch (Exception e) { 33 | ex = e; 34 | } 35 | 36 | return new BoxResponse(result, ex, request); 37 | } 38 | }, request); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApi.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content; 2 | 3 | import com.box.androidsdk.content.models.BoxSession; 4 | 5 | /** 6 | * Base class for the Box API endpoint classes. 7 | */ 8 | public class BoxApi { 9 | 10 | protected BoxSession mSession; 11 | 12 | protected String mBaseUri = BoxConstants.BASE_URI; 13 | protected String mBaseUploadUri = BoxConstants.BASE_UPLOAD_URI; 14 | 15 | /** 16 | * Constructs a BoxApi with the provided BoxSession. 17 | * 18 | * @param session authenticated session to use with the BoxApi. 19 | */ 20 | public BoxApi(BoxSession session) { 21 | this.mSession = session; 22 | } 23 | 24 | /** 25 | * Returns the base URI for the API. 26 | * 27 | * @return base URI for the API. 28 | */ 29 | protected String getBaseUri() { 30 | if (mSession != null && mSession.getAuthInfo() != null && mSession.getAuthInfo().getBaseDomain() != null){ 31 | return String.format(BoxConstants.BASE_URI_TEMPLATE,mSession.getAuthInfo().getBaseDomain()); 32 | } 33 | return mBaseUri; 34 | } 35 | 36 | /** 37 | * Returns the base URI for uploads for the API. 38 | * 39 | * @return base upload URI. 40 | */ 41 | protected String getBaseUploadUri() { 42 | if (mSession != null && mSession.getAuthInfo() != null && mSession.getAuthInfo().getBaseDomain() != null){ 43 | return String.format(BoxConstants.BASE_UPLOAD_URI_TEMPLATE, mSession.getAuthInfo().getBaseDomain()); 44 | } 45 | return mBaseUploadUri; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/layout/boxsdk_choose_auth_activity.xml: -------------------------------------------------------------------------------- 1 | 7 | 15 | 16 | 23 | 24 | 32 | 33 | 34 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxIteratorBoxEntity.java: -------------------------------------------------------------------------------- 1 | package com.box.androidsdk.content.models; 2 | 3 | import com.eclipsesource.json.JsonObject; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | 8 | /** 9 | * A collection that contains a subset of items that are a part of a larger collection. The items within a partial collection begin at an offset within the full 10 | * collection and end at a specified limit. Note that the actual size of a partial collection may be less than its limit since the limit only specifies the 11 | * maximum size. For example, if there's a full collection with a size of 3, then a partial collection with offset 0 and limit 3 would be equal to a partial 12 | * collection with offset 0 and limit 100. 13 | * 14 | * @param the type of elements in this partial collection. 15 | */ 16 | public class BoxIteratorBoxEntity extends BoxIterator{ 17 | 18 | private static final long serialVersionUID = 8036181424029520417L; 19 | 20 | 21 | 22 | public BoxIteratorBoxEntity() { 23 | super(); 24 | } 25 | 26 | public BoxIteratorBoxEntity(JsonObject jsonObject) { 27 | super(jsonObject); 28 | } 29 | 30 | private transient BoxJsonObjectCreator representationCreator; 31 | 32 | @Override 33 | protected BoxJsonObjectCreator getObjectCreator() { 34 | if (representationCreator != null){ 35 | return representationCreator; 36 | } 37 | representationCreator = (BoxJsonObjectCreator)BoxEntity.getBoxJsonObjectCreator(); 38 | return representationCreator; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /box-content-sdk/src/main/res/layout/blocked_ip_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 19 | 27 |