diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..8efd28a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3963879 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ab23685 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..8f75b4c --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,29 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 26 + defaultConfig { + applicationId "com.example.prabhat.locationsample" + minSdkVersion 17 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation project(':easywaylocation') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/example/prabhat/locationsample/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/prabhat/locationsample/ExampleInstrumentedTest.java new file mode 100644 index 0000000..3bbb358 --- /dev/null +++ b/app/src/androidTest/java/com/example/prabhat/locationsample/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.prabhat.locationsample; + +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.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.prabhat.locationsample", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..d48da1d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/prabhat/locationsample/MainActivity.java b/app/src/main/java/com/example/prabhat/locationsample/MainActivity.java new file mode 100644 index 0000000..1399f0a --- /dev/null +++ b/app/src/main/java/com/example/prabhat/locationsample/MainActivity.java @@ -0,0 +1,60 @@ +package com.example.prabhat.locationsample; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.TextView; +import android.widget.Toast; + +import com.example.easywaylocation.EasyWayLocation; +import com.example.easywaylocation.Listener; + +import static com.example.easywaylocation.EasyWayLocation.LOCATION_SETTING_REQUEST_CODE; + +public class MainActivity extends AppCompatActivity implements Listener { + EasyWayLocation easyWayLocation; + private TextView location, latLong, diff; + private Double lati, longi; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + location = findViewById(R.id.location); + latLong = findViewById(R.id.latlong); + diff = findViewById(R.id.diff); + easyWayLocation = new EasyWayLocation(this); + easyWayLocation.setListener(this); + } + + @Override + public void locationOn() { + Toast.makeText(this, "Location ON", Toast.LENGTH_SHORT).show(); + easyWayLocation.beginUpdates(); + lati = easyWayLocation.getLatitude(); + longi = easyWayLocation.getLongitude(); + location.setText(EasyWayLocation.getAddress(this, lati, longi, false, true)); + latLong.setText(String.valueOf(lati) + " " + String.valueOf(longi)); + diff.setText(String.valueOf(EasyWayLocation.calculateDistance(28.626686, 77.026409, 28.626799, 77.033619))); + } + + @Override + public void onPositionChanged() { + Toast.makeText(this, String.valueOf(easyWayLocation.getLongitude()) + "," + String.valueOf(easyWayLocation.getLatitude()), Toast.LENGTH_SHORT).show(); + } + + @Override + public void locationCancelled() { + easyWayLocation.showAlertDialog(getString(R.string.loc_title), getString(R.string.loc_mess), null); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + case LOCATION_SETTING_REQUEST_CODE: + easyWayLocation.onActivityResult(resultCode); + break; + } + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..654b9e0 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a2f5908 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..1b52399 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..ff10afd Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..115a4c7 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..dcd3cd8 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..459ca60 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..8ca12fe Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8e19b41 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..b824ebd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..4c19a13 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..50eda08 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,7 @@ + + + #3F51B5 + #303F9F + #FF4081 + #000000 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..64ef0b5 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,5 @@ + + Location Sample + Please on location of your device. To get your current Address. + Location Alert + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/com/example/prabhat/locationsample/ExampleUnitTest.java b/app/src/test/java/com/example/prabhat/locationsample/ExampleUnitTest.java new file mode 100644 index 0000000..605718f --- /dev/null +++ b/app/src/test/java/com/example/prabhat/locationsample/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.prabhat.locationsample; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e6b32bc --- /dev/null +++ b/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/easywaylocation/.gitignore b/easywaylocation/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/easywaylocation/.gitignore @@ -0,0 +1 @@ +/build diff --git a/easywaylocation/build.gradle b/easywaylocation/build.gradle new file mode 100644 index 0000000..d931538 --- /dev/null +++ b/easywaylocation/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 26 + + + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.android.support:appcompat-v7:26.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + compile 'com.google.android.gms:play-services-location:11.8.0' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/easywaylocation/proguard-rules.pro b/easywaylocation/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/easywaylocation/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/easywaylocation/src/androidTest/java/com/example/easywaylocation/ExampleInstrumentedTest.java b/easywaylocation/src/androidTest/java/com/example/easywaylocation/ExampleInstrumentedTest.java new file mode 100644 index 0000000..0786411 --- /dev/null +++ b/easywaylocation/src/androidTest/java/com/example/easywaylocation/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.easywaylocation; + +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.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.easywaylocation.test", appContext.getPackageName()); + } +} diff --git a/easywaylocation/src/main/AndroidManifest.xml b/easywaylocation/src/main/AndroidManifest.xml new file mode 100644 index 0000000..61b57f7 --- /dev/null +++ b/easywaylocation/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/easywaylocation/src/main/java/com/example/easywaylocation/EasyWayLocation.java b/easywaylocation/src/main/java/com/example/easywaylocation/EasyWayLocation.java new file mode 100644 index 0000000..b5a4736 --- /dev/null +++ b/easywaylocation/src/main/java/com/example/easywaylocation/EasyWayLocation.java @@ -0,0 +1,778 @@ +package com.example.easywaylocation; + + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentSender; +import android.graphics.drawable.Drawable; +import android.location.Address; +import android.location.Geocoder; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; +import android.provider.Settings; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.app.AlertDialog; +import android.widget.Toast; + +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.api.GoogleApiClient; +import com.google.android.gms.common.api.PendingResult; +import com.google.android.gms.common.api.ResultCallback; +import com.google.android.gms.common.api.Status; +import com.google.android.gms.location.LocationRequest; +import com.google.android.gms.location.LocationServices; +import com.google.android.gms.location.LocationSettingsRequest; +import com.google.android.gms.location.LocationSettingsResult; +import com.google.android.gms.location.LocationSettingsStates; +import com.google.android.gms.location.LocationSettingsStatusCodes; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; +import java.util.Random; + +/** + * Utility class for easy access to the device location on Android + */ +public class EasyWayLocation implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks { + + + /* + google api client request code for activty result + */ + public static final int LOCATION_SETTING_REQUEST_CODE = 5; + + /** + * {@link Listener} object + */ + + public Listener getmListener; + /** + * The internal name of the provider for the coarse location + */ + private static final String PROVIDER_COARSE = LocationManager.NETWORK_PROVIDER; + /** + * The internal name of the provider for the fine location + */ + private static final String PROVIDER_FINE = LocationManager.GPS_PROVIDER; + /** + * The internal name of the provider for the fine location in passive mode + */ + private static final String PROVIDER_FINE_PASSIVE = LocationManager.PASSIVE_PROVIDER; + /** + * The default interval to receive new location updates after (in milliseconds) + */ + private static final long INTERVAL_DEFAULT = 10 * 60 * 1000; + /** + * The factor for conversion from kilometers to meters + */ + private static final float KILOMETER_TO_METER = 1000.0f; + /** + * The factor for conversion from latitude to kilometers + */ + private static final float LATITUDE_TO_KILOMETER = 111.133f; + /** + * The factor for conversion from longitude to kilometers at zero degree in latitude + */ + private static final float LONGITUDE_TO_KILOMETER_AT_ZERO_LATITUDE = 111.320f; + /** + * The PRNG that is used for location blurring + */ + private static final Random mRandom = new Random(); + private static final double SQUARE_ROOT_TWO = Math.sqrt(2); + /** + * The last location that was internally cached when creating new instances in the same process + */ + private static Location mCachedPosition; + /** + * The LocationManager instance used to query the device location + */ + private final LocationManager mLocationManager; + /** + * Whether a fine location should be required or coarse location can be used + */ + private final boolean mRequireFine; + /** + * Whether passive mode shall be used or not + */ + private final boolean mPassive; + /** + * The internal after which new location updates are requested (in milliseconds) where longer intervals save battery + */ + private final long mInterval; + /** + * Whether to require a new location (`true`) or accept old (last known) locations as well (`false`) + */ + private final boolean mRequireNewLocation; + boolean gps_enabled = false; + boolean network_enabled = false; + GoogleApiClient googleApiClient; + private Boolean locationReturn = true; + private Context context; + /** + * The blur radius (in meters) that will be used to blur the location for privacy reasons + */ + private int mBlurRadius; + /** + * The LocationListener instance used internally to listen for location updates + */ + private LocationListener mLocationListener; + /** + * The current location with latitude, longitude, speed and altitude + */ + private Location mPosition; + private Listener mListener; + + /** + * Constructs a new instance with default granularity, mode and interval + * + * @param context the Context reference to get the system service from + */ + public EasyWayLocation(final Context context) { + this(context, false); + } + + /** + * Constructs a new instance with default mode and interval + * + * @param context the Context reference to get the system service from + * @param requireFine whether to require fine location or use coarse location + */ + public EasyWayLocation(final Context context, final boolean requireFine) { + this(context, requireFine, false); + } + + /** + * Constructs a new instance with default interval + * + * @param context the Context reference to get the system service from + * @param requireFine whether to require fine location or use coarse location + * @param passive whether to use passive mode (to save battery) or active mode + */ + public EasyWayLocation(final Context context, final boolean requireFine, final boolean passive) { + this(context, requireFine, passive, INTERVAL_DEFAULT); + } + + /** + * Constructs a new instance + * + * @param context the Context reference to get the system service from + * @param requireFine whether to require fine location or use coarse location + * @param passive whether to use passive mode (to save battery) or active mode + * @param interval the interval to request new location updates after (in milliseconds) where longer intervals save battery + */ + public EasyWayLocation(final Context context, final boolean requireFine, final boolean passive, final long interval) { + this(context, requireFine, passive, interval, false); + } + + /** + * Constructs a new instance + * + * @param context the Context reference to get the system service from + * @param requireFine whether to require fine location or use coarse location + * @param passive whether to use passive mode (to save battery) or active mode + * @param interval the interval to request new location updates after (in milliseconds) where longer intervals save battery + * @param requireNewLocation whether to require a new location (`true`) or accept old (last known) locations as well (`false`) + */ + public EasyWayLocation(final Context context, final boolean requireFine, final boolean passive, final long interval, final boolean requireNewLocation) { + mLocationManager = (LocationManager) context.getApplicationContext().getSystemService(Context.LOCATION_SERVICE); + mRequireFine = requireFine; + this.context = context; + mPassive = passive; + mInterval = interval; + mRequireNewLocation = requireNewLocation; + + googleApiClient = new GoogleApiClient.Builder(context) + .addApi(LocationServices.API) + .addConnectionCallbacks(this) + .addOnConnectionFailedListener(this) + .build(); + googleApiClient.connect(); + + if (!mRequireNewLocation) { + mPosition = getCachedPosition(); + cachePosition(); + } + } + + /** + * For any radius `n`, calculate a random offset in the range `[-n, n]` + * + * @param radius the radius + * @return the random offset + */ + private static int calculateRandomOffset(final int radius) { + return mRandom.nextInt((radius + 1) * 2) - radius; + } + + /** + * Opens the device's settings screen where location access can be enabled + * + * @param context the Context reference to start the Intent from + */ + public static void openSettings(final Context context) { + context.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); + } + + /** + * Converts a difference in latitude to a difference in kilometers (rough estimation) + * + * @param latitude the latitude (difference) + * @return the kilometers (difference) + */ + public static double latitudeToKilometer(double latitude) { + return latitude * LATITUDE_TO_KILOMETER; + } + + /** + * Converts a difference in kilometers to a difference in latitude (rough estimation) + * + * @param kilometer the kilometers (difference) + * @return the latitude (difference) + */ + public static double kilometerToLatitude(double kilometer) { + return kilometer / latitudeToKilometer(1.0f); + } + + /** + * Converts a difference in latitude to a difference in meters (rough estimation) + * + * @param latitude the latitude (difference) + * @return the meters (difference) + */ + public static double latitudeToMeter(double latitude) { + return latitudeToKilometer(latitude) * KILOMETER_TO_METER; + } + + /** + * Converts a difference in meters to a difference in latitude (rough estimation) + * + * @param meter the meters (difference) + * @return the latitude (difference) + */ + public static double meterToLatitude(double meter) { + return meter / latitudeToMeter(1.0f); + } + + /** + * Converts a difference in longitude to a difference in kilometers (rough estimation) + * + * @param longitude the longitude (difference) + * @param latitude the latitude (absolute) + * @return the kilometers (difference) + */ + public static double longitudeToKilometer(double longitude, double latitude) { + return longitude * LONGITUDE_TO_KILOMETER_AT_ZERO_LATITUDE * Math.cos(Math.toRadians(latitude)); + } + + /** + * Converts a difference in kilometers to a difference in longitude (rough estimation) + * + * @param kilometer the kilometers (difference) + * @param latitude the latitude (absolute) + * @return the longitude (difference) + */ + public static double kilometerToLongitude(double kilometer, double latitude) { + return kilometer / longitudeToKilometer(1.0f, latitude); + } + + /** + * Converts a difference in longitude to a difference in meters (rough estimation) + * + * @param longitude the longitude (difference) + * @param latitude the latitude (absolute) + * @return the meters (difference) + */ + public static double longitudeToMeter(double longitude, double latitude) { + return longitudeToKilometer(longitude, latitude) * KILOMETER_TO_METER; + } + + /** + * Converts a difference in meters to a difference in longitude (rough estimation) + * + * @param meter the meters (difference) + * @param latitude the latitude (absolute) + * @return the longitude (difference) + */ + public static double meterToLongitude(double meter, double latitude) { + return meter / longitudeToMeter(1.0f, latitude); + } + + /** + * Calculates the difference from the start position to the end position (in meters) + * + * @param start the start position + * @param end the end position + * @return the distance in meters + */ + public static double calculateDistance(Point start, Point end) { + return calculateDistance(start.latitude, start.longitude, end.latitude, end.longitude); + } + + /** + * Calculates the difference from the start position to the end position (in meters) + * + * @param startLatitude the latitude of the start position + * @param startLongitude the longitude of the start position + * @param endLatitude the latitude of the end position + * @param endLongitude the longitude of the end position + * @return the distance in meters + */ + public static double calculateDistance(double startLatitude, double startLongitude, double endLatitude, double endLongitude) { + float[] results = new float[3]; + Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results); + return results[0]; + } + + /** + * Attaches or detaches a listener that informs about certain events + * + * @param listener the `EasyWayLocation.Listener` instance to attach or `null` to detach + */ + public void setListener(final Listener listener) { + mListener = listener; + } + + public boolean locationEnabled() { + try { + gps_enabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + } catch (Exception ex) { + } + + try { + network_enabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); + } catch (Exception ex) { + } + + return !(!gps_enabled && !network_enabled); + + + } + + /** + * Whether the device has location access enabled in the settings + * + * @return whether location access is enabled or not + */ + public boolean hasLocationEnabled() { + return hasLocationEnabled(getProviderName()); + } + + private boolean hasLocationEnabled(final String providerName) { + try { + return mLocationManager.isProviderEnabled(providerName); + } catch (Exception e) { + return false; + } + } + + /** + * Starts updating the location and requesting new updates after the defined interval + */ + @SuppressLint("MissingPermission") + public void beginUpdates() { + if (mLocationListener != null) { + endUpdates(); + } + + if (!mRequireNewLocation) { + mPosition = getCachedPosition(); + } + + mLocationListener = createLocationListener(); + mLocationManager.requestLocationUpdates(getProviderName(), mInterval, 25, mLocationListener); + } + + /** + * Stops the location updates when they aren't needed anymore so that battery can be saved + */ + @SuppressLint("MissingPermission") + public void endUpdates() { + if (mLocationListener != null) { + mLocationManager.removeUpdates(mLocationListener); + mLocationListener = null; + } + } + + /** + * Blurs the specified location with the defined blur radius or returns an unchanged location if no blur radius is set + * + * @param originalLocation the original location received from the device + * @return the blurred location + */ + private Location blurWithRadius(final Location originalLocation) { + if (mBlurRadius <= 0) { + return originalLocation; + } else { + Location newLocation = new Location(originalLocation); + + double blurMeterLong = calculateRandomOffset(mBlurRadius) / SQUARE_ROOT_TWO; + double blurMeterLat = calculateRandomOffset(mBlurRadius) / SQUARE_ROOT_TWO; + + newLocation.setLongitude(newLocation.getLongitude() + meterToLongitude(blurMeterLong, newLocation.getLatitude())); + newLocation.setLatitude(newLocation.getLatitude() + meterToLatitude(blurMeterLat)); + + return newLocation; + } + } + + /** + * Returns the current position as a Point instance + * + * @return the current location (if any) or `null` + */ + public Point getPosition() { + if (mPosition == null) { + return null; + } else { + Location position = blurWithRadius(mPosition); + return new Point(position.getLatitude(), position.getLongitude()); + } + } + + /** + * Returns the latitude of the current location + * + * @return the current latitude (if any) or `0` + */ + public double getLatitude() { + if (mPosition == null) { + return 0.0f; + } else { + Location position = blurWithRadius(mPosition); + return position.getLatitude(); + } + } + + /** + * Returns the longitude of the current location + * + * @return the current longitude (if any) or `0` + */ + public double getLongitude() { + if (mPosition == null) { + return 0.0f; + } else { + Location position = blurWithRadius(mPosition); + return position.getLongitude(); + } + } + + /** + * Returns the current speed + * + * @return the current speed (if detected) or `0` + */ + public float getSpeed() { + if (mPosition == null) { + return 0.0f; + } else { + return mPosition.getSpeed(); + } + } + + /** + * Returns the current altitude + * + * @return the current altitude (if detected) or `0` + */ + public double getAltitude() { + if (mPosition == null) { + return 0.0f; + } else { + return mPosition.getAltitude(); + } + } + + /** + * Sets the blur radius (in meters) to use for privacy reasons + * + * @param blurRadius the blur radius (in meters) + */ + public void setBlurRadius(final int blurRadius) { + mBlurRadius = blurRadius; + } + + /** + * Creates a new LocationListener instance used internally to listen for location updates + * + * @return the new LocationListener instance + */ + private LocationListener createLocationListener() { + return new LocationListener() { + + @Override + public void onLocationChanged(Location location) { + mPosition = location; + cachePosition(); + + if (mListener != null) { + mListener.onPositionChanged(); + } + } + + @Override + public void onStatusChanged(String provider, int status, Bundle extras) { + } + + @Override + public void onProviderEnabled(String provider) { + } + + @Override + public void onProviderDisabled(String provider) { + } + + }; + } + + /** + * Returns the name of the location provider that matches the specified settings + * + * @return the provider's name + */ + private String getProviderName() { + return getProviderName(mRequireFine); + } + + /** + * Returns the name of the location provider that matches the specified settings and depends on the given granularity + * + * @param requireFine whether to require fine location or use coarse location + * @return the provider's name + */ + private String getProviderName(final boolean requireFine) { + // if fine location (GPS) is required + if (requireFine) { + // we just have to decide between active and passive mode + + if (mPassive) { + return PROVIDER_FINE_PASSIVE; + } else { + return PROVIDER_FINE; + } + } + // if both fine location (GPS) and coarse location (network) are acceptable + else { + // if we can use coarse location (network) + if (hasLocationEnabled(PROVIDER_COARSE)) { + // if we wanted passive mode + if (mPassive) { + // throw an exception because this is not possible + throw new RuntimeException("There is no passive provider for the coarse location"); + } + // if we wanted active mode + else { + // use coarse location (network) + return PROVIDER_COARSE; + } + } + // if coarse location (network) is not available + else { + // if we can use fine location (GPS) + if (hasLocationEnabled(PROVIDER_FINE) || hasLocationEnabled(PROVIDER_FINE_PASSIVE)) { + // we have to use fine location (GPS) because coarse location (network) was not available + return getProviderName(true); + } + // no location is available so return the provider with the minimum permission level + else { + return PROVIDER_COARSE; + } + } + } + } + + /** + * Returns the last position from the cache + * + * @return the cached position + */ + @SuppressLint("MissingPermission") + private Location getCachedPosition() { + if (mCachedPosition != null) { + return mCachedPosition; + } else { + try { + return mLocationManager.getLastKnownLocation(getProviderName()); + } catch (Exception e) { + return null; + } + } + } + + /** + * Caches the current position + */ + private void cachePosition() { + if (mPosition != null) { + mCachedPosition = mPosition; + } + } + + @Override + public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { + Toast.makeText(context, "failed", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onConnected(@Nullable Bundle bundle) { + + LocationRequest mLocationRequest = new LocationRequest(); + LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest); + PendingResult result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build()); + + result.setResultCallback(new ResultCallback() { + @Override + public void onResult(@NonNull LocationSettingsResult result1) { + Status status = result1.getStatus(); + final LocationSettingsStates states = result1.getLocationSettingsStates(); + switch (status.getStatusCode()) { + case LocationSettingsStatusCodes.SUCCESS: + mListener.locationOn(); + break; + case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: + try { + + status.startResolutionForResult((Activity) context, LOCATION_SETTING_REQUEST_CODE); + + } catch (IntentSender.SendIntentException e) { + + } + break; + case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: + locationReturn = false; + break; + } + + } + }); + } + + @Override + public void onConnectionSuspended(int i) { + } + + public Boolean checkLocation() { + return locationReturn; + } + + + + /** + * Wrapper for two coordinates (latitude and longitude) + */ + public static class Point implements Parcelable { + + public static final Creator CREATOR = new Creator() { + + @Override + public Point createFromParcel(Parcel in) { + return new Point(in); + } + + @Override + public Point[] newArray(int size) { + return new Point[size]; + } + + }; + /** + * The latitude of the point + */ + public final double latitude; + /** + * The longitude of the point + */ + public final double longitude; + + /** + * Constructs a new point from the given coordinates + * + * @param lat the latitude + * @param lon the longitude + */ + public Point(double lat, double lon) { + latitude = lat; + longitude = lon; + } + + private Point(Parcel in) { + latitude = in.readDouble(); + longitude = in.readDouble(); + } + + @Override + public String toString() { + return "(" + latitude + ", " + longitude + ")"; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeDouble(latitude); + out.writeDouble(longitude); + } + + } + + public void onActivityResult(int result) { + if (result == Activity.RESULT_OK) { + mListener.locationOn(); + } else if (result == Activity.RESULT_CANCELED) { + mListener.locationCancelled(); + } + } + + public void showAlertDialog(String title, String message, Drawable drawable){ + AlertDialog alertDialog = new AlertDialog.Builder(context).create(); + alertDialog.setTitle(title); + if (drawable != null) + { + alertDialog.setIcon(drawable); + } + alertDialog.setMessage(message); + alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + alertDialog.show(); + } + + public static String getAddress(Context context, Double latitude, Double longitude, boolean country, boolean fullAddress) { + String add = ""; + Geocoder geoCoder = new Geocoder(((Activity) context).getBaseContext(), Locale.getDefault()); + try { + List
addresses = geoCoder.getFromLocation(latitude, longitude, 1); + + if (addresses.size() > 0) { + if (country) { + add = addresses.get(0).getCountryName(); + } else if (fullAddress) { + add = addresses.get(0).getFeatureName() + "," + addresses.get(0).getSubLocality() + "," + addresses.get(0).getSubAdminArea() + "," + addresses.get(0).getPostalCode() + "," + addresses.get(0).getCountryName(); + } else { + add = addresses.get(0).getLocality(); + } + } + + + } catch (IOException e) { + e.printStackTrace(); + } + return add.replaceAll(",null", ""); + } + +} diff --git a/easywaylocation/src/main/java/com/example/easywaylocation/Listener.java b/easywaylocation/src/main/java/com/example/easywaylocation/Listener.java new file mode 100644 index 0000000..95e7b24 --- /dev/null +++ b/easywaylocation/src/main/java/com/example/easywaylocation/Listener.java @@ -0,0 +1,17 @@ +package com.example.easywaylocation; + +/** + * Created by prabhat on 11/2/18. + */ + +/** + * Callback that can be implemented in order to listen for events + */ + +public interface Listener { + void locationOn(); + + void onPositionChanged(); + + void locationCancelled(); +} diff --git a/easywaylocation/src/main/res/values/strings.xml b/easywaylocation/src/main/res/values/strings.xml new file mode 100644 index 0000000..1d6f04c --- /dev/null +++ b/easywaylocation/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + EasyWayLocation + OK + diff --git a/easywaylocation/src/test/java/com/example/easywaylocation/ExampleUnitTest.java b/easywaylocation/src/test/java/com/example/easywaylocation/ExampleUnitTest.java new file mode 100644 index 0000000..cb82777 --- /dev/null +++ b/easywaylocation/src/test/java/com/example/easywaylocation/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.easywaylocation; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aac7c9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..356fb91 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Feb 11 19:37:10 IST 2018 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..2fe8ecb --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app', ':easywaylocation'