Skip to content

Commit

Permalink
Compatibility react 0.29.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-k authored Sep 13, 2016
1 parent 960aac6 commit d2c5d57
Showing 1 changed file with 73 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
*/
public class AndroidKeyboardAdjustModule extends ReactContextBaseJavaModule {

private Activity activity;

public AndroidKeyboardAdjustModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
this.activity = getCurrentActivity();
}

@Override
Expand All @@ -26,90 +23,145 @@ public String getName() {

@ReactMethod
public void setAdjustNothing() {
this.activity.runOnUiThread(new Runnable() {

final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
}
});
}

@ReactMethod
public void setAdjustPan() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
});
}

@ReactMethod
public void setAdjustResize() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
});
}

@ReactMethod
public void setAdjustUnspecified() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
}
});
}

@ReactMethod
public void setAlwaysHidden() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
});
}

@ReactMethod
public void setAlwaysVisible() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
}

@ReactMethod
public void setVisible() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
});
}

@ReactMethod
public void setHidden() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}
});
}

@ReactMethod
public void setUnchanged() {
this.activity.runOnUiThread(new Runnable() {
final Activity activity = getCurrentActivity();

if (activity == null) {
return;
}

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);
}
});
}
Expand Down

0 comments on commit d2c5d57

Please sign in to comment.