Auto-rotation stopped working on my Nexus 7 a couple of years ago. So I recently developed this small app that allows manually selecting portrait or landscape screen orientation from the Quick Settings panel.
Please note that the app does not force unsupported orientation for third‑party apps.
Compatibility is for Android Nougat 7.0+. So you'd need to install a custom ROM.
This is an open source project, available on GitHub. Source code is released under the GPLv3 license from the Free Software Foundation: https://github.com/mudar/RotationQuickSetting
You can download and install the APK attached here or from GitHub. Also available on Google Play.
This small app did the job for, making my beloved Nexus 7 usable again I hope other users will find it useful too.