diff --git a/talkback/src/main/java/com/google/android/accessibility/talkback/contextmenu/TalkbackMenuProcessor.java b/talkback/src/main/java/com/google/android/accessibility/talkback/contextmenu/TalkbackMenuProcessor.java index 9a48673d2..d41cb7b38 100644 --- a/talkback/src/main/java/com/google/android/accessibility/talkback/contextmenu/TalkbackMenuProcessor.java +++ b/talkback/src/main/java/com/google/android/accessibility/talkback/contextmenu/TalkbackMenuProcessor.java @@ -69,7 +69,6 @@ public class TalkbackMenuProcessor { private static final int ORDER_SHOW_HIDE_SCREEN = 20; private static final int ORDER_SYSTEM_ACTIONS = 25; - public static final int ORDER_IMAGE_CAPTION = 26; private final TalkBackService service; private final ActorState actorState; @@ -117,10 +116,6 @@ public boolean prepareMenu(ContextMenu menu) { addItemOrSubMenuForCurrentNode( menu, R.id.granularity_menu, R.string.title_granularity, ORDER_NAVIGATION); - // Image caption - addItemOrSubMenuForCurrentNode( - menu, R.id.image_caption_menu, R.string.title_image_caption, ORDER_IMAGE_CAPTION); - // Read From & Last Phrase Spoken & screen search at context_menu.xml addContextMenuXMLMenu(menu); diff --git a/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/NodeMenuRuleProcessor.java b/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/NodeMenuRuleProcessor.java index bbeefb0fa..95b2a6885 100644 --- a/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/NodeMenuRuleProcessor.java +++ b/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/NodeMenuRuleProcessor.java @@ -58,16 +58,12 @@ public NodeMenuRuleProcessor( RuleSpannables ruleSpannables = new RuleSpannables(analytics); rules.add(ruleSpannables); - RuleImageCaption ruleImageCaption = new RuleImageCaption(pipeline, analytics); - rules.add(ruleImageCaption); - nodeMenuRuleHashMap = new HashMap<>(); nodeMenuRuleHashMap.put(R.id.custom_action_menu, ruleCustomAction); nodeMenuRuleHashMap.put(R.id.viewpager_menu, ruleViewPager); nodeMenuRuleHashMap.put(R.id.granularity_menu, ruleGranularity); nodeMenuRuleHashMap.put(R.id.links_menu, ruleSpannables); nodeMenuRuleHashMap.put(R.id.labeling_breakout_add_label, ruleUnlabeledNode); - nodeMenuRuleHashMap.put(R.id.image_caption_menu, ruleImageCaption); } /** @@ -188,7 +184,7 @@ public List getSelfNodeMenuActionTypes(AccessibilityNodeInfoCompat node) // Track which rules accept the node. for (NodeMenuRule rule : rules) { // The items which are generated by these rules won't be read out as action hints. - if (rule instanceof RuleGranularity || rule instanceof RuleImageCaption) { + if (rule instanceof RuleGranularity) { continue; } if (!rule.isEnabled(service) || !rule.accept(service, node)) { diff --git a/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/RuleImageCaption.java b/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/RuleImageCaption.java deleted file mode 100644 index beb9ff14b..000000000 --- a/talkback/src/main/java/com/google/android/accessibility/talkback/menurules/RuleImageCaption.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2021 Google Inc. - * - * 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.google.android.accessibility.talkback.menurules; - -import static com.google.android.accessibility.talkback.contextmenu.TalkbackMenuProcessor.ORDER_IMAGE_CAPTION; -import static com.google.android.accessibility.utils.Performance.EVENT_ID_UNTRACKED; - -import android.accessibilityservice.AccessibilityService; -import android.content.Context; -import android.view.Menu; -import android.view.MenuItem; -import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; -import com.google.android.accessibility.talkback.Feedback; -import com.google.android.accessibility.talkback.Pipeline; -import com.google.android.accessibility.talkback.R; -import com.google.android.accessibility.talkback.actor.ImageCaptioner; -import com.google.android.accessibility.talkback.analytics.TalkBackAnalytics; -import com.google.android.accessibility.talkback.contextmenu.AbstractOnContextMenuItemClickListener; -import com.google.android.accessibility.talkback.contextmenu.ContextMenu; -import com.google.android.accessibility.talkback.contextmenu.ContextMenuItem; -import com.google.android.accessibility.talkback.contextmenu.ContextMenuItem.DeferredType; -import java.util.ArrayList; -import java.util.List; - -/** Performs image captions from menu. */ -public class RuleImageCaption extends NodeMenuRule { - - private final Pipeline.FeedbackReturner pipeline; - private final TalkBackAnalytics analytics; - - public RuleImageCaption(Pipeline.FeedbackReturner pipeline, TalkBackAnalytics analytics) { - super( - R.string.pref_show_context_menu_image_caption_setting_key, - R.bool.pref_show_context_menu_image_caption_default); - this.pipeline = pipeline; - this.analytics = analytics; - } - - @Override - boolean accept(AccessibilityService service, AccessibilityNodeInfoCompat node) { - // Manual-caption item is shown for ALL views if the device can run image caption. - return ImageCaptioner.supportsImageCaption(service); - } - - @Override - List getMenuItemsForNode( - AccessibilityService service, AccessibilityNodeInfoCompat node, boolean includeAncestors) { - List items = new ArrayList<>(); - - final ImageCaptionMenuItemOnClickListener menuItemOnClickListener = - new ImageCaptionMenuItemOnClickListener(node, pipeline, analytics); - - ContextMenuItem item = - ContextMenu.createMenuItem( - service, - Menu.NONE, - R.id.image_caption_menu, - ORDER_IMAGE_CAPTION, - service.getString(R.string.title_image_caption)); - item.setOnMenuItemClickListener(menuItemOnClickListener); - item.setSkipRefocusEvents(true); - item.setSkipWindowEvents(true); - item.setDeferredType(DeferredType.WINDOWS_STABLE); - items.add(item); - - return items; - } - - @Override - CharSequence getUserFriendlyMenuName(Context context) { - return context.getString(R.string.title_image_caption); - } - - @Override - boolean isSubMenu() { - return false; - } - - private static class ImageCaptionMenuItemOnClickListener - extends AbstractOnContextMenuItemClickListener { - - public ImageCaptionMenuItemOnClickListener( - AccessibilityNodeInfoCompat node, - Pipeline.FeedbackReturner pipeline, - TalkBackAnalytics analytics) { - super(node, pipeline, analytics); - } - - @Override - public boolean onMenuItemClick(MenuItem item) { - pipeline.returnFeedback(EVENT_ID_UNTRACKED, Feedback.confirmDownloadAndPerformCaptions(node)); - return true; - } - } -} diff --git a/talkback/src/main/java/com/google/android/accessibility/talkback/preference/base/ContextMenuFragment.java b/talkback/src/main/java/com/google/android/accessibility/talkback/preference/base/ContextMenuFragment.java index 6c88840dc..20551a316 100644 --- a/talkback/src/main/java/com/google/android/accessibility/talkback/preference/base/ContextMenuFragment.java +++ b/talkback/src/main/java/com/google/android/accessibility/talkback/preference/base/ContextMenuFragment.java @@ -21,7 +21,6 @@ import android.text.TextUtils; import androidx.preference.Preference; import com.google.android.accessibility.talkback.R; -import com.google.android.accessibility.talkback.actor.ImageCaptioner; import com.google.android.accessibility.talkback.preference.PreferencesActivityUtils; import com.google.android.accessibility.utils.SharedPreferencesUtils; @@ -93,14 +92,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { } }; prefs.registerOnSharedPreferenceChangeListener(listener); - - // For describe-image menu item. - Preference describeImagePreference = - findPreference( - context.getString(R.string.pref_show_context_menu_image_caption_setting_key)); - if (describeImagePreference != null) { - describeImagePreference.setVisible(ImageCaptioner.supportsImageCaption(context)); - } } @Override diff --git a/talkback/src/main/res/values-watch/donottranslate.xml b/talkback/src/main/res/values-watch/donottranslate.xml index 05e46276d..e6fdb1c98 100644 --- a/talkback/src/main/res/values-watch/donottranslate.xml +++ b/talkback/src/main/res/values-watch/donottranslate.xml @@ -124,7 +124,6 @@ false false false - false false false false diff --git a/talkback/src/main/res/values/donottranslate.xml b/talkback/src/main/res/values/donottranslate.xml index 4c3b3988a..b0b8ab342 100644 --- a/talkback/src/main/res/values/donottranslate.xml +++ b/talkback/src/main/res/values/donottranslate.xml @@ -890,7 +890,6 @@ true false true - true true true diff --git a/talkback/src/main/res/xml/context_menu_preferences.xml b/talkback/src/main/res/xml/context_menu_preferences.xml index a342e0263..ae63e463d 100644 --- a/talkback/src/main/res/xml/context_menu_preferences.xml +++ b/talkback/src/main/res/xml/context_menu_preferences.xml @@ -37,14 +37,6 @@ android:title="@string/title_labeling_show_or_hide_controls" app:singleLineTitle="false" android:summary="@string/summary_labeling_controls"/> -