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

Commit 75722400 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Revert "Customizes input extract edit view for Wear"

This reverts commit 880602eb [1],
which was committed with a wrong author email address and lacked license
notice in some files.  To avoid confusion, this we decided to
temporarily revert that CL so that we can commit it with proper license
notice and author address again.

 [1]: I16226ce393f2d15065d08e66a36d008eb1a0c8a1

Bug: 22512982
Bug: 28098677
Change-Id: I3dd3c7bf0ee9634fc4f3bf433bf5023675873e46
parent 6f3934ea
Loading
Loading
Loading
Loading
+0 −103
Original line number Diff line number Diff line
package android.inputmethodservice;

import android.content.Context;
import android.content.res.Resources;
import android.annotation.FractionRes;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

/**
 * A special purpose layout for the editor extract view for tiny (sub 250dp) screens.
 * The layout is based on sizes proportional to screen pixel size to provide for the
 * best layout fidelity on varying pixel sizes and densities.
 *
 * @hide
 */
public class CompactExtractEditLayout extends LinearLayout {
    private View mInputExtractEditText;
    private View mInputExtractAccessories;
    private View mInputExtractAction;
    private boolean mPerformLayoutChanges;

    public CompactExtractEditLayout(Context context) {
        super(context);
    }

    public CompactExtractEditLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CompactExtractEditLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mInputExtractEditText = findViewById(com.android.internal.R.id.inputExtractEditText);
        mInputExtractAccessories = findViewById(com.android.internal.R.id.inputExtractAccessories);
        mInputExtractAction = findViewById(com.android.internal.R.id.inputExtractAction);

