Skip to content

Commit

Permalink
under dev code
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhat1707 committed Aug 18, 2019
1 parent dbdca17 commit e307c21
Show file tree
Hide file tree
Showing 22 changed files with 1,596 additions and 307 deletions.
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file added .idea/caches/gradle_models.ser
Binary file not shown.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
compileSdkVersion 28
defaultConfig {
applicationId "com.example.prabhat.locationsample"
minSdkVersion 17
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
buildToolsVersion = '28.0.3'
}

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 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':easywaylocation')
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.prabhat.locationsample">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Expand All @@ -11,6 +12,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.example.prabhat.locationsample;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import com.example.easywaylocation.EasyWayLocation;
import com.example.easywaylocation.Listener;
import com.example.easywaylocation.draw_path.DirectionUtil;

import static com.example.easywaylocation.EasyWayLocation.LOCATION_SETTING_REQUEST_CODE;

public class MainActivity extends AppCompatActivity implements Listener {
EasyWayLocation easyWayLocation;
//EasyWayLocation easyWayLocation;
private TextView location, latLong, diff;
private Double lati, longi;
//private TestLocationRequest testLocationRequest;
private EasyWayLocation easyWayLocation;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -23,57 +32,63 @@ protected void onCreate(Bundle savedInstanceState) {
location = findViewById(R.id.location);
latLong = findViewById(R.id.latlong);
diff = findViewById(R.id.diff);
easyWayLocation = new EasyWayLocation(this);
easyWayLocation.setListener(this);
// DirectionUtil directionUtil = new DirectionUtil.Builder()
// .setDirectionKey("AIzaSyDUCCidq_7tBb0s1LRLhhvFyNqd0BeQBuI")
//
// testLocationRequest = new TestLocationRequest(this);
easyWayLocation = new EasyWayLocation(this, false,this);
if (permissionIsGranted()) {
doLocationWork();
} else {
// Permission not granted, ask for it
//testLocationRequest.requestPermission(121);
}
}

@Override
public void locationOn() {
Toast.makeText(this, "Location ON", Toast.LENGTH_SHORT).show();
easyWayLocation.beginUpdates();
diff.setText(String.valueOf(EasyWayLocation.calculateDistance(28.626686, 77.026409, 28.626799, 77.033619)));
}
public boolean permissionIsGranted() {

@Override
public void onPositionChanged() {
lati = easyWayLocation.getLatitude();
longi = easyWayLocation.getLongitude();
location.setText(EasyWayLocation.getAddress(this, lati, longi, false, true));
latLong.setText(String.valueOf(lati) + " " + String.valueOf(longi));
Toast.makeText(this, String.valueOf(easyWayLocation.getLongitude()) + "," + String.valueOf(easyWayLocation.getLatitude()), Toast.LENGTH_SHORT).show();
int permissionState = ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION);

return permissionState == PackageManager.PERMISSION_GRANTED;
}

@Override
public void locationCancelled() {
easyWayLocation.showAlertDialog(getString(R.string.loc_title), getString(R.string.loc_mess), null);
private void doLocationWork() {
easyWayLocation.startLocation();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case LOCATION_SETTING_REQUEST_CODE:
easyWayLocation.onActivityResult(resultCode);
break;
if (requestCode == LOCATION_SETTING_REQUEST_CODE) {
easyWayLocation.onActivityResult(resultCode);
}
}

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

// make the device update its location
easyWayLocation.beginUpdates();
@Override
protected void onPause() {
super.onPause();
easyWayLocation.endUpdates();

}

@Override
public void locationOn() {
}

@Override
protected void onPause() {
// stop location updates (saves battery)
easyWayLocation.endUpdates();
public void currentLocation(Location location) {
Log.v("location_test","------------>"+location.getLatitude());
}

@Override
public void locationCancelled() {

super.onPause();
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
19 changes: 10 additions & 9 deletions easywaylocation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.prabhat1707'
android {
compileSdkVersion 26
compileSdkVersion 28



defaultConfig {
minSdkVersion 16
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

Expand All @@ -22,15 +22,16 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
buildToolsVersion = '28.0.3'

}

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'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
}
Loading

0 comments on commit e307c21

Please sign in to comment.