source: other-projects/tipple-android/tipple-lib/src/org/mapsforge/android/maps/ArrayItemizedTextAudioOverlay.java@ 26899

Last change on this file since 26899 was 26899, checked in by davidb, 11 years ago

Tipple reborn after Chris's Summer of Code 2013

File size: 1.7 KB
Line 
1package org.mapsforge.android.maps;
2
3import org.greenstone.android.tipple.base.TippleActivity;
4
5import android.app.AlertDialog;
6import android.content.Context;
7import android.content.DialogInterface;
8import android.content.DialogInterface.OnCancelListener;
9import android.graphics.drawable.Drawable;
10import android.speech.tts.TextToSpeech;
11
12public 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
Note: See TracBrowser for help on using the repository browser.