Skip to content

Commit

Permalink
Setup sample app for integrating channelize android sdk in app
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak-patidar-bs committed Sep 23, 2019
1 parent 484170e commit bb77acc
Show file tree
Hide file tree
Showing 48 changed files with 2,144 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ChannelizeSampleSdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
1 change: 1 addition & 0 deletions ChannelizeSampleSdk/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
105 changes: 105 additions & 0 deletions ChannelizeSampleSdk/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apply plugin: 'com.android.application'

project.ext {
appVersionCode = 1
appVersionName = '1.0'
storeFile = 'release'
storePassword = 'release'
keyAlias = 'release'
keyPassword = 'release'
}

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.channelize.sample"
minSdkVersion 17
targetSdkVersion 28
versionCode project.ext.appVersionCode.toInteger()
versionName project.ext.appVersionName
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}

signingConfigs {
release {
storeFile file(project.storeFile)
storePassword project.storePassword
keyAlias project.keyAlias
keyPassword project.keyPassword
}
}

dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}

packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}

aaptOptions {
cruncherEnabled = false
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

ext{
channelizeSDKVersion = '4.0.10'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation ('com.android.support:recyclerview-v7:27.1.1') {
exclude group: 'com.android.support'
}
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'

implementation ('com.google.android.gms:play-services-location:15.0.1') {
exclude group: 'com.android.support'
}
implementation ('com.google.android.gms:play-services-maps:15.0.1') {
exclude group: 'com.android.support'
}
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation ('com.google.firebase:firebase-messaging:17.1.0') {
exclude group: 'com.google.android'
}
implementation ('com.google.firebase:firebase-core:16.0.1') {
exclude group: 'com.google.android'
}

// Channelize Dependency.
implementation "com.github.ChannelizeIO.Channelize-Android-SDK:channelizeapi:$channelizeSDKVersion"
implementation "com.github.ChannelizeIO.Channelize-Android-SDK:channelizeui:$channelizeSDKVersion"
implementation "com.github.ChannelizeIO.Channelize-Android-SDK:channelizecall:$channelizeSDKVersion"
}
apply plugin: 'com.google.gms.google-services'
3 changes: 3 additions & 0 deletions ChannelizeSampleSdk/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Configure your project on fcm and replace with your google-service.json file" : "google-service.json"
}
21 changes: 21 additions & 0 deletions ChannelizeSampleSdk/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.channelize.sample;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.channelize.sample", appContext.getPackageName());
}
}
64 changes: 64 additions & 0 deletions ChannelizeSampleSdk/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.channelize.sample">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />



<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="com.channelize.sample.AppController"
tools:replace="android:theme">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/places_api_key" />

<meta-data android:name="com.channelize.giphy.API_KEY"
android:value="@string/giphy_api_key" />


<!-- Replace this with a valid resource name for Launcher white Icon -->
<meta-data android:name="com.channelize.messenger.notification.smallIcon"
android:resource="@drawable/push_noti_icon" />

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/push_noti_icon" />

<!-- Replace with your desired activity's full path(Full class path name)
when click on push notification and channelize is not active then this activity gets launched,
otherwise put the value "@string/pm_push_notification_open_activity_name".
This will simply launch the channelize activity-->
<meta-data android:name="com.channelize.messenger.activity.open.notification"
android:value="com.channelize.messenger.LoginActivity" />

<activity android:name="com.channelize.sample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2018 BigStep Technologies Private Limited.
*
* The distribution of this source code is prohibited.
*/

package com.channelize.sample;


import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;

import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.channelize.apisdk.Channelize;
import com.channelize.apisdk.ChannelizeConfig;
import com.channelize.apisdk.utils.ChannelizePreferences;
import com.channelize.uisdk.ChannelizeUI;
import com.channelize.uisdk.ChannelizeUIConfig;
import com.channelize.uisdk.interfaces.OnConversationClickListener;
import com.channelize.uisdk.utils.ChannelizeUtils;


public class AppController extends MultiDexApplication implements OnConversationClickListener {

private static Context context;
private Channelize channelize;

public AppController() {
}

public static Context getContext() {
return context;
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

@Override
public void onCreate() {
super.onCreate();

context = getApplicationContext();

initializeChannelize();
registerActivityLifecycleCallbacks(new AppLifecycleTracker());
}

/**
* Method to initialize channelize components.
*/
private void initializeChannelize() {
ChannelizeConfig channelizeConfig = new ChannelizeConfig.Builder(this)
.setAPIKey(Config.API_KEY)
.setLoggingEnabled(true).build();
Channelize.initialize(channelizeConfig);
Channelize.getInstance().setCurrentUserId(ChannelizePreferences.getCurrentUserId(getContext()));
if (Channelize.getInstance().getCurrentUserId() != null
&& !Channelize.getInstance().getCurrentUserId().isEmpty()) {
Channelize.connect();
}

ChannelizeUIConfig channelizeUIConfig = new ChannelizeUIConfig.Builder()
.enableCall(true)
.build();
ChannelizeUI.initialize(channelizeUIConfig);
channelize = Channelize.getInstance();

ChannelizeUtils channelizeUtils = ChannelizeUtils.getInstance();
channelizeUtils.setOnConversationClickListener(this);
}

@Override
public void onConversationOpen(String conversationId) {
ChannelizeUI.getInstance().onConversationOpen(getApplicationContext(), conversationId);
}

class AppLifecycleTracker implements Application.ActivityLifecycleCallbacks {

private int numStarted = 0;

@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

}

@Override
public void onActivityStarted(Activity activity) {
if (numStarted == 0 && channelize != null) {
// app went to foreground
channelize.setUserOnline();
}
numStarted++;
}

@Override
public void onActivityResumed(Activity activity) {

}

@Override
public void onActivityPaused(Activity activity) {

}

@Override
public void onActivityStopped(Activity activity) {
numStarted--;
if (numStarted == 0 && channelize != null) {
// app went to background
channelize.setUserOffline();
}
}

@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

}

@Override
public void onActivityDestroyed(Activity activity) {
if (numStarted == 0) {
ChannelizeUtils.getInstance().appClosed(context);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.channelize.sample;

public class Config {

// This will be the api key.
static final String API_KEY = "Replace with your channelize api key";

// this will be sender id of the project
public static final String FIREBASE_SENDER_ID = "Replace with your project number";

}
Loading

0 comments on commit bb77acc

Please sign in to comment.