Commit 6756db90 authored by Geoffrey Métais's avatar Geoffrey Métais

Fix focus and hiding for search edit text

parent d7c465df
...@@ -76,6 +76,8 @@ import java.util.List; ...@@ -76,6 +76,8 @@ import java.util.List;
public class AudioPlayer extends PlaybackServiceFragment implements PlaybackService.Callback, View.OnClickListener, PlaylistAdapter.IPlayer, TextWatcher { public class AudioPlayer extends PlaybackServiceFragment implements PlaybackService.Callback, View.OnClickListener, PlaylistAdapter.IPlayer, TextWatcher {
public static final String TAG = "VLC/AudioPlayer"; public static final String TAG = "VLC/AudioPlayer";
public static final int SEARCH_TIMEOUT_MILLIS = 5000;
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private HeaderMediaSwitcher mHeaderMediaSwitcher; private HeaderMediaSwitcher mHeaderMediaSwitcher;
private CoverMediaSwitcher mCoverMediaSwitcher; private CoverMediaSwitcher mCoverMediaSwitcher;
...@@ -102,6 +104,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -102,6 +104,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
private boolean mPreviewingSeek = false; private boolean mPreviewingSeek = false;
private PlaylistAdapter mPlaylistAdapter; private PlaylistAdapter mPlaylistAdapter;
private Handler mHandler = new Handler();
private boolean mAdvFuncVisible; private boolean mAdvFuncVisible;
private boolean mPlaylistSwitchVisible; private boolean mPlaylistSwitchVisible;
...@@ -408,6 +411,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -408,6 +411,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
public void onMediaPlayerEvent(MediaPlayer.Event event) { public void onMediaPlayerEvent(MediaPlayer.Event event) {
switch (event.type) { switch (event.type) {
case MediaPlayer.Event.Opening: case MediaPlayer.Event.Opening:
hideSearchField();
break; break;
case MediaPlayer.Event.Stopped: case MediaPlayer.Event.Stopped:
hide(); hide();
...@@ -642,7 +646,15 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -642,7 +646,15 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
case R.id.playlist_search: case R.id.playlist_search:
mPlaylistSearchButton.setVisibility(View.GONE); mPlaylistSearchButton.setVisibility(View.GONE);
mPlaylistSearchText.setVisibility(View.VISIBLE); mPlaylistSearchText.setVisibility(View.VISIBLE);
mPlaylistSearchText.requestFocus(); mPlaylistSearchText.getEditText().requestFocus();
InputMethodManager imm = (InputMethodManager) VLCApplication.getAppContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mPlaylistSearchText.getEditText(), InputMethodManager.SHOW_IMPLICIT);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
hideSearchField();
}
}, SEARCH_TIMEOUT_MILLIS);
break; break;
} }
} }
...@@ -736,11 +748,11 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -736,11 +748,11 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
mTime.setText(Strings.millisToString(mShowRemainingTime ? possibleSeek-length : possibleSeek)); mTime.setText(Strings.millisToString(mShowRemainingTime ? possibleSeek-length : possibleSeek));
mTimeline.setProgress(possibleSeek); mTimeline.setProgress(possibleSeek);
mProgressBar.setProgress(possibleSeek); mProgressBar.setProgress(possibleSeek);
h.postDelayed(seekRunnable, 50); handler.postDelayed(seekRunnable, 50);
} }
}; };
Handler h = new Handler(); Handler handler = new Handler();
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
...@@ -756,12 +768,12 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ ...@@ -756,12 +768,12 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
vibrated = false; vibrated = false;
length = mService.getLength(); length = mService.getLength();
h.postDelayed(seekRunnable, 1000); handler.postDelayed(seekRunnable, 1000);
return true; return true;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
(forward ? mNext : mPrevious).setImageResource(this.normal); (forward ? mNext : mPrevious).setImageResource(this.normal);
h.removeCallbacks(seekRunnable); handler.removeCallbacks(seekRunnable);
mPreviewingSeek = false; mPreviewingSeek = false;
if(event.getEventTime()-event.getDownTime() < 1000) { if(event.getEventTime()-event.getDownTime() < 1000) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment