Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .idea/.name
100644 → 100755
Empty file.
Empty file modified .idea/codeStyles/Project.xml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion .idea/compiler.xml
100644 → 100755

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

Empty file modified .idea/gradle.xml
100644 → 100755
Empty file.
Empty file modified .idea/jarRepositories.xml
100644 → 100755
Empty file.
12 changes: 9 additions & 3 deletions .idea/misc.xml
100644 → 100755

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

1 change: 1 addition & 0 deletions .idea/runConfigurations.xml
100644 → 100755

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

Empty file modified .idea/vcs.xml
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified app/.gitignore
100644 → 100755
Empty file.
2 changes: 0 additions & 2 deletions app/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ dependencies {

// baato library
implementation project(':baatolibrary')

// implementation 'com.github.baato:java-client:1.0.1'
}
Empty file modified app/proguard-rules.pro
100644 → 100755
Empty file.
Empty file.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="n">
<activity android:name="com.baato.osmnavigationapp.MainActivity">
<intent-filter>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/baato/osmnavigationapp/Constants.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.baato.osmnavigationapp;

public interface Constants {
String TOKEN = "{your-baato-token}";
String TOKEN = "your-baato-access-token";
}
3 changes: 1 addition & 2 deletions app/src/main/java/com/baato/osmnavigationapp/MainActivity.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public class MainActivity extends AppCompatActivity {

private static final String TAG = "apple";
String encoded = "wv{gD_`lhOQvAO^c@h@Yj@IZKhADXj@|ABrAElB@NLLp@LHFDJJvDb@pBx@~B`AjBBP@fCArBW|KSxEQbHGbAYhBKVmA`C}A`EuBrGcAxC}@hBA^BJb@`@dBr@tBbAh@RdDbBs@fCYxAmBnKy@`F_Gj[]zBS~AWjDC~AA|BBbBj@|JpB~YRrDbAjONlDD~AAbCuArj@o@nSkB~w@CzB{@x\\e@rLa@jN@zBO|DE|EQjBKp@W~@Sf@o@dAs@x@i@d@_@RkAj@_AP_AJmCDkBD}IDoFF_ETc@@iARyAf@UKa@_@YKk@KuBGu@Kq@MkA[k@SsB{@wCwAgAo@g@SsDiBa@OcJmE{IcEiAm@kJmEmAc@U?QA[IUK]EmI_@wBCk@Dm@FiCt@k@ViNvJ_BlAcAj@{@Xc@JuALsGN{@F_@Da@NeAn@WXWb@]fAIf@Al@Bt@`AvKVhDDpAMjB[jASb@yAzBiAvAuCfEYxAe@SmE}AsGeA_FiBwG_CsB_@sGq@{AWcA]eASuC{@g@IiDs@_BWy@FiG`BqCx@sFvA{JlC_APq@DqA?[CcAOgCg@qFqAgGkA{@Gk@@i@Dg@Je@NmAl@_^~R^p@lAlAdAv@^T~Al@t@l@F?b@MjChANBl@ATIDCFl@APNH?Ho@`CTf@HJ`@FJN?Je@fA[d@CJBJHJ@POv@HPFVd@ZBJAJa@v@bAf@JjAw@`@yAf@s@d@SHQAAf@c@C@p@YAm@R?n@SPkAPAB?|@g@HCLaAB";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,7 +40,7 @@ private void performRouting() {
.setAccessToken(Constants.TOKEN)
.setMode("foot")
.setAlternatives(false)
.setInstructions(true)
.setInstructions(false)
.withListener(new BaatoRouting.BaatoRoutingRequestListener() {
@Override
public void onSuccess(DirectionsAPIResponse directionResponse) {
Expand Down
Empty file modified app/src/main/res/drawable-v24/ic_launcher_foreground.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/drawable/ic_launcher_background.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/activity_main.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-hdpi/ic_launcher_round.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-mdpi/ic_launcher_round.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/values/colors.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values/strings.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values/styles.xml
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">baato.io</domain>
<domain includeSubdomains="true">192.168.123.240</domain>
</domain-config>
</network-security-config>
Empty file.
Empty file modified baatolibrary/.gitignore
100644 → 100755
Empty file.
17 changes: 9 additions & 8 deletions baatolibrary/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "29.0.2"


defaultConfig {
minSdkVersion 15
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -26,14 +26,14 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

//graphhopper
implementation(group: 'com.graphhopper', name: 'graphhopper-core', version: '2.2') {
Expand All @@ -43,4 +43,5 @@ dependencies {
}

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'
implementation 'commons-codec:commons-codec:1.14'
}
Empty file modified baatolibrary/consumer-rules.pro
100644 → 100755
Empty file.
Empty file modified baatolibrary/proguard-rules.pro
100644 → 100755
Empty file.
Empty file.
Empty file modified baatolibrary/src/main/AndroidManifest.xml
100644 → 100755
Empty file.
Empty file modified baatolibrary/src/main/assets/locale/en_US.txt
100644 → 100755
Empty file.
Empty file modified baatolibrary/src/main/assets/locale/ne.txt
100644 → 100755
Empty file.
10 changes: 2 additions & 8 deletions baatolibrary/src/main/java/com/baato/baatolibrary/application/BaatoLib.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package com.baato.baatolibrary.application;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.content.res.AssetManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.baato.baatolibrary.utilities.Retry;
import com.baato.baatolibrary.utilities.RetryInterceptor;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

Expand Down Expand Up @@ -43,7 +37,7 @@ public static Retrofit retrofitV2(String apiVersion, String apiBaseURL) {
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.writeTimeout(20, TimeUnit.SECONDS)
.addInterceptor(new Retry(4))
.addInterceptor(new RetryInterceptor(4))
.build();
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl(apiBaseURL+ "v" + apiVersion + "/")
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion baatolibrary/src/main/java/com/baato/baatolibrary/requests/BaatoAPI.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public interface BaatoAPI {
@GET("directions")
Call<DirectionsAPIResponse> getDirections(@Query("key") String key, @Query("points[]") String[] points, @Query("mode") String mode, @Query("alternatives") Boolean alternatives, @Query("instructions") Boolean instructions);
Call<DirectionsAPIResponse> getDirections(@QueryMap Map<String, Object> filters, @Query("points[]") String[] points);

@GET("search")
Call<SearchAPIResponse> searchQuery(@QueryMap Map<String, String> filters);
Expand Down
24 changes: 20 additions & 4 deletions baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoPlace.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.baato.baatolibrary.models.ErrorResponse;
import com.baato.baatolibrary.models.PlaceAPIResponse;
import com.baato.baatolibrary.requests.BaatoAPI;
import com.baato.baatolibrary.utilities.BaatoUtil;
import com.baato.baatolibrary.utilities.ErrorUtils;

import java.io.IOException;
Expand All @@ -25,12 +26,13 @@
public class BaatoPlace {

private Context context;
private String accessToken;
private String accessToken, securityCode;
private String apiVersion = "1";
private String apiBaseUrl = "https://api.baato.io/api/";
private BaatoPlaceListener baatoPlaceListener;
private int placeId = 0;
private Call<PlaceAPIResponse> placeAPIResponseCall;

public interface BaatoPlaceListener {
/**
* onSuccess method called after it is successful
Expand Down Expand Up @@ -77,6 +79,14 @@ public BaatoPlace setAPIBaseURL(@NonNull String apiBaseURL) {
return this;
}

/**
* Set the securityCode is security enabled.
*/
public BaatoPlace setSecurityCode(String securityCode) {
this.securityCode = securityCode;
return this;
}

/**
* Method to set the UpdateListener for the AppUpdaterUtils actions
*
Expand All @@ -90,7 +100,7 @@ public BaatoPlace withListener(BaatoPlaceListener baatoPlaceListener) {

public void doRequest() {
BaatoAPI baatoAPI = BaatoLib.retrofitV2(apiVersion, apiBaseUrl).create(BaatoAPI.class);
placeAPIResponseCall = baatoAPI.performPlacesQuery(giveMeQueryFilter());
placeAPIResponseCall = baatoAPI.performPlacesQuery(giveMeQueryFilter(context));
placeAPIResponseCall.enqueue(new Callback<PlaceAPIResponse>() {
@Override
public void onResponse(Call<PlaceAPIResponse> call, Response<PlaceAPIResponse> response) {
Expand All @@ -108,16 +118,22 @@ public void onFailure(Call<PlaceAPIResponse> call, Throwable throwable) {
}
});
}

public void cancelRequest() {
placeAPIResponseCall.cancel();
placeAPIResponseCall.cancel();
}
private Map<String, String> giveMeQueryFilter() {

private Map<String, String> giveMeQueryFilter(Context context) {
Map<String, String> queryMap = new HashMap<>();
//compulsory ones
if (accessToken != null)
queryMap.put("key", accessToken);
if (placeId != 0)
queryMap.put("placeId", placeId + "");

//optional ones
if (securityCode != null && !securityCode.isEmpty())
queryMap.put("hash", BaatoUtil.generateHash(context.getPackageName(), accessToken, securityCode));
return queryMap;
}
}
20 changes: 15 additions & 5 deletions baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoReverse.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.baato.baatolibrary.services;

import android.content.Context;
import android.util.Log;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
Expand All @@ -12,6 +11,7 @@
import com.baato.baatolibrary.models.LatLon;

import com.baato.baatolibrary.requests.BaatoAPI;
import com.baato.baatolibrary.utilities.BaatoUtil;
import com.baato.baatolibrary.utilities.ErrorUtils;

import java.util.HashMap;
Expand All @@ -27,7 +27,7 @@ public class BaatoReverse {
private static final String TAG = "BaatoReverseGeoCode";
private Context context;
private BaatoReverseRequestListener baatoReverseRequestListener;
private String accessToken;
private String accessToken, securityCode;
private String apiVersion = "1";
private String apiBaseUrl = "https://api.baato.io/api/";
private int radius, limit = 0;
Expand Down Expand Up @@ -97,6 +97,14 @@ public BaatoReverse setLimit(@NonNull int limit) {
return this;
}

/**
* Set the securityCode is security enabled.
*/
public BaatoReverse setSecurityCode(String securityCode) {
this.securityCode = securityCode;
return this;
}

/**
* Method to set the UpdateListener for the AppUpdaterUtils actions
*
Expand All @@ -110,7 +118,7 @@ public BaatoReverse withListener(BaatoReverseRequestListener baatoReverseRequest

public void doRequest() {
BaatoAPI baatoAPI = BaatoLib.retrofitV2(apiVersion, apiBaseUrl).create(BaatoAPI.class);
placeAPIResponseCall=baatoAPI.performReverseGeoCode(giveMeQueryFilter());
placeAPIResponseCall = baatoAPI.performReverseGeoCode(giveMeQueryFilter(context));
placeAPIResponseCall.enqueue(new Callback<PlaceAPIResponse>() {
@Override
public void onResponse(Call<PlaceAPIResponse> call, Response<PlaceAPIResponse> response) {
Expand All @@ -120,7 +128,6 @@ public void onResponse(Call<PlaceAPIResponse> call, Response<PlaceAPIResponse> r
try {
ErrorResponse errorResponse = ErrorUtils.parseError(response, apiVersion, apiBaseUrl);
baatoReverseRequestListener.onFailed(new Throwable(errorResponse.getMessage()));
// baatoReverseRequestListener.onFailed(new Throwable(response.errorBody().string()));
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -133,11 +140,12 @@ public void onFailure(Call<PlaceAPIResponse> call, Throwable throwable) {
}
});
}

public void cancelRequest() {
placeAPIResponseCall.cancel();
}

private Map<String, String> giveMeQueryFilter() {
private Map<String, String> giveMeQueryFilter(Context context) {
Map<String, String> queryMap = new HashMap<>();
//compulsory
if (accessToken != null)
Expand All @@ -150,6 +158,8 @@ private Map<String, String> giveMeQueryFilter() {
queryMap.put("lon", latLon.lon + "");

//optional
if (securityCode != null && !securityCode.isEmpty())
queryMap.put("hash", BaatoUtil.generateHash(context.getPackageName(), accessToken, securityCode));
if (radius != 0)
queryMap.put("radius", radius + "");

Expand Down
Loading