Skip to content

Commit 3120dba

Browse files
author
Chris Bellew
committed
Renamed PlexSearch service; Use password type for password entry field; Need to dispose of TextToSpeech object when activity finishes.
1 parent 4ee4bdb commit 3120dba

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

Voice Control For Plex/src/main/java/com/atomjack/vcfp/ListenerWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] ap
2525
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
2626
R.layout.widget_layout);
2727

28-
Intent serviceIntent = new Intent(context, PlexSearch.class);
28+
Intent serviceIntent = new Intent(context, PlexSearchService.class);
2929
SecureRandom random = new SecureRandom();
3030
serviceIntent.setData(Uri.parse(new BigInteger(130, random).toString(32)));
3131
PendingIntent resultsPendingIntent = PendingIntent.getService(context, 0, serviceIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

Voice Control For Plex/src/main/java/com/atomjack/vcfp/MainActivity.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public static final class PlexHeaders {
9090

9191
private Gson gson = new Gson();
9292

93+
private TextToSpeech tts;
94+
9395
Menu menu;
9496

9597
private boolean loggedIn = false;
@@ -133,11 +135,6 @@ public void onDeviceSelected(PlexDevice device) {
133135
else if(device instanceof PlexClient)
134136
setClient((PlexClient)device);
135137
}
136-
137-
@Override
138-
public void onFinishedScan() {
139-
140-
}
141138
});
142139
remoteScan = new RemoteScan(mPrefs);
143140

@@ -169,16 +166,6 @@ private void openAppInPlayStore(String packageName) {
169166
}
170167
}
171168

172-
private boolean hasValidGoogleSearch() {
173-
try
174-
{
175-
PackageInfo pinfo = getPackageManager().getPackageInfo("com.google.android.googlequicksearchbox", 0);
176-
if(VoiceControlForPlexApplication.isVersionLessThan(pinfo.versionName, "3.4"))
177-
return true;
178-
} catch(Exception e) {}
179-
return false;
180-
}
181-
182169
private boolean hasValidTasker() {
183170
PackageInfo pinfo;
184171
try
@@ -235,7 +222,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
235222
// success, create the TTS instance
236223
availableVoices = data.getStringArrayListExtra(TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
237224
// Need this or else voice selection won't show up:
238-
TextToSpeech tts = new TextToSpeech(this, this);
225+
tts = new TextToSpeech(this, this);
239226
} else {
240227
// missing data, install it
241228
Intent installIntent = new Intent();
@@ -370,7 +357,7 @@ public void onClick(DialogInterface dialog, int id) {
370357
mPrefsEditor.commit();
371358
Intent checkIntent = new Intent();
372359
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
373-
final TextToSpeech tts = new TextToSpeech(ctx, new TextToSpeech.OnInitListener() {
360+
tts = new TextToSpeech(ctx, new TextToSpeech.OnInitListener() {
374361
@Override
375362
public void onInit(int i) {
376363

@@ -710,6 +697,8 @@ protected void onDestroy() {
710697
LocalBroadcastManager.getInstance(this).unregisterReceiver(gdmReceiver);
711698
}
712699
feedback.destroy();
700+
if(tts != null)
701+
tts.shutdown();
713702
super.onDestroy();
714703
}
715704

Voice Control For Plex/src/main/java/com/atomjack/vcfp/PlayReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void onReceive(final Context context, final Intent intent)
1818

1919
if(queryText != null && queryText.matches(context.getResources().getString(R.string.pattern_recognition))) {
2020
queryText = queryText.toLowerCase();
21-
Intent sendIntent = new Intent(context, PlexSearch.class);
21+
Intent sendIntent = new Intent(context, PlexSearchService.class);
2222
sendIntent.setAction("com.atomjack.vcfp.intent.ACTION_SEARCH");
2323
sendIntent.putExtra("queryText", queryText);
2424
sendIntent.putExtra("ORIGIN", "Tasker");

Voice Control For Plex/src/main/java/com/atomjack/vcfp/PlexSearch.java renamed to Voice Control For Plex/src/main/java/com/atomjack/vcfp/PlexSearchService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import us.nineworlds.serenity.GDMReceiver;
3333

34-
public class PlexSearch extends Service {
34+
public class PlexSearchService extends Service {
3535

3636
public final static String PREFS = MainActivity.PREFS;
3737
private SharedPreferences mPrefs;
@@ -70,7 +70,7 @@ private interface AfterTransientTokenRequest {
7070
public int onStartCommand(Intent intent, int flags, int startId) {
7171
Logger.d("PlexSearch: onStartCommand");
7272

73-
BugSenseHandler.initAndStartSession(PlexSearch.this, MainActivity.BUGSENSE_APIKEY);
73+
BugSenseHandler.initAndStartSession(PlexSearchService.this, MainActivity.BUGSENSE_APIKEY);
7474

7575
videoPlayed = false;
7676

@@ -200,7 +200,7 @@ private void startup() {
200200
mServiceIntent = new Intent(this, GDMService.class);
201201
}
202202
mServiceIntent.setAction(VoiceControlForPlexApplication.Intent.GDMRECEIVE);
203-
mServiceIntent.putExtra("class", PlexSearch.class);
203+
mServiceIntent.putExtra("class", PlexSearchService.class);
204204
mServiceIntent.putExtra("ORIGIN", "PlexSearch");
205205
startService(mServiceIntent);
206206
feedback.m("Scanning for Plex Servers");

Voice Control For Plex/src/main/java/com/atomjack/vcfp/ShortcutActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ShortcutActivity extends Activity {
1414
@Override
1515
protected void onCreate(Bundle savedInstanceState) {
1616
super.onCreate(savedInstanceState);
17-
Intent serviceIntent = new Intent(getApplicationContext(), PlexSearch.class);
17+
Intent serviceIntent = new Intent(getApplicationContext(), PlexSearchService.class);
1818

1919
serviceIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_SERVER, getIntent().getStringExtra(VoiceControlForPlexApplication.Intent.EXTRA_SERVER));
2020
serviceIntent.putExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT, getIntent().getStringExtra(VoiceControlForPlexApplication.Intent.EXTRA_CLIENT));

Voice Control For Plex/src/main/res/layout/login.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<EditText
1515
android:id="@+id/passwordInput"
1616
android:layout_width="match_parent"
17-
android:inputType="text"
17+
android:inputType="textPassword"
1818
android:text=""
1919
android:hint="@string/password"
2020
android:layout_height="wrap_content" />

0 commit comments

Comments
 (0)