Skip to content

Commit

Permalink
MVP achieved in debug #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCWright committed Nov 30, 2020
1 parent ad7576a commit 3a69969
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 134 deletions.
Binary file modified __pycache__/main.cpython-38-pytest-6.1.1.pyc
Binary file not shown.
Binary file modified bin/BVWSudoku-0.2-arm64-v8a-debug.apk
Binary file not shown.
Binary file added blank_9x9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source.dir = .
source.include_exts = py,png,jpg,kv,atlas

# (list) List of inclusions using pattern matching
#source.include_patterns = *.png
source.include_patterns = *.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec
Expand Down Expand Up @@ -85,7 +85,7 @@ fullscreen = 0
#android.presplash_color = #FFFFFF

# (list) Permissions
android.permissions = INTERNET
android.permissions = WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE

# (int) Target Android API, should be as high as possible.
android.api = 27
Expand All @@ -94,7 +94,7 @@ android.api = 27
#android.minapi = 21

# (int) Android SDK version to use
# android.sdk = 27
android.sdk = 27

# (str) Android NDK version to use
android.ndk = 19c
Expand Down Expand Up @@ -213,7 +213,7 @@ android.accept_sdk_license = True
#android.uses_library =

# (str) Android logcat filters to use
android.logcat_filters = *:S python:D
#android.logcat_filters = *:S python:D

# (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1
Expand Down
9 changes: 5 additions & 4 deletions bvwsudoku.kv
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
id: im
size_hint: 0.9, 0.9
pos_hint: {'center_x': .5, 'center_y': .5}
source: 'blank_9x9.png'
source: 'blank_9x9.jpg'
allow_stretch: True
#:import platform kivy.utils.platform
FileChooserListView:
rootpath: root.SD_CARD if platform == 'android' else '/'
# #:import platform kivy.utils.platform
# FileChooserListView:
# id: fc
# rootpath: root.rootpath if platform == 'android' else '/'
Button:
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint: None, 0.1
Expand Down
83 changes: 0 additions & 83 deletions fred

This file was deleted.

2 changes: 1 addition & 1 deletion images/blank_grids.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="Electron" modified="2020-11-14T12:59:13.778Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.9.5 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36" etag="ZSeNXCyb90k-9wreFgxp" version="13.9.5" type="device"><diagram id="UZlwy3X2oGdAu3hXRvT0" name="9x9">3Z3Lcts4EEW/RsupIvjm1nYem2TjxcxuirFoiRVKUNF0JM3XDxUCshUbbrgqRN9OeWEJol4H4CGv0TQWyfXm8Kmvd+svetl0izhaHhbJzSKOVZTF469Ty3FqKcpkalj17dJs9NRw2/7X2Gea1sd22TxcbDho3Q3t7rLxTm+3zd1w0Vb3vd5fbnavu8t33dWr5kXD7V3dvWz9u10O66m1zKKn9s9Nu1rbd1aReWRT241Nw8O6Xur9s6bkwyK57rUeplubw3XTneBZLtPzPjoePX+wvtkOPk8oOx1FX4t/Nu3N8G+6LdJhk/2lUtMdP+ru0Xxl83GHo2Ww6vXjzmzW9ENzeI18/c1uHr38ZOr8fceB0uhNM/THcRPzQql5xvHy7v6Jd5KbtvUz1ufG2vTx6vzKTxjGG4bEO6jEeQgob3XIS1bPaKj4FRrnxt9Po2CjMXXE+2Gks7EoaRb7dTs0t7v67nR/P2pxkVyth834PjdqvFk/7CZR3beHZnyvq4eh19+ba93p/ucLJFcfTz/jI06gNLiCBJcG5VbJ5vaLqbgwJtEfgbHkxqjgjOY+9oUVXBLLGGGJ45SCbUh5nEchc0MRXPpHYGQXXIYquFfIBBacx7k9xAjLwATnkQKQuaEITkiAIDCyC84jT4RO6Pb1Y0/FzZfYLXYGOlPHACX21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719ZfxRhlaeJGWZZSc5FNFJWXeZAskuut+P8b7tOgtxq7eNLz+/DPHOs735Uv4MAzAIOZWzo5sh1s6D7swKh90MSTYMO/49doZpr3nQnY8KMOhmSLZh0AHssTNk2zDsvJPGfOxmiLNhbAfAbobJryAnKLOiG+/2Wg/PHvs0fu31F71sTlv8Dw==</diagram></mxfile>
<mxfile host="Electron" modified="2020-11-30T10:55:54.902Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.9.9 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36" etag="OVbxTT7KdcuAaeuGCbAO" version="13.9.9" type="device"><diagram id="UZlwy3X2oGdAu3hXRvT0" name="9x9">3Z1dk5pIFIZ/jZdW0fJ9q7P5mKrkxlTt3m2xI6Nk0TaII86vX2YF1Mww6WMdOC+pXERbRHlo3+aZPtoje7YuPmbRdvVFL+J0NLEWxci+G00mynIn5X8vLcdTix/Yp4Zlliyqjc4N8+Q5rp9Zte6TRby72jDXOs2T7XXjg95s4of8qi3KMn243uxRp9evuo2W8auG+UOUvm79M1nkq1NrMPHP7Z/iZLmqX1l54emRdVRvXB3JbhUt9OGiyf5jZM8yrfPTrXUxi9MXeDWX0/M+tDzavLEs3uQmTyhmO0//eH76HN5/+z7eT+8Lfz6u9vIUpfvqgKs3mx9rAstM77fVZnGWx8Vb3KN/6s2t1+9LNUdbdpNYr+M8O5abVDtyqmccr+8ezrT9eqerC9JNY1Sd4WWz5zOE8kbF4W0mQaot66v/1zq5y/92Nr6Tr92xcmwSlctDfReyKb3XqORgTLybWfwCLguNprtc0mga+Wn4vDQaut3BCDpjEfyaxWGV5PF8Gz283D+UI8TInq7ydfk6d6q8Ge22p8x+TIq4fK3pLs/0v/FMpzr7fwf29MPLv/IRU6B+C9B3wQW9cguHza245iOF0bZ+C4zKk+ZIuwToI9KOrT2s34SzJ4BdzG67msBJONvg+gmZG0rCOb8FRvmEc1ET7i00PUecweV9/33MbQEMFHEGI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awlrKCXEyZQg5lJIBcTvkGkAAjAXdhEkO0weg95IrKagBLKivINZUp5GCSDlIeBrissmJfV5kv6QD03mRdZYF+NoBCJchVmCnkUKIOclnmG0DKRx0/x8ckTWuKG72J3wRYzHae/vH89Dm8//Z9vJ/eF/58fJOW9Sz4HXS8PoDh/DpBB17bB0DcH2nswG8lgAquODlogAB/9OxAfSUA4nykOzBiQaAAPbQDMxYcdACAdjC91uNlUKcAy7uZ1vnFYx/Lg1990Yv4ZYv/AA==</diagram></mxfile>
76 changes: 34 additions & 42 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,54 @@


