/* Copyright 2019 Braden Farmer
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.farmerbb.taskbar.ui;

import android.graphics.PixelFormat;
import android.view.WindowManager;

import com.farmerbb.taskbar.util.U;

public class ViewParams {
    public int width;
    public int height;
    public int gravity;
    public int flags;
    public int bottomMargin;

    public ViewParams(int width, int height, int gravity, int flags, int bottomMargin) {
        this.width = width;
        this.height = height;
        this.gravity = gravity;
        this.flags = flags;
        this.bottomMargin = bottomMargin;
    }

    public WindowManager.LayoutParams toWindowManagerParams() {
        final WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(
                width,
                height,
                U.getOverlayType(),
                flags,
                PixelFormat.TRANSLUCENT
        );

        if(gravity > -1)
            wmParams.gravity = gravity;

        if(bottomMargin > -1)
            wmParams.y = bottomMargin;

        return wmParams;
    }

    public ViewParams updateWidth(int width) {
        return new ViewParams(width, height, gravity, flags, bottomMargin);
    }

    public ViewParams updateHeight(int height) {
        return new ViewParams(width, height, gravity, flags, bottomMargin);
    }

    public ViewParams updateBottomMargin(int bottomMargin) {
        return new ViewParams(width, height, gravity, flags, bottomMargin);
    }
}
@@ -732,16 +732,49 @@
 til.U;%0A%0A
+import java.lang.reflect.Field;%0A%0A
 public c
@@ -1606,24 +1606,603 @@
 tomMargin;%0A%0A
+        U.allowReflection();%0A        try %7B%0A            Class%3C?%3E layoutParamsClass = Class.forName(%22android.view.WindowManager$LayoutParams%22);%0A%0A            Field privateFlags = layoutParamsClass.getField(%22privateFlags%22);%0A            Field noAnim = layoutParamsClass.getField(%22PRIVATE_FLAG_NO_MOVE_ANIMATION%22);%0A%0A            int privateFlagsValue = privateFlags.getInt(wmParams);%0A            int noAnimFlag = noAnim.getInt(wmParams);%0A            privateFlagsValue %7C= noAnimFlag;%0A%0A            privateFlags.setInt(wmParams, privateFlagsValue);%0A        %7D catch (Exception ignored) %7B%7D%0A%0A
         retu

Disable WindowManager animations