Search in sources :

Example 6 with ViewStubCompat

use of android.support.v7.widget.ViewStubCompat in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method initOverlay.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void initOverlay() {
    final ViewStubCompat vsc = findViewById(R.id.player_hud_stub);
    if (vsc != null) {
        mSeekButtons = mSettings.getBoolean("enable_seek_buttons", false);
        vsc.inflate();
        mHudBinding = DataBindingUtil.bind(findViewById(R.id.progress_overlay));
        mHudBinding.setPlayer(this);
        updateTimeValues();
        mHudBinding.setProgress(mProgress);
        mHudBinding.setLength(mMediaLength);
        final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHudBinding.progressOverlay.getLayoutParams();
        if (AndroidDevices.isPhone || !AndroidDevices.hasNavBar)
            layoutParams.width = LayoutParams.MATCH_PARENT;
        else
            layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        mHudBinding.progressOverlay.setLayoutParams(layoutParams);
        mOverlayBackground = findViewById(R.id.player_overlay_background);
        mNavMenu = findViewById(R.id.player_overlay_navmenu);
        if (!AndroidDevices.isChromeBook && AndroidUtil.isJellyBeanMR1OrLater) {
            mRendererBtn = findViewById(R.id.video_renderer);
            RendererDelegate.INSTANCE.getSelectedRenderer().observe(this, new Observer<RendererItem>() {

                @Override
                public void onChanged(@android.support.annotation.Nullable RendererItem rendererItem) {
                    if (mRendererBtn != null)
                        mRendererBtn.setImageResource(rendererItem == null ? R.drawable.ic_renderer_circle : R.drawable.ic_renderer_on_circle);
                }
            });
            RendererDelegate.INSTANCE.getRenderers().observe(this, new Observer<List<RendererItem>>() {

                @Override
                public void onChanged(@Nullable List<RendererItem> rendererItems) {
                    UiTools.setViewVisibility(mRendererBtn, Util.isListEmpty(rendererItems) ? View.GONE : View.VISIBLE);
                }
            });
        }
        if (mSeekButtons)
            initSeekButton();
        resetHudLayout();
        updateOverlayPausePlay();
        updateSeekable(mService.isSeekable());
        updatePausable(mService.isPausable());
        updateNavStatus();
        setListeners(true);
        initPlaylistUi();
        if (!mDisplayManager.isPrimary()) {
            mHudBinding.lockOverlayButton.setVisibility(View.GONE);
            mHudBinding.playerOverlaySize.setVisibility(View.GONE);
        }
    }
}
Also used : ViewStubCompat(android.support.v7.widget.ViewStubCompat) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) ArrayList(java.util.ArrayList) List(java.util.List) RendererItem(org.videolan.libvlc.RendererItem) TargetApi(android.annotation.TargetApi)

Example 7 with ViewStubCompat

use of android.support.v7.widget.ViewStubCompat in project vlc-android by videolan.

the class AudioPlayerContainerActivity method showTipViewIfNeeded.

/**
 * Show a tip view.
 * @param stubId the stub of the tip view
 * @param settingKey the setting key to check if the view must be displayed or not.
 */
public void showTipViewIfNeeded(final int stubId, final String settingKey) {
    if (BuildConfig.DEBUG)
        return;
    View vsc = findViewById(stubId);
    if (vsc != null && !mSettings.getBoolean(settingKey, false) && !VLCApplication.showTvUi()) {
        View v = ((ViewStubCompat) vsc).inflate();
        v.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                removeTipViewIfDisplayed();
            }
        });
        TextView okGotIt = v.findViewById(R.id.okgotit_button);
        okGotIt.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                removeTipViewIfDisplayed();
                SharedPreferences.Editor editor = mSettings.edit();
                editor.putBoolean(settingKey, true);
                editor.apply();
            }
        });
    }
}
Also used : ViewStubCompat(android.support.v7.widget.ViewStubCompat) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView)

Example 8 with ViewStubCompat

use of android.support.v7.widget.ViewStubCompat in project vlc-android by videolan.

