We are currently working on developing an HTML5/JavaScript application specifically designed for tablet devices. Our main goal is to create different screen layouts for landscape and portrait orientations.
Initially, we attempted to detect orientation changes and track the current orientation by analyzing reported degrees (0, 90, -90, or 180) as suggested in this discussion. However, various devices interpret orientations differently which led us to face challenges. Could it be a bug or intentionally designed? An article from Samsung’s official site indicates that "landscape" is considered the default orientation, reporting "0" when held horizontally.
We then experimented with determining landscape mode based on screen size comparison (width vs height). This method proved unreliable when factoring in the on-screen keyboard display. The presence of a visible keyboard alters actual screen dimensions causing inaccuracies. For instance, even in portrait mode, if the unobstructed screen area widens more than its height due to keyboard visibility, it can mislead our algorithm.
An answer linked in this post seems outdated. Can anyone provide a more effective algorithm accounting for keyboard visibility?