Merge "Accessibility fixes and updates" into ub-launcher3-calgary
This commit is contained in:
@@ -36,7 +36,8 @@
|
||||
android:id="@+id/workspace"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center" />
|
||||
android:layout_gravity="center"
|
||||
launcher:pageIndicator="@id/page_indicator" />
|
||||
|
||||
<!-- DO NOT CHANGE THE ID -->
|
||||
<include layout="@layout/hotseat"
|
||||
|
||||
@@ -162,6 +162,8 @@
|
||||
<string name="settings_button_text">Settings</string>
|
||||
<!-- Message shown when a feature is disabled by the administrator -->
|
||||
<string name="msg_disabled_by_admin">Disabled by your admin</string>
|
||||
<!-- Text for custom accessibility action to go to the overview mode, where users can look and change the overall UI of the launcher. -->
|
||||
<string name="accessibility_action_overview">Overview</string>
|
||||
|
||||
<!-- Strings for settings -->
|
||||
<!-- Title for Allow Rotation setting. [CHAR LIMIT=50] -->
|
||||
|
||||
@@ -235,7 +235,6 @@ public class Launcher extends Activity
|
||||
|
||||
@Thunk Workspace mWorkspace;
|
||||
private View mLauncherView;
|
||||
private PageIndicator mPageIndicator;
|
||||
@Thunk DragLayer mDragLayer;
|
||||
private DragController mDragController;
|
||||
|
||||
@@ -513,9 +512,7 @@ public class Launcher extends Activity
|
||||
if (mExtractedColors != null && Utilities.isNycOrAbove()) {
|
||||
mExtractedColors.load(this);
|
||||
mHotseat.updateColor(mExtractedColors, !mPaused);
|
||||
if (mPageIndicator != null) {
|
||||
mPageIndicator.updateColor(mExtractedColors);
|
||||
}
|
||||
mWorkspace.getPageIndicator().updateColor(mExtractedColors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1329,9 +1326,8 @@ public class Launcher extends Activity
|
||||
mLauncherView = findViewById(R.id.launcher);
|
||||
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
|
||||
mFocusHandler = mDragLayer.getFocusIndicatorHelper();
|
||||
|
||||
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
|
||||
mPageIndicator = (PageIndicator) mDragLayer.findViewById(R.id.page_indicator);
|
||||
mWorkspace.initParentViews(mDragLayer);
|
||||
|
||||
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
@@ -2683,7 +2679,7 @@ public class Launcher extends Activity
|
||||
* Event handler for the (Add) Widgets button that appears after a long press
|
||||
* on the home screen.
|
||||
*/
|
||||
protected void onClickAddWidgetButton(View view) {
|
||||
public void onClickAddWidgetButton(View view) {
|
||||
if (LOGD) Log.d(TAG, "onClickAddWidgetButton");
|
||||
if (mIsSafeModeEnabled) {
|
||||
Toast.makeText(this, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
|
||||
@@ -2696,7 +2692,7 @@ public class Launcher extends Activity
|
||||
* Event handler for the wallpaper picker button that appears after a long press
|
||||
* on the home screen.
|
||||
*/
|
||||
protected void onClickWallpaperPicker(View v) {
|
||||
public void onClickWallpaperPicker(View v) {
|
||||
if (!Utilities.isWallapaperAllowed(this)) {
|
||||
Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
@@ -2719,7 +2715,7 @@ public class Launcher extends Activity
|
||||
* Event handler for a click on the settings button that appears after a long press
|
||||
* on the home screen.
|
||||
*/
|
||||
private void onClickSettingsButton(View v) {
|
||||
public void onClickSettingsButton(View v) {
|
||||
if (LOGD) Log.d(TAG, "onClickSettingsButton");
|
||||
startActivity(new Intent(Utilities.ACTION_APPLICATION_PREFERENCES)
|
||||
.setPackage(getPackageName()));
|
||||
@@ -3262,7 +3258,7 @@ public class Launcher extends Activity
|
||||
/**
|
||||
* Shows the overview button.
|
||||
*/
|
||||
void showOverviewMode(boolean animated) {
|
||||
public void showOverviewMode(boolean animated) {
|
||||
showOverviewMode(animated, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
|
||||
// Page Indicator
|
||||
@Thunk int mPageIndicatorViewId;
|
||||
@Thunk PageIndicator mPageIndicator;
|
||||
protected PageIndicator mPageIndicator;
|
||||
// The viewport whether the pages are to be contained (the actual view may be larger than the
|
||||
// viewport)
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
@@ -247,39 +247,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
mScroller.setInterpolator(mDefaultInterpolator);
|
||||
}
|
||||
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
// Hook up the page indicator
|
||||
ViewGroup parent = (ViewGroup) getParent();
|
||||
ViewGroup grandParent = (ViewGroup) parent.getParent();
|
||||
if (mPageIndicator == null && mPageIndicatorViewId > -1) {
|
||||
mPageIndicator = (PageIndicator) grandParent.findViewById(mPageIndicatorViewId);
|
||||
public void initParentViews(View parent) {
|
||||
if (mPageIndicatorViewId > -1) {
|
||||
mPageIndicator = (PageIndicator) parent.findViewById(mPageIndicatorViewId);
|
||||
mPageIndicator.setMarkersCount(getChildCount());
|
||||
|
||||
OnClickListener listener = getPageIndicatorClickListener();
|
||||
if (listener != null) {
|
||||
mPageIndicator.setOnClickListener(listener);
|
||||
}
|
||||
mPageIndicator.setContentDescription(getPageIndicatorDescription());
|
||||
mPageIndicator.setContentDescription(getCurrentPageDescription());
|
||||
}
|
||||
}
|
||||
|
||||
protected String getPageIndicatorDescription() {
|
||||
return getCurrentPageDescription();
|
||||
}
|
||||
|
||||
protected OnClickListener getPageIndicatorClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// Unhook the page indicator
|
||||
mPageIndicator = null;
|
||||
}
|
||||
|
||||
// Convenience methods to map points from self to parent and vice versa
|
||||
private float[] mapPointFromViewToParent(View v, float x, float y) {
|
||||
sTmpPoint[0] = x;
|
||||
@@ -467,7 +442,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
private void updatePageIndicator() {
|
||||
// Update the page indicator (when we aren't reordering)
|
||||
if (mPageIndicator != null) {
|
||||
mPageIndicator.setContentDescription(getPageIndicatorDescription());
|
||||
mPageIndicator.setContentDescription(getCurrentPageDescription());
|
||||
if (!isReordering(false)) {
|
||||
mPageIndicator.setActiveMarker(getNextPage());
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.android.launcher3.Launcher.CustomContentCallbacks;
|
||||
import com.android.launcher3.Launcher.LauncherOverlay;
|
||||
import com.android.launcher3.UninstallDropTarget.DropTargetSource;
|
||||
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate.AccessibilityDragSource;
|
||||
import com.android.launcher3.accessibility.OverviewAccessibilityDelegate;
|
||||
import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate;
|
||||
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
@@ -457,6 +458,12 @@ public class Workspace extends PagedView
|
||||
setEdgeGlowColor(getResources().getColor(R.color.workspace_edge_effect_color));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initParentViews(View parent) {
|
||||
super.initParentViews(parent);
|
||||
mPageIndicator.setAccessibilityDelegate(new OverviewAccessibilityDelegate());
|
||||
}
|
||||
|
||||
private int getDefaultPage() {
|
||||
return numCustomPages();
|
||||
}
|
||||
@@ -1444,10 +1451,9 @@ public class Workspace extends PagedView
|
||||
mHotseatAlpha[direction.ordinal()] = alpha;
|
||||
float finalAlpha = mHotseatAlpha[0] * mHotseatAlpha[1];
|
||||
|
||||
View pageIndicator = getPageIndicator();
|
||||
if (pageIndicator != null) {
|
||||
property.set(pageIndicator, translation);
|
||||
pageIndicator.setAlpha(finalAlpha);
|
||||
if (mPageIndicator != null) {
|
||||
property.set(mPageIndicator, translation);
|
||||
mPageIndicator.setAlpha(alpha);
|
||||
}
|
||||
|
||||
property.set(mLauncher.getHotseat(), translation);
|
||||
@@ -1646,8 +1652,8 @@ public class Workspace extends PagedView
|
||||
mLauncher.getHotseat().setTranslationX(translationX);
|
||||
}
|
||||
|
||||
if (getPageIndicator() != null) {
|
||||
getPageIndicator().setTranslationX(translationX);
|
||||
if (mPageIndicator != null) {
|
||||
mPageIndicator.setTranslationX(translationX);
|
||||
}
|
||||
|
||||
if (mCustomContentCallbacks != null) {
|
||||
@@ -1655,21 +1661,6 @@ public class Workspace extends PagedView
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OnClickListener getPageIndicatorClickListener() {
|
||||
AccessibilityManager am = (AccessibilityManager)
|
||||
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
if (!am.isTouchExplorationEnabled()) {
|
||||
return null;
|
||||
}
|
||||
return new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
mLauncher.showOverviewMode(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void screenScrolled(int screenCenter) {
|
||||
updatePageAlphaValues(screenCenter);
|
||||
@@ -1691,15 +1682,6 @@ public class Workspace extends PagedView
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
if (getPageIndicator() != null) {
|
||||
// In case accessibility state has changed, we need to perform this on every
|
||||
// attach to window
|
||||
OnClickListener listener = getPageIndicatorClickListener();
|
||||
if (listener != null) {
|
||||
getPageIndicator().setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
// Update wallpaper dimensions if they were changed since last onResume
|
||||
// (we also always set the wallpaper dimensions in the constructor)
|
||||
if (LauncherAppState.getInstance().hasWallpaperChangedSinceLastCheck()) {
|
||||
@@ -2085,10 +2067,13 @@ public class Workspace extends PagedView
|
||||
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
|
||||
page.setContentDescription(getPageDescription(pageNo));
|
||||
|
||||
if (mPagesAccessibilityDelegate == null) {
|
||||
mPagesAccessibilityDelegate = new OverviewScreenAccessibilityDelegate(this);
|
||||
// No custom action for the first page.
|
||||
if (!FeatureFlags.QSB_ON_FIRST_SCREEN || pageNo > 0) {
|
||||
if (mPagesAccessibilityDelegate == null) {
|
||||
mPagesAccessibilityDelegate = new OverviewScreenAccessibilityDelegate(this);
|
||||
}
|
||||
page.setAccessibilityDelegate(mPagesAccessibilityDelegate);
|
||||
}
|
||||
page.setAccessibilityDelegate(mPagesAccessibilityDelegate);
|
||||
} else {
|
||||
int accessible = mState == State.NORMAL ?
|
||||
IMPORTANT_FOR_ACCESSIBILITY_AUTO :
|
||||
@@ -2117,7 +2102,7 @@ public class Workspace extends PagedView
|
||||
|
||||
@Override
|
||||
public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
|
||||
if (mPageIndicator instanceof PageIndicator) {
|
||||
if (mPageIndicator != null) {
|
||||
boolean isNewStateSpringLoaded = mState == State.SPRING_LOADED;
|
||||
mPageIndicator.setShouldAutoHide(!isNewStateSpringLoaded);
|
||||
if (isNewStateSpringLoaded) {
|
||||
@@ -4196,7 +4181,7 @@ public class Workspace extends PagedView
|
||||
|
||||
public interface ItemOperator {
|
||||
/**
|
||||
* Process the next itemInfo, possibly with side-effect on {@link ItemOperator#value}.
|
||||
* Process the next itemInfo, possibly with side-effect on the next item.
|
||||
*
|
||||
* @param info info for the shortcut
|
||||
* @param view view for the shortcut
|
||||
@@ -4380,11 +4365,7 @@ public class Workspace extends PagedView
|
||||
exitWidgetResizeMode();
|
||||
}
|
||||
|
||||
protected String getPageIndicatorDescription() {
|
||||
String settings = getResources().getString(R.string.settings_button_text);
|
||||
return getCurrentPageDescription() + ", " + settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCurrentPageDescription() {
|
||||
if (hasCustomContent() && getNextPage() == 0) {
|
||||
return mCustomContentDescription;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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 com.android.launcher3.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
/**
|
||||
* Accessibility delegate with actions pointing to various Overview entry points.
|
||||
*/
|
||||
public class OverviewAccessibilityDelegate extends AccessibilityDelegate {
|
||||
|
||||
private static final int OVERVIEW = R.string.accessibility_action_overview;
|
||||
private static final int WALLPAPERS = R.string.wallpaper_button_text;
|
||||
private static final int WIDGETS = R.string.widget_button_text;
|
||||
private static final int SETTINGS = R.string.settings_button_text;
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
|
||||
Context context = host.getContext();
|
||||
info.addAction(new AccessibilityAction(OVERVIEW, context.getText(OVERVIEW)));
|
||||
|
||||
if (Utilities.isWallapaperAllowed(context)) {
|
||||
info.addAction(new AccessibilityAction(WALLPAPERS, context.getText(WALLPAPERS)));
|
||||
}
|
||||
info.addAction(new AccessibilityAction(WIDGETS, context.getText(WIDGETS)));
|
||||
info.addAction(new AccessibilityAction(SETTINGS, context.getText(SETTINGS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(View host, int action, Bundle args) {
|
||||
Launcher launcher = (Launcher) host.getContext();
|
||||
if (action == OVERVIEW) {
|
||||
launcher.showOverviewMode(true);
|
||||
return true;
|
||||
} else if (action == WALLPAPERS) {
|
||||
launcher.onClickWallpaperPicker(host);
|
||||
return true;
|
||||
} else if (action == WIDGETS) {
|
||||
launcher.onClickAddWidgetButton(host);
|
||||
return true;
|
||||
} else if (action == SETTINGS) {
|
||||
launcher.onClickSettingsButton(host);
|
||||
return true;
|
||||
}
|
||||
return super.performAccessibilityAction(host, action, args);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate {
|
||||
@@ -88,7 +89,9 @@ public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate {
|
||||
if (index < mWorkspace.getChildCount() - 1) {
|
||||
info.addAction(mActions.get(MOVE_FORWARD));
|
||||
}
|
||||
if (index > mWorkspace.numCustomPages()) {
|
||||
|
||||
int startIndex = mWorkspace.numCustomPages() + (FeatureFlags.QSB_ON_FIRST_SCREEN ? 1 : 0);
|
||||
if (index > startIndex) {
|
||||
info.addAction(mActions.get(MOVE_BACKWARD));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public class FolderPagedView extends PagedView {
|
||||
mFolder = folder;
|
||||
mKeyListener = new PagedFolderKeyEventListener(folder);
|
||||
mPageIndicator = (PageIndicator) folder.findViewById(R.id.folder_page_indicator);
|
||||
initParentViews(folder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user