package net.zubricky.AndroidKeyboardAdjust;

import android.app.Activity;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise;
import android.view.WindowManager;

/**
 * A module to change how the android keyboard is displayed
 */
public class AndroidKeyboardAdjustModule extends ReactContextBaseJavaModule {

    private Activity activity;

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

    @Override
    public String getName() {
        return "AndroidKeyboardAdjust";
    }

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

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

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

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

@@ -66,16 +66,51 @@
 ctivity;
+%0Aimport android.view.WindowManager;
 %0A%0Aimport
@@ -271,85 +271,8 @@
 hod;
-%0Aimport com.facebook.react.bridge.Promise;%0Aimport android.view.WindowManager;
 %0A%0A/*
@@ -1884,32 +1884,32 @@
 ic void run() %7B%0A
-
                 
@@ -2069,11 +2069,1682 @@
 );%0A    %7D
+%0A%0A    @ReactMethod%0A    public void setAlwaysHidden() %7B%0A        this.activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @ReactMethod%0A    public void setAlwaysVisible() %7B%0A        this.activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @ReactMethod%0A    public void setVisible() %7B%0A        this.activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @ReactMethod%0A    public void setHidden() %7B%0A        this.activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @ReactMethod%0A    public void setUnchanged() %7B%0A        this.activity.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                AndroidKeyboardAdjustModule.this.activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);%0A            %7D%0A        %7D);%0A    %7D
 %0A%7D%0A

add API