/*
 * Copyright (C) 2014 Peter Gregus for GravityBox Project (C3C076@xda)
 * 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.ceco.kitkat.gravitybox;

import android.view.ViewConfiguration;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class ModViewConfig {

    public static void initZygote(final XSharedPreferences prefs) {
        try {
            final String mode = prefs.getString(GravityBoxSettings.PREF_KEY_FORCE_OVERFLOW_MENU_BUTTON, "default");
            if (!"default".equals(mode)) {
                XposedHelpers.findAndHookMethod(ViewConfiguration.class, "hasPermanentMenuKey",
                        XC_MethodReplacement.returnConstant(!"enabled".equals(mode)));
            }
        } catch (Throwable t) {
            XposedBridge.log(t);
        }
    }
}

@@ -948,16 +948,119 @@
 onfig %7B%0D
+%0A    private static final String CLASS_ACTIONBAR_POLICY = %22com.android.internal.view.ActionBarPolicy%22;%0D
 %0A%0D%0A    p
@@ -1483,16 +1483,313 @@
 ode)));%0D
+%0A%0D%0A                final Class%3C?%3E actionBarPolicyClass = XposedHelpers.findClass(CLASS_ACTIONBAR_POLICY, null);%0D%0A                XposedHelpers.findAndHookMethod(actionBarPolicyClass, %22showsOverflowMenuButton%22,%0D%0A                        XC_MethodReplacement.returnConstant(%22enabled%22.equals(mode)));%0D
 %0A       

make overflow menu option KitKat compatible In KitKat, Google decided to remove decision logic for showing overflow menu button that was based on if device has permanent menu key. Now they assume there are no devices with permanent menu key anymore (wtf?) https://android.googlesource.com/platform/frameworks/base/+/ea04f3cfc6e245fb415fd352ed0048cd940a46fe%5E%21/#F0