Skip to content

Commit

Permalink
Merge pull request #10 from baato/translation_map
Browse files Browse the repository at this point in the history
updated dynamic camera zoom preference
  • Loading branch information
Bhawak authored Sep 28, 2020
2 parents 37d4698 + 93f6130 commit 3e8d9b7
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 38 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name=".OSMNavigation"
Expand All @@ -32,7 +31,8 @@
</intent-filter>
</activity>
<activity android:name=".navigation.view.MockNavigationActivity" />
<!-- <activity android:name=".navigation.view.ComponentNavigationActivity" />-->
<activity android:name=".navigation.view.ComponentNavigationActivity" />
<!-- <activity android:name=".navigation.view.ComponentNavigationActivity" />-->
</application>

</manifest>
14 changes: 7 additions & 7 deletions app/src/main/assets/locale/ne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

continue=गई राख्नुहोस्
continue_onto=%1$s गई राख्नुहोस्
turn_left=बाया मोड्नुहोस्
turn_right=दाया मोड्नुहोस्
turn_slight_left=थोरै बाया मोड्नुहोस्
turn_slight_right=थोरै दाया मोड्नुहोस्
turn_sharp_left=धेरै बाया मोड्नुहोस्
turn_sharp_right=धेरै दाया मोड्नुहोस्
turn_left=बाया मोड्नु होस्
turn_right=दाया मोड्नु होस्
turn_slight_left=थोरै बाया मोड्नु होस्
turn_slight_right=थोरै दाया मोड्नु होस्
turn_sharp_left=धेरै बाया मोड्नु होस्
turn_sharp_right=धेरै दाया मोड्नु होस्
keep_left=बाया तर्फ गई राख्नुहोस्
keep_right=दाया तर्फ गई राख्नुहोस्
turn_onto=%2$s मा %1$s
u_turn=पुरा मोड्नुहोस्
u_turn=पुरा मोड्नु होस्
arrive=तपाईं आफ्नो गन्तव्यमा पुग्नुहुनेछ
unknown=
web.search_button=खोज
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/com/bhawak/osmnavigation/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback,
MapboxMap.OnMapClickListener, LocationListener, PermissionsListener, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
public class MainActivity extends AppCompatActivity implements PermissionsListener, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener,OnMapReadyCallback, MapboxMap.OnMapClickListener {
private static final int CAMERA_ANIMATION_DURATION = 1000;
private static final int DEFAULT_CAMERA_ZOOM = 16;
private static final int CHANGE_SETTING_REQUEST_CODE = 1;
Expand Down Expand Up @@ -364,8 +363,8 @@ public void onClick(View v) {
// .shouldSimulateRoute(simulateRoute)
// .build();
// NavigationLauncher.startNavigation(MainActivity.this, options);
Intent intent = new Intent(MainActivity.this, MockNavigationActivity.class);
// Intent intent = new Intent(MainActivity.this, ComponentNavigationActivity.class);
// Intent intent = new Intent(MainActivity.this, MockNavigationActivity.class);
Intent intent = new Intent(MainActivity.this, ComponentNavigationActivity.class);
intent.putExtra("Route",directionsResponse);
intent.putExtra("origin", originPoint);
intent.putExtra("lastLocation", mylocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

import retrofit2.http.Header;

public class


InstructionResponse {
public class InstructionResponse {
public static final int UNKNOWN = -99;
public static final int U_TURN_UNKNOWN = -98;
public static final int U_TURN_LEFT = -8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Simple class that extends the TranslationMap to add new translations.
*
* @author Robin Boldt
* @author Bhawak
*/
public class NavigateResponseConverterTranslationMap extends BaatoTranslationMap {
private String translation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.bhawak.osmnavigation.navigation;

import com.graphhopper.util.TranslationMap;

import java.util.Locale;

//import static com.graphhopper.navigation.DistanceUtils.meterToKilometer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.baato.baatolibrary.models.DirectionsAPIResponse;
import com.baato.baatolibrary.services.BaatoRouting;
import com.bhawak.osmnavigation.MainActivity;
import com.bhawak.osmnavigation.NavAPIResponse;
import com.bhawak.osmnavigation.NavigationResponse;
import com.bhawak.osmnavigation.R;
import com.bhawak.osmnavigation.navigation.DirectionAPIResponse;
import com.bhawak.osmnavigation.navigation.DistanceConfig;
Expand Down Expand Up @@ -606,15 +608,15 @@ private void getRoute(Point origin, Point destination, boolean isOffRoute) {
// }
// })
// .doRequest();
/*
Call<DirectionAPIResponse> call = MainActivity.getApiInterface().getRoutes(Constants.token, points, "car", false, true);
call.enqueue(new Callback<DirectionAPIResponse>() {

Call<NavAPIResponse> call = MainActivity.getApiInterface().getNavigationRoute(Constants.token, points, "car", false, true);
call.enqueue(new Callback<NavAPIResponse>() {
@Override
public void onResponse(Call<DirectionAPIResponse> call, Response<DirectionAPIResponse> response) {
NavResponse navResponse = null;
if (response.body() != null) {
navResponse = response.body().getData().get(0);
ObjectNode obj = NavigateResponseConverter.convertFromGHResponse(navResponse, "car");
public void onResponse(Call<NavAPIResponse> call, Response<NavAPIResponse> response) {
if (response.body() != null && response.body().getMessage().equals("Success")) {
NavigationResponse navResponse = response.body().getData().get(0);
Locale locale = new Locale("ne", "NP");
ObjectNode obj = NavigateResponseConverter.convertFromGHResponse(navResponse, "car", locale);

// Timber.d("On direction:" + obj);

Expand All @@ -626,13 +628,12 @@ public void onResponse(Call<DirectionAPIResponse> call, Response<DirectionAPIRes
}
}
@Override
public void onFailure(Call<DirectionAPIResponse> call, Throwable t) {
public void onFailure(Call<NavAPIResponse> call, Throwable t) {
Timber.d(t, "onFailure:");
Timber.d("Request:%s", call.request());
}
});

*/
}

private void handleRoute(DirectionsResponse response, boolean isOffRoute) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import android.os.VibrationEffect;
import android.os.Vibrator;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
Expand Down Expand Up @@ -109,6 +110,7 @@ public class MockNavigationActivity extends AppCompatActivity implements OnMapRe
private static final double DEFAULT_BEARING = 0d;
private static final int ONE_SECOND_INTERVAL = 1000;
private static final int BEGIN_ROUTE_MILESTONE = 1001;
private TextToSpeech mTts;

@BindView(R.id.componentNavigationLayout)
ConstraintLayout navigationLayout;
Expand Down Expand Up @@ -193,10 +195,9 @@ protected void onCreate(Bundle savedInstanceState) {

// Will call onMapReady
mapView.getMapAsync(this);
CustomNavigationNotification customNotification = new CustomNavigationNotification(getApplicationContext());
// CustomNavigationNotification customNotification = new CustomNavigationNotification(getApplicationContext());
// .navigationNotification(customNotification)
MapboxNavigationOptions options = MapboxNavigationOptions.builder()
.navigationNotification(customNotification)
.defaultMilestonesEnabled(true)
.build();
navigation = new MapboxNavigation(this, Constants.token, options);
Expand All @@ -215,7 +216,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Trigger.gte(TriggerProperty.STEP_DISTANCE_TRAVELED_METERS, 5)
// )
// ).build());
customNotification.register(new MyBroadcastReceiver(navigation), getApplicationContext());
// customNotification.register(new MyBroadcastReceiver(navigation), getApplicationContext());
}

private static class BeginRouteInstruction extends Instruction {
Expand Down Expand Up @@ -396,6 +397,16 @@ private void initializeSpeechPlayer() {
// String accessToken = "pk.xxx";
SpeechPlayerProvider speechPlayerProvider = new SpeechPlayerProvider(getApplication(), english, true, Constants.token);
speechPlayer = new NavigationSpeechPlayer(speechPlayerProvider);
mTts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(mTts.getEngines().size() == 0) {
Toast.makeText(MockNavigationActivity.this, "No voice engine found", Toast.LENGTH_SHORT).show();
} else {
mTts.setLanguage(locale);
}
}
});
// speechPlayer.speak(text, TextToSpeech.QUEUE_ADD, null);
}

Expand All @@ -404,13 +415,14 @@ private void showSnackbar(String text, int duration) {
}

private void playAnnouncement(Milestone milestone) {
// Log.d("Announcement", milestone.toString());
if (!isMuted) {
if (milestone instanceof VoiceInstructionMilestone) {
SpeechAnnouncement announcement = SpeechAnnouncement.builder()
.voiceInstructionMilestone((VoiceInstructionMilestone) milestone)
.build();
speechPlayer.play(announcement);
mTts.speak(announcement.announcement(), TextToSpeech.QUEUE_ADD, null);
Log.d("Announcement", announcement.announcement());
// speechPlayer.play(announcement);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o/classes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class DynamicCamera extends SimpleCamera {

private static final double MAX_CAMERA_TILT = 50d;
private static final double MIN_CAMERA_TILT = 35d;
private static final double MAX_CAMERA_ZOOM = 16d;
private static final double MIN_CAMERA_ZOOM = 12d;
private static final double MAX_CAMERA_ZOOM = 18d;
private static final double MIN_CAMERA_ZOOM = 14d;
private static final Point DEFAULT_TARGET = Point.fromLngLat(0d, 0d);

private MapboxMap mapboxMap;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o/classes
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 3e8d9b7

Please sign in to comment.