Dynamic skin changing method and device for application program, electronic equipment and medium

By obtaining and replacing the color list of application components, and using interceptors to achieve dynamic application skinning, solving the problem of increasing storage space and security risks in the prior art, and achieving lightweight and efficient skinning operation.

CN119621209APending Publication Date: 2025-03-14BAIDU (CHINA) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411669691.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

When implementing dynamic skinning of applications, the existing technology increases the demand for application storage space and poses security risks. At the same time, adding new skins requires a large number of backgrounds and icons, which has a large amount of changes.

Method used

By obtaining the color list of the new skin and original skin of the component to be resurfacing, replacing it based on the same set of color specifications, using the interceptor to return the replaced color list to realize the skinning operation of the component.

Benefits of technology

It realizes lightweight resource settings, reduces application storage space requirements, reduces security risks, and simplifies skin maintenance and update processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621209A_ABST
    Figure CN119621209A_ABST
Patent Text Reader

Abstract

The invention provides an application program dynamic skin changing method and device, electronic equipment, a computer readable storage medium and a computer program product, and relates to the field of computers, in particular to the technical field of data processing. According to the implementation scheme, a first color list corresponding to new skin of a to-be-skin-changed component in an application program is obtained, wherein the first color list comprises object names and color identifiers of one or more objects in the to-be-skin-changed component; acquiring a second color list corresponding to the original skin of the component to be subjected to skin changing through the interceptor; according to the color identifiers corresponding to the object names in the first color list, replacing the color identifiers corresponding to the corresponding object names in the second color list; and returning the replaced second color list to the component to be subjected to skin replacement through the interceptor so as to realize the skin replacement operation of the component to be subjected to skin replacement. The original skin and the new skin are both formed based on the same set of color specifications, and each color in the set of colors has a corresponding color identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computers, and in particular to the field of data processing technology, and specifically to a method, device, electronic device, computer-readable storage medium, and computer program product for dynamically changing the skin of an application program. Background Art

