Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82386973 authored by Seigo Nonaka's avatar Seigo Nonaka Committed by Automerger Merge Worker
Browse files

Merge "Connect TextFlag feature flag to the application process" into udc-dev am: 43748ce3

parents f124ef0f 43748ce3
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * 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 android.text;

/**
 * Flags in the "text" namespace.
 *
 * @hide
 */
public final class TextFlags {

    /**
     * The name space of the "text" feature.
     *
     * This needs to move to DeviceConfig constant.
     */
    public static final String NAMESPACE = "text";

    /**
     * Whether we use the new design of context menu.
     */
    public static final String ENABLE_NEW_CONTEXT_MENU =
            "TextEditing__enable_new_context_menu";

    /**
     * The key name used in app core settings for {@link #ENABLE_NEW_CONTEXT_MENU}.
     */
    public static final String KEY_ENABLE_NEW_CONTEXT_MENU = "text__enable_new_context_menu";

    /**
     * Default value for the flag {@link #ENABLE_NEW_CONTEXT_MENU}.
     */
    public static final boolean ENABLE_NEW_CONTEXT_MENU_DEFAULT = false;

}
+6 −4
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.StaticLayout;
import android.text.TextFlags;
import android.text.TextUtils;
import android.text.method.InsertModeTransformationMethod;
import android.text.method.KeyListener;
@@ -169,9 +170,6 @@ public class Editor {
    private static final String TAG = "Editor";
    private static final boolean DEBUG_UNDO = false;

    // TODO(nona): Make this configurable.
    private static final boolean FLAG_USE_NEW_CONTEXT_MENU = false;

    // Specifies whether to use the magnifier when pressing the insertion or selection handles.
    private static final boolean FLAG_USE_MAGNIFIER = true;

@@ -470,6 +468,7 @@ public class Editor {
    private static final int LINE_CHANGE_SLOP_MIN_DP = 8;
    private int mLineChangeSlopMax;
    private int mLineChangeSlopMin;
    private boolean mUseNewContextMenu;

    private final AccessibilitySmartActions mA11ySmartActions;
    private InsertModeController mInsertModeController;
@@ -500,6 +499,9 @@ public class Editor {
        mLineSlopRatio = AppGlobals.getFloatCoreSetting(
                WidgetFlags.KEY_LINE_SLOP_RATIO,
                WidgetFlags.LINE_SLOP_RATIO_DEFAULT);
        mUseNewContextMenu = AppGlobals.getIntCoreSetting(
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU,
                TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT ? 1 : 0) != 0;
        if (TextView.DEBUG_CURSOR) {
            logCursor("Editor", "Cursor drag from anywhere is %s.",
                    mFlagCursorDragFromAnywhereEnabled ? "enabled" : "disabled");
@@ -3171,7 +3173,7 @@ public class Editor {
        final int menuItemOrderSelectAll;
        final int menuItemOrderShare;
        final int menuItemOrderAutofill;
        if (FLAG_USE_NEW_CONTEXT_MENU) {
        if (mUseNewContextMenu) {
            menuItemOrderPasteAsPlainText = 7;
            menuItemOrderSelectAll = 8;
            menuItemOrderShare = 9;
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextFlags;
import android.widget.WidgetFlags;

import com.android.internal.R;
@@ -162,6 +163,11 @@ final class CoreSettingsObserver extends ContentObserver {
                DeviceConfig.NAMESPACE_WIDGET, WidgetFlags.MAGNIFIER_ASPECT_RATIO,
                WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class,
                WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT));

        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
                TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU,
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class,
                TextFlags.ENABLE_NEW_CONTEXT_MENU_DEFAULT));
        // add other device configs here...
    }
    private static volatile boolean sDeviceConfigContextEntriesLoaded = false;