use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.
the class SecondaryDisplayLauncher method onNewIntent.
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (Intent.ACTION_MAIN.equals(intent.getAction())) {
// Hide keyboard.
final View v = getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
getSystemService(InputMethodManager.class).hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
// A new intent will bring the launcher to top. Hide the app drawer to reset the state.
showAppDrawer(false);
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.
the class PopupContainerWithArrow method configureForLauncher.
private void configureForLauncher(Launcher launcher) {
addOnAttachStateChangeListener(new LiveUpdateHandler(launcher));
mPopupItemDragHandler = new LauncherPopupItemDragHandler(launcher, this);
mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(launcher);
launcher.getDragController().addDragListener(this);
addPreDrawForColorExtraction(launcher);
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.
the class ShortcutDragPreviewProvider method getScaleAndPosition.
@Override
public float getScaleAndPosition(Drawable preview, int[] outPos) {
Launcher launcher = Launcher.getLauncher(mView.getContext());
int iconSize = getDrawableBounds(mView.getBackground()).width();
float scale = launcher.getDragLayer().getLocationInDragLayer(mView, outPos);
int iconLeft = mView.getPaddingStart();
if (Utilities.isRtl(mView.getResources())) {
iconLeft = mView.getWidth() - iconSize - iconLeft;
}
outPos[0] += Math.round(scale * iconLeft + (scale * iconSize - preview.getIntrinsicWidth()) / 2 + mPositionShift.x);
outPos[1] += Math.round((scale * mView.getHeight() - preview.getIntrinsicHeight()) / 2 + mPositionShift.y);
float size = launcher.getDeviceProfile().iconSizePx;
return scale * iconSize / size;
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.
the class ArrowPopup method initColorExtractionLocations.
private void initColorExtractionLocations(Launcher launcher) {
if (mColorExtractors == null) {
return;
}
Workspace workspace = launcher.getWorkspace();
if (workspace == null) {
return;
}
boolean firstVisibleChild = true;
int screenId = workspace.getScreenIdForPageIndex(workspace.getCurrentPage());
DragLayer dragLayer = launcher.getDragLayer();
final View[] viewAlignedWithArrow = new View[1];
// Order matters here, since we need the arrow to match the color of its adjacent view.
for (final View view : getChildrenForColorExtraction()) {
if (view != null && view.getVisibility() == VISIBLE) {
Rect pos = new Rect();
dragLayer.getDescendantRectRelativeToSelf(view, pos);
if (!pos.isEmpty()) {
LocalColorExtractor extractor = LocalColorExtractor.newInstance(launcher);
extractor.setWorkspaceLocation(pos, dragLayer, screenId);
extractor.setListener(extractedColors -> {
AnimatorSet colors = new AnimatorSet();
int newColor = getExtractedColor(extractedColors);
setChildColor(view, newColor, colors);
int numChildren = view instanceof ViewGroup ? ((ViewGroup) view).getChildCount() : 0;
for (int i = 0; i < numChildren; ++i) {
View childView = ((ViewGroup) view).getChildAt(i);
setChildColor(childView, newColor, colors);
}
if (viewAlignedWithArrow[0] == view) {
mArrowColor = newColor;
updateArrowColor();
}
colors.setDuration(150);
view.post(colors::start);
});
mColorExtractors.add(extractor);
if (mIsAboveIcon || firstVisibleChild) {
viewAlignedWithArrow[0] = view;
}
firstVisibleChild = false;
}
}
}
}
use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.
the class SpringLoadedState method getWorkspaceScaleAndTranslation.
@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
DeviceProfile grid = launcher.getDeviceProfile();
Workspace ws = launcher.getWorkspace();
if (ws.getChildCount() == 0) {
return super.getWorkspaceScaleAndTranslation(launcher);
}
if (grid.isVerticalBarLayout()) {
float scale = grid.workspaceSpringLoadShrinkFactor;
return new ScaleAndTranslation(scale, 0, 0);
}
float scale = grid.workspaceSpringLoadShrinkFactor;
Rect insets = launcher.getDragLayer().getInsets();
float scaledHeight = scale * ws.getNormalChildHeight();
float shrunkTop = insets.top + grid.dropTargetBarSizePx;
float shrunkBottom = ws.getMeasuredHeight() - insets.bottom - grid.workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
float totalShrunkSpace = shrunkBottom - shrunkTop;
float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
float halfHeight = ws.getHeight() / 2;
float myCenter = ws.getTop() + halfHeight;
float cellTopFromCenter = halfHeight - ws.getChildAt(0).getTop();
float actualCellTop = myCenter - cellTopFromCenter * scale;
return new ScaleAndTranslation(scale, 0, (desiredCellTop - actualCellTop) / scale);
}
Aggregations