diff --git a/SampleEasyLocator/.gitignore b/SampleEasyLocator/.gitignore
new file mode 100644
index 0000000..39fb081
--- /dev/null
+++ b/SampleEasyLocator/.gitignore
@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/SampleEasyLocator/.idea/compiler.xml b/SampleEasyLocator/.idea/compiler.xml
new file mode 100644
index 0000000..96cc43e
--- /dev/null
+++ b/SampleEasyLocator/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/copyright/profiles_settings.xml b/SampleEasyLocator/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/SampleEasyLocator/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/encodings.xml b/SampleEasyLocator/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/SampleEasyLocator/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/gradle.xml b/SampleEasyLocator/.idea/gradle.xml
new file mode 100644
index 0000000..152cbe0
--- /dev/null
+++ b/SampleEasyLocator/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/misc.xml b/SampleEasyLocator/.idea/misc.xml
new file mode 100644
index 0000000..5d19981
--- /dev/null
+++ b/SampleEasyLocator/.idea/misc.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/modules.xml b/SampleEasyLocator/.idea/modules.xml
new file mode 100644
index 0000000..2528420
--- /dev/null
+++ b/SampleEasyLocator/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/.idea/runConfigurations.xml b/SampleEasyLocator/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/SampleEasyLocator/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/app/.gitignore b/SampleEasyLocator/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/SampleEasyLocator/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/SampleEasyLocator/app/build.gradle b/SampleEasyLocator/app/build.gradle
new file mode 100644
index 0000000..202d646
--- /dev/null
+++ b/SampleEasyLocator/app/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+ defaultConfig {
+ applicationId "com.pureix.sampleeasylocator"
+ minSdkVersion 15
+ targetSdkVersion 25
+ 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:25.1.0'
+ compile 'com.android.support:design:25.1.0'
+ testCompile 'junit:junit:4.12'
+ compile project(path: ':easylocator')
+}
diff --git a/SampleEasyLocator/app/proguard-rules.pro b/SampleEasyLocator/app/proguard-rules.pro
new file mode 100644
index 0000000..41afecb
--- /dev/null
+++ b/SampleEasyLocator/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\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 *;
+#}
diff --git a/SampleEasyLocator/app/src/androidTest/java/com/pureix/sampleeasylocator/ExampleInstrumentedTest.java b/SampleEasyLocator/app/src/androidTest/java/com/pureix/sampleeasylocator/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..6d272c8
--- /dev/null
+++ b/SampleEasyLocator/app/src/androidTest/java/com/pureix/sampleeasylocator/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.pureix.sampleeasylocator;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.pureix.sampleeasylocator", appContext.getPackageName());
+ }
+}
diff --git a/SampleEasyLocator/app/src/main/AndroidManifest.xml b/SampleEasyLocator/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..9129888
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/AndroidManifest.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java b/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java
new file mode 100644
index 0000000..14987fa
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/java/com/pureix/sampleeasylocator/MainActivity.java
@@ -0,0 +1,127 @@
+package com.pureix.sampleeasylocator;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.View;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+import com.google.android.gms.location.DetectedActivity;
+import com.pureix.easylocator.controller.service.ActivityRecognitionAPI;
+import com.pureix.easylocator.controller.service.BatteryAPI;
+import com.pureix.easylocator.controller.service.InternetAPI;
+import com.pureix.easylocator.controller.service.LocationAPI;
+import com.pureix.easylocator.service.batteryService.listener.BatteryReceiverListener;
+import com.pureix.easylocator.service.activityRecognitionService.listener.ActivityRecognitionListener;
+import com.pureix.easylocator.service.internetService.listener.ConnectivityReceiverListener;
+import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ActivityRecognitionAPI.setActivitiesRecognitionListener(new ActivityRecognitionListener() {
+ @Override
+ public void updateDetectedActivitiesList(ArrayList updatedActivities) {
+ //Toast.makeText(MainActivity.this, "okay", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ InternetAPI.networkListener(new ConnectivityReceiverListener() {
+ @Override
+ public void onNetworkConnectionChanged(boolean isConnected, int connectionProvider) {
+ //Toast.makeText(MainActivity.this, ""+isConnected, Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ BatteryAPI.start(MainActivity.this);
+ BatteryAPI.batteryListener(new BatteryReceiverListener() {
+ @Override
+ public void onBatteryInformationChanged(int level, int scale, int temperature, int voltage, float batteryPct, int status, boolean isCharging, int chargePlug, boolean usbCharge, boolean acCharge) {
+ //Toast.makeText(MainActivity.this, ""+level, Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ LocationAPI.setLocationReceiverListener(new LocationReceiverListener() {
+ @Override
+ public void getLastKnownLocation(Location location) {
+ Toast.makeText(MainActivity.this, "Broadlocationss getLastKnownLocation "+location.toString()+"", Toast.LENGTH_SHORT).show();
+// Log.d("Taag", "Broadlocationss getLastKnownLocation "+location.toString()+"");
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ Toast.makeText(MainActivity.this, "Broadlocationss onLocationChanged "+location.toString()+"", Toast.LENGTH_SHORT).show();
+ Log.d("Taag", "Broadlocationss onLocationChanged "+location.toString()+"");
+ }
+ });
+
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show();
+ }
+ });
+ }
+
+ @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;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ ActivityRecognitionAPI.start(MainActivity.this);
+ LocationAPI.start(MainActivity.this);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ ActivityRecognitionAPI.pause(MainActivity.this);
+ LocationAPI.pause(MainActivity.this);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String permissions[],
+ int[] grantResults) {
+ LocationAPI.onRequestPermissionsResult(requestCode, permissions,
+ grantResults);
+ }
+}
diff --git a/SampleEasyLocator/app/src/main/res/layout/activity_main.xml b/SampleEasyLocator/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..8078ecb
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SampleEasyLocator/app/src/main/res/layout/content_main.xml b/SampleEasyLocator/app/src/main/res/layout/content_main.xml
new file mode 100644
index 0000000..89506fb
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/layout/content_main.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
diff --git a/SampleEasyLocator/app/src/main/res/menu/menu_main.xml b/SampleEasyLocator/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..15f24e8
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,10 @@
+
diff --git a/SampleEasyLocator/app/src/main/res/mipmap-hdpi/ic_launcher.png b/SampleEasyLocator/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/SampleEasyLocator/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/SampleEasyLocator/app/src/main/res/mipmap-mdpi/ic_launcher.png b/SampleEasyLocator/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/SampleEasyLocator/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/SampleEasyLocator/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/SampleEasyLocator/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/SampleEasyLocator/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/SampleEasyLocator/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/SampleEasyLocator/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/SampleEasyLocator/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/SampleEasyLocator/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/SampleEasyLocator/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/SampleEasyLocator/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/SampleEasyLocator/app/src/main/res/values-v21/styles.xml b/SampleEasyLocator/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..dbbdd40
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/SampleEasyLocator/app/src/main/res/values-w820dp/dimens.xml b/SampleEasyLocator/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 64dp
+
diff --git a/SampleEasyLocator/app/src/main/res/values/colors.xml b/SampleEasyLocator/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/SampleEasyLocator/app/src/main/res/values/dimens.xml b/SampleEasyLocator/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..812cb7b
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 16dp
+ 16dp
+ 16dp
+
diff --git a/SampleEasyLocator/app/src/main/res/values/strings.xml b/SampleEasyLocator/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..110821d
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+ Sample Easy Locator
+ Settings
+
diff --git a/SampleEasyLocator/app/src/main/res/values/styles.xml b/SampleEasyLocator/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..545b9c6
--- /dev/null
+++ b/SampleEasyLocator/app/src/main/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SampleEasyLocator/app/src/test/java/com/pureix/sampleeasylocator/ExampleUnitTest.java b/SampleEasyLocator/app/src/test/java/com/pureix/sampleeasylocator/ExampleUnitTest.java
new file mode 100644
index 0000000..6231359
--- /dev/null
+++ b/SampleEasyLocator/app/src/test/java/com/pureix/sampleeasylocator/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.pureix.sampleeasylocator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/SampleEasyLocator/build.gradle b/SampleEasyLocator/build.gradle
new file mode 100644
index 0000000..74b2ab0
--- /dev/null
+++ b/SampleEasyLocator/build.gradle
@@ -0,0 +1,23 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.2.3'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/SampleEasyLocator/easylocator/.gitignore b/SampleEasyLocator/easylocator/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/SampleEasyLocator/easylocator/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/SampleEasyLocator/easylocator/build.gradle b/SampleEasyLocator/easylocator/build.gradle
new file mode 100644
index 0000000..92a7279
--- /dev/null
+++ b/SampleEasyLocator/easylocator/build.gradle
@@ -0,0 +1,45 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+
+ defaultConfig {
+ minSdkVersion 15
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ // Enabling multidex support.
+ multiDexEnabled true
+ }
+// dexOptions {
+// incremental true
+// //javaMaxHeapSize "2048M"
+// javaMaxHeapSize "4g"
+// }
+ 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:25.1.0'
+ testCompile 'junit:junit:4.12'
+
+ //==========Add multidex for running on all mobiles=================
+ compile 'com.android.support:multidex:1.0.1'
+
+ compile 'com.google.android.gms:play-services:10.0.1'
+
+ compile 'com.google.code.gson:gson:2.8.0'
+}
diff --git a/SampleEasyLocator/easylocator/proguard-rules.pro b/SampleEasyLocator/easylocator/proguard-rules.pro
new file mode 100644
index 0000000..41afecb
--- /dev/null
+++ b/SampleEasyLocator/easylocator/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\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 *;
+#}
diff --git a/SampleEasyLocator/easylocator/src/androidTest/java/com/pureix/easylocator/ExampleInstrumentedTest.java b/SampleEasyLocator/easylocator/src/androidTest/java/com/pureix/easylocator/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..56adac0
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/androidTest/java/com/pureix/easylocator/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.pureix.easylocator;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.pureix.easylocator.test", appContext.getPackageName());
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml b/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2c64fa3
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/AndroidManifest.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/BaseApplication.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/BaseApplication.java
new file mode 100644
index 0000000..cb2bf9c
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/BaseApplication.java
@@ -0,0 +1,41 @@
+package com.pureix.easylocator.applicationManger;
+
+import android.app.Application;
+import android.content.Context;
+import android.support.multidex.MultiDex;
+
+import com.pureix.easylocator.applicationManger.configuration.GlobalData;
+
+/**
+ * Created by MelDiSooQi on 5/10/2016.
+ */
+public class BaseApplication extends Application {
+
+ public static final String TAG = BaseApplication.class.getSimpleName();
+
+ private static BaseApplication mInstance;
+
+ public BaseApplication()
+ {
+ }
+
+ @Override
+ public void onCreate()
+ {
+ super.onCreate();
+ mInstance = this;
+ GlobalData.initialize(mInstance.getApplicationContext());
+ }
+
+ public static synchronized BaseApplication getInstance()
+ {
+ return mInstance;
+ }
+
+ protected void attachBaseContext(Context base)
+ {
+ super.attachBaseContext(base);
+ MultiDex.install(this);
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/GlobalData.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/GlobalData.java
new file mode 100644
index 0000000..bb02708
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/GlobalData.java
@@ -0,0 +1,26 @@
+package com.pureix.easylocator.applicationManger.configuration;
+
+import android.content.Context;
+/**
+ * Created by MelDiSooQi on 12/19/2015.
+ */
+
+public class GlobalData
+{
+ public static boolean isInitializeRun = false;
+
+ public static Context context ;
+
+ public static void initialize(Context context)
+ {
+ if(!isInitializeRun)
+ {
+ isInitializeRun = true;
+ //=================initialize=========================
+ //GlobalData.activity = activity;
+ GlobalData.context = context;//activity.getApplicationContext();
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/URLConstants.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/URLConstants.java
new file mode 100644
index 0000000..a02055c
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/applicationManger/configuration/URLConstants.java
@@ -0,0 +1,9 @@
+package com.pureix.easylocator.applicationManger.configuration;
+
+/**
+ * Created by MelDiSooQi on 5/11/2016.
+ */
+public class URLConstants
+{
+ public static final String BASE_URL = "http://api.themoviedb.org/3/";
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/ActivityRecognitionAPI.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/ActivityRecognitionAPI.java
new file mode 100644
index 0000000..456b7e1
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/ActivityRecognitionAPI.java
@@ -0,0 +1,37 @@
+package com.pureix.easylocator.controller.service;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.pureix.easylocator.service.activityRecognitionService.ActivitiesRecognitionService;
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.InitializeActivityRecognitionBroadcast;
+import com.pureix.easylocator.service.activityRecognitionService.listener.ActivityRecognitionListener;
+
+/**
+ * Created by MelDiSooQi on 2/11/2017.
+ */
+
+public class ActivityRecognitionAPI
+{
+ private static InitializeActivityRecognitionBroadcast broadcast;
+ public static ActivityRecognitionListener activitiesRecognitionListener;
+
+ public static void start(Context context)
+ {
+ Intent i = new Intent(context, ActivitiesRecognitionService.class);
+ context.stopService(i);
+ context.startService(i);
+
+ broadcast = new InitializeActivityRecognitionBroadcast();
+ broadcast.onResume(context);
+ }
+
+ public static void pause(Context context)
+ {
+ broadcast.onPause(context);
+ }
+
+ public static void setActivitiesRecognitionListener(ActivityRecognitionListener activitiesRecognitionListener) {
+ ActivityRecognitionAPI.activitiesRecognitionListener = activitiesRecognitionListener;
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/BatteryAPI.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/BatteryAPI.java
new file mode 100644
index 0000000..e9077ff
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/BatteryAPI.java
@@ -0,0 +1,41 @@
+package com.pureix.easylocator.controller.service;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.pureix.easylocator.service.activityRecognitionService.ActivitiesRecognitionService;
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.InitializeActivityRecognitionBroadcast;
+import com.pureix.easylocator.service.batteryService.BatteryService;
+import com.pureix.easylocator.service.batteryService.broadcastReceiver.BatteryStateReceiver;
+import com.pureix.easylocator.service.batteryService.broadcastReceiver.InitializeBatteryBroadcast;
+import com.pureix.easylocator.service.batteryService.listener.BatteryReceiverListener;
+
+/**
+ * Created by MelDiSooQi on 2/11/2017.
+ */
+
+public class BatteryAPI {
+
+ private static InitializeBatteryBroadcast broadcast;
+ public static BatteryReceiverListener batteryReceiverListener;
+
+ public static void start(Context context)
+ {
+ Intent i = new Intent(context, BatteryService.class);
+ context.stopService(i);
+ context.startService(i);
+
+// broadcast = new InitializeBatteryBroadcast();
+// broadcast.onResume(context);
+ }
+
+ public static void pause(Context context)
+ {
+// broadcast.onPause(context);
+ }
+
+ public static void batteryListener(BatteryReceiverListener batteryReceiverListener) {
+ BatteryAPI
+ .batteryReceiverListener = batteryReceiverListener;
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/InternetAPI.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/InternetAPI.java
new file mode 100644
index 0000000..913f19f
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/InternetAPI.java
@@ -0,0 +1,31 @@
+package com.pureix.easylocator.controller.service;
+
+import android.content.Context;
+
+import com.pureix.easylocator.service.internetService.broadcastReceiver.ConnectivityReceiver;
+import com.pureix.easylocator.service.internetService.listener.ConnectivityReceiverListener;
+
+/**
+ * Created by MelDiSooQi on 2/11/2017.
+ */
+
+public class InternetAPI {
+
+ public static int WIFI = 1;
+ public static int MOBILE = 2;
+ public static int NOT_CONNECTED = 0;
+
+ public static ConnectivityReceiverListener connectivityReceiverListener;
+
+ public static void networkListener(ConnectivityReceiverListener connectivityReceiverListener) {
+ InternetAPI.connectivityReceiverListener = connectivityReceiverListener;
+ }
+
+ public static boolean isConnected(Context context) {
+ return ConnectivityReceiver.isConnected(context);
+ }
+
+ public static int getNetworkProvider(Context context) {
+ return ConnectivityReceiver.getNetworkProvider(context);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/LocationAPI.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/LocationAPI.java
new file mode 100644
index 0000000..68c851b
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/controller/service/LocationAPI.java
@@ -0,0 +1,53 @@
+package com.pureix.easylocator.controller.service;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+
+import com.pureix.easylocator.service.activityRecognitionService.ActivitiesRecognitionService;
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.InitializeActivityRecognitionBroadcast;
+import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
+import com.pureix.easylocator.service.locatonService.LocationService;
+import com.pureix.easylocator.service.locatonService.broadcastReceiver.InitializeLocationBroadcast;
+import com.pureix.easylocator.service.locatonService.permission.LocationPermission;
+
+/**
+ * Created by MelDiSooQi on 2/11/2017.
+ */
+
+public class LocationAPI
+{
+ private static InitializeLocationBroadcast broadcast;
+ private static LocationPermission locationPermission;
+ public static LocationReceiverListener locationReceiverListener;
+
+
+ public static void start(Context context)
+ {
+ broadcast = new InitializeLocationBroadcast();
+ broadcast.onResume(context);
+
+ Intent i = new Intent(context, LocationService.class);
+ context.stopService(i);
+ context.startService(i);
+ }
+
+ public static void pause(Context context)
+ {
+ broadcast.onPause(context);
+ }
+
+ public static void setLocationReceiverListener(LocationReceiverListener locationReceiverListener) {
+ LocationAPI.locationReceiverListener = locationReceiverListener;
+ }
+
+ public static void requestPermission(Activity activity){
+ locationPermission = new LocationPermission(activity);
+ }
+
+ public static void onRequestPermissionsResult(int requestCode, String permissions[],
+ int[] grantResults) {
+ locationPermission.onRequestPermissionsResult(requestCode, permissions,
+ grantResults);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorage.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorage.java
new file mode 100644
index 0000000..d9b639d
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorage.java
@@ -0,0 +1,181 @@
+package com.pureix.easylocator.model.storage;
+
+import android.content.Context;
+import android.preference.PreferenceManager;
+
+import com.pureix.easylocator.model.utility.StringUtilitiesHandler;
+
+import java.util.Set;
+
+public class LocalStorage
+{
+//===================================================================================================================
+// public static String PREFERENCE_TYPE_BOOLEAN = "Boolean";
+// public static String PREFERENCE_TYPE_FLOAT = "Float";
+// public static String PREFERENCE_TYPE_INT = "Int";
+// public static String PREFERENCE_TYPE_LONG = "Long";
+// public static String PREFERENCE_TYPE_STRING = "String";
+// public static String PREFERENCE_TYPE_STRINGSET = "StringSet";
+
+ public static boolean setPreference(Context context, String key, Object value)
+ {
+ //o.getClass().getName();
+ //o.getClass().getSimpleName()
+ PreferenceManager.getDefaultSharedPreferences(context).edit().putString(key+"type", value.getClass().getName()).commit();
+
+ if(value.getClass() == Boolean.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean (key, (Boolean) value).commit();
+ }
+ else if(value.getClass() == Float.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putFloat(key, (Float) value).commit();
+ }
+ else if(value.getClass() == Integer.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putInt(key, (Integer) value).commit();
+ }
+ else if(value.getClass() == Long.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putLong(key, (Long) value).commit();
+ }
+ else if(value.getClass() == String.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putString(key, (String) value).commit();
+ }
+ else if(value.getClass() == Set.class)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().putStringSet(key, (Set) value).commit();
+ }
+ else
+ {
+ return false;
+ }
+ }
+//888888888888888888888888888888888888888888888888888888888
+ public static Object getPreference(Context context, String key)
+ {
+ String type = PreferenceManager.getDefaultSharedPreferences(context).getString(key+"type", null);
+
+ if(type != null)
+ {
+ if(StringUtilitiesHandler.StringEqual(type, Boolean.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Float.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getFloat(key, 0);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Integer.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getInt(key, 0);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Long.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getLong(key, 0);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, String.class.getName()))
+ {
+ //null == "defaultStringIfNothingFound"
+ return PreferenceManager.getDefaultSharedPreferences(context).getString(key, null);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Set.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getStringSet(key, null);
+ }
+ else
+ {
+ return null;
+ }
+ }else
+ {
+ return null;
+ }
+
+ }
+//888888888888888888888888888888888888888888888888888888888
+ public static Object getPreference(Context context, String key, Object defaultValue)
+ {
+ String type = PreferenceManager.getDefaultSharedPreferences(context).getString(key+"type", null);
+
+ if(type != null)
+ {
+ if(StringUtilitiesHandler.StringEqual(type, Boolean.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, (Boolean) defaultValue);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Float.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getFloat(key, (Float) defaultValue);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Integer.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getInt(key, (Integer) defaultValue);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Long.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getLong(key, (Long) defaultValue);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, String.class.getName()))
+ {
+ //null == "defaultStringIfNothingFound"
+ return PreferenceManager.getDefaultSharedPreferences(context).getString(key, (String) defaultValue);
+ }
+ else if(StringUtilitiesHandler.StringEqual(type, Set.class.getName()))
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).getStringSet(key, (Set) defaultValue);
+ }
+ else
+ {
+ return null;
+ }
+ }else
+ {
+// if(defaultValue.getClass() == Boolean.class)
+// {
+// return (Boolean) defaultValue;
+// }
+// else if(defaultValue.getClass() == Float.class)
+// {
+// return (Float) defaultValue;
+// }
+// else if(defaultValue.getClass() == Integer.class)
+// {
+// return (Integer) defaultValue;
+// }
+// else if(defaultValue.getClass() == Long.class)
+// {
+// return (Long) defaultValue;
+// }
+// else if(defaultValue.getClass() == String.class)
+// {
+// return (String) defaultValue;
+// }
+// else if(defaultValue.getClass() == Set.class)
+// {
+// return (Set) defaultValue;
+// }else
+// {
+ return defaultValue;
+// }
+ }
+ }
+//888888888888888888888888888888888888888888888888888888888
+ public static boolean removePreference(Context context, String key)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().remove(key).commit();
+ }
+//888888888888888888888888888888888888888888888888888888888
+ public static boolean ClearPreference(Context context)
+ {
+ return PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
+ }
+//888888888888888888888888888888888888888888888888888888888
+ public static boolean ClearPreferenceByApply(Context context)
+ {
+ PreferenceManager.getDefaultSharedPreferences(context).edit().clear().apply();
+ return true;
+ }
+//===================================================================================================================
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorageConstant.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorageConstant.java
new file mode 100644
index 0000000..4bf6ccc
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/storage/LocalStorageConstant.java
@@ -0,0 +1,10 @@
+package com.pureix.easylocator.model.storage;
+
+/**
+ * Created by M.Hayle on 6/29/2016.
+ */
+public class LocalStorageConstant
+{
+ //public final static String
+ public final static String LAST_KNOWN_LOCATION = "LAST_KNOWN_LOCATION";
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/utility/StringUtilitiesHandler.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/utility/StringUtilitiesHandler.java
new file mode 100644
index 0000000..0435bfe
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/model/utility/StringUtilitiesHandler.java
@@ -0,0 +1,21 @@
+package com.pureix.easylocator.model.utility;
+
+/**
+ * Created by M.Hayle on 6/22/2016.
+ */
+public class StringUtilitiesHandler
+{
+ //===================================================================================================================
+ public static boolean StringEqual(String str1, String Str2)
+ {
+ //if(str1.compareTo(Str2) == 0)
+ if(str1.equalsIgnoreCase(Str2))
+ {
+ return true;
+ }else
+ {
+ return false;
+ }
+ }
+ //===================================================================================================================
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionIntentService.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionIntentService.java
new file mode 100644
index 0000000..0434bb1
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionIntentService.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2014 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.pureix.easylocator.service.activityRecognitionService;
+
+import android.app.IntentService;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.google.android.gms.location.ActivityRecognitionResult;
+import com.google.android.gms.location.DetectedActivity;
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.ActivityRecognitionBroadcast;
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.ActivityRecognitionSender;
+
+import java.util.ArrayList;
+
+/**
+ * IntentService for handling incoming intents that are generated as a result of requesting
+ * activity updates using
+ * {@link com.google.android.gms.location.ActivityRecognitionApi#requestActivityUpdates}.
+ */
+public class ActivitiesRecognitionIntentService extends IntentService {
+
+ protected static final String TAG = "DetectedActivitiesIS";
+
+ private Context context;
+ private ActivityRecognitionSender sender;
+
+ /**
+ * This constructor is required, and calls the super IntentService(String)
+ * constructor with the name for a worker thread.
+ */
+ public ActivitiesRecognitionIntentService() {
+ // Use the TAG to name the worker thread.
+ super(TAG);
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ this.context = getApplicationContext();
+
+ sender = new ActivityRecognitionSender(context,
+ ActivityRecognitionBroadcast.class);
+ }
+
+ /**
+ * Handles incoming intents.
+ * @param intent The Intent is provided (inside a PendingIntent) when requestActivityUpdates()
+ * is called.
+ */
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
+
+ // Get the list of the probable activities associated with the current state of the
+ // device. Each activity is associated with a confidence level, which is an int between
+ // 0 and 100.
+ ArrayList detectedActivities = (ArrayList) result.getProbableActivities();
+
+ // Log each activity.
+ Log.i(TAG, "activities detected");
+ for (DetectedActivity da: detectedActivities) {
+ Log.i(TAG, Constants.getActivityString(
+ getApplicationContext(),
+ da.getType()) + " " + da.getConfidence() + "%"
+ );
+ }
+
+ // Broadcast the list of detected activities.
+ sender.sendDetectedActivitiesToApp(detectedActivities);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionService.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionService.java
new file mode 100644
index 0000000..de64c8d
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/ActivitiesRecognitionService.java
@@ -0,0 +1,262 @@
+package com.pureix.easylocator.service.activityRecognitionService;
+
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.PowerManager;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GoogleApiAvailability;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.common.api.ResultCallback;
+import com.google.android.gms.common.api.Status;
+import com.google.android.gms.location.ActivityRecognition;
+
+public class ActivitiesRecognitionService extends Service
+ implements GoogleApiClient.ConnectionCallbacks,
+ GoogleApiClient.OnConnectionFailedListener,
+ ResultCallback
+{
+ private String TAG = "DetectedActivitiesTAG";
+
+ // Binder given to clients
+ private IBinder mBinder = new LocalBinder();
+ private PowerManager.WakeLock mWakeLock;
+
+ private Boolean servicesAvailable = false;
+
+ // Flag that indicates if a request is underway.
+ private boolean mInProgress;
+
+ private GoogleApiClient mGoogleApiClient;
+ private Context context;
+
+ /**
+ * Class used for the client Binder. Because we know this service always
+ * runs in the same process as its clients, we don't need to deal with IPC.
+ */
+ public class LocalBinder extends Binder {
+ public ActivitiesRecognitionService getService() {
+ // Return this instance of LocalService so clients can call public methods
+ return ActivitiesRecognitionService.this;
+ }
+ }
+ public ActivitiesRecognitionService() {
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ super.onStartCommand(intent, flags, startId);
+ Log.e(TAG, "onStartCommand");
+
+ PowerManager mgr = (PowerManager) getSystemService(Context.POWER_SERVICE);
+
+ /*
+ WakeLock is reference counted so we don't want to create multiple WakeLocks. So do a check before initializing and acquiring.
+
+ This will fix the "java.lang.Exception: WakeLock finalized while still held: MyWakeLock" error that you may find.
+ */
+ if (this.mWakeLock == null) { //**Added this
+ this.mWakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
+ }
+
+ if (!this.mWakeLock.isHeld()) { //**Added this
+ this.mWakeLock.acquire();
+ }
+
+ if (!servicesAvailable || mGoogleApiClient.isConnected() || mInProgress)
+ return START_STICKY;
+
+ setUpLocationClientIfNeeded();
+ if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting() && !mInProgress) {
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Started", Constants.LOG_FILE);
+ mInProgress = true;
+ mGoogleApiClient.connect();
+ }
+
+ return START_STICKY;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.e(TAG, "onCreate");
+ context = getApplicationContext();
+
+// senderHandler = new LocationBuiltInSenderHandler(context,
+// LocationBroadcast.class);
+
+ mInProgress = false;
+
+ servicesAvailable = servicesConnected();
+
+ /*
+ * Create a new location client, using the enclosing class to
+ * handle callbacks.
+ */
+ setUpLocationClientIfNeeded();
+ }
+
+ private boolean servicesConnected() {
+
+ // Check that Google Play services is available
+ int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
+
+ // If Google Play services is available
+ if (ConnectionResult.SUCCESS == resultCode) {
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+
+ private boolean checkPlayServices() {
+ GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
+ int result = googleAPI.isGooglePlayServicesAvailable(this);
+ if (result != ConnectionResult.SUCCESS) {
+ if (googleAPI.isUserResolvableError(result)) {
+ //googleAPI.getErrorDialog(this, result,
+ // PLAY_SERVICES_RESOLUTION_REQUEST).show();
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ private void setUpLocationClientIfNeeded() {
+ if (mGoogleApiClient == null)
+ buildGoogleApiClient();
+ }
+
+ /*
+ * Create a new location client, using the enclosing class to
+ * handle callbacks.
+ */
+ protected synchronized void buildGoogleApiClient() {
+ this.mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .addApi(ActivityRecognition.API)
+ .build();
+ }
+
+ /*
+ * Called by Location Services when the request to connect the
+ * client finishes successfully. At this point, you can
+ * request the current location or start periodic updates
+ */
+ @Override
+ public void onConnected(@Nullable Bundle bundle) {
+ Log.e(TAG, "onConnected");
+ Log.e(TAG, "Connected to GoogleApiClient");
+// try {
+// Location location = getLastLocation();
+// sendLocationToBroadcast(location);
+// if(locationReceiverListener !=null) {
+// locationReceiverListener.getLastKnownLocation(location);
+// locationReceiverListener.onLocationChanged(location);
+// }
+// } catch (Exception e) {
+// }
+
+ ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(
+ mGoogleApiClient,
+ Constants.DETECTION_INTERVAL_IN_MILLISECONDS,
+ getActivityDetectionPendingIntent()
+ ).setResultCallback(this);
+
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Connected", Constants.LOG_FILE);
+ }
+
+ /**
+ * Gets a PendingIntent to be sent for each activity detection.
+ */
+ private PendingIntent getActivityDetectionPendingIntent() {
+ Intent intent = new Intent(this, ActivitiesRecognitionIntentService.class);
+
+ // We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling
+ // requestActivityUpdates() and removeActivityUpdates().
+ return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ /*
+ * Called by Location Services if the connection to the
+ * location client drops because of an error.
+ */
+ @Override
+ public void onConnectionSuspended(int i) {
+ Log.e(TAG, "onConnectionSuspended");
+ // Turn off the request flag
+ mInProgress = false;
+ // Destroy the current location client
+ mGoogleApiClient = null;
+ // Display the connection status
+ // Toast.makeText(this, DateFormat.getDateTimeInstance().format(new Date()) + ": Disconnected. Please re-connect.", Toast.LENGTH_SHORT).show();
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Disconnected", Constants.LOG_FILE);
+ }
+
+ /*
+ * Called by Location Services if the attempt to
+ * Location Services fails.
+ */
+ @Override
+ public void onConnectionFailed(@NonNull ConnectionResult connectionResult)
+ {
+ Log.e(TAG, "onConnectionFailed");
+ Log.i(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + connectionResult.getErrorCode());
+ mInProgress = false;
+
+ /*
+ * Google Play services can resolve some errors it detects.
+ * If the error has a resolution, try sending an Intent to
+ * start a Google Play services activity that can resolve
+ * error.
+ */
+ if (connectionResult.hasResolution()) {
+
+ // If no resolution is available, display an error dialog
+ } else {
+
+ }
+ }
+
+ @Override
+ public void onResult(@NonNull Status status) {
+ if (status.isSuccess()) {
+// Toast.makeText(this, "Added", Toast.LENGTH_SHORT).show();
+// // Toggle the status of activity updates requested, and save in shared preferences.
+// boolean requestingUpdates = !getUpdatesRequestedState();
+// setUpdatesRequestedState(requestingUpdates);
+//
+// // Update the UI. Requesting activity updates enables the Remove Activity Updates
+// // button, and removing activity updates enables the Add Activity Updates button.
+// setButtonsEnabledState();
+//
+// Toast.makeText(
+// this,
+// getString(requestingUpdates ? R.string.activity_updates_added :
+// R.string.activity_updates_removed),
+// Toast.LENGTH_SHORT
+// ).show();
+ } else {
+ Log.e(TAG, "Error adding or removing activity detection: " + status.getStatusMessage());
+ }
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/Constants.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/Constants.java
new file mode 100644
index 0000000..89932cb
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/Constants.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright 2014 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.pureix.easylocator.service.activityRecognitionService;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import com.google.android.gms.location.DetectedActivity;
+import com.pureix.easylocator.R;
+
+/**
+ * Constants used in this sample.
+ */
+public final class Constants {
+
+ private Constants() {
+ }
+
+ public static final String PACKAGE_NAME = "com.google.android.gms.location.activityrecognition";
+
+ public static final String BROADCAST_ACTION = PACKAGE_NAME + ".BROADCAST_ACTION";
+
+ public static final String ACTIVITY_EXTRA = PACKAGE_NAME + ".ACTIVITY_EXTRA";
+
+ public static final String SHARED_PREFERENCES_NAME = PACKAGE_NAME + ".SHARED_PREFERENCES";
+
+ public static final String ACTIVITY_UPDATES_REQUESTED_KEY = PACKAGE_NAME +
+ ".ACTIVITY_UPDATES_REQUESTED";
+
+ public static final String DETECTED_ACTIVITIES = PACKAGE_NAME + ".DETECTED_ACTIVITIES";
+
+ /**
+ * The desired time between activity detections. Larger values result in fewer activity
+ * detections while improving battery life. A value of 0 results in activity detections at the
+ * fastest possible rate. Getting frequent updates negatively impact battery life and a real
+ * app may prefer to request less frequent updates.
+ */
+ public static final long DETECTION_INTERVAL_IN_MILLISECONDS = 0;
+
+ /**
+ * List of DetectedActivity types that we monitor in this sample.
+ */
+ protected static final int[] MONITORED_ACTIVITIES = {
+ DetectedActivity.STILL,
+ DetectedActivity.ON_FOOT,
+ DetectedActivity.WALKING,
+ DetectedActivity.RUNNING,
+ DetectedActivity.ON_BICYCLE,
+ DetectedActivity.IN_VEHICLE,
+ DetectedActivity.TILTING,
+ DetectedActivity.UNKNOWN
+ };
+
+ /**
+ * Returns a human readable String corresponding to a detected activity type.
+ */
+ public static String getActivityString(Context context, int detectedActivityType) {
+ Resources resources = context.getResources();
+ switch(detectedActivityType) {
+ case DetectedActivity.IN_VEHICLE:
+ return resources.getString(R.string.in_vehicle);
+ case DetectedActivity.ON_BICYCLE:
+ return resources.getString(R.string.on_bicycle);
+ case DetectedActivity.ON_FOOT:
+ return resources.getString(R.string.on_foot);
+ case DetectedActivity.RUNNING:
+ return resources.getString(R.string.running);
+ case DetectedActivity.STILL:
+ return resources.getString(R.string.still);
+ case DetectedActivity.TILTING:
+ return resources.getString(R.string.tilting);
+ case DetectedActivity.UNKNOWN:
+ return resources.getString(R.string.unknown);
+ case DetectedActivity.WALKING:
+ return resources.getString(R.string.walking);
+ default:
+ return resources.getString(R.string.unidentifiable_activity, detectedActivityType);
+ }
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionBroadcast.java
new file mode 100644
index 0000000..2895ab0
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionBroadcast.java
@@ -0,0 +1,46 @@
+package com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.google.android.gms.location.DetectedActivity;
+import com.pureix.easylocator.controller.service.ActivityRecognitionAPI;
+import com.pureix.easylocator.service.activityRecognitionService.Constants;
+
+import java.util.ArrayList;
+
+public class ActivityRecognitionBroadcast extends BroadcastReceiver
+{
+ protected static final String TAG = "activity-detection-response-receiver";
+
+ private ArrayList mDetectedActivities;
+
+ public ActivityRecognitionBroadcast() {
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ ArrayList updatedActivities =
+ intent.getParcelableArrayListExtra(Constants.ACTIVITY_EXTRA);
+
+ Log.d("mezoTag", "okay here we are hhhhh");
+
+ Toast.makeText(context, "okay here we are hhhhh", Toast.LENGTH_SHORT).show();
+// mDetectedActivities = new ArrayList();
+//
+// // Set the confidence level of each monitored activity to zero.
+// for (int i = 0; i < Constants.MONITORED_ACTIVITIES.length; i++) {
+// mDetectedActivities.add(new DetectedActivity(Constants.MONITORED_ACTIVITIES[i], 0));
+// }
+
+ if(ActivityRecognitionAPI.activitiesRecognitionListener != null) {
+ ActivityRecognitionAPI
+ .activitiesRecognitionListener
+ .updateDetectedActivitiesList(updatedActivities);
+ }
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionSender.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionSender.java
new file mode 100644
index 0000000..078212c
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/ActivityRecognitionSender.java
@@ -0,0 +1,47 @@
+package com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.google.android.gms.location.DetectedActivity;
+import com.pureix.easylocator.service.activityRecognitionService.Constants;
+import com.pureix.easylocator.service.locatonService.ServicesConstant;
+
+import java.util.ArrayList;
+
+/**
+ * Created by MelDiSooQi on 7/16/2016.
+ */
+public class ActivityRecognitionSender
+{
+ private final Context context;
+ private final Class> aClass;
+ private Intent intent;
+
+ public ActivityRecognitionSender(Context context, Class> aClass)
+ {
+ this.context = context;
+ this.aClass = aClass;
+ this.intent = new Intent(context, aClass);
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+// public void sendLocationToApp(String jsonLocation)
+// {
+// intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant
+// .SERVICE_ID_SEND_JSON_LOCATION);
+// intent.putExtra(ServicesConstant.JSON_LOCATION , jsonLocation);
+//
+// context.sendBroadcast(intent);
+// }
+
+ public void sendDetectedActivitiesToApp(ArrayList detectedActivities)
+ {
+ intent.putExtra(Constants.ACTIVITY_EXTRA, detectedActivities);
+
+ context.sendBroadcast(intent);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/InitializeActivityRecognitionBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/InitializeActivityRecognitionBroadcast.java
new file mode 100644
index 0000000..7640234
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/broadcastReceiver/InitializeActivityRecognitionBroadcast.java
@@ -0,0 +1,64 @@
+package com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.IntentFilter;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class InitializeActivityRecognitionBroadcast
+{
+ private static ActivityRecognitionBroadcast broadcastReceiver = null;
+ private static Boolean isRegistered = false;
+
+ public InitializeActivityRecognitionBroadcast() {
+ initialize();
+ }
+
+ private void initialize()
+ {
+ broadcastReceiver = new ActivityRecognitionBroadcast();
+ }
+
+ public void onPause(Context context)
+ {
+ try {
+ if (isRegistered) {
+ context.unregisterReceiver(broadcastReceiver);
+ isRegistered = false;
+ }
+ }catch (Exception e)
+ {}
+ }
+
+ public void onResume(Context context)
+ {
+ if (!isRegistered)
+ {
+ String PACKAGE_NAME = "com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.ActivityRecognitionBroadcast";
+
+ context.registerReceiver(broadcastReceiver, new IntentFilter(PACKAGE_NAME));
+
+ isRegistered = true;
+ }
+ }
+
+
+
+ public static boolean isMyServiceRunning(Activity activity, Class> serviceClass)
+ {
+ ActivityManager manager = (ActivityManager) activity
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ for (ActivityManager.RunningServiceInfo service : manager
+ .getRunningServices(Integer.MAX_VALUE)) {
+ if (serviceClass.getName().equals(service.service.getClassName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/listener/ActivityRecognitionListener.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/listener/ActivityRecognitionListener.java
new file mode 100644
index 0000000..01bbc70
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/activityRecognitionService/listener/ActivityRecognitionListener.java
@@ -0,0 +1,13 @@
+package com.pureix.easylocator.service.activityRecognitionService.listener;
+
+import com.google.android.gms.location.DetectedActivity;
+
+import java.util.ArrayList;
+
+/**
+ * Created by MelDiSooQi on 2/11/2017.
+ */
+
+public interface ActivityRecognitionListener {
+ void updateDetectedActivitiesList(ArrayList updatedActivities);
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/BatteryService.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/BatteryService.java
new file mode 100644
index 0000000..9de100e
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/BatteryService.java
@@ -0,0 +1,58 @@
+package com.pureix.easylocator.service.batteryService;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.pureix.easylocator.service.batteryService.broadcastReceiver.BatteryStateReceiver;
+import com.pureix.easylocator.service.batteryService.broadcastReceiver.InitializeBatteryBroadcast;
+
+public class BatteryService extends Service {
+ private String TAG = "BatteryServiceTAG";
+
+ private Context context;
+// private BatteryStateReceiver batteryStateReceiver;
+ private static InitializeBatteryBroadcast broadcast;
+
+ public BatteryService() {
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // TODO: Return the communication channel to the service.
+ //throw new UnsupportedOperationException("Not yet implemented");
+ return null;
+ }
+
+ @Override
+ public void onCreate() {
+ Log.e(TAG, "onCreate");
+ super.onCreate();
+ context = getApplicationContext();
+// batteryStateReceiver
+// = new BatteryStateReceiver();
+// batteryStateReceiver.onResume(context);
+
+ broadcast = new InitializeBatteryBroadcast();
+ broadcast.onResume(context);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Log.e(TAG, "onStartCommand");
+ super.onStartCommand(intent, flags, startId);
+
+
+ return START_STICKY;
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.e(TAG, "onDestroy");
+// batteryStateReceiver.onPause(context);
+ broadcast.onPause(context);
+ super.onDestroy();
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java
new file mode 100644
index 0000000..a35684f
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/BatteryStateReceiver.java
@@ -0,0 +1,85 @@
+package com.pureix.easylocator.service.batteryService.broadcastReceiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.BatteryManager;
+import android.widget.Toast;
+
+import com.pureix.easylocator.service.batteryService.listener.BatteryReceiverListener;
+
+import static com.pureix.easylocator.controller.service.BatteryAPI.batteryReceiverListener;
+
+public class BatteryStateReceiver extends BroadcastReceiver
+{
+ //private static Context context;
+
+
+ private static Boolean batteryReceiverIsRegistered = false;
+
+ public BatteryStateReceiver() {
+ }
+
+/* public void onResume(Context context)
+ {
+ if (!batteryReceiverIsRegistered)
+ {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ context.registerReceiver(this, filter);
+
+ batteryReceiverIsRegistered = true;
+ }
+ }
+
+ public void onPause(Context context)
+ {
+ try {
+ if (batteryReceiverIsRegistered) {
+ context.unregisterReceiver(this);
+ batteryReceiverIsRegistered = false;
+ }
+ }catch (Exception e)
+ {}
+ }*/
+
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
+ int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
+ int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
+ int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
+
+ float temperatureInC = temperature / 10;
+ float batteryPct = level / (float)scale;
+
+ // Are we charging / charged?
+ int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
+ status == BatteryManager.BATTERY_STATUS_FULL;
+
+ // How are we charging?
+ int chargePlug = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
+ boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
+ boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
+
+ if(!(level == -1 && scale == -1 && temperature == -1 && voltage == -1
+ && status == -1 && chargePlug == -1)) {
+ if(batteryReceiverListener != null) {
+ batteryReceiverListener.onBatteryInformationChanged(level, scale,
+ temperature, voltage, batteryPct, status, isCharging,
+ chargePlug, usbCharge, acCharge);
+ }
+ Toast.makeText(context,
+ "level is " + level + "/" + scale +
+ ", temp is " + temperature +
+ ", voltage is " + voltage
+ + " status :" + status +
+ " chargePlug :" + chargePlug +
+ " Battery Pct : " + batteryPct * 100,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java
new file mode 100644
index 0000000..b7fc18c
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/broadcastReceiver/InitializeBatteryBroadcast.java
@@ -0,0 +1,64 @@
+package com.pureix.easylocator.service.batteryService.broadcastReceiver;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+
+import com.pureix.easylocator.service.activityRecognitionService.broadcastReceiver.ActivityRecognitionBroadcast;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class InitializeBatteryBroadcast
+{
+ private static BatteryStateReceiver broadcastReceiver = null;
+ private static Boolean isRegistered = false;
+
+ public InitializeBatteryBroadcast() {
+ initialize();
+ }
+
+ private void initialize()
+ {
+ broadcastReceiver = new BatteryStateReceiver();
+ }
+
+ public void onPause(Context context)
+ {
+ try {
+ if (isRegistered) {
+ context.unregisterReceiver(broadcastReceiver);
+ isRegistered = false;
+ }
+ }catch (Exception e)
+ {}
+ }
+
+ public void onResume(Context context)
+ {
+ if (!isRegistered)
+ {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ context.registerReceiver(broadcastReceiver, filter);
+
+ isRegistered = true;
+ }
+ }
+
+ public static boolean isMyServiceRunning(Activity activity, Class> serviceClass)
+ {
+ ActivityManager manager = (ActivityManager) activity
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ for (ActivityManager.RunningServiceInfo service : manager
+ .getRunningServices(Integer.MAX_VALUE)) {
+ if (serviceClass.getName().equals(service.service.getClassName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java
new file mode 100644
index 0000000..46ff19e
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/batteryService/listener/BatteryReceiverListener.java
@@ -0,0 +1,13 @@
+package com.pureix.easylocator.service.batteryService.listener;
+
+/**
+ * Created by MelDiSooQi on 1/27/2017.
+ */
+
+public interface BatteryReceiverListener
+{
+ void onBatteryInformationChanged(int level, int scale, int temperature,
+ int voltage, float batteryPct, int status,
+ boolean isCharging, int chargePlug,
+ boolean usbCharge, boolean acCharge);
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/broadcastReceiver/ConnectivityReceiver.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/broadcastReceiver/ConnectivityReceiver.java
new file mode 100644
index 0000000..aca6332
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/broadcastReceiver/ConnectivityReceiver.java
@@ -0,0 +1,88 @@
+package com.pureix.easylocator.service.internetService.broadcastReceiver;
+
+/**
+ * Created by Lincoln on 18/03/16.
+ */
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+
+import static com.pureix.easylocator.controller.service.InternetAPI.connectivityReceiverListener;
+
+public class ConnectivityReceiver
+ extends BroadcastReceiver {
+
+ public static int TYPE_WIFI = 1;
+ public static int TYPE_MOBILE = 2;
+ public static int TYPE_NOT_CONNECTED = 0;
+// public static final int NETWORK_STATUS_NOT_CONNECTED = 0,
+// NETWORK_STATUS_WIFI = 1, NETWORK_STATUS_MOBILE = 2;
+
+ public ConnectivityReceiver() {
+ super();
+ }
+
+ @Override
+ public void onReceive(Context context, Intent arg1) {
+ ConnectivityManager cm = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+
+ boolean isConnected = activeNetwork != null
+ && activeNetwork.isConnectedOrConnecting();
+
+ if (null != activeNetwork) {
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ if (connectivityReceiverListener != null) {
+ connectivityReceiverListener
+ .onNetworkConnectionChanged(isConnected, TYPE_WIFI);
+ return;
+ }
+ }
+
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ if (connectivityReceiverListener != null) {
+ connectivityReceiverListener
+ .onNetworkConnectionChanged(isConnected, TYPE_MOBILE);
+ return;
+ }
+ }
+ }
+
+ if (connectivityReceiverListener != null) {
+ connectivityReceiverListener
+ .onNetworkConnectionChanged(isConnected, TYPE_NOT_CONNECTED);
+ return;
+ }
+ }
+
+ public static boolean isConnected(Context context) {
+ ConnectivityManager
+ cm = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ return activeNetwork != null
+ && activeNetwork.isConnectedOrConnecting();
+ }
+
+ public static int getNetworkProvider(Context context) {
+ ConnectivityManager
+ cm = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+
+ if (null != activeNetwork) {
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ return TYPE_WIFI;
+ }
+
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ return TYPE_MOBILE;
+ }
+ }
+ return TYPE_NOT_CONNECTED;
+ }
+}
\ No newline at end of file
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/listener/ConnectivityReceiverListener.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/listener/ConnectivityReceiverListener.java
new file mode 100644
index 0000000..a80f2fa
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/internetService/listener/ConnectivityReceiverListener.java
@@ -0,0 +1,10 @@
+package com.pureix.easylocator.service.internetService.listener;
+
+/**
+ * Created by MelDiSooQi on 1/27/2017.
+ */
+
+public interface ConnectivityReceiverListener
+{
+ void onNetworkConnectionChanged(boolean isConnected, int connectionProvider);
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Constants.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Constants.java
new file mode 100644
index 0000000..50fdbb5
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Constants.java
@@ -0,0 +1,30 @@
+package com.pureix.easylocator.service.locatonService;
+
+public final class Constants {
+
+ // Milliseconds per second
+ private static final int MILLISECONDS_PER_SECOND = 1000;
+ // Update frequency in seconds
+ private static final int UPDATE_INTERVAL_IN_SECONDS = 60;
+ // Update frequency in milliseconds
+ public static final long UPDATE_INTERVAL = MILLISECONDS_PER_SECOND * UPDATE_INTERVAL_IN_SECONDS;
+ // The fastest update frequency, in seconds
+ private static final int FASTEST_INTERVAL_IN_SECONDS = 60;
+ // A fast frequency ceiling in milliseconds
+ public static final long FASTEST_INTERVAL = MILLISECONDS_PER_SECOND * FASTEST_INTERVAL_IN_SECONDS;
+ // Stores the lat / long pairs in a text file
+ public static final String LOCATION_FILE = "sdcard/location.txt";
+ // Stores the connect / disconnect data in a text file
+ public static final String LOG_FILE = "sdcard/log.txt";
+
+ public static final String RUNNING = "runningInBackground"; // Recording data in background
+
+ public static final String APP_PACKAGE_NAME = "com.blackcj.locationtracker";
+
+ /**
+ * Suppress default constructor for noninstantiability
+ */
+ private Constants() {
+ throw new AssertionError();
+ }
+}
\ No newline at end of file
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Listener/LocationReceiverListener.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Listener/LocationReceiverListener.java
new file mode 100644
index 0000000..2c18d8a
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/Listener/LocationReceiverListener.java
@@ -0,0 +1,14 @@
+package com.pureix.easylocator.service.locatonService.Listener;
+
+import android.location.Location;
+
+/**
+ * Created by MelDiSooQi on 1/27/2017.
+ */
+
+public interface LocationReceiverListener
+{
+ void getLastKnownLocation(Location location);
+
+ void onLocationChanged(Location location);
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java
new file mode 100644
index 0000000..9ac4b73
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/LocationService.java
@@ -0,0 +1,441 @@
+package com.pureix.easylocator.service.locatonService;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.location.Location;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.PowerManager;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GoogleApiAvailability;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.location.LocationListener;
+import com.google.android.gms.location.LocationRequest;
+import com.google.android.gms.location.LocationServices;
+import com.google.gson.Gson;
+import com.pureix.easylocator.model.storage.LocalStorage;
+import com.pureix.easylocator.model.storage.LocalStorageConstant;
+import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
+import com.pureix.easylocator.service.locatonService.broadcastReceiver.LocationBroadcast;
+import com.pureix.easylocator.service.locatonService.broadcastReceiver.LocationSender;
+
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import static com.pureix.easylocator.controller.service.LocationAPI.locationReceiverListener;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class LocationService extends Service implements
+ GoogleApiClient.ConnectionCallbacks,
+ GoogleApiClient.OnConnectionFailedListener,
+ LocationListener {
+ private String TAG = "LocationServiceTAG";
+
+ private Context context;
+ private Timer mtimer;
+
+ private LocationSender senderHandler;
+
+ // Binder given to clients
+ private IBinder mBinder = new LocalBinder();
+ private PowerManager.WakeLock mWakeLock;
+
+ // Flag that indicates if a request is underway.
+ private boolean mInProgress;
+ private LocationRequest mLocationRequest;
+ private Boolean servicesAvailable = false;
+
+ private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
+
+ private GoogleApiClient mGoogleApiClient;
+
+ /**
+ * Class used for the client Binder. Because we know this service always
+ * runs in the same process as its clients, we don't need to deal with IPC.
+ */
+ public class LocalBinder extends Binder {
+ public LocationService getService() {
+ // Return this instance of LocalService so clients can call public methods
+ return LocationService.this;
+ }
+ }
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ super.onStartCommand(intent, flags, startId);
+ Log.e(TAG, "onStartCommand");
+
+ PowerManager mgr = (PowerManager) getSystemService(Context.POWER_SERVICE);
+
+ /*
+ WakeLock is reference counted so we don't want to create multiple WakeLocks. So do a check before initializing and acquiring.
+
+ This will fix the "java.lang.Exception: WakeLock finalized while still held: MyWakeLock" error that you may find.
+ */
+ if (this.mWakeLock == null) { //**Added this
+ this.mWakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
+ }
+
+ if (!this.mWakeLock.isHeld()) { //**Added this
+ this.mWakeLock.acquire();
+ }
+
+ if (!servicesAvailable || mGoogleApiClient.isConnected() || mInProgress)
+ return START_STICKY;
+
+ setUpLocationClientIfNeeded();
+ if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting() && !mInProgress) {
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Started", Constants.LOG_FILE);
+ mInProgress = true;
+ mGoogleApiClient.connect();
+ }
+
+ return START_STICKY;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.e(TAG, "onCreate");
+ context = getApplicationContext();
+
+ senderHandler = new LocationSender(context,
+ LocationBroadcast.class);
+
+ mInProgress = false;
+ // Create the LocationRequest object
+ mLocationRequest = LocationRequest.create();
+ // Use high accuracy
+ mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ // Set the update interval to 5 seconds
+ mLocationRequest.setInterval(Constants.UPDATE_INTERVAL);
+// mLocationRequest.setInterval(1000);
+ // Set the fastest update interval to 1 second
+// mLocationRequest.setFastestInterval(1000);
+ mLocationRequest.setFastestInterval(Constants.FASTEST_INTERVAL);
+ //update the location every some distance
+ //mLocationRequest.setSmallestDisplacement(10);
+
+ servicesAvailable = servicesConnected();
+
+ /*
+ * Create a new location client, using the enclosing class to
+ * handle callbacks.
+ */
+ setUpLocationClientIfNeeded();
+ }
+
+ private void setUpLocationClientIfNeeded() {
+ if (mGoogleApiClient == null)
+ buildGoogleApiClient();
+ }
+
+ /*
+ * Create a new location client, using the enclosing class to
+ * handle callbacks.
+ */
+ protected synchronized void buildGoogleApiClient() {
+ this.mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .addApi(LocationServices.API)
+ .build();
+ }
+
+ private boolean servicesConnected() {
+
+ // Check that Google Play services is available
+ int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
+
+ // If Google Play services is available
+ if (ConnectionResult.SUCCESS == resultCode) {
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+
+ private boolean checkPlayServices() {
+ GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
+ int result = googleAPI.isGooglePlayServicesAvailable(this);
+ if (result != ConnectionResult.SUCCESS) {
+ if (googleAPI.isUserResolvableError(result)) {
+ //googleAPI.getErrorDialog(this, result,
+ // PLAY_SERVICES_RESOLUTION_REQUEST).show();
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /*
+ * Called by Location Services when the request to connect the
+ * client finishes successfully. At this point, you can
+ * request the current location or start periodic updates
+ */
+ @Override
+ public void onConnected(@Nullable Bundle bundle) {
+ Log.e(TAG, "onConnected");
+ try {
+ Location location = getLastLocation();
+ sendLocationToBroadcast(location);
+ if(locationReceiverListener !=null) {
+ locationReceiverListener.getLastKnownLocation(location);
+ locationReceiverListener.onLocationChanged(location);
+ }
+ } catch (Exception e) {
+ }
+ // Request location updates using static settings
+ //Intent intent = new Intent(this, LocationReceiver.class);
+// LocationServices.FusedLocationApi.requestLocationUpdates(this.mGoogleApiClient, mLocationRequest, this); // This is the changed line.
+ LocationServices
+ .FusedLocationApi
+ .requestLocationUpdates(this.mGoogleApiClient,
+ mLocationRequest,
+ this); // This is the changed line.
+
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Connected", Constants.LOG_FILE);
+ }
+
+ private Location getLastLocation() {
+ Location location = null;
+
+ Boolean locationAvailableInByGoogle = false;
+
+ if (getLastLocationByGoogle() != null) {
+ location = getLastLocationByGoogle();
+ locationAvailableInByGoogle = true;
+ }
+
+ //if(isLocationInLocalStorage)
+ if(getLocationInLocalStorage() != null)
+ {
+ // get from local storage
+ location = getLocationInLocalStorage();
+ Log.e(TAG, "getLastLocationFromLocalStorage");
+ }else
+ {
+ if(locationAvailableInByGoogle)
+ {
+// setLocationInLocalStorage(getLastLocationByGoogle());
+ saveLocationInLocalStorage(0, getLastLocationByGoogle());
+ Log.e(TAG, "getLastLocationFromGoogle");
+ }else
+ {
+ // In this case
+ // location not Available at all
+ // location == null
+ }
+ }
+
+ return location;
+ }
+
+ private Location getLastLocationByGoogle() {
+ return LocationServices
+ .FusedLocationApi
+ .getLastLocation(this.mGoogleApiClient);
+ }
+
+ private Location getLocationInLocalStorage() {
+ String jsonLocation = (String) LocalStorage.getPreference(context,
+ LocalStorageConstant.LAST_KNOWN_LOCATION, null);
+ Location location = new Gson().fromJson(jsonLocation, Location.class);
+ location.setProvider("LocalStorage");
+ return location;
+ }
+
+ private void setLocationInLocalStorage(Location location) {
+ Log.e(TAG, "setLocationInLocalStorage");
+ String jsonLocation = new Gson().toJson(location);
+ LocalStorage.setPreference(context, LocalStorageConstant.LAST_KNOWN_LOCATION,
+ jsonLocation);
+ }
+
+ /*
+ * Called by Location Services if the connection to the
+ * location client drops because of an error.
+ */
+ @Override
+ public void onConnectionSuspended(int i) {
+ Log.e(TAG, "onConnectionSuspended");
+ // Turn off the request flag
+ mInProgress = false;
+ // Destroy the current location client
+ mGoogleApiClient = null;
+ // Display the connection status
+ // Toast.makeText(this, DateFormat.getDateTimeInstance().format(new Date()) + ": Disconnected. Please re-connect.", Toast.LENGTH_SHORT).show();
+ //appendLog(DateFormat.getDateTimeInstance().format(new Date()) + ": Disconnected", Constants.LOG_FILE);
+ }
+
+ /*
+ * Called by Location Services if the attempt to
+ * Location Services fails.
+ */
+ @Override
+ public void onConnectionFailed(@NonNull ConnectionResult connectionResult)
+ {
+ Log.e(TAG, "onConnectionFailed");
+ mInProgress = false;
+
+ /*
+ * Google Play services can resolve some errors it detects.
+ * If the error has a resolution, try sending an Intent to
+ * start a Google Play services activity that can resolve
+ * error.
+ */
+ if (connectionResult.hasResolution()) {
+
+ // If no resolution is available, display an error dialog
+ } else {
+
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.e(TAG, "onDestroy");
+ // Turn off the request flag
+ this.mInProgress = false;
+
+ if (this.servicesAvailable && this.mGoogleApiClient != null) {
+ this.mGoogleApiClient.unregisterConnectionCallbacks(this);
+ this.mGoogleApiClient.unregisterConnectionFailedListener(this);
+ this.mGoogleApiClient.disconnect();
+ // Destroy the current location client
+ this.mGoogleApiClient = null;
+ }
+ // Display the connection status
+ // Toast.makeText(this, DateFormat.getDateTimeInstance().format(new Date()) + ":
+ // Disconnected. Please re-connect.", Toast.LENGTH_SHORT).show();
+
+ if (this.mWakeLock != null) {
+ this.mWakeLock.release();
+ this.mWakeLock = null;
+ }
+ super.onDestroy();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ Log.e(TAG, "onConfigurationChanged");
+ super.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public void onLowMemory() {
+ Log.e(TAG, "onLowMemory");
+ super.onLowMemory();
+ }
+
+ @Override
+ public void onTrimMemory(int level) {
+ Log.e(TAG, "onTrimMemory");
+ super.onTrimMemory(level);
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ Log.e(TAG, "onUnbind");
+ return super.onUnbind(intent);
+ }
+
+ @Override
+ public void onRebind(Intent intent) {
+ Log.e(TAG, "onRebind");
+ super.onRebind(intent);
+ }
+
+ @Override
+ public void onTaskRemoved(Intent rootIntent) {
+ Log.e(TAG, "onTaskRemoved");
+ super.onTaskRemoved(rootIntent);
+ }
+
+ // Define the callback method that receives location updates
+ @Override
+ public void onLocationChanged(Location location) {
+ Log.e(TAG, "onLocationChanged");
+ // Report to the UI that the location was updated
+
+ if(location != null)
+ {
+ //setLocationInLocalStorage(location);
+ saveLocationInLocalStorage(10000, location);
+ }
+
+ sendLocationToBroadcast(location);
+ if(locationReceiverListener != null) {
+ locationReceiverListener.onLocationChanged(location);
+ }
+ }
+
+// private void sendLocationToBroadcast(Location location) {
+// senderHandler.sendLocationToApp(
+// location.getLatitude(),
+// location.getLongitude(),
+// location.getProvider(),
+// location.getAccuracy(),
+// location.getTime(),
+// location.getAltitude(),
+// location.getBearing(),
+// location.getSpeed());
+// }
+ private void sendLocationToBroadcast(Location location) {
+ senderHandler.sendLocationToApp(new Gson().toJson(location));
+ }
+
+
+ /*// Binding
+ public static void setLocationListener(LocationReceiverListener locationReceiverListener) {
+ LocationService
+ .locationReceiverListener = locationReceiverListener;
+ }*/
+
+ /** method for clients */
+ /*public int getRandomNumber() {
+ return new Random().nextInt(100);
+ }*/
+
+ private void saveLocationInLocalStorage(long time, final Location location) {
+ if(mtimer != null) {
+ mtimer.cancel();
+ }
+
+ mtimer = new Timer();
+ mtimer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ setLocationInLocalStorage(location);
+ }
+ }).start();
+ }
+ }, time);
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java
new file mode 100644
index 0000000..698f93b
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/ServicesConstant.java
@@ -0,0 +1,26 @@
+package com.pureix.easylocator.service.locatonService;
+
+/**
+ * Created by M.Hayle on 6/29/2016.
+ */
+public class ServicesConstant
+{
+ //==========================S Location Service=================================
+ public final static String SERVICE_ID = "SERVICE_ID";
+ public final static int SERVICE_ID_SEND_LOCATION = 0;
+ public final static int SERVICE_ID_SEND_ID = 1;
+ public final static int SERVICE_ID_SEND_JSON_LOCATION = 2;
+
+
+ public final static String JSON_LOCATION = "JSON_LOCATION";
+ public final static String USER_ID = "USER_ID";
+ public final static String LATITUDE = "LATITUDE";
+ public final static String LONGITUDE = "LONGITUDE";
+ public final static String LOCATION_PROVIDER = "LOCATION_PROVIDER";
+ public final static String ACCURACY = "ACCURACY";
+ public final static String TIME = "TIME";
+ public final static String ALTITUDE = "ALTITUDE";
+ public final static String BEARING = "BEARING";
+ public final static String SPEED = "SPEED";
+ //==========================E Location Service=================================
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/bean/Location.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/bean/Location.java
new file mode 100644
index 0000000..078a5a5
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/bean/Location.java
@@ -0,0 +1,75 @@
+package com.pureix.easylocator.service.locatonService.bean;
+
+/**
+ * Created by MelDiSooQi on 7/16/2016.
+ */
+public class Location
+{
+ private double latitude;
+ private double longitude;
+ private String locationProvider;
+ private Float accuracy;
+ private long time;
+ private double altitude;
+ private float bearing;
+ private float speed;
+
+ public Location() {
+ }
+
+ public Location(double latitude, double longitude, String locationProvider, Float accuracy, long time, double altitude, float bearing, float speed)
+ {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.locationProvider = locationProvider;
+ this.accuracy = accuracy;
+ this.time = time;
+ this.altitude = altitude;
+ this.bearing = bearing;
+ this.speed = speed;
+ }
+
+ public void setLocation(double latitude, double longitude, String locationProvider, Float accuracy, long time, double altitude, float bearing, float speed)
+ {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ this.locationProvider = locationProvider;
+ this.accuracy = accuracy;
+ this.time = time;
+ this.altitude = altitude;
+ this.bearing = bearing;
+ this.speed = speed;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public String getLocationProvider() {
+ return locationProvider;
+ }
+
+ public Float getAccuracy() {
+ return accuracy;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public double getAltitude() {
+ return altitude;
+ }
+
+ public float getBearing() {
+ return bearing;
+ }
+
+ public float getSpeed() {
+ return speed;
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/InitializeLocationBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/InitializeLocationBroadcast.java
new file mode 100644
index 0000000..3bd5499
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/InitializeLocationBroadcast.java
@@ -0,0 +1,63 @@
+package com.pureix.easylocator.service.locatonService.broadcastReceiver;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.IntentFilter;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class InitializeLocationBroadcast
+{
+ private static LocationBroadcast locationBroadcast = null;
+ private static Boolean locationServiceReceiverIsRegistered = false;
+
+ public InitializeLocationBroadcast() {
+ initialize();
+ }
+
+ private void initialize()
+ {
+ locationBroadcast = new LocationBroadcast();
+ }
+
+ public void onPause(Context context)
+ {
+ try {
+ if (locationServiceReceiverIsRegistered) {
+ context.unregisterReceiver(locationBroadcast);
+ locationServiceReceiverIsRegistered = false;
+ }
+ }catch (Exception e)
+ {}
+ }
+
+ public void onResume(Context context)
+ {
+ if (!locationServiceReceiverIsRegistered)
+ {
+ context.registerReceiver(locationBroadcast,
+ new IntentFilter("com.pureix.easylocator.service.locatonService.broadcastReceiver.LocationBroadcast"));
+
+ locationServiceReceiverIsRegistered = true;
+ }
+ }
+
+
+
+ public static boolean isMyServiceRunning(Activity activity, Class> serviceClass)
+ {
+ ActivityManager manager = (ActivityManager) activity
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ for (ActivityManager.RunningServiceInfo service : manager
+ .getRunningServices(Integer.MAX_VALUE)) {
+ if (serviceClass.getName().equals(service.service.getClassName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java
new file mode 100644
index 0000000..210ca6b
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationBroadcast.java
@@ -0,0 +1,93 @@
+package com.pureix.easylocator.service.locatonService.broadcastReceiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.Toast;
+
+import com.google.gson.Gson;
+import com.pureix.easylocator.service.locatonService.Listener.LocationReceiverListener;
+import com.pureix.easylocator.service.locatonService.ServicesConstant;
+import com.pureix.easylocator.service.locatonService.bean.Location;
+
+import static com.pureix.easylocator.controller.service.LocationAPI.locationReceiverListener;
+
+public class LocationBroadcast extends BroadcastReceiver
+{
+// private static LocationReceiverListener locationReceiverListener;
+
+ boolean isLocationInitialized = false;
+
+ public LocationBroadcast() {
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle extras = intent.getExtras();
+ if(extras.getInt(ServicesConstant.SERVICE_ID) == ServicesConstant.SERVICE_ID_SEND_LOCATION)
+ {
+ Location location;
+
+ int USER_ID = extras.getInt (ServicesConstant.USER_ID);
+ double latitude = extras.getDouble(ServicesConstant.LATITUDE);
+ double longitude = extras.getDouble(ServicesConstant.LONGITUDE);
+ String locationProvider = extras.getString(ServicesConstant.LOCATION_PROVIDER);
+ Float accuracy = extras.getFloat(ServicesConstant.ACCURACY);
+ long time = extras.getLong(ServicesConstant.TIME);
+ double altitude = extras.getDouble(ServicesConstant.ALTITUDE);
+ float bearing = extras.getFloat(ServicesConstant.BEARING);
+ float speed = extras.getFloat(ServicesConstant.SPEED);
+
+
+ if(!isLocationInitialized) {
+ isLocationInitialized = true;
+ location = new Location(latitude, longitude, locationProvider, accuracy,
+ time, altitude, bearing, speed);
+ }
+
+ float kMeter = speed * 3.6f;
+
+ String s = latitude
+ + " longitude "+ longitude
+ +" Provider "+locationProvider
+ +" altitude "+altitude
+ +" bearing "+bearing
+ +" speed "+ kMeter
+ +" accuracy "+accuracy
+ +" USER_ID "+USER_ID;
+ Toast.makeText(context, "From BroadCast : "+s, Toast.LENGTH_SHORT).show();
+// LoggerAndToastHandler.PrintToastMsg(s);
+ }else if(extras.getInt(ServicesConstant.SERVICE_ID) == ServicesConstant.SERVICE_ID_SEND_JSON_LOCATION)
+ {
+ String jsonLocation = extras.getString(ServicesConstant.JSON_LOCATION);
+
+ android.location.Location location = new Gson()
+ .fromJson(jsonLocation, android.location.Location.class);
+
+ if(locationReceiverListener != null) {
+ if ("LocalStorage".equals(location.getProvider())) {
+ locationReceiverListener.getLastKnownLocation(location);
+ }
+ locationReceiverListener.onLocationChanged(location);
+ }
+
+ float kMeter = location.getSpeed() * 3.6f;
+
+ String s = location.getLatitude()
+ + " longitude "+ location.getLongitude()
+ +" Provider "+location.getProvider()
+ +" altitude "+location.getAltitude()
+ +" bearing "+location.getBearing()
+ +" speed "+ kMeter
+ +" accuracy "+location.getAccuracy();
+
+ //Toast.makeText(context, "AFrom BroadCast : "+s, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+// public static void addLocationListener(LocationReceiverListener locationReceiverListener)
+// {
+// LocationBroadcast.locationReceiverListener = locationReceiverListener;
+// }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java
new file mode 100644
index 0000000..159eb7c
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/broadcastReceiver/LocationSender.java
@@ -0,0 +1,98 @@
+package com.pureix.easylocator.service.locatonService.broadcastReceiver;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.pureix.easylocator.service.locatonService.ServicesConstant;
+
+/**
+ * Created by MelDiSooQi on 7/16/2016.
+ */
+public class LocationSender
+{
+ private final Context context;
+ private final Class> aClass;
+ private Intent intent;
+
+ public LocationSender(Context context, Class> aClass)
+ {
+ this.context = context;
+ this.aClass = aClass;
+ this.intent = new Intent(context, aClass);
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+/*
+ public void sendLocationToApp(int userID, double latitude, double longitude, String provider, float accuracy, long time)
+ {
+ intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(ServicesConstant.USER_ID , userID);
+ intent.putExtra(ServicesConstant.LATITUDE , latitude);
+ intent.putExtra(ServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(ServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(ServicesConstant.TIME , time);
+
+ context.sendBroadcast(intent);
+ }
+*/
+
+ public void sendLocationToApp(int userID, double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
+ {
+ intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(ServicesConstant.USER_ID , userID);
+ intent.putExtra(ServicesConstant.LATITUDE , latitude);
+ intent.putExtra(ServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(ServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(ServicesConstant.TIME , time);
+ intent.putExtra(ServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(ServicesConstant.BEARING , bearing);
+ intent.putExtra(ServicesConstant.SPEED , speed);
+
+ context.sendBroadcast(intent);
+ }
+
+ public void sendLocationToApp(String userID, double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
+ {
+ intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(ServicesConstant.USER_ID , userID);
+ intent.putExtra(ServicesConstant.LATITUDE , latitude);
+ intent.putExtra(ServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(ServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(ServicesConstant.TIME , time);
+ intent.putExtra(ServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(ServicesConstant.BEARING , bearing);
+ intent.putExtra(ServicesConstant.SPEED , speed);
+
+ context.sendBroadcast(intent);
+ }
+
+ public void sendLocationToApp(double latitude, double longitude, String provider, float accuracy, long time, double altitude, float bearing, float speed)
+ {
+ intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant.SERVICE_ID_SEND_LOCATION);
+ intent.putExtra(ServicesConstant.LATITUDE , latitude);
+ intent.putExtra(ServicesConstant.LONGITUDE , longitude);
+ intent.putExtra(ServicesConstant.LOCATION_PROVIDER , provider);
+ intent.putExtra(ServicesConstant.ACCURACY , accuracy);
+ intent.putExtra(ServicesConstant.TIME , time);
+ intent.putExtra(ServicesConstant.ALTITUDE , altitude);
+ intent.putExtra(ServicesConstant.BEARING , bearing);
+ intent.putExtra(ServicesConstant.SPEED , speed);
+
+ context.sendBroadcast(intent);
+ }
+
+ public void sendLocationToApp(String jsonLocation)
+ {
+ intent.putExtra(ServicesConstant.SERVICE_ID , ServicesConstant
+ .SERVICE_ID_SEND_JSON_LOCATION);
+ intent.putExtra(ServicesConstant.JSON_LOCATION , jsonLocation);
+
+ context.sendBroadcast(intent);
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/permission/LocationPermission.java b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/permission/LocationPermission.java
new file mode 100644
index 0000000..a0b55df
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/java/com/pureix/easylocator/service/locatonService/permission/LocationPermission.java
@@ -0,0 +1,65 @@
+package com.pureix.easylocator.service.locatonService.permission;
+
+import android.app.Activity;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.support.annotation.RequiresApi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by MelDiSooQi on 1/28/2017.
+ */
+
+public class LocationPermission
+{
+ private final int REQUEST_CODE_LOC = 2;
+
+ public LocationPermission(Activity activity) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ accessLocationPermission(activity);
+ }
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ private void accessLocationPermission(Activity activity) {
+ int accessCoarseLocation = activity.checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION);
+ int accessFineLocation = activity.checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION);
+
+ List listRequestPermission = new ArrayList();
+
+ if (accessCoarseLocation != PackageManager.PERMISSION_GRANTED) {
+ listRequestPermission.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
+ }
+ if (accessFineLocation != PackageManager.PERMISSION_GRANTED) {
+ listRequestPermission.add(android.Manifest.permission.ACCESS_FINE_LOCATION);
+ }
+
+ if (!listRequestPermission.isEmpty()) {
+ String[] strRequestPermission = listRequestPermission.toArray(new String[listRequestPermission.size()]);
+ activity.requestPermissions(strRequestPermission, REQUEST_CODE_LOC);
+ }
+ }
+
+ //@Override
+ public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
+ switch (requestCode) {
+ case REQUEST_CODE_LOC:
+ if (grantResults.length > 0) {
+ for (int gr : grantResults) {
+ // Check if request is granted or not
+ if (gr != PackageManager.PERMISSION_GRANTED) {
+ return;
+ }
+ }
+
+ //TODO - Add your code here to start Discovery
+
+ }
+ break;
+ default:
+ return;
+ }
+ }
+}
diff --git a/SampleEasyLocator/easylocator/src/main/res/values/strings.xml b/SampleEasyLocator/easylocator/src/main/res/values/strings.xml
new file mode 100644
index 0000000..da6a59e
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/main/res/values/strings.xml
@@ -0,0 +1,15 @@
+
+ Easy Locator
+
+
+ In a vehicle
+ On a bicycle
+ On foot
+ Running
+ Still
+ Tilting
+ Unknown activity
+ Walking
+ Unidentifiable activity: %1$d
+
+
diff --git a/SampleEasyLocator/easylocator/src/test/java/com/pureix/easylocator/ExampleUnitTest.java b/SampleEasyLocator/easylocator/src/test/java/com/pureix/easylocator/ExampleUnitTest.java
new file mode 100644
index 0000000..63a14e1
--- /dev/null
+++ b/SampleEasyLocator/easylocator/src/test/java/com/pureix/easylocator/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.pureix.easylocator;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/SampleEasyLocator/gradle.properties b/SampleEasyLocator/gradle.properties
new file mode 100644
index 0000000..aac7c9b
--- /dev/null
+++ b/SampleEasyLocator/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/SampleEasyLocator/gradle/wrapper/gradle-wrapper.jar b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..04e285f
--- /dev/null
+++ b/SampleEasyLocator/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/SampleEasyLocator/gradlew b/SampleEasyLocator/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/SampleEasyLocator/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/SampleEasyLocator/gradlew.bat b/SampleEasyLocator/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/SampleEasyLocator/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/SampleEasyLocator/settings.gradle b/SampleEasyLocator/settings.gradle
new file mode 100644
index 0000000..abc07d5
--- /dev/null
+++ b/SampleEasyLocator/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':easylocator'