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

use Chaquopy syntax directly in the android folder #2129

Merged
merged 46 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d7f2fbe
Changed android app.py to use chaquopy
dgmouris Sep 20, 2023
0299b59
Changed android colors.py to use chaquopy
dgmouris Sep 20, 2023
277b155
Changed android container.py to use chaquopy, not complete
dgmouris Sep 20, 2023
a4e40b4
Changed android fonts.py to use chaquopy
dgmouris Sep 20, 2023
ddf317a
Changed android images.py to use chaquopy
dgmouris Sep 20, 2023
f06d3c7
Changed android keys.py to use chaquopy
dgmouris Sep 20, 2023
3af9e9a
Changed android window.py to use chaquopy
dgmouris Sep 20, 2023
9c6a801
Changed android widgets/base.py to use chaquopy, not complete
dgmouris Sep 20, 2023
85e1eb6
Changed android widgets/box.py to use chaquopy
dgmouris Sep 20, 2023
9382940
Changed android widgets/button.py to use chaquopy
dgmouris Sep 21, 2023
668f3b7
Changed android widgets/dateinput.py to use chaquopy
dgmouris Sep 21, 2023
b078b5b
Revert to use MainActivity from libs for tests to pass
dgmouris Sep 22, 2023
7447ce4
Changed more values in widgets/base.py to use chaquopy
dgmouris Sep 22, 2023
cb7062e
Changed widgets/detailedlist.py to use chaquopy
dgmouris Sep 22, 2023
0f49649
Changed android widgets/imageview.py to use chaquopy
dgmouris Sep 22, 2023
b097ea3
Changed android widgets/label.py to use chaquopy
dgmouris Sep 22, 2023
bbefdee
Changed android widgets/multilinetextinput.py to use chaquopy
dgmouris Sep 22, 2023
cc92b2b
Changed android widgets/numberinput.py to use chaquopy
dgmouris Sep 22, 2023
99c2bc9
Changed android widgets/passwordinput.py to use chaquopy
dgmouris Sep 22, 2023
da9d3c9
Changed android widgets/progressbar.py to use chaquopy
dgmouris Sep 22, 2023
ec1fd79
Changed android widgets/scrollcontainer.py to use chaquopy
dgmouris Sep 22, 2023
43f8105
Changed android widgets/selection.py to use chaquopy
dgmouris Sep 22, 2023
4a75934
Changed android widgets/slider.py to use chaquopy
dgmouris Sep 22, 2023
c20dcf7
Removed extra text from android widgets/slider.py
dgmouris Sep 22, 2023
b823422
Removed extra text from android widgets/switch.py
dgmouris Sep 22, 2023
fdec9c9
Changed android widgets/table.py to use chaquopy
dgmouris Sep 22, 2023
fd9c039
Changed android widgets/timeinput.py to use chaquopy
dgmouris Sep 22, 2023
2d87fd6
Changed android widgets/webview.py to use chaquopy
dgmouris Sep 22, 2023
a4fb9f0
Changed android widgets/textinput.py to use chaquopy
dgmouris Sep 22, 2023
5b2a2d1
Changed android container.py to use chaquopy
dgmouris Sep 22, 2023
12817ff
Changed android dialogs.py to use chaquopy
dgmouris Sep 22, 2023
09e6498
Added a change note the PR
dgmouris Sep 22, 2023
b3e33a8
Changed android app.py to use Chaquopy, tests passed
dgmouris Sep 22, 2023
e588c9f
Removed unnecessary dynamic_proxy call
dgmouris Sep 25, 2023
81dd6b8
Removed reference to libs in base.py
dgmouris Sep 25, 2023
208898f
Changed android widgets/canvas.py to use Chaquopy, tests passed
dgmouris Sep 25, 2023
9c64e19
Changed android widgets/internal/pickers.py to use chaquopy
dgmouris Sep 25, 2023
029ef73
Refactor: remove commented out imports
dgmouris Sep 25, 2023
61c68a7
Remove libs folder completely
dgmouris Sep 25, 2023
4e12488
Removed old imports from android widgets/progressbar.py
dgmouris Sep 26, 2023
76abf4a
Update message in changes/1980.misc.rst
dgmouris Sep 26, 2023
c8756af
Merge branch 'issue-1980' of github.com:dgmouris/toga into issue-1980
dgmouris Sep 26, 2023
3d7f673
Remove reference to toga_android.libs in test_backend/app.py
dgmouris Sep 26, 2023
ffc54f7
Remove rubicon requirement from toga_android setup.py
dgmouris Sep 27, 2023
42f2912
Copy android_events.py from briefcase-android-gradle-template
mhsmith Sep 27, 2023
710cd74
Update events.py to use Chaquopy syntax
mhsmith Sep 27, 2023
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
1 change: 0 additions & 1 deletion android/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
setup(
version=version,
install_requires=[
"rubicon-java>=0.2.6",
"toga-core==%s" % version,
],
)
13 changes: 7 additions & 6 deletions android/src/toga_android/app.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import asyncio

from rubicon.java import android_events
from java import dynamic_proxy
from org.beeware.android import IPythonApp, MainActivity

import toga
from android.graphics.drawable import Drawable
from android.media import RingtoneManager
from android.view import Menu, MenuItem
from toga.command import Group

