Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Add counter to auto hide buttons #3359

Merged
merged 5 commits into from
Aug 27, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@
import android.media.MediaPlayer;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
Expand All @@ -53,6 +50,7 @@ public class FullscreenVideoLayout extends FullscreenVideoView implements View.O
public void run()
{
updateCounter();
autoHideControls();
TIME_THREAD.postDelayed(this, 200);
}
};
Expand Down Expand Up @@ -219,6 +217,23 @@ protected void updateCounter()
}
}

protected void autoHideControls()
{
if (m_elapsedTimeView == null)
{
return;
}

// We add one tick every 200 miliseconds and if the ticks have surpassed the 3 seconds ticks,
// we hide the controls
m_currentTicksForAutoHide++;

if (m_currentTicksForAutoHide > c_ticksBeforeAutohide)
{
hideControls();
}
}

@Override
public void setOnTouchListener(View.OnTouchListener l)
{
Expand Down Expand Up @@ -359,6 +374,7 @@ public void showControls() {
if (m_videoControlsView != null)
{
m_videoControlsView.setVisibility(View.VISIBLE);
m_currentTicksForAutoHide = 0;
}
}

Expand Down Expand Up @@ -425,4 +441,10 @@ public void onStopTrackingTouch(SeekBar seekBar)
protected SeekBar m_seekBar;
protected ImageButton m_playButton;
protected TextView m_elapsedTimeView, m_totalTimeView;

// We update the play counter every 200 miliseconds so we keep this count to hide the separator
protected int m_currentTicksForAutoHide = 0;

// The controls will autohide after 3 seconds
private final int c_ticksBeforeAutohide = 15;
}