the class VideoPlayerActivity method initOverlay.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void initOverlay() {
    final ViewStubCompat vsc = (ViewStubCompat) findViewById(R.id.player_hud_stub);
    if (vsc != null) {
        mSeekButtons = mSettings.getBoolean("enable_seek_buttons", false);
        vsc.inflate();
        mHudBinding = DataBindingUtil.bind(findViewById(R.id.progress_overlay));
        mHudBinding.setPlayer(this);
        updateTimeValues();
        mHudBinding.setProgress(mProgress);
        mHudBinding.setLength(mMediaLength);
        final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHudBinding.progressOverlay.getLayoutParams();
        if (AndroidDevices.isPhone || !AndroidDevices.hasNavBar)
            layoutParams.width = LayoutParams.MATCH_PARENT;
        else
            layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
        mHudBinding.progressOverlay.setLayoutParams(layoutParams);
        mOverlayBackground = findViewById(R.id.player_overlay_background);
        mNavMenu = (ImageView) findViewById(R.id.player_overlay_navmenu);
        if (!AndroidDevices.isChromeBook && AndroidUtil.isJellyBeanMR1OrLater) {
            mRendererBtn = (ImageView) findViewById(R.id.video_renderer);
            onRenderersChanged(RendererDelegate.INSTANCE.getRenderers().isEmpty());
            onRendererChanged(RendererDelegate.INSTANCE.getSelectedRenderer());
        }
        if (mSeekButtons)
            initSeekButton();
        resetHudLayout();
        updateOverlayPausePlay();
        updateSeekable(mService.isSeekable());
        updatePausable(mService.isPausable());
        updateNavStatus();
        setListeners(true);
        initPlaylistUi();
        if (!mDisplayManager.isPrimary()) {
            mHudBinding.lockOverlayButton.setVisibility(View.GONE);
            mHudBinding.playerOverlaySize.setVisibility(View.GONE);
        }
    }
}
Also used : ViewStubCompat(android.support.v7.widget.ViewStubCompat) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) TargetApi(android.annotation.TargetApi)

Example 9 with ViewStubCompat

use of android.support.v7.widget.ViewStubCompat in project vlc-android by videolan.

the class VideoPlayerActivity method onCreate.

@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!VLCInstance.testCompatibleCPU(this)) {
        exit(RESULT_CANCELED);
        return;
    }
    mSettings = PreferenceManager.getDefaultSharedPreferences(this);
    if (!VLCApplication.showTvUi()) {
        mTouchControls = (mSettings.getBoolean("enable_volume_gesture", true) ? TOUCH_FLAG_AUDIO_VOLUME : 0) + (mSettings.getBoolean("enable_brightness_gesture", true) ? TOUCH_FLAG_BRIGHTNESS : 0) + (mSettings.getBoolean("enable_double_tap_seek", true) ? TOUCH_FLAG_SEEK : 0);
    }
    /* Services and miscellaneous */
    mAudioManager = (AudioManager) getApplicationContext().getSystemService(AUDIO_SERVICE);
    mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    audioBoostEnabled = mSettings.getBoolean("audio_boost", false);
    mEnableCloneMode = mSettings.getBoolean("enable_clone_mode", false);
    mDisplayManager = new DisplayManager(this, mEnableCloneMode);
    setContentView(mDisplayManager.isPrimary() ? R.layout.player : R.layout.player_remote_control);
    /**
     * initialize Views an their Events
     */
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    mActionBar.setBackgroundDrawable(null);
    mActionBar.setDisplayShowCustomEnabled(true);
    mActionBar.setCustomView(R.layout.player_action_bar);
    mRootView = findViewById(R.id.player_root);
    mActionBarView = (ViewGroup) mActionBar.getCustomView();
    mTitle = mActionBarView.findViewById(R.id.player_overlay_title);
    if (!AndroidUtil.isJellyBeanOrLater) {
        View v = findViewById(R.id.player_overlay_systime);
        if (v instanceof TextView)
            mSysTime = (TextView) v;
        v = findViewById(R.id.player_overlay_battery);
        if (v instanceof TextView)
            mBattery = (TextView) v;
    }
    mPlaylistToggle = (ImageView) findViewById(R.id.playlist_toggle);
    mPlaylist = (RecyclerView) findViewById(R.id.video_playlist);
    mScreenOrientation = Integer.valueOf(mSettings.getString("screen_orientation", "99"));
    mSurfaceView = (SurfaceView) findViewById(R.id.player_surface);
    mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.subtitles_surface);
    mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
    mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
    /* Loading view */
    mLoading = (ImageView) findViewById(R.id.player_overlay_loading);
    dimStatusBar(true);
    mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
    mSwitchingView = false;
    mAskResume = mSettings.getBoolean("dialog_confirm_resume", false);
    sDisplayRemainingTime = mSettings.getBoolean(KEY_REMAINING_TIME_DISPLAY, false);
    // Clear the resume time, since it is only used for resumes in external
    // videos.
    final SharedPreferences.Editor editor = mSettings.edit();
    editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
    // Also clear the subs list, because it is supposed to be per session
    // only (like desktop VLC). We don't want the custom subtitle files
    // to persist forever with this video.
    editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);
    // Paused flag - per session too, like the subs list.
    editor.remove(PreferencesActivity.VIDEO_PAUSED);
    editor.apply();
    final IntentFilter filter = new IntentFilter();
    if (mBattery != null)
        filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    filter.addAction(VLCApplication.SLEEP_INTENT);
    registerReceiver(mReceiver, filter);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    // 100 is the value for screen_orientation_start_lock
    setRequestedOrientation(getScreenOrientation(mScreenOrientation));
    // Extra initialization when no secondary display is detected
    if (mDisplayManager.isPrimary()) {
        // Tips
        if (!BuildConfig.DEBUG && !VLCApplication.showTvUi() && !mSettings.getBoolean(PREF_TIPS_SHOWN, false)) {
            ((ViewStubCompat) findViewById(R.id.player_overlay_tips)).inflate();
            mOverlayTips = findViewById(R.id.overlay_tips_layout);
        }
        // Set margins for TV overscan
        if (VLCApplication.showTvUi()) {
            int hm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_horizontal);
            int vm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_vertical);
            final RelativeLayout uiContainer = (RelativeLayout) findViewById(R.id.player_ui_container);
            final RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) uiContainer.getLayoutParams();
            lp.setMargins(hm, 0, hm, vm);
            uiContainer.setLayoutParams(lp);
            final LinearLayout.LayoutParams titleParams = (LinearLayout.LayoutParams) mTitle.getLayoutParams();
            titleParams.setMargins(0, vm, 0, 0);
            mTitle.setLayoutParams(titleParams);
        }
    }
    getWindowManager().getDefaultDisplay().getMetrics(mScreen);
    mSurfaceYDisplayRange = Math.min(mScreen.widthPixels, mScreen.heightPixels);
    mSurfaceXDisplayRange = Math.max(mScreen.widthPixels, mScreen.heightPixels);
    mCurrentScreenOrientation = getResources().getConfiguration().orientation;
    if (mIsBenchmark) {
        mCurrentSize = SURFACE_FIT_SCREEN;
    } else {
        mCurrentSize = mSettings.getInt(PreferencesActivity.VIDEO_RATIO, SURFACE_BEST_FIT);
    }
    mMedialibrary = VLCApplication.getMLInstance();
    mIsRtl = AndroidUtil.isJellyBeanMR1OrLater && TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
}
Also used : IntentFilter(android.content.IntentFilter) LayoutParams(android.view.ViewGroup.LayoutParams) SharedPreferences(android.content.SharedPreferences) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) SurfaceView(android.view.SurfaceView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) ViewStubCompat(android.support.v7.widget.ViewStubCompat) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) TargetApi(android.annotation.TargetApi)

Example 10 with ViewStubCompat

use of android.support.v7.widget.ViewStubCompat in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method showDelayControls.

public void showDelayControls() {
    mTouchAction = TOUCH_NONE;
    if (!mDisplayManager.isPrimary())
        showOverlayTimeout(OVERLAY_INFINITE);
    ViewStubCompat vsc = (ViewStubCompat) findViewById(R.id.player_overlay_settings_stub);
    if (vsc != null) {
        vsc.inflate();
        mPlaybackSettingPlus = (ImageView) findViewById(R.id.player_delay_plus);
        mPlaybackSettingMinus = (ImageView) findViewById(R.id.player_delay_minus);
    }
    mPlaybackSettingMinus.setOnClickListener(this);
    mPlaybackSettingPlus.setOnClickListener(this);
    mPlaybackSettingMinus.setOnTouchListener(new OnRepeatListener(this));
    mPlaybackSettingPlus.setOnTouchListener(new OnRepeatListener(this));
    mPlaybackSettingMinus.setVisibility(View.VISIBLE);
    mPlaybackSettingPlus.setVisibility(View.VISIBLE);
    mPlaybackSettingPlus.requestFocus();
    initPlaybackSettingInfo();
}
Also used : ViewStubCompat(android.support.v7.widget.ViewStubCompat) OnRepeatListener(org.videolan.vlc.gui.helpers.OnRepeatListener)

Aggregations

ViewStubCompat (android.support.v7.widget.ViewStubCompat)10 TargetApi (android.annotation.TargetApi)4 View (android.view.View)4 LayoutParams (android.view.ViewGroup.LayoutParams)4 RelativeLayout (android.widget.RelativeLayout)4 TextView (android.widget.TextView)4 SuppressLint (android.annotation.SuppressLint)2 IntentFilter (android.content.IntentFilter)2 SharedPreferences (android.content.SharedPreferences)2 RecyclerView (android.support.v7.widget.RecyclerView)2 SurfaceView (android.view.SurfaceView)2 ImageView (android.widget.ImageView)2 LinearLayout (android.widget.LinearLayout)2 OnRepeatListener (org.videolan.vlc.gui.helpers.OnRepeatListener)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RendererItem (org.videolan.libvlc.RendererItem)1