Skip to content

Commit

Permalink
[Android] fix: screen height wrong. Not catering correctly for action…
Browse files Browse the repository at this point in the history
… bar
  • Loading branch information
hboon committed Dec 16, 2016
1 parent 82f1e31 commit b88aaad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions flow/ui/android/navigation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
class UI::Navigation
attr_reader :root_screen

#In pixels
def self.bar_height
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

def initialize(root_screen)
@root_screen = root_screen
@root_screen.navigation = self
Expand All @@ -17,7 +32,8 @@ def hide_bar
bar.hide
Task.after 0.05 do
screen = @current_screens.last
screen.view.height += (bar.height / UI.density)
bar_height = bar.height>0 ? bar.height : self.class.bar_height
screen.view.height += (bar_height / UI.density)
screen.view.update_layout
end
end
Expand All @@ -29,7 +45,8 @@ def show_bar
bar.show
Task.after 0.05 do
screen = @current_screens.last
screen.view.height -= (bar.height / UI.density)
bar_height = bar.height>0 ? bar.height : self.class.bar_height
screen.view.height -= (bar_height / UI.density)
screen.view.update_layout
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

0 comments on commit b88aaad

Please sign in to comment.