-
-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2181 from proneon267/patch-21
Implemented Divider Widget on Android.
- Loading branch information
Showing
6 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from android.graphics import Color | ||
from android.view import View | ||
from android.widget import LinearLayout | ||
from travertino.size import at_least | ||
|
||
from .base import Widget | ||
|
||
|
||
class Divider(Widget): | ||
def create(self): | ||
self.native = View(self._native_activity) | ||
|
||
# Background color needs to be set or else divider will not be visible. | ||
self.native.setBackgroundColor(Color.LTGRAY) | ||
|
||
self._direction = self.interface.HORIZONTAL | ||
|
||
def set_background_color(self, value): | ||
self.set_background_simple(value) | ||
|
||
def get_direction(self): | ||
return self._direction | ||
|
||
def set_direction(self, value): | ||
self._direction = value | ||
|
||
if value == self.interface.VERTICAL: | ||
# Set the height for a vertical divider | ||
params = LinearLayout.LayoutParams(1, self.interface._MIN_HEIGHT) | ||
else: | ||
# Set the width for a horizontal divider | ||
params = LinearLayout.LayoutParams(self.interface._MIN_WIDTH, 1) | ||
|
||
self.native.setLayoutParams(params) | ||
|
||
def rehint(self): | ||
if self.get_direction() == self.interface.VERTICAL: | ||
self.interface.intrinsic.width = 1 | ||
self.interface.intrinsic.height = at_least(self.native.getHeight()) | ||
else: | ||
self.interface.intrinsic.width = at_least(self.native.getWidth()) | ||
self.interface.intrinsic.height = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from java import jclass | ||
|
||
from .base import SimpleProbe | ||
|
||
|
||
class DividerProbe(SimpleProbe): | ||
native_class = jclass("android.view.View") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Divider widget was implemented on Android. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters