Skip to content
Permalink
Browse files

initial commit

  • Loading branch information...
ZahraShakib committed Nov 1, 2017
1 parent acae246 commit 61852d20bdec56e1d4370a817022a2cbdf8bfc8e
@@ -0,0 +1,41 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
/*/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

#iml files
*.iml
/*/*.iml

/.idea
.DS_Store
@@ -0,0 +1 @@
/build
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.adpdigital.chabok.starter"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile 'com.github.arturogutierrez:badges:1.0.5@aar'
compile 'me.leolin:ShortcutBadger:1.1.18@aar'
compile 'com.adpdigital.push:chabok-lib:2.8.0'

compile "com.google.android.gms:play-services-gcm:10.0.1"
}
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/adp/Library/Android/sdk/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 *;
#}

# 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
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adpdigital.chabok.starter" >

<permission
android:name="com.adpdigital.chabok.starter.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>

<uses-permission android:name="com.adpdigital.chabok.starter.permission.C2D_MESSAGE" />

<application
android:name=".StarterApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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



<receiver android:name="PushMessageReceiver">
<intent-filter>
<category android:name="com.adpdigital.chabok.starter"/>
<action android:name="com.adpdigital.push.client.MSGRECEIVE"/>
</intent-filter>
</receiver>


<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:enabled="true"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.adpdigital.chabok.starter" />
</intent-filter>
</receiver>





</application>

</manifest>
@@ -0,0 +1,87 @@
package com.adpdigital.chabok.starter;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.adpdigital.push.AdpPushClient;
import com.adpdigital.push.ConnectionStatus;

public class MainActivity extends AppCompatActivity {


private AdpPushClient chabok;
private TextView connectionStatus;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
chabok = ((StarterApp) getApplication()).getPushClient();
connectionStatus = (TextView) findViewById(R.id.connection_status);

}

@Override
protected void onResume() {
super.onResume();
attachPushClient();
}


@Override
protected void onPause() {
super.onPause();
detachPushClient();
}

@Override
protected void onDestroy() {
detachPushClient();
super.onDestroy();
}

private void attachPushClient() {
if (chabok != null) {
chabok.setPushListener(this);
}
}

private void detachPushClient() {
if (chabok != null) {
chabok.removePushListener(this);
}
}

public void onEvent(final ConnectionStatus status) {
runOnUiThread(new Runnable() {
@Override
public void run() {
updateConnectionStatus(status);
}
});
}

private void updateConnectionStatus(ConnectionStatus status) {

if (connectionStatus != null && status != null) {
switch (status) {
case CONNECTED:
connectionStatus.setText(getString(R.string.connected));
connectionStatus.setBackgroundResource(R.drawable.green_circle);
break;

case CONNECTING:
connectionStatus.setText(getString(R.string.connecting));
connectionStatus.setBackgroundResource(R.drawable.orange_circle);
break;

case DISCONNECTED:
connectionStatus.setText(getString(R.string.disconnected));
connectionStatus.setBackgroundResource(R.drawable.red_circle);
break;
}
}
}

}
@@ -0,0 +1,29 @@
package com.adpdigital.chabok.starter;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.WakefulBroadcastReceiver;

import com.adpdigital.push.AdpPushClient;
import com.adpdigital.push.PushMessage;

public class PushMessageReceiver extends WakefulBroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {
Bundle messageData = intent.getExtras();
String channel = messageData.getString(AdpPushClient.PUSH_MSG_RECEIVED_TOPIC);
String body = messageData.getString(AdpPushClient.PUSH_MSG_RECEIVED_MSG);
PushMessage push = PushMessage.fromJson(body, channel);
handleNewMessage(push);
completeWakefulIntent(intent);
}


private void handleNewMessage(PushMessage message) {
// write your code to handle new message
}
}
@@ -0,0 +1,56 @@
package com.adpdigital.chabok.starter;

import android.app.Application;

import com.adpdigital.push.AdpPushClient;


public class StarterApp extends Application {

// private static final String YOUR_APP_ID = "YOUR_APP_ID/SENDER_ID";
private static final String YOUR_APP_ID = "torjungaj/1078814764250";
// private static final String YOUR_API_KEY = "YOUR_API_KEY";
private static final String YOUR_API_KEY = "e3772e0734e26b4ea39a12fe93764db095face28";
// private static final String SDK_USERNAME = "SDK_USERNAME";
private static final String SDK_USERNAME = "nigitdosvet";
// private static final String SDK_PASSWORD = "SDK_PASSWORD";
private static final String SDK_PASSWORD = "doiwamahhij";

private AdpPushClient chabok = null;

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

private synchronized void initPushClient() {
if (chabok == null) {
chabok = AdpPushClient.init(
getApplicationContext(),
MainActivity.class,
YOUR_APP_ID,
YOUR_API_KEY,
SDK_USERNAME,
SDK_PASSWORD
);
chabok.setDevelopment(true);
chabok.register("adpdigital.chabok");
}
}

public synchronized AdpPushClient getPushClient() throws IllegalStateException {
if (chabok == null) {
throw new IllegalStateException("Adp Push Client not initialized");
}
return chabok;
}

@Override
public void onTerminate() {
if (chabok != null)
chabok.dismiss();

super.onTerminate();
}
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid
android:color="@color/connected_status"/>

<size
android:width="250dp"
android:height="250dp"/>
</shape>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid
android:color="@color/connecting_status"/>

<size
android:width="250dp"
android:height="250dp"/>
</shape>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid
android:color="@color/disconnected_status"/>

<size
android:width="250dp"
android:height="250dp"/>
</shape>

0 comments on commit 61852d2

Please sign in to comment.
You can’t perform that action at this time.