We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Toga slider widget in android has 1 fewer tick counts than in Windows
**Describe the bug**
The toga.Slider widget when defined with range=(2,20), tick_count=19 instantiates a slider in Windows which has 19 tick values.
However when the same code is built and run for Android (both in the emulator and an actual Android phone), the slider only
has 18 tick values.  In addition ,the property Slider.value returns a value which is 18/19 per tick.

**To Reproduce**
I wrote a simple example which demonstrates the bug clearly.    I build and compiled like this:
    briefcase update android
    briefcase build android
    briefcase run android

Here is the source code from app.py.

import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW

TIMER_MIN=1
TIMER_MAX=19

class slidetest(toga.App):

    def startup(self):
        main_box = toga.Box()

        self.timer_label=toga.Label(text="Counter: ")
        self.timer_label.style.width=200
        self.timer_label.style.padding=5

        self.timer_slide=toga.Slider(range=(TIMER_MIN,TIMER_MAX),tick_count=(TIMER_MAX-TIMER_MIN+1),on_change=(self.timer_change),
            on_release=(self.timer_set))
        self.timer_slide.style.padding=5
        self.timer_slide.style.padding_top=5
        self.timer_slide.style.width=200
        self.timer_slide.value=10.0

        main_box.add(self.timer_slide)
        main_box.add(self.timer_label)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()

    def timer_change(self,widget):
        self.timer_label.text="Counter: "+str(self.timer_slide.tick_value)

    def timer_set(self,widget):
        pass

def main():
    return slidetest()


**Expected behavior**
This should produce a slider with 19 tick stops, and return values from 2.0 to 20.0.  

The android build of this code has a slide with 18 tick stops and return values from 2.0 to 19.05263.

Screenshots below just show screen capture of the android emulator with slider full left and full right position.  You can see the resulting tick_value is 1 and 18 respectively.

