Add All Project

This commit is contained in:
MOATAZ IBRAHIM ELDESOUKI TAWFEEK MOHAMMED 2017-02-14 10:43:15 +02:00
parent 1ce4c3f812
commit d1c6423157
75 changed files with 3296 additions and 0 deletions

9
SampleEasyLocator/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/easylocator" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/SampleEasyLocator.iml" filepath="$PROJECT_DIR$/SampleEasyLocator.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/easylocator/easylocator.iml" filepath="$PROJECT_DIR$/easylocator/easylocator.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

1
SampleEasyLocator/app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -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')
}

View File

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

View File

@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pureix.sampleeasylocator">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -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<DetectedActivity> 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);
}
}

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.pureix.sampleeasylocator.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.pureix.sampleeasylocator.MainActivity"
tools:showIn="@layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>

View File

@ -0,0 +1,10 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.pureix.sampleeasylocator.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,9 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

View File

@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@ -0,0 +1,6 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>

View File

@ -0,0 +1,4 @@
<resources>
<string name="app_name">Sample Easy Locator</string>
<string name="action_settings">Settings</string>
</resources>

View File

@ -0,0 +1,20 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

View File

@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

View File

@ -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
}

View File

@ -0,0 +1 @@
/build

View File

@ -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'
}

View File

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

View File

@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}

View File

@ -0,0 +1,108 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pureix.easylocator">
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<application
android:name=".applicationManger.BaseApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<receiver
android:name=".service.activityRecognitionService.broadcastReceiver.ActivityRecognitionBroadcast"
android:enabled="true"
android:exported="true" />
<service
android:name=".service.activityRecognitionService.ActivitiesRecognitionService"
android:enabled="true"
android:exported="true"
android:process=":ActivitiesRecognitionService"/>
<!-- Service that provides activity recognition data. Setting the android:exported attribute
to "false" stops other apps from starting this service, even when using an explicit
intent. -->
<service
android:name=".service.activityRecognitionService.ActivitiesRecognitionIntentService"
android:exported="false"
android:process=":ActivitiesRecognitionIntentService"/>
<receiver
android:name=".service.internetService.broadcastReceiver.ConnectivityReceiver"
android:enabled="true">
<intent-filter>
<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> -->
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<receiver
android:name=".service.batteryService.broadcastReceiver.BatteryStateReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
<action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
</receiver>
<service
android:name=".service.batteryService.BatteryService"
android:enabled="true"
android:exported="true"
android:process=":BatteryService">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
<action android:name="android.intent.action.BATTERY_CHANGED" />
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
</service>
<!-- android:process=":LocationService" Remove it if you will use binding -->
<service
android:name=".service.locatonService.LocationService"
android:enabled="true"
android:process=":LocationManagerService">
<intent-filter>
<action android:name="com.pureix.locationutility.service.LocationService" />
</intent-filter>
</service>
<receiver
android:name=".service.locatonService.broadcastReceiver.LocationBroadcast"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -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);
}
}

View File

@ -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();
}
}
}

View File

@ -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/";
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<String>) 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<String>) 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<String>) 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;
}
//===================================================================================================================
}

View File

@ -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";
}

View File

@ -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;
}
}
//===================================================================================================================
}

View File

@ -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<DetectedActivity> 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);
}
}

View File

@ -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<Status>
{
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());
}
}
}

View File

@ -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);
}
}
}

View File

@ -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<DetectedActivity> mDetectedActivities;
public ActivityRecognitionBroadcast() {
}
@Override
public void onReceive(Context context, Intent intent)
{
ArrayList<DetectedActivity> 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<DetectedActivity>();
//
// // 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);
}
}
}

View File

@ -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<DetectedActivity> detectedActivities)
{
intent.putExtra(Constants.ACTIVITY_EXTRA, detectedActivities);
context.sendBroadcast(intent);
}
}

View File

@ -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;
}
}

View File

@ -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<DetectedActivity> updatedActivities);
}

View File

@ -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();
}
}

View File

@ -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();
}
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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=================================
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
// }
}

View File

@ -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);
}
}

View File

@ -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<String> listRequestPermission = new ArrayList<String>();
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;
}
}
}

View File

@ -0,0 +1,15 @@
<resources>
<string name="app_name">Easy Locator</string>
<!-- Activity detection strings -->
<string name="in_vehicle">In a vehicle</string>
<string name="on_bicycle">On a bicycle</string>
<string name="on_foot">On foot</string>
<string name="running">Running</string>
<string name="still">Still</string>
<string name="tilting">Tilting</string>
<string name="unknown">Unknown activity</string>
<string name="walking">Walking</string>
<string name="unidentifiable_activity">Unidentifiable activity: %1$d</string>
</resources>

View File

@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

View File

@ -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

Binary file not shown.

View File

@ -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

160
SampleEasyLocator/gradlew vendored Normal file
View File

@ -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 "$@"

90
SampleEasyLocator/gradlew.bat vendored Normal file
View File

@ -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

View File

@ -0,0 +1 @@
include ':app', ':easylocator'