diff --git a/android/NOTE b/android/NOTE deleted file mode 100644 index b43a5872..00000000 --- a/android/NOTE +++ /dev/null @@ -1,11 +0,0 @@ - - -This android build setup ist out-dated. -Please use the new setup presented in directory -buildozer. - -LB221118. - -This Directory will soon be deleted from the Repo. - -LB230919. diff --git a/android/debian/README b/android/debian/README deleted file mode 100644 index e9db191d..00000000 --- a/android/debian/README +++ /dev/null @@ -1,16 +0,0 @@ -Actions to take upon a freshly installed Debian stretch/xfce (virtualbox). - -Do something like: - -user$ su -- enter root password. - -root$ ./apt-install.sh -- .... some output. - -root$ exit - -Now all required packages are installed to proceed with the -android build. - -LB170709. diff --git a/android/debian/apt-installs.sh b/android/debian/apt-installs.sh deleted file mode 100755 index d1eaf138..00000000 --- a/android/debian/apt-installs.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -set -e - -# install as root - -apt-get install -y \ - git \ - openjdk-8-jdk \ - cython3 \ - python3-pip \ - python3-yaml \ - virtualenv \ - pkg-config \ - automake autoconf libtool \ - zlib1g-dev \ - libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \ - libtinfo5 \ - lld - -update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - -apt-get install -y --no-install-recommends \ - imagemagick \ - python3-tk \ - ccache \ - libltdl-dev - -# set python3 as default. -# make python alternatives selectable. -# (debian stretch, adapt for different versions) - -update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 -update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2 - diff --git a/android/initsdk b/android/initsdk deleted file mode 100755 index f41acda4..00000000 --- a/android/initsdk +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -eux -# This script mimics the instructions laid out in the p4a documentation: -# https://python-for-android.readthedocs.io/en/latest/quickstart/ - -. mkp4a.common - -urlbase=https://dl.google.com/android/repository/ - -if [[ -d $ndkdir ]]; then - echo "Skipping NDK installation: NDK directory already exists." -else - mkdir -p $ndkdir - ndk_zip=android-ndk-${ndkver}-linux-x86_64.zip - [ -a $ndk_zip ] || wget $urlbase/$ndk_zip - unzip -d $(dirname $ndkdir) $ndk_zip -fi - -if [[ -d $sdkdir ]]; then - echo "Skipping SDK installation: SDK directory already exists." -else - mkdir -p $sdkdir - tools_zip=sdk-tools-linux-4333796.zip - [ -a $tools_zip ] || wget $urlbase/$tools_zip - unzip -d $sdkdir $tools_zip - - $sdkdir/tools/bin/sdkmanager 'platforms;android-27' - $sdkdir/tools/bin/sdkmanager 'build-tools;29.0.1' -fi - - diff --git a/android/initsupport b/android/initsupport deleted file mode 100755 index 71877496..00000000 --- a/android/initsupport +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -eux -# Download android support library from maven - -. mkp4a.common - -liburl="https://maven.google.com/com/android/support/support-v4/24.1.1" -libname="support-v4-24.1.1.aar" - -. mkp4a.preload supportlib ${liburl} ${libname} diff --git a/android/main.py b/android/main.py deleted file mode 100755 index c3dac4bd..00000000 --- a/android/main.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# --------------------------------------------------------------------------- -# -# PySol -- a Python Solitaire game -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# --------------------------------------------------------------------------- - -# Starter for kivy/android using buildozer: Needs an explizitly -# named main.py as startpoint. - -import sys -if '--kivy' not in sys.argv: - sys.argv.append('--kivy') - -runmain = True -if runmain: - from pysollib.init import init -init() - -if runmain: - from pysollib.main import main -sys.exit(main(sys.argv)) diff --git a/android/mkcards b/android/mkcards deleted file mode 100755 index d28df654..00000000 --- a/android/mkcards +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -set -eux - -. mkp4a.common - -echo '### prepare cardsets' - -if [ ! -f ${cardsets_file} ]; then - echo '### downloading cardsets' - wget https://netix.dl.sourceforge.net/project/pysolfc/PySolFC-Cardsets/minimal/${cardsets_file} -fi - -if [ ! -d ${cardsets_dir} ]; then - echo '### extracting cardsets' - tar -xf ${cardsets_file} -fi - -echo '### processing cardsets' -( - cd ${cardsets_dir} - ../../scripts/cardconv gif png - for i in cardset-*-png; do - rm -rf `basename $i -png` - done -) - -echo '### end cardsets' diff --git a/android/mkkeystore b/android/mkkeystore deleted file mode 100755 index cbdba26d..00000000 --- a/android/mkkeystore +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -eux - -# memo: -# keytool -genkey -v -keystore my-release-keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 12000 - -mkdir -p bin - -if [ -f ./bin/keystore ]; then - echo "keystore is already defined" -else - keytool -genkey -v -keystore ./bin/keystore -alias python -keyalg RSA -keysize 2048 -validity 12000 -fi diff --git a/android/mkp4a.clean b/android/mkp4a.clean deleted file mode 100755 index c8ea6f26..00000000 --- a/android/mkp4a.clean +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -eux - -rm -rf tmp -python3 -m pythonforandroid.toolchain clean_dists -python3 -m pythonforandroid.toolchain clean_builds -rm -f *.apk -rm -rf PySolFC-Cardsets--Minimal-2.2.0 diff --git a/android/mkp4a.cleanall b/android/mkp4a.cleanall deleted file mode 100755 index ad1d4bdf..00000000 --- a/android/mkp4a.cleanall +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -e - -rm -rf tmp -rm -f *.apk -rm -f *.bz2 -rm -f *.zip -rm -rf PySolFC-Cardsets-2.0 -rm -rf ~/.local/share/python-for-android/packages -rm -rf ~/.local/share/python-for-android/build -rm -rf ~/.local/share/python-for-android/dists -python3 -m pip uninstall python-for-android -y -exit 0 diff --git a/android/mkp4a.common b/android/mkp4a.common deleted file mode 100644 index f4114bbc..00000000 --- a/android/mkp4a.common +++ /dev/null @@ -1,36 +0,0 @@ -# Common constants for various scripts in this directory. - -version=$(PYTHONPATH=.. python3 -c \ - 'from pysollib.settings import VERSION; print(VERSION)') - -tmpdir=${HOME}/.cache/tmp-for-p4a/pysolfc/src - -cardsets_dir='PySolFC-Cardsets--Minimal-2.2.0' -cardsets_file="${cardsets_dir}.tar.xz" - -p4aver="2019.10.6" -ndkver="r19c" - -sdkdir="${HOME}/.cache/sdk-for-p4a/sdk" -ndkdir="${HOME}/.cache/sdk-for-p4a/android-ndk-${ndkver}" -pkgdir="${HOME}/.local/share/python-for-android/packages" - -# gradle may need this. -export TERM="xterm" - -p4a_options="\ - --sdk-dir ${sdkdir} \ - --ndk-dir ${ndkdir} \ - --dist-name pysolfc \ - --name PySolFC \ - --package org.lufebe16.pysolfc \ - --version ${version} \ - --bootstrap sdl2 \ - --requirements python3,attrs,configobj,kivy,pysol-cards,random2,six \ - --private ${tmpdir} \ - --orientation sensor \ - --icon ${tmpdir}/data/images/icons/48x48/pysol.png \ - --presplash ${tmpdir}/data/images/logo-with-margin-1024.png \ - --copy-libs \ - --add-jar ${tmpdir}/support-v4-24.1.1.aar \ - --color always" diff --git a/android/mkp4a.debug b/android/mkp4a.debug deleted file mode 100755 index 25cff219..00000000 --- a/android/mkp4a.debug +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -eux - -. mkp4a.common - -new_options=${p4a_options} -new_options=${new_options/PySolFC/PySolFCdbg} -new_options=${new_options/org.lufebe16.pysolfc/org.lufebe16.pysolfc.dbg} - -python3 -m pythonforandroid.toolchain apk \ - ${new_options} diff --git a/android/mkp4a.init b/android/mkp4a.init deleted file mode 100755 index 1d1ef7ef..00000000 --- a/android/mkp4a.init +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -set -eux - -. mkp4a.common - -# NOTE: $1 will be set with fdroid builds only. - -echo '### prepare sdk' - -if [[ $# == 0 ]] -then - ./initsupport - ./initsdk -fi - -echo '### install p4a' - -if [[ $# == 0 ]] -then - if not python3 -m pip install -q --user "python-for-android==${p4aver}" - then - echo "obviously inside a virtualenv, so omit --user" - if python3 -m pip install -q "python-for-android==${p4aver}" - then - echo "done" - fi - else - echo "done" - fi -fi - -echo '### prepare source' - -(cd .. && make rules && make all_games_html && make mo) - -mkdir -p ${tmpdir} -rm -rf ${tmpdir} -cp -a .. ${tmpdir} -rm -rf ${tmpdir}/android -rm -rf ${tmpdir}/src - -# remove useless load from the app -rm -rf ${tmpdir}/.git -rm -rf ${tmpdir}/.gitignore -rm -rf ${tmpdir}/Screenshots -rm -rf ${tmpdir}/build -rm -rf ${tmpdir}/contrib -rm -rf ${tmpdir}/dist -rm -rf ${tmpdir}/runtests.pl -rm -rf ${tmpdir}/tests -rm -rf ${tmpdir}/Brewfile -rm -rf ${tmpdir}/.appveyor.yml -rm -rf ${tmpdir}/.perltidyrc -rm -rf ${tmpdir}/.travis.yml - -rm -rf ${tmpdir}/setup.py -rm -rf ${tmpdir}/setup_osx.py -rm -rf ${tmpdir}/setup.cfg - -cp -a ${pkgdir}/supportlib/support-v4-24.1.1.aar ${tmpdir} -cp -a main.py ${tmpdir} -mkdir -p ${tmpdir}/data/images/cards/bottoms/trumps-only -echo "" > ${tmpdir}/data/images/cards/bottoms/trumps-only/.keep - -echo '### prepare cardsets' - -./mkcards - -cp -a ${cardsets_dir}/* ${tmpdir}/data - -echo '### end init' diff --git a/android/mkp4a.preload b/android/mkp4a.preload deleted file mode 100755 index 60c6a11c..00000000 --- a/android/mkp4a.preload +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# package preload helper for fdroid build. - -set -eux - -if [[ $# < 3 ]] -then - exit 1 -fi - -packagebase=${HOME}'/.local/share/python-for-android/packages' - -packagedir=${packagebase}/$1 -packageurl=$2 -packagename=$3 -packagemark='.mark-'${packagename} - -if [[ $# == 4 ]] -then - packagemark='.mark'$4 -fi - -mkdir -p ${packagedir} -cd ${packagedir} -if [ ! -f ${packagemark} ] -then - wget -nv ${packageurl}/${packagename} - touch ${packagemark} -fi diff --git a/android/mkp4a.release b/android/mkp4a.release deleted file mode 100755 index 541c92cc..00000000 --- a/android/mkp4a.release +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -set -e - -. mkp4a.common - -pass1="" -pass2="" -keyalias="python" -keystore="${PWD}/bin/keystore" -if [ $1 ]; then - pass1=$1 - pass2=$1 -else - echo "usage: ./mkp4a.release [] [] []" - echo " (use ./mkkeystore to create one in default location)" - exit -fi -if [ $2 ]; then - pass2=$2 -fi -if [ $3 ]; then - keyalias=$3 -fi -if [ $4 ]; then - keystore=$4 -fi - -export P4A_RELEASE_KEYSTORE="$keystore" -export P4A_RELEASE_KEYSTORE_PASSWD="$pass1" -export P4A_RELEASE_KEYALIAS_PASSWD="$pass2" -export P4A_RELEASE_KEYALIAS="$keyalias" - -python3 -m pythonforandroid.toolchain apk \ - ${p4a_options} \ - --release \ - --sign - -# keystore options (instead environment vars): -# -# keystore: --keystore -# key alias --signkey -# keystore passwd --keystorepw -# key passwd --signkeypw diff --git a/android/mkp4a.unsigned b/android/mkp4a.unsigned deleted file mode 100755 index 2c19f66c..00000000 --- a/android/mkp4a.unsigned +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -set -eux - -. mkp4a.common - -# NOTE: $1 and $2 (sdk and ndk) used with fdroid build only. - -if [[ $# == 2 ]] -then - sdkdir=$1 - ndkdir=$2 -fi - -python3 -m pythonforandroid.toolchain apk \ - ${p4a_options} \ - --sdk-dir ${sdkdir} \ - --ndk-dir ${ndkdir} \ - --release - -# python3 -m pythonforandroid.toolchain apk -# ... -# --release #1 -# --sign #2 -# ... -# -# ad 1,2: -# ohne: -> debug version -# 1: -> release unsigned -# 1 und 2: -> release version. diff --git a/android/version.py b/android/version.py deleted file mode 100755 index 483b0b9b..00000000 --- a/android/version.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -# --------------------------------------------------------------------------- -# -# PySol -- a Python Solitaire game -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; see the file COPYING. -# If not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# --------------------------------------------------------------------------- - -# import pychecker.checker - -# Starter for kivy/android using buildozer: Needs an explizitly -# named main.py as startpoint. - -if True: - import sys - sys.path.insert(0, '..') -if True: - from pysollib.settings import VERSION - print(VERSION) diff --git a/buildozer/buildozer.init b/buildozer/buildozer.init index b5548e02..27068ecd 100755 --- a/buildozer/buildozer.init +++ b/buildozer/buildozer.init @@ -28,6 +28,7 @@ echo "" > ${tmpdir}/data/images/cards/bottoms/trumps-only/.keep echo '### prepare cardsets' ./mkcards +./resize4k ${tmpdir}/data/tiles cp -a cardsets/* ${tmpdir}/data diff --git a/buildozer/mkcards b/buildozer/mkcards index b35d97fa..5eee4ef5 100755 --- a/buildozer/mkcards +++ b/buildozer/mkcards @@ -1,5 +1,5 @@ #!/bin/bash -set -eux +#set -eux #loadmode="forge" loadmode="" @@ -58,16 +58,22 @@ else done rm repo -rf - echo '### processing cardsets' + echo '### processing cardsets' - ../../scripts/cardconv gif png - for i in cardset-*-png; do - rm -rf `basename $i -png` - done + ../../scripts/cardconv gif png + for i in cardset-*-png; do + rm -rf `basename $i -png` + done popd fi ln -s ${cardsets_dir} cardsets fi +pushd cardsets + for i in cardset-*; do + ../resizecards $i + done +popd + echo '### end cardsets' diff --git a/buildozer/resize4k b/buildozer/resize4k new file mode 100755 index 00000000..d33826be --- /dev/null +++ b/buildozer/resize4k @@ -0,0 +1,37 @@ +#!/usr/bin/bash + +location='.' +if [ $1 ] +then + location=$1 +fi + +pushd $location + +dir='save-aspect-4k' +if [ -d $dir ] +then + pushd 'save-aspect-4k' + for f in *.jpg + do + echo $f + convert $f -resize 1920x1920 -quality 65 temp_$f + mv -f temp_$f $f + done + popd +fi + +dir='stretch-4k' +if [ -d $dir ] +then + pushd 'stretch-4k' + for f in *.jpg + do + echo $f + convert $f -resize 1920x1920 -quality 65 temp_$f + mv -f temp_$f $f + done + popd +fi + +popd diff --git a/buildozer/resizecards b/buildozer/resizecards new file mode 100755 index 00000000..719b09c8 --- /dev/null +++ b/buildozer/resizecards @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +# -*- mode: python; coding: utf-8; -*- + +import sys +import os +import math + +carddir = "" +filename = "" +maxw = 120 +maxh = 180 + +# arguments: +# 1: cardset directory +# 2: maximum card width +# 3: maximum card height + +if len(sys.argv) < 2: + exit (1) +if len(sys.argv) > 1: + carddir = sys.argv[1] + filename = sys.argv[1]+"/config.txt" +if len(sys.argv) > 2: + maxw = int(sys.argv[2]) +if len(sys.argv) > 3: + maxh = int(sys.argv[3]) + +#print (filename) +#print (carddir) +#print (maxw,"x",maxh) + +# 1: read the config file line by line and extract x,y, xoffset, yoffset. + +lines_list = None +with open(filename, "rt") as f: + lines_list = f.readlines() + lines_list = [line.strip() for line in lines_list] + if not lines_list[0].startswith("PySol"): + exit (1) + +#print (lines_list) + +cardw, cardh, cardd = (int(x) for x in lines_list[2].split()) +xoffs, yoffs, sxoffs, syoffs = (int(x) for x in lines_list[3].split()) + +#print (cardw,cardh) +#print (xoffs,yoffs) + +# 2: calculate scale factor. + +scale = maxw / cardw +scaleh = maxh / cardh +if scaleh < scale: + scale = scaleh + +#print (scale) + +if scale >= 1.0: + exit (0) + +# 3: convert all images to (width)x(height) with imagemagick if needed. + +def img_size(f): + stream = os.popen('identify '+f) + info = stream.read().split() + dims = info[2].split('x') + w = int(dims[0]) + h = int(dims[1]) + return (w,h) + +cardw = int(math.floor(cardw*scale)) +cardh = int(math.floor(cardh*scale)) +xoffs = int(math.ceil(xoffs*scale)) +yoffs = int(math.ceil(yoffs*scale)) +#print (cardw,cardh) +#print (xoffs,yoffs) + +for fn in os.listdir(path=carddir): + file = carddir+'/'+fn + fileo = carddir+'/conv-'+fn + + if fn.endswith('.png') and not fn.startswith('shadow'): + cmd = "convert "+file+" -resize "+str(cardw)+"x"+str(cardh)+" "+fileo + cmd2 = "mv -f "+fileo+" "+file + #print (cmd) + os.system(cmd) + os.system(cmd2) + + if fn.endswith('.png') and fn.startswith('shadow'): + w,h = img_size(file) + if w>h: + w = int(w*scale) + else: + h = int(h*scale) + cmd = "convert "+file+" -resize '"+str(w)+"x"+str(h)+"!' "+fileo + cmd2 = "mv -f "+fileo+" "+file + #print (cmd) + os.system(cmd) + os.system(cmd2) + +# 4: rewrite the config file. + +print ('rescaled by',scale,':',carddir) +lines_list[2] = str(cardw)+" "+str(cardh)+" "+str(cardd) +lines_list[3] = str(xoffs)+" "+str(yoffs)+" "+str(sxoffs)+" "+str(syoffs) +#print (lines_list) + +with open(carddir+"/config.txt", "w") as f: + for l in lines_list: + f.write(l+"\n") diff --git a/fastlane/metadata/android/en-US/changelogs/102122100.txt b/fastlane/metadata/android/en-US/changelogs/102122100.txt index 24e37cdc..69886bec 100644 --- a/fastlane/metadata/android/en-US/changelogs/102122100.txt +++ b/fastlane/metadata/android/en-US/changelogs/102122100.txt @@ -1,11 +1,13 @@ Android specific: -- Temporary screen orientation lock added. Long tap (2.5 seconds) to the - playground locks screen rotation. -- Toolbar: configuration of displayed toolbar buttons added to options menu. +- Temporary screen orientation lock added. Long tap (3 seconds) to the + playground locks screen rotation, pause unlocks. +- Toolbar: configuration of displayed toolbar buttons added to the options menu. - Toolbar: dynamic updates on Toolbar and Options settings. -- Toolbar buttons for 'new deal' and 'restart' have now display a - toast instead of executing immediatley. Tap to the toast accept. +- Toolbar buttons for 'new deal' and 'restart' now display a + toast. Tap to it to accept. - Implementation of full picture hint for the new puzzle type games. +- Background images from the save-aspect folder now are preserving + correct aspect ratio (bug fix). Main version: - consult NEWS.asscidoc or html-src/news.html on github for more change informations. diff --git a/pysollib/kivy/menubar.py b/pysollib/kivy/menubar.py index 6c155a49..76e058d9 100644 --- a/pysollib/kivy/menubar.py +++ b/pysollib/kivy/menubar.py @@ -38,6 +38,7 @@ from pysollib.kivy.LApp import LScrollView from pysollib.kivy.LApp import LTopLevel from pysollib.kivy.LApp import LTreeNode from pysollib.kivy.LApp import LTreeRoot +from pysollib.kivy.androidrot import AndroidScreenRotation from pysollib.kivy.findcarddialog import destroy_find_card_dialog from pysollib.kivy.fullpicturedialog import destroy_full_picture_dialog from pysollib.kivy.selectcardset import SelectCardsetDialogWithPreview @@ -55,7 +56,6 @@ from pysollib.pysoltk import connect_game_full_picture_dialog from pysollib.settings import SELECT_GAME_MENU from pysollib.settings import TITLE - # ************************************************************************ # * tk emuls: # ************************************************************************ @@ -2031,6 +2031,7 @@ class PysolMenubarTk: return self.game.doPause() self.tkopt.pause.set(self.game.pause) + AndroidScreenRotation.unlock() def mOptLanguage(self, *args): if self._cancelDrag(break_pause=False): diff --git a/pysollib/kivy/tkcanvas.py b/pysollib/kivy/tkcanvas.py index 1c4e7c46..174e66ff 100644 --- a/pysollib/kivy/tkcanvas.py +++ b/pysollib/kivy/tkcanvas.py @@ -652,6 +652,10 @@ class MfxCanvas(Widget): hh = r.tex_coords[5] - v w = ww * stepsx h = hh * stepsy + + # move reference point to top left: + v = stepsy - math.floor(stepsy) + r.tex_coords = ( u, v, u + w, v, u + w, v + h, u, v + h ) # noqa def setBackgroundImage(self, event=None):