Skip to content

Instantly share code, notes, and snippets.

View Dirk-Sandberg's full-sized avatar

Erik Sandberg Dirk-Sandberg

  • 3M
  • Minneapolis
View GitHub Profile
@Dirk-Sandberg
Dirk-Sandberg / sign-and-deploy.sh
Last active May 9, 2020 00:19
Automates generating keys and building release apks with buildozer
#!/bin/bash
KEYNAME=$1
KEYPASS=$2
function generate_keys() {
# Make keystores directory if it doesn't exist
if [ ! -d ~/keystores ]; then
mkdir ~/keystores
fi
@Dirk-Sandberg
Dirk-Sandberg / update_buildozer_spec.py
Last active May 8, 2020 15:22
used by sign_and_deploy shell script
import sys
ANDROID_TARGET_API = '28'
ARCH = sys.argv[1]
with open("buildozer.spec", "r") as f:
text = f.readlines()
for i, line in enumerate(text):
if 'android.api' in line:
# Set the minimum target API as required by Google
text[i] = 'android.api = ' + ANDROID_TARGET_API + "\n"
@Dirk-Sandberg
Dirk-Sandberg / main.m snippet
Created December 23, 2019 03:18
How to determine if the top notch exists on iOS with python/kivy/pyobjus
@interface NotchDetector : UIViewController
@end
@implementation NotchDetector
-(id)init {
NSLog(@"initializing NotchDetector");
return self;
}
- (BOOL)hasTopNotch {
if (@available(iOS 13.0, *)) {
@Dirk-Sandberg
Dirk-Sandberg / main.kv
Created December 20, 2019 18:55
How to use a native image chooser in iOS - not perfected, just proof of concept.
BoxLayout:
Button:
text: "hello"
on_release:
app.pick_image()
Button:
text: "update"
on_release:
app.update()
@Dirk-Sandberg
Dirk-Sandberg / Example of kivy-ios push notifications
Last active May 31, 2022 12:23
Most basic example of code needed for push notifications with kivy-ios
# Files are below, this is just to change the name of the gist
@Dirk-Sandberg
Dirk-Sandberg / remove_so_o_files.py
Created June 24, 2019 18:23
Fixes errors shown in this image (https://ibb.co/3y4T1rL) when uploading an App to AppStoreConnect. INSTRUCTIONS: Put this in your kivy-ios folder, then run `python remove_so_o_files.py` to delete all files ending with .so.o from your project. They are not needed and only cause errors with kivy-ios.
from os.path import join, dirname, realpath, exists, isdir, basename, dirname, abspath
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, remove
def remove_junk(d):
exts = [".so.o"]
for root, dirnames, filenames in walk(d):
for fn in filenames:
if any([fn.endswith(ext) for ext in exts]):
print("Removing", join(root,fn))
unlink(join(root, fn))
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
from kivy.garden.mapview import MapView
print("A")
# Animate moving around on a map
kv = """
FloatLayout:
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Expands an element in a grid and adds a widget to it/
kv = """
<AnimatedListTile@FloatLayout>:
canvas.before:
Color:
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Loads an image from the web, changes it's color and angle.
kv = """
<AnimatedImage@AsyncImage>:
color: (1,1,1,1) # Setting color for images works best on white images
color2: (1,0,0,1)
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Makes a widget bounce around the screen
kv = """
<AnimatedMenu@GridLayout>:
cols: 2
spacing: 10,