[Android] Boolean field to identify TV Build

Geoffrey Métais git at videolan.org
Mon Apr 27 18:37:25 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 27 17:19:34 2015 +0200| [554b3afa7f0527c0dc106db255b6bcffbeeea678] | committer: Geoffrey Métais

Boolean field to identify TV Build

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

 vlc-android/build.gradle                           |    3 +++
 .../src/org/videolan/vlc/gui/MainActivity.java     |    2 +-
 .../videolan/vlc/gui/dialogs/AdvOptionsDialog.java |   20 ++++++++++----------
 .../videolan/vlc/gui/dialogs/PickTimeFragment.java |    3 ++-
 .../vlc/gui/video/VideoPlayerActivity.java         |   18 ++++++++++--------
 5 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index c1712be..5536f7f 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -82,16 +82,19 @@ android {
         vanilla {
             flavorDimension "target"
             versionCode = 0
+            buildConfigField "boolean", "tv", "false"
         }
         tv {
             minSdkVersion 17
             flavorDimension "target"
             versionCode = 1
+            buildConfigField "boolean", "tv", "true"
         }
         chrome {
             minSdkVersion 19
             flavorDimension "target"
             versionCode = 2
+            buildConfigField "boolean", "tv", "false"
         }
         ARMv5 {
             flavorDimension "abi"
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 1361ef8..5f40b37 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -901,7 +901,7 @@ public class MainActivity extends AppCompatActivity implements OnItemClickListen
      * @param settingKey the setting key to check if the view must be displayed or not.
      */
     public void showTipViewIfNeeded(final int layoutId, final String settingKey) {
-        if (!mSettings.getBoolean(settingKey, false) && AndroidDevices.hasTsp()) {
+        if (!mSettings.getBoolean(settingKey, false) && !BuildConfig.tv) {
             removeTipViewIfDisplayed();
             View v = LayoutInflater.from(this).inflate(layoutId, null);
             mRootContainer.addView(v,
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index d664cd3..437e304 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -147,12 +147,12 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
 
         mJumpTitle.setOnClickListener(this);
 
-        if (AndroidDevices.hasTsp()) {
+        if (BuildConfig.tv) {
+            root.findViewById(R.id.sleep_timer_container).setVisibility(View.GONE);
+        } else {
             mSleepTitle.setOnClickListener(this);
             mSleepTime.setOnClickListener(this);
             mSleepCancel.setOnClickListener(this);
-        } else {
-            root.findViewById(R.id.sleep_timer_container).setVisibility(View.GONE);
         }
 
         mReset.setOnFocusChangeListener(mFocusListener);
@@ -257,15 +257,13 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         if (mDelayController == null && getActivity() instanceof IDelayController)
             mDelayController = (IDelayController) getActivity();
         DialogFragment newFragment = null;
-        if (AndroidDevices.hasTsp()) {
+        if (BuildConfig.tv) {
             switch (action){
                 case PickTimeFragment.ACTION_AUDIO_DELAY:
-                    if (mDelayController != null)
-                        mDelayController.showAudioDelaySetting();
+                    newFragment = new AudioDelayDialog();
                     break;
                 case PickTimeFragment.ACTION_SPU_DELAY:
-                    if (mDelayController != null)
-                        mDelayController.showSubsDelaySetting();
+                    newFragment = new SubsDelayDialog();
                     break;
                 case PickTimeFragment.ACTION_JUMP_TO_TIME:
                     newFragment = new JumpToTimeDialog();
@@ -276,10 +274,12 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         } else {
             switch (action){
                 case PickTimeFragment.ACTION_AUDIO_DELAY:
-                    newFragment = new AudioDelayDialog();
+                    if (mDelayController != null)
+                        mDelayController.showAudioDelaySetting();
                     break;
                 case PickTimeFragment.ACTION_SPU_DELAY:
-                    newFragment = new SubsDelayDialog();
+                    if (mDelayController != null)
+                        mDelayController.showSubsDelaySetting();
                     break;
                 case PickTimeFragment.ACTION_JUMP_TO_TIME:
                     newFragment = new JumpToTimeDialog();
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
index 715d0e8..a5d00ac 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.java
@@ -38,6 +38,7 @@ import android.widget.EditText;
 import android.widget.TextView;
 
 import org.videolan.libvlc.LibVLC;
+import org.videolan.vlc.BuildConfig;
 import org.videolan.vlc.R;
 import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.Util;
@@ -101,7 +102,7 @@ public abstract class PickTimeFragment extends DialogFragment implements DialogI
         view.findViewById(R.id.jump_minutes_down).setOnClickListener(this);
         view.findViewById(R.id.jump_seconds_up).setOnClickListener(this);
         view.findViewById(R.id.jump_seconds_down).setOnClickListener(this);
-        if (!AndroidDevices.hasTsp()){
+        if (BuildConfig.tv){
             mHours.setInputType(InputType.TYPE_NULL);
             mMinutes.setInputType(InputType.TYPE_NULL);
             mSeconds.setInputType(InputType.TYPE_NULL);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 7f429de..fa139ef 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -98,6 +98,7 @@ import org.videolan.libvlc.IVideoPlayer;
 import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.LibVlcUtil;
 import org.videolan.libvlc.Media;
+import org.videolan.vlc.BuildConfig;
 import org.videolan.vlc.MediaDatabase;
 import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.MediaWrapperListPlayer;
@@ -501,7 +502,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
                     : getScreenOrientation());
             // Tips
             mOverlayTips = findViewById(R.id.player_overlay_tips);
-            if(!AndroidDevices.hasTsp() || mSettings.getBoolean(PREF_TIPS_SHOWN, false))
+            if(BuildConfig.tv || mSettings.getBoolean(PREF_TIPS_SHOWN, false))
                 mOverlayTips.setVisibility(View.GONE);
             else {
                 mOverlayTips.bringToFront();
@@ -908,17 +909,18 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
 
         if (System.currentTimeMillis() - mLastMove > JOYSTICK_INPUT_DELAY){
             if (Math.abs(x) > 0.3){
-                if (AndroidDevices.hasTsp()) {
-                    seekDelta(x > 0.0f ? 10000 : -10000);
-                } else
+                if (BuildConfig.tv) {
                     navigateDvdMenu(x > 0.0f ? KeyEvent.KEYCODE_DPAD_RIGHT : KeyEvent.KEYCODE_DPAD_LEFT);
+                } else
+                    seekDelta(x > 0.0f ? 10000 : -10000);
             } else if (Math.abs(y) > 0.3){
-                if (AndroidDevices.hasTsp()) {
+                if (BuildConfig.tv)
+                    navigateDvdMenu(x > 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN);
+                else {
                     if (mIsFirstBrightnessGesture)
                         initBrightnessTouch();
                     changeBrightness(-y / 10f);
-                } else
-                    navigateDvdMenu(x > 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN);
+                }
             } else if (Math.abs(rz) > 0.3){
                 mVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
                 int delta = -(int) ((rz / 7) * mAudioMax);
@@ -936,7 +938,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
             mLockBackButton = false;
             mHandler.sendEmptyMessageDelayed(RESET_BACK_LOCK, 2000);
             Toast.makeText(this, getString(R.string.back_quit_lock), Toast.LENGTH_SHORT).show();
-        } else if (!AndroidDevices.hasTsp() && mShowing && !mIsLocked) {
+        } else if (BuildConfig.tv && mShowing && !mIsLocked) {
             hideOverlay(true);
         } else
             super.onBackPressed();



More information about the Android mailing list