        if (mInputExtractEditText != null && mInputExtractAccessories != null
                && mInputExtractAction != null) {
            mPerformLayoutChanges = true;
        }
    }

    private int applyFractionInt(@FractionRes int fraction, int whole) {
        return Math.round(getResources().getFraction(fraction, whole, whole));
    }

    private static void setLayoutHeight(View v, int px) {
        ViewGroup.LayoutParams lp = v.getLayoutParams();
        lp.height = px;
        v.setLayoutParams(lp);
    }

    private static void setLayoutMarginBottom(View v, int px) {
        ViewGroup.MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
        lp.bottomMargin = px;
        v.setLayoutParams(lp);
    }

    private void applyProportionalLayout(int screenWidthPx, int screenHeightPx) {
        if (getResources().getConfiguration().isScreenRound()) {
            setGravity(Gravity.BOTTOM);
        }
        setLayoutHeight(this, applyFractionInt(
                com.android.internal.R.fraction.input_extract_layout_height, screenHeightPx));

        setPadding(
                applyFractionInt(com.android.internal.R.fraction.input_extract_layout_padding_left,
                        screenWidthPx),
                0,
                applyFractionInt(com.android.internal.R.fraction.input_extract_layout_padding_right,
                        screenWidthPx),
                0);

        setLayoutMarginBottom(mInputExtractEditText,
                applyFractionInt(com.android.internal.R.fraction.input_extract_text_margin_bottom,
                        screenHeightPx));

        setLayoutMarginBottom(mInputExtractAccessories,
                applyFractionInt(com.android.internal.R.fraction.input_extract_action_margin_bottom,
                        screenHeightPx));
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (mPerformLayoutChanges) {
            Resources res = getResources();
            DisplayMetrics dm = res.getDisplayMetrics();
            int heightPixels = dm.heightPixels;
            int widthPixels = dm.widthPixels;
            applyProportionalLayout(widthPixels, heightPixels);
        }
    }
}
+7 −46
Original line number Diff line number Diff line
@@ -68,10 +68,9 @@ import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -303,7 +302,7 @@ public class InputMethodService extends AbstractInputMethodService {
    boolean mExtractViewHidden;
    ExtractEditText mExtractEditText;
    ViewGroup mExtractAccessories;
    View mExtractAction;
    Button mExtractAction;
    ExtractedText mExtractedText;
    int mExtractedToken;
    
@@ -1345,7 +1344,7 @@ public class InputMethodService extends AbstractInputMethodService {
            mExtractEditText = (ExtractEditText)view.findViewById(
                    com.android.internal.R.id.inputExtractEditText);
            mExtractEditText.setIME(this);
            mExtractAction = view.findViewById(
            mExtractAction = (Button)view.findViewById(
                    com.android.internal.R.id.inputExtractAction);
            if (mExtractAction != null) {
                mExtractAccessories = (ViewGroup)view.findViewById(
@@ -2410,34 +2409,6 @@ public class InputMethodService extends AbstractInputMethodService {
        }
    }
    
    /**
     * Return a drawable resource id that can be used as a button icon for the given
     * {@link EditorInfo#imeOptions EditorInfo.imeOptions}.
     *
     * @param imeOptions The value from @link EditorInfo#imeOptions EditorInfo.imeOptions}.
     *
     * @return Returns a drawable resource id to use.
     */
    @DrawableRes
    private int getIconForImeAction(int imeOptions) {
        switch (imeOptions&EditorInfo.IME_MASK_ACTION) {
            case EditorInfo.IME_ACTION_GO:
                return com.android.internal.R.drawable.ic_input_extract_action_go;
            case EditorInfo.IME_ACTION_SEARCH:
                return com.android.internal.R.drawable.ic_input_extract_action_search;
            case EditorInfo.IME_ACTION_SEND:
                return com.android.internal.R.drawable.ic_input_extract_action_send;
            case EditorInfo.IME_ACTION_NEXT:
                return com.android.internal.R.drawable.ic_input_extract_action_next;
            case EditorInfo.IME_ACTION_DONE:
                return com.android.internal.R.drawable.ic_input_extract_action_done;
            case EditorInfo.IME_ACTION_PREVIOUS:
                return com.android.internal.R.drawable.ic_input_extract_action_previous;
            default:
                return com.android.internal.R.drawable.ic_input_extract_action_return;
        }
    }

    /**
     * Called when the fullscreen-mode extracting editor info has changed,
     * to determine whether the extracting (extract text and candidates) portion
@@ -2488,20 +2459,10 @@ public class InputMethodService extends AbstractInputMethodService {
        if (hasAction) {
            mExtractAccessories.setVisibility(View.VISIBLE);
            if (mExtractAction != null) {
                if (mExtractAction instanceof ImageButton) {
                    ((ImageButton) mExtractAction)
                            .setImageResource(getIconForImeAction(ei.imeOptions));
                if (ei.actionLabel != null) {
                        mExtractAction.setContentDescription(ei.actionLabel);
                    mExtractAction.setText(ei.actionLabel);
                } else {
                        mExtractAction.setContentDescription(getTextForImeAction(ei.imeOptions));
                    }
                } else {
                    if (ei.actionLabel != null) {
                        ((TextView) mExtractAction).setText(ei.actionLabel);
                    } else {
                        ((TextView) mExtractAction).setText(getTextForImeAction(ei.imeOptions));
                    }
                    mExtractAction.setText(getTextForImeAction(ei.imeOptions));
                }
                mExtractAction.setOnClickListener(mActionClickListener);
            }
+0 −4
Original line number Diff line number Diff line
<vector android:height="24dp" android:viewportHeight="48.0"
    android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FFFFFF" android:pathData="M18,32.34L9.66,24l-2.83,2.83L18,38l24,-24 -2.83,-2.83z"/>
</vector>
+0 −4
Original line number Diff line number Diff line
<vector android:height="24dp" android:viewportHeight="48.0"
    android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FFFFFF" android:pathData="M6,22h28.34l-7.17,-7.17L30,12l12,12 -12,12 -2.83,-2.83L34.34,26H6z"/>
</vector>
+0 −4
Original line number Diff line number Diff line
<vector android:height="24dp" android:viewportHeight="48.0"
    android:viewportWidth="48.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FFFFFF" android:pathData="M23.17,14.83L30.34,22H2v4h28.34l-7.17,7.17L26,36l12,-12 -12,-12 -2.83,2.83zM40,12v24h4V12h-4z"/>
</vector>
Loading