[0002] User experience is an important factor in measuring the quality of an APP (i.e., application program), and skinning is an important part of improving user experience. Skinning includes but is not limited to APP actively changing themes (such as changing holiday themes according to holidays such as the Spring Festival, Christmas, and New Year's Day), partial page skinning (switching between daytime and nighttime modes, adjusting the font color of reading pages), and editing of APP user-defined skins.

[0003] During the project development process, front-end developers often encounter the need to switch between different themes. Nowadays, in order to increase the market share of software and provide users with a better experience, more and more manufacturers have added skin or theme functions to their software. Summary of the invention

[0004] The present disclosure provides a method, device, electronic device, computer-readable storage medium and computer program product for dynamically changing the skin of an application program.

[0005] According to one aspect of the present disclosure, a method for dynamically reskinning an application program is provided, comprising: obtaining a first color list corresponding to a new skin of a component to be reskinned in the application program, the first color list comprising object names of one or more objects in the component to be reskinned, and color identifiers corresponding to the one or more objects respectively; obtaining a second color list corresponding to an original skin of the component to be reskinned through an interceptor, the second color list comprising object names of the one or more objects, and color identifiers corresponding to the one or more objects respectively, wherein the original skin and the new skin are formed based on the same set of color specifications; replacing the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list; and returning the replaced second color list to the component to be reskinned through the interceptor to implement the skinning operation of the component to be reskinned.

[0006] According to another aspect of the present disclosure, a device for dynamically reskinning an application program is provided, comprising: a first acquisition unit, configured to acquire a first color list corresponding to a new skin of a component to be reskinned in the application program, the first color list comprising object names of one or more objects in the component to be reskinned, and color identifiers corresponding to the one or more objects respectively; a second acquisition unit, configured to acquire a second color list corresponding to an original skin of the component to be reskinned through an interceptor, the second color list comprising object names of the one or more objects, and color identifiers corresponding to the one or more objects respectively, wherein the original skin and the new skin are formed based on the same set of color specifications; a replacement unit, configured to replace the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list; and a rendering unit, configured to return the replaced second color list to the component to be reskinned through the interceptor, so as to implement the skinning operation of the component to be reskinned.

[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described in the present disclosure.

[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided. The computer instructions are used to cause a computer to execute the method described in the present disclosure.

[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements the method described in the present disclosure when executed by a processor.

[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings exemplarily illustrate the embodiments and constitute a part of the specification, and together with the text description of the specification, are used to explain the exemplary implementation of the embodiments. The embodiments shown are for illustrative purposes only and do not limit the scope of the claims. In all drawings, the same reference numerals refer to similar but not necessarily identical elements.

[0012] Figure 1 A schematic diagram showing an exemplary system in which the various methods described herein may be implemented according to an embodiment of the present disclosure;

[0013] Figure 2 A flowchart of a method for dynamically changing the skin of an application program according to an embodiment of the present disclosure is shown;

[0014] Figure 3 A structural block diagram of a device for dynamically changing the skin of an application according to an embodiment of the present disclosure is shown; and

[0015] Figure 4 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0016] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0017] In the present disclosure, unless otherwise specified, the use of the terms "first", "second", etc. to describe various elements is not intended to limit the positional relationship, timing relationship, or importance relationship of these elements, and such terms are only used to distinguish one element from another element. In some examples, the first element and the second element may refer to the same instance of the element, and in some cases, based on the description of the context, they may also refer to different instances.

[0018] The terms used in the description of various examples in this disclosure are only for the purpose of describing specific examples and are not intended to be limiting. Unless the context clearly indicates otherwise, if the number of elements is not specifically limited, the element can be one or more. In addition, the term "and / or" used in this disclosure covers any one of the listed items and all possible combinations.

[0019] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.

[0020] Figure 1 FIG. 1 is a schematic diagram of an exemplary system 100 in which various methods and apparatuses described herein may be implemented according to an embodiment of the present disclosure. Figure 1 , the system 100 includes one or more client devices 101, 102, 103, 104, 105, and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105, and 106 may be configured to execute one or more applications.

[0021] In an embodiment of the present disclosure, the server 120 may run one or more services or software applications that enable the method of dynamic skinning of an application program to be performed.

[0022] In some embodiments, server 120 may also provide other services or software applications, which may include non-virtualized environments and virtualized environments. In some embodiments, these services may be provided as web-based services or cloud services, such as provided to users of client devices 101, 102, 103, 104, 105, and / or 106 under a software as a service (SaaS) model.

[0023] exist Figure 1 In the configuration shown, the server 120 may include one or more components that implement the functions performed by the server 120. These components may include software components, hardware components, or a combination thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 may in turn utilize one or more client applications to interact with the server 120 to utilize the services provided by these components. It should be understood that a variety of different system configurations are possible, which may differ from the system 100. Therefore, Figure 1 is one example of a system for implementing the various methods described herein and is not intended to be limiting.

[0024] The user can use client devices 101, 102, 103, 104, 105 and / or 106 to select a new skin to be replaced, etc. The client device can provide an interface that enables the user of the client device to interact with the client device. The client device can also output information to the user via the interface. Figure 1 Only six client devices are depicted, but one skilled in the art will appreciate that the present disclosure may support any number of client devices.

[0025] Client devices 101, 102, 103, 104, 105 and / or 106 may include various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, game systems, thin clients, various messaging devices, sensors or other sensing devices, etc. These computer devices may run various types and versions of software applications and operating systems, such as MICROSOFT Windows, APPLE iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as GOOGLE Chrome OS); or include various mobile operating systems, such as MICROSOFT Windows Mobile OS, iOS, Windows Phone, Android. Portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Game systems may include various handheld game devices, Internet-enabled game devices, etc. Client devices are capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.

[0026] The network 110 may be any type of network known to those skilled in the art that may support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more networks 110 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.

[0027] Server 120 may include one or more general purpose computers, dedicated server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running virtual operating systems, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that may be virtualized to maintain a server's virtual storage device). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.

[0028] The computing units in the server 120 may run one or more operating systems including any of the above operating systems and any commercially available server operating systems. The server 120 may also run any of a variety of additional server applications and / or middle-tier applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.

[0029] In some implementations, server 120 may include one or more applications to analyze and consolidate data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.

[0030] In some embodiments, the server 120 may be a server of a distributed system, or a server combined with a blockchain. The server 120 may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in a cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.

[0031] The system 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as color. The databases 130 may reside in various locations. For example, the database used by the server 120 may be local to the server 120, or may be remote from the server 120 and may communicate with the server 120 via a network-based or dedicated connection. The databases 130 may be of different types. In some embodiments, the databases used by the server 120 may be, for example, relational databases. One or more of these databases may store, update, and retrieve data to and from the databases in response to commands.

[0032] In some embodiments, one or more of the databases 130 may also be used by applications to store application data. The databases used by the applications may be different types of databases, such as a key-value store, an object store, or a conventional store backed by a file system.

[0033] Figure 1 The system 100 may be configured and operated in various ways to enable the application of various methods and apparatuses described in the present disclosure.

[0034] Front-end skinning refers to the process of changing the style of a web page to achieve different themes or skin effects in front-end development. Through skinning, you can change the color, font, background and other styles of a web page to suit different user preferences or to meet specific design requirements.

[0035] Dynamic skinning refers to the use of front-end technologies such as JavaScript to dynamically change the style of a web page after it is loaded. Dynamic skinning is usually achieved using CSS variables, JavaScript frameworks, or other technologies. Through dynamic skinning, the style of a web page can be changed in real time based on user selection or other conditions, achieving a more flexible skinning effect. The characteristic of dynamic skinning is that it can achieve instant style switching, but it may require more code and complex logic to achieve.

[0036] In the Android system, skinning usually requires replacing the colors of all background, icon and other elements. To achieve dynamic skinning, it is necessary not only to replace the above elements, but also to save these elements locally through various means so that the application can obtain these elements and complete the dynamic skinning. For example, multiple sets of elements need to be pre-added in the code, and the user selects one set of elements to change the skin. For example, use a plug-in to package multiple sets of elements into an Android application package (apk) and place it in the mobile phone storage space. Dynamic skinning in the Android system is very common, but there are always some limitations. First of all, to add a new skin, not only the color needs to be changed, but also a set of background and icon needs to be added, which is a large amount of changes; and these elements need to be stored locally, which not only increases the application storage space, but also has certain security risks.

[0037] Therefore, according to an embodiment of the present disclosure, a method for dynamically changing the skin of an application is provided. Figure 2 A flowchart of a method for dynamically changing the skin of an application program according to an embodiment of the present disclosure is shown. Figure 2As shown, it includes: obtaining a first color list corresponding to a new skin of a component to be skinned in an application, the first color list including object names of one or more objects in the component to be skinned, and color identifiers corresponding to the one or more objects (step 210); obtaining a second color list corresponding to an original skin of the component to be skinned through an interceptor, the second color list including object names of the one or more objects, and color identifiers corresponding to the one or more objects, wherein the original skin and the new skin are formed based on the same set of color specifications (step 220); replacing the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list (step 230); and returning the replaced second color list to the component to be skinned through the interceptor to implement the skinning operation of the component to be skinned (step 240).

[0038] According to the embodiments of the present disclosure, dynamic skinning can be achieved through lightweight resource settings, with a small amount of data, reduced application storage space, and easy maintenance.

[0039] In the present disclosure, a set of color specifications is preset, that is, the original skin and the new skin are formed based on the same set of color specifications, so as to ensure that each color used in the application has a corresponding color identifier. That is, the same color identifier in the original skin and the new skin is used to represent the same color. The components in the application are implemented based on the new and old skins based on the color specifications.

[0040] According to some embodiments, the color identifier includes at least one of the following items: a color code, a color value, and a color name. For example, for black, the color name is black, the color value is RGB (0, 0, 0), and the hexadecimal color code is #000000; for red, the color name is red, the color value is RGB (255, 0, 0), and the hexadecimal color code is #FF0000.

[0041] In some embodiments, the resources of the new skin corresponding to the component to be skinned can be directly placed in the cloud, so that when the component to be skinned is dynamically skinned, the skin resources can be directly obtained from the cloud, which improves data security. In addition, it can also be stored in the local private directory where the application is installed, which is not limited here.

[0042] According to some embodiments, the component to be skinned includes at least one of the following items: text, picture and icon.

[0043] In some examples, the component to be skinned includes a picture, wherein in order to realize dynamic skinning, the picture is usually not a picture of the type of png / jpg / jepg / webp, but a picture of the type of vector graphics, etc. Vector graphics, also known as object-oriented images or drawing images, are mathematically defined as a series of lines connected by points. The graphic elements in a vector file are called objects. Each object is a self-contained entity with properties such as color, shape, outline, size, and screen position. Vector graphics can be filled with colors freely and conveniently. In addition, when creating the vector graphics, the colors used all use a set of colors preset in advance to facilitate color replacement.

[0044] In the Android system, each displayed element is a View, which is the basic component for displaying the user interface. View is the accumulation of all controls (i.e. components) in Android. Whether it is a simple ImageView (image component), TextView (text component) or a complex ListView (list component), they all have a common base class, which is View. View is an abstraction of the space of an interface layer, which represents a control. The ViewGroup (view container component) in the Android system also inherits View, which means that View itself can be a single control or a group of controls composed of multiple controls.

[0045] Therefore, in some embodiments, the component to be skinned may be a View. However, it is understandable that the skinning component may also be other possible application modules, which is not limited here.

[0046] In the present disclosure, an interceptor is a software design pattern used to intercept or intercept specific operations or events during program execution. It can perform customized processing before, after, or instead of the operation itself. For example, when registering and configuring an interceptor, you can specify which requests to intercept through the addPathPatterns() method; you can also specify which requests not to intercept through excludePathPatterns(), such as user login verification, which is expected to be effective for all paths except login. For example, the interceptor intercepts and modifies data in the process of sending requests and receiving responses. Interceptors can be used for various purposes, including modifying response data to cached data.

[0047] For example, in the interceptor object, implement the request and response interceptor functions. The request interceptor function is called before sending the request, and the response interceptor function is called after receiving the response. In the request interceptor function, you can modify the request or add additional information, such as adding request header information, modifying request parameters, etc. In the response interceptor function, you can modify or process the response. If you need to modify the response data to cached data, you can cache the data in the interceptor and replace the response data with the cached data.

[0048] In some examples, when the component to be skinned displays text, background, pictures and other information, an interceptor is first obtained to intercept the place in the Android system where the color of each element is set, providing a replacement node for subsequent skinning.

[0049] In the embodiment of the present disclosure, the color information of the component to be skinned is obtained through the interceptor, and the replaced color information is returned to the color user through the interceptor. Thus, the skinning operation can be completed using only such lightweight data.

[0050] According to some embodiments, the component to be skinned displays different colors or color combinations in different states. The first color list and the second color list include the object names and corresponding color identifiers or color identifier combinations of the one or more objects of the component to be skinned in different states. Replacing the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list includes: replacing the color identifiers or color identifier combinations corresponding to the corresponding object names in each state of the component to be skinned in the second color list according to the color identifiers corresponding to the object names in different states in the first color list.

[0051] According to some embodiments, the color of the original skin is implemented based on a color state list. Obtaining the second color list corresponding to the original skin of the component to be skinned through an interceptor includes: in response to determining that the color state list is defined based on a selector element, traversing the colors corresponding to the component to be skinned in each state corresponding to the color state list to obtain the second color list.

[0052] In this disclosure, ColorStateList is a class used to define color states in Android development, and is used to define resources for color values ​​in different states. It allows developers to define different colors for different view states, thereby applying different colors according to the current state of the view. It can define color values ​​corresponding to different states, such as normal state, pressed state, selected state, etc. ColorStateList can be used to display different colors in different states. It actually changes the color according to the state of the View object to which it is applied. Using Colorstatelistist can greatly improve the user experience of the application because it can dynamically change the color according to the current state of the view, thereby providing richer visual effects.

[0053] In some examples, a color state list Colorstatelist can be described in an XML file. Colorstatelist can be defined in an XML layout file and then applied to a background or other objects. In some examples, when different colors can be displayed in different states through ColorStateList, each color can be displayed in <selector>Inside the element <item>element. Each <item>Use different attributes to describe the state in which it is used.

[0054] Specifically, the color state list ColorStateList is obtained by <selector>Elements are defined, and the color of each state is in <item>Specified in the element. <item>An element can use different attributes to describe the state in which it is used, as follows:

[0055] <? xml version="1.0" encoding="utf-8"? >

[0056] <selector xmlns:android="http: / / schemas.android.com / apk / res / android">

[0057] <item android:state_pressed="true"android:color="#ffff0000" / > <!-- Pressed State -->

[0058] <item android:state_focused="true"android:color="#ff0000ff" / > <!--Focus Status-->

[0059] <item android:color="#ff000000" / > <!--Default State-->

[0060] < / item> < / item> < / selector>

[0061] In the above example, when the component's button is in the pressed state, its color will change to red (#ffff0000); when the button is in the focused state, its color will change to blue (#ff0000ff); in other states, its color will be black (#ff000000).

[0062] In the Android system, the color acquisition will eventually get the Colorstatelist first. Therefore, when replacing the color, first determine whether the color of the View object corresponds to multiple states (such as based on <selector>element) still has only a single state.

[0063] Among them, for colors corresponding to multiple states, after obtaining the original Colorstatelist corresponding to the component to be skinned, the color list in the Colorstatelist is traversed to obtain the original color and the object name corresponding to the original color, so as to obtain the new color based on the object name. After obtaining all the new colors, the latest Colorstatelist is created with the latest color list and returned to the color user through the interceptor.

[0064] Among them, for colors with only a single state, it corresponds to a color or color combination. After obtaining the original Colorstatelist, you only need to obtain the original color in the Colorstatelist. After obtaining the latest color, use the latest color to create a new Colorstatelist and use the color returned by the interceptor.

[0065] In the Android system, when obtaining the second color list corresponding to the original skin of the component to be skinned, the information of the component to be skinned can be obtained into a Drawable. Drawable is an abstract class, which is an object used to draw graphics, colors, bitmaps, etc. It can be used as the background, foreground, or as a picture source for ImageView. Drawable provides a drawable object for defining different shapes and styles, which can be created, operated, and displayed through XML or code to achieve colorful interface effects. It can be a picture, shape, graphic, etc. Different Drawables can be displayed in different states by setting different states. In some examples, ColorStateList is a special form of Drawable, which is used to define color values ​​in different states.

[0066] It is understandable that the acquisition of image data such as background in the Android system will first obtain Drawable. Since the images in the code are usually XML type images, the Drawable has color when it is created, so you only need to change the color to become a skinned Drawable.

[0067] Therefore, in some embodiments, obtaining the second color list corresponding to the original skin of the component to be skinned may include: based on the obtained Drawable of the component to be skinned, further obtaining its corresponding color information, so as to obtain the second color list.

[0068] In some examples, after obtaining a Drawable, the type of the Drawable can be further determined, and a new Drawable can be copied to ensure that the color change does not affect the original default Drawable, so that the color of the copied Drawable is replaced.

[0069] According to some embodiments, the color of the original skin is implemented based on a Drawable object, and wherein obtaining a second color list corresponding to the original skin of the component to be skinned through an interceptor includes: in response to determining that the Drawable object is a GradientDrawable type or a ShapeDrawable type, obtaining a group of colors corresponding to the component to be skinned and traversing to obtain the second color list.

[0070] In this disclosure, GradientDrawable is a class in Android development that is used to create and draw customizable gradient shapes. GradientDrawable can be used to draw various shapes, such as rectangles, circles, ellipses, etc., and can set attributes such as gradient colors, borders, and rounded corners. It provides a rich gradient effect, including linear gradients, radial gradients, and sweep gradients. ShapeDrawable is an important class in Android development. It belongs to the Drawable object and is used to draw basic shapes. ShapeDrawable can set attributes such as color, borders, and rounded corners. It is a commonly used drawing method in Android. ShapeDrawable can be defined through an XML file. The file is usually located in the res / drawable / directory, and the file name is used as a resource ID. Used in the XML file <shape>Elements are used to define shapes and to set properties such as color, gradient, border, and rounded corners.

[0071] Specifically, if it is determined to be a GradientDrawable or ShapeDrawable type, after obtaining the Drawable object, a set of colors corresponding to the Drawable object is traversed to obtain the original color to a colors or color object. After obtaining the colors or color object of the new color, the colors or color object of the original color in the Drawable object is replaced with the colors or color object of the new color, and finally the GradientDrawable or ShapeDrawable with the replaced color is returned to the Drawable user through the interceptor.

[0072] According to some embodiments, the color of the original skin is implemented based on a Drawable object, and wherein obtaining a second color list corresponding to the original skin of the component to be skinned through an interceptor includes: in response to determining that the Drawable object is a vector image VectorDrawable type, obtaining each path node corresponding to the vector image; and for each path node, obtaining the color in the path node to obtain the second color list.

[0073] Specifically, if it is a VectorDrawable vector type, parse the VectorDrawable to obtain the path nodes inside it, which is usually achieved through reflection or access to internal APIs. Then, get the fill color, line color, etc. in each path node. If the fill color or line color is a gradient color type, after getting the color list, replace the original list with the new color list. If the fill color or line color is a solid color type, you need to get the resource id of VectorDrawable to get the original color value. For example, the replaced color list can be notified to the corresponding path node object of the native layer (ie, local service) through mNativePtr (the address of the path node in the native layer), so as to update the color value stored in the native. Thus, the skinned Drawable is obtained.

[0074] According to some embodiments, the color of the original skin is implemented based on a Drawable object, and wherein obtaining a second color list corresponding to the original skin of the component to be skinned through an interceptor includes: in response to determining that the Drawable object is any one of the StateListDrawable type, LayerDrawable type, ScaleDrawable and ClipDrawable type, traversing a group of child Drawable objects corresponding to the Drawable object to obtain the corresponding colors of each of the group of child Drawable objects; and obtaining the second color list based on the corresponding colors of each of the group of child Drawable objects.

[0075] StateListDrawable is a commonly used drawable object (Drawable) in Android system development. It allows developers to display different images or colors according to the different states of components (such as Button, EditText, etc.). StateListDrawable is a resource defined in XML, which contains a set of <item>element, each <item>Each element defines a specific state and the drawable that should be displayed in that state. When the state of a component changes, StateListDrawable automatically selects and displays the drawable that matches the current state. In Android, StateListDrawable is a resource that displays different Drawables based on the different states of a component.

[0076] LayerDrawable is an important Drawable type in Android graphics development. It allows developers to overlay multiple Drawable objects in a specified order to create complex graphics effects. LayerDrawable is a Drawable that can manage a group of Drawable objects. These Drawable objects are drawn in the order of the array, and the Drawable with the largest index value will be drawn on the top layer.

[0077] ScaleDrawable is a Drawable resource in Android that allows developers to scale a specified Drawable based on the current level. Level is a key attribute of ScaleDrawable, which determines the degree of scaling of the Drawable. ClipDrawable is a special Drawable resource in Android that allows developers to crop a fragment from a Drawable object for display. ClipDrawable controls the display area of ​​a Drawable by cropping it. It determines the size of the cropping area based on the level attribute value, and can specify the direction and alignment of the cropping.

[0078] Specifically, if it is determined that the Drawable object is any one of the StateListDrawable type, LayerDrawable type, ScaleDrawable and ClipDrawable type, a group of sub-Drawable objects corresponding to the Drawable object (that is, the Drawable objects or operable Drawable objects in each state) are traversed to obtain the corresponding colors of each of the group of sub-Drawable objects. Among them, if the sub-Drawable object is of VectorDrawable type, it is necessary to obtain the StateListDrawable resource id, parse and obtain the resource id of VectorDrawable to ensure that the skinned Drawable object can be obtained normally. After all the sub-Drawable objects are obtained, the sub-Drawable object list of StateListDrawable or LayerDrawable is replaced with the sub-Drawable object list of the new skin to obtain the skinned StateListDrawable or LayerDrawable.

[0079] If it is of ScaleDrawable or ClipDrawable type, the child Drawable object is usually not of ScaleDrawable or ClipDrawable type. Replace the original child Drawable with the new child Drawable to obtain the skinned ScaleDrawable or ClipDrawable.

[0080] According to the embodiments of the present disclosure, by properly using interceptors, the maintainability, reusability and scalability of the code are improved, so that the skinning operation can be completed using only lightweight data.

[0081] According to the embodiments of the present disclosure, Figure 3 As shown, a device 300 for dynamically reskinning an application is provided, comprising: a first acquisition unit 310, configured to acquire a first color list corresponding to a new skin of a component to be reskinned in an application, the first color list comprising object names of one or more objects in the component to be reskinned, and color identifiers corresponding to the one or more objects respectively; a second acquisition unit 320, configured to acquire a second color list corresponding to an original skin of the component to be reskinned through an interceptor, the second color list comprising object names of the one or more objects, and color identifiers corresponding to the one or more objects respectively, wherein the original skin and the new skin are formed based on the same set of color specifications; a replacement unit 330, configured to replace the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list; and a rendering unit 340, configured to return the replaced second color list to the component to be reskinned through the interceptor, so as to implement the skinning operation of the component to be reskinned.

[0082] Here, the operations of the above-mentioned units 310-340 of the application program dynamic skinning device 300 are similar to the operations of the above-described steps 210-240, and will not be repeated here.

[0083] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0084] According to an embodiment of the present disclosure, an electronic device, a readable storage medium and a computer program product are also provided.

[0085] refer to Figure 4 , a block diagram of an electronic device 400 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0086] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0087] Multiple components in the electronic device 400 are connected to the I / O interface 405, including: an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. The input unit 406 can be any type of device that can input information to the electronic device 400. The input unit 406 can receive input digital or character information and generate key signal input related to user settings and / or function control of the electronic device, and can include but is not limited to a mouse, a keyboard, a touch screen, a track pad, a track ball, a joystick, a microphone, and / or a remote controller. The output unit 407 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 408 can include but is not limited to a disk, an optical disk. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, an 802.11 device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0088] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as method 200. For example, in some embodiments, the method 200 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the method 200 described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the method 200 in any other appropriate manner (e.g., by means of firmware).

