[Android] Use util method to hide keyboard
Geoffrey Métais
git at videolan.org
Fri Apr 1 15:36:18 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr 1 15:29:26 2016 +0200| [c03b748daa2d33f2e8e567e70524d113c1853df3] | committer: Geoffrey Métais
Use util method to hide keyboard
> https://code.videolan.org/videolan/vlc-android/commit/c03b748daa2d33f2e8e567e70524d113c1853df3
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 8 +-------
vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java | 3 +--
.../org/videolan/vlc/gui/helpers/SearchSuggestionsAdapter.java | 8 +-------
3 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index a9f4cd0..38b661e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -55,7 +55,6 @@ import android.view.SubMenu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
-import android.view.inputmethod.InputMethodManager;
import android.widget.FilterQueryProvider;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -97,7 +96,7 @@ import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
import java.util.List;
-public class MainActivity extends AudioPlayerContainerActivity implements SearchSuggestionsAdapter.SuggestionDisplay, FilterQueryProvider, NavigationView.OnNavigationItemSelectedListener, ExtensionManagerService.ExtensionManagerActivity {
+public class MainActivity extends AudioPlayerContainerActivity implements FilterQueryProvider, NavigationView.OnNavigationItemSelectedListener, ExtensionManagerService.ExtensionManagerActivity {
public final static String TAG = "VLC/MainActivity";
private static final String PREF_FIRST_RUN = "first_run";
@@ -859,11 +858,6 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
}
}
- public void hideKeyboard(){
- ((InputMethodManager) VLCApplication.getAppContext().getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
- getWindow().getDecorView().getRootView().getWindowToken(), 0);
- }
-
public void showProgressBar() {
mHandler.obtainMessage(ACTIVITY_SHOW_PROGRESSBAR).sendToTarget();
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index fc08975..f6b8ab3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -677,8 +677,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
mPlaylistSearchText.getEditText().removeTextChangedListener(this);
mPlaylistSearchText.getEditText().setText("");
mPlaylistSearchText.getEditText().addTextChangedListener(this);
- ((InputMethodManager) VLCApplication.getAppContext().getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
- getActivity().getWindow().getDecorView().getRootView().getWindowToken(), 0);
+ UiTools.setKeyboardVisibility(mPlaylistSearchText, false);
mPlaylistSearchButton.setVisibility(View.VISIBLE);
mPlaylistSearchText.setVisibility(View.GONE);
return true;
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/SearchSuggestionsAdapter.java b/vlc-android/src/org/videolan/vlc/gui/helpers/SearchSuggestionsAdapter.java
index bc21ead..fc00485 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/SearchSuggestionsAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/SearchSuggestionsAdapter.java
@@ -45,15 +45,9 @@ public class SearchSuggestionsAdapter extends CursorAdapter {
private static int backgroundColor;
MediaLibrary mMediaLibrary = MediaLibrary.getInstance();
- SuggestionDisplay activity;
-
- public interface SuggestionDisplay {
- public void hideKeyboard();
- }
public SearchSuggestionsAdapter(Context context, Cursor cursor){
super(context, cursor, false);
- activity = (SuggestionDisplay) context;
backgroundColor = UiTools.getColorFromAttribute(context, R.attr.background_menu);
}
@@ -109,7 +103,7 @@ public class SearchSuggestionsAdapter extends CursorAdapter {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN)
- activity.hideKeyboard();
+ UiTools.setKeyboardVisibility(v, false);
return false;
}
});
More information about the Android
mailing list