[Android] Remove AUDIO_RECORD permission for TV

Geoffrey Métais git at videolan.org
Fri Oct 23 10:13:26 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 23 10:12:50 2015 +0200| [9d97be4811c2cf0721f4af3ea983e1e4c54dd495] | committer: Geoffrey Métais

Remove AUDIO_RECORD permission for TV

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9d97be4811c2cf0721f4af3ea983e1e4c54dd495
---

 vlc-android/tv/AndroidManifest.xml                 |    2 --
 .../org/videolan/vlc/gui/tv/SearchActivity.java    |   30 ++++++++++++++++++--
 .../org/videolan/vlc/gui/tv/SearchFragment.java    |    3 +-
 3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/vlc-android/tv/AndroidManifest.xml b/vlc-android/tv/AndroidManifest.xml
index 0cbb44e..64cca17 100644
--- a/vlc-android/tv/AndroidManifest.xml
+++ b/vlc-android/tv/AndroidManifest.xml
@@ -7,8 +7,6 @@
         android:minSdkVersion="17"
         android:targetSdkVersion="22" />
 
-    <!-- Needed for audio search on TV -->
-    <uses-permission android:name="android.permission.RECORD_AUDIO" />
     <!-- Launch recommendations service once device is booted -->
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchActivity.java
index 8718282..7a7688d 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchActivity.java
@@ -24,12 +24,38 @@ import org.videolan.vlc.R;
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.support.v17.leanback.widget.SpeechRecognitionCallback;
+import android.view.KeyEvent;
 
 public class SearchActivity extends Activity {
+
+    SearchFragment mFragment;
+    private static final int REQUEST_SPEECH = 1;
+
     @Override
-    public void onCreate(Bundle savedInstanceState)
-    {
+    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.tv_search);
+
+        mFragment = (SearchFragment) getFragmentManager()
+                .findFragmentById(R.id.search_fragment);
+
+        SpeechRecognitionCallback speechRecognitionCallback = new SpeechRecognitionCallback() {
+
+            @Override
+            public void recognizeSpeech() {
+                startActivityForResult(mFragment.getRecognizerIntent(), REQUEST_SPEECH);
+            }
+        };
+        mFragment.setSpeechRecognitionCallback(speechRecognitionCallback);
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_SEARCH) {
+            mFragment.startRecognition();
+            return true;
+        }
+        return super.onKeyDown(keyCode, event);
     }
 }
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchFragment.java
index 0b3514e..2d21ab1 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/SearchFragment.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import org.videolan.vlc.MediaLibrary;
 import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.R;
+import org.videolan.vlc.VLCApplication;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -71,7 +72,7 @@ public class SearchFragment extends android.support.v17.leanback.app.SearchFragm
         if (!TextUtils.isEmpty(words) && words.length() > 2) {
             mDelayedLoad.setSearchQuery(words);
             mDelayedLoad.setSearchType(MediaWrapper.TYPE_ALL);
-            new Thread(mDelayedLoad).start();
+            VLCApplication.runBackground(mDelayedLoad);
         }
     }
 



More information about the Android mailing list