Skip to content

Commit 78e5bf3

Browse files
U-METAL103\103U-METAL103\103
authored andcommitted
55897-elys
1 parent bd1968b commit 78e5bf3

30 files changed

Lines changed: 258 additions & 178 deletions

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ android {
104104
}
105105

106106
dependencies {
107-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'
108-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'
107+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1'
108+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'
109109
// https://developer.android.com/jetpack/androidx/versions
110-
implementation 'com.google.android.material:material:1.11.0'
111-
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
110+
implementation 'com.google.android.material:material:1.12.0'
111+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2"
112112
implementation 'androidx.cardview:cardview:1.0.0'
113-
implementation 'androidx.core:core-ktx:1.13.0'
113+
implementation 'androidx.core:core-ktx:1.13.1'
114114
implementation 'androidx.media:media:1.7.0'
115115
implementation 'androidx.preference:preference-ktx:1.2.1'
116116
implementation 'androidx.recyclerview:recyclerview:1.3.2'

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<!-- modded by ELY M. -->
2222

2323
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
24-
android:versionCode="55887"
25-
android:versionName="55887-elys">
24+
android:versionCode="55897"
25+
android:versionName="55897-elys">
2626

2727
<uses-permission android:name="android.permission.INTERNET" />
2828
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
@@ -37,12 +37,7 @@
3737
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
3838
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
3939
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
40-
<!-- Added for telecine API34 -->
41-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
42-
<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
43-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
44-
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
45-
40+
4641
<queries>
4742
<intent>
4843
<action android:name="android.intent.action.MAIN" />
@@ -495,9 +490,6 @@
495490
android:name=".settings.SettingsHomeScreenActivity"
496491
android:label="Manage Home Screen"
497492
android:parentActivityName="WX" />
498-
<activity
499-
android:name=".audio.VoiceCommandActivity"
500-
android:theme="@style/Theme.Transparent" />
501493

502494
<provider
503495
android:name=".util.FileProvider"
@@ -533,7 +525,8 @@
533525
<provider
534526
android:name="WeatherDataProvider"
535527
android:exported="true"
536-
android:authorities="joshuatee.wx.weatherlistwidget.provider" />
528+
android:authorities="joshuatee.wx.weatherlistwidget.provider"
529+
tools:ignore="ExportedContentProvider" />
537530

538531
<service
539532
android:name="joshuatee.wx.notifications.WXJobService"

app/src/main/java/joshuatee/wx/audio/AudioPlayActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ abstract class AudioPlayActivity : AppCompatActivity() {
107107

108108
R.id.action_stop -> {
109109
if (UtilityTts.mediaPlayer != null) {
110-
UtilityTts.playMediaPlayer(1)
110+
UtilityTts.playMediaPlayer()
111111
}
112112
if (UtilityTts.mediaPlayer != null && !UtilityTts.mediaPlayer!!.isPlaying) {
113113
pause.setIcon(pausePressedIcon)

app/src/main/java/joshuatee/wx/audio/PlayListAdapter.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ internal class PlayListAdapter(val context: Context, private val dataSet: Mutabl
5151
with(holder) {
5252
label.text = items[0]
5353
timeAndSize.text = items[1]
54-
// val string = Utility.fromHtml(Utility.readPref(context, "PLAYLIST_" + items[0], ""))
55-
// val s = Utility.readPref(context, "PLAYLIST_" + items[0], "")
5654
contentPreview.text = Utility.readPref(context, "PLAYLIST_" + items[0], "")
5755
.replace(GlobalVariables.newline, " ")
5856
.take(maxLength)
@@ -61,7 +59,6 @@ internal class PlayListAdapter(val context: Context, private val dataSet: Mutabl
6159

6260
fun deleteItem(index: Int) {
6361
dataSet.removeAt(index)
64-
// notifyDataSetChanged()
6562
notifyItemRemoved(index)
6663
}
6764

app/src/main/java/joshuatee/wx/audio/SettingsPlaylistActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class SettingsPlaylistActivity : BaseActivity(), OnMenuItemClickListener {
169169

170170
private fun playItemFab() {
171171
if (UtilityTts.mediaPlayer != null) {
172-
UtilityTts.playMediaPlayer(1)
172+
UtilityTts.playMediaPlayer()
173173
}
174174
val icon = if (UtilityTts.mediaPlayer != null && !UtilityTts.mediaPlayer!!.isPlaying) {
175175
GlobalVariables.ICON_PAUSE_PRESSED

app/src/main/java/joshuatee/wx/audio/UtilityTTS.kt

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import java.io.IOException
3737
import java.util.Locale
3838
import kotlin.math.min
3939

40-
4140
object UtilityTts {
4241

4342
private var ttsInit = false
@@ -66,18 +65,18 @@ object UtilityTts {
6665
if (status != TextToSpeech.ERROR) {
6766
ttobjGlobal?.language = Locale.US
6867
}
68+
ttsInit = true
69+
ttobjGlobal?.setSpeechRate(Utility.readPrefInt(context, "TTS_SPEED_PREF", 10) / 10.0f)
6970
}
70-
ttsInit = true
71-
ttobjGlobal!!.setSpeechRate(Utility.readPrefInt(context, "TTS_SPEED_PREF", 10) / 10.0f)
7271
} catch (e: Exception) {
7372
UtilityLog.handleException(e)
7473
}
7574
}
7675

7776
fun shutdownTts() {
7877
ttobjGlobal.let {
79-
ttobjGlobal!!.stop()
80-
ttobjGlobal!!.shutdown()
78+
ttobjGlobal?.stop()
79+
ttobjGlobal?.shutdown()
8180
}
8281
}
8382

@@ -88,7 +87,7 @@ object UtilityTts {
8887

8988
private fun initMediaPlayer(context: Context) {
9089
mediaPlayer = MediaPlayer()
91-
mediaPlayer!!.setOnCompletionListener {
90+
mediaPlayer?.setOnCompletionListener {
9291
if (currentFile < fileCount) {
9392
playMediaPlayerFile(context, currentFile)
9493
currentFile += 1
@@ -116,12 +115,12 @@ object UtilityTts {
116115
initTts(context)
117116
}
118117
// clear the queue of any pending objects
119-
ttobjGlobal!!.stop()
118+
ttobjGlobal?.stop()
120119
if (!mpInit) {
121120
initMediaPlayer(context)
122121
}
123122
synthesizeText(context, Utility.readPref(context, "PLAYLIST_" + playlistArr[index], ""), prodg)
124-
ttobjGlobal!!.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
123+
ttobjGlobal?.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
125124
override fun onDone(utteranceId: String) {
126125
if (currentFile == 0 && utteranceId.contains(prodg)) {
127126
playMediaPlayerFile(context, 0)
@@ -149,12 +148,12 @@ object UtilityTts {
149148
initTts(context)
150149
}
151150
// clear the queue of any pending objects
152-
ttobjGlobal!!.stop()
151+
ttobjGlobal?.stop()
153152
if (!mpInit) {
154153
initMediaPlayer(context)
155154
}
156155
synthesizeText(context, txt, prod)
157-
ttobjGlobal!!.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
156+
ttobjGlobal?.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
158157
override fun onDone(utteranceId: String) {
159158
if (currentFile == 0 && utteranceId.contains(prod)) {
160159
playMediaPlayerFile(context, 0)
@@ -176,54 +175,31 @@ object UtilityTts {
176175

177176
private fun synthesizeText(context: Context, txtF: String, prod: String) {
178177
if (mediaPlayer != null && mediaPlayer!!.isPlaying) {
179-
mediaPlayer!!.stop()
178+
mediaPlayer?.stop()
180179
}
181180
val txt = UtilityTtsTranslations.translateAbbreviation(txtF)
182-
// val myHashRender = HashMap<String, String>()
183-
// val musicDir = context.getExternalFilesDir(Environment.DIRECTORY_MUSIC)
184-
// val wxDir = File(musicDir, GlobalVariables.PACKAGE_NAME)
185-
// if (!wxDir.exists() && !wxDir.mkdirs()) {
186-
// return
187-
// }
188181
val chunks = splitInChunks(Utility.fromHtml(txt))
189182
fileCount = chunks.size
190183
(0 until fileCount).forEach {
191-
// myHashRender.clear()
192-
// myHashRender[TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID] = it.toString() + prod
193-
// val fileName = File(wxDir, FILENAME + it.toString()).absolutePath
194-
// val fileName = File(context.filesDir, FILENAME + it.toString()).absolutePath
195184
val fileName = File(context.filesDir, FILENAME + it.toString())
196-
197-
// ttobjGlobal!!.synthesizeToFile(chunks[it], myHashRender, fileName)
198185
val bundle = Bundle()
199186
bundle.putString(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, it.toString() + prod)
200-
ttobjGlobal!!.synthesizeToFile(chunks[it], bundle, fileName, it.toString() + prod)
187+
ttobjGlobal?.synthesizeToFile(chunks[it], bundle, fileName, it.toString() + prod)
201188
}
202189
}
203190

204-
internal fun playMediaPlayer(status: Int) {
205-
if (status == 0) {
206-
mediaPlayer!!.start()
207-
}
208-
if (status == 1) {
209-
ttsIsPaused = if (!ttsIsPaused) {
210-
mediaPlayer!!.pause()
211-
true
212-
} else {
213-
mediaPlayer!!.start()
214-
false
215-
}
191+
internal fun playMediaPlayer() {
192+
ttsIsPaused = if (!ttsIsPaused) {
193+
mediaPlayer?.pause()
194+
true
195+
} else {
196+
mediaPlayer?.start()
197+
false
216198
}
217199
}
218200

219201
private fun playMediaPlayerFile(context: Context, fileNum: Int) {
220-
// val musicDir = context.getExternalFilesDir(Environment.DIRECTORY_MUSIC)
221-
// val wxDir = File(musicDir, GlobalVariables.PACKAGE_NAME)
222-
// if (!wxDir.exists() && !wxDir.mkdirs()) {
223-
// return
224-
// }
225202
mediaPlayer?.reset()
226-
// val fileName = File(wxDir, FILENAME + fileNum.toString()).absolutePath
227203
val fileName = File(context.filesDir, FILENAME + fileNum.toString()).absolutePath
228204
val uri = Uri.parse("file://$fileName")
229205
try {

app/src/main/java/joshuatee/wx/audio/UtilityVoiceCommand.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import joshuatee.wx.common.RegExp
2828
import joshuatee.wx.objects.Route
2929
import joshuatee.wx.settings.UtilityLocation
3030
import joshuatee.wx.util.Utility
31-
import joshuatee.wx.wpc.NationalTextActivity
3231

3332
object UtilityVoiceCommand {
3433

35-
fun processCommand(context: Context, vrStringOriginal: String, radarSiteArg: String, wfoOriginal: String, state: String): Boolean {
36-
var radarSite = radarSiteArg
37-
var wfo = wfoOriginal
34+
fun processCommand(context: Context, vrStringOriginal: String): Boolean {
35+
var radarSite = Location.rid
36+
var wfo = Location.wfo
37+
val state = Location.state
3838
var gotHit = true
3939
val tokens = RegExp.space.split(vrStringOriginal)
4040
when {
@@ -56,7 +56,7 @@ object UtilityVoiceCommand {
5656
wfo = tokens[1].uppercase(Locale.US)
5757
}
5858
if (wfo == "WPC") {
59-
Route(context, NationalTextActivity::class.java, NationalTextActivity.URL, arrayOf("pmdspd", "Short Range Forecast Discussion", "sound"))
59+
Route.wpcTextWithSound(context, "pmdspd", "Short Range Forecast Discussion")
6060
} else {
6161
Route.wfoText(context, arrayOf(wfo, "AFD", "sound"))
6262
}
@@ -122,7 +122,6 @@ object UtilityVoiceCommand {
122122

123123
vrStringOriginal.contains("forecast") -> {
124124
val forecast = Utility.readPref(context, "FCST", "")
125-
// UtilityTts.synthesizeTextAndPlay(context, forecast, "7day")
126125
Route.textPlaySound(context, forecast, "Forecast for " + Location.latLon.prettyPrint())
127126
}
128127

app/src/main/java/joshuatee/wx/audio/VoiceCommandActivity.kt

Lines changed: 0 additions & 73 deletions
This file was deleted.

app/src/main/java/joshuatee/wx/misc/TextScreenActivity.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ import joshuatee.wx.ui.VBox
3838
class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener {
3939

4040
//
41-
// arg0 URL or text chunk depending on if start with "http"
42-
// arg1 Title
43-
// arg2 if "sound" will play TTS on first load
41+
// Display raw text, if text is a URL download and display
42+
//
43+
// Arguments
44+
// 1: URL or text chunk depending on if start with "http"
45+
// 2: Title
46+
// 3: if "sound" will play TTS on first load
4447
//
4548

4649
companion object {
@@ -67,6 +70,7 @@ class TextScreenActivity : AudioPlayActivity(), OnMenuItemClickListener {
6770
cardText.text = url
6871
}
6972
html = url
73+
UtilityTts.conditionalPlay(arguments, 2, applicationContext, html, "textscreen")
7074
} else {
7175
getContent()
7276
}

app/src/main/java/joshuatee/wx/misc/UtilityHourly.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ object UtilityHourly {
9999

100100
private fun getString(locationNumber: Int): List<String> {
101101
var html = UtilityDownloadNws.getHourlyData(Location.getLatLon(locationNumber))
102-
if (html.length < 300) {
102+
if (html.length < 1000) {
103+
Thread.sleep(1000)
103104
html = UtilityDownloadNws.getHourlyData(Location.getLatLon(locationNumber))
104105
}
105106
val header = To.stringPadLeft("Time", 7) + " " +

0 commit comments

Comments
 (0)