[0089] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0090] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0091] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0092] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0093] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0094] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0095] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0096] Although the embodiments or examples of the present disclosure have been described with reference to the accompanying drawings, it should be understood that the above-mentioned methods, systems and devices are merely exemplary embodiments or examples, and the scope of the present invention is not limited by these embodiments or examples, but only by the claims after authorization and their equivalent scope. Various elements in the embodiments or examples can be omitted or replaced by their equivalent elements. In addition, each step can be performed in an order different from that described in the present disclosure. Further, the various elements in the embodiments or examples can be combined in various ways. It is important that with the evolution of technology, many elements described herein can be replaced by equivalent elements that appear after the present disclosure.< / item> < / item> < / shape> < / selector> < / item> < / item> < / selector>

Claims

1. A method for dynamically changing the skin of an application program, comprising: Obtaining a first color list corresponding to a new skin of a component to be skinned in an application, wherein the first color list includes object names of one or more objects in the component to be skinned and color identifiers corresponding to the one or more objects; Acquire, through an interceptor, a second color list corresponding to an original skin of the component to be skinned, wherein the second color list includes object names of the one or more objects and color identifiers respectively corresponding to the one or more objects, wherein the original skin and the new skin are formed based on the same set of color specifications; According to the color identifiers corresponding to the object names in the first color list, the color identifiers corresponding to the corresponding object names in the second color list are replaced; and The replaced second color list is returned to the component to be skinned through the interceptor to implement the skinning operation of the component to be skinned.

2. The method of claim 1, wherein: The color identification includes at least one of the following items: a color code, a color value, and a color name.

3. The method of claim 1, wherein: The component to be skinned displays different colors or color combinations in different states, and wherein the first color list and the second color list include object names and corresponding color identifiers or color identifier combinations of the one or more objects of the component to be skinned in different states, wherein: Replacing the color identifiers corresponding to the corresponding object names in the second color list according to the color identifiers corresponding to the object names in the first color list includes: replacing the color identifiers or color identifier combinations corresponding to the corresponding object names of the components to be skinned in each state in the second color list according to the color identifiers corresponding to the object names in different states in the first color list.

4. The method according to any one of claims 1 to 3, wherein: The color of the original skin is implemented based on a color state list, and wherein obtaining the second color list corresponding to the original skin of the component to be skinned through an interceptor includes: In response to determining that the color state list is defined based on a selector element, colors corresponding to the to-be-skinned component in each state corresponding to the color state list are traversed to obtain the second color list.

5. The method according to any one of claims 1 to 3, wherein: The color of the original skin is implemented based on a Drawable object, and wherein obtaining the second color list corresponding to the original skin of the component to be skinned through an interceptor includes: In response to determining that the Drawable object is of the GradientDrawable type or the ShapeDrawable type, a group of colors corresponding to the component to be skinned is obtained and traversed to obtain the second color list.

