Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] fix: screen height wrong. Not catering correctly for action bar #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions flow/ui/android/navigation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
class UI::Navigation
attr_reader :root_screen

#In pixels
def self.bar_height
@bar_height ||= begin
value = Android::Util::TypedValue.new
if UI.context.theme.resolveAttribute(Android::R::Attr::ActionBarSize, value, true)
Android::Util::TypedValue.complexToDimensionPixelSize(value.data, UI::context.resources.displayMetrics)
else
resource_id = UI.context.resources.getIdentifier('action_bar_default_height', 'dimen', 'android')
if resource_id
UI.context.resources.getDimensionPixelSize(resource_id)
else
0
end
end
end
end

def initialize(root_screen)
@root_screen = root_screen
@root_screen.navigation = self
Expand All @@ -16,9 +33,11 @@ def hide_bar
if bar.isShowing
bar.hide
Task.after 0.05 do
screen = @current_screens.last
screen.view.height += (bar.height / UI.density)
screen.view.update_layout
bar_height = bar.height>0 ? bar.height : self.class.bar_height
@current_screens.each do |e|
e.view.height += (bar_height / UI.density)
e.view.update_layout
end
end
end
end
Expand All @@ -28,9 +47,11 @@ def show_bar
if !bar.isShowing
bar.show
Task.after 0.05 do
screen = @current_screens.last
screen.view.height -= (bar.height / UI.density)
screen.view.update_layout
bar_height = bar.height>0 ? bar.height : self.class.bar_height
@current_screens.each do |e|
e.view.height -= (bar_height / UI.density)
e.view.update_layout
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions flow/ui/android/screen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def view
if resource_id > 0
view_height -= UI.context.resources.getDimensionPixelSize(resource_id)
end
view_height -= UI::Navigation.bar_height

view.width = main_screen_metrics.width / UI.density
view.height = view_height / UI.density
Expand Down