### Manage Glyph Toy Service Lifecycle (onBind/onUnbind) Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This Java example demonstrates how to manage the lifecycle of a Glyph Toy service. It shows the implementation of `onBind()` to initialize functions when the toy is selected and `onUnbind()` to clean up resources when the toy is deselected. ```Java @Override public IBinder onBind(Intent intent) { init();// Experience that you want to create when Glyph Toy is selected return null; } @Override public boolean onUnbind(Intent intent) { mGM.unInit(); mGM = null; mCallback = null; return false; } ``` -------------------------------- ### Constructing a GlyphMatrixObject in Java Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This Java example demonstrates how to use the `GlyphMatrixObject.Builder` to construct a `GlyphMatrixObject` instance. It shows the chaining of various setter methods like `setImageSource`, `setScale`, `setOrientation`, `setPosition`, and `setReverse` before calling `build()`. ```java GlyphMatrixObject.Builder butterflyBuilder = new GlyphMatrixObject.Builder(); GlyphMatrixObject butterfly = butterflyBuilder .setImageSource(GlyphMatrixUtils.drawableToBitmap(getResources().getDrawable(R.drawable.butterfly))) .setScale(100) .setOrientation(0) .setPosition(0, 0) .setReverse(false) .build(); ``` -------------------------------- ### Java Example: Building and Rendering a GlyphMatrixFrame Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Illustrates how to create a `GlyphMatrixFrame` using its `Builder`, add a `GlyphMatrixObject` (e.g., 'butterfly') to the top layer, and then render the resulting frame to the actual Glyph Matrix using a `GlyphMatrixManager` instance (`mGM`). ```Java GlyphMatrixFrame.Builder frameBuilder = new GlyphMatrixFrame.Builder(); GlyphMatrixFrame frame = frameBuilder.addTop(butterfly).build(); mGM.setMatrixFrame(frame.render()); ``` -------------------------------- ### Register Glyph Toy Services in AndroidManifest.xml Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This XML snippet demonstrates how to register Glyph Toy services within the tag of your AndroidManifest.xml file. It includes two examples: a full configuration with optional metadata (summary, introduction activity, long press, AOD support) and a minimal configuration with only required name and image metadata. Developers must replace placeholder class names and resource references with their own values. ```xml ``` -------------------------------- ### GlyphMatrixObject Public Methods API Reference Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This section details the public methods available for configuring a GlyphMatrixObject. It includes methods for setting various properties like image source, text, position, orientation, brightness, and scale, culminating in the `build()` method to construct the object instance. ```APIDOC GlyphMatrixObject: setImageSource(imagesource: Object): void imagesource: The image source. Must be a 1:1 bitmap - other formats require conversion. Higher resolutions may impact performance. setText(text: String): void text: The string content to be displayed in the Glyph Matrix. setPosition(x: int, y: int): void x: The object's top-left corner x-position on the Glyph Matrix. y: The object's top-left corner y-position on the Glyph Matrix. setOrientation(angle: int): void angle: The object's clockwise rotation angle in degrees, anchored at center. 0 = no rotation (default). Values normalized to 0-360° range. setBrightness(brightness: int): void brightness: The brightness level of the object. Valid range is from 0: LED off - 255 :brightest (default). setScale(scale: int): void scale: The scaling factor for the object. The anchor point is in the middle of the object. Valid range: 0-200. 0: Object is not visible. 100: Original size (default). 200: Double size. build(): GlyphMatrixObject Constructs and returns a GlyphMatrix Object instance based on the current settings. ``` -------------------------------- ### GlyphMatrixObject.Builder Constructor Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Documents the constructor for `GlyphMatrixObject.Builder`, which initializes a new instance. It specifies default values for position, orientation, scale, and brightness if not explicitly set. ```APIDOC GlyphMatrixObject.Builder() Description: If not explicitly set by other methods, the Builder will use the following default values for the GlyphMatrixObject: - Position: (0, 0) - Orientation: 0 degrees - Scale: 100 - Brightness: 255 ``` -------------------------------- ### GlyphMatrixFrame.Builder Layer Addition and Build Methods Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Describes methods for adding `GlyphMatrixObject` instances to specific layers (top, middle, low) within a `GlyphMatrixFrame.Builder`, and the `build()` method for constructing the final `GlyphMatrixFrame` instance. ```APIDOC void addTop(GlyphMatrixObject object) Description: Adds object to top layer, rendered above middle and low layers. void addMid(GlyphMatrixObject object) Description: Adds object to middle layer, rendered between top and low layers. void addLow(GlyphMatrixObject object) Description: Adds object to bottom layer, rendered below top and middle layers. GlyphMatrixFrame build(Context context) Description: Constructs and returns a new GlyphMatrixFrame instance based on the currently accumulated settings. This instance is ready for display or further manipulation. ``` -------------------------------- ### Glyph Matrix Rendering Method Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Documents the `render()` method, which processes previously added objects and integrates them into the Glyph Matrix data. This method can either drive hardware directly or return data for further processing. ```APIDOC int[] render() Description: Renders all objects previously added via the Builder and integrates them into the corresponding Glyph Matrix data. The implementation of this method may vary depending on project requirements. This method can either directly drive hardware to display on an actual Glyph Matrix, or return an array or bitmap data to the caller for further processing. ``` -------------------------------- ### GlyphMatrixFrame.Builder Constructor Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Documents the constructor for `GlyphMatrixFrame.Builder`, which initializes a new instance with a default matrix size of 25x25, ready for configuration. ```APIDOC GlyphMatrixFrame.Builder() Description: Initializes a new Builder instance. This creates an empty GlyphMatrixFrame.Builder ready for configuration. By default, the Matrix size is set to 25x25. ``` -------------------------------- ### GlyphMatrixFrame.Builder Class Definition Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Details the `GlyphMatrixFrame.Builder` static inner class, which uses the Builder pattern to construct and configure `GlyphMatrixFrame` instances. A `GlyphMatrixFrame` defines LED lighting for the matrix and can hold up to 3 `GlyphMatrixObject` instances across different layers. ```APIDOC GlyphMatrixFrame.Builder Description: Static inner class that uses the Builder pattern to construct and configure a GlyphMatrixFrame. This frame is essentially an array of data that defines how each LED on the matrix should light up, and it can be read by the GlyphMatrixManager. Constraints: You can have maximum 3 GlyphMatrixObject for each GlyphMatrixFrame, 1 for each layer before you finally call build() to generate your finished GlyphMatrixFrame instance. ``` -------------------------------- ### GlyphMatrixManager API Reference Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md The `GlyphMatrixManager` class is responsible for connecting to/disconnecting from the underlying service, registering the application, and updating the Glyph Matrix display using raw color data or structured frame objects. ```APIDOC GlyphMatrixManager: Description: Responsible for connecting to and disconnecting from an underlying service or device, registering your application, and updating the display of a Glyph Matrix. Public Methods: init(Callback callback): Return Type: void Description: Used for binding the Service. Recommended to be created when components start. unInit(): Return Type: void Description: Used for unbinding the Service. Recommended to be destroyed when components end. register(String target): Return Type: void Description: Register your app for service. You need to send which target device you are working on. For Phone 3, this should be Glyph.DEVICE_23112. setMatrixFrame(int[] color): Return Type: void Description: Updates the Glyph Matrix display using raw color data. This overload expects a 25x25 integer array. setMatrixFrame(GlyphMatrixFrame): Return Type: void Description: Updates the Glyph Matrix display using a structured GlyphMatrixFrame object. ``` -------------------------------- ### GlyphMatrixObject Accessor Methods Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Lists public accessor methods for `GlyphMatrixObject`, allowing retrieval of its configured properties such as image source, position (X, Y), orientation, scale, and brightness. ```APIDOC Object getImageSource() Description: Returns the image source object. Int getPositionX() Description: Returns the X-coordinate of the object's top-left corner. Int getPositionY() Description: Returns the Y-coordinate of the object's top-left corner. Int getOrientation() Description: Returns the counterclockwise rotation angle of the object from the original (default: 0). Int getScale() Description: Returns the scaling factor of the object. (0-200, default: 100). Int getBrightness() Description: Returns the brightness level of the object. (0-255, default: 255). ``` -------------------------------- ### GlyphMatrixObject.Builder Class Definition Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Describes `GlyphMatrixObject.Builder`, a static inner class used for creating and configuring the display parameters of a `GlyphMatrixObject`. ```APIDOC GlyphMatrixObject.Builder Description: Static inner class of GlyphMatrixObject, used to create and configure an image object's display parameters. ``` -------------------------------- ### Handle Glyph Toy AOD Event Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This Java snippet shows how to handle the `EVENT_AOD` for Glyph Toys configured with Always-On Display (AOD) capability. The `serviceHandler` processes `MSG_GLYPH_TOY` messages and specifically checks for the `EVENT_AOD` to trigger custom actions. ```Java private final Handler serviceHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { switch (msg.what) { case GlyphToy.MSG_GLYPH_TOY: { Bundle bundle = msg.getData(); String event = bundle.getString(GlyphToy.MSG_GLYPH_TOY_DATA); if (GlyphToy.EVENT_AOD.equals(event)) { // Your action for aod } break; } default: super.handleMessage(msg); } } }; ``` -------------------------------- ### Handle Glyph Button 'Change' Event (Long Press) Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md This Java code illustrates how to receive and process the 'Change' event, typically a long press, from a Glyph Button. It involves creating a `Handler` to process messages and a `Messenger` to communicate with the system, returning the `Messenger`'s `IBinder` from `onBind()`. ```Java @Override public IBinder onBind(Intent intent) { init(); return serviceMessenger.getBinder(); } private final Handler serviceHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { switch (msg.what) { case GlyphToy.MSG_GLYPH_TOY: { Bundle bundle = msg.getData(); String event = bundle.getString(GlyphToy.MSG_GLYPH_TOY_DATA); if (GlyphToy.EVENT_CHANGE.equals(event)) { // Your reaction for the long press. } break; } default: super.handleMessage(msg); } } }; private final Messenger serviceMessenger = new Messenger(serviceHandler); ``` -------------------------------- ### GlyphMatrixFrame API Reference Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md The `GlyphMatrixFrame` class handles and displays the Glyph Matrix. It has a default size of 25x25 and can be customized using its Builder. Developers use this class to render GlyphMatrix objects and control layering. ```APIDOC GlyphMatrixFrame: Description: Handles and displays the Glyph Matrix. Default size is 25x25, customizable using the Builder. Developers use this class to render GlyphMatrix objects and control layering. ``` -------------------------------- ### GlyphMatrixObject Class Definition Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md Defines the `GlyphMatrixObject` class, which encapsulates an image or frame for display on the Glyph Matrix. It includes configurable properties like image source, position, rotation, scaling, brightness, and transparency, adjustable via `GlyphMatrixObject.Builder`. ```APIDOC GlyphMatrixObject Description: Encapsulates a single image or frame for display on the Glyph Matrix, along with its configurable properties. Properties: image source, position coordinates (X, Y), clockwise rotation angle, scaling, brightness, and transparency. ``` -------------------------------- ### Add Required Permission to AndroidManifest.xml Source: https://github.com/nothing-developer-programme/glyphmatrix-development-kit/blob/main/README.md To enable the Glyph Matrix functionality and allow the GlyphMatrixSDK to operate correctly, you must declare a specific permission in your AndroidManifest.xml file. This permission grants the necessary access for the SDK. ```XML ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.