CN110399130B - APP skin changing method based on android system - Google Patents

APP skin changing method based on android system Download PDF

Info

Publication number
CN110399130B
CN110399130B CN201910641321.2A CN201910641321A CN110399130B CN 110399130 B CN110399130 B CN 110399130B CN 201910641321 A CN201910641321 A CN 201910641321A CN 110399130 B CN110399130 B CN 110399130B
Authority
CN
China
Prior art keywords
skin
resource
replacement
compiling
app
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910641321.2A
Other languages
Chinese (zh)
Other versions
CN110399130A (en
Inventor
李君�
谭雪松
朱震宇
张飞龙
余亭亭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guojin Securities Co ltd
Original Assignee
Guojin Securities Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guojin Securities Co ltd filed Critical Guojin Securities Co ltd
Priority to CN201910641321.2A priority Critical patent/CN110399130B/en
Publication of CN110399130A publication Critical patent/CN110399130A/en
Application granted granted Critical
Publication of CN110399130B publication Critical patent/CN110399130B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses an APP skin-changing method based on an android system, which comprises the following steps: s1: creating skin resources, compiling a compiling script, generating skin changing files and packaging; s2: loading the skin files packaged in the step S1 into a skin exchange frame, wherein the skin exchange frame comprises a resource manager, a skin update manager and a resource object; s3: the UI component needing skin replacement is adapted through the UI adaptation layer, and related resources are automatically loaded through the skin replacement framework, so that the skin replacement purpose is achieved. According to the APP skin changing method based on the android system, the requirements of skin file generation and packaging, loading and buffering of skin files and dynamic skin replacement are met, the requirements of performance and diversity are met, and the modularized design is adopted, so that the skin manufacturing process and the skin changing operation process in the business are relatively independent, and the development efficiency of developers is greatly improved.

Description

APP skin changing method based on android system
Technical Field
The invention relates to an APP skin changing method, in particular to an APP skin changing method based on an android system.
Background
In the existing android system, when developing the APP, in order to meet the personalized requirements of users, an APP skin-changing function is generally provided for the users. This is true for smartphones of a variety of different operating systems.
APP loads different skins, and the refinement is as follows: different controls in the APP are required to be able to display different styles under different topics. More common topics include daytime topics and nighttime topics, and the topics are mainly selected manually or automatically by a user according to the intensity of ambient light. This is most common in reading class APP.
The existing APP and android system mainly comprises the following skin changing methods:
1. skin change is achieved through the Google native night mode. However, the proposal only supports the black and white skin at present, and the problem of screen flash can be caused during switching;
2. the skin of the View (View) is dynamically switched by traversing the root layout. This scheme suffers from performance loss due to the need to start a recursive loop from the root layout;
3. the related method of the AssetManager of the system is rewritten in a reflection mode to realize skin replacement; can support various skins and support dynamic seamless switching, and the method is a mainstream application scheme at present. Android 9.0 begins to limit the use of hidden APIs, so versions of this solution on Android 9.0 and beyond may not be available.
Since the AssetManager related APIs in the SDK are rewritten by reflection, which belongs to one way of hacker, the method has certain uncertainty according to the evolution of android versions. In android 9.0 and later versions, google strictly restricts application of the APP to a hidden API, cannot be accessed through a displayed API calling mode, and can only call related APIs through a Java reflection mechanism, so in android 9.0 and later versions, the method faces uncertainty and seriously causes APP flash back. Therefore, there is a need for a stable, convenient and fast APP skin change method that can be dynamically switched seamlessly.
Disclosure of Invention
The invention aims to solve the technical problems of screen flash, performance loss and system compatibility uncertainty possibly existing in the current APP skin-changing method.
The technical scheme adopted for solving the technical problems is to provide an APP skin changing method based on an android system, which comprises the following steps: s1: creating skin resources, compiling a compiling script, generating skin changing files and packaging; s2: loading the skin file packaged in the step S1 into a skin exchange framework, wherein the skin exchange framework comprises a resource manager, a skin update manager and a resource object; s3: the page needing to be changed is adapted through the user interface adaptation layer, and the resource object is loaded through the skin changing frame to change the skin.
Further, the step S1 specifically includes: s11: creating a new project in an Android studio of a development environment of an Android system, and adding a resource file requiring skin replacement, wherein the resource comprises color values and pictures; s12: compiling a compiling script for compiling a skin in an app gradle file in the item created in the step S11, wherein the compiling script is a gradle script; s13: and the compiling script packages the resource file through an Android studio compiling tool to generate a resource compression file required by skin replacement.
Further, the step S2 specifically includes: s21: the user interface adaptation layer obtains the custom resource object through the skin update manager, and obtains the required skin change resource through the custom resource object: the user-defined resource object judges whether skin replacement is needed, if skin replacement is needed, corresponding skin replacement resources are obtained through a resource manager, and otherwise, original skin resources are obtained through the original resource object; and S22, the resource manager dynamically loads the resource compression file in the step S13 according to the resource type comprising color values and pictures of the skin change, and the loading speed is increased through the LRU algorithm of the caching mechanism.
Further, in the step S22, the resource manager converts the resource number of the page to be changed into a corresponding resource name, and then matches the corresponding resource in the resource compression file through the resource name and loads the corresponding resource.
Further, the step S3 includes: s31: the user interface adaptation layer returns the user-defined resource object through the skin update manager, and simultaneously provides an application program interface, and the user interface obtains the corresponding resource through the application program interface; s32, loading various skin-changing resources through the resource numbers by the page needing skin-changing through the user-defined resource object obtained in the S31; s33: the user interface adaptation layer registers a callback monitor of skin update to a skin update manager in a base class of a user interface, wherein the base class is Activity or Fragment; s34: after the skin change is completed, the skin update manager notifies all listeners that the skin has been updated.
Further, the page needing to be changed acquires a resource object by rewriting getResources () through the Activity base class.
Further, the business logic layer completes corresponding UI refreshing through the callback monitor.
Compared with the prior art, the invention has the following beneficial effects: according to the APP skin changing method based on the android system, the requirements of skin file generation and packaging, loading and buffering of skin files and dynamic skin replacement are met, the requirements of performance and diversity are met, and the modularized design is adopted, so that the skin manufacturing process and the skin changing operation process in the business are relatively independent, and the development efficiency of developers is greatly improved.
Drawings
FIG. 1 is a flowchart of an APP skin change method based on an android system in an embodiment of the invention;
fig. 2 is a block diagram of an APP skin-changing method based on an android system in an embodiment of the invention.
Detailed Description
The invention is further described below with reference to the drawings and examples.
FIG. 1 is a flowchart of an APP skin change method based on an android system in an embodiment of the invention; fig. 2 is a block diagram of an APP skin-changing method based on an android system in an embodiment of the invention.
Referring to fig. 1, an APP skin-changing method based on an android system according to an embodiment of the present invention includes the following steps:
s1: creating skin resources, compiling a compiling script (gradle script), generating skin changing files and packaging;
s2: loading the skin files packaged in the step S1 into a skin exchange frame, wherein the skin exchange frame comprises a resource manager, a skin update manager and a resource object;
s3: the page needing skin replacement is adapted through the UI adaptation layer, and finally the resource object is loaded through the skin replacement frame to perform skin replacement.
Activity is one of the four most basic and common components in Android components. The Android four-component has Activity, service service, content Provider Content provision and BroadcastReceiver broadcast receiver.
Referring to fig. 2, in the APP skin-changing method based on the android system according to the embodiment of the present invention, step S1 specifically includes: s1: creating skin resources, compiling a compiling script (gradle script), generating skin changing files and packaging;
s2: loading the skin files packaged in the step S1 into a skin exchange framework, wherein the skin exchange framework comprises a resource manager, a skin update manager and a resource object;
s3: the page needing skin replacement is adapted through the UI adaptation layer, and finally the resource object is loaded through the skin replacement frame to perform skin replacement.
Specifically, the application skin-changing method based on the android system in the embodiment of the invention, step S2 specifically includes: s21: the UI adaptation layer obtains a user-defined resource object through a skin update manager, and the UI obtains required skin change resources (color values, pictures and the like) through the resource object;
s22, judging whether skin replacement is needed by the resource object, and if skin replacement is not needed, acquiring corresponding resources through the original resource object. Otherwise, acquiring corresponding skin change resources through a resource manager;
s23, the resource manager dynamically loads the resource compression file in the step S13 according to the type (color value, picture and the like) of the resources for changing the skin, and the loading speed is increased through a cache (LRU algorithm) mechanism;
the user-defined resource returned in step S23 converts the resource number of the page to be changed into a corresponding resource name, and then matches the corresponding resource in the resource compression file through the resource name.
Specifically, the application skin-changing method based on the android system in the embodiment of the invention includes the following steps: s31: the UI adaptation layer rewrites the getResources method to return the custom resource object (via the update manager) while providing other APIs for the UI to acquire the corresponding resource (color value, picture, etc.);
s32, loading various skin-changing resources (the resource manager can convert the resource ID into a resource name and complete skin-changing through the matched resource in the resource compression file by the resource name) through the resource ID (indirectly through the resource manager in S23) of the self-defined resource object acquired in S31 by the page needing skin-changing;
s33: the UI adaptation layer will register a callback listener of the skin update with the skin update manager in the UI base class (Activity or Fragment);
s34: after the skin change is completed, the skin update manager notifies all listeners that the skin has been updated.
The UI adaptation layer acquires a custom resource object by rewriting getResources () of the Activity. And the business logic layer completes corresponding UI refreshing through the callback monitor.
In summary, the android system-based APP skin-changing method provided by the invention completes skin file generation and packaging, loading and caching of skin files and dynamic skin replacement, meets the requirements of performance and diversity, adopts a modularized design, enables the skin manufacturing and skin-changing operation process in business to be relatively independent, and greatly improves the development efficiency of developers.
While the invention has been described with reference to the preferred embodiments, it is not intended to limit the invention thereto, and it is to be understood that other modifications and improvements may be made by those skilled in the art without departing from the spirit and scope of the invention, which is therefore defined by the appended claims.

Claims (3)

1. An APP skin change method based on an android system is characterized by comprising the following steps:
s1: creating skin resources, compiling a compiling script, generating skin changing files and packaging;
s2: loading the skin file packaged in the step S1 into a skin exchange framework, wherein the skin exchange framework comprises a resource manager, a skin update manager and a resource object;
s3: the page needing skin replacement is adapted through a user interface adaptation layer, and a resource object is loaded through a skin replacement frame to perform skin replacement;
the step S1 specifically includes:
s11: creating a new project in an Android studio of a development environment of an Android system, and adding resources needing skin replacement, wherein the resources comprise color values and pictures;
s12: compiling a compiling script for compiling a skin in an app gradle file in the item created in the step S11, wherein the compiling script is a gradle script;
s13: the compiling script compiles and packages the resource file through an Android studio compiling tool to generate a resource compression file required by skin replacement;
the step S2 specifically includes:
s21: the user interface adaptation layer obtains the custom resource object through the skin update manager, and obtains the required skin change resource through the custom resource object: the user-defined resource object judges whether skin replacement is needed, if skin replacement is needed, corresponding skin replacement resources are obtained through a resource manager, and otherwise, original skin resources are obtained through the original resource object;
s22, the resource manager dynamically loads the resource compression file in the step S13 according to the resource type of the skin change, including the color value and the picture, and increases the loading speed through the LRU algorithm of the caching mechanism;
the resource manager in the step S22 converts the resource number of the page needing to be changed into a corresponding resource name, and then matches the corresponding resource in the resource compression file through the resource name and loads the corresponding resource;
the step S3 includes:
s31: the user interface adaptation layer returns the user-defined resource object through the skin update manager, and simultaneously provides an application program interface, and the user interface obtains the corresponding resource through the application program interface;
s32, loading various skin-changing resources through the resource numbers by the page needing skin-changing through the user-defined resource object obtained in the S31;
s33: the user interface adaptation layer registers a callback monitor of skin update to a skin update manager in a base class of a user interface, wherein the base class is Activity or Fragment;
s34: after the skin change is completed, the skin update manager notifies all listeners that the skin has been updated.
2. The android system-based APP skin-switching method of claim 1, wherein the page to be skin-switched acquires a custom resource object by rewriting getResources () through an Activity base class.
3. The android system-based APP skin-changing method according to claim 1, wherein the business logic layer completes corresponding user interface refreshing through a callback monitor.
CN201910641321.2A 2019-07-16 2019-07-16 APP skin changing method based on android system Active CN110399130B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910641321.2A CN110399130B (en) 2019-07-16 2019-07-16 APP skin changing method based on android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910641321.2A CN110399130B (en) 2019-07-16 2019-07-16 APP skin changing method based on android system

Publications (2)

Publication Number Publication Date
CN110399130A CN110399130A (en) 2019-11-01
CN110399130B true CN110399130B (en) 2023-10-20

Family

ID=68325695

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910641321.2A Active CN110399130B (en) 2019-07-16 2019-07-16 APP skin changing method based on android system

Country Status (1)

Country Link
CN (1) CN110399130B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625312A (en) * 2020-05-19 2020-09-04 小船出海教育科技(北京)有限公司 APP skin changing method and device, electronic equipment and storage medium
CN112231031A (en) * 2020-10-16 2021-01-15 蜂助手股份有限公司 Dynamic skin changing method and device for application program

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110114754A (en) * 2010-04-14 2011-10-20 (주)앵글스톤테크놀러지 Media containing a program convert sk-vm and wipi-java application to android application
CN102810060A (en) * 2011-06-01 2012-12-05 腾讯科技(深圳)有限公司 Method and device for configuring Android picture resource
CN103019781A (en) * 2012-12-04 2013-04-03 广东欧珀移动通信有限公司 Rapid skin changing method based on Android system
CN103942037A (en) * 2013-01-17 2014-07-23 阿里巴巴集团控股有限公司 Method and device for theme replacement of mobile device
CN104850440A (en) * 2015-05-25 2015-08-19 广州市久邦数码科技有限公司 Android system based resource loading method and system therefor
CN108804188A (en) * 2018-05-30 2018-11-13 珠海市君天电子科技有限公司 Changing an interface skin method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6791581B2 (en) * 2001-01-31 2004-09-14 Microsoft Corporation Methods and systems for synchronizing skin properties
US20140282371A1 (en) * 2013-03-14 2014-09-18 Media Direct, Inc. Systems and methods for creating or updating an application using a pre-existing application
CN106802794B (en) * 2016-12-20 2020-06-16 智车优行科技(北京)有限公司 Theme switching method, device, vehicle and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20110114754A (en) * 2010-04-14 2011-10-20 (주)앵글스톤테크놀러지 Media containing a program convert sk-vm and wipi-java application to android application
CN102810060A (en) * 2011-06-01 2012-12-05 腾讯科技(深圳)有限公司 Method and device for configuring Android picture resource
CN103019781A (en) * 2012-12-04 2013-04-03 广东欧珀移动通信有限公司 Rapid skin changing method based on Android system
CN103942037A (en) * 2013-01-17 2014-07-23 阿里巴巴集团控股有限公司 Method and device for theme replacement of mobile device
CN104850440A (en) * 2015-05-25 2015-08-19 广州市久邦数码科技有限公司 Android system based resource loading method and system therefor
CN108804188A (en) * 2018-05-30 2018-11-13 珠海市君天电子科技有限公司 Changing an interface skin method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
android动态换肤框架实现;派派的生活;《CSDN博客,https://blog.csdn.net/mike_Cui_LS/article/details/79688606》;20180325;正文第3页第3段至第17页第1段以及附图 *
Android机顶盒主题切换的设计与实现;陈淡;;有线电视技术(第12期) *

Also Published As

Publication number Publication date
CN110399130A (en) 2019-11-01

Similar Documents

Publication Publication Date Title
US11853820B2 (en) Cross-process communication method, apparatus, and device
CN111158818A (en) Page rendering method and device
US10871973B2 (en) Application activation method and apparatus
CN101980157B (en) Mobile terminal starting method and mobile terminal
CN107741844B (en) Method and device for generating application installation package
WO2020007146A1 (en) Method for running program, apparatus, computer device and storage medium
CN103914205B (en) A kind of file thumbnail methods of exhibiting of intelligent terminal and device
CN110399130B (en) APP skin changing method based on android system
US20220365773A1 (en) Run-Time Application Modification
CN111796823A (en) Method and device for updating page and displaying page and page maintenance system
CN110874217A (en) Interface display method and device for fast application and storage medium
CN104793966A (en) Display and loading method and system of Android local application
WO2020207232A1 (en) Sub-application development method, apparatus, computer device, and storage medium
CN110851285B (en) Resource multiplexing method, device and equipment based on GPU virtualization
CN105868420A (en) Network resource loading mode configuration method and device
CN109933381A (en) A kind of loading method and device of kernel
CN104615432B (en) Splash screen information processing method and client
CN114595065A (en) Data acquisition method and device, storage medium and electronic equipment
CN112214250A (en) Application program assembly loading method and device
US20220292141A1 (en) Quick Application Startup Method and Related Apparatus
WO2012024857A1 (en) Method and terminal for loading picture resources to java virtual machine
CN111625250A (en) Application updating method and device, storage medium and electronic equipment
CN110730300A (en) Camera control method, device, storage medium and terminal
CN107423367B (en) Web page loading method and device
CN101478599B (en) JAVA program installation method and device in mobile communication terminal thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant