Skip to content

Some Pyjnius tools for Kivy-Android developments.

License

Notifications You must be signed in to change notification settings

Sahil-pixel/Kvdroid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kvdroid

Some Android tools for Kivy developments

Dependencies

Android min-api21

Requirements

kivy, android, jnius

Installation

pip install kvdroid

Usage

To detect keyboard height

from kvdroid import keyboard_height
print(keyboard_height())

To detect if app is installed from Play Store or not

from kvdroid.appsource import app_source
print(app_source)

To get absolute screen size in dp-pixel and detect current orientation

from kvdroid.metrics import screen
print(screen.orientation())
print(screen.width_dp())
print(screen.height_px())
print(screen.resolution())

To check if device has a data connection both for wifi and cellular

from kvdroid.network import network_state
print(network_state)

To check if device is in dark mode or not

from kvdroid.darkmode import dark_mode
print(dark_mode)

To get device informations. Available options are; 'model','brand','manufacturer','version','sdk','product','base','rom','security','hardware','tags','sdk_int','total_mem','used_mem','avail_ram','total_ram','used_ram','bat_level','bat_capacity','bat_tempeture','bat_voltage','bat_technology'

from kvdroid import device_info
print(device_info("model"))
print(device_info("avail_ram",convert = True))

To enable immersive mode

from kvdroid import immersive_mode
immersive_mode(True) # default is False

To launch a specific app

from kvdroid import launch_app  
launch_app(<app_package>,<app_activity>)

To open target app's details page

from kvdroid import app_details
app_details(<app_package>)

To detect current device's language

from kvdroid.lang import device_lang
print(device_lang)

To set statusbar color

from kvdroid import statusbar_color
statusbar_color("#FFFFFF","black")

To set navigationbar color

from kvdroid import navbar_color
navbar_color("#FFFFFF")

To display a toast message

from kvdroid import toast
toast("hello world")

To get absolute sdcard path

from kvdroid.path import sdcard
print(sdcard)

To get absolute external_sdcard

from kvdroid.path import external_sdcard
print(external_sdcard)

To get path of working app folder

from kvdroid.path import app_folder
print(app_folder)

To get file mime Type

from kvdroid import mime_type
mime_type = mime_type(file_path)
print(mime_type)

To change default wallpaper

from kvdroid import set_wallpaper
set_wallpaper("/sdcard/test.jpg")

To use text-to-speech

from kvdroid import speech
speech("hello world", "en")

To use default Download Manager

from kvdroid import download_manager
download_manager(<title>,<description>,<URL>,<path>,<file>)

To restart the app

from kvdroid import restart_app
restart_app(True) # default is false

To share text via Android Share menu

from kvdroid import share_text
share_text("hello world", title="Share", chooser=False, app_package=None, 
           call_playstore=False, error_msg="application unavailable")

To share any file via Android Share menu

from kvdroid import share_file
share_file(<path-to-file>, <title>, <chooser>, <app-package: open-with-default-app>, 
    <call_playstore>, <error_msg>)
share_file("/sdcard/test.pdf", title='Share', chooser=False, app_package=None, 
           call_playstore=False, error_msg="application unavailable")

To play suported music format or radio stream through Android Media Player player.mPLayer = Android Media PLayer

from kvdroid.audio import player
player.play(<path-to-music-file>)
player.stream(Url) # radio
player.pause()
player.resume()
player.seek(value)
player.do_loop(True) # default is False
player.is_playing()
player.get_duration()
player.current_position()

To cast Java Object

from kvdroid.cast import cast_object
from kvdroid import Uri
uri = Uri.fromFile("/home/java/my_document.pdf")
parcelable = cast_object("parcelable", uri)

# Above code  is same as below code::

from kvdroid.cast import cast_object
from kvdroid import Uri
from jnius import cast
uri = Uri.fromFile("/home/java/my_document.pdf")
parcelable = cast("android.os.Parcelabel", uri)

'''
 the difference is, you dont have to remember the package name, just only the name and 
 you are good to go. This will also be helpful for python devs who do have zero knowledge on java
 
 Note:: 
 not all castable java object are included you can open an issue to include all missing 
 castables
'''

License

MIT

About

Some Pyjnius tools for Kivy-Android developments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%