├── settings.gradle
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── app
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable-hdpi
│ │ │ ├── ic_logout.png
│ │ │ ├── ic_tasks.png
│ │ │ ├── ic_user.png
│ │ │ ├── ic_contacts.png
│ │ │ └── ic_loading.jpeg
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── ic_logout.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── menu
│ │ │ ├── navigation_drawer.xml
│ │ │ ├── main_page.xml
│ │ │ ├── record_view_page_drawer.xml
│ │ │ └── activity_navigation_drawer.xml
│ │ ├── values-v21
│ │ │ └── styles.xml
│ │ ├── drawable-v21
│ │ │ ├── ic_menu_send.xml
│ │ │ ├── ic_menu_slideshow.xml
│ │ │ ├── ic_menu_gallery.xml
│ │ │ ├── ic_menu_manage.xml
│ │ │ ├── ic_menu_camera.xml
│ │ │ └── ic_menu_share.xml
│ │ ├── values-w820dp
│ │ │ ├── dimens.xml
│ │ │ └── drawables.xml
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── drawables.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── layout
│ │ │ ├── list_activity.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── content_navigation_drawer.xml
│ │ │ ├── home_calendar.xml
│ │ │ ├── app_bar_navigation_drawer.xml
│ │ │ ├── list_item.xml
│ │ │ ├── activity_home.xml
│ │ │ ├── records_list.xml
│ │ │ ├── nav_header_navigation_drawer.xml
│ │ │ ├── record_view_page.xml
│ │ │ ├── activity_navigation_drawer.xml
│ │ │ ├── module_tab.xml
│ │ │ └── home_activity.xml
│ │ └── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── android_kotlin_sample_app
│ │ │ ├── DataHandler.kt
│ │ │ ├── DataProvider.kt
│ │ │ ├── HomeActivity.kt
│ │ │ └── ListActivity.kt
│ │ └── AndroidManifest.xml
└── build.gradle
├── .gitignore
├── LICENSE
├── gradlew.bat
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Zoho CRM Android SDK Sample App
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/drawable-hdpi/ic_logout.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_tasks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/drawable-hdpi/ic_tasks.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/drawable-hdpi/ic_user.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-hdpi/ic_logout.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_contacts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/drawable-hdpi/ic_contacts.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_loading.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/drawable-hdpi/ic_loading.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoho/ZCRM-Android-SDK-Sample-App/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android_kotlin_sample_app/DataHandler.kt:
--------------------------------------------------------------------------------
1 | package com.example.android_kotlin_sample_app
2 |
3 | import android.graphics.Bitmap
4 |
5 | interface DataHandler {
6 | fun setUserName(userName: String)
7 | fun setOrganizationName(organizationName: String)
8 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 28 16:54:54 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /gradle.properties
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | app/build
10 | /captures
11 | app/roguard-rules.pro
12 | out/
13 | .idea/
14 | app/src/main/res/drawable/
15 | .gitignore.swp
16 | app/proguard-rules.pro
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_page.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #5b8ba3
5 | #5b8ba3
6 | #5b8ba3
7 | #277F9C
8 | #277F9C
9 | #0b5e7a
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 16dp
7 | 160dp
8 | 16dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ___VARIABLE_AppName___
3 | ___VARIABLE_AppName___
4 |
5 | Open navigation drawer
6 | Close navigation drawer
7 |
8 | Contacts
9 | Tasks
10 | Welcome
11 | TODO
12 |
13 | ___VARIABLE_RedirectURLScheme___://
14 | ___VARIABLE_URLScheme___
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 | - @android:drawable/ic_menu_send
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/record_view_page_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/home_calendar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 zoho
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/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "30.0.1"
8 |
9 | defaultConfig {
10 | applicationId "com.example.android_kotlin_sample_app"
11 | minSdkVersion 22
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 |
29 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
30 | implementation 'androidx.core:core-ktx:1.3.1'
31 | implementation 'androidx.appcompat:appcompat:1.2.0'
32 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
33 | implementation 'com.google.android.material:material:1.3.0-alpha02'
34 | implementation 'androidx.cardview:cardview:1.0.0'
35 |
36 | implementation 'com.zoho.crm:android-sdk:1.1.9'
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
26 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/records_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
16 |
17 |
23 |
24 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
20 |
21 |
28 |
29 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/record_view_page.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
14 |
15 |
22 |
23 |
27 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_navigation_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
18 |
19 |
23 |
24 |
29 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/module_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
20 |
21 |
22 |
26 |
27 |
28 |
33 |
34 |
35 |
36 |
46 |
47 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android_kotlin_sample_app/DataProvider.kt:
--------------------------------------------------------------------------------
1 | package com.example.android_kotlin_sample_app
2 |
3 | import android.content.Context
4 | import com.zoho.crm.sdk.android.api.handler.DataCallback
5 | import com.zoho.crm.sdk.android.api.response.APIResponse
6 | import com.zoho.crm.sdk.android.exception.ZCRMException
7 | import com.zoho.crm.sdk.android.exception.ZCRMLogger
8 | import com.zoho.crm.sdk.android.setup.metadata.ZCRMOrg
9 | import com.zoho.crm.sdk.android.setup.sdkUtil.ZCRMSDKUtil
10 | import com.zoho.crm.sdk.android.setup.users.ZCRMUser
11 |
12 | class DataProvider private constructor() {
13 | private var userName: String? = null
14 | private var organisationName: String? = null
15 |
16 | fun getOrganisationName(handler: DataHandler) {
17 | if (organisationName == null) {
18 | ZCRMSDKUtil.getOrgDetails(object : DataCallback
19 | {
20 | override fun completed(response: APIResponse, org: ZCRMOrg) {
21 | organisationName = org.name ?: "No Company name"
22 | handler.setOrganizationName(organisationName!!)
23 | }
24 |
25 | override fun failed(exception: ZCRMException) {
26 | organisationName = " Error "
27 | handler.setOrganizationName(organisationName!!)
28 | ZCRMLogger.logError("Unable to get org details - $exception")
29 | }
30 |
31 | })
32 | } else {
33 | handler.setOrganizationName(organisationName!!)
34 | }
35 | }
36 |
37 | fun getUserName(handler: DataHandler) {
38 | if (userName == null) {
39 | ZCRMSDKUtil.getCurrentUser(object : DataCallback
40 | {
41 | override fun completed(response: APIResponse, user: ZCRMUser) {
42 | userName = user.fullName
43 | handler.setUserName(userName!!)
44 | }
45 |
46 | override fun failed(exception: ZCRMException) {
47 | userName = " Error "
48 | handler.setUserName(userName!!)
49 | ZCRMLogger.logError("Unable to get user details - $exception")
50 | }
51 |
52 | })
53 | } else {
54 | handler.setUserName(userName!!)
55 | }
56 | }
57 | companion object {
58 | @JvmStatic
59 | val instance = DataProvider()
60 | }
61 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/home_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
28 |
29 |
30 |
37 |
38 |
44 |
45 |
51 |
52 |
58 |
59 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
93 |
94 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android_kotlin_sample_app/HomeActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.android_kotlin_sample_app
2 |
3 | import android.app.AlertDialog
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.view.Menu
7 | import android.view.MenuItem
8 | import androidx.appcompat.app.AppCompatActivity
9 | import com.zoho.crm.sdk.android.authorization.ZCRMSDKClient
10 | import com.zoho.crm.sdk.android.common.CommonUtil
11 | import com.zoho.crm.sdk.android.configuration.ZCRMSDKConfigs
12 | import com.zoho.crm.sdk.android.exception.ZCRMException
13 | import com.zoho.crm.sdk.android.exception.ZCRMLogger
14 | import kotlinx.android.synthetic.main.home_activity.*
15 | import java.util.logging.Level
16 |
17 | class HomeActivity : AppCompatActivity(),
18 | DataHandler {
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContentView(R.layout.home_activity)
22 | showLogin()
23 | }
24 |
25 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
26 | menuInflater.inflate(R.menu.main_page, menu)
27 | return true
28 | }
29 |
30 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
31 | // Take appropriate action for each action item click
32 | return when (item.itemId) {
33 | R.id.signout -> {
34 | AlertDialog.Builder(this)
35 | .setTitle("Sign Out")
36 | .setMessage("Are you sure you want to sign out?")
37 | .setPositiveButton(
38 | "Yes"
39 | ) { dialog, which -> logout() }
40 | .setNegativeButton(
41 | "No"
42 | ) { dialog, which ->
43 | // user doesn't want to logout
44 | }
45 | .show()
46 | true
47 | }
48 | else -> false
49 | }
50 | }
51 |
52 | private fun showLogin() {
53 | try {
54 |
55 | val configs = ZCRMSDKConfigs()
56 | configs.appType = CommonUtil.AppType.ZVCRM
57 | configs.apiBaseURL = "https://___VARIABLE_ApiBaseURL___"
58 | configs.oauthScopes = "ZohoCRM.users.ALL,ZohoCRM.org.ALL,profile.orguserphoto.READ,ZohoCRM.notifications.ALL,ZohoCRM.bulk.ALL,ZohoCRM.crmapi.ALL,ZohoCRM.settings.intelligence.ALL,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL"
59 | configs.setClientDetails("___VARIABLE_ClientID___", "___VARIABLE_ClientSecret___")
60 | // configs.portalID = "___VARIABLE_PortalId___" // for ZCRMCP / ZVCRM app type
61 | // configs.customerPortalName = "___VARIABLE_PortalName___" // for ZCRMCP app type
62 | configs.httpRequestMode = CommonUtil.HttpRequestMode.ASYNC
63 | configs.userAgent = "ZCRM Android Sample App"
64 | configs.setLoggingPreferences(Level.ALL, true)
65 |
66 | ZCRMSDKClient.getInstance(applicationContext).init(configs, object : ZCRMSDKClient.Companion.ZCRMInitCallback {
67 |
68 | override fun onSuccess() {
69 | runOnUiThread { loadViews() }
70 | }
71 |
72 | override fun onFailed(ex: ZCRMException) {
73 | runOnUiThread {
74 | ZCRMLogger.logError("Login failed - $ex")
75 | }
76 | }
77 | })
78 | } catch (e: Exception) {
79 | e.printStackTrace()
80 | }
81 | }
82 |
83 | private fun logout() {
84 | ZCRMSDKClient.getInstance(applicationContext).logout(object : ZCRMSDKClient.Companion.ZCRMLogoutCallback {
85 |
86 | override fun onSuccess() {
87 | runOnUiThread { showLogin() }
88 | }
89 |
90 | override fun onFailed(ex: ZCRMException) {
91 | runOnUiThread {
92 | ZCRMLogger.logError("Login failed - $ex")
93 | }
94 | }
95 | })
96 | }
97 |
98 | private fun loadViews() {
99 | dataProvider.getUserName( this)
100 | dataProvider.getOrganisationName( this)
101 | contactsRecords.setOnClickListener { startActivity("Contacts") }
102 | tasksRecords.setOnClickListener { startActivity("Tasks") }
103 | }
104 |
105 | private fun startActivity(moduleApiName: String) {
106 | val intent = Intent(
107 | applicationContext,
108 | ListActivity::class.java
109 | )
110 | intent.putExtra("module", moduleApiName)
111 | startActivity(intent)
112 | }
113 |
114 | override fun setUserName(name: String) {
115 | runOnUiThread {
116 | val userNameWithMsg = "Welcome $name!"
117 | userName.setText(userNameWithMsg)
118 | }
119 | }
120 |
121 | override fun setOrganizationName(orgName: String) {
122 | runOnUiThread {
123 | if (supportActionBar != null) {
124 | supportActionBar!!.title = orgName
125 | }
126 | }
127 | }
128 |
129 | companion object {
130 | private val dataProvider = DataProvider.instance
131 | }
132 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android_kotlin_sample_app/ListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.android_kotlin_sample_app
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.AdapterView.OnItemClickListener
9 | import android.widget.ArrayAdapter
10 | import android.widget.ListView
11 | import android.widget.ProgressBar
12 | import android.widget.TextView
13 | import androidx.appcompat.app.AppCompatActivity
14 | import com.zoho.crm.sdk.android.api.handler.DataCallback
15 | import com.zoho.crm.sdk.android.api.response.BulkAPIResponse
16 | import com.zoho.crm.sdk.android.common.CommonUtil
17 | import com.zoho.crm.sdk.android.crud.ZCRMQuery
18 | import com.zoho.crm.sdk.android.crud.ZCRMRecord
19 | import com.zoho.crm.sdk.android.exception.ZCRMException
20 | import com.zoho.crm.sdk.android.exception.ZCRMLogger
21 | import com.zoho.crm.sdk.android.setup.sdkUtil.ZCRMSDKUtil
22 | import kotlinx.android.synthetic.main.list_activity.*
23 |
24 | class ListActivity : AppCompatActivity() {
25 | var emptyList: TextView? = null
26 | var loading: TextView? = null
27 | var mProgress: ProgressBar? = null
28 |
29 | override fun onCreate(savedInstanceState: Bundle?) {
30 | super.onCreate(savedInstanceState)
31 | setContentView(R.layout.module_tab)
32 | moduleApiName = getIntent().getStringExtra("module")
33 | getSupportActionBar()?.setTitle(moduleApiName)
34 | emptyList = findViewById(R.id.textView32) as TextView?
35 | emptyList!!.text = ""
36 | loading = findViewById(R.id.loading) as TextView?
37 | initiatePage()
38 | }
39 |
40 | fun initiatePage() {
41 | initiateList()
42 |
43 | mProgress = findViewById(R.id.moduleprogress)
44 | mProgress!!.visibility = ProgressBar.VISIBLE
45 |
46 | loading!!.text = "LOADING.. please wait." //No I18N
47 | loadRecords()
48 | }
49 |
50 | fun initiateList() {
51 | val listView = findViewById(R.id.listView) as ListView
52 | adapter = RecordListAdapter()
53 | listView.adapter = adapter
54 | clearList()
55 | listView.onItemClickListener = OnItemClickListener { adapterView, view, position, idy ->
56 | //load record's detail page here
57 | }
58 | }
59 |
60 | internal inner class RecordListAdapter : ArrayAdapter(
61 | applicationContext,
62 | R.layout.list_item,
63 | storeList as List
64 | ) {
65 | override fun getView(
66 | position: Int,
67 | view: View?,
68 | parent: ViewGroup
69 | ): View {
70 | var view = view
71 | if (view == null) {
72 | val inflater =
73 | getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
74 | view = inflater.inflate(R.layout.list_item, parent, false)
75 | }
76 | val record: ZCRMRecord =
77 | storeList[position]
78 | try {
79 | val primaryField = view!!.findViewById(R.id.textView4)
80 | val secondaryField = view.findViewById(R.id.textView5)
81 | val tertiaryField = view.findViewById(R.id.textView6)
82 | var primaryFieldValue = ""
83 | var secondaryFieldValue = ""
84 | var tertiaryFieldValue = ""
85 | if (moduleApiName == "Contacts") {
86 | if (record.getFieldValue("First_Name") != null) {
87 | primaryFieldValue += record.getFieldValue("First_Name").toString() + " "
88 | }
89 | primaryFieldValue += record.getFieldValue("Last_Name")
90 | secondaryFieldValue = if (record.getFieldValue("Email") == null) {
91 | "No Email"
92 | } else {
93 | record.getFieldValue("Email").toString()
94 | }
95 | tertiaryFieldValue = if (record.getFieldValue("Phone") == null) {
96 | "No Phone"
97 | } else {
98 | record.getFieldValue("Phone").toString()
99 | }
100 | } else if (moduleApiName == "Tasks") {
101 | primaryFieldValue = record.getFieldValue("Subject").toString()
102 | secondaryFieldValue = record.getFieldValue("Status").toString()
103 | tertiaryFieldValue = record.getFieldValue("Priority").toString()
104 | }
105 | primaryField.text = primaryFieldValue
106 | secondaryField.text = secondaryFieldValue
107 | tertiaryField.text = tertiaryFieldValue
108 | } catch (e: ZCRMException) {
109 | e.printStackTrace()
110 | }
111 | return view!!
112 | }
113 | }
114 |
115 | fun loadRecords()
116 | {
117 | val recordGetParams = ZCRMQuery.Companion.GetRecordParams()
118 | recordGetParams.page = 1
119 | recordGetParams.perPage = 50
120 | recordGetParams.sortOrder = CommonUtil.SortOrder.ASC
121 | ZCRMSDKUtil.getModuleDelegate(moduleApiName!!).getRecords(recordGetParams, object : DataCallback>
122 | {
123 | override fun completed(
124 | response: BulkAPIResponse,
125 | entityList: List
126 | ) {
127 | records = entityList as ArrayList
128 | try {
129 | recordList()
130 | } catch (e: ZCRMException) {
131 | e.printStackTrace()
132 | }
133 | }
134 |
135 | override fun failed(exception: ZCRMException) {
136 | ZCRMLogger.logError("get records failed - $exception")
137 | }
138 |
139 | })
140 | }
141 |
142 | fun recordList() {
143 | var zcrmRecord: ZCRMRecord
144 | val itr: Iterator<*> =
145 | records.iterator()
146 | while (itr.hasNext()) {
147 | zcrmRecord = itr.next() as ZCRMRecord
148 | addRecordToList(zcrmRecord, RecordListAdapter())
149 | }
150 | setPageRefreshingOff()
151 | }
152 |
153 | fun setPageRefreshingOff() {
154 | mProgress!!.visibility = ProgressBar.INVISIBLE
155 | loading!!.text = ""
156 | if (records.isEmpty()) {
157 | emptyList!!.text = "Seems you have nothing..."
158 | }
159 | }
160 |
161 | fun clearList() {
162 | records.clear()
163 | storeList.clear()
164 | }
165 |
166 | fun addRecordToList(zcrmRecord: ZCRMRecord, recordListHandler: ArrayAdapter) {
167 | storeList.add(zcrmRecord)
168 | adapter = recordListHandler
169 | runOnUiThread {
170 | // Stuff that updates the UI
171 | listView.adapter = adapter
172 | }
173 | }
174 |
175 | companion object {
176 | var adapter: ArrayAdapter? = null
177 | var records: ArrayList = ArrayList()
178 | var storeList: ArrayList = ArrayList()
179 | private var moduleApiName: String? = null
180 | }
181 | }
--------------------------------------------------------------------------------