**Screenshots**
![Screenshot 2021-06-10 203556](https://user-images.githubusercontent.com/46497064/121627164-b42a2f00-ca2b-11eb-80f1-6e2ac35f8d1f.gif)
![Screenshot 2021-06-10 203638](https://user-images.githubusercontent.com/46497064/121627173-b8eee300-ca2b-11eb-9816-c8e1d4cf3e3c.gif)


**Environment:**
 - Operating System: Windows
 - Python version:3.8
 - Software versions:
   - Briefcase: briefcase          0.3.5
   - Toga:
   - toga-core          0.3.0.dev27
   - toga-winforms      0.3.0.dev27
   
arrow              1.1.0
binaryornot        0.4.4
certifi            2021.5.30
chardet            4.0.0
click              8.0.1
colorama           0.4.4
cookiecutter       1.7.3
gitdb              4.0.7
GitPython          3.1.17
idna               2.10
Jinja2             2.11.3
jinja2-time        0.2.0
MarkupSafe         2.0.1
oauthlib           3.1.1
pip                21.1.1
poyo               0.5.0
pycparser          2.20
python-dateutil    2.8.1
python-slugify     5.0.2
pythonnet          2.5.2
setuptools         56.0.0
six                1.16.0
smmap              4.0.0
text-unidecode     1.3
toml               0.10.2
travertino         0.1.3
urllib3            1.26.5
wheel              0.36.2

**Additional context**
Add any other context about the problem here.

Toga slider widget in android has 1 fewer tick counts than in Windows
**Describe the bug**
The toga.Slider widget when defined with range=(2,20), tick_count=19 instantiates a slider in Windows which has 19 tick values.
However when the same code is built and run for Android (both in the emulator and an actual Android phone), the slider only
has 18 tick values.  In addition ,the property Slider.value returns a value which is 18/19 per tick.

**To Reproduce**
I wrote a simple example which demonstrates the bug clearly.    I build and compiled like this:
    briefcase update android
    briefcase build android
    briefcase run android

Here is the source code from app.py.

import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW

TIMER_MIN=1
TIMER_MAX=19

class slidetest(toga.App):

    def startup(self):
        main_box = toga.Box()

        self.timer_label=toga.Label(text="Counter: ")
        self.timer_label.style.width=200
        self.timer_label.style.padding=5

        self.timer_slide=toga.Slider(range=(TIMER_MIN,TIMER_MAX),tick_count=(TIMER_MAX-TIMER_MIN+1),on_change=(self.timer_change),
            on_release=(self.timer_set))
        self.timer_slide.style.padding=5
        self.timer_slide.style.padding_top=5
        self.timer_slide.style.width=200
        self.timer_slide.value=10.0

        main_box.add(self.timer_slide)
        main_box.add(self.timer_label)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()

    def timer_change(self,widget):
        self.timer_label.text="Counter: "+str(self.timer_slide.tick_value)

    def timer_set(self,widget):
        pass

def main():
    return slidetest()


**Expected behavior**
This should produce a slider with 19 tick stops, and return values from 2.0 to 20.0.  

The android build of this code has a slide with 18 tick stops and return values from 2.0 to 19.05263.

Screenshots below just show screen capture of the android emulator with slider full left and full right position.  You can see the resulting tick_value is 1 and 18 respectively.

**Screenshots**
![Screenshot 2021-06-10 203556](https://user-images.githubusercontent.com/46497064/121627164-b42a2f00-ca2b-11eb-80f1-6e2ac35f8d1f.gif)
![Screenshot 2021-06-10 203638](https://user-images.githubusercontent.com/46497064/121627173-b8eee300-ca2b-11eb-9816-c8e1d4cf3e3c.gif)


**Environment:**
 - Operating System: Windows
 - Python version:3.8
 - Software versions:
   - Briefcase: briefcase          0.3.5
   - Toga:
   - toga-core          0.3.0.dev27
   - toga-winforms      0.3.0.dev27
   
arrow              1.1.0
binaryornot        0.4.4
certifi            2021.5.30
chardet            4.0.0
click              8.0.1
colorama           0.4.4
cookiecutter       1.7.3
gitdb              4.0.7
GitPython          3.1.17
idna               2.10
Jinja2             2.11.3
jinja2-time        0.2.0
MarkupSafe         2.0.1
oauthlib           3.1.1
pip                21.1.1
poyo               0.5.0
pycparser          2.20
python-dateutil    2.8.1
python-slugify     5.0.2
pythonnet          2.5.2
setuptools         56.0.0
six                1.16.0
smmap              4.0.0
text-unidecode     1.3
toml               0.10.2
travertino         0.1.3
urllib3            1.26.5
wheel              0.36.2

**Additional context**
Add any other context about the problem here.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/android/toga_android/widgets/slider.py`
Content:
```
1 from travertino.size import at_least
2 
3 from ..libs.android.view import View__MeasureSpec
4 from ..libs.android.widget import SeekBar, SeekBar__OnSeekBarChangeListener
5 from .base import Widget
6 
7 
8 class TogaOnSeekBarChangeListener(SeekBar__OnSeekBarChangeListener):
9     def __init__(self, impl):
10         super().__init__()
11         self.impl = impl
12 
13     def onProgressChanged(self, _view, _progress, _from_user):
14         if self.impl.interface.on_change:
15             self.impl.interface.on_change(widget=self.impl.interface)
16 
17     # Add two unused methods so that the Java interface is completely implemented.
18     def onStartTrackingTouch(self, native_seekbar):
19         pass
20 
21     def onStopTrackingTouch(self, native_seekbar):
22         pass
23 
24 
25 # Since Android's SeekBar is always discrete,
26 # use a high number of steps for a "continuous" slider.
27 DEFAULT_NUMBER_OF_TICKS = 10000
28 
29 
30 class Slider(Widget):
31     def create(self):
32         self.native = SeekBar(self._native_activity)
33         self.native.setMax(DEFAULT_NUMBER_OF_TICKS)
34         self.native.setOnSeekBarChangeListener(TogaOnSeekBarChangeListener(self))
35 
36     def get_value(self):
37         minimum, maximum = self.interface.range
38         n_steps = self.interface.tick_count
39         if n_steps is None:
40             n_steps = DEFAULT_NUMBER_OF_TICKS
41         return (self.native.getProgress() * (maximum - minimum) / n_steps) + minimum
42 
43     def set_value(self, value):
44         minimum, maximum = self.interface.range
45         n_steps = self.interface.tick_count
46         if n_steps is None:
47             n_steps = DEFAULT_NUMBER_OF_TICKS
48         self.native.setProgress(int((maximum - value - minimum) * n_steps))
49 
50     def set_range(self, range):
51         pass
52 
53     def set_tick_count(self, tick_count):
54         if tick_count is None:
55             self.native.setMax(DEFAULT_NUMBER_OF_TICKS)
56         else:
57             self.native.setMax(int(tick_count) - 1)
58 
59     def rehint(self):
60         self.native.measure(
61             View__MeasureSpec.UNSPECIFIED, View__MeasureSpec.UNSPECIFIED
62         )
63         self.interface.intrinsic.width = at_least(self.native.getMeasuredWidth())
64         self.interface.intrinsic.height = self.native.getMeasuredHeight()
65 
66     def set_on_change(self, handler):
67         # No special handling required
68         pass
69 
70     def set_on_press(self, handler):
71         self.interface.factory.not_implemented("Slider.set_on_press()")
72 
73     def set_on_release(self, handler):
74         self.interface.factory.not_implemented("Slider.set_on_release()")
75
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/android/toga_android/widgets/slider.py b/src/android/toga_android/widgets/slider.py
--- a/src/android/toga_android/widgets/slider.py
+++ b/src/android/toga_android/widgets/slider.py
@@ -35,26 +35,37 @@
 
     def get_value(self):
         minimum, maximum = self.interface.range
-        n_steps = self.interface.tick_count
-        if n_steps is None:
-            n_steps = DEFAULT_NUMBER_OF_TICKS
-        return (self.native.getProgress() * (maximum - minimum) / n_steps) + minimum
+        if self.interface.tick_count is not None and self.interface.tick_count <= 1:
+            return minimum
+        toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS
+        android_slider_max = toga_tick_count - 1
+        tick_factor = (maximum - minimum) / android_slider_max
+        progress_scaled = self.native.getProgress() * tick_factor
+        result = progress_scaled + minimum
+        return result
 
     def set_value(self, value):
         minimum, maximum = self.interface.range
-        n_steps = self.interface.tick_count
-        if n_steps is None:
-            n_steps = DEFAULT_NUMBER_OF_TICKS
-        self.native.setProgress(int((maximum - value - minimum) * n_steps))
+        if self.interface.tick_count is not None and self.interface.tick_count <= 1:
+            android_progress = 0
+        else:
+            toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS
+            android_slider_max = toga_tick_count - 1
+            tick_factor = (maximum - minimum) / android_slider_max
+            android_progress = int((value - minimum) * tick_factor)
+        self.native.setProgress(android_progress)
 
     def set_range(self, range):
         pass
 
     def set_tick_count(self, tick_count):
-        if tick_count is None:
-            self.native.setMax(DEFAULT_NUMBER_OF_TICKS)
+        # Since the Android slider slides from 0 to max inclusive, always subtract 1 from tick_count.
+        if self.interface.tick_count is None:
+            android_slider_max = DEFAULT_NUMBER_OF_TICKS - 1
         else:
-            self.native.setMax(int(tick_count) - 1)
+            android_slider_max = int(self.interface.tick_count - 1)
+        # Set the Android SeekBar max, clamping so it's non-negative.
+        self.native.setMax(max(0, android_slider_max))
 
     def rehint(self):
         self.native.measure(

{"golden_diff": "diff --git a/src/android/toga_android/widgets/slider.py b/src/android/toga_android/widgets/slider.py\n--- a/src/android/toga_android/widgets/slider.py\n+++ b/src/android/toga_android/widgets/slider.py\n@@ -35,26 +35,37 @@\n \n     def get_value(self):\n         minimum, maximum = self.interface.range\n-        n_steps = self.interface.tick_count\n-        if n_steps is None:\n-            n_steps = DEFAULT_NUMBER_OF_TICKS\n-        return (self.native.getProgress() * (maximum - minimum) / n_steps) + minimum\n+        if self.interface.tick_count is not None and self.interface.tick_count <= 1:\n+            return minimum\n+        toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS\n+        android_slider_max = toga_tick_count - 1\n+        tick_factor = (maximum - minimum) / android_slider_max\n+        progress_scaled = self.native.getProgress() * tick_factor\n+        result = progress_scaled + minimum\n+        return result\n \n     def set_value(self, value):\n         minimum, maximum = self.interface.range\n-        n_steps = self.interface.tick_count\n-        if n_steps is None:\n-            n_steps = DEFAULT_NUMBER_OF_TICKS\n-        self.native.setProgress(int((maximum - value - minimum) * n_steps))\n+        if self.interface.tick_count is not None and self.interface.tick_count <= 1:\n+            android_progress = 0\n+        else:\n+            toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS\n+            android_slider_max = toga_tick_count - 1\n+            tick_factor = (maximum - minimum) / android_slider_max\n+            android_progress = int((value - minimum) * tick_factor)\n+        self.native.setProgress(android_progress)\n \n     def set_range(self, range):\n         pass\n \n     def set_tick_count(self, tick_count):\n-        if tick_count is None:\n-            self.native.setMax(DEFAULT_NUMBER_OF_TICKS)\n+        # Since the Android slider slides from 0 to max inclusive, always subtract 1 from tick_count.\n+        if self.interface.tick_count is None:\n+            android_slider_max = DEFAULT_NUMBER_OF_TICKS - 1\n         else:\n-            self.native.setMax(int(tick_count) - 1)\n+            android_slider_max = int(self.interface.tick_count - 1)\n+        # Set the Android SeekBar max, clamping so it's non-negative.\n+        self.native.setMax(max(0, android_slider_max))\n \n     def rehint(self):\n         self.native.measure(\n", "issue": "Toga slider widget in android has 1 fewer tick counts than in Windows\n**Describe the bug**\r\nThe toga.Slider widget when defined with range=(2,20), tick_count=19 instantiates a slider in Windows which has 19 tick values.\r\nHowever when the same code is built and run for Android (both in the emulator and an actual Android phone), the slider only\r\nhas 18 tick values.  In addition ,the property Slider.value returns a value which is 18/19 per tick.\r\n\r\n**To Reproduce**\r\nI wrote a simple example which demonstrates the bug clearly.    I build and compiled like this:\r\n    briefcase update android\r\n    briefcase build android\r\n    briefcase run android\r\n\r\nHere is the source code from app.py.\r\n\r\nimport toga\r\nfrom toga.style import Pack\r\nfrom toga.style.pack import COLUMN, ROW\r\n\r\nTIMER_MIN=1\r\nTIMER_MAX=19\r\n\r\nclass slidetest(toga.App):\r\n\r\n    def startup(self):\r\n        main_box = toga.Box()\r\n\r\n        self.timer_label=toga.Label(text=\"Counter: \")\r\n        self.timer_label.style.width=200\r\n        self.timer_label.style.padding=5\r\n\r\n        self.timer_slide=toga.Slider(range=(TIMER_MIN,TIMER_MAX),tick_count=(TIMER_MAX-TIMER_MIN+1),on_change=(self.timer_change),\r\n            on_release=(self.timer_set))\r\n        self.timer_slide.style.padding=5\r\n        self.timer_slide.style.padding_top=5\r\n        self.timer_slide.style.width=200\r\n        self.timer_slide.value=10.0\r\n\r\n        main_box.add(self.timer_slide)\r\n        main_box.add(self.timer_label)\r\n\r\n        self.main_window = toga.MainWindow(title=self.formal_name)\r\n        self.main_window.content = main_box\r\n        self.main_window.show()\r\n\r\n    def timer_change(self,widget):\r\n        self.timer_label.text=\"Counter: \"+str(self.timer_slide.tick_value)\r\n\r\n    def timer_set(self,widget):\r\n        pass\r\n\r\ndef main():\r\n    return slidetest()\r\n\r\n\r\n**Expected behavior**\r\nThis should produce a slider with 19 tick stops, and return values from 2.0 to 20.0.  \r\n\r\nThe android build of this code has a slide with 18 tick stops and return values from 2.0 to 19.05263.\r\n\r\nScreenshots below just show screen capture of the android emulator with slider full left and full right position.  You can see the resulting tick_value is 1 and 18 respectively.\r\n\r\n**Screenshots**\r\n![Screenshot 2021-06-10 203556](https://user-images.githubusercontent.com/46497064/121627164-b42a2f00-ca2b-11eb-80f1-6e2ac35f8d1f.gif)\r\n![Screenshot 2021-06-10 203638](https://user-images.githubusercontent.com/46497064/121627173-b8eee300-ca2b-11eb-9816-c8e1d4cf3e3c.gif)\r\n\r\n\r\n**Environment:**\r\n - Operating System: Windows\r\n - Python version:3.8\r\n - Software versions:\r\n   - Briefcase: briefcase          0.3.5\r\n   - Toga:\r\n   - toga-core          0.3.0.dev27\r\n   - toga-winforms      0.3.0.dev27\r\n   \r\narrow              1.1.0\r\nbinaryornot        0.4.4\r\ncertifi            2021.5.30\r\nchardet            4.0.0\r\nclick              8.0.1\r\ncolorama           0.4.4\r\ncookiecutter       1.7.3\r\ngitdb              4.0.7\r\nGitPython          3.1.17\r\nidna               2.10\r\nJinja2             2.11.3\r\njinja2-time        0.2.0\r\nMarkupSafe         2.0.1\r\noauthlib           3.1.1\r\npip                21.1.1\r\npoyo               0.5.0\r\npycparser          2.20\r\npython-dateutil    2.8.1\r\npython-slugify     5.0.2\r\npythonnet          2.5.2\r\nsetuptools         56.0.0\r\nsix                1.16.0\r\nsmmap              4.0.0\r\ntext-unidecode     1.3\r\ntoml               0.10.2\r\ntravertino         0.1.3\r\nurllib3            1.26.5\r\nwheel              0.36.2\r\n\r\n**Additional context**\r\nAdd any other context about the problem here.\r\n\nToga slider widget in android has 1 fewer tick counts than in Windows\n**Describe the bug**\r\nThe toga.Slider widget when defined with range=(2,20), tick_count=19 instantiates a slider in Windows which has 19 tick values.\r\nHowever when the same code is built and run for Android (both in the emulator and an actual Android phone), the slider only\r\nhas 18 tick values.  In addition ,the property Slider.value returns a value which is 18/19 per tick.\r\n\r\n**To Reproduce**\r\nI wrote a simple example which demonstrates the bug clearly.    I build and compiled like this:\r\n    briefcase update android\r\n    briefcase build android\r\n    briefcase run android\r\n\r\nHere is the source code from app.py.\r\n\r\nimport toga\r\nfrom toga.style import Pack\r\nfrom toga.style.pack import COLUMN, ROW\r\n\r\nTIMER_MIN=1\r\nTIMER_MAX=19\r\n\r\nclass slidetest(toga.App):\r\n\r\n    def startup(self):\r\n        main_box = toga.Box()\r\n\r\n        self.timer_label=toga.Label(text=\"Counter: \")\r\n        self.timer_label.style.width=200\r\n        self.timer_label.style.padding=5\r\n\r\n        self.timer_slide=toga.Slider(range=(TIMER_MIN,TIMER_MAX),tick_count=(TIMER_MAX-TIMER_MIN+1),on_change=(self.timer_change),\r\n            on_release=(self.timer_set))\r\n        self.timer_slide.style.padding=5\r\n        self.timer_slide.style.padding_top=5\r\n        self.timer_slide.style.width=200\r\n        self.timer_slide.value=10.0\r\n\r\n        main_box.add(self.timer_slide)\r\n        main_box.add(self.timer_label)\r\n\r\n        self.main_window = toga.MainWindow(title=self.formal_name)\r\n        self.main_window.content = main_box\r\n        self.main_window.show()\r\n\r\n    def timer_change(self,widget):\r\n        self.timer_label.text=\"Counter: \"+str(self.timer_slide.tick_value)\r\n\r\n    def timer_set(self,widget):\r\n        pass\r\n\r\ndef main():\r\n    return slidetest()\r\n\r\n\r\n**Expected behavior**\r\nThis should produce a slider with 19 tick stops, and return values from 2.0 to 20.0.  \r\n\r\nThe android build of this code has a slide with 18 tick stops and return values from 2.0 to 19.05263.\r\n\r\nScreenshots below just show screen capture of the android emulator with slider full left and full right position.  You can see the resulting tick_value is 1 and 18 respectively.\r\n\r\n**Screenshots**\r\n![Screenshot 2021-06-10 203556](https://user-images.githubusercontent.com/46497064/121627164-b42a2f00-ca2b-11eb-80f1-6e2ac35f8d1f.gif)\r\n![Screenshot 2021-06-10 203638](https://user-images.githubusercontent.com/46497064/121627173-b8eee300-ca2b-11eb-9816-c8e1d4cf3e3c.gif)\r\n\r\n\r\n**Environment:**\r\n - Operating System: Windows\r\n - Python version:3.8\r\n - Software versions:\r\n   - Briefcase: briefcase          0.3.5\r\n   - Toga:\r\n   - toga-core          0.3.0.dev27\r\n   - toga-winforms      0.3.0.dev27\r\n   \r\narrow              1.1.0\r\nbinaryornot        0.4.4\r\ncertifi            2021.5.30\r\nchardet            4.0.0\r\nclick              8.0.1\r\ncolorama           0.4.4\r\ncookiecutter       1.7.3\r\ngitdb              4.0.7\r\nGitPython          3.1.17\r\nidna               2.10\r\nJinja2             2.11.3\r\njinja2-time        0.2.0\r\nMarkupSafe         2.0.1\r\noauthlib           3.1.1\r\npip                21.1.1\r\npoyo               0.5.0\r\npycparser          2.20\r\npython-dateutil    2.8.1\r\npython-slugify     5.0.2\r\npythonnet          2.5.2\r\nsetuptools         56.0.0\r\nsix                1.16.0\r\nsmmap              4.0.0\r\ntext-unidecode     1.3\r\ntoml               0.10.2\r\ntravertino         0.1.3\r\nurllib3            1.26.5\r\nwheel              0.36.2\r\n\r\n**Additional context**\r\nAdd any other context about the problem here.\r\n\n", "before_files": [{"content": "from travertino.size import at_least\n\nfrom ..libs.android.view import View__MeasureSpec\nfrom ..libs.android.widget import SeekBar, SeekBar__OnSeekBarChangeListener\nfrom .base import Widget\n\n\nclass TogaOnSeekBarChangeListener(SeekBar__OnSeekBarChangeListener):\n    def __init__(self, impl):\n        super().__init__()\n        self.impl = impl\n\n    def onProgressChanged(self, _view, _progress, _from_user):\n        if self.impl.interface.on_change:\n            self.impl.interface.on_change(widget=self.impl.interface)\n\n    # Add two unused methods so that the Java interface is completely implemented.\n    def onStartTrackingTouch(self, native_seekbar):\n        pass\n\n    def onStopTrackingTouch(self, native_seekbar):\n        pass\n\n\n# Since Android's SeekBar is always discrete,\n# use a high number of steps for a \"continuous\" slider.\nDEFAULT_NUMBER_OF_TICKS = 10000\n\n\nclass Slider(Widget):\n    def create(self):\n        self.native = SeekBar(self._native_activity)\n        self.native.setMax(DEFAULT_NUMBER_OF_TICKS)\n        self.native.setOnSeekBarChangeListener(TogaOnSeekBarChangeListener(self))\n\n    def get_value(self):\n        minimum, maximum = self.interface.range\n        n_steps = self.interface.tick_count\n        if n_steps is None:\n            n_steps = DEFAULT_NUMBER_OF_TICKS\n        return (self.native.getProgress() * (maximum - minimum) / n_steps) + minimum\n\n    def set_value(self, value):\n        minimum, maximum = self.interface.range\n        n_steps = self.interface.tick_count\n        if n_steps is None:\n            n_steps = DEFAULT_NUMBER_OF_TICKS\n        self.native.setProgress(int((maximum - value - minimum) * n_steps))\n\n    def set_range(self, range):\n        pass\n\n    def set_tick_count(self, tick_count):\n        if tick_count is None:\n            self.native.setMax(DEFAULT_NUMBER_OF_TICKS)\n        else:\n            self.native.setMax(int(tick_count) - 1)\n\n    def rehint(self):\n        self.native.measure(\n            View__MeasureSpec.UNSPECIFIED, View__MeasureSpec.UNSPECIFIED\n        )\n        self.interface.intrinsic.width = at_least(self.native.getMeasuredWidth())\n        self.interface.intrinsic.height = self.native.getMeasuredHeight()\n\n    def set_on_change(self, handler):\n        # No special handling required\n        pass\n\n    def set_on_press(self, handler):\n        self.interface.factory.not_implemented(\"Slider.set_on_press()\")\n\n    def set_on_release(self, handler):\n        self.interface.factory.not_implemented(\"Slider.set_on_release()\")\n", "path": "src/android/toga_android/widgets/slider.py"}], "after_files": [{"content": "from travertino.size import at_least\n\nfrom ..libs.android.view import View__MeasureSpec\nfrom ..libs.android.widget import SeekBar, SeekBar__OnSeekBarChangeListener\nfrom .base import Widget\n\n\nclass TogaOnSeekBarChangeListener(SeekBar__OnSeekBarChangeListener):\n    def __init__(self, impl):\n        super().__init__()\n        self.impl = impl\n\n    def onProgressChanged(self, _view, _progress, _from_user):\n        if self.impl.interface.on_change:\n            self.impl.interface.on_change(widget=self.impl.interface)\n\n    # Add two unused methods so that the Java interface is completely implemented.\n    def onStartTrackingTouch(self, native_seekbar):\n        pass\n\n    def onStopTrackingTouch(self, native_seekbar):\n        pass\n\n\n# Since Android's SeekBar is always discrete,\n# use a high number of steps for a \"continuous\" slider.\nDEFAULT_NUMBER_OF_TICKS = 10000\n\n\nclass Slider(Widget):\n    def create(self):\n        self.native = SeekBar(self._native_activity)\n        self.native.setMax(DEFAULT_NUMBER_OF_TICKS)\n        self.native.setOnSeekBarChangeListener(TogaOnSeekBarChangeListener(self))\n\n    def get_value(self):\n        minimum, maximum = self.interface.range\n        if self.interface.tick_count is not None and self.interface.tick_count <= 1:\n            return minimum\n        toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS\n        android_slider_max = toga_tick_count - 1\n        tick_factor = (maximum - minimum) / android_slider_max\n        progress_scaled = self.native.getProgress() * tick_factor\n        result = progress_scaled + minimum\n        return result\n\n    def set_value(self, value):\n        minimum, maximum = self.interface.range\n        if self.interface.tick_count is not None and self.interface.tick_count <= 1:\n            android_progress = 0\n        else:\n            toga_tick_count = self.interface.tick_count or DEFAULT_NUMBER_OF_TICKS\n            android_slider_max = toga_tick_count - 1\n            tick_factor = (maximum - minimum) / android_slider_max\n            android_progress = int((value - minimum) * tick_factor)\n        self.native.setProgress(android_progress)\n\n    def set_range(self, range):\n        pass\n\n    def set_tick_count(self, tick_count):\n        # Since the Android slider slides from 0 to max inclusive, always subtract 1 from tick_count.\n        if self.interface.tick_count is None:\n            android_slider_max = DEFAULT_NUMBER_OF_TICKS - 1\n        else:\n            android_slider_max = int(self.interface.tick_count - 1)\n        # Set the Android SeekBar max, clamping so it's non-negative.\n        self.native.setMax(max(0, android_slider_max))\n\n    def rehint(self):\n        self.native.measure(\n            View__MeasureSpec.UNSPECIFIED, View__MeasureSpec.UNSPECIFIED\n        )\n        self.interface.intrinsic.width = at_least(self.native.getMeasuredWidth())\n        self.interface.intrinsic.height = self.native.getMeasuredHeight()\n\n    def set_on_change(self, handler):\n        # No special handling required\n        pass\n\n    def set_on_press(self, handler):\n        self.interface.factory.not_implemented(\"Slider.set_on_press()\")\n\n    def set_on_release(self, handler):\n        self.interface.factory.not_implemented(\"Slider.set_on_release()\")\n", "path": "src/android/toga_android/widgets/slider.py"}]}