class PrintScreen(BoxLayout):
if platform == 'android':
SD_CARD = primary_external_storage_path()

def build(self):
pass

def print(self):
if platform == 'android':
path = os.path.join(self.SD_CARD,'blank_9x9.png')
# path = os.path.join(self.ids.fc.path, self.ids.fc.selection[0])
path = os.path.abspath(self.ids.im.source)
path = self.copy_to_external_storage(path)
print(f"sharing file path: {path}")
self.share(path)

def copy_to_external_storage(self,path):
if platform == 'android':
Environment = autoclass('android.os.Environment')
rootpath = Environment.getExternalStorageDirectory().getAbsolutePath()
Files = autoclass('java.nio.file.Files')
StandardCopyOption = autoclass('java.nio.file.StandardCopyOption')
File = autoclass('java.io.File')

newpath=os.path.join(rootpath,os.path.basename(path))

Oldpath = File(path).toPath()
Newpath = File(newpath).toPath()

JPath = Files.copy(Oldpath, Newpath, StandardCopyOption.REPLACE_EXISTING)

print(f"Files.copy to newpath: {JPath.toUri().toString()}")
return JPath.toUri()

def share(self,path):
if platform == 'android':
PythonActivity = autoclass('org.kivy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
String = autoclass('java.lang.String')
Uri = autoclass('android.net.Uri')
File = autoclass('java.io.File')
intent = Intent()
intent.setData(Uri.parse(path))
intent.setAction(Intent.ACTION_SEND)
intent.setType('image/png')
chooser = Intent.createChooser(intent, String("Print my stuff"))
PythonActivity.mActivity.startActivity(chooser)
intent.setAction(Intent.ACTION_VIEW)
intent.setType("image/jpg")
uri = Uri.fromFile(File(path))
parcelable = cast('android.os.Parcelable', uri)
intent.putExtra(Intent.EXTRA_STREAM, parcelable)

PythonActivity = autoclass('org.kivy.android.PythonActivity')
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
self.context = cast('android.content.ContextWrapper', currentActivity.getApplicationContext())

if intent.resolveActivity(self.context.getPackageManager()) != None:
currentActivity.startActivity(intent)

class BVWSudoku(App):
def build(self):
Expand All @@ -51,38 +75,6 @@ def build(self):
Permission.READ_EXTERNAL_STORAGE])
return PrintScreen()

# def print_canvas(self, obj):
# # PrintHelper = autoclass('androidx.print.PrintHelper')
# # PrintHelper.printBitmap('jobname','./blank_9x9.png')


# # # Context is a normal java class in the Android API
# # Context = autoclass('android.content.Context')

# # # PythonActivity is provided by the Kivy bootstrap app in python-for-android
# # PythonActivity = autoclass("org.kivy.android.PythonActivity")

# # # The PythonActivity stores a reference to the currently running activity
# # # We need this to access the vibrator service
# # activity = PythonActivity.mActivity

# # # This is almost identical to the java code for the vibrator
# # vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)

# # vibrator.vibrate(500) # The value is in milliseconds - this is 0.5s




if __name__ == '__main__':
BVWSudoku().run()

# Builds with the following:
# p4a apk --private /mnt/c/Users/tcw25/Documents/GitHub/Sudoku/
# --package=com.chdirections
# --name "myapp"
# --version 0.1
# --bootstrap=sdl2
# --requirements=python3,kivy,pyjnius
# --arch=arm64-v8a
# --permission VIBRATE
Binary file removed main.pyc
Binary file not shown.

0 comments on commit 3a69969

Please sign in to comment.