Skip to content

Commit 46757f0

Browse files
committed
Some cleanup
1 parent dd7ad0c commit 46757f0

File tree

8 files changed

+14
-143
lines changed

8 files changed

+14
-143
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## extension-androidtools
22

3-
![](https://img.shields.io/github/repo-size/MAJigsaw77/extension-androidtools) ![](https://badgen.net/github/open-issues/MAJigsaw77/extension-androidtools) ![](https://badgen.net/badge/license/MIT/green)
3+
![](https://img.shields.io/github/repo-size/LimeExtensions/extension-androidtools) ![](https://badgen.net/github/open-issues/LimeExtensions/extension-androidtools) ![](https://badgen.net/badge/license/MIT/green)
44

55
A Haxe/[Lime](https://lime.openfl.org) extension that incorporates Java functions through [JNI](https://en.m.wikipedia.org/wiki/Java_Native_Interface).
66

@@ -12,7 +12,7 @@ haxelib install extension-androidtools
1212
```
1313
Or through `Git`, if you want the latest updates
1414
```bash
15-
haxelib git extension-androidtools https://github.com/MAJigsaw77/extension-androidtools.git
15+
haxelib git extension-androidtools https://github.com/LimeExtensions/extension-androidtools.git
1616
```
1717

1818
## Licensing

example/project.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://lime.openfl.org/project/1.0.4 http://lime.openfl.org/xsd/project-1.0.4.xsd">
66

7-
<meta title="Extension-IAPCore Test" package="org.openfl.lime.samples.helloworld" version="1.0.0" company="OpenFL" />
7+
<meta title="Extension-AndroidTools Test" package="org.openfl.lime.samples.helloworld" version="1.0.0" company="OpenFL" />
88

9-
<app main="Main" path="export" file="EITest" />
9+
<app main="Main" path="export" file="ATTest" />
1010

1111
<architecture name="arm64" exclude="armv7" if="android" />
1212

extension/androidtools/Tools.hx

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@ import sys.io.Process;
1717
*/
1818
class Tools
1919
{
20-
/**
21-
* Installs a package from a given path.
22-
*
23-
* @param path The path to the package file to install.
24-
* @return true if the installation was successful, false otherwise.
25-
*/
26-
public static function installPackage(path:String):Bool
27-
{
28-
final installPackageJNI:Null<Dynamic> = JNICache.createStaticMethod('org/haxe/extension/Tools', 'installPackage', '(Ljava/lang/String;)Z');
29-
30-
return installPackageJNI != null && !installPackageJNI(path);
31-
}
32-
3320
/**
3421
* Enables app security, restricting access to sensitive data.
3522
* This method may require specific permissions or system-level access.
@@ -137,47 +124,6 @@ class Tools
137124
showNotificationJNI(title, message, channelID, channelName, ID);
138125
}
139126

140-
/**
141-
* Retrieves the dimensions of any screen cutouts (e.g., notch, camera hole).
142-
*
143-
* @return An array of `Rectangle` objects representing the cutout areas.
144-
*/
145-
public static function getCutoutDimensions():Array<Rectangle>
146-
{
147-
final getCutoutDimensionsJNI:Null<Dynamic> = JNICache.createStaticMethod('org/haxe/extension/Tools', 'getCutoutDimensions',
148-
'()[Landroid/graphics/Rect;');
149-
150-
if (getCutoutDimensionsJNI != null)
151-
{
152-
final rectangles:Array<Rectangle> = [];
153-
154-
for (rectangle in cast(getCutoutDimensionsJNI(), Array<Dynamic>))
155-
{
156-
if (rectangle == null)
157-
continue;
158-
159-
final topJNI:Null<JNIMemberField> = JNICache.createMemberField('android/graphics/Rect', 'top', 'I');
160-
final leftJNI:Null<JNIMemberField> = JNICache.createMemberField('android/graphics/Rect', 'left', 'I');
161-
final rightJNI:Null<JNIMemberField> = JNICache.createMemberField('android/graphics/Rect', 'right', 'I');
162-
final bottomJNI:Null<JNIMemberField> = JNICache.createMemberField('android/graphics/Rect', 'bottom', 'I');
163-
164-
if (topJNI != null && leftJNI != null && rightJNI != null && bottomJNI != null)
165-
{
166-
final top:Int = topJNI.get(rectangle);
167-
final left:Int = leftJNI.get(rectangle);
168-
final right:Int = rightJNI.get(rectangle);
169-
final bottom:Int = bottomJNI.get(rectangle);
170-
171-
rectangles.push(new Rectangle(left, top, right - left, bottom - top));
172-
}
173-
}
174-
175-
return rectangles;
176-
}
177-
178-
return [];
179-
}
180-
181127
/**
182128
* Sets the title of the current activity.
183129
*

haxelib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extension-androidtools",
3-
"url": "https://github.com/MAJigsaw77/extension-androidtools",
3+
"url": "https://github.com/LimeExtensions/extension-androidtools",
44
"license": "MIT",
55
"tags": [
66
"android",

project/androidtools/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ repositories
66
google()
77
}
88

9+
tasks.withType(JavaCompile)
10+
{
11+
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
12+
}
13+
914
android
1015
{
1116
namespace 'org.haxe.extension.androidtools'
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
<application>
4-
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
5-
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
6-
</provider>
7-
</application>
8-
</manifest>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />

project/androidtools/src/main/java/org/haxe/extension/Tools.java

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -241,49 +241,6 @@ public void onDismiss(DialogInterface dialog)
241241
}
242242
}
243243

244-
/**
245-
* Installs an application package from the specified path.
246-
*
247-
* @param path The path to the application package (.apk file).
248-
* @return true if the installation was successful, false otherwise.
249-
*/
250-
public static boolean installPackage(final String path)
251-
{
252-
try
253-
{
254-
boolean retVal = true;
255-
256-
if (Build.VERSION.SDK_INT >= 26)
257-
retVal = mainContext.getPackageManager().canRequestPackageInstalls();
258-
259-
final File file = new File(path);
260-
261-
if (file.exists())
262-
{
263-
Intent intent = new Intent(Intent.ACTION_VIEW);
264-
265-
if (Build.VERSION.SDK_INT >= 24)
266-
intent.setDataAndType(FileProvider.getUriForFile(mainContext, packageName + ".provider", file), "application/vnd.android.package-archive");
267-
else
268-
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
269-
270-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
271-
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
272-
mainContext.startActivity(intent);
273-
}
274-
else
275-
Log.e(LOG_TAG, "Attempted to install an application package from " + file.getAbsolutePath() + " but the file doesn't exist.");
276-
277-
return retVal;
278-
}
279-
catch (Exception e)
280-
{
281-
Log.e(LOG_TAG, e.toString());
282-
283-
return false;
284-
}
285-
}
286-
287244
/**
288245
* Enables secure mode for the application window.
289246
*/
@@ -430,6 +387,7 @@ public static boolean isDolbyAtmos()
430387
* @param channelName The name of the notification channel.
431388
* @param ID The ID of the notification.
432389
*/
390+
@SuppressWarnings("deprecation")
433391
public static void showNotification(final String title, final String message, final String channelID, final String channelName, final int ID)
434392
{
435393
mainActivity.runOnUiThread(new Runnable()
@@ -466,36 +424,6 @@ public void run()
466424
});
467425
}
468426

469-
/**
470-
* Retrieves the bounding rectangles for the display cutout (notch) if present.
471-
* Each rectangle represents an area of the display that is obstructed by the cutout.
472-
*
473-
* @return An array of Rect objects representing the bounding rectangles of the display cutout.
474-
* Returns an empty array if there is no cutout or if cutouts are not supported on the device.
475-
*/
476-
public static Rect[] getCutoutDimensions()
477-
{
478-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
479-
{
480-
WindowInsets insets = mainActivity.getWindow().getDecorView().getRootWindowInsets();
481-
482-
if (insets != null)
483-
{
484-
DisplayCutout cutout = insets.getDisplayCutout();
485-
486-
if (cutout != null)
487-
{
488-
List<Rect> boundingRects = cutout.getBoundingRects();
489-
490-
if (boundingRects != null && !boundingRects.isEmpty())
491-
return boundingRects.toArray(new Rect[0]);
492-
}
493-
}
494-
}
495-
496-
return new Rect[0];
497-
}
498-
499427
/**
500428
* Retrieves the application's private files directory.
501429
*
@@ -649,6 +577,7 @@ public static int getStreamVolume(final int streamType)
649577
* @param durationHint The duration of the audio focus request (e.g., AudioManager.AUDIOFOCUS_GAIN).
650578
* @return The result of the audio focus request (e.g., AudioManager.AUDIOFOCUS_REQUEST_GRANTED or AUDIOFOCUS_REQUEST_FAILED).
651579
*/
580+
@SuppressWarnings("deprecation")
652581
public static int requestAudioFocus(final HaxeObject haxeCallbackObject, final int streamType, final int durationHint)
653582
{
654583
try
@@ -681,6 +610,7 @@ public void onAudioFocusChange(int focusChange)
681610
* @param haxeCallbackObject The HaxeObject that was used to request audio focus.
682611
* @return The result of the abandon audio focus request (e.g., AudioManager.AUDIOFOCUS_REQUEST_GRANTED or AUDIOFOCUS_REQUEST_FAILED).
683612
*/
613+
@SuppressWarnings("deprecation")
684614
public static int abandonAudioFocus(final HaxeObject haxeCallbackObject)
685615
{
686616
try

project/androidtools/src/main/res/xml/file_paths.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)