Beispiel #1
0
    def build(self):
        Logger.setLevel(LOG_LEVELS['debug'])
        self.theme_cls.primary_palette = "Indigo"
        self.theme_cls.accent_palette = "Amber"
        Loader.loading_image = 'images/empty_coverart.png'

        self.nav_layout = Factory.NavLayout()
        self.screen_manager = self.nav_layout.screen_manager
        self.nav_drawer = self.nav_layout.nav_drawer
        self.nav_drawer_list = self.nav_drawer.children[0].ids.nav_drawer_list
        if platform == 'android':
            from android.storage import app_storage_path
            storage_path = app_storage_path()
        else:
            from kivy.core.window import Window
            storage_path = ''
            Window.size = (330, 650)

        songs_path = join(storage_path, 'songs')
        if not os.path.isdir(songs_path):
            os.mkdir(songs_path)
            Logger.info('DIR: created songs directory')
        self.songs_path = songs_path
        images_path = join(storage_path, 'temp')
        if not os.path.isdir(images_path):
            os.mkdir(images_path)
            Logger.info('DIR: created images temp directory')
        self.images_path = images_path

        self.load_first_page()
        Logger.debug('DISPLAY: Loaded first page.')
        if platform == 'android':
            Clock.schedule_once(remove_splash_screen, 1)
        return self.nav_layout
Beispiel #2
0
class options:
    restapi = 8085
    statedir = app_storage_path()
    ipv8 = -1
    libtorrent = -1
    ipv8_bootstrap_override = None
    testnet = False
Beispiel #3
0
    def photo_take(self):
        self.preview_view.performClick()
        context = PythonActivity.mActivity.getApplicationContext()
        dt = datetime.datetime.now()
        today = dt.strftime("%Y_%m_%d")
        name = dt.strftime("%H_%M_%S")
        if self.private:
            file = name + '.jpg'
            dir = join(app_storage_path(), Environment.DIRECTORY_DCIM)
            if not exists(dir):
                mkdir(dir)
            dir = join(dir, today)
            if not exists(dir):
                mkdir(dir)
            self.filepath = join(dir, file)
            self.picfile = File(self.filepath)
            self.icf = ImageCaptureOutputFileOptionsBuilder(
                self.picfile).build()
        else:
            self.cr = PythonActivity.mActivity.getContentResolver()
            collection = MediaStoreImagesMedia.EXTERNAL_CONTENT_URI
            self.cv = ContentValues()
            self.cv.put(MediaStoreMediaColumns.DISPLAY_NAME, name)
            self.cv.put(MediaStoreMediaColumns.MIME_TYPE, "image/jpeg")
            self.cv.put(
                MediaStoreMediaColumns.RELATIVE_PATH,
                join(Environment.DIRECTORY_DCIM, self.app_name(), today))
            self.icf = ImageCaptureOutputFileOptionsBuilder(
                self.cr, collection, self.cv).build()

        self.te = context.getMainExecutor()
        self.wrapper = CallbackWrapper(self.callback)
        self.isc = ImageSavedCallback(self.wrapper)
        self.imageCapture.takePicture(self.icf, self.te, self.isc)
Beispiel #4
0
 def video_start(self):
     if not self.video_is_recording:
         self.preview_view.performClick()
         context = PythonActivity.mActivity.getApplicationContext()
         dt = datetime.datetime.now()
         today = dt.strftime("%Y_%m_%d")
         name = dt.strftime("%H_%M_%S") + '.mp4'
         if self.private:
             dir = join(app_storage_path(), Environment.DIRECTORY_DCIM)
             if not exists(dir):
                 mkdir(dir)
             dir = join(dir, today)
             if not exists(dir):
                 mkdir(dir)
             self.filepath = join(dir, name)
             self.videofile = File(self.filepath)
             self.vcf = VideoCaptureOutputFileOptionsBuilder(
                 self.videofile).build()
         else:
             self.cr = PythonActivity.mActivity.getContentResolver()
             collection = MediaStoreVideoMedia.EXTERNAL_CONTENT_URI
             self.cv = ContentValues()
             self.cv.put(MediaStoreMediaColumns.DISPLAY_NAME, name)
             self.cv.put(MediaStoreMediaColumns.MIME_TYPE, "video/mp4")
             self.cv.put(
                 MediaStoreMediaColumns.RELATIVE_PATH,
                 join(Environment.DIRECTORY_DCIM, self.app_name(), today))
             self.vcf = VideoCaptureOutputFileOptionsBuilder(
                 self.cr, collection, self.cv).build()
         self.te = context.getMainExecutor()
         self.wrapper = CallbackWrapper(self.callback)
         self.vsc = VideoSavedCallback(self.wrapper)
         self.imageCapture.startRecording(self.vcf, self.te, self.vsc)
         self.video_is_recording = not self.video_is_recording
Beispiel #5
0
def getpaths():
    if platform == 'android':
        from android.storage import app_storage_path
        app_storage = app_storage_path()
        from android.storage import primary_external_storage_path
        internal = primary_external_storage_path()
        from android.storage import secondary_external_storage_path
        external = secondary_external_storage_path()
        return app_storage, internal, external
    if platform == 'linux' or platform == 'win':
        internal_storage = str(Path.home())
        return None, internal_storage, None
Beispiel #6
0
def load():
    global db
    db_path = ""
    if platform == "android":
        from android.storage import app_storage_path
        db_path = str(app_storage_path())
    db_path = db_path + "database.sqlite"
    db.bind(provider="sqlite", filename=db_path, create_db=True)
    try:
        db.generate_mapping()
        db.create_tables()
    except Exception as e:
        print(e)
        # corrupted database, attempting to recreate
        db.drop_all_tables(with_all_data=True)
        db.create_tables()
    return db
Beispiel #7
0
    def _create_local_file(self):
        # Create a file for testing
        from android.storage import app_storage_path
        from jnius import autoclass
        from os.path import join, exists
        from os import mkdir

        Environment = autoclass('android.os.Environment')
        path = join(app_storage_path(), Environment.DIRECTORY_DOCUMENTS)
        if not exists(path):
            mkdir(path)
        self.filename = join(path, 'from_space.html')
        with open(self.filename, "w") as f:
            f.write("<html>\n")
            f.write(" <head>\n")
            f.write(" </head>\n")
            f.write(" <body>\n")
            f.write("  <h1>Greetings Earthlings<h1>\n")
            f.write(" </body>\n")
            f.write("</html>\n")
Beispiel #8
0
    def select_zip(self, *args):
        if platform == 'android':

            if check_permission(
                    Permission.WRITE_EXTERNAL_STORAGE
            ) == False:  # check permission takes str not a list
                request_permission(Permission.WRITE_EXTERNAL_STORAGE)
                request_permission(Permission.READ_EXTERNAL_STORAGE)
                request_permission(Permission.MANAGE_EXTERNAL_STORAGE)
                request_permission(Permission.MANAGE_DOCUMENTS)

                #request_permisssion takes str and request_permissions takes list
                return
            self.secondary_ext_storage = secondary_external_storage_path()
            self.primary_ext_storage = primary_external_storage_path()
            self.app_path = app_storage_path()

            Logger.debug(" Storages are \n" + str(self.app_path) + "\n" +
                         str(self.primary_ext_storage))
        else:
            #self.root.ids.status_label.text = " I am not running in android "
            pass
        self.file_manager_open()
Beispiel #9
0
from kivy.utils import platform
import os
import json
from threading import Lock

VERSION = "0.1"

# Get settings folder path

APP_NAME = "pixgrabber"

if platform == "win":
    PATH = os.path.join(os.environ.get("USERPROFILE"), APP_NAME)
elif platform == "android":
    from android.storage import app_storage_path
    PATH = app_storage_path()
else:
    PATH = os.path.join(os.environ.get("HOME"), APP_NAME)

LOG_PATH = os.path.join(PATH, "log.txt")
SETTINGS_PATH = os.path.join(PATH, "settings.json")
DEFAULT_PICTURE_PATH = "Pictures"

_file_lock = Lock()

