Skip to content

Commit bc4ce6f

Browse files
author
Arnav Gupta
committed
Fix TTS being an empty screen
1 parent 03c914c commit bc4ce6f

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

App/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
android:name="android.support.PARENT_ACTIVITY"
3737
android:value="MainActivity" />
3838
</activity>
39-
<activity android:name="in.ac.dtu.subtlenews.TTS" >
39+
<activity
40+
android:name="in.ac.dtu.subtlenews.TTS"
41+
android:theme="@android:style/Theme.Translucent.NoTitleBar">
4042
<meta-data
4143
android:name="android.support.PARENT_ACTIVITY"
4244
android:value="MainActivity" />

App/src/main/java/in/ac/dtu/subtlenews/MainFragment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.net.Uri;
1111
import android.os.AsyncTask;
1212
import android.os.Bundle;
13+
import android.speech.tts.TextToSpeech;
1314
import android.support.v4.app.Fragment;
1415
import android.util.Log;
1516
import android.view.Gravity;
@@ -191,6 +192,7 @@ public void onClick(DialogInterface dialog, int id) {
191192
}
192193
startActivity(tts);
193194

195+
194196
}
195197
})
196198
.setNegativeButton("Source", new DialogInterface.OnClickListener() {

App/src/main/java/in/ac/dtu/subtlenews/TTS.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
package in.ac.dtu.subtlenews;
22

33
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.Context;
6+
import android.content.DialogInterface;
7+
import android.content.Intent;
8+
import android.net.Uri;
49
import android.os.Bundle;
510
import android.speech.tts.TextToSpeech;
611
import android.util.Log;
12+
import android.view.ContextThemeWrapper;
13+
import android.widget.TextView;
14+
15+
import org.json.JSONException;
716

817
import java.util.Locale;
918

@@ -26,6 +35,25 @@ public void onCreate(Bundle savedInstanceState) {
2635

2736
tts = new TextToSpeech(this, this);
2837
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
38+
AlertDialog summaryBox = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AppTheme))
39+
.setMessage(text)
40+
.setOnDismissListener(new DialogInterface.OnDismissListener() {
41+
@Override
42+
public void onDismiss(DialogInterface dialogInterface) {
43+
finish();
44+
45+
}
46+
})
47+
.setOnCancelListener(new DialogInterface.OnCancelListener() {
48+
@Override
49+
public void onCancel(DialogInterface dialogInterface) {
50+
finish();
51+
}
52+
})
53+
.show();
54+
TextView summaryText = (TextView) summaryBox.findViewById(android.R.id.message);
55+
summaryText.setTextSize(12);
56+
2957

3058
}
3159

@@ -56,8 +84,14 @@ public void onInit(int status) {
5684
Log.e("TTS", "Initilization Failed!");
5785
}
5886
}
59-
60-
//private void speakOut() {
61-
//}
62-
87+
/*
88+
@Override
89+
public void onBackPressed() {
90+
if (tts != null) {
91+
tts.stop();
92+
tts.shutdown();
93+
}
94+
super.onDestroy();
95+
}
96+
*/
6397
}

App/src/main/res/values-v11/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<resources>
22

3-
<style name="FullscreenTheme" parent="android:Theme.Holo">
3+
<style name="FullscreenTheme" parent="android:Theme.Holo.Light.DarkActionBar">
44
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
55
<item name="android:windowActionBarOverlay">true</item>
66
<item name="android:windowBackground">@null</item>

App/src/main/res/values/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
<item name="android:background">@android:drawable/bottom_bar</item>
2222
</style>
2323

24+
<style name="AlertDialogCustom" parent="Theme.AppCompat.Base.CompactMenu.Dialog">
25+
<item name="android:textColor">#222222</item>
26+
<item name="android:textSize">12pt</item>
27+
</style>
28+
2429
<style name="ButtonBarButton" />
2530

2631
</resources>

0 commit comments

Comments
 (0)