80 lines
6.2 KiB
Markdown
80 lines
6.2 KiB
Markdown
# Unfloat
|
|
|
|
libxposed (API 101+) module that moves the rotation suggestion button back into the 3-button navigation bar, as it was up to Android 14, instead of the floating button Android 15 introduced.
|
|
|
|
| | Navigation bar |
|
|
|---|---|
|
|
| **Stock** |  |
|
|
| **Unfloat** |  |
|
|
|
|
With auto-rotate off, turning the phone shows a "rotate screen" suggestion button. Since Android 15 that button is always a floating circle hovering over the app, even with 3-button navigation, where it covers app content right above the nav bar. With Unfloat it sits in the nav bar's right-hand contextual slot again (where the IME switcher and accessibility button live), sized, tinted and rippled like the other nav buttons. Gesture navigation keeps the stock floating button.
|
|
|
|
## What it changes
|
|
|
|
AOSP commit *"Replace Contextual Rotation Button with Floating Action Button"* (bug 324070001), shipped in Android 15, deleted `RotationContextButton`. Since then the rotation controller is always given a `FloatingRotationButton`, which adds its own little window via `WindowManager`.
|
|
|
|
On this device (crDroid, Android 17) the 3-button nav bar isn't drawn by SystemUI at all. SystemUI's `NavigationBarControllerImpl.supportsTaskbar()` returns `true`, so the bar is the Launcher3 taskbar (`NavbarButtonsViewController`), and the rotation button is Launcher3's copy of the shared `FloatingRotationButton`. Reconstructed from the decompiled `Launcher3QuickStep.apk`, it looks roughly like this:
|
|
|
|
```java
|
|
// NavbarButtonsViewController.setupController()
|
|
mFloatingRotationButton = new FloatingRotationButton(...);
|
|
mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton, mRotationButtonListener);
|
|
|
|
// RotationButtonController.setRotateSuggestionButtonState(true, ...)
|
|
View view = mRotationButton.getCurrentView();
|
|
Drawable icon = mRotationButton.getImageDrawable();
|
|
view.setAlpha(1f);
|
|
((AnimatedVectorDrawable) icon).start();
|
|
mRotationButton.show(); // FloatingRotationButton: WindowManager.addView(...)
|
|
// ...and on hide: fade getCurrentView() to alpha 0, then mRotationButton.hide()
|
|
```
|
|
|
|
The controller only ever talks to the button through the `RotationButton` interface. Unfloat leaves the controller alone and redirects that interface when the taskbar is in phone 3-button mode:
|
|
|
|
```java
|
|
// after NavbarButtonsViewController.setupController(), in phone 3-button mode only
|
|
ImageView inBar = nbvc.addButton(contextualContainer, id, R.layout.taskbar_contextual_button);
|
|
|
|
hook(FloatingRotationButton::getCurrentView) -> inBar
|
|
hook(FloatingRotationButton::getImageDrawable) -> AVD loaded from controller.getIconResId()
|
|
hook(FloatingRotationButton::show) -> inBar.setVisibility(VISIBLE) // no floating window
|
|
hook(FloatingRotationButton::hide) -> inBar.setVisibility(INVISIBLE)
|
|
hook(FloatingRotationButton::isVisible) -> our state
|
|
hook(FloatingRotationButton::setOnClickListener) -> remember the controller's listener, inBar forwards to it
|
|
```
|
|
|
|
Because `getCurrentView()` and `getImageDrawable()` return the in-bar view, the stock controller logic (icon animation, ripple hint for the first suggestions, 100 ms fade-out, 5 s timeout, hide on rotation) runs unchanged on the new button.
|
|
|
|
### Why this hook point
|
|
|
|
- **The `RotationButton` interface, not the controller.** `RotationContextButton` can't be restored: it extended SystemUI's `ContextualButton`, and a module class can't subclass across classloaders. Redirecting the interface methods of the existing `FloatingRotationButton` keeps the controller's proposal, timeout and click logic intact without reimplementing any of it.
|
|
- **The launcher builds the button.** The view is created with the launcher's own `addButton(ViewGroup, int, int)` and the stock `taskbar_contextual_button` layout, the same path as the accessibility button. That puts it in `mAllButtons`, so the launcher itself gives it the nav button size, the `KeyButtonRipple`, the light/dark icon tint (`applyButtonColors`) and a touchable region. No tint hook is needed.
|
|
- **Re-attached after every layout.** The phone layouters clear the contextual containers and re-add the IME switcher and accessibility button (end container in portrait and seascape, start container in landscape). A hook on `updateButtonLayoutSpacing()` puts the rotation button back into whichever container holds them, on top.
|
|
- **Slot priority follows Android 14:** accessibility button > rotation > IME switcher. While the accessibility button is shown, the rotation button stays hidden. While the rotation button is shown, the IME switcher's `transitionAlpha` is set to 0 (rather than fighting the launcher's own alpha animators) and the rotation button, on top, takes the touches.
|
|
- **Nav mode switches.** Changing navigation mode rebuilds the taskbar. The button is only created when `isPhoneButtonNavMode()` is true, so gesture navigation (and tablet taskbars) keep the stock floating button.
|
|
|
|
### SystemUI fallback
|
|
|
|
If the launcher has no taskbar, SystemUI's own `NavigationBarView` draws the bar. SystemUI is scoped too, with an equivalent path for that case. There, R8 has inlined `FloatingRotationButton.show()` and `isVisible()`, so it hooks `RotationButtonController.setRotateSuggestionButtonState()` and drives the leftover `@id/rotate_suggestion` `KeyButtonView` that `menu_ime.xml` still contains. On a device where the launcher draws the nav bar, those hooks attach but stay idle.
|
|
|
|
### Safety
|
|
|
|
Every hook body is wrapped in try/catch and falls back to the original method. If a required class, field or method is missing, nothing is hooked and the stock floating button stays. The redirect is only enabled once all of its supporting hooks have attached.
|
|
|
|
## Build
|
|
|
|
Uses `io.github.libxposed:api:101.0.1` from Maven Central (compile-only).
|
|
|
|
```bash
|
|
./gradlew assembleDebug
|
|
adb install -r app/build/outputs/apk/debug/app-debug.apk
|
|
```
|
|
|
|
Vector discovers the module through `app/src/main/resources/META-INF/xposed/` (`java_init.list`, `module.prop`, `scope.list`).
|
|
|
|
## Usage
|
|
|
|
1. Enable **Unfloat** in Vector. The scope is preset to Launcher3 (`com.android.launcher3`) and System UI.
|
|
2. Restart the launcher: `adb shell am force-stop com.android.launcher3` (or reboot).
|
|
3. Check that the hooks attached: `adb logcat -s unfloat`
|