prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Android Read-only Multi-line text input displays suggestions (Spell Checking)
  ### Describe the bug
  
  When using the "MultilineTextInput" with the "readonly" parameter set to "True" on Android, it will suggest spelling improvements based on dictionary candidates. This behavior results in underlined text on android devices when using a language other than the keyboard language or with unknown words in general.
  
  ### Steps to reproduce
  
  1. Use MultilineTextInput in readonly with a set text
  2. Compile for android and set the KeyBoard language to a different one than the text.
  3. The suggestions should appear, underlining the Text.
  
  ### Expected behavior
  
  Suggestions do not show up in MultilineTextInput if set to readonly.
  
  ### Screenshots
  
  _No response_
  
  ### Environment
  
  - Operating System: Fedora 38 Workstation / Lineage OS 20.0
  - Python version: 3.11.5
  - Software versions:
    - Briefcase: 0.3.15
    - Toga: 0.3.1 
  
  [tool.briefcase.app.trinker.android]
  requires = [
      #"toga-android~=0.3.1"
      'git+https://github.com/beeware/toga.git#subdirectory=core',
      'git+https://github.com/beeware/toga.git#subdirectory=android',
  ]
  
  
  
  ### Logs
  
  ```
  
  ```
  
  
  ### Additional context
  
  I did some research on the topic and while I'm not really an Android dev, I think I found the problem. In "android/src/toga_android/widgets/textinput.py" we need to set the flag [TYPE_TEXT_FLAG_NO_SUGGESTIONS](https://developer.android.com/reference/android/text/InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS) if "readonly" is true.
  
  As said before, I'm not really an Android dev and am not sure how this would be implemented.
  
  
  </issue>
  <code>
  [start of android/src/toga_android/widgets/textinput.py]
  1 from java import dynamic_proxy
  2 from travertino.size import at_least
  3 
  4 from android.text import InputType, TextWatcher
  5 from android.view import Gravity, View
  6 from android.widget import EditText
  7 from toga_android.keys import toga_key
  8 
  9 from .label import TextViewWidget
  10 
  11 
  12 class TogaTextWatcher(dynamic_proxy(TextWatcher)):
  13     def __init__(self, impl):
  14         super().__init__()
  15         self.impl = impl
  16 
  17     def beforeTextChanged(self, _charSequence, _start, _count, _after):
  18         pass
  19 
  20     def afterTextChanged(self, _editable):
  21         self.impl._on_change()
  22 
  23     def onTextChanged(self, _charSequence, _start, _before, _count):
  24         pass
  25 
  26 
  27 class TogaKeyListener(dynamic_proxy(View.OnKeyListener)):
  28     def __init__(self, impl):
  29         super().__init__()
  30         self.impl = impl
  31 
  32     def onKey(self, _view, _key, _event):
  33         event_info = toga_key(_event)
  34         if event_info is None:
  35             pass  # pragma: nocover
  36         else:
  37             key_pressed = event_info["key"].value
  38             if (key_pressed == "<enter>" or key_pressed == "numpad:enter") and (
  39                 int(_event.getAction()) == 1
  40             ):
  41                 self.impl._on_confirm()
  42         return False
  43 
  44 
  45 class TogaFocusListener(dynamic_proxy(View.OnFocusChangeListener)):
  46     def __init__(self, impl):
  47         super().__init__()
  48         self.impl = impl
  49 
  50     def onFocusChange(self, view, has_focus):
  51         if has_focus:
  52             self.impl._on_gain_focus()
  53         else:
  54             self.impl._on_lose_focus()
  55 
  56 
  57 class TextInput(TextViewWidget):
  58     def create(self, input_type=InputType.TYPE_CLASS_TEXT):
  59         self.native = EditText(self._native_activity)
  60         self.native.setInputType(input_type)
  61         self.cache_textview_defaults()
  62 
  63         self.native.addTextChangedListener(TogaTextWatcher(self))
  64         self.native.setOnKeyListener(TogaKeyListener(self))
  65         self.native.setOnFocusChangeListener(TogaFocusListener(self))
  66 
  67     def get_value(self):
  68         return str(self.native.getText())
  69 
  70     def set_value(self, value):
  71         self.native.setText(value)
  72 
  73     def get_readonly(self):
  74         return not self.native.isFocusable()
  75 
  76     def set_readonly(self, readonly):
  77         if readonly:
  78             # Implicitly calls setFocusableInTouchMode(False)
  79             self.native.setFocusable(False)
  80         else:
  81             # Implicitly calls setFocusable(True)
  82             self.native.setFocusableInTouchMode(True)
  83 
  84     def get_placeholder(self):
  85         return str(self.native.getHint())
  86 
  87     def set_placeholder(self, value):
  88         self.native.setHint(value)
  89 
  90     def set_alignment(self, value):
  91         self.set_textview_alignment(value, Gravity.CENTER_VERTICAL)
  92 
  93     def set_error(self, error_message):
  94         self.native.setError(error_message)
  95 
  96     def clear_error(self):
  97         self.native.setError(None)
  98 
  99     def is_valid(self):
  100         return self.native.getError() is None
  101 
  102     def _on_change(self):
  103         self.interface.on_change(None)
  104         self.interface._validate()
  105 
  106     def _on_confirm(self):
  107         self.interface.on_confirm(None)
  108 
  109     def _on_gain_focus(self):
  110         self.interface.on_gain_focus(None)
  111 
  112     def _on_lose_focus(self):
  113         self.interface.on_lose_focus(None)
  114 
  115     def rehint(self):
  116         self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH)
  117         self.native.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
  118         self.interface.intrinsic.height = self.native.getMeasuredHeight()
  119
  [end of android/src/toga_android/widgets/textinput.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/android/src/toga_android/widgets/textinput.py b/android/src/toga_android/widgets/textinput.py
  --- a/android/src/toga_android/widgets/textinput.py
  +++ b/android/src/toga_android/widgets/textinput.py
  @@ -77,9 +77,19 @@
           if readonly:
               # Implicitly calls setFocusableInTouchMode(False)
               self.native.setFocusable(False)
  +            # Add TYPE_TEXT_FLAG_NO_SUGGESTIONS to the input type to disable suggestions
  +            input_type = (
  +                self.native.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
  +            )
  +            self.native.setInputType(input_type)
           else:
               # Implicitly calls setFocusable(True)
               self.native.setFocusableInTouchMode(True)
  +            # Remove TYPE_TEXT_FLAG_NO_SUGGESTIONS to enable suggestions
  +            input_type = (
  +                self.native.getInputType() & ~InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
  +            )
  +            self.native.setInputType(input_type)
   
       def get_placeholder(self):
           return str(self.native.getHint())
  
verification_info: {"golden_diff": "diff --git a/android/src/toga_android/widgets/textinput.py b/android/src/toga_android/widgets/textinput.py\n--- a/android/src/toga_android/widgets/textinput.py\n+++ b/android/src/toga_android/widgets/textinput.py\n@@ -77,9 +77,19 @@\n         if readonly:\n             # Implicitly calls setFocusableInTouchMode(False)\n             self.native.setFocusable(False)\n+            # Add TYPE_TEXT_FLAG_NO_SUGGESTIONS to the input type to disable suggestions\n+            input_type = (\n+                self.native.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS\n+            )\n+            self.native.setInputType(input_type)\n         else:\n             # Implicitly calls setFocusable(True)\n             self.native.setFocusableInTouchMode(True)\n+            # Remove TYPE_TEXT_FLAG_NO_SUGGESTIONS to enable suggestions\n+            input_type = (\n+                self.native.getInputType() & ~InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS\n+            )\n+            self.native.setInputType(input_type)\n \n     def get_placeholder(self):\n         return str(self.native.getHint())\n", "issue": "Android Read-only Multi-line text input displays suggestions (Spell Checking)\n### Describe the bug\n\nWhen using the \"MultilineTextInput\" with the \"readonly\" parameter set to \"True\" on Android, it will suggest spelling improvements based on dictionary candidates. This behavior results in underlined text on android devices when using a language other than the keyboard language or with unknown words in general.\n\n### Steps to reproduce\n\n1. Use MultilineTextInput in readonly with a set text\r\n2. Compile for android and set the KeyBoard language to a different one than the text.\r\n3. The suggestions should appear, underlining the Text.\n\n### Expected behavior\n\nSuggestions do not show up in MultilineTextInput if set to readonly.\n\n### Screenshots\n\n_No response_\n\n### Environment\n\n- Operating System: Fedora 38 Workstation / Lineage OS 20.0\r\n- Python version: 3.11.5\r\n- Software versions:\r\n  - Briefcase: 0.3.15\r\n  - Toga: 0.3.1 \r\n\r\n[tool.briefcase.app.trinker.android]\r\nrequires = [\r\n    #\"toga-android~=0.3.1\"\r\n    'git+https://github.com/beeware/toga.git#subdirectory=core',\r\n    'git+https://github.com/beeware/toga.git#subdirectory=android',\r\n]\r\n\r\n\n\n### Logs\n\n```\r\n\r\n```\r\n\n\n### Additional context\n\nI did some research on the topic and while I'm not really an Android dev, I think I found the problem. In \"android/src/toga_android/widgets/textinput.py\" we need to set the flag [TYPE_TEXT_FLAG_NO_SUGGESTIONS](https://developer.android.com/reference/android/text/InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS) if \"readonly\" is true.\r\n\r\nAs said before, I'm not really an Android dev and am not sure how this would be implemented.\r\n\n", "before_files": [{"content": "from java import dynamic_proxy\nfrom travertino.size import at_least\n\nfrom android.text import InputType, TextWatcher\nfrom android.view import Gravity, View\nfrom android.widget import EditText\nfrom toga_android.keys import toga_key\n\nfrom .label import TextViewWidget\n\n\nclass TogaTextWatcher(dynamic_proxy(TextWatcher)):\n    def __init__(self, impl):\n        super().__init__()\n        self.impl = impl\n\n    def beforeTextChanged(self, _charSequence, _start, _count, _after):\n        pass\n\n    def afterTextChanged(self, _editable):\n        self.impl._on_change()\n\n    def onTextChanged(self, _charSequence, _start, _before, _count):\n        pass\n\n\nclass TogaKeyListener(dynamic_proxy(View.OnKeyListener)):\n    def __init__(self, impl):\n        super().__init__()\n        self.impl = impl\n\n    def onKey(self, _view, _key, _event):\n        event_info = toga_key(_event)\n        if event_info is None:\n            pass  # pragma: nocover\n        else:\n            key_pressed = event_info[\"key\"].value\n            if (key_pressed == \"<enter>\" or key_pressed == \"numpad:enter\") and (\n                int(_event.getAction()) == 1\n            ):\n                self.impl._on_confirm()\n        return False\n\n\nclass TogaFocusListener(dynamic_proxy(View.OnFocusChangeListener)):\n    def __init__(self, impl):\n        super().__init__()\n        self.impl = impl\n\n    def onFocusChange(self, view, has_focus):\n        if has_focus:\n            self.impl._on_gain_focus()\n        else:\n            self.impl._on_lose_focus()\n\n\nclass TextInput(TextViewWidget):\n    def create(self, input_type=InputType.TYPE_CLASS_TEXT):\n        self.native = EditText(self._native_activity)\n        self.native.setInputType(input_type)\n        self.cache_textview_defaults()\n\n        self.native.addTextChangedListener(TogaTextWatcher(self))\n        self.native.setOnKeyListener(TogaKeyListener(self))\n        self.native.setOnFocusChangeListener(TogaFocusListener(self))\n\n    def get_value(self):\n        return str(self.native.getText())\n\n    def set_value(self, value):\n        self.native.setText(value)\n\n    def get_readonly(self):\n        return not self.native.isFocusable()\n\n    def set_readonly(self, readonly):\n        if readonly:\n            # Implicitly calls setFocusableInTouchMode(False)\n            self.native.setFocusable(False)\n        else:\n            # Implicitly calls setFocusable(True)\n            self.native.setFocusableInTouchMode(True)\n\n    def get_placeholder(self):\n        return str(self.native.getHint())\n\n    def set_placeholder(self, value):\n        self.native.setHint(value)\n\n    def set_alignment(self, value):\n        self.set_textview_alignment(value, Gravity.CENTER_VERTICAL)\n\n    def set_error(self, error_message):\n        self.native.setError(error_message)\n\n    def clear_error(self):\n        self.native.setError(None)\n\n    def is_valid(self):\n        return self.native.getError() is None\n\n    def _on_change(self):\n        self.interface.on_change(None)\n        self.interface._validate()\n\n    def _on_confirm(self):\n        self.interface.on_confirm(None)\n\n    def _on_gain_focus(self):\n        self.interface.on_gain_focus(None)\n\n    def _on_lose_focus(self):\n        self.interface.on_lose_focus(None)\n\n    def rehint(self):\n        self.interface.intrinsic.width = at_least(self.interface._MIN_WIDTH)\n        self.native.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)\n        self.interface.intrinsic.height = self.native.getMeasuredHeight()\n", "path": "android/src/toga_android/widgets/textinput.py"}]}