Fix important issue
This commit is contained in:
parent
2c49581cee
commit
8eff8c62c9
5 changed files with 165 additions and 43 deletions
|
@ -49,6 +49,7 @@
|
||||||
<data android:scheme="geo"></data>
|
<data android:scheme="geo"></data>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".activities.TestVoiceActivity"></activity>
|
||||||
<activity android:name=".activities.LocalIndexesActivity" android:label="@string/local_index_descr_title"></activity>
|
<activity android:name=".activities.LocalIndexesActivity" android:label="@string/local_index_descr_title"></activity>
|
||||||
<service android:process="net.osmand.plus" android:label="@string/process_navigation_service" android:name=".NavigationService">
|
<service android:process="net.osmand.plus" android:label="@string/process_navigation_service" android:name=".NavigationService">
|
||||||
<intent-filter><action android:name="net.osmand.plus.NavigationService"></action></intent-filter>
|
<intent-filter><action android:name="net.osmand.plus.NavigationService"></action></intent-filter>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Stack;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
import net.osmand.Algoritms;
|
import net.osmand.Algoritms;
|
||||||
|
@ -45,34 +46,15 @@ public class AsyncLoadingThread extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startPoiLoadingThread() {
|
private void startPoiLoadingThread() {
|
||||||
if (asyncLoadingPoi == null) {
|
HandlerThread h = new HandlerThread("Loading poi");
|
||||||
Thread th = new Thread(new Runnable() {
|
h.start();
|
||||||
@Override
|
asyncLoadingPoi = new Handler(h.getLooper());
|
||||||
public void run() {
|
|
||||||
Looper.prepare();
|
|
||||||
asyncLoadingPoi = new Handler();
|
|
||||||
Looper.loop();
|
|
||||||
}
|
|
||||||
}, "Loading poi");
|
|
||||||
th.start();
|
|
||||||
}
|
|
||||||
while(asyncLoadingPoi != null){
|
|
||||||
// wait
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTransportLoadingThread() {
|
private void startTransportLoadingThread() {
|
||||||
new Thread(new Runnable() {
|
HandlerThread h = new HandlerThread("Loading transport");
|
||||||
@Override
|
h.start();
|
||||||
public void run() {
|
asyncLoadingTransport = new Handler(h.getLooper());
|
||||||
Looper.prepare();
|
|
||||||
asyncLoadingTransport = new Handler();
|
|
||||||
Looper.loop();
|
|
||||||
}
|
|
||||||
}, "Loading transport").start();
|
|
||||||
while(asyncLoadingTransport != null){
|
|
||||||
// wait
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateProgressStatus(){
|
private int calculateProgressStatus(){
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
private static final String MORE_VALUE = "MORE_VALUE";
|
private static final String MORE_VALUE = "MORE_VALUE";
|
||||||
|
|
||||||
private Preference saveCurrentTrack;
|
private Preference saveCurrentTrack;
|
||||||
|
private Preference testVoiceCommands;
|
||||||
|
|
||||||
private EditTextPreference applicationDir;
|
private EditTextPreference applicationDir;
|
||||||
private ListPreference tileSourcePreference;
|
private ListPreference tileSourcePreference;
|
||||||
|
@ -294,6 +295,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
localIndexes.setOnPreferenceClickListener(this);
|
localIndexes.setOnPreferenceClickListener(this);
|
||||||
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
|
saveCurrentTrack =(Preference) screen.findPreference(OsmandSettings.SAVE_CURRENT_TRACK);
|
||||||
saveCurrentTrack.setOnPreferenceClickListener(this);
|
saveCurrentTrack.setOnPreferenceClickListener(this);
|
||||||
|
testVoiceCommands =(Preference) screen.findPreference("test_voice_commands");
|
||||||
|
testVoiceCommands.setOnPreferenceClickListener(this);
|
||||||
routeServiceEnabled =(CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED);
|
routeServiceEnabled =(CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED);
|
||||||
routeServiceEnabled.setOnPreferenceChangeListener(this);
|
routeServiceEnabled.setOnPreferenceChangeListener(this);
|
||||||
applicationDir = (EditTextPreference) screen.findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR);
|
applicationDir = (EditTextPreference) screen.findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR);
|
||||||
|
@ -656,9 +659,22 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
if(preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)){
|
if(preference.getKey().equals(OsmandSettings.LOCAL_INDEXES)){
|
||||||
startActivity(new Intent(this, LocalIndexesActivity.class));
|
startActivity(new Intent(this, LocalIndexesActivity.class));
|
||||||
return true;
|
return true;
|
||||||
|
} else if(preference == testVoiceCommands){
|
||||||
|
startActivity(new Intent(this, TestVoiceActivity.class));
|
||||||
|
return true;
|
||||||
} else if(preference == saveCurrentTrack){
|
} else if(preference == saveCurrentTrack){
|
||||||
SavingTrackHelper helper = new SavingTrackHelper(this);
|
SavingTrackHelper helper = new SavingTrackHelper(this);
|
||||||
if (helper.hasDataToSave()) {
|
if (helper.hasDataToSave()) {
|
||||||
|
saveCurrentTracks();
|
||||||
|
} else {
|
||||||
|
helper.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveCurrentTracks() {
|
||||||
progressDlg = ProgressDialog.show(this, getString(R.string.saving_gpx_tracks), getString(R.string.saving_gpx_tracks), true);
|
progressDlg = ProgressDialog.show(this, getString(R.string.saving_gpx_tracks), getString(R.string.saving_gpx_tracks), true);
|
||||||
final ProgressDialogImplementation impl = new ProgressDialogImplementation(progressDlg);
|
final ProgressDialogImplementation impl = new ProgressDialogImplementation(progressDlg);
|
||||||
impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$
|
impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$
|
||||||
|
@ -677,12 +693,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
impl.run();
|
impl.run();
|
||||||
} else {
|
|
||||||
helper.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result){
|
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result){
|
||||||
|
|
125
OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java
Normal file
125
OsmAnd/src/net/osmand/plus/activities/TestVoiceActivity.java
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
|
||||||
|
import net.osmand.plus.voice.CommandBuilder;
|
||||||
|
import net.osmand.plus.voice.CommandPlayer;
|
||||||
|
import net.osmand.plus.voice.CommandPlayerException;
|
||||||
|
import net.osmand.plus.voice.CommandPlayerFactory;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Voice activity
|
||||||
|
*/
|
||||||
|
public class TestVoiceActivity extends Activity {
|
||||||
|
|
||||||
|
|
||||||
|
private CommandPlayer player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
|
||||||
|
final OsmandApplication app = ((OsmandApplication) getApplication());
|
||||||
|
app.showDialogInitializingCommandPlayer(this, true);
|
||||||
|
|
||||||
|
|
||||||
|
LinearLayout gl = new LinearLayout(this);
|
||||||
|
gl.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
gl.setPadding(3, 3, 3, 3);
|
||||||
|
|
||||||
|
TextView tv = new TextView(this);
|
||||||
|
tv.setText("Press buttons and listen various voice instructions, if you don't hear anything probably they are missed.");
|
||||||
|
tv.setPadding(0, 5, 0, 7);
|
||||||
|
|
||||||
|
ScrollView sv = new ScrollView(this);
|
||||||
|
gl.addView(sv, new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
|
||||||
|
android.view.ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
|
final LinearLayout ll = new LinearLayout(this);
|
||||||
|
ll.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
sv.addView(ll, new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
|
||||||
|
android.view.ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
|
|
||||||
|
// add buttons
|
||||||
|
new AsyncTask<Void, Void, CommandPlayer>() {
|
||||||
|
|
||||||
|
private ProgressDialog dlg;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
dlg = ProgressDialog.show(app, "Loading", "Initializing voice player...", true, false);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected CommandPlayer doInBackground(Void... params) {
|
||||||
|
try {
|
||||||
|
return CommandPlayerFactory.createCommandPlayer(app.getSettings().VOICE_PROVIDER.get(), app, TestVoiceActivity.this);
|
||||||
|
} catch (CommandPlayerException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(CommandPlayer p) {
|
||||||
|
dlg.dismiss();
|
||||||
|
if (p == null) {
|
||||||
|
Toast.makeText(TestVoiceActivity.this, "Voice player not initialized", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
addButtons(ll, p);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute((Void)null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setContentView(gl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addButtons(final LinearLayout ll, CommandPlayer p) {
|
||||||
|
addButton(ll, "New route is calculated (15350 m)", builder(p).newRouteCalculated(15350));
|
||||||
|
addButton(ll, "Prepare 400 m make UT", builder(p).prepareMakeUT(400));
|
||||||
|
addButton(ll, "Prepare 320 m make right turn", builder(p).prepareTurn(AbstractPrologCommandPlayer.A_RIGHT, 320));
|
||||||
|
addButton(ll, "In 370 m make right sharp turn", builder(p).turn(AbstractPrologCommandPlayer.A_RIGHT_SH, 320));
|
||||||
|
ll.forceLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private CommandBuilder builder(CommandPlayer p){
|
||||||
|
return p.newCommandBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addButton(ViewGroup layout, String description, final CommandBuilder builder){
|
||||||
|
Button button = new Button(this);
|
||||||
|
button.setText(description);
|
||||||
|
button.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
||||||
|
button.setPadding(10, 5, 10, 2);
|
||||||
|
|
||||||
|
layout.addView(button);
|
||||||
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
builder.play();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -60,6 +60,10 @@ public class VoiceRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CommandPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMute(boolean mute) {
|
public void setMute(boolean mute) {
|
||||||
this.mute = mute;
|
this.mute = mute;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue