use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.
the class FocusHelper method handleHotseatButtonKeyEvent.
/**
* Handles key events in the workspace hotseat (bottom of the screen).
* <p>Currently we don't special case for the phone UI in different orientations, even though
* the hotseat is on the side in landscape mode. This is to ensure that accessibility
* consistency is maintained across rotations.
*/
static boolean handleHotseatButtonKeyEvent(View v, int keyCode, KeyEvent e) {
boolean consume = FocusLogic.shouldConsume(keyCode);
if (e.getAction() == KeyEvent.ACTION_UP || !consume) {
return consume;
}
final Launcher launcher = Launcher.getLauncher(v.getContext());
final DeviceProfile profile = launcher.getDeviceProfile();
if (DEBUG) {
Log.v(TAG, String.format("Handle HOTSEAT BUTTONS keyevent=[%s] on hotseat buttons, isVertical=%s", KeyEvent.keyCodeToString(keyCode), profile.isVerticalBarLayout()));
}
// Initialize the variables.
final Workspace workspace = (Workspace) v.getRootView().findViewById(R.id.workspace);
final ShortcutAndWidgetContainer hotseatParent = (ShortcutAndWidgetContainer) v.getParent();
final CellLayout hotseatLayout = (CellLayout) hotseatParent.getParent();
final ItemInfo itemInfo = (ItemInfo) v.getTag();
int pageIndex = workspace.getNextPage();
int pageCount = workspace.getChildCount();
int iconIndex = hotseatParent.indexOfChild(v);
int iconRank = ((CellLayout.LayoutParams) hotseatLayout.getShortcutsAndWidgets().getChildAt(iconIndex).getLayoutParams()).cellX;
final CellLayout iconLayout = (CellLayout) workspace.getChildAt(pageIndex);
if (iconLayout == null) {
// animation.)
return consume;
}
final ViewGroup iconParent = iconLayout.getShortcutsAndWidgets();
ViewGroup parent = null;
int[][] matrix = null;
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
iconIndex += iconParent.getChildCount();
parent = iconParent;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
iconIndex += iconParent.getChildCount();
parent = iconParent;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && profile.isVerticalBarLayout()) {
keyCode = KeyEvent.KEYCODE_PAGE_DOWN;
} else {
// For other KEYCODE_DPAD_LEFT and KEYCODE_DPAD_RIGHT navigation, do not use the
// matrix extended with hotseat.
matrix = FocusLogic.createSparseMatrix(hotseatLayout);
parent = hotseatParent;
}
// Process the focus.
int newIconIndex = FocusLogic.handleKeyEvent(keyCode, matrix, iconIndex, pageIndex, pageCount, Utilities.isRtl(v.getResources()));
View newIcon = null;
switch(newIconIndex) {
case FocusLogic.NEXT_PAGE_FIRST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex + 1);
newIcon = parent.getChildAt(0);
// TODO(hyunyoungs): handle cases where the child is not an icon but
// a folder or a widget.
workspace.snapToPage(pageIndex + 1);
break;
case FocusLogic.PREVIOUS_PAGE_FIRST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
newIcon = parent.getChildAt(0);
// TODO(hyunyoungs): handle cases where the child is not an icon but
// a folder or a widget.
workspace.snapToPage(pageIndex - 1);
break;
case FocusLogic.PREVIOUS_PAGE_LAST_ITEM:
parent = getCellLayoutChildrenForIndex(workspace, pageIndex - 1);
newIcon = parent.getChildAt(parent.getChildCount() - 1);
// TODO(hyunyoungs): handle cases where the child is not an icon but
// a folder or a widget.
workspace.snapToPage(pageIndex - 1);
break;
case FocusLogic.PREVIOUS_PAGE_LEFT_COLUMN:
case FocusLogic.PREVIOUS_PAGE_RIGHT_COLUMN:
// Go to the previous page but keep the focus on the same hotseat icon.
workspace.snapToPage(pageIndex - 1);
break;
case FocusLogic.NEXT_PAGE_LEFT_COLUMN:
case FocusLogic.NEXT_PAGE_RIGHT_COLUMN:
// Go to the next page but keep the focus on the same hotseat icon.
workspace.snapToPage(pageIndex + 1);
break;
}
if (parent == iconParent && newIconIndex >= iconParent.getChildCount()) {
newIconIndex -= iconParent.getChildCount();
}
if (parent != null) {
if (newIcon == null && newIconIndex >= 0) {
newIcon = parent.getChildAt(newIconIndex);
}
if (newIcon != null) {
newIcon.requestFocus();
playSoundEffect(keyCode, v);
}
}
return consume;
}
use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.
the class FocusHelper method handlePreviousPageLastItem.
private static View handlePreviousPageLastItem(Workspace workspace, CellLayout hotseatLayout, int pageIndex, boolean isRtl) {
if (pageIndex - 1 < 0) {
return null;
}
CellLayout workspaceLayout = (CellLayout) workspace.getChildAt(pageIndex - 1);
View newIcon = getFirstFocusableIconInReverseReadingOrder(workspaceLayout, isRtl);
if (newIcon == null) {
// Check the hotseat if no focusable item was found on the workspace.
newIcon = getFirstFocusableIconInReverseReadingOrder(hotseatLayout, isRtl);
workspace.snapToPage(pageIndex - 1);
}
return newIcon;
}
use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.
the class Workspace method getFirstMatchForAppClose.
/**
* Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
* animation.
*
* @param packageName The package name of the app to match.
* @param user The user of the app to match.
*/
public View getFirstMatchForAppClose(String packageName, UserHandle user) {
final int curPage = getCurrentPage();
final CellLayout currentPage = (CellLayout) getPageAt(curPage);
final Workspace.ItemOperator packageAndUser = (ItemInfo info, View view) -> info != null && info.getTargetComponent() != null && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName) && info.user.equals(user);
final Workspace.ItemOperator packageAndUserAndApp = (ItemInfo info, View view) -> packageAndUser.evaluate(info, view) && info.itemType == ITEM_TYPE_APPLICATION;
final Workspace.ItemOperator packageAndUserAndAppInFolder = (info, view) -> {
if (info instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) info;
for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
if (packageAndUserAndApp.evaluate(shortcutInfo, view)) {
return true;
}
}
}
return false;
};
// Order: App icons, app in folder. Items in hotseat get returned first.
if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, packageAndUserAndApp, packageAndUserAndAppInFolder);
} else {
// FolderAdaptiveIcon as the background.
return getFirstMatch(new CellLayout[] { getHotseat(), currentPage }, packageAndUserAndApp);
}
}
use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.
the class Workspace method isPointInSelfOverHotseat.
boolean isPointInSelfOverHotseat(int x, int y) {
mTempFXY[0] = x;
mTempFXY[1] = y;
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempFXY, true);
View hotseat = mLauncher.getHotseat();
return mTempFXY[0] >= hotseat.getLeft() && mTempFXY[0] <= hotseat.getRight() && mTempFXY[1] >= hotseat.getTop() && mTempFXY[1] <= hotseat.getBottom();
}
use of com.android.launcher3.Hotseat in project Neo-Launcher by NeoApplications.
the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.
/**
* Starts a transition animation for the workspace.
*/
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, AnimatorSetBuilder builder, AnimationConfig config) {
ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
mNewScale = scaleAndTranslation.scale;
PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
final int childCount = mWorkspace.getChildCount();
for (int i = 0; i < childCount; i++) {
applyChildState(state, (CellLayout) mWorkspace.getChildAt(i), i, pageAlphaProvider, propertySetter, builder, config);
}
int elements = state.getVisibleElements(mLauncher);
Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
Hotseat hotseat = mWorkspace.getHotseat();
if (playAtomicComponent) {
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
if (!hotseat.getRotationMode().isTransposed) {
// Set the hotseat's pivot point to match the workspace's, so that it scales
// together. Since both hotseat and workspace can move, transform the point
// manually instead of using dragLayer.getDescendantCoordRelativeToSelf and
// related methods.
/*hotseat.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop() - hotseat.getTop());
hotseat.setPivotX(mWorkspace.getPivotX()
+ mWorkspace.getLeft() - hotseat.getLeft());*/
DragLayer dragLayer = mLauncher.getDragLayer();
float[] workspacePivot = new float[] { mWorkspace.getPivotX(), mWorkspace.getPivotY() };
dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
hotseat.setPivotX(workspacePivot[0]);
hotseat.setPivotY(workspacePivot[1]);
}
float hotseatScale = hotseatScaleAndTranslation.scale;
Interpolator hotseatScaleInterpolator = builder.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), hotseatIconsAlpha, fadeInterpolator);
}
// Set options view
OptionsPanel optionsPanel = OmegaLauncher.getLauncher(mLauncher).getOptionsView();
propertySetter.setViewAlpha(optionsPanel, (elements & OPTIONS_VIEW) != 0 ? 1 : 0, fadeInterpolator);
if (!config.playNonAtomicComponent()) {
// Only the alpha and scale, handled above, are included in the atomic animation.
return;
}
Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_X, scaleAndTranslation.translationX, translationInterpolator);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y, scaleAndTranslation.translationY, translationInterpolator);
Interpolator hotseatTranslationInterpolator = builder.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
propertySetter.setFloat(hotseat, View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
propertySetter.setFloat(mWorkspace.getPageIndicator(), View.TRANSLATION_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
setScrim(propertySetter, state);
}
Aggregations