This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Graph, OneNote and LiveAuth SDKs
- Loading branch information
Marcos Torres
committed
Apr 24, 2015
1 parent
934561c
commit 8d8a389
Showing
390 changed files
with
31,033 additions
and
721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "22.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.microsoft.samples.onenotesample" | ||
minSdkVersion 15 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:22.0.0' | ||
compile project(':odata-engine-android-impl') | ||
compile project(':onenote-services') | ||
compile project(':live-auth') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/joshgav/dev/android-sdk-macosx/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
...eSample/app/src/androidTest/java/com/microsoft/samples/onenotesample/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.microsoft.samples.onenotesample; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.microsoft.samples.onenotesample" > | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
18 changes: 18 additions & 0 deletions
18
samples/OneNoteSample/app/src/main/java/com/microsoft/samples/onenotesample/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.microsoft.samples.onenotesample; | ||
|
||
import com.google.common.collect.Iterators; | ||
|
||
import java.util.Arrays; | ||
|
||
public class Constants { | ||
final static public String CLIENT_ID = "00000000DDDDDDDD"; // get your own please | ||
final static public String[] SCOPES = { | ||
"wl.signin", | ||
"wl.basic", | ||
"wl.offline_access", | ||
"wl.skydrive_update", | ||
"wl.contacts_create", | ||
"office.onenote_create" | ||
}; | ||
final static public String ONENOTE_API_ROOT = "https://www.onenote.com/api/v1.0"; | ||
} |
155 changes: 155 additions & 0 deletions
155
...les/OneNoteSample/app/src/main/java/com/microsoft/samples/onenotesample/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package com.microsoft.samples.onenotesample; | ||
|
||
import android.support.v7.app.ActionBarActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.Button; | ||
import android.widget.ListView; | ||
|
||
import com.google.common.util.concurrent.FutureCallback; | ||
import com.google.common.util.concurrent.Futures; | ||
import com.microsoft.live.LiveAuthClient; | ||
import com.microsoft.services.odata.impl.LiveAuthDependencyResolver; | ||
import com.microsoft.onenote.api.Notebook; | ||
import com.microsoft.onenote.api.odata.OneNoteApiClient; | ||
import com.microsoft.services.odata.interfaces.LogLevel; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MainActivity extends ActionBarActivity { | ||
|
||
private static final String TAG = "OneNoteSampleActivity"; | ||
|
||
private ListView lvNotebooks; | ||
private Button btnNotebooks; | ||
private OneNoteApiClient oneNoteClient; | ||
private LiveAuthDependencyResolver dependencyResolver; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
lvNotebooks = (ListView) findViewById(R.id.listView1); | ||
btnNotebooks = (Button) findViewById(R.id.button1); | ||
btnNotebooks.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getNotebooks(); | ||
} | ||
}); | ||
|
||
logon(); | ||
} | ||
|
||
|
||
protected OneNoteApiClient getOneNoteClient() { | ||
if (oneNoteClient == null) { | ||
oneNoteClient = new OneNoteApiClient(Constants.ONENOTE_API_ROOT, getDependencyResolver()); | ||
} | ||
return oneNoteClient; | ||
} | ||
|
||
protected LiveAuthDependencyResolver getDependencyResolver() { | ||
|
||
if (dependencyResolver == null) { | ||
LiveAuthClient theAuthClient = new LiveAuthClient(getApplicationContext(), Constants.CLIENT_ID, | ||
Arrays.asList(Constants.SCOPES)); | ||
|
||
dependencyResolver = new LiveAuthDependencyResolver(theAuthClient); | ||
|
||
dependencyResolver.getLogger().setEnabled(true); | ||
dependencyResolver.getLogger().setLogLevel(LogLevel.VERBOSE); | ||
} | ||
|
||
return dependencyResolver; | ||
} | ||
|
||
|
||
private void logon() { | ||
|
||
try { | ||
Futures.addCallback(this.getDependencyResolver().interactiveInitialize(this), new FutureCallback<Boolean>() { | ||
@Override | ||
public void onSuccess(Boolean result) { | ||
btnNotebooks.setEnabled(true); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable t) { | ||
getDependencyResolver().getLogger().log(t.getMessage(), LogLevel.ERROR); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
Log.e(TAG, e.getMessage()); | ||
} | ||
} | ||
|
||
private void getNotebooks() { | ||
|
||
Futures.addCallback(getOneNoteClient().getnotebooks().read(), new FutureCallback<List<Notebook>>() { | ||
@Override | ||
public void onSuccess(List<Notebook> notebooks) { | ||
List<String> nbNames = new ArrayList<String>(); | ||
for (Notebook nb : notebooks) { | ||
nbNames.add(nb.getname()); | ||
} | ||
final ArrayAdapter<String> adapter = | ||
new ArrayAdapter<String>(getBaseContext(),android.R.layout.simple_list_item_1, nbNames); | ||
|
||
runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
lvNotebooks.setAdapter(adapter); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable t) { | ||
Log.e(TAG, t.getMessage()); | ||
} | ||
}); | ||
|
||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
if (id == R.id.action_logout) { | ||
getDependencyResolver().logout(); | ||
btnNotebooks.setEnabled(false); | ||
lvNotebooks.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, new String[0])); | ||
} | ||
|
||
if (id == R.id.action_login) { | ||
logon(); | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
samples/OneNoteSample/app/src/main/res/layout/activity_main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity" > | ||
<Button | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/button1" | ||
android:text="Get Notebooks" | ||
android:enabled="false" /> | ||
|
||
<ListView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/listView1" | ||
android:layout_gravity="center_horizontal" | ||
tools:listitem="@android:layout/simple_list_item_2" /> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> | ||
<item android:id="@+id/action_settings" android:title="@string/action_settings" | ||
android:orderInCategory="100" app:showAsAction="never" /> | ||
<item android:id="@+id/action_logout" android:title="Logout" | ||
android:orderInCategory="50" /> | ||
<item android:id="@+id/action_login" android:title="Login" | ||
android:orderInCategory="75" /> | ||
</menu> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
samples/OneNoteSample/app/src/main/res/values-w820dp/dimens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<string name="app_name">One Note Sample</string> | ||
|
||
<string name="hello_world">Hello world!</string> | ||
<string name="action_settings">Settings</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.1.2' | ||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
tests/e2e-test-app/gradle.properties → samples/OneNoteSample/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include ':app', | ||
':onenote-services', | ||
':live-auth', | ||
':odata-engine-android-impl', | ||
':odata-engine-core' | ||
|
||
|
||
project (':onenote-services').projectDir = file('../../sdk/onenote-services') | ||
project (':live-auth').projectDir = file('../../sdk/live-auth') | ||
project (':odata-engine-android-impl').projectDir = file('../../sdk/odata-engine-android-impl') | ||
project (':odata-engine-core').projectDir = file('../../sdk/odata-engine-core') |
Oops, something went wrong.