Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 8d8a389

Browse files
author
Marcos Torres
committed
Adding Graph, OneNote and LiveAuth SDKs
1 parent 934561c commit 8d8a389

File tree

390 files changed

+31033
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

390 files changed

+31033
-721
lines changed

CHANGES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Office 365 SDK for Android #
22

3+
### Version 0.13.0 ###
4+
5+
* Added OneNote SDK
6+
* Added Graph Services (Preview)
7+
* Added Live Auth SDK
8+
* Added LiveDependencyResolver
9+
* Updated the Exchange SDK to use TimeZone, CalendarColor, GeoCoordinates
10+
311
### Version 0.12.0 ###
412

513
* Fixing classpath for javadoc generation

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ Now we'll create a simple application that retrieves messages using this SDK and
3333
```Groovy
3434
dependencies {
3535
// base OData stuff:
36-
compile group: 'com.microsoft.services', name: 'odata-engine-core', version: '0.12.0'
37-
compile group: 'com.microsoft.services', name: 'odata-engine-android-impl', version: '0.12.0', ext:'aar'
36+
compile group: 'com.microsoft.services', name: 'odata-engine-core', version: '0.13.0'
37+
compile group: 'com.microsoft.services', name: 'odata-engine-android-impl', version: '0.13.0', ext:'aar'
3838

3939
// choose the services/SDKs you need:
40-
compile group: 'com.microsoft.services', name: 'outlook-services', version: '0.12.0'
41-
compile group: 'com.microsoft.services', name: 'discovery-services', version: '0.12.0'
42-
compile group: 'com.microsoft.services', name: 'directory-services', version: '0.12.0'
43-
compile group: 'com.microsoft.services', name: 'file-services', version: '0.12.0'
44-
compile group: 'com.microsoft.services', name: 'sharepoint-services', version: '0.12.0', ext:'aar'
40+
compile group: 'com.microsoft.services', name: 'graph-services', version: '0.1.0'
41+
compile group: 'com.microsoft.services', name: 'onenote-services', version: '0.13.0'
42+
compile group: 'com.microsoft.services', name: 'outlook-services', version: '0.13.0'
43+
compile group: 'com.microsoft.services', name: 'discovery-services', version: '0.13.0'
44+
compile group: 'com.microsoft.services', name: 'directory-services', version: '0.13.0'
45+
compile group: 'com.microsoft.services', name: 'file-services', version: '0.13.0'
46+
compile group: 'com.microsoft.services', name: 'sharepoint-services', version: '0.13.0', ext:'aar'
4547
4648
// ADAL
4749
compile (group: 'com.microsoft.aad', name: 'adal', version: '1.0.5') {
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 22
5+
buildToolsVersion "22.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.microsoft.samples.onenotesample"
9+
minSdkVersion 15
10+
targetSdkVersion 22
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile 'com.android.support:appcompat-v7:22.0.0'
24+
compile project(':odata-engine-android-impl')
25+
compile project(':onenote-services')
26+
compile project(':live-auth')
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/joshgav/dev/android-sdk-macosx/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+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.microsoft.samples.onenotesample;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.microsoft.samples.onenotesample" >
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:theme="@style/AppTheme" >
11+
<activity
12+
android:name=".MainActivity"
13+
android:label="@string/app_name" >
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.microsoft.samples.onenotesample;
2+
3+
import com.google.common.collect.Iterators;
4+
5+
import java.util.Arrays;
6+
7+
public class Constants {
8+
final static public String CLIENT_ID = "00000000DDDDDDDD"; // get your own please
9+
final static public String[] SCOPES = {
10+
"wl.signin",
11+
"wl.basic",
12+
"wl.offline_access",
13+
"wl.skydrive_update",
14+
"wl.contacts_create",
15+
"office.onenote_create"
16+
};
17+
final static public String ONENOTE_API_ROOT = "https://www.onenote.com/api/v1.0";
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
package com.microsoft.samples.onenotesample;
2+
3+
import android.support.v7.app.ActionBarActivity;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
import android.view.Menu;
7+
import android.view.MenuItem;
8+
import android.view.View;
9+
import android.widget.ArrayAdapter;
10+
import android.widget.Button;
11+
import android.widget.ListView;
12+
13+
import com.google.common.util.concurrent.FutureCallback;
14+
import com.google.common.util.concurrent.Futures;
15+
import com.microsoft.live.LiveAuthClient;
16+
import com.microsoft.services.odata.impl.LiveAuthDependencyResolver;
17+
import com.microsoft.onenote.api.Notebook;
18+
import com.microsoft.onenote.api.odata.OneNoteApiClient;
19+
import com.microsoft.services.odata.interfaces.LogLevel;
20+
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.List;
24+
25+
public class MainActivity extends ActionBarActivity {
26+
27+
private static final String TAG = "OneNoteSampleActivity";
28+
29+
private ListView lvNotebooks;
30+
private Button btnNotebooks;
31+
private OneNoteApiClient oneNoteClient;
32+
private LiveAuthDependencyResolver dependencyResolver;
33+
34+
@Override
35+
protected void onCreate(Bundle savedInstanceState) {
36+
super.onCreate(savedInstanceState);
37+
setContentView(R.layout.activity_main);
38+
39+
lvNotebooks = (ListView) findViewById(R.id.listView1);
40+
btnNotebooks = (Button) findViewById(R.id.button1);
41+
btnNotebooks.setOnClickListener(new View.OnClickListener() {
42+
@Override
43+
public void onClick(View v) {
44+
getNotebooks();
45+
}
46+
});
47+
48+
logon();
49+
}
50+
51+
52+
protected OneNoteApiClient getOneNoteClient() {
53+
if (oneNoteClient == null) {
54+
oneNoteClient = new OneNoteApiClient(Constants.ONENOTE_API_ROOT, getDependencyResolver());
55+
}
56+
return oneNoteClient;
57+
}
58+
59+
protected LiveAuthDependencyResolver getDependencyResolver() {
60+
61+
if (dependencyResolver == null) {
62+
LiveAuthClient theAuthClient = new LiveAuthClient(getApplicationContext(), Constants.CLIENT_ID,
63+
Arrays.asList(Constants.SCOPES));
64+
65+
dependencyResolver = new LiveAuthDependencyResolver(theAuthClient);
66+
67+
dependencyResolver.getLogger().setEnabled(true);
68+
dependencyResolver.getLogger().setLogLevel(LogLevel.VERBOSE);
69+
}
70+
71+
return dependencyResolver;
72+
}
73+
74+
75+
private void logon() {
76+
77+
try {
78+
Futures.addCallback(this.getDependencyResolver().interactiveInitialize(this), new FutureCallback<Boolean>() {
79+
@Override
80+
public void onSuccess(Boolean result) {
81+
btnNotebooks.setEnabled(true);
82+
}
83+
84+
@Override
85+
public void onFailure(Throwable t) {
86+
getDependencyResolver().getLogger().log(t.getMessage(), LogLevel.ERROR);
87+
}
88+
});
89+
} catch (Exception e) {
90+
Log.e(TAG, e.getMessage());
91+
}
92+
}
93+
94+
private void getNotebooks() {
95+
96+
Futures.addCallback(getOneNoteClient().getnotebooks().read(), new FutureCallback<List<Notebook>>() {
97+
@Override
98+
public void onSuccess(List<Notebook> notebooks) {
99+
List<String> nbNames = new ArrayList<String>();
100+
for (Notebook nb : notebooks) {
101+
nbNames.add(nb.getname());
102+
}
103+
final ArrayAdapter<String> adapter =
104+
new ArrayAdapter<String>(getBaseContext(),android.R.layout.simple_list_item_1, nbNames);
105+
106+
runOnUiThread(new Runnable() {
107+
@Override
108+
public void run() {
109+
lvNotebooks.setAdapter(adapter);
110+
}
111+
});
112+
}
113+
114+
@Override
115+
public void onFailure(Throwable t) {
116+
Log.e(TAG, t.getMessage());
117+
}
118+
});
119+
120+
}
121+
122+
123+
124+
@Override
125+
public boolean onCreateOptionsMenu(Menu menu) {
126+
// Inflate the menu; this adds items to the action bar if it is present.
127+
getMenuInflater().inflate(R.menu.menu_main, menu);
128+
return true;
129+
}
130+
131+
@Override
132+
public boolean onOptionsItemSelected(MenuItem item) {
133+
// Handle action bar item clicks here. The action bar will
134+
// automatically handle clicks on the Home/Up button, so long
135+
// as you specify a parent activity in AndroidManifest.xml.
136+
int id = item.getItemId();
137+
138+
//noinspection SimplifiableIfStatement
139+
if (id == R.id.action_settings) {
140+
return true;
141+
}
142+
143+
if (id == R.id.action_logout) {
144+
getDependencyResolver().logout();
145+
btnNotebooks.setEnabled(false);
146+
lvNotebooks.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, new String[0]));
147+
}
148+
149+
if (id == R.id.action_login) {
150+
logon();
151+
}
152+
153+
return super.onOptionsItemSelected(item);
154+
}
155+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<LinearLayout
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:orientation="vertical"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".MainActivity" >
8+
<Button
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:id="@+id/button1"
12+
android:text="Get Notebooks"
13+
android:enabled="false" />
14+
15+
<ListView
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content"
18+
android:id="@+id/listView1"
19+
android:layout_gravity="center_horizontal"
20+
tools:listitem="@android:layout/simple_list_item_2" />
21+
</LinearLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
4+
<item android:id="@+id/action_settings" android:title="@string/action_settings"
5+
android:orderInCategory="100" app:showAsAction="never" />
6+
<item android:id="@+id/action_logout" android:title="Logout"
7+
android:orderInCategory="50" />
8+
<item android:id="@+id/action_login" android:title="Login"
9+
android:orderInCategory="75" />
10+
</menu>
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<string name="app_name">One Note Sample</string>
3+
4+
<string name="hello_world">Hello world!</string>
5+
<string name="action_settings">Settings</string>
6+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
</style>
7+
8+
</resources>

samples/OneNoteSample/build.gradle

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath 'com.android.tools.build:gradle:1.1.2'
7+
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6"
8+
}
9+
}
10+
11+
allprojects {
12+
repositories {
13+
jcenter()
14+
}
15+
}

tests/e2e-test-app/gradle.properties samples/OneNoteSample/gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Project-wide Gradle settings.
22

33
# IDE (e.g. Android Studio) users:
4-
# Settings specified in this file will override any Gradle settings
5-
# configured through the IDE.
4+
# Gradle settings configured through the IDE *will override*
5+
# any settings specified in this file.
66

77
# For more details on how to configure your build environment visit
88
# http://www.gradle.org/docs/current/userguide/build_environment.html

samples/OneNoteSample/settings.gradle

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include ':app',
2+
':onenote-services',
3+
':live-auth',
4+
':odata-engine-android-impl',
5+
':odata-engine-core'
6+
7+
8+
project (':onenote-services').projectDir = file('../../sdk/onenote-services')
9+
project (':live-auth').projectDir = file('../../sdk/live-auth')
10+
project (':odata-engine-android-impl').projectDir = file('../../sdk/odata-engine-android-impl')
11+
project (':odata-engine-core').projectDir = file('../../sdk/odata-engine-core')

0 commit comments

Comments
 (0)