1 | package org.mapsforge.android.maps;
|
---|
2 |
|
---|
3 | import org.greenstone.android.tipple.base.TippleActivity;
|
---|
4 |
|
---|
5 | import android.app.AlertDialog;
|
---|
6 | import android.content.Context;
|
---|
7 | import android.content.DialogInterface;
|
---|
8 | import android.content.DialogInterface.OnCancelListener;
|
---|
9 | import android.graphics.drawable.Drawable;
|
---|
10 | import android.speech.tts.TextToSpeech;
|
---|
11 |
|
---|
12 | public class ArrayItemizedTextAudioOverlay extends ArrayItemizedOverlayTweaked
|
---|
13 | {
|
---|
14 | protected final TextToSpeech tts_;
|
---|
15 | protected AlertDialog dialogAlert;
|
---|
16 |
|
---|
17 | public ArrayItemizedTextAudioOverlay(Drawable defaultMarker, Context context, TextToSpeech tts)
|
---|
18 | {
|
---|
19 | super(defaultMarker,context);
|
---|
20 | tts_ = tts;
|
---|
21 | }
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | public synchronized boolean onTap(int index) {
|
---|
25 | this.item = this.overlayItems.get(index);
|
---|
26 | this.dialog = new AlertDialog.Builder(this.context);
|
---|
27 | this.dialog.setTitle(this.item.getTitle());
|
---|
28 | this.dialog.setMessage(this.item.getSnippet());
|
---|
29 |
|
---|
30 | this.dialog.setOnCancelListener(new OnCancelListener() {
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public void onCancel(DialogInterface dialog) {
|
---|
34 | tts_.stop();
|
---|
35 | }
|
---|
36 | });
|
---|
37 |
|
---|
38 | dialogAlert = this.dialog.show();
|
---|
39 |
|
---|
40 | TippleActivity.log.optMessage("Manual Location Tap", "Title: " + item.getTitle());
|
---|
41 |
|
---|
42 | OverlayTextAudioItem ta_item = (OverlayTextAudioItem)this.overlayItems.get(index);
|
---|
43 | tts_.speak(ta_item.getTTSTitle(), TextToSpeech.QUEUE_FLUSH, null);
|
---|
44 | tts_.speak(ta_item.getTTSSnippet(), TextToSpeech.QUEUE_ADD, null);
|
---|
45 |
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public synchronized boolean unTap() {
|
---|
50 |
|
---|
51 | dialogAlert.cancel();
|
---|
52 | tts_.stop();
|
---|
53 | return true;
|
---|
54 | }
|
---|
55 |
|
---|
56 | /* public synchronized boolean onBackPressed() {
|
---|
57 |
|
---|
58 | dialogAlert.cancel();
|
---|
59 | tts_.stop();
|
---|
60 |
|
---|
61 | return true;
|
---|
62 | } */
|
---|
63 | }
|
---|
64 |
|
---|