Skip to content

Commit

Permalink
Print button working with chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCWright committed Nov 28, 2020
1 parent dc44a0c commit ad7576a
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 141 deletions.
Binary file added __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.
File renamed without changes
4 changes: 2 additions & 2 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 = assets/*,images/*.png
#source.include_patterns = *.png

# (list) Source files to exclude (let empty to not exclude anything)
#source.exclude_exts = spec
Expand Down Expand Up @@ -103,7 +103,7 @@ android.ndk = 19c
#android.ndk_api = 21

# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True
android.private_storage = True

# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =
Expand Down
5 changes: 4 additions & 1 deletion bvwsudoku.kv
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
id: im
size_hint: 0.9, 0.9
pos_hint: {'center_x': .5, 'center_y': .5}
source: 'images/blank_9x9.png'
source: 'blank_9x9.png'
allow_stretch: True
#:import platform kivy.utils.platform
FileChooserListView:
rootpath: root.SD_CARD if platform == 'android' else '/'
Button:
pos_hint: {'center_x': .5, 'center_y': .5}
size_hint: None, 0.1
Expand Down
144 changes: 35 additions & 109 deletions debug.xml
Original file line number Diff line number Diff line change
@@ -1,109 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<debug_sources>
<source from="androguard xaml APK">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="8211"
android:versionName="0.1"
android:installLocation="0"
package="com.chdirections"
platformBuildVersionCode="8211"
platformBuildVersionName="0.100000">
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="27" />
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:theme="@android:01030007"
android:label="@7F090000"
android:icon="@7F050001"
android:debuggable="true"
android:allowBackup="true"
android:hardwareAccelerated="true">
<meta-data android:name="wakelock"
android:value="0" />
<activity android:label="@7F090000"
android:name="org.kivy.android.PythonActivity"
android:launchMode="2"
android:screenOrientation="1"
android:configChanges="0x40002FFF">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:authorities="com.chdirections.fileprovider"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@7F0C0000" />
</provider>
<meta-data android:name="android.support.VERSION"
android:value="26.1.0" />
<meta-data android:name="android.arch.lifecycle.VERSION"
android:value="27.0.0-SNAPSHOT" />
</application>
</manifest>
</source>
<source from="/home/surfubu/.local/share/python-for-android/dists/unnamed_dist_1__arm64-v8a/src/main/AndroidManifest.xml">
<!-- <?xml version="1.0" encoding="utf-8"?> -->
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
com.gamemaker.game -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chdirections"
android:versionCode="8211"
android:versionName="0.1"
android:installLocation="auto">
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
android:xlargeScreens="true" />
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="27" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Create a Java class extending SDLActivity and place it in a
directory under src matching the package, e.g.
src/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
An example Java class can be found in README-android.txt -->
<application android:label="@string/app_name"
android:debuggable="true"
android:icon="@drawable/icon"
android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true">
<meta-data android:name="wakelock"
android:value="0" />
<activity android:name="org.kivy.android.PythonActivity"
android:label="@string/app_name"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode|uiMode|screenSize|smallestScreenSize|layoutDirection"
android:screenOrientation="portrait"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="com.chdirections.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
</source>
</debug_sources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="8212"
android:versionName="0.2"
android:installLocation="0"
package="com.chdirections.bvwsudoku">
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="27" />
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:theme="@android:01030006"
android:label="@7F040000"
android:icon="@7F010001"
android:debuggable="true"
android:allowBackup="true"
android:hardwareAccelerated="true">
<meta-data android:name="wakelock"
android:value="0" />
<activity android:label="@7F040000"
android:name="org.kivy.android.PythonActivity"
android:launchMode="2"
android:screenOrientation="4"
android:configChanges="0x40002FFF">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
45 changes: 16 additions & 29 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,44 @@

if platform == 'android':
from android.permissions import Permission, request_permissions
from android.storage import primary_external_storage_path


from jnius import autoclass, cast
from kivy.app import App
from kivy.graphics import Color, Ellipse, Line
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scatter import Scatter
from kivy.uix.widget import Widget


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('images','blank_9x9.png')
path = os.path.join(self.SD_CARD,'blank_9x9.png')
print(f"sharing file path: {path}")
self.share(path)

def share(self,path):
if platform == 'android':
PythonActivity = autoclass('org.kivy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
# String = autoclass('java.lang.String')
String = autoclass('java.lang.String')
Uri = autoclass('android.net.Uri')
File = autoclass('java.io.File')
# FileProvider = autoclass('android.support.v4.content.FileProvider')
Context = autoclass("android.content.Context")
# Environment = autoclass("android.os.Environment")

for c in Context.fileList():
print(f"Context.filelist(): {c}")

print(f"Context.getFilesDir(): {Context.getFilesDir().list()}")


shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.setType('"image/*"')
imageFile = File(path)
uri = Uri.fromFile(imageFile)

# File imagePath = new File(Context.getFilesDir(), "images");
# File newFile = new File(imagePath, "default_image.jpg");
# uri = FileProvider.getUriForFile(Context.getApplicationContext(),"org.test.myapp.fileprovider", imageFile)

parcelable = cast('android.os.Parcelable', uri)
shareIntent.putExtra(Intent.EXTRA_STREAM, parcelable)

currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
currentActivity.startActivity(shareIntent)
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)

class BVWSudoku(App):
def build(self):
Expand Down

0 comments on commit ad7576a

Please sign in to comment.