6. The method according to any one of claims 1 to 3, wherein: The color of the original skin is implemented based on a Drawable object, and wherein obtaining the second color list corresponding to the original skin of the component to be skinned through an interceptor includes: In response to determining that the Drawable object is a vector image VectorDrawable type, obtaining each path node corresponding to the vector image; and For each of the path nodes, the color in the path node is obtained to obtain the second color list.

7. The method according to any one of claims 1 to 3, wherein: The color of the original skin is implemented based on a Drawable object, and wherein obtaining the second color list corresponding to the original skin of the component to be skinned through an interceptor includes: In response to determining that the Drawable object is any one of a StateListDrawable type, a LayerDrawable type, a ScaleDrawable type, and a ClipDrawable type, traversing a group of child Drawable objects corresponding to the Drawable object to obtain colors corresponding to each of the group of child Drawable objects; and Based on the colors corresponding to each of the group of child Drawable objects, the second color list is obtained.

8. The method of claim 1, wherein: The component includes at least one of the following items: text, picture and icon.

9. A device for dynamically changing the skin of an application program, comprising: A first acquisition unit is configured to acquire a first color list corresponding to a new skin of a component to be skinned in an application, wherein the first color list includes object names of one or more objects in the component to be skinned and color identifiers corresponding to the one or more objects; a second acquisition unit configured to acquire, through an interceptor, a second color list corresponding to an original skin of the component to be skinned, wherein the second color list includes object names of the one or more objects and color identifiers corresponding to the one or more objects, wherein the original skin and the new skin are formed based on the same set of color specifications; A replacement unit, configured to replace the color identifier corresponding to the corresponding object name in the second color list according to the color identifier corresponding to the object name in the first color list; as well as The rendering unit is configured to return the replaced second color list to the component to be skinned through the interceptor to implement the skinning operation of the component to be skinned.

