@Test @UiThreadTest public void testOnUpdateExtractingViews() { final Context context = InstrumentationRegistry.getTargetContext(); final EmojiExtractTextLayout layout = (EmojiExtractTextLayout) LayoutInflater.from(context) .inflate(androidx.emoji.test.R.layout.extract_view, null); final EditorInfo editorInfo = new EditorInfo(); editorInfo.actionLabel = "My Action Label"; editorInfo.imeOptions = EditorInfo.IME_ACTION_SEND; editorInfo.inputType = InputType.TYPE_CLASS_TEXT; when(mInputMethodService.isExtractViewShown()).thenReturn(true); final ViewGroup inputExtractAccessories = layout.findViewById( R.id.inputExtractAccessories); inputExtractAccessories.setVisibility(View.GONE); final ExtractButtonCompat extractButton = inputExtractAccessories.findViewById( R.id.inputExtractAction); layout.onUpdateExtractingViews(mInputMethodService, editorInfo); assertEquals(View.VISIBLE, inputExtractAccessories.getVisibility()); assertEquals(editorInfo.actionLabel, extractButton.getText()); assertTrue(extractButton.hasOnClickListeners()); }
public void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei) { if (!inputMethodService.isExtractViewShown()) { return; } if (mExtractAccessories == null) { return; } final boolean hasAction = ei.actionLabel != null || ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE && (ei.imeOptions & EditorInfo.IME_FLAG_NO_ACCESSORY_ACTION) == 0 && ei.inputType != InputType.TYPE_NULL); if (hasAction) { mExtractAccessories.setVisibility(View.VISIBLE); if (mExtractAction != null) { if (ei.actionLabel != null) { mExtractAction.setText(ei.actionLabel); } else { mExtractAction.setText(inputMethodService.getTextForImeAction(ei.imeOptions)); } mExtractAction.setOnClickListener(getButtonClickListener(inputMethodService)); } } else { mExtractAccessories.setVisibility(View.GONE); if (mExtractAction != null) { mExtractAction.setOnClickListener(null); } } }
EmojiExtractTextLayout extends LinearLayout { public void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei) { if (!inputMethodService.isExtractViewShown()) { return; } if (mExtractAccessories == null) { return; } final boolean hasAction = ei.actionLabel != null || ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE && (ei.imeOptions & EditorInfo.IME_FLAG_NO_ACCESSORY_ACTION) == 0 && ei.inputType != InputType.TYPE_NULL); if (hasAction) { mExtractAccessories.setVisibility(View.VISIBLE); if (mExtractAction != null) { if (ei.actionLabel != null) { mExtractAction.setText(ei.actionLabel); } else { mExtractAction.setText(inputMethodService.getTextForImeAction(ei.imeOptions)); } mExtractAction.setOnClickListener(getButtonClickListener(inputMethodService)); } } else { mExtractAccessories.setVisibility(View.GONE); if (mExtractAction != null) { mExtractAction.setOnClickListener(null); } } } }
EmojiExtractTextLayout extends LinearLayout { public void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei) { if (!inputMethodService.isExtractViewShown()) { return; } if (mExtractAccessories == null) { return; } final boolean hasAction = ei.actionLabel != null || ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE && (ei.imeOptions & EditorInfo.IME_FLAG_NO_ACCESSORY_ACTION) == 0 && ei.inputType != InputType.TYPE_NULL); if (hasAction) { mExtractAccessories.setVisibility(View.VISIBLE); if (mExtractAction != null) { if (ei.actionLabel != null) { mExtractAction.setText(ei.actionLabel); } else { mExtractAction.setText(inputMethodService.getTextForImeAction(ei.imeOptions)); } mExtractAction.setOnClickListener(getButtonClickListener(inputMethodService)); } } else { mExtractAccessories.setVisibility(View.GONE); if (mExtractAction != null) { mExtractAction.setOnClickListener(null); } } } EmojiExtractTextLayout(Context context);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  EmojiExtractTextLayout(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes); }
EmojiExtractTextLayout extends LinearLayout { public void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei) { if (!inputMethodService.isExtractViewShown()) { return; } if (mExtractAccessories == null) { return; } final boolean hasAction = ei.actionLabel != null || ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE && (ei.imeOptions & EditorInfo.IME_FLAG_NO_ACCESSORY_ACTION) == 0 && ei.inputType != InputType.TYPE_NULL); if (hasAction) { mExtractAccessories.setVisibility(View.VISIBLE); if (mExtractAction != null) { if (ei.actionLabel != null) { mExtractAction.setText(ei.actionLabel); } else { mExtractAction.setText(inputMethodService.getTextForImeAction(ei.imeOptions)); } mExtractAction.setOnClickListener(getButtonClickListener(inputMethodService)); } } else { mExtractAccessories.setVisibility(View.GONE); if (mExtractAction != null) { mExtractAction.setOnClickListener(null); } } } EmojiExtractTextLayout(Context context);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  EmojiExtractTextLayout(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes); void setEmojiReplaceStrategy(@EmojiCompat.ReplaceStrategy int replaceStrategy); int getEmojiReplaceStrategy(); void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei); }
EmojiExtractTextLayout extends LinearLayout { public void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei) { if (!inputMethodService.isExtractViewShown()) { return; } if (mExtractAccessories == null) { return; } final boolean hasAction = ei.actionLabel != null || ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE && (ei.imeOptions & EditorInfo.IME_FLAG_NO_ACCESSORY_ACTION) == 0 && ei.inputType != InputType.TYPE_NULL); if (hasAction) { mExtractAccessories.setVisibility(View.VISIBLE); if (mExtractAction != null) { if (ei.actionLabel != null) { mExtractAction.setText(ei.actionLabel); } else { mExtractAction.setText(inputMethodService.getTextForImeAction(ei.imeOptions)); } mExtractAction.setOnClickListener(getButtonClickListener(inputMethodService)); } } else { mExtractAccessories.setVisibility(View.GONE); if (mExtractAction != null) { mExtractAction.setOnClickListener(null); } } } EmojiExtractTextLayout(Context context);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs);  EmojiExtractTextLayout(Context context,
            @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  EmojiExtractTextLayout(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes); void setEmojiReplaceStrategy(@EmojiCompat.ReplaceStrategy int replaceStrategy); int getEmojiReplaceStrategy(); void onUpdateExtractingViews(InputMethodService inputMethodService, EditorInfo ei);  }