{"id":15533065,"url":"https://github.com/t-dynamos/pyjnius-scripts","last_synced_at":"2025-04-23T13:42:00.758Z","repository":{"id":133879228,"uuid":"610584637","full_name":"T-Dynamos/pyjnius-scripts","owner":"T-Dynamos","description":"A handfull of pyjnius android scripts","archived":false,"fork":false,"pushed_at":"2023-03-07T17:42:00.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T13:41:59.543Z","etag":null,"topics":["android-kivy","kivy","kivy-app","pyjnius","python-for-android"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/T-Dynamos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-07T04:03:46.000Z","updated_at":"2024-08-17T20:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"586f3bea-6de5-47f2-ac3d-75db9e0c0b4c","html_url":"https://github.com/T-Dynamos/pyjnius-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fpyjnius-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fpyjnius-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fpyjnius-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fpyjnius-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T-Dynamos","download_url":"https://codeload.github.com/T-Dynamos/pyjnius-scripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250440825,"owners_count":21431062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-kivy","kivy","kivy-app","pyjnius","python-for-android"],"created_at":"2024-10-02T11:34:29.989Z","updated_at":"2025-04-23T13:42:00.747Z","avatar_url":"https://github.com/T-Dynamos.png","language":null,"readme":"# pyjnius-scripts\n\n## Get App in full screen with status bar and navigation bar transparent\n![Screenshot_20230307_100007](https://user-images.githubusercontent.com/68729523/223321096-da8e35db-cffa-4fb2-b75a-ae96bf1e75bc.png)\n\n*Want somthing like this?*\n\nImport this on top\n\n```python\nfrom android.runnable import run_on_ui_thread\nfrom jnius import autoclass\n```\nAdd this function in your code and call it in `build` function.\n\n```python\n    @run_on_ui_thread\n    def setup_android(self):\n        activity = autoclass(\"org.kivy.android.PythonActivity\").mActivity\n        WindowCompat = autoclass(\"androidx.core.view.WindowCompat\")\n        ViewCompat = autoclass(\"androidx.core.view.ViewCompat\")\n        Color = autoclass(\"android.graphics.Color\")\n        window = activity.getWindow()\n        windowInsetsController = ViewCompat.getWindowInsetsController(\n            window.getDecorView()\n        )\n        windowInsetsController.setAppearanceLightNavigationBars(self.BarMode)\n        windowInsetsController.setAppearanceLightStatusBars(self.BarMode)\n        WindowCompat.setDecorFitsSystemWindows(window, False)\n        window.setNavigationBarColor(Color.TRANSPARENT)\n        window.setStatusBarColor(Color.TRANSPARENT)\n```\n(Here `self.BarMode` is bool. It sets the color of text and icons in staus and navigation bar)\n\n*If you have custom _android.entrypoint_ please replace it with `org.kivy.android.PythonActivity`*\n\nAdd this in _buildozer.spec_:\n```python\nandroid.apptheme = \"@style/AppTheme\"\n```\nNow create a file naming `styles.xml`:\n```xml\n\u003cresources\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"android:Theme.Material.Wallpaper.NoTitleBar\"\u003e\n        \u003citem name=\"android:windowDrawsSystemBarBackgrounds\"\u003etrue\u003c/item\u003e\n        \u003citem name=\"android:enforceNavigationBarContrast\"\u003efalse\u003c/item\u003e\n    \u003c/style\u003e\n\u003c/resources\u003e\n```\nNow when you will compile your app, it will fail.\n\nThen move styles.xml to `.buildozer/android/platform/build-armeabi-v7a/dists/\u003c\u003e/src/main/res/values/styles.xml`(replace \u003c\u003e with you package.name)\n\nNow try compile it, then your app will be in full screen with transparent status and navigation bar\n\n## Get all installed apps with icon and starting intent\n\nThis also requires a permission in android 11+\n\n_buildozer.spec_\n```\nandroid.permissions = QUERY_ALL_PACKAGES\n```\n\nDon't forget to import this on top\n\n```python\nfrom android.runnable import run_on_ui_thread\nfrom jnius import autoclass\n```\n\nset `ANDROID_PATH` in starting of your app class to `/data/data/\u003c\u003e/shared_prefs` (replace \u003c\u003e with package name)\n\n```python\n    @run_on_ui_thread\n    def get_all_apps(self) -\u003e dict:\n        Bitmap = autoclass(\"android.graphics.Bitmap\")\n        Canvas = autoclass(\"android.graphics.Canvas\")\n        Intent = autoclass(\"android.content.Intent\")\n        BitmapConfig = autoclass(\"android.graphics.Bitmap$Config\")\n        File = autoclass(\"java.io.File\")\n        FileOutputStream = autoclass(\"java.io.FileOutputStream\")\n        CompressFormat = autoclass(\"android.graphics.Bitmap$CompressFormat\")\n        activity = autoclass(\"org.kivy.android.PythonActivity\").mActivity\n        intent = Intent(Intent.ACTION_MAIN)\n        PackageManager = activity.getPackageManager()\n        intent.addCategory(Intent.CATEGORY_LAUNCHER)\n\n        InstalledApps = PackageManager.queryIntentActivities(intent, 0)\n        self.AllInstalledApps = {}\n\n        if os.path.isdir(os.path.join(self.ANDROID_PATH, \"icons\")) != True:\n            os.mkdir(os.path.join(self.ANDROID_PATH, \"icons\"))\n\n        for app in InstalledApps:\n            icon_file = os.path.join(\n                self.ANDROID_PATH, \"icons/{}.png\".format(app.activityInfo.packageName)\n            )\n            drawable = app.activityInfo.loadIcon(PackageManager)\n            bitmap = Bitmap.createBitmap(\n                drawable.getIntrinsicWidth(),\n                drawable.getIntrinsicHeight(),\n                BitmapConfig.ARGB_8888,\n            )\n            canvas = Canvas(bitmap)\n            drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight())\n            drawable.draw(canvas)\n            imageFile = File(\n                os.path.join(self.ANDROID_PATH, \"icons/\"),\n                \"{}.png\".format(app.activityInfo.packageName),\n            )\n\n            file_buffer = FileOutputStream(imageFile)\n            bitmap.compress(CompressFormat.PNG, 100, file_buffer)\n            file_buffer.close()\n\n            self.AllInstalledApps[app.loadLabel(PackageManager)] = [\n                app.activityInfo.packageName,\n                icon_file,\n                app.activityInfo.packageName + \"/\" + app.activityInfo.name,\n            ]\n\n        with open(os.path.join(self.ANDROID_PATH, \"apps_installed.json\"), \"w\") as file:\n            json.dump(self.AllInstalledApps, file)\n            file.close()\n        print(self.AllInstalledApps)\n        return self.AllInstalledApps\n\n```\nThis will save icons to icons folder _in shared_prefs_ and print something like:\n```\n03-07 09:53:34.590  3054  3054 I python  : {'Camera': ['com.android.camera2', '/data/data/com.tdynamos.snowflakes/shared_prefs/icons/com.android.camera2.png', 'com.android.camera2/com.android.camera.CameraLauncher'], 'Contacts': ['com.android.contacts', '/data/data/com.tdynamos.snowflakes/shared_prefs/icons/com.android.contacts.png', 'com.android.contacts/com.android.contacts.activities.PeopleActivity'], 'Clock': ['com.android.deskclock', '/data/data/com.tdynamos.snowflakes/shared_prefs/icons/com.android.deskclock.png', 'com.android.deskclock/com.android.deskclock.DeskClock'], 'Gallery': ['com.android.gallery3d', '/data/data/com.tdynamos.snowflakes/shared_prefs/icons/com.android.gallery3d.png', 'com.android.gallery3d/com.android.gallery3d.app.GalleryActivity'], \n```\nNow you can start you app with that last arg using:\n```python\n    @run_on_ui_thread\n    def launch_app(self, root):\n        strings = root.split(\"/\")\n        Intent = autoclass(\"android.content.Intent\")\n        ComponentName = autoclass(\"android.content.ComponentName\")\n        intent = Intent(Intent.ACTION_MAIN)\n        activity = autoclass(\"org.kivy.android.PythonActivity\").mActivity\n        intent.setClassName(strings[0], strings[1])\n        intent.setComponent(ComponentName(strings[0], strings[1]))\n        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)\n        activity.startActivity(intent)\n```\nwhere root is arg[-1] like `com.android.camera2/com.android.camera.CameraLauncher`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-dynamos%2Fpyjnius-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-dynamos%2Fpyjnius-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-dynamos%2Fpyjnius-scripts/lists"}