from .libs.activity import IPythonApp, MainActivity
from .libs.android.graphics import Drawable
from .libs.android.view import Menu, MenuItem
from .libs import events
from .window import Window

# `MainWindow` is defined here in `app.py`, not `window.py`, to mollify the test suite.
MainWindow = Window


class TogaApp(IPythonApp):
class TogaApp(dynamic_proxy(IPythonApp)):
last_intent_requestcode = (
-1
) # always increment before using it for invoking new Intents
Expand Down Expand Up @@ -170,7 +171,7 @@ def __init__(self, interface):
self.interface._impl = self
self._listener = None

self.loop = android_events.AndroidEventLoop()
self.loop = events.AndroidEventLoop()

@property
def native(self):
Expand Down
2 changes: 1 addition & 1 deletion android/src/toga_android/colors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from travertino.colors import NAMED_COLOR, TRANSPARENT

from .libs.android.graphics import Color
from android.graphics import Color

CACHE = {TRANSPARENT: Color.TRANSPARENT}

Expand Down
5 changes: 3 additions & 2 deletions android/src/toga_android/container.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .libs.android.widget import RelativeLayout, RelativeLayout__LayoutParams
from android.widget import RelativeLayout

from .widgets.base import Scalable


Expand Down Expand Up @@ -56,7 +57,7 @@ def remove_content(self, widget):
self.native_content.removeView(widget.native)

def set_content_bounds(self, widget, x, y, width, height):
lp = RelativeLayout__LayoutParams(width, height)
lp = RelativeLayout.LayoutParams(width, height)
lp.topMargin = y
lp.leftMargin = x
widget.native.setLayoutParams(lp)
14 changes: 8 additions & 6 deletions android/src/toga_android/dialogs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from abc import ABC

from .libs.android import R__drawable
from .libs.android.app import AlertDialog__Builder
from .libs.android.content import DialogInterface__OnClickListener
from java import dynamic_proxy

from android import R
from android.app import AlertDialog
from android.content import DialogInterface

class OnClickListener(DialogInterface__OnClickListener):

class OnClickListener(dynamic_proxy(DialogInterface.OnClickListener)):
def __init__(self, fn=None, value=None):
super().__init__()
self._fn = fn
Expand Down Expand Up @@ -44,7 +46,7 @@ def __init__(
super().__init__(interface=interface)
self.on_result = on_result

self.native = AlertDialog__Builder(interface.window._impl.app.native)
self.native = AlertDialog.Builder(interface.window._impl.app.native)
self.native.setCancelable(False)
self.native.setTitle(title)
self.native.setMessage(message)
Expand Down Expand Up @@ -108,7 +110,7 @@ def __init__(self, interface, title, message, on_result=None):
title=title,
message=message,
positive_text="OK",
icon=R__drawable.ic_dialog_alert,
icon=R.drawable.ic_dialog_alert,
on_result=on_result,
)

Expand Down
4 changes: 2 additions & 2 deletions android/src/toga_android/fonts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path

from android.graphics import Typeface
from android.util import TypedValue
from toga.fonts import (
_REGISTERED_FONT_CACHE,
BOLD,
Expand All @@ -15,8 +17,6 @@
SYSTEM_DEFAULT_FONT_SIZE,
SYSTEM_DEFAULT_FONTS,
)
from toga_android.libs.android.graphics import Typeface
from toga_android.libs.android.util import TypedValue

_FONT_CACHE = {}

Expand Down
2 changes: 1 addition & 1 deletion android/src/toga_android/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from java.io import FileOutputStream

from .libs.android.graphics import Bitmap, BitmapFactory
from android.graphics import Bitmap, BitmapFactory


class Image:
Expand Down
3 changes: 1 addition & 2 deletions android/src/toga_android/keys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from android.view import KeyEvent
from toga.keys import Key

from .libs.android.view import KeyEvent

KEYEVENT_KEYS = {
KeyEvent.KEYCODE_ESCAPE: Key.ESCAPE,
KeyEvent.KEYCODE_F1: Key.F1,
Expand Down
20 changes: 0 additions & 20 deletions android/src/toga_android/libs/activity.py

This file was deleted.

8 changes: 0 additions & 8 deletions android/src/toga_android/libs/android/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions android/src/toga_android/libs/android/app.py

This file was deleted.

6 changes: 0 additions & 6 deletions android/src/toga_android/libs/android/content.py

This file was deleted.

16 changes: 0 additions & 16 deletions android/src/toga_android/libs/android/graphics/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions android/src/toga_android/libs/android/graphics/drawable.py

This file was deleted.

3 changes: 0 additions & 3 deletions android/src/toga_android/libs/android/os.py

This file was deleted.

5 changes: 0 additions & 5 deletions android/src/toga_android/libs/android/text.py

This file was deleted.

5 changes: 0 additions & 5 deletions android/src/toga_android/libs/android/util.py

This file was deleted.

20 changes: 0 additions & 20 deletions android/src/toga_android/libs/android/view.py

This file was deleted.

5 changes: 0 additions & 5 deletions android/src/toga_android/libs/android/webkit.py

This file was deleted.

45 changes: 0 additions & 45 deletions android/src/toga_android/libs/android/widget.py

This file was deleted.

Empty file.
6 changes: 0 additions & 6 deletions android/src/toga_android/libs/androidx/swiperefreshlayout.py

This file was deleted.

Loading