package info.knacki.pass.ui.alertPrompt;

import android.content.Context;
import android.os.IBinder;
import android.view.Window;
import android.view.WindowManager;

import info.knacki.pass.R;

public class ServiceAlertPrompt extends AlertPrompt {
    protected final IBinder fWindowToken;

    ServiceAlertPrompt(Context c, IBinder windowToken) {
        super(c);
        fWindowToken = windowToken;
    }

    @Override
    protected void OnBeforeShow() {
        final Window window = fDialog.getWindow();
        if (window != null) {
            WindowManager.LayoutParams lay = window.getAttributes();
            lay.token = fWindowToken;
            lay.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
            window.setAttributes(lay);
            window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        }
        final int hzPadding = fContext.getResources().getDimensionPixelSize(R.dimen.fab_margin);
        getView().setPadding(hzPadding, 0, hzPadding, 0);
    }
}
