Summary of the invention
The technical problem to be solved in the present invention is, for the defect that above-mentioned development difficulty is large, cost of development is higher, the construction cycle is longer of prior art, provide generation method and the device of the UI control across mobile terminal that a kind of development difficulty is less, cost of development is lower, the construction cycle is shorter.
The technical solution adopted for the present invention to solve the technical problems is: construct a kind of generation method of the UI control across mobile terminal, comprise the steps:
A) the corresponding js of the increasing income engine of different Mobile operating systems is packaged into the adaptation layer with unified api interface;
B) described adaptation layer is carried out to initialization;
C) js execution environment is carried out to initialization;
D) the js engine of increasing income described in using is injected into js object corresponding to described api interface in described js execution environment, and the local UI establishment of js function and Mobile operating system function is bound;
E) in described js execution environment, call UI and create interface function, find corresponding local UI create function and call;
F) by described UI ActiveX drafting on the display screen of described mobile terminal.
In the generation method of the UI control across mobile terminal of the present invention, described step e) further comprise:
E1) js code is carried out in js application, calls the member function that js injects object;
E2) described adaptation layer finds the corresponding local UI of described member function to create function;
E2) carry out described local UI and create function.
In the generation method of the UI control across mobile terminal of the present invention, described step F) further comprise:
F1) by measurement, determine the size of UI control;
F2) according to control parameter, layout is carried out in the position of described UI control;
F3) call described api interface by described UI ActiveX drafting on the display screen of described mobile terminal.
In the generation method of the UI control across mobile terminal of the present invention, in described step F) also comprise afterwards:
G1) trigger the operation that refreshes described UI control;
G2) judge whether to re-start measurement, in this way, recalculate the size of each UI control and perform step G3); Otherwise, execution step G3);
G3) judge whether to re-start layout, in this way, again the position of described each UI control is carried out layout and performed step G4); Otherwise, execution step G4);
G4) judge whether to repaint described UI control, in this way, repaint described UI control; Otherwise, do not carry out any operation.
In the generation method of the UI control across mobile terminal of the present invention, also comprise the interaction flow of the primary control event of UI, described interaction flow comprises:
H1) this locality saves the js function of the title of the primary control event of UI and readjustment;
H2) the primary control event of UI is triggered, and finds corresponding js function;
H3) by the js engine of increasing income of adaptation layer, described js function is adjusted back in described js execution environment.
The invention still further relates to a kind of device of realizing the generation method of the above-mentioned UI control across mobile terminal comprises:
Encapsulation unit: for the corresponding js of the increasing income engine of different Mobile operating systems is packaged into the adaptation layer with unified api interface;
Adaptation layer initialization unit: for described adaptation layer is carried out to initialization;
Execution environment initialization unit: for js execution environment is carried out to initialization;
Object injects binding unit: for the js engine of increasing income described in using, js object corresponding to described api interface is injected into described js execution environment, and the local UI establishment of js function and Mobile operating system function is bound;
Interface function call unit: create interface function for call UI at described js execution environment, find corresponding local UI create function and call;
ActiveX drafting unit: for the display screen at described mobile terminal by described UI ActiveX drafting.
In the device of the generation method that realizes the above-mentioned UI control across mobile terminal of the present invention, described interface function call unit further comprises:
Code is carried out calling module: for calling js application, carry out js code, call the member function that js injects object;
UI creates function acquisition module: for making described adaptation layer find the corresponding local UI of described member function to create function;
UI creates function execution module: for carrying out described local UI, create function.
In the device of the generation method that realizes the above-mentioned UI control across mobile terminal of the present invention, described ActiveX drafting unit further comprises:
Measurement module: for determine the size of UI control by measurement;
Layout modules: for layout being carried out in the position of described UI control according to control parameter;
Call drafting module: for call described api interface by described UI ActiveX drafting the display screen at described mobile terminal.
In the device of the generation method that realizes the above-mentioned UI control across mobile terminal of the present invention, also comprise refresh unit, described refresh unit further comprises:
Trigger module: for triggering the operation that refreshes described UI control;
Measure judge module: for judging whether to re-start measurement, in this way, recalculate the size of each UI control;
Layout judge module: for judging whether to re-start layout, in this way, again layout is carried out in the position of described each UI control;
Draw judge module: for judging whether to repaint described UI control, in this way, repaint described UI control; Otherwise, do not carry out any operation.
In the device of the generation method that realizes the above-mentioned UI control across mobile terminal of the present invention, also comprise interactive unit, described interactive unit further comprises:
Memory module: for this locality is saved the js function of the title of the primary control event of UI and readjustment;
Control Event triggered module: for when the primary control event of UI is triggered, find corresponding js function;
Callback module: described js function is adjusted back to described js execution environment for the js engine of increasing income by adaptation layer.
Generation method and the device of implementing the UI control across mobile terminal of the present invention, have following beneficial effect: due to by the corresponding js of the increasing income engine of different Mobile operating systems is packaged into the adaptation layer with unified api interface, after adaptation layer and the initialization of js execution environment, use the js engine of increasing income that js object corresponding to api interface is injected in js execution environment, and js function and the local UI establishment of Mobile operating system function are bound, in js execution environment, call UI and create interface function, find corresponding local UI create function and call, finally by UI ActiveX drafting on the display screen of mobile terminal, like this by unified adaptation layer is provided in multiple Mobile operating system, adaptation layer provides complete unified JS Programming with Pascal Language interface, application developer only need to be understood JS language, the UI that attribute and adaptation layer provide creates interface function, can on mobile terminal, present style unified, the graphical interaction interface element that interactive mode is consistent, its needs primary development, so its development difficulty is less, cost of development is lower, construction cycle is shorter.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
The present invention across the generation method of the UI control of mobile terminal and device embodiment in, its process flow diagram across the generation method of the UI control of mobile terminal is as shown in Figure 2.In Fig. 2, this generation method comprises:
Step S01 is packaged into the adaptation layer with unified api interface by the corresponding js of the increasing income engine of different Mobile operating systems: in this step, the corresponding js of the increasing income engine of different Mobile operating systems is packaged into the adaptation layer with unified api interface.Particularly, on different Mobile operating platforms, select a js engine of increasing income that efficiency is higher, the primary exploitation code providing with Mobile operating system again, the js engine of increasing income is done to corresponding encapsulation, offer a set of complete UI control establishment of js application developer, destruction, Alternative Attribute, the monitoring of interpolation alternative events etc.Adaptation layer is according to the difference between different Mobile operating systems, and the js engine of increasing income of selection (js linguistic interpretation engine) is difference to some extent also.On iOS, employing be the javaScriptCoreJS rendering engine of the self-service research and development of Apple; In Android system, what adopt is the Rhino engine of mozilla company, but due to the singularity (the non-pure java language of development language) of Android platform, so the executive mode of Rhino engine has adopted explanation shape grammer, the efficiency of carrying out js language is very low, so used two kinds of js linguistic interpretation engines of Rhino and v8 on Android platform simultaneously, V8 is the js engine of increasing income that google provides, and the js language execution speed of this engine is very fast
Step S02 carries out initialization to adaptation layer: in this step, adaptation layer is carried out to initialization, the operation of js application relies on adaptation layer, before any js code of operation, first carry out the initialization of adaptation layer program.
Step S03 carries out initialization to js execution environment: in this step, js execution environment is carried out to initialization.By adaptation layer, complete the initialization to js execution environment, and the execution environment using it as application js code.
Step S04 is used the js engine of increasing income that js object corresponding to api interface is injected in js execution environment, and js function and the local UI establishment of Mobile operating system function are bound: in this step, the use js engine of increasing income is injected into js object corresponding to api interface in js execution environment, and js function and the local UI of Mobile operating system are created to function binds.
Step S05 calls UI and creates interface function in js execution environment, find corresponding local UI create function and call: in this step, in this step, in js execution environment, to call UI and create interface function, find corresponding local UI to create function, and call this this locality UI establishment function.
Step S06 by UI ActiveX drafting on the display screen of mobile terminal: in this step, by UI ActiveX drafting on the display screen of mobile terminal.Like this by unified adaptation layer is provided in multiple Mobile operating system, adaptation layer provides complete unified js Programming with Pascal Language interface, the UI that application developer only need to be understood js language, attribute and adaptation layer to be provided creates interface function, can on mobile terminal, present the graphical interaction interface element that style is unified, interactive mode is consistent, its needs primary development, so its development difficulty is less, cost of development is lower, the construction cycle is shorter.
Fig. 3 in the present embodiment is packaged into the corresponding js of the increasing income engine of different Mobile operating systems the schematic diagram of the adaptation layer with unified api interface, different Mobile operating systems adopts the corresponding js engine of increasing income (js linguistic interpretation engine), on various Mobile operating platforms, utilize corresponding local primary code to be packaged into js adaptation layer, this js adaptation layer provides unified js exploitation api interface, js application is by the interface of the unified establishment UI control that calls js adaptation layer (in the present embodiment referred to as adaptation layer) and provide, on multiple Mobile operating system, obtain style unified, interactive mode UI control always.
Fig. 4 creates the sequential chart of UI control in js application call adaptation layer in the present embodiment.
For the present embodiment, above-mentioned steps S05 is further refinement also, and the process flow diagram after its refinement as shown in Figure 5.In Fig. 5, above-mentioned steps S05 further comprises:
Js code is carried out in step S51 js application, calls the member function that js injects object: this step, js code is carried out in js application, calls the member function that js injects object.
Step S52 adaptation layer finds the corresponding local UI of member function to create function: in this step, adaptation layer finds the corresponding local UI of above-mentioned member function to create function.
Step S53 carries out local UI and creates function: in this step, finding local UI to create after function, carrying out local UI and create function.
In the present embodiment, UI control is conceptualized as packaging group in adaptation layer, is the base class of all controls, and whole attributes and the pattern that control is supported stated in its inside, the handle that inside comprises a primary control object, actual operation is all the operation for this primary object.The same with most of GUI (graphical interfaces) operating system, introduced the concept of container simultaneously.Container derives from from packaging group, when possessing all packaging group characteristics, also supports to add, remove daughter element function.
For the present embodiment, above-mentioned steps S06 is further refinement also, and the process flow diagram after its refinement as shown in Figure 6.In Fig. 6, above-mentioned steps S06 further comprises:
Step S61 determines the size of UI control by measurement: in this step, by measuring the size of determining UI control.Specifically, this step is exactly the process that reality by all UI controls are provided or relative size are determined UI control actual space available.This process is a recursive procedure, the region that the maximum that child control provides according to father's container can show, and wide high setting the in conjunction with self, obtains best size, and this result is left to the foundation of layout.If child control itself is also a container, will does so same logic and continue and upwards transmit until the end of recurrence layer.
Step S62 carries out layout according to control parameter to the position of UI control: in this step, according to control parameter, layout is carried out in the position of UI control.This step is actual is the various attributes of setting according to UI control, carries out the adjustment process of physical location.After UI control has been determined size, determine final placement position according to parameters such as alignment thereof (align), frontier distances (margin).
Step S63 call api interface by UI ActiveX drafting on the display screen of mobile terminal: in this step, after size, the position of UI control are all determined, call api interface by UI ActiveX drafting on the display screen of mobile terminal.The style that the UI control of drawing out like this can present on different Mobile operating systems is unified, and its interactive mode is also consistent.
Under the certain situation of the present embodiment, carry out sometimes refreshing of UI control.At this moment, after step S06, also comprise the steps:
Step S71 triggers the operation that refreshes UI control: in this step, trigger the operation that refreshes UI control.
Step S72 judges whether to re-start measurement: in this step, judge whether to re-start measurement, if the result of judgement is yes, perform step S73; Otherwise, execution step S74.
Step S73 recalculates the size of each UI control: in this step, recalculate the size of each UI control.Execute this step, execution step S74.
Step S74 judges whether to re-start layout: in this step, judge whether to re-start layout, if the result of judgement is yes, perform step S75; Otherwise, execution step S76.
Step S75 carries out layout to the position of each UI control again: in this step, again cloth is carried out in the position of each UI control.Execute this step, execution step S76.
Step S76 judges whether to repaint UI control: in this step, judge whether to repaint UI control, if the result of judgement is yes, perform step S77; Otherwise, execution step S78.
Step S77 repaints UI control: in this step, repaint UI control.
Step S78 does not carry out any operation: in this step, do not carry out any operation.
In the present embodiment, this generation method also comprises the interaction flow of the primary control event of UI, and interaction diagrams as shown in Figure 8.In Fig. 8, this interaction flow comprises the steps:
Step S81 this locality saves the js function of the title of the primary control event of UI and readjustment: in this step, and the method for injecting by initialization, this locality saves the js function of the title of the primary control event of UI and readjustment.
The primary control event of step S82 UI is triggered, and finds corresponding js function: in this step, the primary control event of UI is triggered, and finds corresponding js function.
Step S83 adjusts back js function in js environment by the js engine of increasing income of adaptation layer: the js engine of increasing income by adaptation layer is adjusted back js function in js execution environment.
Fig. 9 is the mutual schematic diagram of UI control event in the present embodiment.
The present embodiment also relates to a kind of device of realizing the generation method of the above-mentioned UI control across mobile terminal, and device structural representation as shown in figure 10.In Figure 10, this device comprises that encapsulation unit 1, adaptation layer initialization unit 2, execution environment initialization unit 3, object inject binding unit 4, interface function call unit 5 and ActiveX drafting unit 6; Wherein, encapsulation unit 1 is for being packaged into the adaptation layer with unified api interface by the corresponding js of the increasing income engine of different Mobile operating systems; Adaptation layer initialization unit 2 is for carrying out initialization to adaptation layer; Execution environment initialization unit 3 is for carrying out initialization to js execution environment; Object injects binding unit 4 for using the js engine of increasing income that js object corresponding to api interface is injected into js execution environment, and js function and the local UI establishment of Mobile operating system function are bound; Interface function call unit 5 creates interface function for call UI at js execution environment, finds corresponding local UI create function and call; ActiveX drafting unit 6 is for the display screen at mobile terminal by UI ActiveX drafting.
In the present embodiment, interface function call unit 5 further comprises that code is carried out calling module 51, UI creates function acquisition module 52 and UI creates function execution module 53; Wherein, code is carried out calling module 51 and is carried out js code for calling js application, calls the member function that js injects object; UI creates function acquisition module 52 for making adaptation layer find the corresponding local UI of member function to create function; UI creates function execution module 53 and creates function for carrying out local UI.ActiveX drafting unit 6 further comprises measurement module 61, layout modules 62 and calls drafting module 63; Wherein, measurement module 61 is for determining the size of UI control by measurement; Layout modules 62 is for carrying out layout according to control parameter to the position of UI control; Call drafting module 63 for call api interface by UI ActiveX drafting the display screen at mobile terminal.
In the present embodiment, this device also comprises refresh unit 7 and interactive unit 8; Wherein, refresh unit 7 further comprises trigger module 71, measurement judge module 72, layout judge module 73 and draws judge module 74; Wherein, trigger module 71 is for triggering the operation that refreshes UI control; Measure judge module 72 for judging whether to re-start measurement, in this way, recalculate the size of each UI control; Layout judge module 73, for judging whether to re-start layout, in this way, carries out layout to the position of each UI control again; Draw judge module 74 for judging whether to repaint UI control, in this way, repaint UI control; Otherwise, do not carry out any operation.Interactive unit 8 further comprises memory module 81, control Event triggered module 82 and callback module 83; Wherein, memory module 81 is for making this locality that the js function of the title of the primary control event of UI and readjustment is saved; Control Event triggered module 82, for when the primary control event of UI is triggered, finds corresponding js function; Callback module 83 is adjusted back js environment for the js engine of increasing income by adaptation layer by js function.
In a word, in the present embodiment, at different operating platforms, provide a set of complete adaptation layer, by js adaptation layer, complete the mapping of js function and the local API of Mobile operating system, create local primary control and show user.Js is general web development language, by js language, in the unified DLL (dynamic link library) of different mobile system platform developments, can allow web programmer in the situation that not understanding mobile platform exploitation API, also can develop native applications, reduces development difficulty.By js adaptation layer and unified js DLL (dynamic link library), a set of code or one-time programming can adaptive multiple Mobile operating systems, accomplished cross-platform unitarity.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.