android-widgets 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ def hello():
2
+ """
3
+ Simple hello function for testing the package.
4
+ """
5
+ return "Hello from android-widgets!"
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: android-widgets
3
+ Version: 0.1.0
4
+ Summary: A simple hello world package for Kivy Android widgets.
5
+ Author-email: Fabian <fector101@yahoo.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yourusername/kivy-androidwidgets
8
+ Project-URL: Documentation, https://github.com/yourusername/kivy-androidwidgets
9
+ Project-URL: Source, https://github.com/yourusername/kivy-androidwidgets
10
+ Project-URL: Tracker, https://github.com/yourusername/kivy-androidwidgets/issues
11
+ Keywords: kivy,android,widgets,hello-world,python-package
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: Android
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: kivy>=2.0.0
21
+
22
+ Kivy-androidwidgets
23
+ ---
24
+ This repo contains how to create An Android Widget.
25
+ Complete Sample: [working app](https://github.com/Fector101/wallpaper-carousel)
26
+
27
+ 5 Steps For a simple widget
28
+ ---
29
+
30
+ step 1: First you Design How you want the Widget to Look [it's Layout].
31
+ Store it in: `res/layout/simple_widget.xml`
32
+ This a simple widget with a text
33
+ ```xml
34
+ <?xml version="1.0" encoding="utf-8"?>
35
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
36
+ android:orientation="vertical"
37
+ android:padding="10dp"
38
+ android:background="#FFFFFF"
39
+ android:gravity="center"
40
+ android:layout_width="wrap_content"
41
+ android:layout_height="wrap_content">
42
+
43
+ <TextView
44
+ android:id="@+id/widget_text"
45
+ android:text="Loading..."
46
+ android:textSize="18sp"
47
+ android:textColor="#000"
48
+ android:layout_width="wrap_content"
49
+ android:layout_height="wrap_content"/>
50
+
51
+ </LinearLayout>
52
+ ```
53
+ step 2: Create an xml containing the info about the widget.
54
+ Like: size, preview icon and others
55
+ path: `res/xml/widgetproviderinfo.xml`
56
+ ```xml
57
+ <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
58
+ android:minWidth="120dp"
59
+ android:minHeight="60dp"
60
+ android:updatePeriodMillis="1800000"
61
+ android:initialLayout="@layout/simple_widget"
62
+ android:previewImage="@drawable/ic_launcher_foreground"
63
+ android:resizeMode="horizontal|vertical"
64
+ android:widgetCategory="home_screen">
65
+ </appwidget-provider>
66
+ ```
67
+ Create preview image png in right path`res/drawable/ic_launcher_foreground.png`
68
+
69
+ step 3: Create a `AppWidgetProvider` it's used to receive events for widget.
70
+ path: `src/SimpleWidget.java`.
71
+ This will receive an event when widget is add to change it's text
72
+
73
+ ```java
74
+ package org.wally.waller; // Change here from buildozer.spec package.domain+package.name
75
+
76
+ import android.appwidget.AppWidgetManager;
77
+ import android.appwidget.AppWidgetProvider;
78
+ import android.content.Context;
79
+ import android.widget.RemoteViews;
80
+
81
+ import org.wally.waller.R; // Change here from buildozer.spec package.domain+package.name
82
+ import android.app.PendingIntent;
83
+ import android.content.Intent;
84
+
85
+ public class SimpleWidget extends AppWidgetProvider {
86
+
87
+ @Override
88
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
89
+ for (int appWidgetId : appWidgetIds) {
90
+
91
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.simple_widget);
92
+
93
+ // Example: Set text
94
+ views.setTextViewText(R.id.widget_text, "Hello Widget!");
95
+
96
+ // Update widget
97
+ appWidgetManager.updateAppWidget(appWidgetId, views);
98
+ }
99
+ }
100
+ }
101
+ ```
102
+ Step 4: Automate injecting Receiver in XML
103
+
104
+ path:`p4a/hook.py`
105
+
106
+ ```py
107
+ from pathlib import Path
108
+ from pythonforandroid.toolchain import ToolchainCL
109
+
110
+
111
+ def after_apk_build(toolchain: ToolchainCL):
112
+ manifest_file = Path(toolchain._dist.dist_dir) / "src" / "main" / "AndroidManifest.xml"
113
+ text = manifest_file.read_text(encoding="utf-8")
114
+
115
+ package = "org.wally.waller"
116
+ receiver_xml = f'''
117
+ <receiver android:name="{package}.SimpleWidget"
118
+ android:enabled="true"
119
+ android:exported="false">
120
+ <intent-filter>
121
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
122
+ </intent-filter>
123
+ <meta-data android:name="android.appwidget.provider"
124
+ android:resource="@xml/widgetproviderinfo" />
125
+ </receiver>
126
+ '''
127
+
128
+ if receiver_xml.strip() not in text:
129
+ if "</application>" in text:
130
+ text = text.replace("</application>", f"{receiver_xml}\n</application>")
131
+ print("Receiver added")
132
+ else:
133
+ print("Could not find </application> to insert receiver")
134
+ else:
135
+ print("Receiver already exists in manifest")
136
+
137
+ manifest_file.write_text(text, encoding="utf-8")
138
+ print("Successfully_101: Manifest update completed successfully!")
139
+
140
+ ```
141
+ Step 5: From `buildozer.spec` tell it you want to add resources, src and p4a hook
142
+ ```ini
143
+ android.add_resources = res
144
+ android.add_src = src
145
+ p4a.hook = p4a/hook.py
146
+ ```
147
+
148
+ For More widget customisation check: [How to Customise.md](how-to-customise.md)
149
+ ---
150
+
151
+ Sample Image:
152
+
153
+ ![Rounded corners widget](https://raw.githubusercontent.com/Fector101/kivy-androidwidgets/main/imgs/not-rounded.jpg)
@@ -0,0 +1,5 @@
1
+ android-widgets/__init__.py,sha256=WRXI9lN_Tlq-ftohOfB-VEh3XB6F-hpMJYdBDlY-HZc,121
2
+ android_widgets-0.1.0.dist-info/METADATA,sha256=czVholrwp-n36GiAxmMZBd0c2uvP257wP2HOla_eUyw,5288
3
+ android_widgets-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ android_widgets-0.1.0.dist-info/top_level.txt,sha256=O-3FCfvkKVwYHV4lw2MnTOkWhaV4HtQ3NXxkMDU0aS4,16
5
+ android_widgets-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ android-widgets