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 | // ALERTBOX
|
---|
24 | @Override
|
---|
25 | public synchronized boolean onTap(int index) {
|
---|
26 | this.item = this.overlayItems.get(index);
|
---|
27 | this.dialog = new AlertDialog.Builder(this.context);
|
---|
28 | this.dialog.setTitle(this.item.getTitle());
|
---|
29 | this.dialog.setMessage(this.item.getSnippet());
|
---|
30 |
|
---|
31 | this.dialog.setOnCancelListener(new OnCancelListener() {
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public void onCancel(DialogInterface dialog) {
|
---|
35 | tts_.stop();
|
---|
36 | }
|
---|
37 | });
|
---|
38 |
|
---|
39 | dialogAlert = this.dialog.show();
|
---|
40 |
|
---|
41 | TippleActivity.log.optMessage("Manual Location Tap", "Title: " + item.getTitle());
|
---|
42 |
|
---|
43 | OverlayTextAudioItem ta_item = (OverlayTextAudioItem)this.overlayItems.get(index);
|
---|
44 | tts_.speak(ta_item.getTTSTitle(), TextToSpeech.QUEUE_FLUSH, null);
|
---|
45 | tts_.speak(ta_item.getTTSSnippet(), TextToSpeech.QUEUE_ADD, null);
|
---|
46 |
|
---|
47 | return true;
|
---|
48 | }
|
---|
49 |
|
---|
50 | public synchronized boolean unTap() {
|
---|
51 |
|
---|
52 | dialogAlert.cancel();
|
---|
53 | tts_.stop();
|
---|
54 | return true;
|
---|
55 | }
|
---|
56 |
|
---|
57 | /* public synchronized boolean onBackPressed() {
|
---|
58 |
|
---|
59 | dialogAlert.cancel();
|
---|
60 | tts_.stop();
|
---|
61 |
|
---|
62 | return true;
|
---|
63 | } */
|
---|
64 | }
|
---|
65 |
|
---|