mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Android build scripts updates. Some Comments in kivy files.
This commit is contained in:
parent
a1219f6db1
commit
9155493dc9
7 changed files with 90 additions and 211 deletions
|
@ -1,6 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
package='org.lufebe16.pysolfc'
|
||||
version=`./version.py`
|
||||
name='PySolFC'
|
||||
tmpdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src
|
||||
|
||||
if [ "$1" ]
|
||||
then
|
||||
package=${package}.dbg
|
||||
name=${name}dbg
|
||||
fi
|
||||
|
||||
python3 -m pythonforandroid.toolchain apk \
|
||||
--sdk-dir ${HOME}/.cache/sdk-for-p4a \
|
||||
|
@ -9,15 +18,15 @@ python3 -m pythonforandroid.toolchain apk \
|
|||
--ndk-version r12b \
|
||||
--arch armeabi-v7a \
|
||||
--dist-name pysolfc \
|
||||
--name PySolFC \
|
||||
--name ${name} \
|
||||
--bootstrap=sdl2 \
|
||||
--requirements kivy,hostpython2,random2 \
|
||||
--minsdk 14 \
|
||||
--private tmp/src \
|
||||
--package org.lufebe16.pysolfc \
|
||||
--private ${tmpdir} \
|
||||
--package ${package} \
|
||||
--version ${version} \
|
||||
--orientation sensor \
|
||||
--color=always \
|
||||
--icon tmp/src/data/images/misc/pysol01.png \
|
||||
--presplash tmp/src/data/images/misc/pysol06.png \
|
||||
--icon ${tmpdir}/data/images/misc/pysol01.png \
|
||||
--presplash ${tmpdir}/data/images/misc/pysol06.png \
|
||||
--copy-libs
|
||||
|
|
|
@ -6,61 +6,51 @@ echo '### prepare sdk'
|
|||
|
||||
echo '### install p4a'
|
||||
|
||||
#p4aversion='0.5.3p'
|
||||
# Downloded file "https://github.com/kivy/python-for-android/archive/0.5.3.zip"
|
||||
# Note: Minor fixes had to be added to version 0.5.3 in order to
|
||||
# cooperate with fdroid.
|
||||
#python3 -m pip install -q --user "./p4a/${p4aversion}.zip"
|
||||
p4adir=${HOME}/.cache/tmp-for-p4a
|
||||
mkdir -p ${p4adir}
|
||||
|
||||
p4aversion='0.5.3'
|
||||
if [ ! -f ./${p4aversion}.zip ]
|
||||
if [ ! -f ${p4adir}/${p4aversion}.zip ]
|
||||
then
|
||||
wget "https://github.com/kivy/python-for-android/archive/${p4aversion}.zip"
|
||||
cp -a ./${p4aversion}.zip ${p4adir}/${p4aversion}.zip
|
||||
rm -f ./${p4aversion}.zip
|
||||
fi
|
||||
if [ -f ./${p4aversion}.zip ]
|
||||
if [ -f ${p4adir}/${p4aversion}.zip ]
|
||||
then
|
||||
python3 -m pip install -q --user "./${p4aversion}.zip"
|
||||
python3 -m pip install -q --user "${p4adir}/${p4aversion}.zip"
|
||||
else
|
||||
echo "### download of ${p4aversion}.zip failed"
|
||||
fi
|
||||
|
||||
echo '### load prepared recipes if available'
|
||||
|
||||
if [ -d ./packages ]
|
||||
then
|
||||
echo '### copying recipes'
|
||||
mkdir -p ${HOME}/.local/share/python-for-android
|
||||
cp -a packages ${HOME}/.local/share/python-for-android/
|
||||
fi
|
||||
|
||||
echo '### prepare source'
|
||||
|
||||
mkdir -p tmp
|
||||
rm -rf tmp/src
|
||||
srcdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src
|
||||
|
||||
# Easiest variant. But rsync may not be installed.
|
||||
# rsync -a .. tmp/src --exclude android/tmp
|
||||
# so:
|
||||
mkdir -p ${srcdir}
|
||||
rm -rf ${srcdir}
|
||||
cp -a .. ${srcdir}
|
||||
rm -rf ${srcdir}/android
|
||||
rm -rf ${srcdir}/src
|
||||
cp -a main.py ${srcdir}/main.py
|
||||
mkdir -p ${srcdir}/data/images/cards/bottoms/trumps-only
|
||||
echo "" > ${srcdir}/data/images/cards/bottoms/trumps-only/.keep
|
||||
|
||||
mkdir -p ${HOME}/.local/tmp/src
|
||||
cp -a .. ${HOME}/.local/tmp/src
|
||||
mv ${HOME}/.local/tmp/src tmp/src
|
||||
echo '### prepare cardsets'
|
||||
|
||||
rm -rf tmp/src/android
|
||||
rm -rf tmp/src/src
|
||||
cp -a main.py tmp/src/main.py
|
||||
mkdir -p tmp/src/data/images/cards/bottoms/trumps-only
|
||||
echo "" > tmp/src/data/images/cards/bottoms/trumps-only/.keep
|
||||
cardsdir=${HOME}/.cache/tmp-for-p4a/pysolfc
|
||||
|
||||
if [ ! -d ./PySolFC-Cardsets-2.0 ]
|
||||
if [ ! -d ${cardsdir}/PySolFC-Cardsets-2.0 ]
|
||||
then
|
||||
./mkcards
|
||||
mv PySolFC-Cardsets-2.0 ${cardsdir}/
|
||||
rm -f PySolFC-Cardsets-2.0.tar.bz2
|
||||
fi
|
||||
|
||||
if [ -d ./PySolFC-Cardsets-2.0 ]
|
||||
if [ -d ${cardsdir}/PySolFC-Cardsets-2.0 ]
|
||||
then
|
||||
echo '### copying cardsets'
|
||||
cp -a ./PySolFC-Cardsets-2.0/* ./tmp/src/data
|
||||
cp -a ${cardsdir}/PySolFC-Cardsets-2.0/* ${srcdir}/data
|
||||
fi
|
||||
|
||||
echo '### end init'
|
||||
|
|
|
@ -32,6 +32,7 @@ export P4A_RELEASE_KEYALIAS_PASSWD="$pass2"
|
|||
export P4A_RELEASE_KEYALIAS="$keyalias"
|
||||
|
||||
version=`./version.py`
|
||||
tmpdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src
|
||||
|
||||
python3 -m pythonforandroid.toolchain apk \
|
||||
--sdk-dir ${HOME}/.cache/sdk-for-p4a \
|
||||
|
@ -46,13 +47,13 @@ python3 -m pythonforandroid.toolchain apk \
|
|||
--release \
|
||||
--sign \
|
||||
--minsdk 14 \
|
||||
--private tmp/src \
|
||||
--private ${tmpdir} \
|
||||
--package org.lufebe16.pysolfc \
|
||||
--version ${version} \
|
||||
--orientation sensor \
|
||||
--color=always \
|
||||
--icon tmp/src/data/images/misc/pysol01.png \
|
||||
--presplash tmp/src/data/images/misc/pysol06.png \
|
||||
--icon ${tmpdir}/data/images/misc/pysol01.png \
|
||||
--presplash ${tmpdir}/data/images/misc/pysol06.png \
|
||||
--copy-libs
|
||||
|
||||
# keystore options (instead environment vars):
|
||||
|
|
|
@ -20,6 +20,7 @@ fi
|
|||
echo '### run toolchain'
|
||||
|
||||
version=`./version.py`
|
||||
tmpdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src
|
||||
|
||||
python3 -m pythonforandroid.toolchain apk \
|
||||
--sdk-dir ${sdkdir} \
|
||||
|
@ -33,13 +34,13 @@ python3 -m pythonforandroid.toolchain apk \
|
|||
--requirements kivy,hostpython2,random2 \
|
||||
--release \
|
||||
--minsdk 14 \
|
||||
--private tmp/src \
|
||||
--private ${tmpdir} \
|
||||
--package org.lufebe16.pysolfc \
|
||||
--version ${version} \
|
||||
--orientation sensor \
|
||||
--color=always \
|
||||
--icon tmp/src/data/images/misc/pysol01.png \
|
||||
--presplash tmp/src/data/images/misc/pysol06.png \
|
||||
--icon ${tmpdir}/data/images/misc/pysol01.png \
|
||||
--presplash ${tmpdir}/data/images/misc/pysol06.png \
|
||||
--copy-libs
|
||||
|
||||
# python3 -m pythonforandroid.toolchain apk
|
||||
|
|
|
@ -1455,6 +1455,8 @@ class LMainWindow(BoxLayout, LTkBase):
|
|||
self.workStack = LStack()
|
||||
self.app = None
|
||||
|
||||
# self.touches = []
|
||||
|
||||
# beispiel zu canvas (hintergrund)
|
||||
# with self.canvas.before:
|
||||
# Color(0, 1, 0.7, 0.5)
|
||||
|
@ -1466,11 +1468,37 @@ class LMainWindow(BoxLayout, LTkBase):
|
|||
# self.rect.pos = self.pos
|
||||
# self.rect.size = self.size
|
||||
|
||||
def on_motion(self, m):
|
||||
print('on_motion', m)
|
||||
pass
|
||||
|
||||
# Events.
|
||||
|
||||
def on_touch_down(self, touch):
|
||||
ret = False
|
||||
|
||||
# print(dir(touch))
|
||||
|
||||
# multitouch detection
|
||||
'''
|
||||
#print("MainWindow touch_down",touch.ox,touch.oy)
|
||||
#print("MainWindow touch_down",touch.sx,touch.sy)
|
||||
#print("MainWindow touch_down",touch.px,touch.py)
|
||||
self.touches.append(touch)
|
||||
print("touches cnt = ",len(self.touches))
|
||||
'''
|
||||
# multiclick detection
|
||||
'''
|
||||
if touch.is_double_tap:
|
||||
print('Touch is a double tap !')
|
||||
print(' - interval is', touch.double_tap_time)
|
||||
print(' - distance between previous is', touch.double_tap_distance)
|
||||
|
||||
if touch.is_triple_tap:
|
||||
print('Touch is a triple tap !')
|
||||
print(' - interval is', touch.triple_tap_time)
|
||||
print(' - distance between previous is', touch.triple_tap_distance)
|
||||
'''
|
||||
# (Eventloop reentrancy check)
|
||||
if self.in_loop:
|
||||
return ret
|
||||
|
@ -1499,6 +1527,12 @@ class LMainWindow(BoxLayout, LTkBase):
|
|||
ret = c.on_touch_up(touch)
|
||||
if ret:
|
||||
break
|
||||
|
||||
# multitouch support
|
||||
'''
|
||||
self.touches = [xx for xx in self.touches if xx != touch]
|
||||
print("touches cnt = ",len(self.touches))
|
||||
'''
|
||||
return ret
|
||||
|
||||
# Menubar:
|
||||
|
@ -1572,6 +1606,9 @@ class LApp(App):
|
|||
|
||||
def __init__(self):
|
||||
super(LApp, self).__init__()
|
||||
|
||||
# Config.set('input', 'multitouchscreen1', 'tuio,0.0.0.0:3333')
|
||||
|
||||
self.mainWindow = LMainWindow()
|
||||
logging.info('top = %s' % str(self.mainWindow))
|
||||
Cache.register('LAppCache', limit=10)
|
||||
|
|
|
@ -499,6 +499,14 @@ class MfxCanvas(Widget):
|
|||
if self.r_height is None:
|
||||
return self.scale
|
||||
|
||||
# TBD (idee).
|
||||
# Hier ev. einen 2ten Modus zulassen, welche das Spielfeld
|
||||
# knapp auf die vorhandenen Karten/Anzeigeelemente bemisst.
|
||||
# Zur Optimierung der Sichtbarkeit auf kleinen Geräten.
|
||||
# Könnte z.B. über Doppelklick umgeschaltet werden. (Die
|
||||
# Skalierung müsste dann allerding nach jedem Zug dem ev.
|
||||
# veränderten Feld angepasst werden.)
|
||||
|
||||
scfx = self.size[0] / self.r_width
|
||||
scfy = self.size[1] / self.r_height
|
||||
|
||||
|
@ -685,21 +693,6 @@ class MfxCanvas(Widget):
|
|||
# self.size[1] = height
|
||||
return
|
||||
|
||||
# print 'setInitialSize:', width, height
|
||||
if self.preview:
|
||||
self.config(width=width, height=height,
|
||||
scrollregion=(0, 0, width, height))
|
||||
else:
|
||||
# add margins
|
||||
# dx, dy = 40, 40
|
||||
dx, dy = self.xmargin, self.ymargin
|
||||
self.config(width=dx + width + dx, height=dy + height + dy,
|
||||
scrollregion=(-dx, -dy, width + dx, height + dy))
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
# delete all CanvasItems, but keep the background and top tiles
|
||||
def deleteAllItems(self):
|
||||
print('MfxCanvas: deleteAllItems')
|
||||
|
|
|
@ -69,60 +69,6 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
self.accel_keys = {}
|
||||
self.top = makeToplevel(parent, title=title)
|
||||
|
||||
'''
|
||||
def mainloop(self, focus=None, timeout=0, transient=True):
|
||||
bind(self.top, "<Escape>", self.mCancel)
|
||||
bind(self.top, '<Alt-Key>', self.altKeyEvent) # for accelerators
|
||||
if focus is not None:
|
||||
focus.focus()
|
||||
if transient:
|
||||
setTransient(self.top, self.parent)
|
||||
try:
|
||||
self.top.grab_set()
|
||||
except Tkinter.TclError:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
if timeout > 0:
|
||||
self.timer = after(self.top, timeout, self.mTimeout)
|
||||
try:
|
||||
self.top.mainloop()
|
||||
except SystemExit:
|
||||
pass
|
||||
self.destroy()
|
||||
|
||||
def destroy(self):
|
||||
after_cancel(self.timer)
|
||||
unbind_destroy(self.top)
|
||||
try:
|
||||
self.top.wm_withdraw()
|
||||
except:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
try:
|
||||
self.top.destroy()
|
||||
except:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
# destruct(self.top)
|
||||
if 1 and self.parent: # ???
|
||||
try:
|
||||
# self.parent.update_idletasks()
|
||||
# FIXME: why do we need this under Windows ?
|
||||
if hasattr(self.parent, "busyUpdate"):
|
||||
self.parent.busyUpdate()
|
||||
else:
|
||||
self.parent.update()
|
||||
except:
|
||||
if traceback:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
self.top = None
|
||||
self.parent = None
|
||||
'''
|
||||
|
||||
def wmDeleteWindow(self, *event):
|
||||
self.status = 1
|
||||
raise SystemExit
|
||||
|
@ -170,104 +116,6 @@ class MfxDialog: # ex. _ToplevelDialog
|
|||
a = LBoxLayout(orientation="vertical")
|
||||
b = LBoxLayout(orientation="vertical")
|
||||
return a, b
|
||||
'''
|
||||
bottom_frame = Tkinter.Frame(self.top)
|
||||
bottom_frame.pack(side='bottom', fill='both', expand=False,
|
||||
ipadx=3, ipady=3)
|
||||
if kw.separator:
|
||||
separator = Tkinter.Frame(self.top, relief="sunken",
|
||||
height=2, width=2, borderwidth=1)
|
||||
separator.pack(side='bottom', fill='x')
|
||||
top_frame = Tkinter.Frame(self.top)
|
||||
top_frame.pack(side='top', fill='both', expand=True)
|
||||
return top_frame, bottom_frame
|
||||
'''
|
||||
|
||||
'''
|
||||
def createBitmaps(self, frame, kw):
|
||||
if kw.bitmap: # in ("error", "info", "question", "warning")
|
||||
img = self.img.get(kw.bitmap)
|
||||
b = Tkinter.Label(frame, image=img)
|
||||
b.pack(side=kw.bitmap_side,
|
||||
padx=kw.bitmap_padx, pady=kw.bitmap_pady)
|
||||
elif kw.image:
|
||||
b = Tkinter.Label(frame, image=kw.image)
|
||||
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
|
||||
'''
|
||||
|
||||
'''
|
||||
def createButtons(self, frame, kw):
|
||||
button = -1
|
||||
column = 0
|
||||
# padx, pady = kw.get("buttonpadx", 10), kw.get("buttonpady", 10)
|
||||
focus = None
|
||||
max_len = 0
|
||||
for s in kw.strings:
|
||||
if isinstance(s, tuple):
|
||||
s = s[0]
|
||||
if s:
|
||||
# if os.name == 'posix':
|
||||
# s = s.replace('...', '.')
|
||||
s = s.replace('&', '')
|
||||
max_len = max(max_len, len(s))
|
||||
# print s, len(s)
|
||||
# if max_len > 12 and WIN_SYSTEM == 'x11':
|
||||
# button_width = max_len
|
||||
# elif max_len > 9:
|
||||
# button_width = max_len + 1
|
||||
# elif max_len > 6:
|
||||
# button_width = max_len + 2
|
||||
# else:
|
||||
# button_width = 8
|
||||
# print 'button_width =', button_width
|
||||
#
|
||||
#
|
||||
for s in kw.strings:
|
||||
xbutton = button = button + 1
|
||||
if isinstance(s, tuple):
|
||||
assert len(s) == 2
|
||||
button = int(s[1])
|
||||
s = s[0]
|
||||
if s is None:
|
||||
continue
|
||||
# accel_indx = s.find('&')
|
||||
s = s.replace('&', '')
|
||||
if button < 0:
|
||||
# b = Tkinter.Button(frame, text=s, state="disabled")
|
||||
button = xbutton
|
||||
else:
|
||||
# b = Tkinter.Button(frame, text=s, default="normal",
|
||||
# command=(lambda self=self,
|
||||
# button=button: self.mDone(button)))
|
||||
b = Button(text=s, size_hint=(1, 1))
|
||||
frame.add_widget(b)
|
||||
# if button == kw.default:
|
||||
# focus = b
|
||||
# focus.config(default="active")
|
||||
# self.buttons.append(b)
|
||||
#
|
||||
# b.config(width=button_width)
|
||||
# if accel_indx >= 0:
|
||||
# key accelerator
|
||||
# b.config(underline=accel_indx)
|
||||
# key = s[accel_indx]
|
||||
# self.accel_keys[key.lower()] = button
|
||||
#
|
||||
# img = None
|
||||
# if self.button_img:
|
||||
# img = self.button_img.get(s)
|
||||
# b.config(compound='left', image=img)
|
||||
column += 1
|
||||
# b.grid(column=column, row=0, sticky="ns", padx=padx, pady=pady)
|
||||
# if focus is not None:
|
||||
# l = (lambda event=None,
|
||||
# selScrollViewf=self, button=kw.default: self.mDone(button))
|
||||
# bind(self.top, "<Return>", l)
|
||||
# bind(self.top, "<KP_Enter>", l)
|
||||
# frame.columnconfigure(0, weight=1)
|
||||
# frame.columnconfigure(99, weight=1)
|
||||
return focus
|
||||
'''
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue