Skip to content

Commit 9bcb918

Browse files
committed
Initial Commit
1 parent ad617b2 commit 9bcb918

File tree

124 files changed

+6394
-1
lines changed

Some content is hidden

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

124 files changed

+6394
-1
lines changed

.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#built application files
2+
*.apk
3+
*.ap_
4+
5+
# files for the dex VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# generated files
12+
bin/
13+
gen/
14+
15+
# Local configuration file (sdk path, etc)
16+
local.properties
17+
18+
# Windows thumbnail db
19+
Thumbs.db
20+
21+
# OSX files
22+
.DS_Store
23+
24+
# Proguard folder generated by Eclipse
25+
proguard/
26+
27+
# Android Studio
28+
*.iml
29+
.idea
30+
.gradle
31+
build/

License.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Copyright (c) Microsoft Corporation
3+
4+
All rights reserved. 
5+
6+
MIT License
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9+
and associated documentation files (the ""Software""), to deal in the Software without restriction,
10+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
11+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
12+
subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all copies or substantial
15+
portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
# Android-Activity-Tracker-for-Dynamics-CRM-Web-API
1+
# Android Activity Tracker Sample App for Microsoft Dynamics CRM
2+
3+
These instructions describe how to build and run the sample Android Activity Tracker application.
4+
5+
## Register the application
6+
7+
Applications that access CRM business data, using the OAuth identity provider of the organization web service, must be registered in Active Directory. For an on-premises/IFD CRM deployment, AD FS 3.0 (or later) is used to register the app. With CRM Online, Microsoft Azure Active Directory is used for app registration. The result of application registration is a client ID value and a redirect URI that must be placed into the sample application's code where indicated in the next section. These values are used in the authentication process to determine whether the app has permission to access the organization's data.
8+
9+
For information on how to register an application, see [Walkthrough: Register a CRM app with Active Directory](https://msdn.microsoft.com/en-us/library/dn531010.aspx).
10+
11+
For internal app testing, you can share a single app registration across multiple apps. An app registration contains a single client ID, but can include multiple redirect URI's. For testing, you can add a redirect URI for each app you are developing. Once you are ready to publish an app to the Play Store, the app need's its own registration.
12+
13+
## Build the application
14+
15+
Prerequisites: This sample requires Android Studio 2, JDK 1.8.0, Android 6, and CRM 2016 to build and run.
16+
17+
1. Load the app's project, located in the ActivityTracker folder under the project’s root folder, into Android Studio (note: if this is the first time you are opening the project, you need to import it so it properly sets up the workspace and gradle system).
18+
2. In the project view, expand app > src > main > java > com.microsoft.activitytracker > ui.
19+
3. Edit the SetupActivity.java file.
20+
4. On line 46 in the code file, change the provided value of `CLIENT_ID` to the client ID value from your app registration.
21+
5. On line 47 in the code file, change the provided value of `REDIRECT_URI` to the redirect URI value from your app registration.
22+
6. Build the application.
23+
24+
## Run the application
25+
26+
On the mobile device where you deployed the app, choose the Activity Tracker app to start it. The following screens show how to access the features of the app.
27+
28+
Page | Visual Navigation | Description
29+
------- | ---- | ----
30+
Server and account | ![Server URL and username](./_images/1A - Server URL.png) | Enter the https:// root address of your CRM server, including the name of your domain, and the username of the logon system user account. If you do not know the URL, you can find it in the CRM web application by navigating to **Settings > Customization > Developer Resources**. An example URL would be: https://mydomain.crm.dynamics.com. Choose **Start Login** to continue.
31+
Logon credentials |![Logon credentials](./_images/2A - Logon.png) | Enter your the system user account password, for the organization that you specified on the previous page, and choose **Sign in**.
32+
Search | ![Search results](./_images/4A - Contact list.png) | The main page is initially blank with no contacts showing. Choose the search icon and enter one or more letters to find all contacts whose full name contain those letters.
33+
Contact details | ![Contact record](./_images/5A - Contact record with activity.png) | From the search results, choose a contact to display the details for that contact. On the details page, you can choose the street address to see that location on a map, the phone number to call the contact, or the email icon to send an email.
34+
Activity Creation | ![Contact new](./_images/5A1 - Contact create types.png) | Press the + floating action button to display the different types of activities you can create. Note that only the check mark command is enabled. The other commands are just place holders.
35+
New activity | ![New activity](./_images/6A - Adding an activity.png) | Choose the check mark icon on the details page to create a new activity for the contact. Enter the requested information. Choose the check mark again to save the activity record and return to the details page.
36+
37+
## Notes
38+
39+
Normally in oAuth you want to store the token and the refresh token so if the access token hasn't expired yet, you just reuse that one. Otherwise you pass the refresh token to get a new access token. Since you are unable to access the Token from ADAL, and you are required to pass the refresh token into `acquireTokenByRefreshToken` you have to actually store them manually as shown in this sample. If you want to continuously refresh without caring if the access token is still valid or not, all you have to store is the refresh token.

_images/1A - Server URL.png

48.5 KB
Loading

_images/2A - Logon.png

120 KB
Loading
102 KB
Loading
166 KB
Loading

_images/6A - Adding an activity.png

80.5 KB
Loading

app/build.gradle

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'com.neenbedankt.android-apt'
3+
apply plugin: 'me.tatarka.retrolambda'
4+
5+
android {
6+
7+
packagingOptions {
8+
exclude 'META-INF/LICENSE.txt'
9+
exclude 'META-INF/NOTICE.txt'
10+
exclude '.readme'
11+
}
12+
13+
lintOptions {
14+
abortOnError false
15+
}
16+
17+
compileSdkVersion 23
18+
buildToolsVersion '23.0.3'
19+
defaultConfig {
20+
minSdkVersion 19
21+
targetSdkVersion 23
22+
versionCode 1
23+
versionName "0.0.1"
24+
}
25+
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
31+
dataBinding {
32+
enabled = true
33+
}
34+
35+
}
36+
37+
buildscript {
38+
repositories {
39+
mavenCentral()
40+
jcenter()
41+
}
42+
43+
dependencies {
44+
// Retrolambda is brought in so I can utilize Java 8 Lambda functionality, since
45+
// Official support with the jack compiler isn't available with use of Annotation
46+
// Processors
47+
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
48+
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
49+
}
50+
}
51+
52+
repositories {
53+
mavenCentral()
54+
55+
flatDir {
56+
dirs 'libs'
57+
}
58+
59+
maven { url 'https://jitpack.io' }
60+
}
61+
62+
def dbflow_version = "3.0.1"
63+
64+
dependencies {
65+
compile fileTree(include: ['*.jar'], dir: 'libs')
66+
compile project(path: ':xrm')
67+
68+
// Debug tools for finding memory leaks, checking network calls, debug views, and
69+
// check the database with sql queries and table checks
70+
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
71+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
72+
debugCompile 'com.facebook.stetho:stetho:1.3.1'
73+
debugCompile 'com.facebook.stetho:stetho-okhttp:1.3.1'
74+
debugCompile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
75+
76+
// Google libraries
77+
compile 'com.android.support:support-v4:23.4.0'
78+
compile 'com.android.support:appcompat-v7:23.4.0'
79+
compile 'com.android.support:recyclerview-v7:23.4.0'
80+
compile 'com.android.support:design:23.4.0'
81+
82+
// Google's Dagger Dependency Injection Annotation Processor
83+
apt 'com.google.dagger:dagger-compiler:2.2'
84+
compile 'com.google.dagger:dagger:2.2'
85+
86+
// Google's Databinding Annotation Processor
87+
apt 'com.android.databinding:compiler:2.0.0-rc3'
88+
89+
// Database ORM Annotation Processor
90+
apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
91+
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
92+
compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"
93+
94+
// RXJava is the famous reactive library used in all kinds of libraries, this is very powerful
95+
// and allows you to no longer have to use huge messy AsyncTasks. RXAndroid allows you to go right
96+
// back to the UI Thread with a AndroidScheduler.
97+
provided 'org.glassfish:javax.annotation:10.0-b28'
98+
compile 'io.reactivex:rxandroid:1.1.0'
99+
compile 'io.reactivex:rxjava:1.1.2'
100+
101+
// Square's Networking framework build on top of their okhttp library, along with the
102+
// jackson converter and adapter for rxjava so responses can be observable
103+
compile 'com.squareup.retrofit2:retrofit:2.0.1'
104+
compile 'com.squareup.retrofit2:converter-jackson:2.0.1'
105+
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.1'
106+
107+
// Common library to reduce boilerplate code when working with views. Allowing you to
108+
// "bind" events with methods and auto bind views to variables.
109+
compile 'com.jakewharton:butterknife:7.0.1'
110+
111+
112+
compile 'org.mod4j.org.apache.commons:lang:2.1.0'
113+
compile('com.microsoft.aad:adal:1.2.0') {
114+
exclude group: 'com.android.support'
115+
}
116+
117+
}

app/fabric.properties

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
2+
#Sun Sep 06 23:37:02 CDT 2015
3+

app/proguard-rules.pro

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/JeremyShore/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Retrofit
20+
-dontwarn retrofit.**
21+
-keep class retrofit.** { *; }
22+
-keepattributes Signature
23+
-keepattributes Exceptions
24+
25+
# Xrm
26+
-keep class com.microsoft.xrm.sdk.** { *; }
27+
-keep class * extends com.microsoft.xrm.sdk.Entity { *; }
28+
29+
# Google
30+
-dontwarn android.support.v7.**
31+
-keep class android.support.v7.** { *; }
32+
-keep interface android.support.v7.** { *; }
33+
34+
-keep public class com.google.android.gms.* { public *; }
35+
-dontwarn com.google.android.gms.**
36+
37+
# Debugging
38+
-dontwarn com.facebook.stetho.**
39+
-keep class com.facebook.stetho.** { *; }
40+
41+
-dontwarn okio.**
42+
-keep class okio.** { *; }
43+
44+
#Butterknife
45+
-keep class butterknife.** { *; }
46+
-dontwarn butterknife.internal.**
47+
-keep class **$$ViewBinder { *; }
48+
49+
-keepclasseswithmembernames class * {
50+
@butterknife.* <fields>;
51+
}
52+
53+
-keepclasseswithmembernames class * {
54+
@butterknife.* <methods>;
55+
}

app/src/debug/AndroidManifest.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<manifest
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.microsoft.activitytracker">
5+
6+
<application
7+
tools:replace="android:name"
8+
android:name=".DebugActivityTracker" />
9+
10+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.microsoft.activitytracker;
2+
3+
import com.facebook.stetho.Stetho;
4+
import com.microsoft.activitytracker.classes.ActivityTracker;
5+
6+
public final class DebugActivityTracker extends ActivityTracker {
7+
8+
@Override
9+
public void onCreate() {
10+
super.onCreate();
11+
12+
Stetho.initialize(
13+
Stetho.newInitializerBuilder(this)
14+
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
15+
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
16+
.build());
17+
18+
}
19+
}

app/src/main/AndroidManifest.xml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
package="com.microsoft.activitytracker">
6+
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9+
10+
<application
11+
android:name=".classes.ActivityTracker"
12+
android:icon="@mipmap/ic_launcher"
13+
android:label="@string/app_name"
14+
android:theme="@style/ActivityTracker"
15+
tools:replace="theme">
16+
17+
<activity
18+
android:name="com.microsoft.aad.adal.AuthenticationActivity"
19+
android:theme="@style/ActivityTracker.Activities"
20+
android:configChanges="orientation|screenSize|keyboardHidden"
21+
android:exported="true">
22+
23+
</activity>
24+
<activity
25+
android:name=".ui.MainActivity"
26+
android:configChanges="orientation|screenSize|keyboardHidden"
27+
android:theme="@style/ActivityTracker.Activities">
28+
<intent-filter>
29+
<action android:name="android.intent.action.MAIN" />
30+
<category android:name="android.intent.category.LAUNCHER" />
31+
</intent-filter>
32+
33+
<meta-data
34+
android:name="android.app.default_searchable"
35+
android:value=".ui.SearchActivity" />
36+
</activity>
37+
<activity
38+
android:name=".ui.CreateActivity"
39+
android:configChanges="orientation|screenSize|keyboardHidden"
40+
android:theme="@style/ActivityTracker.Activities"
41+
android:windowSoftInputMode="adjustPan">
42+
43+
</activity>
44+
<activity
45+
android:name=".ui.ItemActivity"
46+
android:configChanges="orientation|screenSize|keyboardHidden"
47+
android:theme="@style/ActivityTracker.Activities"
48+
android:parentActivityName=".ui.MainActivity">
49+
50+
</activity>
51+
<activity
52+
android:name=".ui.SetupActivity"
53+
android:configChanges="orientation|screenSize|keyboardHidden"
54+
android:theme="@style/ActivityTracker.Activities"
55+
android:launchMode="singleTop">
56+
57+
</activity>
58+
59+
<activity
60+
android:name=".ui.SearchActivity"
61+
android:configChanges="orientation|screenSize|keyboardHidden"
62+
android:theme="@style/ActivityTracker.Activities"
63+
android:launchMode="singleTop">
64+
65+
<intent-filter>
66+
<action android:name="android.intent.action.SEARCH" />
67+
</intent-filter>
68+
69+
<intent-filter>
70+
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
71+
<category android:name="android.intent.category.DEFAULT" />
72+
</intent-filter>
73+
74+
<meta-data
75+
android:name="android.app.searchable"
76+
android:resource="@xml/searchable" />
77+
</activity>
78+
79+
</application>
80+
81+
</manifest>

0 commit comments

Comments
 (0)