Moving LauncherAccessibilityDelegate to Launcher to associate it with
activity lifecycle. Change-Id: Ib815505677fa7ed74bdcfe7141b1d9bea5d7143a
This commit is contained in:
@@ -143,7 +143,7 @@ public class BubbleTextView extends TextView
|
||||
setShadowLayer(SHADOW_LARGE_RADIUS, 0.0f, SHADOW_Y_OFFSET, SHADOW_LARGE_COLOUR);
|
||||
}
|
||||
|
||||
setAccessibilityDelegate(LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
|
||||
}
|
||||
|
||||
public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) {
|
||||
|
||||
@@ -312,8 +312,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LauncherAppState.getInstance().getAccessibilityDelegate()
|
||||
.handleAccessibleDrop(this, null, null);
|
||||
mLauncher.getAccessibilityDelegate().handleAccessibleDrop(this, null, null);
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
|
||||
@@ -92,6 +92,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.DropTarget.DragObject;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.android.launcher3.allapps.AllAppsContainerView;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.allapps.DefaultAppSearchController;
|
||||
@@ -286,6 +287,7 @@ public class Launcher extends Activity
|
||||
private LauncherModel mModel;
|
||||
private IconCache mIconCache;
|
||||
private ExtractedColors mExtractedColors;
|
||||
private LauncherAccessibilityDelegate mAccessibilityDelegate;
|
||||
@Thunk boolean mUserPresent = true;
|
||||
private boolean mVisible = false;
|
||||
private boolean mHasFocus = false;
|
||||
@@ -414,6 +416,7 @@ public class Launcher extends Activity
|
||||
mIsSafeModeEnabled = getPackageManager().isSafeMode();
|
||||
mModel = app.setLauncher(this);
|
||||
mIconCache = app.getIconCache();
|
||||
mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);
|
||||
|
||||
mDragController = new DragController(this);
|
||||
mAllAppsController = new AllAppsTransitionController(this);
|
||||
@@ -1999,6 +2002,10 @@ public class Launcher extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
|
||||
return mAccessibilityDelegate;
|
||||
}
|
||||
|
||||
public DragController getDragController() {
|
||||
return mDragController;
|
||||
}
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
|
||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||
import com.android.launcher3.compat.PackageInstallerCompat;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.dynamicui.ExtractionUtils;
|
||||
import com.android.launcher3.util.ConfigMonitor;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.util.ConfigMonitor;
|
||||
import com.android.launcher3.util.TestingUtils;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
|
||||
@@ -51,8 +49,6 @@ public class LauncherAppState {
|
||||
|
||||
private InvariantDeviceProfile mInvariantDeviceProfile;
|
||||
|
||||
private LauncherAccessibilityDelegate mAccessibilityDelegate;
|
||||
|
||||
public static LauncherAppState getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new LauncherAppState();
|
||||
@@ -154,15 +150,9 @@ public class LauncherAppState {
|
||||
LauncherModel setLauncher(Launcher launcher) {
|
||||
sLauncherProvider.get().setLauncherProviderChangeListener(launcher);
|
||||
mModel.initialize(launcher);
|
||||
mAccessibilityDelegate = ((launcher != null) && Utilities.ATLEAST_LOLLIPOP) ?
|
||||
new LauncherAccessibilityDelegate(launcher) : null;
|
||||
return mModel;
|
||||
}
|
||||
|
||||
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
|
||||
return mAccessibilityDelegate;
|
||||
}
|
||||
|
||||
public IconCache getIconCache() {
|
||||
return mIconCache;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
|
||||
mStylusEventHelper = new StylusEventHelper(new SimpleOnStylusPressListener(this), this);
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mDragLayer = ((Launcher) context).getDragLayer();
|
||||
setAccessibilityDelegate(LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
setAccessibilityDelegate(((Launcher) context).getAccessibilityDelegate());
|
||||
|
||||
setBackgroundResource(R.drawable.widget_internal_focus_bg);
|
||||
}
|
||||
|
||||
@@ -601,9 +601,7 @@ public class Workspace extends PagedView
|
||||
mScreenOrder.add(insertIndex, screenId);
|
||||
addView(newScreen, insertIndex);
|
||||
|
||||
LauncherAccessibilityDelegate delegate =
|
||||
LauncherAppState.getInstance().getAccessibilityDelegate();
|
||||
if (delegate != null && delegate.isInAccessibleDrag()) {
|
||||
if (mLauncher.getAccessibilityDelegate().isInAccessibleDrag()) {
|
||||
newScreen.enableAccessibleDrag(true, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG);
|
||||
}
|
||||
|
||||
@@ -918,8 +916,7 @@ public class Workspace extends PagedView
|
||||
}
|
||||
}
|
||||
|
||||
LauncherAccessibilityDelegate delegate =
|
||||
LauncherAppState.getInstance().getAccessibilityDelegate();
|
||||
boolean isInAccessibleDrag = mLauncher.getAccessibilityDelegate().isInAccessibleDrag();
|
||||
|
||||
// We enforce at least one page to add new items to. In the case that we remove the last
|
||||
// such screen, we convert the last screen to the empty screen
|
||||
@@ -936,7 +933,7 @@ public class Workspace extends PagedView
|
||||
pageShift++;
|
||||
}
|
||||
|
||||
if (delegate != null && delegate.isInAccessibleDrag()) {
|
||||
if (isInAccessibleDrag) {
|
||||
cl.enableAccessibleDrag(false, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import android.view.View.OnClickListener;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
|
||||
import java.util.List;
|
||||
@@ -50,7 +50,7 @@ public abstract class DragAndDropAccessibilityDelegate extends ExploreByTouchHel
|
||||
super(forView);
|
||||
mView = forView;
|
||||
mContext = mView.getContext();
|
||||
mDelegate = LauncherAppState.getInstance().getAccessibilityDelegate();
|
||||
mDelegate = ((Launcher) mContext).getAccessibilityDelegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -490,16 +490,14 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
|
||||
AppInfo info = mApps.getAdapterItems().get(position).appInfo;
|
||||
BubbleTextView icon = (BubbleTextView) holder.mContent;
|
||||
icon.applyFromApplicationInfo(info);
|
||||
icon.setAccessibilityDelegate(
|
||||
LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
|
||||
break;
|
||||
}
|
||||
case PREDICTION_ICON_VIEW_TYPE: {
|
||||
AppInfo info = mApps.getAdapterItems().get(position).appInfo;
|
||||
BubbleTextView icon = (BubbleTextView) holder.mContent;
|
||||
icon.applyFromApplicationInfo(info);
|
||||
icon.setAccessibilityDelegate(
|
||||
LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
icon.setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
|
||||
break;
|
||||
}
|
||||
case EMPTY_SEARCH_VIEW_TYPE:
|
||||
|
||||
@@ -339,9 +339,7 @@ public class DragLayer extends InsettableFrameLayout {
|
||||
}
|
||||
|
||||
private boolean isInAccessibleDrag() {
|
||||
LauncherAccessibilityDelegate delegate = LauncherAppState
|
||||
.getInstance().getAccessibilityDelegate();
|
||||
return delegate != null && delegate.isInAccessibleDrag();
|
||||
return mLauncher.getAccessibilityDelegate().isInAccessibleDrag();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,8 +144,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||
mPreviewLayoutRule = FeatureFlags.LAUNCHER3_LEGACY_FOLDER_ICON ?
|
||||
new StackFolderIconLayoutRule() :
|
||||
new ClippedFolderIconLayoutRule();
|
||||
|
||||
setAccessibilityDelegate(LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
}
|
||||
|
||||
public static FolderIcon fromXml(int resId, Launcher launcher, ViewGroup group,
|
||||
@@ -183,6 +181,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
|
||||
folder.setFolderIcon(icon);
|
||||
folder.bind(folderInfo);
|
||||
icon.setFolder(folder);
|
||||
icon.setAccessibilityDelegate(launcher.getAccessibilityDelegate());
|
||||
|
||||
folderInfo.addListener(icon);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
||||
setContainerWidth();
|
||||
setWillNotDraw(false);
|
||||
setClipToPadding(false);
|
||||
setAccessibilityDelegate(LauncherAppState.getInstance().getAccessibilityDelegate());
|
||||
setAccessibilityDelegate(mLauncher.getAccessibilityDelegate());
|
||||
}
|
||||
|
||||
private void setContainerWidth() {
|
||||
|
||||
Reference in New Issue
Block a user