DEFAULT_SETTINGS = {
    "app_version": VERSION,
    "cookies": {"firefox": True, "chrome": False, "opera": False, "edge": False},
    "proxy": {"enable": False, "ip": "", "port": 0, "username": "", "password": ""},
    "max_connections": 10,
    "connection_timeout": 5,
#!/usr/bin/python3
# coding: utf8
from kivy.app import App
from kivy.factory import Factory
from kivy.logger import Logger
from kivy.storage.jsonstore import JsonStore
from gen_pdf import motifs_courts, generer_pdf
import os.path
from kivy import platform
if platform == 'android':
    from android.permissions import request_permissions, Permission
    from android.storage import primary_external_storage_path, app_storage_path
    data_dir = app_storage_path()
    user_dir = primary_external_storage_path()
else:
    from pathlib import Path
    data_dir = os.path.dirname(os.path.abspath(__file__))
    user_dir = Path.home()
    import locale
    locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')

__version__ = "0.9.9"


class AttgenApp(App):
    data = {
        'nom': '',
        'prenom': '',
        'date_naissance': '',
        'lieu_naissance': '',
        'adresse': '',
Beispiel #11
0
from pathlib import Path
from android.storage import app_storage_path

MUSIC_DIR = Path(app_storage_path()) / 'music'
PLAYLIST_NAME = 'Shuffleupagus'
PLAYLIST_ID = '95f83b1d-1d5d-4626-bcdd-bf3a1a8a0b6e'

USERNAME = "******"
PASSWORD = "******"
Beispiel #12
0
 def download_test_pdf(self):
     self.target = join(app_storage_path(), 'day5.pdf')
     r = requests.get('http://www.planckvacuum.com/pdf/day5.pdf')
     with open(self.target, 'wb') as fd:
         for chunk in r.iter_content(chunk_size=128):
             fd.write(chunk)
Beispiel #13
0
import os, shutil, sys, traceback, logging
try:
    from android.storage import app_storage_path
    settings_path = app_storage_path()
except:
    settings_path = os.path.expanduser('~/.hardlinep2p/')
    drayerDB_root = os.path.expanduser('~/.hardlinep2p/drayerdb')

assetLibPath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'assets')

externalStorageDir = None
try:
    from jnius import autoclass, cast
    PythonActivity = autoclass('org.kivy.android.PythonActivity')

    if PythonActivity and PythonActivity.mActivity:
        context = cast('android.content.Context', PythonActivity.mActivity)
    else:
        PythonActivity = autoclass('org.kivy.android.PythonService')
        context = cast('android.content.Context', PythonActivity.mService)

    Environment = autoclass('android.os.Environment')

    internalDir = context.getExternalFilesDir(None).getAbsolutePath()
    logging.info("Internal App Dir", internalDir)
    r = internalDir

    for i in context.getExternalFilesDirs(None):
        logging.info("Found storage dir:", i)
        p = i.getAbsolutePath()
Beispiel #14
0
MediaSession = autoclass('android.media.session.MediaSession')
MediaStyle = autoclass("androidx.media.app.NotificationCompat$MediaStyle")
NotificationCompatAction = autoclass(
    "androidx.core.app.NotificationCompat$Action")
NotificationCompatBuilder = autoclass(
    "androidx.core.app.NotificationCompat$Builder")
PlaybackStateCompat = autoclass(
    "android.support.v4.media.session.PlaybackStateCompat")
BitmapFactory = autoclass("android.graphics.BitmapFactory")
IconDrawable = autoclass(
    "{}.R$drawable".format("org.allerter.geniustmusicplayer"))
mediaSession = MediaSession(context, "gtplayer music notification")
controller = mediaSession.getController()
mediaMetadata = controller.getMetadata()
icon = getattr(IconDrawable, 'icon')
images_path = os.path.join(app_storage_path(), "temp")


class OSCSever:
    def __init__(self, activity_server_address, port):
        self.song = SoundAndroidPlayer(self.on_complete)
        self.osc = OSCThreadServer()
        self.osc.listen(port=port, default=True)
        self.activity_server_address = activity_server_address
        self.osc.bind(b'/get_pos', self.get_pos)
        self.osc.bind(b'/load', self.load)
        self.osc.bind(b'/play', self.play)
        self.osc.bind(b'/load_play', self.load_play)
        self.osc.bind(b'/seek', self.seek)
        self.osc.bind(b'/play_new_playlist', self.play_next)
        self.osc.bind(b'/set_volume', self.set_volume)