10. The device of claim 9, wherein: The color identification includes at least one of the following items: a color code, a color value, and a color name.

11. The device of claim 9, wherein: The component to be skinned displays different colors or color combinations in different states, and wherein the first color list and the second color list include object names of the one or more objects of the component to be skinned in different states and corresponding color identifiers or color identifier combinations, Among them, the replacement unit includes: a unit for replacing the color identifiers or color identifier combinations corresponding to the corresponding object names of the components to be skinned in each state in the second color list according to the color identifiers corresponding to the object names in different states in the first color list.

12. The device according to any one of claims 9 to 11, wherein: The color of the original skin is realized based on a color state list, and wherein the second acquisition unit comprises: In response to determining that the color state list is defined based on a selector element, the color state list corresponds to the color of the component to be skinned in each state, so as to obtain a unit of the second color list.

13. The device according to any one of claims 9 to 11, wherein: The color of the original skin is implemented based on a Drawable object, and wherein the second acquisition unit includes: In response to determining that the Drawable object is of the GradientDrawable type or the ShapeDrawable type, a group of colors corresponding to the component to be skinned is obtained and traversed to obtain a unit of the second color list.

14. The device according to any one of claims 9 to 11, wherein: The color of the original skin is implemented based on a Drawable object, and wherein the second acquisition unit includes: a unit configured to obtain each path node corresponding to the vector image in response to determining that the Drawable object is a vector image VectorDrawable type; and A unit for obtaining, for each of the path nodes, the color in the path node and obtaining the second color list.

15. The device according to any one of claims 9 to 11, wherein: The color of the original skin is implemented based on a Drawable object, and wherein the second acquisition unit includes: a unit for traversing a group of sub-Drawable objects corresponding to the Drawable object to obtain colors corresponding to each of the group of sub-Drawable objects in response to determining that the Drawable object is any one of the StateListDrawable type, the LayerDrawable type, the ScaleDrawable type, and the ClipDrawable type; and A unit for obtaining the second color list based on the colors corresponding to each of the set of child Drawable objects.

16. The device of claim 9, wherein: The component includes at least one of the following items: text, picture and icon.

17. An electronic device comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; in The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.

19. A computer program product comprising a computer program, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Application program skin changing method and device

    CN111061536A

  • Page theme control method and system and computer equipment

    CN111666123A

  • Dynamic skin changing method, device and equipment based on IOS system and storage medium

    CN113296863A

  • Subject resource replacement method and device, electronic equipment and storage medium

    CN115826966A

  • Dynamic skin changing method and device for application page, equipment, storage medium and product

    CN117492887A