| 1 |
__all__ = ('AlertDialogBuilder', 'DownloadManagerRequest') |
| 2 |
|
| 3 |
from jnius import JavaClass, JavaMethod, JavaMultipleMethod, JavaStaticField, MetaJavaClass |
| 4 |
|
| 5 |
|
| 6 |
class AlertDialogBuilder(JavaClass, metaclass=MetaJavaClass): |
| 7 |
""" |
| 8 |
Represents a builder for creating AlertDialog instances in the Android platform. |
| 9 |
|
| 10 |
This class provides a fluent API for constructing and customizing AlertDialog instances |
| 11 |
with various settings such as title, message, icon, buttons, custom views, and other |
| 12 |
behavioral options. It serves as a wrapper around the native Java AlertDialog.Builder |
| 13 |
implementation, enabling its usage within Python applications interfacing with Android. |
| 14 |
|
| 15 |
Attributes: |
| 16 |
__javaclass__ (str): Specifies the Java class represented by this Python class. |
| 17 |
__javaconstructor__ (list): Defines available constructors in the underlying Java class. |
| 18 |
|
| 19 |
Methods: |
| 20 |
setTitle: Sets the title of the AlertDialog. |
| 21 |
setCustomTitle: Sets a custom view to be used as the title of the AlertDialog. |
| 22 |
setMessage: Specifies the message text for the AlertDialog. |
| 23 |
setIcon: Sets the icon for the AlertDialog. |
| 24 |
setIconAttribute: Sets an attribute as the icon for the AlertDialog. |
| 25 |
setPositiveButton: Sets positive button text and its click listener. |
| 26 |
setNegativeButton: Sets negative button text and its click listener. |
| 27 |
setNeutralButton: Sets neutral button text and its click listener. |
| 28 |
setCancelable: Configures whether the AlertDialog is cancelable or not. |
| 29 |
setOnCancelListener: Sets the cancel listener to invoke when the AlertDialog is canceled. |
| 30 |
setOnDismissListener: Sets a listener for when the AlertDialog is dismissed. |
| 31 |
setOnKeyListener: Sets a key listener for key events within the AlertDialog. |
| 32 |
setItems: Populates the AlertDialog with a list of selectable items. |
| 33 |
setAdapter: Populates the AlertDialog with a list using a custom adapter. |
| 34 |
setCursor: Sets a cursor to define the data to be displayed in the AlertDialog. |
| 35 |
setMultiChoiceItems: Configures multiple choice items and their states for the AlertDialog. |
| 36 |
setSingleChoiceItems: Configures single-choice items and their states for the AlertDialog. |
| 37 |
setView: Sets a custom view to be displayed in the AlertDialog. |
| 38 |
setInverseBackgroundForced: Specifies whether to force the AlertDialog to use an inverse background. |
| 39 |
create: Constructs an AlertDialog instance without displaying it. |
| 40 |
show: Shows the AlertDialog after construction. |
| 41 |
""" |
| 42 |
|
| 43 |
__javaclass__ = 'android/app/AlertDialog$Builder' |
| 44 |
__javaconstructor__ = [ |
| 45 |
('(Landroid/content/Context;)V', False), |
| 46 |
('(Landroid/content/Context;I)V', False), |
| 47 |
] |
| 48 |
setTitle = JavaMultipleMethod( |
| 49 |
[ |
| 50 |
('(I)Landroid/app/AlertDialog$Builder;', False, False), |
| 51 |
('(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;', False, False), |
| 52 |
] |
| 53 |
) |
| 54 |
setCustomTitle = JavaMethod('(Landroid/view/View;)Landroid/app/AlertDialog$Builder;') |
| 55 |
setMessage = JavaMultipleMethod( |
| 56 |
[ |
| 57 |
('(I)Landroid/app/AlertDialog$Builder;', False, False), |
| 58 |
('(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;', False, False), |
| 59 |
] |
| 60 |
) |
| 61 |
setIcon = JavaMultipleMethod( |
| 62 |
[ |
| 63 |
('(I)Landroid/app/AlertDialog$Builder;', False, False), |
| 64 |
( |
| 65 |
'(Landroid/graphics/drawable/Drawable;)Landroid/app/AlertDialog$Builder;', |
| 66 |
False, |
| 67 |
False, |
| 68 |
), |
| 69 |
] |
| 70 |
) |
| 71 |
setIconAttribute = JavaMethod('(I)Landroid/app/AlertDialog$Builder;') |
| 72 |
setPositiveButton = JavaMultipleMethod( |
| 73 |
[ |
| 74 |
( |
| 75 |
'(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;', |
| 76 |
False, |
| 77 |
False, |
| 78 |
), |
| 79 |
( |
| 80 |
'(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)' |
| 81 |
'Landroid/app/AlertDialog$Builder;', |
| 82 |
False, |
| 83 |
False, |
| 84 |
), |
| 85 |
] |
| 86 |
) |
| 87 |
setNegativeButton = JavaMultipleMethod( |
| 88 |
[ |
| 89 |
( |
| 90 |
'(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;', |
| 91 |
False, |
| 92 |
False, |
| 93 |
), |
| 94 |
( |
| 95 |
'(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)' |
| 96 |
'Landroid/app/AlertDialog$Builder;', |
| 97 |
False, |
| 98 |
False, |
| 99 |
), |
| 100 |
] |
| 101 |
) |
| 102 |
setNeutralButton = JavaMultipleMethod( |
| 103 |
[ |
| 104 |
( |
| 105 |
'(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;', |
| 106 |
False, |
| 107 |
False, |
| 108 |
), |
| 109 |
( |
| 110 |
'(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)' |
| 111 |
'Landroid/app/AlertDialog$Builder;', |
| 112 |
False, |
| 113 |
False, |
| 114 |
), |
| 115 |
] |
| 116 |
) |
| 117 |
setCancelable = JavaMethod('(Z)Landroid/app/AlertDialog$Builder;') |
| 118 |
setOnCancelListener = JavaMethod( |
| 119 |
'(Landroid/content/DialogInterface$OnCancelListener;)Landroid/app/AlertDialog$Builder;' |
| 120 |
) |
| 121 |
setOnDismissListener = JavaMethod( |
| 122 |
'(Landroid/content/DialogInterface$OnDismissListener;)Landroid/app/AlertDialog$Builder;' |
| 123 |
) |
| 124 |
setOnKeyListener = JavaMethod( |
| 125 |
'(Landroid/content/DialogInterface$OnKeyListener;)Landroid/app/AlertDialog$Builder;' |
| 126 |
) |
| 127 |
setItems = JavaMultipleMethod( |
| 128 |
[ |
| 129 |
( |
| 130 |
'(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;', |
| 131 |
False, |
| 132 |
False, |
| 133 |
), |
| 134 |
( |
| 135 |
'([Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)' |
| 136 |
'Landroid/app/AlertDialog$Builder;', |
| 137 |
False, |
| 138 |
False, |
| 139 |
), |
| 140 |
] |
| 141 |
) |
| 142 |
setAdapter = JavaMethod( |
| 143 |
'(Landroid/widget/ListAdapter;Landroid/content/DialogInterface$OnClickListener;)' |
| 144 |
'Landroid/app/AlertDialog$Builder;' |
| 145 |
) |
| 146 |
setCursor = JavaMethod( |
| 147 |
'(Landroid/database/Cursor;Landroid/content/DialogInterface$OnClickListener;' |
| 148 |
'Ljava/lang/String;)Landroid/app/AlertDialog$Builder;' |
| 149 |
) |
| 150 |
setMultiChoiceItems = JavaMultipleMethod( |
| 151 |
[ |
| 152 |
( |
| 153 |
'(I[ZLandroid/content/DialogInterface$OnMultiChoiceClickListener;)' |
| 154 |
'Landroid/app/AlertDialog$Builder;', |
| 155 |
False, |
| 156 |
False, |
| 157 |
), |
| 158 |
( |
| 159 |
'([Ljava/lang/CharSequence;[ZLandroid/content/DialogInterface$OnMultiChoiceClickListener;)' |
| 160 |
'Landroid/app/AlertDialog$Builder;', |
| 161 |
False, |
| 162 |
False, |
| 163 |
), |
| 164 |
( |
| 165 |
'(Landroid/database/Cursor;Ljava/lang/String;' |
| 166 |
'Ljava/lang/String;Landroid/content/DialogInterface$OnMultiChoiceClickListener;)' |
| 167 |
'Landroid/app/AlertDialog$Builder;', |
| 168 |
False, |
| 169 |
False, |
| 170 |
), |
| 171 |
] |
| 172 |
) |
| 173 |
setSingleChoiceItems = JavaMultipleMethod( |
| 174 |
[ |
| 175 |
( |
| 176 |
'(IILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;', |
| 177 |
False, |
| 178 |
False, |
| 179 |
), |
| 180 |
( |
| 181 |
'(Landroid/database/Cursor;ILjava/lang/String;Landroid/content/DialogInterface$OnClickListener;)' |
| 182 |
'Landroid/app/AlertDialog$Builder;', |
| 183 |
False, |
| 184 |
False, |
| 185 |
), |
| 186 |
( |
| 187 |
'([Ljava/lang/CharSequence;ILandroid/content/DialogInterface$OnClickListener;)' |
| 188 |
'Landroid/app/AlertDialog$Builder;', |
| 189 |
False, |
| 190 |
False, |
| 191 |
), |
| 192 |
( |
| 193 |
'(Landroid/widget/ListAdapter;ILandroid/content/DialogInterface$OnClickListener;)', |
| 194 |
False, |
| 195 |
False, |
| 196 |
), |
| 197 |
] |
| 198 |
) |
| 199 |
setView = JavaMultipleMethod( |
| 200 |
[ |
| 201 |
('(I)Landroid/app/AlertDialog$Builder;', False, False), |
| 202 |
('(Landroid/view/View;)Landroid/app/AlertDialog$Builder;', False, False), |
| 203 |
] |
| 204 |
) |
| 205 |
setInverseBackgroundForced = JavaMethod('(Z)Landroid/app/AlertDialog$Builder;') |
| 206 |
create = JavaMethod('()Landroid/app/AlertDialog;') |
| 207 |
show = JavaMethod('()Landroid/app/AlertDialog;') |
| 208 |
|
| 209 |
|
| 210 |
class DownloadManagerRequest(JavaClass, metaclass=MetaJavaClass): |
| 211 |
""" |
| 212 |
Represents a request for downloading a file, providing methods to configure |
| 213 |
download behavior and properties. This class is a part of the Android Download |
| 214 |
Manager system, enabling developers to easily handle file downloads in |
| 215 |
background. |
| 216 |
|
| 217 |
The DownloadManagerRequest class allows setting various options for a download |
| 218 |
request, including destination, network restrictions, visibility, and more. It is |
| 219 |
designed to be used as a configuration object passed to the DownloadManager |
| 220 |
to initiate a download task. |
| 221 |
|
| 222 |
Attributes: |
| 223 |
NETWORK_MOBILE: int |
| 224 |
Specifies that downloads are allowed over a mobile network connection. |
| 225 |
NETWORK_WIFI: int |
| 226 |
Specifies that downloads are allowed over a Wi-Fi network connection. |
| 227 |
VISIBILITY_HIDDEN: int |
| 228 |
Visibility state where the download is hidden from the user interface. |
| 229 |
VISIBILITY_VISIBLE: int |
| 230 |
Visibility state where the download is visible in the user interface. |
| 231 |
VISIBILITY_VISIBLE_NOTIFY_COMPLETED: int |
| 232 |
Visibility state where the download's completion will notify the user. |
| 233 |
VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION: int |
| 234 |
Visibility state where only completion of the download notifies the user. |
| 235 |
""" |
| 236 |
|
| 237 |
__javaclass__ = 'android/app/DownloadManager$Request' |
| 238 |
__javaconstructor__ = [('(Landroid/net/Uri;)V', False)] |
| 239 |
NETWORK_MOBILE = JavaStaticField('I') |
| 240 |
NETWORK_WIFI = JavaStaticField('I') |
| 241 |
VISIBILITY_HIDDEN = JavaStaticField('I') |
| 242 |
VISIBILITY_VISIBLE = JavaStaticField('I') |
| 243 |
VISIBILITY_VISIBLE_NOTIFY_COMPLETED = JavaStaticField('I') |
| 244 |
VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION = JavaStaticField('I') |
| 245 |
setDestinationUri = JavaMethod('(Landroid/net/Uri;)Landroid/app/DownloadManager$Request;') |
| 246 |
setDestinationInExternalFilesDir = JavaMethod( |
| 247 |
'(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)' |
| 248 |
'Landroid/app/DownloadManager$Request;' |
| 249 |
) |
| 250 |
setDestinationInExternalPublicDir = JavaMethod( |
| 251 |
'(Ljava/lang/String;Ljava/lang/String;)Landroid/app/DownloadManager$Request;' |
| 252 |
) |
| 253 |
allowScanningByMediaScanner = JavaMethod('()V') |
| 254 |
addRequestHeader = JavaMethod( |
| 255 |
'(Ljava/lang/String;Ljava/lang/String;)Landroid/app/DownloadManager$Request;' |
| 256 |
) |
| 257 |
setTitle = JavaMethod('(Ljava/lang/CharSequence;)Landroid/app/DownloadManager$Request;') |
| 258 |
setDescription = JavaMethod('(Ljava/lang/CharSequence;)Landroid/app/DownloadManager$Request;') |
| 259 |
setMimeType = JavaMethod('(Ljava/lang/String;)Landroid/app/DownloadManager$Request;') |
| 260 |
setShowRunningNotification = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |
| 261 |
setNotificationVisibility = JavaMethod('(I)Landroid/app/DownloadManager$Request;') |
| 262 |
setAllowedNetworkTypes = JavaMethod('(I)Landroid/app/DownloadManager$Request;') |
| 263 |
setAllowedOverRoaming = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |
| 264 |
setAllowedOverMetered = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |
| 265 |
setRequiresDeviceIdle = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |
| 266 |
setRequiresCharging = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |
| 267 |
setVisibleInDownloadsUi = JavaMethod('(Z)Landroid/app/DownloadManager$Request;') |