org.robolectric.shadows.ShadowInputMethodManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-core-v18 Show documentation
Show all versions of shadows-core-v18 Show documentation
An alternative Android testing framework.
The newest version!
package org.robolectric.shadows;
import android.os.IBinder;
import android.os.ResultReceiver;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.HiddenApi;
import org.robolectric.internal.Shadow;
/**
* Shadow for {@link android.view.inputmethod.InputMethodManager}.
*/
@Implements(value = InputMethodManager.class, callThroughByDefault = false)
public class ShadowInputMethodManager {
private boolean softInputVisible;
@HiddenApi @Implementation
static public InputMethodManager peekInstance() {
return Shadow.newInstanceOf(InputMethodManager.class);
}
@Implementation
public boolean showSoftInput(View view, int flags) {
return showSoftInput(view, flags, null);
}
@Implementation
public boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver) {
softInputVisible = true;
return true;
}
@Implementation
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) {
return hideSoftInputFromWindow(windowToken, flags, null);
}
@Implementation
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
ResultReceiver resultReceiver) {
softInputVisible = false;
return true;
}
@Implementation
public void toggleSoftInput(int showFlags, int hideFlags) {
softInputVisible = !softInputVisible;
}
public boolean isSoftInputVisible() {
return softInputVisible;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy