├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── Notices.MD ├── README.MD ├── app ├── .gitignore ├── build.gradle ├── local.properties ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── microsoft │ │ └── office365 │ │ └── snippetapp │ │ ├── AndroidSnippetsApplication.java │ │ ├── CalendarStories │ │ ├── CreateOrDeleteEventStory.java │ │ ├── CreateRecurringEventStory.java │ │ ├── EventsFetcherStory.java │ │ ├── RespondToCalendarEventInviteStory.java │ │ └── UpdateEventStory.java │ │ ├── ContactStories │ │ ├── CreateOrDeleteContactStory.java │ │ ├── GetContactsStory.java │ │ ├── GetFilteredContactsWithSurnameStory.java │ │ └── UpdateContactStory.java │ │ ├── EmailStories │ │ ├── BaseEmailUserStory.java │ │ ├── DeleteEmailAttachmentStory.java │ │ ├── ForwardEmailMessageStory.java │ │ ├── GetEmailAttachmentsStory.java │ │ ├── GetEmailMessagesStory.java │ │ ├── ReplyToEmailMessageStory.java │ │ ├── SendEmailMessageStory.java │ │ ├── SendEmailWithMessageAttachStory.java │ │ └── SendEmailWithTextFileAttachmentStory.java │ │ ├── FileFolderStories │ │ ├── CreateOrDeleteFileStory.java │ │ ├── CreateOrDeleteOneDriveFolder.java │ │ ├── DownloadFileStory.java │ │ ├── GetFilesAndFoldersStory.java │ │ └── UpdateFileContentsOnServerStory.java │ │ ├── Interfaces │ │ ├── IOperationCompleteListener.java │ │ ├── O365Operations.java │ │ └── OnUseCaseStatusChangedListener.java │ │ ├── ODataStories │ │ ├── ODataFilterStory.java │ │ └── ODataSelectStory.java │ │ ├── OperationDetailActivity.java │ │ ├── OperationDetailFragment.java │ │ ├── OperationListActivity.java │ │ ├── OperationListAdapter.java │ │ ├── OperationListFragment.java │ │ ├── Snippets │ │ ├── CalendarSnippets.java │ │ ├── ContactsSnippets.java │ │ ├── EmailSnippets.java │ │ ├── FileFolderSnippets.java │ │ ├── ODataSystemQuerySnippets.java │ │ └── UsersAndGroupsSnippets.java │ │ ├── UserGroupStories │ │ ├── GetADGroupsStory.java │ │ ├── GetADUsersStory.java │ │ └── GetTenantDetailsStory.java │ │ └── helpers │ │ ├── APIErrorMessageHelper.java │ │ ├── AsyncUseCaseWrapper.java │ │ ├── AuthUtil.java │ │ ├── AuthenticationController.java │ │ ├── BaseUserStory.java │ │ ├── Constants.java │ │ ├── DiscoveryController.java │ │ ├── GlobalValues.java │ │ ├── O365ServicesManager.java │ │ ├── StoryAction.java │ │ ├── StoryGroupPlaceholder.java │ │ ├── StoryList.java │ │ └── StoryResultFormatter.java │ └── res │ ├── drawable │ ├── ic_action_refresh.png │ ├── ic_launcher.png │ ├── runall.png │ ├── store_logo_scale_100.png │ ├── user_signedout.png │ └── yellowtulip.jpg │ ├── layout │ ├── activity_operation_detail.xml │ ├── activity_operation_list.xml │ ├── fragment_operation_detail.xml │ ├── list_item_grouper.xml │ └── list_item_task.xml │ ├── menu │ └── main.xml │ ├── mipmap-hdpi │ ├── ic_action_editor_format_paint.png │ ├── ic_launcher.png │ ├── runall.png │ └── store_logo_scale_100.png │ ├── mipmap-mdpi │ ├── ic_action_editor_format_paint.png │ ├── ic_launcher.png │ ├── runall.png │ └── store_logo_scale_100.png │ ├── mipmap-xhdpi │ ├── ic_action_editor_format_paint.png │ ├── ic_launcher.png │ └── store_logo_scale_100.png │ ├── mipmap-xxhdpi │ ├── ic_action_editor_format_paint.png │ ├── ic_launcher.png │ └── store_logo_scale_100.png │ └── values │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── readme-images ├── constants_Modify.png ├── permissions-for-snippets-1.PNG ├── permissions-for-snippets-2.PNG └── permissions-for-snippets-3.PNG └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.ap_ 2 | *.apk 3 | *.class 4 | *.dex 5 | *.iml 6 | *.ipr 7 | *.iws 8 | .DS_Store 9 | .classpath 10 | .gradle 11 | .idea 12 | .project 13 | /.idea/libraries 14 | /.idea/workspace.xml 15 | /build 16 | /captures 17 | /gradle 18 | /gradlew 19 | /gradlew.bat 20 | /local.properties 21 | Thumbs.db 22 | bin/ 23 | build/ 24 | gen/ 25 | gradle/ 26 | out/ 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - platform-tools 5 | - extra 6 | - android-21 7 | - build-tools-21.1.2 8 | script: 9 | - gradle clean build 10 | notifications: 11 | slack: 12 | secure: ZHXQ3GQs7w5Svdweg3ZIzGxQo3DvSZlWWqR1Uyl6AiIUKLqjtM6KqriJDToja4lQu/DqFZb5OhBVGr08zutwcyQoW5AmRigSHFjEdb5nXs7YgLglPqxu3TAdXwjBN88otx0FNDeNbJOaN8EeNfyxTHtiUkSLafuobvgeTFUCWpA= 13 | email: 14 | recipients: 15 | - jak@microsoft.com 16 | on_success: never 17 | on_failure: always 18 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | defaultConfig { 7 | applicationId "com.microsoft.office365.snippetapp" 8 | minSdkVersion 16 9 | targetSdkVersion 21 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | 14 | compileOptions { 15 | sourceCompatibility JavaVersion.VERSION_1_7 16 | targetCompatibility JavaVersion.VERSION_1_7 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | productFlavors { 26 | } 27 | } 28 | 29 | dependencies { 30 | compile 'com.android.support:appcompat-v7:22.1.1' 31 | 32 | //Joda-Time for calendar time 33 | compile 'joda-time:joda-time:2.7' 34 | 35 | // base Office 365 SDK OData libraries: 36 | compile 'com.microsoft.services:odata-engine-core:0.13.0' 37 | compile 'com.microsoft.services:odata-engine-android-impl:0.13.0@aar' 38 | 39 | //Office 365 SDK service libraries: 40 | compile 'com.microsoft.services:outlook-services:0.13.0' 41 | compile 'com.microsoft.services:discovery-services:0.13.0' 42 | compile 'com.microsoft.services:directory-services:0.13.0' 43 | compile 'com.microsoft.services:file-services:0.13.0' 44 | 45 | // Azure Active Directory Library 46 | compile 'com.microsoft.aad:adal:1.1.3' 47 | } 48 | -------------------------------------------------------------------------------- /app/local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | #Tue Mar 24 18:24:15 PDT 2015 11 | sdk.dir=C\:\\Users\\davech\\AppData\\Local\\Android\\sdk 12 | -------------------------------------------------------------------------------- /app/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/johnaustin/AndroidSDK/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 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 34 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/AndroidSnippetsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp; 5 | 6 | import android.app.Application; 7 | 8 | public class AndroidSnippetsApplication extends Application { 9 | 10 | private static AndroidSnippetsApplication mAndroidSnippetsApplication; 11 | 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | mAndroidSnippetsApplication = this; 16 | } 17 | 18 | public static AndroidSnippetsApplication getApplication() { 19 | return mAndroidSnippetsApplication; 20 | } 21 | } 22 | // ********************************************************* 23 | // 24 | // O365-Android-Snippet, https://github.com/OfficeDev/O365-Android-Snippet 25 | // 26 | // Copyright (c) Microsoft Corporation 27 | // All rights reserved. 28 | // 29 | // MIT License: 30 | // Permission is hereby granted, free of charge, to any person obtaining 31 | // a copy of this software and associated documentation files (the 32 | // "Software"), to deal in the Software without restriction, including 33 | // without limitation the rights to use, copy, modify, merge, publish, 34 | // distribute, sublicense, and/or sell copies of the Software, and to 35 | // permit persons to whom the Software is furnished to do so, subject to 36 | // the following conditions: 37 | // 38 | // The above copyright notice and this permission notice shall be 39 | // included in all copies or substantial portions of the Software. 40 | // 41 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 42 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 43 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 44 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 45 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 46 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 47 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 | // 49 | // ********************************************************* 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/CalendarStories/CreateOrDeleteEventStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.CalendarStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 11 | import com.microsoft.office365.snippetapp.helpers.StoryAction; 12 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.concurrent.ExecutionException; 17 | 18 | //This story handles both of the following stories that appear in the UI list 19 | // based on strings passed in the constructor... 20 | //- Create an event (which is then deleted for cleanup) 21 | //- Delete an event (which is created first and then deleted) 22 | public class CreateOrDeleteEventStory extends BaseUserStory { 23 | private final String CREATE_DESCRIPTION = "Adds a new calendar event"; 24 | private final String CREATE_TAG = "Create event story"; 25 | private final String CREATE_SUCCESS = "CreateEventStory: Event created."; 26 | private final String CREATE_ERROR = "Create event exception: "; 27 | private final String DELETE_DESCRIPTION = "Deletes a calendar event"; 28 | private final String DELETE_TAG = "Delete event story"; 29 | private final String DELETE_SUCCESS = "DeleteEventStory: Event deleted."; 30 | private final String DELETE_ERROR = "Delete event exception: "; 31 | 32 | private String mDescription; 33 | private String mLogTag; 34 | private String mSuccessDescription; 35 | private String mErrorDescription; 36 | 37 | public CreateOrDeleteEventStory(StoryAction action) { 38 | switch (action) { 39 | case CREATE: { 40 | mDescription = CREATE_DESCRIPTION; 41 | mLogTag = CREATE_TAG; 42 | mSuccessDescription = CREATE_SUCCESS; 43 | mErrorDescription = CREATE_ERROR; 44 | break; 45 | } 46 | case DELETE: { 47 | mDescription = DELETE_DESCRIPTION; 48 | mLogTag = DELETE_TAG; 49 | mSuccessDescription = DELETE_SUCCESS; 50 | mErrorDescription = DELETE_ERROR; 51 | break; 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | public String execute() { 58 | //PREPARE 59 | AuthenticationController 60 | .getInstance() 61 | .setResourceId( 62 | super.getO365MailResourceId()); 63 | 64 | CalendarSnippets calendarSnippets = new CalendarSnippets( 65 | getO365MailClient()); 66 | 67 | List attendeeEmailAddresses = new ArrayList<>(); 68 | attendeeEmailAddresses.add(GlobalValues.USER_EMAIL); 69 | String newEventId; 70 | //ACT 71 | try { 72 | newEventId = calendarSnippets.createCalendarEvent( 73 | getStringResource(R.string.calendar_subject_text) 74 | , getStringResource(R.string.calendar_body_text) 75 | , java.util.Calendar.getInstance() 76 | , java.util.Calendar.getInstance() 77 | , attendeeEmailAddresses); 78 | 79 | //Delete event 80 | calendarSnippets.deleteCalendarEvent(newEventId); 81 | } catch (ExecutionException | InterruptedException e) { 82 | return FormatException(e, mLogTag); 83 | } 84 | return StoryResultFormatter.wrapResult(mSuccessDescription, true); 85 | } 86 | 87 | @Override 88 | public String getDescription() { 89 | return mDescription; 90 | } 91 | } 92 | // ********************************************************* 93 | // 94 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 95 | // 96 | // Copyright (c) Microsoft Corporation 97 | // All rights reserved. 98 | // 99 | // MIT License: 100 | // Permission is hereby granted, free of charge, to any person obtaining 101 | // a copy of this software and associated documentation files (the 102 | // "Software"), to deal in the Software without restriction, including 103 | // without limitation the rights to use, copy, modify, merge, publish, 104 | // distribute, sublicense, and/or sell copies of the Software, and to 105 | // permit persons to whom the Software is furnished to do so, subject to 106 | // the following conditions: 107 | // 108 | // The above copyright notice and this permission notice shall be 109 | // included in all copies or substantial portions of the Software. 110 | // 111 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 112 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 113 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 114 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 115 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 116 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 117 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 118 | // 119 | // ********************************************************* 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/CalendarStories/CreateRecurringEventStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.CalendarStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.concurrent.ExecutionException; 16 | 17 | public class CreateRecurringEventStory extends BaseUserStory { 18 | 19 | private static final String STORY_DESCRIPTION = "Create a recurring event"; 20 | 21 | @Override 22 | public String execute() { 23 | boolean isStoryComplete; 24 | String resultMessage; 25 | 26 | AuthenticationController 27 | .getInstance() 28 | .setResourceId( 29 | getO365MailResourceId()); 30 | 31 | CalendarSnippets calendarSnippets = new CalendarSnippets( 32 | getO365MailClient()); 33 | List attendeeEmailAdresses = new ArrayList<>(); 34 | attendeeEmailAdresses.add(GlobalValues.USER_EMAIL); 35 | 36 | try { 37 | //Create a recurring event 38 | String newEventId = calendarSnippets.createRecurringCalendarEvent( 39 | getStringResource(R.string.calendar_subject_text) 40 | , getStringResource(R.string.calendar_body_text) 41 | , attendeeEmailAdresses); 42 | 43 | //Cleanup by deleting the event 44 | calendarSnippets.deleteCalendarEvent(newEventId); 45 | isStoryComplete = true; 46 | resultMessage = STORY_DESCRIPTION + ": Recurring event created"; 47 | } catch (ExecutionException | InterruptedException e) { 48 | isStoryComplete = false; 49 | resultMessage = FormatException(e, STORY_DESCRIPTION); 50 | } 51 | 52 | return StoryResultFormatter.wrapResult(resultMessage, isStoryComplete); 53 | } 54 | 55 | @Override 56 | public String getDescription() { 57 | return STORY_DESCRIPTION; 58 | } 59 | } 60 | // ********************************************************* 61 | // 62 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 63 | // 64 | // Copyright (c) Microsoft Corporation 65 | // All rights reserved. 66 | // 67 | // MIT License: 68 | // Permission is hereby granted, free of charge, to any person obtaining 69 | // a copy of this software and associated documentation files (the 70 | // "Software"), to deal in the Software without restriction, including 71 | // without limitation the rights to use, copy, modify, merge, publish, 72 | // distribute, sublicense, and/or sell copies of the Software, and to 73 | // permit persons to whom the Software is furnished to do so, subject to 74 | // the following conditions: 75 | // 76 | // The above copyright notice and this permission notice shall be 77 | // included in all copies or substantial portions of the Software. 78 | // 79 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 80 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 81 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 82 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 83 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 84 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 85 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 86 | // 87 | // ********************************************************* 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/CalendarStories/EventsFetcherStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.CalendarStories; 6 | 7 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Event; 12 | 13 | import java.text.SimpleDateFormat; 14 | import java.util.List; 15 | import java.util.Locale; 16 | 17 | public class EventsFetcherStory extends BaseUserStory { 18 | 19 | public static final String STORY_DESCRIPTION = "Get calendar events"; 20 | 21 | @Override 22 | public String execute() { 23 | String returnResult; 24 | if (getO365MailClient() == null) { 25 | returnResult = "Null OutlookClient"; 26 | } 27 | try { 28 | AuthenticationController 29 | .getInstance() 30 | .setResourceId( 31 | getO365MailResourceId()); 32 | 33 | CalendarSnippets calendarSnippets = new CalendarSnippets( 34 | getO365MailClient()); 35 | 36 | //get the calendar events 37 | List events = calendarSnippets.getO365Events(); 38 | 39 | //build string for test results on UI 40 | StringBuilder sb = new StringBuilder(); 41 | sb.append("The following events were retrieved:\n"); 42 | for (Event event : events) { 43 | sb.append("\t\t" + event.getSubject() + ". " + formatEventDates(event)); 44 | sb.append("\n"); 45 | } 46 | returnResult = StoryResultFormatter.wrapResult(sb.toString(), true); 47 | } catch (Exception ex) { 48 | return FormatException(ex, STORY_DESCRIPTION); 49 | } 50 | return returnResult; 51 | } 52 | 53 | private String formatEventDates(Event thisEvent) { 54 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yy - hh:ss a", Locale.US); 55 | return simpleDateFormat.format(thisEvent.getStart().getTime()); 56 | } 57 | 58 | @Override 59 | public String getDescription() { 60 | return STORY_DESCRIPTION; 61 | } 62 | 63 | } 64 | // ********************************************************* 65 | // 66 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 67 | // 68 | // Copyright (c) Microsoft Corporation 69 | // All rights reserved. 70 | // 71 | // MIT License: 72 | // Permission is hereby granted, free of charge, to any person obtaining 73 | // a copy of this software and associated documentation files (the 74 | // "Software"), to deal in the Software without restriction, including 75 | // without limitation the rights to use, copy, modify, merge, publish, 76 | // distribute, sublicense, and/or sell copies of the Software, and to 77 | // permit persons to whom the Software is furnished to do so, subject to 78 | // the following conditions: 79 | // 80 | // The above copyright notice and this permission notice shall be 81 | // included in all copies or substantial portions of the Software. 82 | // 83 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 84 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 85 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 86 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 87 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 88 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 89 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 90 | // 91 | // ********************************************************* 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/CalendarStories/RespondToCalendarEventInviteStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.CalendarStories; 5 | 6 | import com.microsoft.office365.snippetapp.EmailStories.BaseEmailUserStory; 7 | import com.microsoft.office365.snippetapp.R; 8 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 9 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 10 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | import com.microsoft.outlookservices.ResponseType; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.concurrent.ExecutionException; 17 | 18 | public class RespondToCalendarEventInviteStory extends BaseEmailUserStory { 19 | 20 | private static final String STORY_DESCRIPTION = "Responds to accept an event invite"; 21 | 22 | @Override 23 | public String execute() { 24 | //PREPARE 25 | boolean isStoryComplete; 26 | String resultMessage; 27 | AuthenticationController 28 | .getInstance() 29 | .setResourceId( 30 | getO365MailResourceId()); 31 | 32 | CalendarSnippets calendarSnippets = new CalendarSnippets( 33 | getO365MailClient()); 34 | 35 | List attendeeEmailAddresses = new ArrayList<>(); 36 | attendeeEmailAddresses.add(GlobalValues.USER_EMAIL); 37 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 38 | String subjectLine = getStringResource(R.string.calendar_subject_text) 39 | + ":" 40 | + uniqueGUID; 41 | try { 42 | String newEventId = calendarSnippets.createCalendarEvent( 43 | subjectLine 44 | , getStringResource(R.string.calendar_body_text) 45 | , java.util.Calendar.getInstance() 46 | , java.util.Calendar.getInstance() 47 | , attendeeEmailAddresses); 48 | 49 | //wait for server to send event invitation 50 | Thread.sleep(5000); 51 | 52 | if (calendarSnippets.respondToCalendarEventInvite(newEventId 53 | , GlobalValues.USER_EMAIL, ResponseType.Accepted) != null) { 54 | 55 | //wait for server to update attendee status in event 56 | Thread.sleep(5000); 57 | ResponseType attendeeStatus = calendarSnippets.getEventAttendeeStatus( 58 | newEventId 59 | , GlobalValues.USER_EMAIL); 60 | 61 | //Validate the attendee status was set to accepted as expected 62 | if (attendeeStatus == ResponseType.Accepted) { 63 | resultMessage = StoryResultFormatter.wrapResult( 64 | "Respond to event invite story: Event accepted." 65 | , true); 66 | } else { 67 | resultMessage = StoryResultFormatter.wrapResult( 68 | "Respond to event invite story: Event response failed. " 69 | + attendeeStatus 70 | , false); 71 | } 72 | 73 | //CLEANUP by cancelling event 74 | calendarSnippets.deleteCalendarEvent(newEventId); 75 | } else { 76 | resultMessage = StoryResultFormatter.wrapResult( 77 | "Respond to event invite story: Event is null." 78 | , false); 79 | } 80 | } catch (ExecutionException | InterruptedException e) { 81 | resultMessage = FormatException(e, STORY_DESCRIPTION); 82 | } 83 | return resultMessage; 84 | } 85 | 86 | @Override 87 | public String getDescription() { 88 | return STORY_DESCRIPTION; 89 | } 90 | 91 | } 92 | // ********************************************************* 93 | // 94 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 95 | // 96 | // Copyright (c) Microsoft Corporation 97 | // All rights reserved. 98 | // 99 | // MIT License: 100 | // Permission is hereby granted, free of charge, to any person obtaining 101 | // a copy of this software and associated documentation files (the 102 | // "Software"), to deal in the Software without restriction, including 103 | // without limitation the rights to use, copy, modify, merge, publish, 104 | // distribute, sublicense, and/or sell copies of the Software, and to 105 | // permit persons to whom the Software is furnished to do so, subject to 106 | // the following conditions: 107 | // 108 | // The above copyright notice and this permission notice shall be 109 | // included in all copies or substantial portions of the Software. 110 | // 111 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 112 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 113 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 114 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 115 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 116 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 117 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 118 | // 119 | // ********************************************************* 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/CalendarStories/UpdateEventStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.CalendarStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | import com.microsoft.outlookservices.Event; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | import java.util.concurrent.ExecutionException; 17 | 18 | public class UpdateEventStory extends BaseUserStory { 19 | 20 | 21 | private static final String STORY_DESCRIPTION = "Update a calendar event"; 22 | 23 | @Override 24 | public String execute() { 25 | AuthenticationController 26 | .getInstance() 27 | .setResourceId( 28 | getO365MailResourceId()); 29 | 30 | CalendarSnippets calendarSnippets = new CalendarSnippets(getO365MailClient()); 31 | List attendeeEmailAddresses = new ArrayList<>(); 32 | attendeeEmailAddresses.add(GlobalValues.USER_EMAIL); 33 | String newEventId = ""; 34 | try { 35 | newEventId = calendarSnippets.createCalendarEvent( 36 | getStringResource(R.string.calendar_subject_text) 37 | , getStringResource(R.string.calendar_body_text) 38 | , java.util.Calendar.getInstance() 39 | , java.util.Calendar.getInstance() 40 | , attendeeEmailAddresses 41 | ); 42 | Thread.sleep(20000); 43 | Event updatedEvent = calendarSnippets.updateCalendarEvent( 44 | newEventId 45 | , getStringResource(R.string.calendar_subject_text) 46 | + " Updated Subject" 47 | , false 48 | , null 49 | , null 50 | , null 51 | , null 52 | ); 53 | Thread.sleep(20000); 54 | String updatedSubject = updatedEvent.getSubject(); 55 | calendarSnippets.deleteCalendarEvent(newEventId); 56 | if (updatedSubject.equals(getStringResource(R.string.calendar_subject_text) 57 | + " Updated Subject")) { 58 | return StoryResultFormatter.wrapResult( 59 | STORY_DESCRIPTION + ": Event " 60 | + " updated.", true); 61 | } else { 62 | return StoryResultFormatter.wrapResult( 63 | STORY_DESCRIPTION + ": Update " 64 | + " event.", false); 65 | } 66 | } catch (ExecutionException | InterruptedException e) { 67 | return FormatException(e, STORY_DESCRIPTION); 68 | } 69 | } 70 | 71 | @Override 72 | public String getDescription() { 73 | return STORY_DESCRIPTION; 74 | } 75 | } 76 | // ********************************************************* 77 | // 78 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 79 | // 80 | // Copyright (c) Microsoft Corporation 81 | // All rights reserved. 82 | // 83 | // MIT License: 84 | // Permission is hereby granted, free of charge, to any person obtaining 85 | // a copy of this software and associated documentation files (the 86 | // "Software"), to deal in the Software without restriction, including 87 | // without limitation the rights to use, copy, modify, merge, publish, 88 | // distribute, sublicense, and/or sell copies of the Software, and to 89 | // permit persons to whom the Software is furnished to do so, subject to 90 | // the following conditions: 91 | // 92 | // The above copyright notice and this permission notice shall be 93 | // included in all copies or substantial portions of the Software. 94 | // 95 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 96 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 97 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 98 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 99 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 100 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 101 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 102 | // 103 | // ********************************************************* 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ContactStories/CreateOrDeleteContactStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ContactStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.ContactsSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryAction; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | 13 | import java.util.concurrent.ExecutionException; 14 | 15 | //This story handles both of the following stories that appear in the UI list 16 | // based on strings passed in the constructor... 17 | //- Create a contact (which is then deleted for cleanup) 18 | //- Delete a contact (which is created first and then deleted) 19 | public class CreateOrDeleteContactStory extends BaseUserStory { 20 | private final String CREATE_DESCRIPTION = "Creates a new contact"; 21 | private final String CREATE_TAG = "Create contact story"; 22 | private final String CREATE_SUCCESS = "CreateContactStory: Contact created."; 23 | private final String CREATE_ERROR = "Create contact exception: "; 24 | private final String DELETE_DESCRIPTION = "Deletes a contact"; 25 | private final String DELETE_TAG = "Delete contact story"; 26 | private final String DELETE_SUCCESS = "DeleteContactStory: Contact deleted."; 27 | private final String DELETE_ERROR = "Delete contact exception: "; 28 | 29 | private String mDescription; 30 | private String mLogTag; 31 | private String mSuccessDescription; 32 | private String mErrorDescription; 33 | 34 | public CreateOrDeleteContactStory(StoryAction action) { 35 | switch (action) { 36 | case CREATE: { 37 | mDescription = CREATE_DESCRIPTION; 38 | mLogTag = CREATE_TAG; 39 | mSuccessDescription = CREATE_SUCCESS; 40 | mErrorDescription = CREATE_ERROR; 41 | break; 42 | } 43 | case DELETE: { 44 | mDescription = DELETE_DESCRIPTION; 45 | mLogTag = DELETE_TAG; 46 | mSuccessDescription = DELETE_SUCCESS; 47 | mErrorDescription = DELETE_ERROR; 48 | break; 49 | } 50 | } 51 | } 52 | 53 | @Override 54 | public String execute() { 55 | String returnValue = StoryResultFormatter.wrapResult( 56 | mLogTag, false 57 | ); 58 | AuthenticationController 59 | .getInstance() 60 | .setResourceId( 61 | getO365MailResourceId()); 62 | 63 | ContactsSnippets contactsSnippets = new ContactsSnippets(getO365MailClient()); 64 | try { 65 | String contactId = contactsSnippets.createContact( 66 | getStringResource(R.string.contacts_email), 67 | getStringResource(R.string.contacts_business_phone), 68 | getStringResource(R.string.contacts_home_phone), 69 | getStringResource(R.string.contacts_first_name), 70 | getStringResource(R.string.contacts_last_name)); 71 | if (contactId.length() > 0) { 72 | contactsSnippets.deleteContact(contactId); 73 | return StoryResultFormatter.wrapResult( 74 | mSuccessDescription, true 75 | ); 76 | } 77 | } catch (ExecutionException | InterruptedException e) { 78 | return FormatException(e, mDescription); 79 | } 80 | return returnValue; 81 | } 82 | 83 | @Override 84 | public String getDescription() { 85 | return mDescription; 86 | } 87 | 88 | } 89 | // ********************************************************* 90 | // 91 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 92 | // 93 | // Copyright (c) Microsoft Corporation 94 | // All rights reserved. 95 | // 96 | // MIT License: 97 | // Permission is hereby granted, free of charge, to any person obtaining 98 | // a copy of this software and associated documentation files (the 99 | // "Software"), to deal in the Software without restriction, including 100 | // without limitation the rights to use, copy, modify, merge, publish, 101 | // distribute, sublicense, and/or sell copies of the Software, and to 102 | // permit persons to whom the Software is furnished to do so, subject to 103 | // the following conditions: 104 | // 105 | // The above copyright notice and this permission notice shall be 106 | // included in all copies or substantial portions of the Software. 107 | // 108 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 109 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 110 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 111 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 112 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 113 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 114 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 115 | // 116 | // ********************************************************* 117 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ContactStories/GetContactsStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ContactStories; 5 | 6 | import com.microsoft.office365.snippetapp.Snippets.ContactsSnippets; 7 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 8 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 9 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 10 | import com.microsoft.outlookservices.Contact; 11 | 12 | import java.util.List; 13 | import java.util.concurrent.ExecutionException; 14 | 15 | public class GetContactsStory extends BaseUserStory { 16 | 17 | private static final String STORY_DESCRIPTION = "Gets your contacts"; 18 | 19 | @Override 20 | public String execute() { 21 | AuthenticationController 22 | .getInstance() 23 | .setResourceId( 24 | getO365MailResourceId()); 25 | 26 | ContactsSnippets contactsSnippets = new ContactsSnippets( 27 | getO365MailClient()); 28 | try { 29 | List contacts = contactsSnippets.getContacts(11); 30 | //build string for test results on UI 31 | StringBuilder sb = new StringBuilder(); 32 | sb.append("Gets contacts: " 33 | + contacts.size() 34 | + " contacts returned"); 35 | sb.append("\n"); 36 | for (Contact contact : contacts) { 37 | sb.append("\t\t"); 38 | sb.append(contact.getDisplayName()); 39 | sb.append("\n"); 40 | } 41 | return StoryResultFormatter.wrapResult(sb.toString(), true); 42 | 43 | } catch (ExecutionException | InterruptedException e) { 44 | return FormatException(e, STORY_DESCRIPTION); 45 | } 46 | } 47 | 48 | @Override 49 | public String getDescription() { 50 | return STORY_DESCRIPTION; 51 | } 52 | 53 | 54 | } 55 | // ********************************************************* 56 | // 57 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 58 | // 59 | // Copyright (c) Microsoft Corporation 60 | // All rights reserved. 61 | // 62 | // MIT License: 63 | // Permission is hereby granted, free of charge, to any person obtaining 64 | // a copy of this software and associated documentation files (the 65 | // "Software"), to deal in the Software without restriction, including 66 | // without limitation the rights to use, copy, modify, merge, publish, 67 | // distribute, sublicense, and/or sell copies of the Software, and to 68 | // permit persons to whom the Software is furnished to do so, subject to 69 | // the following conditions: 70 | // 71 | // The above copyright notice and this permission notice shall be 72 | // included in all copies or substantial portions of the Software. 73 | // 74 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 75 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 76 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 77 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 78 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 79 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 80 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 81 | // 82 | // ********************************************************* 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ContactStories/GetFilteredContactsWithSurnameStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ContactStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.ContactsSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Contact; 12 | 13 | import java.util.List; 14 | import java.util.concurrent.ExecutionException; 15 | 16 | public class GetFilteredContactsWithSurnameStory extends BaseUserStory { 17 | 18 | private static final String STORY_DESCRIPTION = "Gets contacts filtered by surname"; 19 | private static final String CONTACT_WITH_SURNAME = "Contact with surname"; 20 | 21 | @Override 22 | public String execute() { 23 | boolean isStoryComplete = false; 24 | String storyResultText = ""; 25 | 26 | String surname = getStringResource(R.string.contacts_last_name); 27 | AuthenticationController 28 | .getInstance() 29 | .setResourceId(getO365MailResourceId()); 30 | ContactsSnippets contactsSnippets = new ContactsSnippets(getO365MailClient()); 31 | 32 | try { 33 | //Create a contact that we can test against 34 | String contactId = contactsSnippets.createContact( 35 | getStringResource(R.string.contacts_email), 36 | getStringResource(R.string.contacts_business_phone), 37 | getStringResource(R.string.contacts_home_phone), 38 | getStringResource(R.string.contacts_first_name), 39 | surname); 40 | 41 | //Find the new test contact 42 | List contacts = contactsSnippets.getContactsWithSurname(surname); 43 | for (Contact contact : contacts) { 44 | if (contact.getSurname().equals(surname)) { 45 | break; 46 | } 47 | } 48 | //Delete the test contact from tenant 49 | contactsSnippets.deleteContact(contactId); 50 | 51 | //Story is completed 52 | storyResultText = StoryResultFormatter.wrapResult(CONTACT_WITH_SURNAME 53 | + " " + surname 54 | + " found.", true); 55 | } catch (ExecutionException | InterruptedException e) { 56 | storyResultText = FormatException(e, STORY_DESCRIPTION); 57 | } 58 | return storyResultText; 59 | } 60 | 61 | @Override 62 | public String getDescription() { 63 | return STORY_DESCRIPTION; 64 | } 65 | 66 | 67 | } 68 | // ********************************************************* 69 | // 70 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 71 | // 72 | // Copyright (c) Microsoft Corporation 73 | // All rights reserved. 74 | // 75 | // MIT License: 76 | // Permission is hereby granted, free of charge, to any person obtaining 77 | // a copy of this software and associated documentation files (the 78 | // "Software"), to deal in the Software without restriction, including 79 | // without limitation the rights to use, copy, modify, merge, publish, 80 | // distribute, sublicense, and/or sell copies of the Software, and to 81 | // permit persons to whom the Software is furnished to do so, subject to 82 | // the following conditions: 83 | // 84 | // The above copyright notice and this permission notice shall be 85 | // included in all copies or substantial portions of the Software. 86 | // 87 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 88 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 89 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 90 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 91 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 92 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 93 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 94 | // 95 | // ********************************************************* 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ContactStories/UpdateContactStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ContactStories; 5 | 6 | import android.content.Context; 7 | 8 | import com.microsoft.office365.snippetapp.R; 9 | import com.microsoft.office365.snippetapp.Snippets.ContactsSnippets; 10 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 11 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 12 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 13 | import com.microsoft.outlookservices.Contact; 14 | 15 | import java.util.concurrent.ExecutionException; 16 | 17 | public class UpdateContactStory extends BaseUserStory { 18 | private static final String UPDATE_CONTACT_STORY = "Update Contact story"; 19 | private static final String STORY_DESCRIPTION = "Updates the surname of a contact"; 20 | private Context mContext; 21 | 22 | public UpdateContactStory(Context context) { 23 | mContext = context; 24 | } 25 | 26 | @Override 27 | public String execute() { 28 | String returnValue = "CreateContactStory failed"; 29 | AuthenticationController 30 | .getInstance() 31 | .setResourceId( 32 | getO365MailResourceId()); 33 | 34 | ContactsSnippets contactsSnippets = new ContactsSnippets(getO365MailClient()); 35 | try { 36 | //Create a new contact to test update API with 37 | String contactId = contactsSnippets.createContact( 38 | mContext.getString(R.string.contacts_email), 39 | mContext.getString(R.string.contacts_business_phone), 40 | mContext.getString(R.string.contacts_home_phone), 41 | mContext.getString(R.string.contacts_first_name), 42 | mContext.getString(R.string.contacts_last_name) 43 | ); 44 | if (contactId.length() > 0) { 45 | //Set a new surname value on contact to update 46 | //and update the contact 47 | String newSurname = "Curtis_2"; 48 | 49 | contactsSnippets.updateContact( 50 | contactId 51 | , mContext.getString(R.string.contacts_first_name) 52 | , newSurname 53 | ); 54 | 55 | //Get the updated contact from server and compare surname with 56 | //the intended update surname value 57 | Contact updatedContact = contactsSnippets.getAContact(contactId); 58 | if (updatedContact != null) { 59 | String testSurName = updatedContact.getSurname(); 60 | if (testSurName.length() > 0 && testSurName.equals(newSurname)) { 61 | returnValue = StoryResultFormatter.wrapResult( 62 | "UpdateContactStory: Contact " 63 | + " updated." 64 | , true 65 | ); 66 | } else { 67 | returnValue = StoryResultFormatter.wrapResult( 68 | "UpdateContactStory: Contact " 69 | , false 70 | ); 71 | 72 | } 73 | } else { 74 | returnValue = StoryResultFormatter.wrapResult( 75 | "UpdateContactStory: Contact " 76 | , false 77 | ); 78 | 79 | } 80 | //Clean up state 81 | contactsSnippets.deleteContact(contactId); 82 | return returnValue; 83 | } 84 | } catch (ExecutionException | InterruptedException e) { 85 | return FormatException(e, UPDATE_CONTACT_STORY); 86 | } 87 | return returnValue; 88 | } 89 | 90 | @Override 91 | public String getDescription() { 92 | return STORY_DESCRIPTION; 93 | } 94 | } 95 | // ********************************************************* 96 | // 97 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 98 | // 99 | // Copyright (c) Microsoft Corporation 100 | // All rights reserved. 101 | // 102 | // MIT License: 103 | // Permission is hereby granted, free of charge, to any person obtaining 104 | // a copy of this software and associated documentation files (the 105 | // "Software"), to deal in the Software without restriction, including 106 | // without limitation the rights to use, copy, modify, merge, publish, 107 | // distribute, sublicense, and/or sell copies of the Software, and to 108 | // permit persons to whom the Software is furnished to do so, subject to 109 | // the following conditions: 110 | // 111 | // The above copyright notice and this permission notice shall be 112 | // included in all copies or substantial portions of the Software. 113 | // 114 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 115 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 116 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 117 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 118 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 119 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 120 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 121 | // 122 | // ********************************************************* 123 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/BaseEmailUserStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 7 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 8 | import com.microsoft.outlookservices.Message; 9 | 10 | import java.util.List; 11 | import java.util.concurrent.ExecutionException; 12 | 13 | public abstract class BaseEmailUserStory extends BaseUserStory { 14 | 15 | private static final int MAX_POLL_REQUESTS = 20; 16 | public static final int THREAD_SLEEP_TIME = 3000; 17 | 18 | public abstract String execute(); 19 | 20 | public abstract String getDescription(); 21 | 22 | /** 23 | * Gets first message found with the given subject line from the user's inbox. 24 | * Uses a polling technique because typically the message was just sent and there 25 | * is a small wait time until it arrives. 26 | * 27 | * @param emailSnippets Snippets which contains a message search snippet that is needed 28 | * @param subjectLine The subject line to search for 29 | * @return 30 | * @throws ExecutionException 31 | * @throws InterruptedException 32 | */ 33 | protected Message GetAMessageFromEmailFolder(EmailSnippets emailSnippets, String subjectLine, String folderName) 34 | throws ExecutionException, InterruptedException { 35 | 36 | Message message = null; 37 | int tryCount = 0; 38 | 39 | //Continue trying to get the email while the email is not found 40 | //and the loop has tried less than MAX_POLL_REQUESTS times. 41 | do { 42 | List messages; 43 | messages = emailSnippets 44 | .getMailboxMessagesByFolderNameSubject( 45 | subjectLine 46 | , folderName); 47 | if (messages.size() > 0) { 48 | message = messages.get(0); 49 | } 50 | tryCount++; 51 | Thread.sleep(THREAD_SLEEP_TIME); 52 | //Stay in loop while these conditions are true. 53 | //If either condition becomes false, break 54 | } while (message == null && tryCount < MAX_POLL_REQUESTS); 55 | 56 | return message; 57 | } 58 | 59 | //Deletes all messages with the given subject line from a named email folder 60 | protected void DeleteAMessageFromMailFolder( 61 | EmailSnippets emailSnippets 62 | , String subjectLine, String folderName) 63 | throws ExecutionException, InterruptedException { 64 | 65 | List messagesToDelete; 66 | int tryCount = 0; 67 | //Try to get the newly sent email from user's inbox at least once. 68 | //continue trying to get the email while the email is not found 69 | //and the loop has tried less than 50 times. 70 | do { 71 | 72 | messagesToDelete = emailSnippets 73 | .getMailboxMessagesByFolderNameSubject( 74 | subjectLine 75 | , folderName); 76 | for (Message message : messagesToDelete) { 77 | //3. Delete the email using the ID 78 | emailSnippets.deleteMail(message.getId()); 79 | } 80 | tryCount++; 81 | Thread.sleep(THREAD_SLEEP_TIME); 82 | //Stay in loop while these conditions are true. 83 | //If either condition becomes false, break 84 | } while (messagesToDelete.size() == 0 && tryCount < MAX_POLL_REQUESTS); 85 | 86 | } 87 | } 88 | // ********************************************************* 89 | // 90 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 91 | // 92 | // Copyright (c) Microsoft Corporation 93 | // All rights reserved. 94 | // 95 | // MIT License: 96 | // Permission is hereby granted, free of charge, to any person obtaining 97 | // a copy of this software and associated documentation files (the 98 | // "Software"), to deal in the Software without restriction, including 99 | // without limitation the rights to use, copy, modify, merge, publish, 100 | // distribute, sublicense, and/or sell copies of the Software, and to 101 | // permit persons to whom the Software is furnished to do so, subject to 102 | // the following conditions: 103 | // 104 | // The above copyright notice and this permission notice shall be 105 | // included in all copies or substantial portions of the Software. 106 | // 107 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 108 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 109 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 110 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 111 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 112 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 113 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 114 | // 115 | // ********************************************************* 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/DeleteEmailAttachmentStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.EmailStories; 6 | 7 | import com.microsoft.office365.snippetapp.R; 8 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 9 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 10 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | 13 | import java.util.concurrent.ExecutionException; 14 | 15 | public class DeleteEmailAttachmentStory extends BaseEmailUserStory{ 16 | 17 | private static final String SENT_NOTICE = "Attachment email sent with subject line:"; 18 | private static final String STORY_DESCRIPTION = "Deletes an attachment from a draft email message"; 19 | 20 | @Override 21 | public String execute() { 22 | StringBuilder returnResult = new StringBuilder(); 23 | try { 24 | AuthenticationController 25 | .getInstance() 26 | .setResourceId( 27 | getO365MailResourceId()); 28 | 29 | EmailSnippets emailSnippets = new EmailSnippets( 30 | getO365MailClient()); 31 | 32 | //1. Add an email to draft folder and store the ID 33 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 34 | String mailSubject = getStringResource(R.string.mail_subject_text) + uniqueGUID; 35 | 36 | //Add a new email to the user's draft folder 37 | String emailID = emailSnippets.addDraftMail(GlobalValues.USER_EMAIL, 38 | mailSubject, 39 | getStringResource(R.string.mail_body_text)); 40 | 41 | //Add a text file attachment to the mail added to the draft folder 42 | emailSnippets.addTextFileAttachmentToMessage(emailID 43 | , getStringResource(R.string.text_attachment_contents) 44 | , getStringResource(R.string.text_attachment_filename) 45 | , false); 46 | 47 | StringBuilder sb = new StringBuilder(); 48 | sb.append(SENT_NOTICE); 49 | sb.append(getStringResource(R.string.mail_subject_text)); 50 | sb.append(uniqueGUID); 51 | 52 | if (emailID.length() > 0) { 53 | emailSnippets.removeEmailAttachments(emailID); 54 | 55 | returnResult.append(StoryResultFormatter.wrapResult(sb.toString(), true)); 56 | } else 57 | returnResult.append(StoryResultFormatter.wrapResult(sb.toString(), false)) ; 58 | 59 | 60 | } catch (ExecutionException | InterruptedException ex) { 61 | returnResult.append(FormatException(ex, STORY_DESCRIPTION)) ; 62 | } 63 | return returnResult.toString(); 64 | } 65 | 66 | @Override 67 | public String getDescription() { 68 | return STORY_DESCRIPTION; 69 | } 70 | } 71 | 72 | // ********************************************************* 73 | // 74 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 75 | // 76 | // Copyright (c) Microsoft Corporation 77 | // All rights reserved. 78 | // 79 | // MIT License: 80 | // Permission is hereby granted, free of charge, to any person obtaining 81 | // a copy of this software and associated documentation files (the 82 | // "Software"), to deal in the Software without restriction, including 83 | // without limitation the rights to use, copy, modify, merge, publish, 84 | // distribute, sublicense, and/or sell copies of the Software, and to 85 | // permit persons to whom the Software is furnished to do so, subject to 86 | // the following conditions: 87 | // 88 | // The above copyright notice and this permission notice shall be 89 | // included in all copies or substantial portions of the Software. 90 | // 91 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 92 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 93 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 94 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 95 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 96 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 97 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 98 | // 99 | // ********************************************************* 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/ForwardEmailMessageStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Message; 12 | 13 | import java.util.concurrent.ExecutionException; 14 | 15 | public class ForwardEmailMessageStory extends BaseEmailUserStory { 16 | 17 | private static final String STORY_DESCRIPTION = "Forward a draft email message"; 18 | 19 | @Override 20 | public String execute() { 21 | AuthenticationController 22 | .getInstance() 23 | .setResourceId( 24 | getO365MailResourceId()); 25 | 26 | try { 27 | EmailSnippets emailSnippets = new EmailSnippets( 28 | getO365MailClient()); 29 | 30 | //1. Send an email and store the ID 31 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 32 | emailSnippets.createAndSendMail( 33 | GlobalValues.USER_EMAIL 34 | , getStringResource(R.string.mail_subject_text) 35 | + uniqueGUID, getStringResource(R.string.mail_body_text)); 36 | 37 | //Get the new message 38 | Message messageToForward = GetAMessageFromEmailFolder(emailSnippets, 39 | getStringResource(R.string.mail_subject_text) 40 | + uniqueGUID, getStringResource(R.string.Email_Folder_Inbox)); 41 | 42 | String forwardEmailId = emailSnippets.forwardDraftMail(messageToForward.getId(),GlobalValues.USER_EMAIL); 43 | 44 | //3. Delete the email using the ID 45 | emailSnippets.deleteMail(messageToForward.getId()); 46 | if (forwardEmailId.length() > 0) { 47 | emailSnippets.deleteMail(forwardEmailId); 48 | } 49 | 50 | return StoryResultFormatter.wrapResult( 51 | STORY_DESCRIPTION, true 52 | ); 53 | } catch (ExecutionException | InterruptedException ex) { 54 | return FormatException(ex, STORY_DESCRIPTION); 55 | } 56 | } 57 | 58 | @Override 59 | public String getDescription() { 60 | return STORY_DESCRIPTION; 61 | } 62 | 63 | } 64 | // ********************************************************* 65 | // 66 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 67 | // 68 | // Copyright (c) Microsoft Corporation 69 | // All rights reserved. 70 | // 71 | // MIT License: 72 | // Permission is hereby granted, free of charge, to any person obtaining 73 | // a copy of this software and associated documentation files (the 74 | // "Software"), to deal in the Software without restriction, including 75 | // without limitation the rights to use, copy, modify, merge, publish, 76 | // distribute, sublicense, and/or sell copies of the Software, and to 77 | // permit persons to whom the Software is furnished to do so, subject to 78 | // the following conditions: 79 | // 80 | // The above copyright notice and this permission notice shall be 81 | // included in all copies or substantial portions of the Software. 82 | // 83 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 84 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 85 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 86 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 87 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 88 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 89 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 90 | // 91 | // ********************************************************* 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/GetEmailAttachmentsStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Attachment; 12 | import com.microsoft.outlookservices.FileAttachment; 13 | import com.microsoft.outlookservices.Message; 14 | 15 | import java.io.UnsupportedEncodingException; 16 | import java.util.List; 17 | import java.util.concurrent.ExecutionException; 18 | 19 | 20 | public class GetEmailAttachmentsStory extends BaseEmailUserStory { 21 | private static final String SENT_NOTICE = "Attachment email sent with subject line:"; 22 | private static final boolean IS_INLINE = false; 23 | private static final String STORY_DESCRIPTION = "Gets the attachments from an email message"; 24 | 25 | @Override 26 | public String execute() { 27 | String returnResult = ""; 28 | try { 29 | AuthenticationController 30 | .getInstance() 31 | .setResourceId( 32 | getO365MailResourceId()); 33 | 34 | EmailSnippets emailSnippets = new EmailSnippets( 35 | getO365MailClient()); 36 | //1. Send an email and store the ID 37 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 38 | String mailSubject = getStringResource(R.string.mail_subject_text) + uniqueGUID; 39 | 40 | //Add a new email to the user's draft folder 41 | String emailID = emailSnippets.addDraftMail(GlobalValues.USER_EMAIL, 42 | mailSubject, 43 | getStringResource(R.string.mail_body_text)); 44 | 45 | //Add a text file attachment to the mail added to the draft folder 46 | emailSnippets.addTextFileAttachmentToMessage(emailID 47 | , getStringResource(R.string.text_attachment_contents) 48 | , getStringResource(R.string.text_attachment_filename) 49 | , IS_INLINE); 50 | 51 | String draftMessageID = emailSnippets.getMailMessageById(emailID).getId(); 52 | 53 | //Send the draft email to the recipient 54 | emailSnippets.sendMail(draftMessageID); 55 | 56 | //Get the new message 57 | Message sentMessage = GetAMessageFromEmailFolder(emailSnippets, 58 | getStringResource(R.string.mail_subject_text) 59 | + uniqueGUID, getStringResource(R.string.Email_Folder_Inbox)); 60 | 61 | 62 | StringBuilder sb = new StringBuilder(); 63 | sb.append(SENT_NOTICE); 64 | sb.append(getStringResource(R.string.mail_subject_text) + uniqueGUID); 65 | if (sentMessage.getId().length() > 0) { 66 | List attachments = emailSnippets.getAttachmentsFromEmailMessage( 67 | sentMessage.getId()); 68 | //Send the mail with attachments 69 | //build string for test results on UI 70 | for (Attachment attachment : attachments) { 71 | if (attachment instanceof FileAttachment) { 72 | FileAttachment fileAttachment = (FileAttachment) attachment; 73 | String fileContents = new String(fileAttachment.getContentBytes(), "UTF-8"); 74 | sb.append(fileContents); 75 | sb.append("/n"); 76 | } 77 | } 78 | returnResult = StoryResultFormatter.wrapResult(sb.toString(), true); 79 | } else 80 | returnResult = StoryResultFormatter.wrapResult(sb.toString(), false); 81 | 82 | 83 | //3. Delete the email using the ID 84 | // Boolean result = emailSnippets.deleteMail(emailID); 85 | 86 | } catch (ExecutionException | InterruptedException | UnsupportedEncodingException ex) { 87 | return FormatException(ex, STORY_DESCRIPTION); 88 | } 89 | return returnResult; 90 | 91 | } 92 | 93 | @Override 94 | public String getDescription() { 95 | return STORY_DESCRIPTION; 96 | } 97 | } 98 | // ********************************************************* 99 | // 100 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 101 | // 102 | // Copyright (c) Microsoft Corporation 103 | // All rights reserved. 104 | // 105 | // MIT License: 106 | // Permission is hereby granted, free of charge, to any person obtaining 107 | // a copy of this software and associated documentation files (the 108 | // "Software"), to deal in the Software without restriction, including 109 | // without limitation the rights to use, copy, modify, merge, publish, 110 | // distribute, sublicense, and/or sell copies of the Software, and to 111 | // permit persons to whom the Software is furnished to do so, subject to 112 | // the following conditions: 113 | // 114 | // The above copyright notice and this permission notice shall be 115 | // included in all copies or substantial portions of the Software. 116 | // 117 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 118 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 119 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 120 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 121 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 122 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 123 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 124 | // 125 | // ********************************************************* 126 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/GetEmailMessagesStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 7 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 8 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 9 | import com.microsoft.outlookservices.Message; 10 | 11 | import java.util.List; 12 | import java.util.concurrent.ExecutionException; 13 | 14 | public class GetEmailMessagesStory extends BaseEmailUserStory { 15 | 16 | private static final String STORY_DESCRIPTION = "Gets 10 newest email messages"; 17 | 18 | @Override 19 | public String execute() { 20 | String returnResult; 21 | 22 | AuthenticationController 23 | .getInstance() 24 | .setResourceId( 25 | getO365MailResourceId()); 26 | 27 | try { 28 | 29 | EmailSnippets emailSnippets = new EmailSnippets( 30 | getO365MailClient()); 31 | 32 | //O365 API called in this helper 33 | List messages = emailSnippets.getMailMessages(); 34 | 35 | //build string for test results on UI 36 | StringBuilder sb = new StringBuilder(); 37 | sb.append("Gets email: " + messages.size() + " messages returned"); 38 | sb.append("\n"); 39 | for (Message m : messages) { 40 | sb.append("\t\t"); 41 | sb.append(m.getSubject()); 42 | sb.append("\n"); 43 | } 44 | returnResult = StoryResultFormatter.wrapResult(sb.toString(), true); 45 | } catch (ExecutionException | InterruptedException e) { 46 | return FormatException(e, STORY_DESCRIPTION); 47 | } 48 | return returnResult; 49 | } 50 | 51 | @Override 52 | public String getDescription() { 53 | return STORY_DESCRIPTION; 54 | } 55 | } 56 | // ********************************************************* 57 | // 58 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 59 | // 60 | // Copyright (c) Microsoft Corporation 61 | // All rights reserved. 62 | // 63 | // MIT License: 64 | // Permission is hereby granted, free of charge, to any person obtaining 65 | // a copy of this software and associated documentation files (the 66 | // "Software"), to deal in the Software without restriction, including 67 | // without limitation the rights to use, copy, modify, merge, publish, 68 | // distribute, sublicense, and/or sell copies of the Software, and to 69 | // permit persons to whom the Software is furnished to do so, subject to 70 | // the following conditions: 71 | // 72 | // The above copyright notice and this permission notice shall be 73 | // included in all copies or substantial portions of the Software. 74 | // 75 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 76 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 77 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 78 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 79 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 80 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 81 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 82 | // 83 | // ********************************************************* 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/ReplyToEmailMessageStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Message; 12 | 13 | import java.util.concurrent.ExecutionException; 14 | 15 | //Create a new email, send to yourself, reply to the email, and delete sent mail 16 | public class ReplyToEmailMessageStory extends BaseEmailUserStory { 17 | 18 | 19 | private static final String STORY_DESCRIPTION = "Reply to an email message"; 20 | 21 | @Override 22 | public String execute() { 23 | 24 | AuthenticationController 25 | .getInstance() 26 | .setResourceId( 27 | getO365MailResourceId()); 28 | 29 | try { 30 | EmailSnippets emailSnippets = new EmailSnippets( 31 | getO365MailClient()); 32 | 33 | //1. Send an email and store the ID 34 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 35 | emailSnippets.createAndSendMail( 36 | GlobalValues.USER_EMAIL 37 | , getStringResource(R.string.mail_subject_text) 38 | + uniqueGUID 39 | , getStringResource(R.string.mail_body_text)); 40 | 41 | //Get the new message 42 | Message message = GetAMessageFromEmailFolder(emailSnippets, 43 | getStringResource(R.string.mail_subject_text) 44 | + uniqueGUID, getStringResource(R.string.Email_Folder_Inbox)); 45 | 46 | if (message.getId().length() > 0) { 47 | String replyEmailId = emailSnippets.replyToEmailMessage( 48 | message.getId() 49 | , getStringResource(R.string.mail_body_text)); 50 | //3. Delete the email using the ID 51 | emailSnippets.deleteMail(message.getId()); 52 | if (replyEmailId.length() > 0) { 53 | emailSnippets.deleteMail(replyEmailId); 54 | } 55 | return StoryResultFormatter.wrapResult( 56 | STORY_DESCRIPTION + ":", true); 57 | } else { 58 | return StoryResultFormatter.wrapResult( 59 | STORY_DESCRIPTION + ":", false); 60 | } 61 | } catch (ExecutionException | InterruptedException ex) { 62 | return FormatException(ex, STORY_DESCRIPTION); 63 | } 64 | } 65 | 66 | @Override 67 | public String getDescription() { 68 | return STORY_DESCRIPTION; 69 | } 70 | } 71 | // ********************************************************* 72 | // 73 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 74 | // 75 | // Copyright (c) Microsoft Corporation 76 | // All rights reserved. 77 | // 78 | // MIT License: 79 | // Permission is hereby granted, free of charge, to any person obtaining 80 | // a copy of this software and associated documentation files (the 81 | // "Software"), to deal in the Software without restriction, including 82 | // without limitation the rights to use, copy, modify, merge, publish, 83 | // distribute, sublicense, and/or sell copies of the Software, and to 84 | // permit persons to whom the Software is furnished to do so, subject to 85 | // the following conditions: 86 | // 87 | // The above copyright notice and this permission notice shall be 88 | // included in all copies or substantial portions of the Software. 89 | // 90 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 91 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 92 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 93 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 94 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 95 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 96 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 97 | // 98 | // ********************************************************* 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/SendEmailMessageStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Message; 12 | 13 | public class SendEmailMessageStory extends BaseEmailUserStory { 14 | 15 | private static final String STORY_DESCRIPTION = "Sends an email message"; 16 | 17 | @Override 18 | public String execute() { 19 | String returnResult; 20 | try { 21 | 22 | AuthenticationController 23 | .getInstance() 24 | .setResourceId( 25 | getO365MailResourceId()); 26 | 27 | EmailSnippets emailSnippets = new EmailSnippets( 28 | getO365MailClient()); 29 | 30 | //1. Send an email and store the ID 31 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 32 | String subject = getStringResource(R.string.mail_subject_text) + uniqueGUID; 33 | emailSnippets.createAndSendMail(GlobalValues.USER_EMAIL, 34 | subject, 35 | getStringResource(R.string.mail_body_text)); 36 | 37 | //3. Delete the email using the ID 38 | Message message = GetAMessageFromEmailFolder(emailSnippets, subject, getStringResource(R.string.Email_Folder_Inbox)); 39 | emailSnippets.deleteMail(message.getId()); 40 | 41 | returnResult = StoryResultFormatter.wrapResult("Email is added", true); 42 | } catch (Exception e) { 43 | return FormatException(e, STORY_DESCRIPTION); 44 | } 45 | return returnResult; 46 | } 47 | 48 | @Override 49 | public String getDescription() { 50 | return STORY_DESCRIPTION; 51 | } 52 | 53 | 54 | } 55 | // ********************************************************* 56 | // 57 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 58 | // 59 | // Copyright (c) Microsoft Corporation 60 | // All rights reserved. 61 | // 62 | // MIT License: 63 | // Permission is hereby granted, free of charge, to any person obtaining 64 | // a copy of this software and associated documentation files (the 65 | // "Software"), to deal in the Software without restriction, including 66 | // without limitation the rights to use, copy, modify, merge, publish, 67 | // distribute, sublicense, and/or sell copies of the Software, and to 68 | // permit persons to whom the Software is furnished to do so, subject to 69 | // the following conditions: 70 | // 71 | // The above copyright notice and this permission notice shall be 72 | // included in all copies or substantial portions of the Software. 73 | // 74 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 75 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 76 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 77 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 78 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 79 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 80 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 81 | // 82 | // ********************************************************* 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/SendEmailWithMessageAttachStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | import com.microsoft.outlookservices.Message; 12 | 13 | public class SendEmailWithMessageAttachStory extends BaseEmailUserStory { 14 | 15 | private static final String STORY_DESCRIPTION = "Sends an email message with a message attachment"; 16 | private static final String SENT_NOTICE = "Email sent with subject line:"; 17 | private static final boolean IS_INLINE = false; 18 | 19 | 20 | @Override 21 | public String execute() { 22 | String returnResult = ""; 23 | try { 24 | AuthenticationController 25 | .getInstance() 26 | .setResourceId( 27 | getO365MailResourceId()); 28 | 29 | EmailSnippets emailSnippets = new EmailSnippets( 30 | getO365MailClient()); 31 | 32 | //1. Send an email and store the ID 33 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 34 | emailSnippets.createAndSendMail( 35 | GlobalValues.USER_EMAIL 36 | , getStringResource(R.string.mail_subject_text) 37 | + uniqueGUID, getStringResource(R.string.mail_body_text)); 38 | 39 | 40 | Message messageToAttach = GetAMessageFromEmailFolder(emailSnippets, 41 | getStringResource(R.string.mail_subject_text) 42 | + uniqueGUID, getStringResource(R.string.Email_Folder_Inbox)); 43 | 44 | if (messageToAttach != null) { 45 | //Create a new email message but do not send yet 46 | String newEmailId = emailSnippets.addDraftMail( 47 | GlobalValues.USER_EMAIL 48 | , getStringResource(R.string.mail_subject_text) + uniqueGUID 49 | , getStringResource(R.string.mail_body_text)); 50 | 51 | //Attach email message to new draft email 52 | emailSnippets.addItemAttachment( 53 | newEmailId 54 | , messageToAttach 55 | , IS_INLINE); 56 | 57 | //Send draft email 58 | emailSnippets.sendMail(newEmailId); 59 | 60 | DeleteAMessageFromMailFolder(emailSnippets, 61 | getStringResource(R.string.mail_subject_text) 62 | + uniqueGUID, 63 | getStringResource(R.string.Email_Folder_Sent)); 64 | 65 | returnResult = StoryResultFormatter.wrapResult( 66 | SENT_NOTICE 67 | + " " 68 | + getStringResource(R.string.mail_subject_text) 69 | , true); 70 | } 71 | 72 | 73 | } catch (Exception ex) { 74 | return FormatException(ex, STORY_DESCRIPTION); 75 | } 76 | return returnResult; 77 | } 78 | 79 | @Override 80 | public String getDescription() { 81 | return STORY_DESCRIPTION; 82 | } 83 | } 84 | 85 | // ********************************************************* 86 | // 87 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 88 | // 89 | // Copyright (c) Microsoft Corporation 90 | // All rights reserved. 91 | // 92 | // MIT License: 93 | // Permission is hereby granted, free of charge, to any person obtaining 94 | // a copy of this software and associated documentation files (the 95 | // "Software"), to deal in the Software without restriction, including 96 | // without limitation the rights to use, copy, modify, merge, publish, 97 | // distribute, sublicense, and/or sell copies of the Software, and to 98 | // permit persons to whom the Software is furnished to do so, subject to 99 | // the following conditions: 100 | // 101 | // The above copyright notice and this permission notice shall be 102 | // included in all copies or substantial portions of the Software. 103 | // 104 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 105 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 106 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 107 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 108 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 109 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 110 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 111 | // 112 | // ********************************************************* 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/EmailStories/SendEmailWithTextFileAttachmentStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.EmailStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.EmailSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.GlobalValues; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | 12 | 13 | public class SendEmailWithTextFileAttachmentStory extends BaseEmailUserStory { 14 | 15 | private static final String STORY_DESCRIPTION = "Sends an email message with a text file attachment"; 16 | private static final String SENT_NOTICE = "Email sent with subject line:"; 17 | private static final boolean IS_INLINE = false; 18 | 19 | @Override 20 | public String execute() { 21 | String returnResult; 22 | try { 23 | AuthenticationController 24 | .getInstance() 25 | .setResourceId( 26 | getO365MailResourceId()); 27 | 28 | EmailSnippets emailSnippets = new EmailSnippets( 29 | getO365MailClient()); 30 | 31 | //1. Send an email and store the ID 32 | String uniqueGUID = java.util.UUID.randomUUID().toString(); 33 | 34 | //Add a new email to the user's draft folder 35 | String emailID = emailSnippets.addDraftMail(GlobalValues.USER_EMAIL, 36 | getStringResource(R.string.mail_subject_text) + uniqueGUID, 37 | getStringResource(R.string.mail_body_text)); 38 | 39 | //Add a text file attachment to the mail added to the draft folder 40 | emailSnippets.addTextFileAttachmentToMessage(emailID 41 | , getStringResource(R.string.text_attachment_contents) 42 | , getStringResource(R.string.text_attachment_filename) 43 | , IS_INLINE); 44 | 45 | String draftMessageID = emailSnippets.getMailMessageById(emailID).getId(); 46 | 47 | //Send the mail with attachments 48 | returnResult = StoryResultFormatter.wrapResult( 49 | SENT_NOTICE 50 | + getStringResource(R.string.mail_subject_text) 51 | + uniqueGUID 52 | , true); 53 | 54 | //Send the draft email to the recipient 55 | emailSnippets.sendMail(draftMessageID); 56 | 57 | } catch (Exception ex) { 58 | return FormatException(ex, STORY_DESCRIPTION); 59 | } 60 | return returnResult; 61 | } 62 | 63 | @Override 64 | public String getDescription() { 65 | return STORY_DESCRIPTION; 66 | } 67 | } 68 | // ********************************************************* 69 | // 70 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 71 | // 72 | // Copyright (c) Microsoft Corporation 73 | // All rights reserved. 74 | // 75 | // MIT License: 76 | // Permission is hereby granted, free of charge, to any person obtaining 77 | // a copy of this software and associated documentation files (the 78 | // "Software"), to deal in the Software without restriction, including 79 | // without limitation the rights to use, copy, modify, merge, publish, 80 | // distribute, sublicense, and/or sell copies of the Software, and to 81 | // permit persons to whom the Software is furnished to do so, subject to 82 | // the following conditions: 83 | // 84 | // The above copyright notice and this permission notice shall be 85 | // included in all copies or substantial portions of the Software. 86 | // 87 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 88 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 89 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 90 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 91 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 92 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 93 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 94 | // 95 | // ********************************************************* 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/FileFolderStories/CreateOrDeleteFileStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.FileFolderStories; 5 | 6 | import com.google.common.base.Charsets; 7 | import com.microsoft.office365.snippetapp.Snippets.FileFolderSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryAction; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | 13 | import java.util.concurrent.ExecutionException; 14 | 15 | //This story handles both of the following stories that appear in the UI list 16 | // based on strings passed in the constructor... 17 | //- Create a file (which is then deleted for cleanup) 18 | //- Delete a file (which is created first and then deleted) 19 | public class CreateOrDeleteFileStory extends BaseUserStory { 20 | private final String CREATE_DESCRIPTION = "Create a file on server"; 21 | private final String CREATE_TAG = "CreateFile"; 22 | private final String CREATE_SUCCESS = "Create a file on server"; 23 | private final String CREATE_ERROR = "Create a file on server exception: "; 24 | 25 | private final String DELETE_DESCRIPTION = "Delete a file on server"; 26 | private final String DELETE_TAG = "DeleteFile"; 27 | private final String DELETE_SUCCESS = "Delete a file on server"; 28 | private final String DELETE_ERROR = "Delete a file on server exception: "; 29 | 30 | private String mDescription; 31 | private String mLogTag; 32 | private String mSuccessDescription; 33 | private String mErrorDescription; 34 | 35 | public CreateOrDeleteFileStory(StoryAction action) { 36 | switch (action) { 37 | case CREATE: { 38 | mDescription = CREATE_DESCRIPTION; 39 | mLogTag = CREATE_TAG; 40 | mSuccessDescription = CREATE_SUCCESS; 41 | mErrorDescription = CREATE_ERROR; 42 | break; 43 | } 44 | case DELETE: { 45 | mDescription = DELETE_DESCRIPTION; 46 | mLogTag = DELETE_TAG; 47 | mSuccessDescription = DELETE_SUCCESS; 48 | mErrorDescription = DELETE_ERROR; 49 | break; 50 | } 51 | } 52 | } 53 | 54 | @Override 55 | public String execute() { 56 | AuthenticationController 57 | .getInstance() 58 | .setResourceId( 59 | getFilesFoldersResourceId()); 60 | FileFolderSnippets fileFolderSnippets = new FileFolderSnippets( 61 | getO365MyFilesClient()); 62 | 63 | try { 64 | 65 | String fileContents = "Test create and delete file"; 66 | //Create file 67 | String newFileId = fileFolderSnippets 68 | .postNewFileToServer( 69 | "test_Create_Delete_" 70 | + java 71 | .util 72 | .UUID 73 | .randomUUID() 74 | .toString() 75 | + ".txt" 76 | , fileContents.getBytes(Charsets.UTF_8)); 77 | 78 | //Delete file 79 | fileFolderSnippets.deleteFileFromServer(newFileId); 80 | return StoryResultFormatter.wrapResult(mSuccessDescription, true); 81 | } catch (ExecutionException | InterruptedException e) { 82 | return FormatException(e, mDescription); 83 | } 84 | } 85 | 86 | @Override 87 | public String getDescription() { 88 | return mDescription; 89 | } 90 | } 91 | // ********************************************************* 92 | // 93 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 94 | // 95 | // Copyright (c) Microsoft Corporation 96 | // All rights reserved. 97 | // 98 | // MIT License: 99 | // Permission is hereby granted, free of charge, to any person obtaining 100 | // a copy of this software and associated documentation files (the 101 | // "Software"), to deal in the Software without restriction, including 102 | // without limitation the rights to use, copy, modify, merge, publish, 103 | // distribute, sublicense, and/or sell copies of the Software, and to 104 | // permit persons to whom the Software is furnished to do so, subject to 105 | // the following conditions: 106 | // 107 | // The above copyright notice and this permission notice shall be 108 | // included in all copies or substantial portions of the Software. 109 | // 110 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 111 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 112 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 113 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 114 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 115 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 116 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 117 | // 118 | // ********************************************************* 119 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/FileFolderStories/CreateOrDeleteOneDriveFolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.FileFolderStories; 5 | 6 | import com.microsoft.office365.snippetapp.Snippets.FileFolderSnippets; 7 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 8 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 9 | import com.microsoft.office365.snippetapp.helpers.StoryAction; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | 12 | import java.util.concurrent.ExecutionException; 13 | 14 | //This story handles both of the following stories that appear in the UI list 15 | // based on strings passed in the constructor... 16 | //- Create a OneDrive Folder (which is then deleted for cleanup) 17 | //- Delete a OneDrive Folder (which is created first and then deleted) 18 | public class CreateOrDeleteOneDriveFolder extends BaseUserStory { 19 | //Unique names used for tracking and cleanup of items created by running snippets 20 | private static final String FOLDER_NAME = "O365SnippetFolder_"; 21 | private final String CREATE_DESCRIPTION = "Create new folder on OneDrive"; 22 | private final String CREATE_SUCCESS = "OneDrive create folder story: Folder created."; 23 | private final String DELETE_DESCRIPTION = "Delete folder from OneDrive"; 24 | private final String DELETE_SUCCESS = "OneDrive delete folder story: Folder deleted."; 25 | private String mDescription; 26 | private String mSuccessDescription; 27 | 28 | public CreateOrDeleteOneDriveFolder(StoryAction action) { 29 | switch (action) { 30 | case CREATE: { 31 | mDescription = CREATE_DESCRIPTION; 32 | mSuccessDescription = CREATE_SUCCESS; 33 | break; 34 | } 35 | case DELETE: { 36 | mDescription = DELETE_DESCRIPTION; 37 | mSuccessDescription = DELETE_SUCCESS; 38 | break; 39 | } 40 | } 41 | } 42 | 43 | @Override 44 | public String execute() { 45 | AuthenticationController 46 | .getInstance() 47 | .setResourceId( 48 | getFilesFoldersResourceId()); 49 | FileFolderSnippets fileFolderSnippets = new FileFolderSnippets(getO365MyFilesClient()); 50 | 51 | try { 52 | String folderName = FOLDER_NAME + java 53 | .util 54 | .UUID 55 | .randomUUID() 56 | .toString(); 57 | 58 | //Create folder 59 | fileFolderSnippets.createO365Folder(folderName); 60 | 61 | //Delete folder 62 | fileFolderSnippets.deleteO365Folder(folderName); 63 | 64 | return StoryResultFormatter.wrapResult( 65 | mSuccessDescription, true); 66 | 67 | } catch (ExecutionException | InterruptedException e) { 68 | return FormatException(e, mDescription); 69 | } 70 | } 71 | 72 | @Override 73 | public String getDescription() { 74 | return mDescription; 75 | } 76 | 77 | } 78 | // ********************************************************* 79 | // 80 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 81 | // 82 | // Copyright (c) Microsoft Corporation 83 | // All rights reserved. 84 | // 85 | // MIT License: 86 | // Permission is hereby granted, free of charge, to any person obtaining 87 | // a copy of this software and associated documentation files (the 88 | // "Software"), to deal in the Software without restriction, including 89 | // without limitation the rights to use, copy, modify, merge, publish, 90 | // distribute, sublicense, and/or sell copies of the Software, and to 91 | // permit persons to whom the Software is furnished to do so, subject to 92 | // the following conditions: 93 | // 94 | // The above copyright notice and this permission notice shall be 95 | // included in all copies or substantial portions of the Software. 96 | // 97 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 98 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 99 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 100 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 101 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 102 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 103 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 104 | // 105 | // ********************************************************* 106 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/FileFolderStories/GetFilesAndFoldersStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.FileFolderStories; 5 | 6 | import com.microsoft.fileservices.Item; 7 | import com.microsoft.office365.snippetapp.Snippets.FileFolderSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | 12 | import java.util.List; 13 | import java.util.concurrent.ExecutionException; 14 | 15 | public class GetFilesAndFoldersStory extends BaseUserStory { 16 | 17 | private static final String STORY_DESCRIPTION = "Gets files and folders from user's OneDrive"; 18 | 19 | @Override 20 | public String execute() { 21 | AuthenticationController 22 | .getInstance() 23 | .setResourceId( 24 | getFilesFoldersResourceId()); 25 | 26 | FileFolderSnippets fileFolderSnippets = new FileFolderSnippets( 27 | getO365MyFilesClient()); 28 | try { 29 | List items = fileFolderSnippets.getFilesAndFolders(); 30 | //build string for test results on UI 31 | StringBuilder sb = new StringBuilder(); 32 | sb.append("Gets items: " 33 | + items.size() 34 | + " items returned"); 35 | sb.append("\n"); 36 | for (Item item : items) { 37 | sb.append("\t\t"); 38 | sb.append(item.gettype() + ": " + item.getname()); 39 | sb.append("\n"); 40 | } 41 | return StoryResultFormatter.wrapResult(sb.toString(), true); 42 | 43 | } catch (ExecutionException | InterruptedException e) { 44 | return FormatException(e, STORY_DESCRIPTION); 45 | } 46 | } 47 | 48 | @Override 49 | public String getDescription() { 50 | return STORY_DESCRIPTION; 51 | } 52 | 53 | } 54 | // ********************************************************* 55 | // 56 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 57 | // 58 | // Copyright (c) Microsoft Corporation 59 | // All rights reserved. 60 | // 61 | // MIT License: 62 | // Permission is hereby granted, free of charge, to any person obtaining 63 | // a copy of this software and associated documentation files (the 64 | // "Software"), to deal in the Software without restriction, including 65 | // without limitation the rights to use, copy, modify, merge, publish, 66 | // distribute, sublicense, and/or sell copies of the Software, and to 67 | // permit persons to whom the Software is furnished to do so, subject to 68 | // the following conditions: 69 | // 70 | // The above copyright notice and this permission notice shall be 71 | // included in all copies or substantial portions of the Software. 72 | // 73 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 74 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 75 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 76 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 77 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 78 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 79 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 80 | // 81 | // ********************************************************* 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/FileFolderStories/UpdateFileContentsOnServerStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.FileFolderStories; 5 | 6 | import com.google.common.base.Charsets; 7 | import com.microsoft.office365.snippetapp.Snippets.FileFolderSnippets; 8 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 9 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | 12 | import java.util.concurrent.ExecutionException; 13 | 14 | public class UpdateFileContentsOnServerStory extends BaseUserStory { 15 | 16 | private static final String STORY_DESCRIPTION = "Update file contents on user's OneDrive"; 17 | 18 | @Override 19 | public String execute() { 20 | AuthenticationController 21 | .getInstance() 22 | .setResourceId( 23 | getFilesFoldersResourceId()); 24 | FileFolderSnippets fileFolderSnippets = new FileFolderSnippets( 25 | getO365MyFilesClient()); 26 | try { 27 | 28 | String fileContents = "Test create file"; 29 | String newFileId = fileFolderSnippets 30 | .postNewFileToServer( 31 | "test_Update_" 32 | + java 33 | .util 34 | .UUID 35 | .randomUUID() 36 | .toString() 37 | + ".txt" 38 | , fileContents.getBytes(Charsets.UTF_8)); 39 | 40 | 41 | String updatedFileContents = fileContents + " updated"; 42 | fileFolderSnippets.postUpdatedFileToServer(newFileId, updatedFileContents); 43 | byte[] fileContentsBytes = fileFolderSnippets.getFileContentsFromServer(newFileId); 44 | fileFolderSnippets.deleteFileFromServer(newFileId); 45 | 46 | if (fileContentsBytes.length == updatedFileContents.length()) { 47 | return StoryResultFormatter.wrapResult(STORY_DESCRIPTION, true); 48 | } else { 49 | return StoryResultFormatter.wrapResult(STORY_DESCRIPTION, false); 50 | } 51 | 52 | } catch (ExecutionException | InterruptedException e) { 53 | return FormatException(e, STORY_DESCRIPTION); 54 | } 55 | } 56 | 57 | @Override 58 | public String getDescription() { 59 | return STORY_DESCRIPTION; 60 | } 61 | } 62 | // ********************************************************* 63 | // 64 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 65 | // 66 | // Copyright (c) Microsoft Corporation 67 | // All rights reserved. 68 | // 69 | // MIT License: 70 | // Permission is hereby granted, free of charge, to any person obtaining 71 | // a copy of this software and associated documentation files (the 72 | // "Software"), to deal in the Software without restriction, including 73 | // without limitation the rights to use, copy, modify, merge, publish, 74 | // distribute, sublicense, and/or sell copies of the Software, and to 75 | // permit persons to whom the Software is furnished to do so, subject to 76 | // the following conditions: 77 | // 78 | // The above copyright notice and this permission notice shall be 79 | // included in all copies or substantial portions of the Software. 80 | // 81 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 82 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 83 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 84 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 85 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 86 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 87 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 88 | // 89 | // ********************************************************* 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Interfaces/IOperationCompleteListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.Interfaces; 6 | 7 | public interface IOperationCompleteListener { 8 | class OperationResult { 9 | String mOperationResult; 10 | String mOperation; 11 | String mid; 12 | 13 | public String getOperationResult() { 14 | return mOperationResult; 15 | } 16 | 17 | public String getOperation() { 18 | return mOperation; 19 | } 20 | 21 | public String getId() { 22 | return mid; 23 | } 24 | 25 | // operation: the CRUD operation attempted. 26 | // operationResult: The result of the CRUD operation. 27 | // id: The id of the entity that was operated on. 28 | public OperationResult(String operation, String operationResult) { 29 | mOperation = operation; 30 | mOperationResult = operationResult; 31 | 32 | } 33 | 34 | } 35 | 36 | void onOperationComplete(OperationResult opResult); 37 | } 38 | // ********************************************************* 39 | // 40 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 41 | // 42 | // Copyright (c) Microsoft Corporation 43 | // All rights reserved. 44 | // 45 | // MIT License: 46 | // Permission is hereby granted, free of charge, to any person obtaining 47 | // a copy of this software and associated documentation files (the 48 | // "Software"), to deal in the Software without restriction, including 49 | // without limitation the rights to use, copy, modify, merge, publish, 50 | // distribute, sublicense, and/or sell copies of the Software, and to 51 | // permit persons to whom the Software is furnished to do so, subject to 52 | // the following conditions: 53 | // 54 | // The above copyright notice and this permission notice shall be 55 | // included in all copies or substantial portions of the Software. 56 | // 57 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 58 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 59 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 60 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 61 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 62 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 63 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64 | // 65 | // ********************************************************* 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Interfaces/O365Operations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.Interfaces; 6 | 7 | import android.view.View; 8 | 9 | import com.microsoft.fileservices.odata.SharePointClient; 10 | import com.microsoft.outlookservices.odata.OutlookClient; 11 | 12 | public interface O365Operations { 13 | public void connectToO365(); 14 | 15 | public void disconnectFromO365(); 16 | 17 | public void clearResults(); 18 | 19 | public OutlookClient getO365MailClient(); 20 | 21 | public String getMailServiceResourceId(); 22 | 23 | public SharePointClient getO365MyFilesClient(); 24 | 25 | public String getMyFilesServiceResourceId(); 26 | 27 | public View getResultView(); 28 | 29 | } 30 | 31 | // ********************************************************* 32 | // 33 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 34 | // 35 | // Copyright (c) Microsoft Corporation 36 | // All rights reserved. 37 | // 38 | // MIT License: 39 | // Permission is hereby granted, free of charge, to any person obtaining 40 | // a copy of this software and associated documentation files (the 41 | // "Software"), to deal in the Software without restriction, including 42 | // without limitation the rights to use, copy, modify, merge, publish, 43 | // distribute, sublicense, and/or sell copies of the Software, and to 44 | // permit persons to whom the Software is furnished to do so, subject to 45 | // the following conditions: 46 | // 47 | // The above copyright notice and this permission notice shall be 48 | // included in all copies or substantial portions of the Software. 49 | // 50 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 51 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 52 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 53 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 54 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 55 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 56 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 57 | // 58 | // ********************************************************* 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Interfaces/OnUseCaseStatusChangedListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.Interfaces; 5 | 6 | public interface OnUseCaseStatusChangedListener { 7 | 8 | void onUseCaseStatusChanged(); 9 | } 10 | // ********************************************************* 11 | // 12 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 13 | // 14 | // Copyright (c) Microsoft Corporation 15 | // All rights reserved. 16 | // 17 | // MIT License: 18 | // Permission is hereby granted, free of charge, to any person obtaining 19 | // a copy of this software and associated documentation files (the 20 | // "Software"), to deal in the Software without restriction, including 21 | // without limitation the rights to use, copy, modify, merge, publish, 22 | // distribute, sublicense, and/or sell copies of the Software, and to 23 | // permit persons to whom the Software is furnished to do so, subject to 24 | // the following conditions: 25 | // 26 | // The above copyright notice and this permission notice shall be 27 | // included in all copies or substantial portions of the Software. 28 | // 29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 32 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 34 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 35 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | // 37 | // ********************************************************* 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ODataStories/ODataFilterStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ODataStories; 5 | 6 | import com.microsoft.office365.snippetapp.R; 7 | import com.microsoft.office365.snippetapp.Snippets.CalendarSnippets; 8 | import com.microsoft.office365.snippetapp.Snippets.ODataSystemQuerySnippets; 9 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 10 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 11 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 12 | import com.microsoft.outlookservices.BodyType; 13 | import com.microsoft.outlookservices.Event; 14 | import com.microsoft.outlookservices.Importance; 15 | import com.microsoft.outlookservices.ItemBody; 16 | 17 | import java.util.Calendar; 18 | import java.util.List; 19 | import java.util.concurrent.ExecutionException; 20 | 21 | public class ODataFilterStory extends BaseUserStory { 22 | private static final String STORY_DESCRIPTION = "Use $filter to get events filtered by most important"; 23 | 24 | @Override 25 | public String execute() { 26 | boolean isSucceeding; 27 | AuthenticationController 28 | .getInstance() 29 | .setResourceId(getO365MailResourceId()); 30 | CalendarSnippets calendarSnippets = new CalendarSnippets(getO365MailClient()); 31 | ODataSystemQuerySnippets oDataSystemQuerySnippets = new ODataSystemQuerySnippets(); 32 | 33 | try { 34 | //Set up one important event to test with 35 | Event testEvent = new Event(); 36 | testEvent.setSubject(getStringResource(R.string.calendar_subject_text)); 37 | 38 | //Set body on test event 39 | ItemBody itemBody = new ItemBody(); 40 | itemBody.setContent(getStringResource(R.string.calendar_body_text)); 41 | itemBody.setContentType(BodyType.HTML); 42 | testEvent.setBody(itemBody); 43 | 44 | //Set start and end time for event 45 | Calendar eventTime = Calendar.getInstance(); 46 | testEvent.setStart(eventTime); 47 | eventTime.add(Calendar.HOUR_OF_DAY, 2); 48 | testEvent.setIsAllDay(false); 49 | testEvent.setEnd(eventTime); 50 | testEvent.setImportance(Importance.High); 51 | 52 | //Create test event on tenant 53 | testEvent = calendarSnippets.createCalendarEvent(testEvent); 54 | 55 | //Retrieve important events (should include our test event) 56 | List importantEvents = oDataSystemQuerySnippets.getImportantEventsUsing$filter(getO365MailClient()); 57 | 58 | //Check that all events are important to determine if story succeeded. 59 | isSucceeding = true; 60 | for (Event event : importantEvents) { 61 | if (event.getImportance() != Importance.High) { 62 | isSucceeding = false; 63 | break; 64 | } 65 | } 66 | 67 | //Delete test event from tenant 68 | calendarSnippets.deleteCalendarEvent(testEvent.getId()); 69 | 70 | } catch (ExecutionException | InterruptedException e) { 71 | return FormatException(e, STORY_DESCRIPTION); 72 | } 73 | if (isSucceeding) { 74 | return StoryResultFormatter.wrapResult(STORY_DESCRIPTION + ": Important events found.", true); 75 | } else { 76 | return StoryResultFormatter.wrapResult(STORY_DESCRIPTION + ": Important events not found.", false); 77 | } 78 | } 79 | 80 | @Override 81 | public String getDescription() { 82 | return STORY_DESCRIPTION; 83 | } 84 | 85 | 86 | } 87 | // ********************************************************* 88 | // 89 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 90 | // 91 | // Copyright (c) Microsoft Corporation 92 | // All rights reserved. 93 | // 94 | // MIT License: 95 | // Permission is hereby granted, free of charge, to any person obtaining 96 | // a copy of this software and associated documentation files (the 97 | // "Software"), to deal in the Software without restriction, including 98 | // without limitation the rights to use, copy, modify, merge, publish, 99 | // distribute, sublicense, and/or sell copies of the Software, and to 100 | // permit persons to whom the Software is furnished to do so, subject to 101 | // the following conditions: 102 | // 103 | // The above copyright notice and this permission notice shall be 104 | // included in all copies or substantial portions of the Software. 105 | // 106 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 107 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 108 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 109 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 110 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 111 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 112 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 113 | // 114 | // ********************************************************* 115 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/ODataStories/ODataSelectStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.ODataStories; 5 | 6 | import android.util.Log; 7 | 8 | import com.microsoft.office365.snippetapp.Snippets.ODataSystemQuerySnippets; 9 | import com.microsoft.office365.snippetapp.helpers.APIErrorMessageHelper; 10 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 11 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 12 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 13 | import com.microsoft.outlookservices.Message; 14 | 15 | import java.util.List; 16 | import java.util.concurrent.ExecutionException; 17 | 18 | public class ODataSelectStory extends BaseUserStory { 19 | private static final String STORY_DESCRIPTION = "Use $select to reduce payload when getting messages"; 20 | 21 | @Override 22 | public String execute() { 23 | boolean isStoryComplete = false; 24 | StringBuilder returnResult = new StringBuilder(); 25 | 26 | AuthenticationController 27 | .getInstance() 28 | .setResourceId( 29 | getO365MailResourceId()); 30 | try { 31 | ODataSystemQuerySnippets oDataSystemQuerySnippets = new ODataSystemQuerySnippets(); 32 | 33 | //O365 API called in this helper 34 | List messages = oDataSystemQuerySnippets.getMailMessagesUsing$select(getO365MailClient()); 35 | 36 | returnResult.append(STORY_DESCRIPTION) 37 | .append(": ") 38 | .append(messages.size()) 39 | .append(" messages returned") 40 | .append("\n"); 41 | 42 | for (Message message : messages) { 43 | returnResult.append("\t\tFrom: ") 44 | .append(message.getFrom()) 45 | .append("\n\t\tIs Read: ") 46 | .append(message.getIsRead().toString()) 47 | .append("\n\t\tSubject: ") 48 | .append(message.getSubject()) 49 | .append("\n"); 50 | } 51 | isStoryComplete = true; 52 | } catch (ExecutionException | InterruptedException e) { 53 | isStoryComplete = false; 54 | e.printStackTrace(); 55 | String formattedException = APIErrorMessageHelper.getErrorMessage(e.getMessage()); 56 | Log.e("Get email story", formattedException); 57 | returnResult = new StringBuilder(); 58 | returnResult.append(STORY_DESCRIPTION) 59 | .append(": ") 60 | .append(formattedException); 61 | } 62 | return StoryResultFormatter.wrapResult(returnResult.toString(), isStoryComplete); 63 | } 64 | 65 | @Override 66 | public String getDescription() { 67 | return STORY_DESCRIPTION; 68 | } 69 | } 70 | // ********************************************************* 71 | // 72 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 73 | // 74 | // Copyright (c) Microsoft Corporation 75 | // All rights reserved. 76 | // 77 | // MIT License: 78 | // Permission is hereby granted, free of charge, to any person obtaining 79 | // a copy of this software and associated documentation files (the 80 | // "Software"), to deal in the Software without restriction, including 81 | // without limitation the rights to use, copy, modify, merge, publish, 82 | // distribute, sublicense, and/or sell copies of the Software, and to 83 | // permit persons to whom the Software is furnished to do so, subject to 84 | // the following conditions: 85 | // 86 | // The above copyright notice and this permission notice shall be 87 | // included in all copies or substantial portions of the Software. 88 | // 89 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 90 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 91 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 92 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 93 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 94 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 95 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 96 | // 97 | // ********************************************************* 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/OperationDetailActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp; 5 | 6 | import android.os.Bundle; 7 | import android.support.v7.app.ActionBarActivity; 8 | import android.view.MenuItem; 9 | 10 | 11 | public class OperationDetailActivity extends ActionBarActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_operation_detail); 17 | 18 | if (savedInstanceState == null) { 19 | String itemId = getIntent().getStringExtra(OperationDetailFragment.ARG_ITEM_ID); 20 | OperationDetailFragment fragment = OperationDetailFragment.getInstance(itemId); 21 | getFragmentManager().beginTransaction() 22 | .add(R.id.operation_detail_container, fragment) 23 | .commit(); 24 | } 25 | } 26 | 27 | @Override 28 | public boolean onOptionsItemSelected(MenuItem item) { 29 | int id = item.getItemId(); 30 | return super.onOptionsItemSelected(item); 31 | } 32 | } 33 | // ********************************************************* 34 | // 35 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 36 | // 37 | // Copyright (c) Microsoft Corporation 38 | // All rights reserved. 39 | // 40 | // MIT License: 41 | // Permission is hereby granted, free of charge, to any person obtaining 42 | // a copy of this software and associated documentation files (the 43 | // "Software"), to deal in the Software without restriction, including 44 | // without limitation the rights to use, copy, modify, merge, publish, 45 | // distribute, sublicense, and/or sell copies of the Software, and to 46 | // permit persons to whom the Software is furnished to do so, subject to 47 | // the following conditions: 48 | // 49 | // The above copyright notice and this permission notice shall be 50 | // included in all copies or substantial portions of the Software. 51 | // 52 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 53 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 54 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 55 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 56 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 57 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 58 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 59 | // 60 | // ********************************************************* 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/OperationDetailFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp; 5 | 6 | import android.app.Fragment; 7 | import android.os.Bundle; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | public class OperationDetailFragment extends Fragment { 14 | 15 | public static final String ARG_ITEM_ID = "item_id"; 16 | 17 | private TextView mOperationDetailTextView; 18 | 19 | public static OperationDetailFragment getInstance(String itemId) { 20 | OperationDetailFragment fragment = new OperationDetailFragment(); 21 | Bundle arguments = new Bundle(); 22 | arguments.putString( 23 | OperationDetailFragment.ARG_ITEM_ID, 24 | itemId 25 | ); 26 | fragment.setArguments(arguments); 27 | return fragment; 28 | } 29 | 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 32 | View view = inflater.inflate(R.layout.fragment_operation_detail, container, false); 33 | mOperationDetailTextView = ((TextView) view.findViewById(R.id.operation_detail)); 34 | return view; 35 | } 36 | 37 | public void clearResults() { 38 | mOperationDetailTextView.setText(""); 39 | } 40 | } 41 | // ********************************************************* 42 | // 43 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 44 | // 45 | // Copyright (c) Microsoft Corporation 46 | // All rights reserved. 47 | // 48 | // MIT License: 49 | // Permission is hereby granted, free of charge, to any person obtaining 50 | // a copy of this software and associated documentation files (the 51 | // "Software"), to deal in the Software without restriction, including 52 | // without limitation the rights to use, copy, modify, merge, publish, 53 | // distribute, sublicense, and/or sell copies of the Software, and to 54 | // permit persons to whom the Software is furnished to do so, subject to 55 | // the following conditions: 56 | // 57 | // The above copyright notice and this permission notice shall be 58 | // included in all copies or substantial portions of the Software. 59 | // 60 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 61 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 62 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 63 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 64 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 65 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 66 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 67 | // 68 | // ********************************************************* 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/OperationListAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp; 6 | 7 | import android.app.Activity; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.BaseAdapter; 12 | import android.widget.TextView; 13 | 14 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 15 | 16 | import java.util.List; 17 | 18 | class OperationListAdapter extends BaseAdapter { 19 | 20 | protected LayoutInflater mLayoutInflater; 21 | protected List mBaseStoryList; 22 | protected TextView mOperationName; 23 | protected View mOperationProgressBar; 24 | 25 | OperationListAdapter(Activity activityContext, List stories) { 26 | if (null == activityContext) { 27 | throw new IllegalArgumentException("Context cannot be null"); 28 | } 29 | 30 | if (null == stories) { 31 | throw new IllegalArgumentException("Use cases cannot be null"); 32 | } 33 | mLayoutInflater = activityContext.getLayoutInflater(); 34 | mBaseStoryList = stories; 35 | } 36 | 37 | @Override 38 | public int getCount() { 39 | return mBaseStoryList.size(); 40 | } 41 | 42 | @Override 43 | public BaseUserStory getItem(int position) { 44 | return mBaseStoryList.get(position); 45 | } 46 | 47 | @Override 48 | public long getItemId(int position) { 49 | return 0; 50 | } 51 | 52 | @Override 53 | public View getView(int position, View convertView, ViewGroup parent) { 54 | CharSequence opDescription = getStoryDescription(position); 55 | int progressVisibility = isStoryExecuting(position) ? View.VISIBLE : View.INVISIBLE; 56 | 57 | //Always re-inflate the view because we have two view layouts and the layout changes 58 | //depending on the current scroll position. 59 | if (!getStoryGroupingFlag(position)) { 60 | convertView = mLayoutInflater.inflate(R.layout.list_item_task, parent, false); 61 | } else { 62 | convertView = mLayoutInflater.inflate(R.layout.list_item_grouper, parent, false); 63 | } 64 | 65 | if (!getStoryGroupingFlag(position)) { 66 | mOperationName = (TextView) convertView.findViewById(R.id.use_case_name); 67 | mOperationProgressBar = convertView.findViewById(R.id.use_case_progress); 68 | if (mOperationProgressBar != null) 69 | mOperationProgressBar.setVisibility(progressVisibility); 70 | } else { 71 | mOperationName = (TextView) convertView.findViewById(R.id.Group_name); 72 | } 73 | 74 | if (mOperationName != null) 75 | mOperationName.setText(opDescription); 76 | 77 | return convertView; 78 | } 79 | 80 | /** 81 | * Get the description of a story 82 | * 83 | * @param position the story to examine 84 | * @return the name to display 85 | */ 86 | protected CharSequence getStoryDescription(int position) { 87 | return getItem(position).getDescription(); 88 | } 89 | 90 | /** 91 | * Gets the story grouping flag of a story 92 | * 93 | * @param position the story to examine 94 | * @return the grouping flag 95 | */ 96 | protected boolean getStoryGroupingFlag(int position) { 97 | return getItem(position).getGroupingFlag(); 98 | } 99 | 100 | /** 101 | * Check if a story is executing 102 | * 103 | * @param position the position of the use case to examine 104 | * @return true if the use case is executing, otherwise false 105 | */ 106 | protected boolean isStoryExecuting(int position) { 107 | return getItem(position).isExecuting(); 108 | } 109 | } 110 | // ********************************************************* 111 | // 112 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 113 | // 114 | // Copyright (c) Microsoft Corporation 115 | // All rights reserved. 116 | // 117 | // MIT License: 118 | // Permission is hereby granted, free of charge, to any person obtaining 119 | // a copy of this software and associated documentation files (the 120 | // "Software"), to deal in the Software without restriction, including 121 | // without limitation the rights to use, copy, modify, merge, publish, 122 | // distribute, sublicense, and/or sell copies of the Software, and to 123 | // permit persons to whom the Software is furnished to do so, subject to 124 | // the following conditions: 125 | // 126 | // The above copyright notice and this permission notice shall be 127 | // included in all copies or substantial portions of the Software. 128 | // 129 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 130 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 131 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 132 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 133 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 134 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 135 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 136 | // 137 | // ********************************************************* 138 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Snippets/ContactsSnippets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.Snippets; 5 | 6 | import com.microsoft.outlookservices.Contact; 7 | import com.microsoft.outlookservices.EmailAddress; 8 | import com.microsoft.outlookservices.odata.OutlookClient; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.concurrent.ExecutionException; 13 | 14 | public class ContactsSnippets { 15 | 16 | private final OutlookClient mOutlookClient; 17 | 18 | public ContactsSnippets(OutlookClient mailClient) { 19 | mOutlookClient = mailClient; 20 | } 21 | 22 | /** 23 | * Return a list of contacts and ordered by the 24 | * contact's surname field. 25 | * 26 | * @return List. A list of the com.microsoft.outlookservices.Contact objects 27 | */ 28 | public List getContacts(int pageSize) throws ExecutionException, InterruptedException { 29 | return mOutlookClient 30 | .getMe() 31 | .getContacts() 32 | .top(pageSize) 33 | .skip(1) 34 | .select("displayName") 35 | .orderBy("surName") 36 | .read().get(); 37 | } 38 | 39 | /** 40 | * Creates a new contact 41 | * 42 | * @param emailAddressString The email address of the contact to be added 43 | * @param businessPhoneString The business telephone number of the new contact 44 | * @param firstNameString The first name of the new contact 45 | * @param homePhoneString The home telephone number of the new contact 46 | * @param lastNameString The surname of the new contact 47 | * @return String. The id of the new contact 48 | */ 49 | public String createContact( 50 | String emailAddressString, 51 | String businessPhoneString, 52 | String homePhoneString, 53 | String firstNameString, 54 | String lastNameString) throws ExecutionException, InterruptedException { 55 | Contact contact = new Contact(); 56 | 57 | EmailAddress emailAddress = new EmailAddress(); 58 | emailAddress.setAddress(emailAddressString); 59 | List emailAddressList = new ArrayList<>(); 60 | emailAddressList.add(emailAddress); 61 | contact.setEmailAddresses(emailAddressList); 62 | 63 | List businessPhones = new ArrayList<>(); 64 | businessPhones.add(businessPhoneString); 65 | List homePhones = new ArrayList<>(); 66 | homePhones.add(homePhoneString); 67 | contact.setBusinessPhones(businessPhones); 68 | contact.setHomePhones(homePhones); 69 | contact.setGivenName(firstNameString); 70 | contact.setSurname(lastNameString); 71 | 72 | return mOutlookClient 73 | .getMe() 74 | .getContacts() 75 | .select("ID") 76 | .add(contact).get().getId(); 77 | } 78 | 79 | /** 80 | * Gets a contact by the contact Id 81 | * 82 | * @return Contact. The contact corresponding to the id 83 | */ 84 | public Contact getAContact(String id) throws ExecutionException, InterruptedException { 85 | return mOutlookClient 86 | .getMe() 87 | .getContacts() 88 | .getById(id) 89 | .select("surname") 90 | .read().get(); 91 | } 92 | 93 | 94 | /** 95 | * Updates the first and surname of a contact 96 | * 97 | * @param contactId The id of the contact to be updated 98 | * @param firstNameString The updated first name of the new contact 99 | * @param lastNameString The updated surname of the new contact 100 | */ 101 | public void updateContact(String contactId, String firstNameString, String lastNameString) 102 | throws ExecutionException, InterruptedException { 103 | //Get the contact to update 104 | Contact updateContact = mOutlookClient 105 | .getMe() 106 | .getContacts() 107 | .getById(contactId) 108 | .select("ID") 109 | .read() 110 | .get(); 111 | 112 | //Update the contact first and last name 113 | updateContact.setSurname(lastNameString); 114 | updateContact.setGivenName(firstNameString); 115 | 116 | //push the updated contact to the server 117 | mOutlookClient 118 | .getMe() 119 | .getContacts() 120 | .getById(contactId) 121 | .update(updateContact).get(); 122 | } 123 | 124 | /** 125 | * Deletes a contact 126 | * 127 | * @param id The id of the contact to be deleted 128 | * @throws ExecutionException 129 | * @throws InterruptedException 130 | */ 131 | public void deleteContact(String id) throws ExecutionException, InterruptedException { 132 | mOutlookClient 133 | .getMe() 134 | .getContacts() 135 | .getById(id) 136 | .addHeader("If-Match", "*") 137 | .delete() 138 | .get(); 139 | 140 | } 141 | 142 | /** 143 | * Runs a filtered query to find all contacts with the given surname. This snippet can be 144 | * modified to run any filtered query. For a complete list of contact properties that 145 | * can be filtered, see https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesEvent 146 | * 147 | * @param surname The surname to match 148 | * @return A list of contacts matching the given surname 149 | * @throws ExecutionException 150 | * @throws InterruptedException 151 | */ 152 | public List getContactsWithSurname(String surname) throws ExecutionException, InterruptedException { 153 | return mOutlookClient 154 | .getMe() 155 | .getContacts() 156 | .select("surname") 157 | .filter("surname eq '" + surname + "'") 158 | .read() 159 | .get(); 160 | } 161 | 162 | } 163 | // ********************************************************* 164 | // 165 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 166 | // 167 | // Copyright (c) Microsoft Corporation 168 | // All rights reserved. 169 | // 170 | // MIT License: 171 | // Permission is hereby granted, free of charge, to any person obtaining 172 | // a copy of this software and associated documentation files (the 173 | // "Software"), to deal in the Software without restriction, including 174 | // without limitation the rights to use, copy, modify, merge, publish, 175 | // distribute, sublicense, and/or sell copies of the Software, and to 176 | // permit persons to whom the Software is furnished to do so, subject to 177 | // the following conditions: 178 | // 179 | // The above copyright notice and this permission notice shall be 180 | // included in all copies or substantial portions of the Software. 181 | // 182 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 183 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 184 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 185 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 186 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 187 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 188 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 189 | // 190 | // ********************************************************* 191 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Snippets/ODataSystemQuerySnippets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.Snippets; 5 | 6 | import com.microsoft.outlookservices.Event; 7 | import com.microsoft.outlookservices.Message; 8 | import com.microsoft.outlookservices.odata.OutlookClient; 9 | 10 | import java.util.List; 11 | import java.util.concurrent.ExecutionException; 12 | 13 | /** 14 | * This class contains snippets that demonstrate how to specify 15 | * OData system query options such as $select and $filter 16 | * through the Office 365 SDK for Android. 17 | */ 18 | public class ODataSystemQuerySnippets { 19 | 20 | /** 21 | * Demonstrates how to specify the $select OData system query option. 22 | * Gets a list of the 10 email messages selecting only the from, subject, 23 | * and isRead fields. Use the .select() method to specify a $select query 24 | * as shown in this snippet. 25 | *

26 | * For a complete list of types and properties that can be selected 27 | * see https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#OdataQueryParams 28 | * 29 | * @return List of type com.microsoft.outlookservices.Message 30 | */ 31 | public List getMailMessagesUsing$select(OutlookClient outlookClient) 32 | throws ExecutionException, InterruptedException { 33 | List messages = outlookClient 34 | .getMe() 35 | .getFolders() 36 | .getById("Inbox") 37 | .getMessages() 38 | .select("from,subject,isRead") 39 | .top(10) 40 | .read().get(); 41 | return messages; 42 | } 43 | 44 | /** 45 | * Demonstrates how to specify the $filter OData system query option. Runs a filtered 46 | * query to find all events that are high importance. Use the .filter() method 47 | * to specify a $filter query as shown in this snippet. 48 | *

49 | * For a complete list of types and properties that can be filtered 50 | * see https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#OdataQueryParams 51 | * 52 | * @param outlookClient - A client providing access to Office 365 Outlook APIs 53 | * @return A list of important events 54 | * @throws ExecutionException 55 | * @throws InterruptedException 56 | */ 57 | public List getImportantEventsUsing$filter(OutlookClient outlookClient) 58 | throws ExecutionException, InterruptedException { 59 | return outlookClient 60 | .getMe() 61 | .getEvents() 62 | .filter("Importance eq 'High'") 63 | .read() 64 | .get(); 65 | } 66 | 67 | } 68 | // ********************************************************* 69 | // 70 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 71 | // 72 | // Copyright (c) Microsoft Corporation 73 | // All rights reserved. 74 | // 75 | // MIT License: 76 | // Permission is hereby granted, free of charge, to any person obtaining 77 | // a copy of this software and associated documentation files (the 78 | // "Software"), to deal in the Software without restriction, including 79 | // without limitation the rights to use, copy, modify, merge, publish, 80 | // distribute, sublicense, and/or sell copies of the Software, and to 81 | // permit persons to whom the Software is furnished to do so, subject to 82 | // the following conditions: 83 | // 84 | // The above copyright notice and this permission notice shall be 85 | // included in all copies or substantial portions of the Software. 86 | // 87 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 88 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 89 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 90 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 91 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 92 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 93 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 94 | // 95 | // ********************************************************* 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/Snippets/UsersAndGroupsSnippets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.Snippets; 5 | 6 | import com.microsoft.directoryservices.Group; 7 | import com.microsoft.directoryservices.TenantDetail; 8 | import com.microsoft.directoryservices.User; 9 | import com.microsoft.directoryservices.odata.DirectoryClient; 10 | 11 | import java.util.List; 12 | import java.util.concurrent.ExecutionException; 13 | 14 | 15 | public class UsersAndGroupsSnippets { 16 | 17 | DirectoryClient mDirectoryClient; 18 | 19 | public UsersAndGroupsSnippets(DirectoryClient directoryClient) { 20 | mDirectoryClient = directoryClient; 21 | } 22 | 23 | /** 24 | * Return a list of users from Active Directory, sorted by display name.. 25 | * 26 | * @return List. A list of the com.microsoft.directoryservices.User objects. 27 | */ 28 | public List getUsers() throws ExecutionException, InterruptedException { 29 | return mDirectoryClient 30 | .getusers() 31 | .orderBy("displayName") 32 | .read() 33 | .get(); 34 | } 35 | 36 | /** 37 | * Return tenant details from Active Directory. 38 | * * 39 | * 40 | * @return TenantDetail. The com.microsoft.directoryservices.TenantDetail object for first tenant found. 41 | */ 42 | public TenantDetail getTenantDetails() throws ExecutionException, InterruptedException { 43 | List tenants = mDirectoryClient 44 | .gettenantDetails() 45 | .read() 46 | .get(); 47 | return tenants.get(0); 48 | } 49 | 50 | /** 51 | * Return a list of groups from Active Directory. 52 | * 53 | * @return List. A list of the com.microsoft.directoryservices.Group objects. 54 | */ 55 | public List getGroups() throws ExecutionException, InterruptedException { 56 | return mDirectoryClient 57 | .getgroups() 58 | .orderBy("displayName") 59 | .read() 60 | .get(); 61 | } 62 | 63 | } 64 | // ********************************************************* 65 | // 66 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 67 | // 68 | // Copyright (c) Microsoft Corporation 69 | // All rights reserved. 70 | // 71 | // MIT License: 72 | // Permission is hereby granted, free of charge, to any person obtaining 73 | // a copy of this software and associated documentation files (the 74 | // "Software"), to deal in the Software without restriction, including 75 | // without limitation the rights to use, copy, modify, merge, publish, 76 | // distribute, sublicense, and/or sell copies of the Software, and to 77 | // permit persons to whom the Software is furnished to do so, subject to 78 | // the following conditions: 79 | // 80 | // The above copyright notice and this permission notice shall be 81 | // included in all copies or substantial portions of the Software. 82 | // 83 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 84 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 85 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 86 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 87 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 88 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 89 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 90 | // 91 | // ********************************************************* 92 | 93 | 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/UserGroupStories/GetADGroupsStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.UserGroupStories; 5 | 6 | import com.microsoft.directoryservices.Group; 7 | import com.microsoft.directoryservices.odata.DirectoryClient; 8 | import com.microsoft.office365.snippetapp.Snippets.UsersAndGroupsSnippets; 9 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 10 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 11 | import com.microsoft.office365.snippetapp.helpers.Constants; 12 | import com.microsoft.office365.snippetapp.helpers.O365ServicesManager; 13 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 14 | 15 | import java.util.List; 16 | import java.util.concurrent.ExecutionException; 17 | 18 | public class GetADGroupsStory extends BaseUserStory { 19 | 20 | private static final String STORY_DESCRIPTION = "Gets groups from Active Directory"; 21 | 22 | @Override 23 | public String execute() { 24 | boolean isStoryComplete; 25 | StringBuilder resultMessage = new StringBuilder(); 26 | 27 | AuthenticationController 28 | .getInstance() 29 | .setResourceId(Constants.DIRECTORY_RESOURCE_ID); 30 | DirectoryClient directoryClient = O365ServicesManager.getDirectoryClient(); 31 | if (directoryClient == null) 32 | return StoryResultFormatter.wrapResult("Tenant ID was null", false); 33 | 34 | UsersAndGroupsSnippets usersAndGroupsSnippets = new UsersAndGroupsSnippets(directoryClient); 35 | 36 | try { 37 | //Get list of groups 38 | List groupList; 39 | groupList = usersAndGroupsSnippets.getGroups(); 40 | if (groupList == null) { 41 | //No groups were found 42 | resultMessage.append("Get Active Directory Groups: No groups found"); 43 | } else { 44 | resultMessage.append("Get Active Directory Groups: The following groups were found:\n"); 45 | for (Group group : groupList) { 46 | resultMessage.append(group.getdisplayName()) 47 | .append("\n"); 48 | } 49 | } 50 | isStoryComplete = true; 51 | } catch (ExecutionException | InterruptedException e) { 52 | return FormatException(e, STORY_DESCRIPTION); 53 | } 54 | return StoryResultFormatter.wrapResult(resultMessage.toString(), isStoryComplete); 55 | } 56 | 57 | @Override 58 | public String getDescription() { 59 | return STORY_DESCRIPTION; 60 | } 61 | } 62 | // ********************************************************* 63 | // 64 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 65 | // 66 | // Copyright (c) Microsoft Corporation 67 | // All rights reserved. 68 | // 69 | // MIT License: 70 | // Permission is hereby granted, free of charge, to any person obtaining 71 | // a copy of this software and associated documentation files (the 72 | // "Software"), to deal in the Software without restriction, including 73 | // without limitation the rights to use, copy, modify, merge, publish, 74 | // distribute, sublicense, and/or sell copies of the Software, and to 75 | // permit persons to whom the Software is furnished to do so, subject to 76 | // the following conditions: 77 | // 78 | // The above copyright notice and this permission notice shall be 79 | // included in all copies or substantial portions of the Software. 80 | // 81 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 82 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 83 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 84 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 85 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 86 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 87 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 88 | // 89 | // ********************************************************* 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/UserGroupStories/GetADUsersStory.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.office365.snippetapp.UserGroupStories; 2 | 3 | import com.microsoft.directoryservices.User; 4 | import com.microsoft.directoryservices.odata.DirectoryClient; 5 | import com.microsoft.office365.snippetapp.Snippets.UsersAndGroupsSnippets; 6 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 7 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 8 | import com.microsoft.office365.snippetapp.helpers.Constants; 9 | import com.microsoft.office365.snippetapp.helpers.O365ServicesManager; 10 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 11 | 12 | import java.util.List; 13 | import java.util.concurrent.ExecutionException; 14 | 15 | public class GetADUsersStory extends BaseUserStory { 16 | 17 | private static final String STORY_DESCRIPTION = "Gets users from Active Directory"; 18 | 19 | @Override 20 | public String execute() { 21 | boolean isStoryComplete; 22 | StringBuilder resultMessage = new StringBuilder(); 23 | 24 | AuthenticationController 25 | .getInstance() 26 | .setResourceId(Constants.DIRECTORY_RESOURCE_ID); 27 | DirectoryClient directoryClient = O365ServicesManager.getDirectoryClient(); 28 | if (directoryClient == null) 29 | return StoryResultFormatter.wrapResult("Tenant ID was null", false); 30 | UsersAndGroupsSnippets usersAndGroupsSnippets = new UsersAndGroupsSnippets(directoryClient); 31 | 32 | try { 33 | //Get list of users 34 | List userList = usersAndGroupsSnippets.getUsers(); 35 | if (userList == null) { 36 | //No users were found 37 | resultMessage.append(STORY_DESCRIPTION); 38 | resultMessage.append(": No users found."); 39 | } else { 40 | resultMessage.append(STORY_DESCRIPTION); 41 | resultMessage.append(": The following users were found:\n"); 42 | for (User user : userList) { 43 | resultMessage.append(user.getdisplayName()) 44 | .append("\n"); 45 | } 46 | } 47 | isStoryComplete = true; 48 | } catch (ExecutionException | InterruptedException e) { 49 | return FormatException(e, STORY_DESCRIPTION); 50 | } 51 | return StoryResultFormatter.wrapResult(resultMessage.toString(), isStoryComplete); 52 | } 53 | 54 | @Override 55 | public String getDescription() { 56 | return STORY_DESCRIPTION; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/UserGroupStories/GetTenantDetailsStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.UserGroupStories; 5 | 6 | import com.microsoft.directoryservices.TenantDetail; 7 | import com.microsoft.directoryservices.odata.DirectoryClient; 8 | import com.microsoft.office365.snippetapp.Snippets.UsersAndGroupsSnippets; 9 | import com.microsoft.office365.snippetapp.helpers.AuthenticationController; 10 | import com.microsoft.office365.snippetapp.helpers.BaseUserStory; 11 | import com.microsoft.office365.snippetapp.helpers.Constants; 12 | import com.microsoft.office365.snippetapp.helpers.O365ServicesManager; 13 | import com.microsoft.office365.snippetapp.helpers.StoryResultFormatter; 14 | 15 | import java.util.concurrent.ExecutionException; 16 | 17 | public class GetTenantDetailsStory extends BaseUserStory { 18 | 19 | private static final String STORY_DESCRIPTION = "Gets the tenant details from Active Directory"; 20 | 21 | @Override 22 | public String execute() { 23 | StringBuilder results = new StringBuilder(); 24 | AuthenticationController 25 | .getInstance() 26 | .setResourceId(Constants.DIRECTORY_RESOURCE_ID); 27 | DirectoryClient directoryClient = O365ServicesManager.getDirectoryClient(); 28 | if (directoryClient == null) 29 | return StoryResultFormatter.wrapResult("Tenant ID was null", false); 30 | 31 | UsersAndGroupsSnippets usersAndGroupsSnippets = new UsersAndGroupsSnippets(directoryClient); 32 | TenantDetail tenant; 33 | try { 34 | tenant = usersAndGroupsSnippets.getTenantDetails(); 35 | } catch (ExecutionException | InterruptedException e) { 36 | return FormatException(e, STORY_DESCRIPTION); 37 | } 38 | 39 | if (tenant == null) { 40 | //No tenants were found 41 | return StoryResultFormatter.wrapResult(STORY_DESCRIPTION + ": No tenant found", false); 42 | } 43 | results.append(STORY_DESCRIPTION); 44 | results.append(": The following tenant was found:\n"); 45 | results.append(tenant.getdisplayName()) 46 | .append("\n"); 47 | return StoryResultFormatter.wrapResult(results.toString(), true); 48 | } 49 | 50 | @Override 51 | public String getDescription() { 52 | return STORY_DESCRIPTION; 53 | } 54 | } 55 | // ********************************************************* 56 | // 57 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 58 | // 59 | // Copyright (c) Microsoft Corporation 60 | // All rights reserved. 61 | // 62 | // MIT License: 63 | // Permission is hereby granted, free of charge, to any person obtaining 64 | // a copy of this software and associated documentation files (the 65 | // "Software"), to deal in the Software without restriction, including 66 | // without limitation the rights to use, copy, modify, merge, publish, 67 | // distribute, sublicense, and/or sell copies of the Software, and to 68 | // permit persons to whom the Software is furnished to do so, subject to 69 | // the following conditions: 70 | // 71 | // The above copyright notice and this permission notice shall be 72 | // included in all copies or substantial portions of the Software. 73 | // 74 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 75 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 76 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 77 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 78 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 79 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 80 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 81 | // 82 | // ********************************************************* 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/APIErrorMessageHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.helpers; 6 | 7 | import org.json.JSONException; 8 | import org.json.JSONObject; 9 | 10 | public class APIErrorMessageHelper { 11 | // Takes the string returned from Outlook service in the 12 | // onFailure event, parses for the JSON object, and gets 13 | // the actual error message. 14 | public static String getErrorMessage(String result) { 15 | String errorMessage; 16 | try { 17 | 18 | // Gets the JSON object out of the result string. 19 | String responseJSON = result 20 | .substring(result.indexOf("{"), result.length()); 21 | 22 | JSONObject jObject = new JSONObject(responseJSON); 23 | JSONObject error = (JSONObject) jObject.get("error"); 24 | errorMessage = error.getString("message"); 25 | 26 | } catch (JSONException e) { 27 | e.printStackTrace(); 28 | errorMessage = result; 29 | } catch (Exception ex) { 30 | ex.printStackTrace(); 31 | errorMessage = result; 32 | } 33 | return errorMessage; 34 | } 35 | 36 | } 37 | // ********************************************************* 38 | // 39 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 40 | // 41 | // Copyright (c) Microsoft Corporation 42 | // All rights reserved. 43 | // 44 | // MIT License: 45 | // Permission is hereby granted, free of charge, to any person obtaining 46 | // a copy of this software and associated documentation files (the 47 | // "Software"), to deal in the Software without restriction, including 48 | // without limitation the rights to use, copy, modify, merge, publish, 49 | // distribute, sublicense, and/or sell copies of the Software, and to 50 | // permit persons to whom the Software is furnished to do so, subject to 51 | // the following conditions: 52 | // 53 | // The above copyright notice and this permission notice shall be 54 | // included in all copies or substantial portions of the Software. 55 | // 56 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 57 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 58 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 59 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 60 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 61 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 62 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 63 | // 64 | // ********************************************************* 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/AsyncUseCaseWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | import android.os.AsyncTask; 7 | 8 | import com.microsoft.office365.snippetapp.Interfaces.IOperationCompleteListener; 9 | 10 | public class AsyncUseCaseWrapper extends AsyncTask { 11 | 12 | private final IOperationCompleteListener mOperationCompletedListener; 13 | 14 | 15 | public AsyncUseCaseWrapper(IOperationCompleteListener operationCompleteListener) { 16 | mOperationCompletedListener = operationCompleteListener; 17 | } 18 | 19 | @Override 20 | protected Void doInBackground(BaseUserStory... params) { 21 | String result; 22 | for (BaseUserStory useCase : params) { 23 | useCase.onPreExecute(); 24 | result = useCase.execute(); 25 | useCase.onPostExecute(); 26 | publishProgress(new IOperationCompleteListener.OperationResult("O365 operation", 27 | result)); 28 | } 29 | return null; 30 | } 31 | 32 | @Override 33 | protected void onProgressUpdate(IOperationCompleteListener.OperationResult... values) { 34 | if (null != mOperationCompletedListener) { 35 | for (IOperationCompleteListener.OperationResult result : values) { 36 | mOperationCompletedListener.onOperationComplete(result); 37 | } 38 | } 39 | } 40 | } 41 | // ********************************************************* 42 | // 43 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 44 | // 45 | // Copyright (c) Microsoft Corporation 46 | // All rights reserved. 47 | // 48 | // MIT License: 49 | // Permission is hereby granted, free of charge, to any person obtaining 50 | // a copy of this software and associated documentation files (the 51 | // "Software"), to deal in the Software without restriction, including 52 | // without limitation the rights to use, copy, modify, merge, publish, 53 | // distribute, sublicense, and/or sell copies of the Software, and to 54 | // permit persons to whom the Software is furnished to do so, subject to 55 | // the following conditions: 56 | // 57 | // The above copyright notice and this permission notice shall be 58 | // included in all copies or substantial portions of the Software. 59 | // 60 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 61 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 62 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 63 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 64 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 65 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 66 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 67 | // 68 | // ********************************************************* 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/AuthUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | 5 | package com.microsoft.office365.snippetapp.helpers; 6 | 7 | import android.os.Build; 8 | import android.provider.Settings; 9 | import android.util.Log; 10 | 11 | import com.microsoft.aad.adal.AuthenticationSettings; 12 | import com.microsoft.office365.snippetapp.OperationListActivity; 13 | 14 | import java.io.UnsupportedEncodingException; 15 | 16 | public class AuthUtil { 17 | private static final String TAG = "AuthUtil"; 18 | public static final int MIN_VERSION_CODE_FOR_ENCRYPT = Build.VERSION_CODES.JELLY_BEAN_MR2; 19 | 20 | public static void configureAuthSettings(OperationListActivity activity) { 21 | // Devices with API level lower than 18 must setup an encryption key. 22 | if (Build.VERSION.SDK_INT < MIN_VERSION_CODE_FOR_ENCRYPT && AuthenticationSettings.INSTANCE.getSecretKeyData() == null) { 23 | AuthenticationSettings.INSTANCE.setSecretKey(generateSecretKey()); 24 | } 25 | 26 | // We're not using Microsoft Intune's Company portal app, 27 | // skip the broker check so we don't get warnings about the following permissions 28 | // in manifest: 29 | // GET_ACCOUNTS 30 | // USE_CREDENTIALS 31 | // MANAGE_ACCOUNTS 32 | AuthenticationSettings.INSTANCE.setSkipBroker(true); 33 | } 34 | 35 | /** 36 | * Generates an encryption key for devices with API level lower than 18 using the 37 | * ANDROID_ID value as a seed. 38 | * In production scenarios, you should come up with your own implementation of this method. 39 | * Consider that your algorithm must return the same key so it can encrypt/decrypt values 40 | * successfully. 41 | * 42 | * @return The encryption key in a 32 byte long array. 43 | */ 44 | private static byte[] generateSecretKey() { 45 | byte[] key = new byte[32]; 46 | byte[] android_id = null; 47 | 48 | try { 49 | android_id = Settings.Secure.ANDROID_ID.getBytes("UTF-8"); 50 | } catch (UnsupportedEncodingException e) { 51 | Log.e(TAG, "generateSecretKey - " + e.getMessage()); 52 | } 53 | 54 | for (int i = 0; i < key.length; i++) { 55 | key[i] = android_id[i % android_id.length]; 56 | } 57 | 58 | return key; 59 | } 60 | } 61 | // ********************************************************* 62 | // 63 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 64 | // 65 | // Copyright (c) Microsoft Corporation 66 | // All rights reserved. 67 | // 68 | // MIT License: 69 | // Permission is hereby granted, free of charge, to any person obtaining 70 | // a copy of this software and associated documentation files (the 71 | // "Software"), to deal in the Software without restriction, including 72 | // without limitation the rights to use, copy, modify, merge, publish, 73 | // distribute, sublicense, and/or sell copies of the Software, and to 74 | // permit persons to whom the Software is furnished to do so, subject to 75 | // the following conditions: 76 | // 77 | // The above copyright notice and this permission notice shall be 78 | // included in all copies or substantial portions of the Software. 79 | // 80 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 81 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 82 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 83 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 84 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 85 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 86 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 87 | // 88 | // ********************************************************* 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/BaseUserStory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | 7 | import android.content.res.AssetFileDescriptor; 8 | import android.util.Log; 9 | import android.view.View; 10 | 11 | import com.microsoft.fileservices.odata.SharePointClient; 12 | import com.microsoft.office365.snippetapp.AndroidSnippetsApplication; 13 | import com.microsoft.office365.snippetapp.Interfaces.OnUseCaseStatusChangedListener; 14 | import com.microsoft.outlookservices.odata.OutlookClient; 15 | 16 | import java.io.ByteArrayOutputStream; 17 | import java.io.FileInputStream; 18 | import java.io.IOException; 19 | 20 | public abstract class BaseUserStory { 21 | 22 | private boolean mIsExecuting = false; 23 | private View mUpdateView; 24 | private OutlookClient mO365MailClient; 25 | private SharePointClient mO365MyFilesClient; 26 | private String mMailResourceId; 27 | private OnUseCaseStatusChangedListener mUseCaseStatusChangedListener; 28 | private String mFilesFoldersResourceId; 29 | boolean mGroupingFlag = false; 30 | 31 | public String getFilesFoldersResourceId() { 32 | return mFilesFoldersResourceId; 33 | } 34 | 35 | public void setFilesFoldersResourceId(String filesFoldersResourceId) { 36 | this.mFilesFoldersResourceId = filesFoldersResourceId; 37 | } 38 | 39 | public void setUseCaseStatusChangedListener(OnUseCaseStatusChangedListener listener) { 40 | mUseCaseStatusChangedListener = listener; 41 | } 42 | 43 | protected abstract String execute(); 44 | 45 | public abstract String getDescription(); 46 | 47 | 48 | public boolean getGroupingFlag() { 49 | return mGroupingFlag; 50 | } 51 | 52 | public void setGroupingFlag(boolean groupingFlag) { 53 | mGroupingFlag = groupingFlag; 54 | } 55 | 56 | protected String getId() { 57 | return java.util.UUID.randomUUID().toString(); 58 | } 59 | 60 | protected String getStringResource(int resourceToGet) { 61 | return AndroidSnippetsApplication 62 | .getApplication() 63 | .getApplicationContext() 64 | .getString(resourceToGet); 65 | } 66 | 67 | protected String FormatException(Exception exception, String storyDescription) { 68 | exception.printStackTrace(); 69 | String formattedException = APIErrorMessageHelper.getErrorMessage(exception.getMessage()); 70 | Log.e(storyDescription, formattedException); 71 | return StoryResultFormatter.wrapResult( 72 | storyDescription + ": " 73 | + formattedException 74 | , false 75 | ); 76 | 77 | } 78 | 79 | public byte[] getDrawableResource(int resourceToGet) { 80 | 81 | //Get the photo from the resource/drawable folder as a raw image 82 | final AssetFileDescriptor raw = AndroidSnippetsApplication 83 | .getApplication() 84 | .getApplicationContext() 85 | .getResources() 86 | .openRawResourceFd(resourceToGet); 87 | 88 | //Load raw image into a buffer 89 | final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 90 | try { 91 | final FileInputStream is = raw.createInputStream(); 92 | int nRead; 93 | 94 | //Read 16kb at a time 95 | final byte[] data = new byte[16384]; 96 | 97 | while ((nRead = is.read(data, 0, data.length)) != -1) { 98 | buffer.write(data, 0, nRead); 99 | } 100 | 101 | buffer.flush(); 102 | 103 | } catch (IOException e) { 104 | e.printStackTrace(); 105 | } 106 | return buffer.toByteArray(); 107 | 108 | } 109 | 110 | public View getUIResultView() { 111 | return mUpdateView; 112 | } 113 | 114 | public void setUIResultView(View view) { 115 | mUpdateView = view; 116 | } 117 | 118 | public String getO365MailResourceId() { 119 | return mMailResourceId; 120 | } 121 | 122 | public void setO365MailResourceId(String resourceId) { 123 | mMailResourceId = resourceId; 124 | } 125 | 126 | public OutlookClient getO365MailClient() { 127 | AuthenticationController 128 | .getInstance() 129 | .setResourceId( 130 | this.getO365MailResourceId()); 131 | 132 | return mO365MailClient; 133 | } 134 | 135 | public void setO365MailClient(OutlookClient client) { 136 | 137 | mO365MailClient = client; 138 | } 139 | 140 | public SharePointClient getO365MyFilesClient() { 141 | return mO365MyFilesClient; 142 | } 143 | 144 | public void setO365MyFilesClient(SharePointClient client) { 145 | mO365MyFilesClient = client; 146 | } 147 | 148 | private void notifyStatusChange() { 149 | if (null != mUseCaseStatusChangedListener) { 150 | mUseCaseStatusChangedListener.onUseCaseStatusChanged(); 151 | } 152 | } 153 | 154 | public final void onPreExecute() { 155 | mIsExecuting = true; 156 | notifyStatusChange(); 157 | } 158 | 159 | public final void onPostExecute() { 160 | mIsExecuting = false; 161 | notifyStatusChange(); 162 | } 163 | 164 | public final boolean isExecuting() { 165 | return mIsExecuting; 166 | } 167 | 168 | @Override 169 | public String toString() { 170 | return this.getDescription(); 171 | } 172 | 173 | 174 | } 175 | // ********************************************************* 176 | // 177 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 178 | // 179 | // Copyright (c) Microsoft Corporation 180 | // All rights reserved. 181 | // 182 | // MIT License: 183 | // Permission is hereby granted, free of charge, to any person obtaining 184 | // a copy of this software and associated documentation files (the 185 | // "Software"), to deal in the Software without restriction, including 186 | // without limitation the rights to use, copy, modify, merge, publish, 187 | // distribute, sublicense, and/or sell copies of the Software, and to 188 | // permit persons to whom the Software is furnished to do so, subject to 189 | // the following conditions: 190 | // 191 | // The above copyright notice and this permission notice shall be 192 | // included in all copies or substantial portions of the Software. 193 | // 194 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 195 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 196 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 197 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 198 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 199 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 200 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 201 | // 202 | // ********************************************************* 203 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | public interface Constants { 7 | public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common"; 8 | public static final String DISCOVERY_RESOURCE_URL = "https://api.office.com/discovery/v1.0/me/"; 9 | public static final String DISCOVERY_RESOURCE_ID = "https://api.office.com/discovery/"; 10 | public static final String DIRECTORY_RESOURCE_URL = "https://graph.windows.net/"; 11 | public static final String DIRECTORY_RESOURCE_ID = "https://graph.windows.net/"; 12 | public static final String DIRECTORY_API_VERSION = "api-version=1.5"; 13 | public static final String MAIL_CAPABILITY = "Mail"; 14 | public static final String MYFILES_CAPABILITY = "MyFiles"; 15 | public static final String CALENDAR_CAPABILITY = "Calendar"; 16 | public static final String CONTACTS_CAPABILITY = "Contacts"; 17 | 18 | // Update these two constants with the values for your application: 19 | public static final String CLIENT_ID = ""; 20 | public static final String REDIRECT_URI = ""; 21 | 22 | } 23 | 24 | // ********************************************************* 25 | // 26 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 27 | // 28 | // Copyright (c) Microsoft Corporation 29 | // All rights reserved. 30 | // 31 | // MIT License: 32 | // Permission is hereby granted, free of charge, to any person obtaining 33 | // a copy of this software and associated documentation files (the 34 | // "Software"), to deal in the Software without restriction, including 35 | // without limitation the rights to use, copy, modify, merge, publish, 36 | // distribute, sublicense, and/or sell copies of the Software, and to 37 | // permit persons to whom the Software is furnished to do so, subject to 38 | // the following conditions: 39 | // 40 | // The above copyright notice and this permission notice shall be 41 | // included in all copies or substantial portions of the Software. 42 | // 43 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 44 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 45 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 46 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 47 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 48 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 49 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 50 | // 51 | // ********************************************************* 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/GlobalValues.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | public class GlobalValues { 7 | public static String USER_EMAIL; 8 | public static String USER_NAME; 9 | } 10 | // ********************************************************* 11 | // 12 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 13 | // 14 | // Copyright (c) Microsoft Corporation 15 | // All rights reserved. 16 | // 17 | // MIT License: 18 | // Permission is hereby granted, free of charge, to any person obtaining 19 | // a copy of this software and associated documentation files (the 20 | // "Software"), to deal in the Software without restriction, including 21 | // without limitation the rights to use, copy, modify, merge, publish, 22 | // distribute, sublicense, and/or sell copies of the Software, and to 23 | // permit persons to whom the Software is furnished to do so, subject to 24 | // the following conditions: 25 | // 26 | // The above copyright notice and this permission notice shall be 27 | // included in all copies or substantial portions of the Software. 28 | // 29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 32 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 33 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 34 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 35 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | // 37 | // ********************************************************* 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/O365ServicesManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | import com.microsoft.directoryservices.odata.DirectoryClient; 7 | import com.microsoft.services.odata.interfaces.DependencyResolver; 8 | 9 | public class O365ServicesManager { 10 | static DirectoryClient mDirectoryClient = null; 11 | static String mTenantId = null; 12 | 13 | public static void initialize(String tenantId) { 14 | mTenantId = tenantId; 15 | } 16 | 17 | public static DirectoryClient getDirectoryClient() { 18 | if (mDirectoryClient == null && mTenantId != null) { 19 | DependencyResolver dependencyResolver = AuthenticationController.getInstance().getDependencyResolver(); 20 | StringBuilder endpoint = new StringBuilder(); 21 | endpoint.append(Constants.DIRECTORY_RESOURCE_URL) 22 | .append(mTenantId) 23 | .append("?") 24 | .append(Constants.DIRECTORY_API_VERSION); 25 | mDirectoryClient = new DirectoryClient(endpoint.toString(), dependencyResolver); 26 | } 27 | return mDirectoryClient; 28 | } 29 | } 30 | // ********************************************************* 31 | // 32 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 33 | // 34 | // Copyright (c) Microsoft Corporation 35 | // All rights reserved. 36 | // 37 | // MIT License: 38 | // Permission is hereby granted, free of charge, to any person obtaining 39 | // a copy of this software and associated documentation files (the 40 | // "Software"), to deal in the Software without restriction, including 41 | // without limitation the rights to use, copy, modify, merge, publish, 42 | // distribute, sublicense, and/or sell copies of the Software, and to 43 | // permit persons to whom the Software is furnished to do so, subject to 44 | // the following conditions: 45 | // 46 | // The above copyright notice and this permission notice shall be 47 | // included in all copies or substantial portions of the Software. 48 | // 49 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 50 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 51 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 52 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 53 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 54 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 55 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 56 | // 57 | // ********************************************************* 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/StoryAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | //Defines which action a story should take when called by StoryList, when a story can 7 | //perform both a create, and delete action. 8 | public enum StoryAction { 9 | CREATE, DELETE 10 | } 11 | // ********************************************************* 12 | // 13 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 14 | // 15 | // Copyright (c) Microsoft Corporation 16 | // All rights reserved. 17 | // 18 | // MIT License: 19 | // Permission is hereby granted, free of charge, to any person obtaining 20 | // a copy of this software and associated documentation files (the 21 | // "Software"), to deal in the Software without restriction, including 22 | // without limitation the rights to use, copy, modify, merge, publish, 23 | // distribute, sublicense, and/or sell copies of the Software, and to 24 | // permit persons to whom the Software is furnished to do so, subject to 25 | // the following conditions: 26 | // 27 | // The above copyright notice and this permission notice shall be 28 | // included in all copies or substantial portions of the Software. 29 | // 30 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 31 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 32 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 33 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 34 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 35 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 36 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | // 38 | // ********************************************************* 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/StoryGroupPlaceholder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | /** 7 | * Represents a placeholder in the UI snippet list to separate groups of 8 | * snippets visually. For example, this class could represent the 9 | * "Mail" group of snippets. 10 | */ 11 | public class StoryGroupPlaceholder extends BaseUserStory { 12 | 13 | private String mDescription; 14 | 15 | private StoryGroupPlaceholder() { 16 | //Mark this story as a story group list item for UI list 17 | setGroupingFlag(true); 18 | } 19 | 20 | public StoryGroupPlaceholder(String description) { 21 | this(); 22 | mDescription = description; 23 | } 24 | 25 | @Override 26 | public String execute() { 27 | return ""; 28 | } 29 | 30 | @Override 31 | public String getDescription() { 32 | return mDescription; 33 | } 34 | } 35 | // ********************************************************* 36 | // 37 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 38 | // 39 | // Copyright (c) Microsoft Corporation 40 | // All rights reserved. 41 | // 42 | // MIT License: 43 | // Permission is hereby granted, free of charge, to any person obtaining 44 | // a copy of this software and associated documentation files (the 45 | // "Software"), to deal in the Software without restriction, including 46 | // without limitation the rights to use, copy, modify, merge, publish, 47 | // distribute, sublicense, and/or sell copies of the Software, and to 48 | // permit persons to whom the Software is furnished to do so, subject to 49 | // the following conditions: 50 | // 51 | // The above copyright notice and this permission notice shall be 52 | // included in all copies or substantial portions of the Software. 53 | // 54 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 55 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 56 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 57 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 58 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 59 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 60 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 61 | // 62 | // ********************************************************* 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/StoryList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | import android.content.Context; 7 | 8 | import com.microsoft.office365.snippetapp.CalendarStories.CreateOrDeleteEventStory; 9 | import com.microsoft.office365.snippetapp.CalendarStories.CreateRecurringEventStory; 10 | import com.microsoft.office365.snippetapp.CalendarStories.EventsFetcherStory; 11 | import com.microsoft.office365.snippetapp.CalendarStories.RespondToCalendarEventInviteStory; 12 | import com.microsoft.office365.snippetapp.CalendarStories.UpdateEventStory; 13 | import com.microsoft.office365.snippetapp.ContactStories.CreateOrDeleteContactStory; 14 | import com.microsoft.office365.snippetapp.ContactStories.GetContactsStory; 15 | import com.microsoft.office365.snippetapp.ContactStories.GetFilteredContactsWithSurnameStory; 16 | import com.microsoft.office365.snippetapp.ContactStories.UpdateContactStory; 17 | import com.microsoft.office365.snippetapp.EmailStories.DeleteEmailAttachmentStory; 18 | import com.microsoft.office365.snippetapp.EmailStories.ForwardEmailMessageStory; 19 | import com.microsoft.office365.snippetapp.EmailStories.GetEmailAttachmentsStory; 20 | import com.microsoft.office365.snippetapp.EmailStories.GetEmailMessagesStory; 21 | import com.microsoft.office365.snippetapp.EmailStories.ReplyToEmailMessageStory; 22 | import com.microsoft.office365.snippetapp.EmailStories.SendEmailMessageStory; 23 | import com.microsoft.office365.snippetapp.EmailStories.SendEmailWithMessageAttachStory; 24 | import com.microsoft.office365.snippetapp.EmailStories.SendEmailWithTextFileAttachmentStory; 25 | import com.microsoft.office365.snippetapp.FileFolderStories.CreateOrDeleteFileStory; 26 | import com.microsoft.office365.snippetapp.FileFolderStories.CreateOrDeleteOneDriveFolder; 27 | import com.microsoft.office365.snippetapp.FileFolderStories.DownloadFileStory; 28 | import com.microsoft.office365.snippetapp.FileFolderStories.GetFilesAndFoldersStory; 29 | import com.microsoft.office365.snippetapp.FileFolderStories.UpdateFileContentsOnServerStory; 30 | import com.microsoft.office365.snippetapp.ODataStories.ODataFilterStory; 31 | import com.microsoft.office365.snippetapp.ODataStories.ODataSelectStory; 32 | import com.microsoft.office365.snippetapp.R; 33 | import com.microsoft.office365.snippetapp.UserGroupStories.GetADGroupsStory; 34 | import com.microsoft.office365.snippetapp.UserGroupStories.GetADUsersStory; 35 | import com.microsoft.office365.snippetapp.UserGroupStories.GetTenantDetailsStory; 36 | 37 | import java.util.ArrayList; 38 | import java.util.Arrays; 39 | import java.util.HashMap; 40 | import java.util.List; 41 | import java.util.Map; 42 | 43 | public class StoryList { 44 | /** 45 | * An array of story scenarios. 46 | */ 47 | static final Map ITEM_MAP = new HashMap<>(); 48 | /** 49 | * A map of story scenarios, by ID. 50 | */ 51 | public List ITEMS = new ArrayList<>(); 52 | 53 | /* 54 | * Add stories to the public story list and story map. 55 | */ 56 | public StoryList(Context context) { 57 | List baseUserStories = Arrays.asList( 58 | //OData system query option stories 59 | new StoryGroupPlaceholder("OData system query stories"), 60 | new ODataSelectStory(), 61 | new ODataFilterStory(), 62 | 63 | //Active Directory Stories 64 | new StoryGroupPlaceholder(context.getString(R.string.active_directory_group_placeholder)), 65 | new GetADUsersStory(), 66 | new GetTenantDetailsStory(), 67 | new GetADGroupsStory(), 68 | 69 | //Email Stories 70 | new StoryGroupPlaceholder(context.getString(R.string.email_group_placeholder)), 71 | new SendEmailMessageStory(), 72 | new GetEmailMessagesStory(), 73 | new ReplyToEmailMessageStory(), 74 | new ForwardEmailMessageStory(), 75 | new SendEmailWithTextFileAttachmentStory(), 76 | new SendEmailWithMessageAttachStory(), 77 | new GetEmailAttachmentsStory(), 78 | new DeleteEmailAttachmentStory(), 79 | 80 | //Contact Stories 81 | new StoryGroupPlaceholder(context.getString(R.string.contact_group_placeholder)), 82 | new GetContactsStory(), 83 | new CreateOrDeleteContactStory(StoryAction.CREATE), 84 | new CreateOrDeleteContactStory(StoryAction.DELETE), 85 | new UpdateContactStory(context), 86 | new GetFilteredContactsWithSurnameStory(), 87 | 88 | //Calendar Stories 89 | new StoryGroupPlaceholder(context.getString(R.string.calendar_group_placeholder)), 90 | new CreateOrDeleteEventStory(StoryAction.CREATE), 91 | new CreateOrDeleteEventStory(StoryAction.DELETE), 92 | new EventsFetcherStory(), 93 | new UpdateEventStory(), 94 | new RespondToCalendarEventInviteStory(), 95 | new CreateRecurringEventStory(), 96 | 97 | //Files and Folders Stories 98 | new StoryGroupPlaceholder(context.getString(R.string.file_folder_group_placeholder)), 99 | new GetFilesAndFoldersStory(), 100 | new CreateOrDeleteFileStory(StoryAction.CREATE), 101 | new UpdateFileContentsOnServerStory(), 102 | new CreateOrDeleteFileStory(StoryAction.DELETE), 103 | new DownloadFileStory(), 104 | new CreateOrDeleteOneDriveFolder(StoryAction.CREATE), 105 | new CreateOrDeleteOneDriveFolder(StoryAction.DELETE) 106 | ); 107 | for (BaseUserStory object : baseUserStories) { 108 | ITEM_MAP.put(object.getId(), object); 109 | } 110 | ITEMS = baseUserStories; 111 | } 112 | } 113 | // ********************************************************* 114 | // 115 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 116 | // 117 | // Copyright (c) Microsoft Corporation 118 | // All rights reserved. 119 | // 120 | // MIT License: 121 | // Permission is hereby granted, free of charge, to any person obtaining 122 | // a copy of this software and associated documentation files (the 123 | // "Software"), to deal in the Software without restriction, including 124 | // without limitation the rights to use, copy, modify, merge, publish, 125 | // distribute, sublicense, and/or sell copies of the Software, and to 126 | // permit persons to whom the Software is furnished to do so, subject to 127 | // the following conditions: 128 | // 129 | // The above copyright notice and this permission notice shall be 130 | // included in all copies or substantial portions of the Software. 131 | // 132 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 133 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 134 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 135 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 136 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 137 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 138 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 139 | // 140 | // ********************************************************* 141 | -------------------------------------------------------------------------------- /app/src/main/java/com/microsoft/office365/snippetapp/helpers/StoryResultFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 3 | */ 4 | package com.microsoft.office365.snippetapp.helpers; 5 | 6 | public class StoryResultFormatter { 7 | public static String wrapResult(String result, boolean passed) { 8 | String passfail = "FAILED: "; 9 | if (passed) { 10 | passfail = "PASSED: "; 11 | } 12 | return passfail + result + "\n------------------------------------------------------------------\n"; 13 | } 14 | } 15 | // ********************************************************* 16 | // 17 | // O365-Android-Snippets, https://github.com/OfficeDev/O365-Android-Snippets 18 | // 19 | // Copyright (c) Microsoft Corporation 20 | // All rights reserved. 21 | // 22 | // MIT License: 23 | // Permission is hereby granted, free of charge, to any person obtaining 24 | // a copy of this software and associated documentation files (the 25 | // "Software"), to deal in the Software without restriction, including 26 | // without limitation the rights to use, copy, modify, merge, publish, 27 | // distribute, sublicense, and/or sell copies of the Software, and to 28 | // permit persons to whom the Software is furnished to do so, subject to 29 | // the following conditions: 30 | // 31 | // The above copyright notice and this permission notice shall be 32 | // included in all copies or substantial portions of the Software. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 35 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 36 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 37 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 38 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 39 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 40 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 41 | // 42 | // ********************************************************* 43 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_action_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/ic_action_refresh.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/runall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/runall.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/store_logo_scale_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/store_logo_scale_100.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/user_signedout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/user_signedout.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/yellowtulip.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/drawable/yellowtulip.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_operation_detail.xml: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_operation_list.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 17 | 18 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_operation_detail.xml: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_grouper.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_task.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 22 | 23 | 24 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 |

3 | 4 | 9 | 16 | 24 | 25 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_action_editor_format_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-hdpi/ic_action_editor_format_paint.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/runall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-hdpi/runall.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/store_logo_scale_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-hdpi/store_logo_scale_100.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_action_editor_format_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-mdpi/ic_action_editor_format_paint.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/runall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-mdpi/runall.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/store_logo_scale_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-mdpi/store_logo_scale_100.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_action_editor_format_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xhdpi/ic_action_editor_format_paint.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/store_logo_scale_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xhdpi/store_logo_scale_100.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_action_editor_format_paint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xxhdpi/ic_action_editor_format_paint.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/store_logo_scale_100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/app/src/main/res/mipmap-xxhdpi/store_logo_scale_100.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Office 365 Snippets 3 | Operation Detail 4 | 5 | 6 | Connect to Office 365 7 | Disconnect 8 | 9 | 10 | Connected to Office 365 11 | Connected to service 12 | Mail sent 13 | Disconnected from Office 365 14 | 15 | 16 | Oops! 17 | \nSorry, can\'t connect to Office 365.\nHint: Check logcat for details. 18 | \nSorry, can\'t find the mail service.\nHint: Check logcat for details. 19 | \nSorry, can\'t send the email.\nHint: Check logcat for details. 20 | 21 | 22 | Error setting up encryption key\nCheck logcat for details 23 | Error connecting to Office 365\nCheck logcat for details 24 | Error finding mail service\nCheck logcat for details 25 | Error sending email\nCheck logcat for details 26 | The client ID or redirect URI is not valid. Enter a valid client ID and redirect URI in the Constants.java file and run again 27 | 28 | 29 | zoec@contoso.com 30 | 5555551212 31 | 5555552121 32 | Zoe 33 | Curtis 34 | 35 | 36 | O365 Android Snippets sample email 37 | 38 | <html> 39 | <head> 40 | <title></title> 41 | </head> 42 | <body> 43 | <p> 44 | This message was sent by the <a href=\'https://github.com/OfficeDev/O365-Android-Snippets\' >Office 365 Android Snippets sample</a> 45 | </p> 46 | </body> 47 | </html> 48 | 49 | 50 | <html> 51 | <head> 52 | <title></title> 53 | </head> 54 | <body> 55 | <p> 56 | This text file attachment was generated by the <a href=\'https://github.com/OfficeDev/O365-Android-Snippets\' >Office 365 Android Snippets sample</a> 57 | </p> 58 | </body> 59 | </html> 60 | 61 | "attachment.txt" 62 | Connect 63 | Disconnect 64 | Clear tokens 65 | Run all 66 | 67 | 68 | O365 Android Snippets sample event 69 | 70 | <html> 71 | <head> 72 | <title></title> 73 | </head> 74 | <body> 75 | <p> 76 | This event was created by the <a href=\'https://github.com/OfficeDev/O365-Android-Snippets\' >Office 365 Android Snippets sample</a> 77 | </p> 78 | </body> 79 | </html> 80 | 81 | Clear results 82 | Accepted 83 | Declined 84 | Tentative 85 | Inbox 86 | Sent Items 87 | Drafts 88 | File and Folder stories 89 | Calendar stories 90 | Contact stories 91 | Email stories 92 | Active Directory stories 93 | 94 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /readme-images/constants_Modify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/readme-images/constants_Modify.png -------------------------------------------------------------------------------- /readme-images/permissions-for-snippets-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/readme-images/permissions-for-snippets-1.PNG -------------------------------------------------------------------------------- /readme-images/permissions-for-snippets-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/readme-images/permissions-for-snippets-2.PNG -------------------------------------------------------------------------------- /readme-images/permissions-for-snippets-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/O365-Android-Snippets/521606cc26d7786090de71b2c32d6e20501f1f14/readme-images/permissions-for-snippets-3.PNG -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------