commit b305095ab3e15e6676e7f4dfdbab5c7619a8cfbe Author: Ziver Koc Date: Fri Jul 25 13:42:36 2014 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..0f885ac --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gradle +/local.properties +/.idea/workspace.xml +.DS_Store +/build diff --git a/.idea/.name b/.idea/.name new file mode 100755 index 0000000..c8e4ba3 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +UeControl \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100755 index 0000000..217af47 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100755 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100755 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100755 index 0000000..61b8d3b --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/.idea/libraries/GraphView_3_1_2.xml b/.idea/libraries/GraphView_3_1_2.xml new file mode 100755 index 0000000..78349eb --- /dev/null +++ b/.idea/libraries/GraphView_3_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/support_v4_19_1_0.xml b/.idea/libraries/support_v4_19_1_0.xml new file mode 100755 index 0000000..3f6ff2d --- /dev/null +++ b/.idea/libraries/support_v4_19_1_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100755 index 0000000..b153e48 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100755 index 0000000..e6767f1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100755 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100755 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/UeControl.iml b/UeControl.iml new file mode 100755 index 0000000..135c0f9 --- /dev/null +++ b/UeControl.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/.gitignore b/app/.gitignore new file mode 100755 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/LICENSE.txt b/app/LICENSE.txt new file mode 100755 index 0000000..2a71cf4 --- /dev/null +++ b/app/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2013 47 Degrees + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/app/NOTICE.txt b/app/NOTICE.txt new file mode 100755 index 0000000..57eed52 --- /dev/null +++ b/app/NOTICE.txt @@ -0,0 +1,4 @@ +This software contains code derived from Jonas Gehring (http://android-graphview.org/). +This software contains code derived from The Android Open Source Project. + +Including various modifications by Ziver Koc. \ No newline at end of file diff --git a/app/app.iml b/app/app.iml new file mode 100755 index 0000000..0844e47 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/build.gradle b/app/build.gradle new file mode 100755 index 0000000..1cd81a5 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 19 + buildToolsVersion '19.1.0' + + defaultConfig { + applicationId "com.ericsson.uecontrol" + minSdkVersion 19 + targetSdkVersion 19 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + runProguard false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + // You must install or update the Support Repository through the SDK manager to use this dependency. + compile 'com.android.support:support-v4:19.1.+' + compile files('libs/GraphView-3.1.2.jar') +} \ No newline at end of file diff --git a/app/gpl.txt b/app/gpl.txt new file mode 100755 index 0000000..20d40b6 --- /dev/null +++ b/app/gpl.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/app/lgpl.txt b/app/lgpl.txt new file mode 100755 index 0000000..02bbb60 --- /dev/null +++ b/app/lgpl.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. \ No newline at end of file diff --git a/app/libs/GraphView-3.1.2.jar b/app/libs/GraphView-3.1.2.jar new file mode 100644 index 0000000..978e47f Binary files /dev/null and b/app/libs/GraphView-3.1.2.jar differ diff --git a/app/libs/GraphView-master.zip b/app/libs/GraphView-master.zip new file mode 100644 index 0000000..286bdcb Binary files /dev/null and b/app/libs/GraphView-master.zip differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100755 index 0000000..f5037b6 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Program Files (x86)\Android Studio\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100755 index 0000000..d8c2dd1 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java b/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java new file mode 100755 index 0000000..538a602 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/UeBehaviour.java @@ -0,0 +1,103 @@ +package com.ericsson.uecontrol.core; + +/** + * Base class for Ue behaviours that can be used by the executor + * + * Created by ezivkoc on 2014-07-15. + */ +public abstract class UeBehaviour { + private boolean running; + private BehaviourExecutionListener execListener; + private DataHandledListener datahandledListener; + + /** + * Starts to run the behaviour, this method will block until the execution is done + */ + public synchronized void run(){ + running = true; + + if(execListener != null) execListener.executionStarted(); + execute(); + if(execListener != null) execListener.executionStopped(); + } + + /** + * Will stop the currently running behaviour + */ + public synchronized void terminate(){ + running = false; + } + + /** + * @return if currently running behaviour should be terminated + */ + protected boolean stopExecution(){ + return !running; + } + + /** + * @return true is this behaviour is currently running + */ + public boolean isRunning(){ + return running; + } + + public void setExecutionListener(BehaviourExecutionListener l){ + execListener = l; + } + + protected void setProgress(float progress){ + if(execListener != null) + execListener.progressChanged(progress); + + // TODO: This is a dirty way of updating the throughput, should be changed + if(datahandledListener != null) + datahandledListener.handledIncomingData(0); + } + + public void setDataHandledListener(DataHandledListener listener) { + datahandledListener = listener; + } + + protected void setHandledIncomingData(long size){ + if(datahandledListener != null) + datahandledListener.handledIncomingData(size); + } + protected void setHandledOutgoingData(long size){ + if(datahandledListener != null) + datahandledListener.handledOutgoingData(size); + } + + /** + * Executes the behaviour, will block until behaviour has run to completion. + */ + protected abstract void execute(); + + /** + * @return the short name of the behaviour + */ + public abstract String getName(); + + /** + * @return a longer description of the behaviour + */ + //public abstract String getDescription(); + + /** + * @return a nice String with the current settings + */ + public abstract String toString(); + + + + public static interface BehaviourExecutionListener { + public void executionStarted(); + public void progressChanged(float progress); + public void executionStopped(); + } + + public static interface DataHandledListener { + public void handledIncomingData(long size); + public void handledOutgoingData(long size); + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java b/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java new file mode 100755 index 0000000..aa9a34d --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/UeControlExecutor.java @@ -0,0 +1,106 @@ +package com.ericsson.uecontrol.core; + +import android.util.Log; + +import com.ericsson.uecontrol.core.util.ThroughputCalculator; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by ezivkoc on 2014-07-15. + */ +public class UeControlExecutor implements Runnable, UeBehaviour.DataHandledListener { + private static final String TAG = "UeControlExecutor"; + + private List behaviours; + private UeBehaviour currentlyActive; + private boolean terminate; + private Thread thread; + + private ThroughputCalculator downloadSpeed; + private ThroughputCalculator uploadSpeed; + private ThroughputListener throughputListener; + + + public UeControlExecutor(){ + behaviours = new ArrayList(); + downloadSpeed = new ThroughputCalculator(); + uploadSpeed = new ThroughputCalculator(); + } + + public void addBehaviour(UeBehaviour b){ + behaviours.add(b); + b.setDataHandledListener(this); + } + + + public void execute(){ + if(thread == null || !thread.isAlive()) { + terminate = false; + thread = new Thread(this); + thread.start(); + } + } + + public void terminate(){ + terminate = true; + if(currentlyActive != null); + currentlyActive.terminate(); + } + + public boolean isRunning(){ + if(currentlyActive == null) + return false; + return currentlyActive.isRunning(); + } + + public void run(){ + while(!terminate) { + if(behaviours.isEmpty()) { + terminate(); + break; + } + else if (currentlyActive == null) + currentlyActive = behaviours.get(0); + + Log.v(TAG, "Running behaviour: " + currentlyActive.getName()); + currentlyActive.run(); + + int index = behaviours.indexOf(currentlyActive) +1; + if(index < behaviours.size()) + currentlyActive = behaviours.get(index); + else + currentlyActive = null; + } + Log.v(TAG, "Execution completed"); + } + + + @Override + public void handledIncomingData(long size) { + downloadSpeed.setHandledData(size); + if(throughputListener != null && downloadSpeed.isUpdated()) + throughputListener.throughputUpdate(downloadSpeed.getThroughput(), uploadSpeed.getThroughput()); + } + + @Override + public void handledOutgoingData(long size) { + uploadSpeed.setHandledData(size); + if(throughputListener != null && uploadSpeed.isUpdated()) + throughputListener.throughputUpdate(downloadSpeed.getThroughput(), uploadSpeed.getThroughput()); + } + + public void setThroughputListener(ThroughputListener listener){ + throughputListener = listener; + } + + public List getBehaviourList() { + return behaviours; + } + + + public static interface ThroughputListener{ + public void throughputUpdate(double downThroughput, double upThroughput); + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourDownload.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourDownload.java new file mode 100755 index 0000000..f6e4293 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourDownload.java @@ -0,0 +1,34 @@ +package com.ericsson.uecontrol.core.behaviour; + +import com.ericsson.uecontrol.core.UeBehaviour; + +/** + * This behaviour simulates streaming data. + * E.g: video, music etc... + * + * Created by ezivkoc on 2014-07-15. + */ +public class UeBehaviourDownload extends UeBehaviour { + private long data_size; + + public UeBehaviourDownload(long byte_amount){ + data_size = byte_amount; + } + + @Override + protected void execute() { + //TODO + } + + + @Override + public String getName() { + return "Download"; + } + + + @Override + public String toString() { + return "Will download "+ data_size/1000 +"kB"; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSleep.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSleep.java new file mode 100755 index 0000000..028bcc9 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSleep.java @@ -0,0 +1,46 @@ +package com.ericsson.uecontrol.core.behaviour; + +import com.ericsson.uecontrol.core.UeBehaviour; +import com.ericsson.uecontrol.gui.util.Configurator.Configurable; + +/** + * This behaviour simulates an idle period for the device. + * + * Created by ezivkoc on 2014-07-15. + */ +public class UeBehaviourSleep extends UeBehaviour{ + private static final int SLEEP_PERIOD = 100; + + @Configurable("Sleep(millisec)") + private int time; + + public UeBehaviourSleep(){ + this(2000); + } + public UeBehaviourSleep(int milliseconds){ + time = milliseconds; + } + + @Override + protected void execute() { + int elapsedTime = 0; + while(elapsedTime < time){ + super.setProgress((float)elapsedTime/time); + if(super.stopExecution()) break; + try{ + Thread.sleep(SLEEP_PERIOD); + }catch(Exception e){e.printStackTrace();}; + elapsedTime += SLEEP_PERIOD; + } + } + + @Override + public String getName() { + return "Sleep"; + } + + @Override + public String toString() { + return "Will sleep for "+(time/1000)+" seconds"; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSurfing.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSurfing.java new file mode 100755 index 0000000..be7d7c0 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourSurfing.java @@ -0,0 +1,65 @@ +package com.ericsson.uecontrol.core.behaviour; + +import com.ericsson.uecontrol.core.UeBehaviour; +import com.ericsson.uecontrol.gui.util.Configurator.Configurable; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * This behaviour simulates visiting a website + * + * Created by ezivkoc on 2014-07-15. + */ +public class UeBehaviourSurfing extends UeBehaviour { + + @Configurable("Web Address") + private String strUrl; + + public UeBehaviourSurfing(){ + this("http://google.com"); + } + public UeBehaviourSurfing(String url){ + strUrl = url; + } + + @Override + protected void execute() { + try { + URL url = new URL(strUrl); + if(url == null) return; + + byte[] data = new byte[100]; + URLConnection connection = url.openConnection(); + connection.setUseCaches(false); + connection.connect(); + InputStream in = connection.getInputStream(); + + long total = in.available(); + long progress = 0; + long read = 0; + + while((read = in.read(data)) != -1 && !stopExecution()){ + progress += read; + super.setProgress((float)progress/total); + super.setHandledIncomingData(read); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + + @Override + public String getName() { + return "Surfing"; + } + + + @Override + public String toString() { + return "Will visit "+ strUrl; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourUpload.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourUpload.java new file mode 100755 index 0000000..318f578 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourUpload.java @@ -0,0 +1,34 @@ +package com.ericsson.uecontrol.core.behaviour; + +import com.ericsson.uecontrol.core.UeBehaviour; + +/** + * This behaviour simulates streaming data. + * E.g: video, music etc... + * + * Created by ezivkoc on 2014-07-15. + */ +public class UeBehaviourUpload extends UeBehaviour { + private long data_size; + + public UeBehaviourUpload(long byte_amount){ + data_size = byte_amount; + } + + @Override + protected void execute() { + //TODO + } + + + @Override + public String getName() { + return "Upload"; + } + + + @Override + public String toString() { + return "Will Upload "+ data_size/1000 +"kB"; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/core/util/ThroughputCalculator.java b/app/src/main/java/com/ericsson/uecontrol/core/util/ThroughputCalculator.java new file mode 100755 index 0000000..6ee2242 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/util/ThroughputCalculator.java @@ -0,0 +1,50 @@ +package com.ericsson.uecontrol.core.util; + +/** + * Created by ezivkoc on 2014-07-22. + */ +public class ThroughputCalculator { + public static final int UPDATES_PER_SEC = 2; + public static final double NANOSEC_PER_SECOND = 1000000000.0; + + private boolean updated; + private double throughput; + private long previousTimeStamp; + private long data_amount; + + + public void setHandledData(long bytes){ + long currentTimeStamp = System.nanoTime(); + data_amount += bytes; + if(currentTimeStamp - (NANOSEC_PER_SECOND/UPDATES_PER_SEC) > previousTimeStamp) { + throughput = data_amount / ((currentTimeStamp - previousTimeStamp) / (NANOSEC_PER_SECOND/UPDATES_PER_SEC)); + previousTimeStamp = currentTimeStamp; + data_amount = 0; + updated = true; + } + } + + public double getThroughput(){ + setHandledData(0); // Update throughput + updated = false; + return throughput; + } + + public boolean isUpdated(){ + return updated; + } + + + private static final String[] DATA_SIZE = new String[]{"b/s", "kbit/s", "Mbit/s", "Gbit/s"}; + public static String getThroughputString(double bits){ + int index = 0; + double value = bits; + + for(; value > 1024 && index < DATA_SIZE.length ;index++) { + value /= 1024; + } + + value = (int)(value*10) / 10.0; + return value+" "+DATA_SIZE[index]; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/EditActivity.java b/app/src/main/java/com/ericsson/uecontrol/gui/EditActivity.java new file mode 100755 index 0000000..8aee120 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/EditActivity.java @@ -0,0 +1,87 @@ +package com.ericsson.uecontrol.gui; + +import android.app.ListActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ListView; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeBehaviour; +import com.ericsson.uecontrol.core.UeControlExecutor; +import com.ericsson.uecontrol.gui.fragments.SelectBehaviourDialog; +import com.ericsson.uecontrol.gui.util.BehaviourListAdapter; +import com.ericsson.uecontrol.gui.util.DynamicListView; + +import java.util.ArrayList; +import java.util.List; + +public class EditActivity extends ListActivity implements View.OnClickListener { + private UeControlExecutor executor; + private BehaviourListAdapter adapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_edit); + + final List list; + if(getIntent().hasExtra("executor")) { + int executorIndex = getIntent().getExtras().getInt("executor_index"); + executor = MainActivity.getExecutor(executorIndex); + + list = executor.getBehaviourList(); + } + else + list = new ArrayList(); + + adapter = new BehaviourListAdapter(this, list); + adapter.setEditable(true); + DynamicListView listView = (DynamicListView) findViewById(android.R.id.list); + listView.setAdapter(adapter); + listView.setActionListener(adapter); + listView.setOnClickListener(this); + listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.edit, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + if (id == R.id.action_add) { + SelectBehaviourDialog selector = new SelectBehaviourDialog(); + selector.setSelectionCallback(new SelectBehaviourDialog.BehaviourSelectionCallback() { + public void behaviourSelected(String name, Class objClass) { + try { + UeBehaviour obj = objClass.newInstance(); + executor.addBehaviour(obj); + adapter.generateIds(); + adapter.notifyDataSetChanged(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + selector.show(getFragmentManager(), "behaviour_selector"); + return true; + } + return super.onOptionsItemSelected(item); + } + + + @Override + public void onClick(View view) { + + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java b/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java new file mode 100755 index 0000000..0278ed9 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/MainActivity.java @@ -0,0 +1,147 @@ +package com.ericsson.uecontrol.gui; + +import android.app.ActionBar; +import android.app.FragmentManager; +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.app.FragmentActivity; +import android.support.v4.widget.DrawerLayout; +import android.view.Menu; +import android.view.MenuItem; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeControlExecutor; +import com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep; +import com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing; +import com.ericsson.uecontrol.gui.fragments.BehaviourListFragment; +import com.ericsson.uecontrol.gui.fragments.NavigationDrawerFragment; +import com.ericsson.uecontrol.gui.fragments.StatusFragment; + +import java.util.ArrayList; + + +public class MainActivity extends FragmentActivity + implements NavigationDrawerFragment.NavigationDrawerCallbacks { + + /** + * Fragment managing the behaviors, interactions and presentation of the navigation drawer. + */ + private NavigationDrawerFragment navigationDrawerFragment; + private StatusFragment statusFragment; + + /** + * Used to store the last screen title. For use in {@link #restoreActionBar()}. + */ + private CharSequence title; + private int currentExecutor; + + private static ArrayList executors; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + navigationDrawerFragment = (NavigationDrawerFragment) + getFragmentManager().findFragmentById(R.id.navigation_drawer); + statusFragment = (StatusFragment) + getFragmentManager().findFragmentById(R.id.status_fragment); + title = getTitle(); + + // Set up the drawer. + navigationDrawerFragment.setUp( + R.id.navigation_drawer, + (DrawerLayout) findViewById(R.id.drawer_layout)); + + executors = new ArrayList(); + currentExecutor = 0; + + UeControlExecutor exec = new UeControlExecutor(); + exec.addBehaviour(new UeBehaviourSleep(1000)); + exec.addBehaviour(new UeBehaviourSurfing("http://google.com")); + exec.addBehaviour(new UeBehaviourSleep(4000)); + exec.setThroughputListener(statusFragment.getThroughputListener()); + executors.add(exec); + } + + @Override + public void onNavigationDrawerItemSelected(int position) { + // update the main content by replacing fragments + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction() + .replace(R.id.container, BehaviourListFragment.newInstance(position)).commit(); + } + + public void onSectionAttached(int number) { + currentExecutor = number; + switch (number) { + case 1: + title = getString(R.string.title_section1); + break; + case 2: + title = getString(R.string.title_section2); + break; + case 3: + title = getString(R.string.title_section3); + break; + } + } + + public void restoreActionBar() { + ActionBar actionBar = getActionBar(); + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + actionBar.setDisplayShowTitleEnabled(true); + actionBar.setTitle(title); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + if (!navigationDrawerFragment.isDrawerOpen()) { + // Only show items in the action bar relevant to this screen + // if the drawer is not showing. Otherwise, let the drawer + // decide what to show in the action bar. + getMenuInflater().inflate(R.menu.main, menu); + restoreActionBar(); + return true; + } + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + if (id == R.id.action_execute) { + UeControlExecutor exec = executors.get(currentExecutor); + if(exec.isRunning()){ + exec.terminate(); + item.setTitle(R.string.action_run); + } + else { + exec.execute(); + item.setTitle(R.string.action_stop); + } + return true; + } + if (id == R.id.action_edit) { + Intent intent = new Intent(this, EditActivity.class); + intent.putExtra("executor", currentExecutor); + startActivity(intent); + return true; + } + if (id == R.id.action_settings) { + startActivity(new Intent(this, SettingsActivity.class)); + return true; + } + return super.onOptionsItemSelected(item); + } + + public static UeControlExecutor getExecutor(int index) { + if(index >= executors.size()) + return null; + return executors.get(index); + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/SettingsActivity.java b/app/src/main/java/com/ericsson/uecontrol/gui/SettingsActivity.java new file mode 100755 index 0000000..ec73582 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/SettingsActivity.java @@ -0,0 +1,31 @@ +package com.ericsson.uecontrol.gui; + +import android.app.Activity; +import android.os.Bundle; +import android.preference.PreferenceFragment; + +import com.ericsson.uecontrol.R; + +public class SettingsActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Display the fragment as the main content. + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new SettingsFragment()) + .commit(); + } + + + public static class SettingsFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Load the preferences from an XML resource + addPreferencesFromResource(R.xml.preferences); + } + } +} + diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/BehaviourListFragment.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/BehaviourListFragment.java new file mode 100755 index 0000000..4dc03c9 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/BehaviourListFragment.java @@ -0,0 +1,104 @@ +package com.ericsson.uecontrol.gui.fragments; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.TextView; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeControlExecutor; +import com.ericsson.uecontrol.gui.MainActivity; +import com.ericsson.uecontrol.gui.util.BehaviourListAdapter; + +import java.util.ArrayList; + +/** + * This fragment will show a read only list of defined UeBehaviours + */ +public class BehaviourListFragment extends Fragment implements AbsListView.OnItemClickListener { + + /** + * The fragment's ListView/GridView. + */ + private AdapterView listView; + + /** + * The Adapter which will be used to populate the ListView/GridView with + * Views. + */ + private BehaviourListAdapter adapter; + private UeControlExecutor executor; + + public static BehaviourListFragment newInstance(int index) { + BehaviourListFragment f = new BehaviourListFragment(); + // Supply index input as an argument. + Bundle args = new Bundle(); + args.putInt("executor", index); + f.setArguments(args); + return f; + } + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + int index = args.getInt("executor", 0); + + if(MainActivity.getExecutor(index) != null) { + UeControlExecutor executor = MainActivity.getExecutor(index); + adapter = new BehaviourListAdapter(getActivity(), executor.getBehaviourList()); + } + else + adapter = new BehaviourListAdapter(getActivity(), new ArrayList()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_item, container, false); + + // Set the adapter + listView = (AdapterView) view.findViewById(android.R.id.list); + listView.setAdapter(adapter); + + // Set OnItemClickListener so we can be notified on item clicks + //listView.setOnItemClickListener(this); + + setEmptyText("No Behaviours Defined"); + + return view; + } + + @Override + public void onResume() { + adapter.generateIds(); + adapter.notifyDataSetChanged(); + super.onResume(); + } + + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + + } + + /** + * The default content for this Fragment has a TextView that is shown when + * the list is empty. If you would like to change the text, call this method + * to supply the text it should use. + */ + public void setEmptyText(CharSequence emptyText) { + View emptyView = listView.getEmptyView(); + + if (emptyText instanceof TextView) { + ((TextView) emptyView).setText(emptyText); + } + } + +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/ConfigureBehaviourDialog.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/ConfigureBehaviourDialog.java new file mode 100755 index 0000000..7373fd9 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/ConfigureBehaviourDialog.java @@ -0,0 +1,45 @@ +package com.ericsson.uecontrol.gui.fragments; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.os.Bundle; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.ericsson.uecontrol.R; + +/** + * Created by ezivkoc on 2014-07-24. + */ +public class ConfigureBehaviourDialog extends DialogFragment { + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Create dialog + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(R.string.configure_behaviour); + + builder.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // User clicked OK button + } + }); + builder.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) {} + }); + + + LinearLayout root = new LinearLayout(getActivity()); + + LinearLayout param = new LinearLayout(getActivity()); + param.addView(new TextView(getActivity())); + param.addView(new EditText(getActivity())); + root.addView(param); + + builder.setView(root); + return builder.create(); + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/NavigationDrawerFragment.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/NavigationDrawerFragment.java new file mode 100755 index 0000000..14d271e --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/NavigationDrawerFragment.java @@ -0,0 +1,284 @@ +package com.ericsson.uecontrol.gui.fragments; + + +import android.app.ActionBar; +import android.app.Activity; +import android.app.Fragment; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.Toast; + +import com.ericsson.uecontrol.R; + +/** + * Fragment used for managing interactions for and presentation of a navigation drawer. + * See the + * design guidelines for a complete explanation of the behaviors implemented here. + */ +public class NavigationDrawerFragment extends Fragment { + + /** + * Remember the position of the selected item. + */ + private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; + + /** + * Per the design guidelines, you should show the drawer on launch until the user manually + * expands it. This shared preference tracks this. + */ + private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; + + /** + * A pointer to the current callbacks instance (the Activity). + */ + private NavigationDrawerCallbacks mCallbacks; + + /** + * Helper component that ties the action bar to the navigation drawer. + */ + private ActionBarDrawerToggle mDrawerToggle; + + private DrawerLayout mDrawerLayout; + private ListView mDrawerListView; + private View mFragmentContainerView; + + private int mCurrentSelectedPosition = 0; + private boolean mFromSavedInstanceState; + private boolean mUserLearnedDrawer; + + public NavigationDrawerFragment() { + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Read in the flag indicating whether or not the user has demonstrated awareness of the + // drawer. See PREF_USER_LEARNED_DRAWER for details. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); + mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); + + if (savedInstanceState != null) { + mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); + mFromSavedInstanceState = true; + } + + // Select either the default item (0) or the last selected item. + selectItem(mCurrentSelectedPosition); + } + + @Override + public void onActivityCreated (Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + // Indicate that this fragment would like to influence the set of actions in the action bar. + setHasOptionsMenu(true); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + mDrawerListView = (ListView) inflater.inflate( + R.layout.fragment_navigation_drawer, container, false); + mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + selectItem(position); + } + }); + mDrawerListView.setAdapter(new ArrayAdapter( + getActionBar().getThemedContext(), + android.R.layout.simple_list_item_activated_1, + android.R.id.text1, + new String[]{ + getString(R.string.title_section1), + getString(R.string.title_section2), + getString(R.string.title_section3), + })); + mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); + return mDrawerListView; + } + + public boolean isDrawerOpen() { + return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); + } + + /** + * Users of this fragment must call this method to set up the navigation drawer interactions. + * + * @param fragmentId The android:id of this fragment in its activity's layout. + * @param drawerLayout The DrawerLayout containing this fragment's UI. + */ + public void setUp(int fragmentId, DrawerLayout drawerLayout) { + mFragmentContainerView = getActivity().findViewById(fragmentId); + mDrawerLayout = drawerLayout; + + // set a custom shadow that overlays the main content when the drawer opens + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + // set up the drawer's list view with items and click listener + + ActionBar actionBar = getActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); + + // ActionBarDrawerToggle ties together the the proper interactions + // between the navigation drawer and the action bar app icon. + mDrawerToggle = new ActionBarDrawerToggle( + getActivity(), /* host Activity */ + mDrawerLayout, /* DrawerLayout object */ + R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ + R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ + R.string.navigation_drawer_close /* "close drawer" description for accessibility */ + ) { + @Override + public void onDrawerClosed(View drawerView) { + super.onDrawerClosed(drawerView); + if (!isAdded()) { + return; + } + + getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() + } + + @Override + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + if (!isAdded()) { + return; + } + + if (!mUserLearnedDrawer) { + // The user manually opened the drawer; store this flag to prevent auto-showing + // the navigation drawer automatically in the future. + mUserLearnedDrawer = true; + SharedPreferences sp = PreferenceManager + .getDefaultSharedPreferences(getActivity()); + sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); + } + + getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() + } + }; + + // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, + // per the navigation drawer design guidelines. + if (!mUserLearnedDrawer && !mFromSavedInstanceState) { + mDrawerLayout.openDrawer(mFragmentContainerView); + } + + // Defer code dependent on restoration of previous instance state. + mDrawerLayout.post(new Runnable() { + @Override + public void run() { + mDrawerToggle.syncState(); + } + }); + + mDrawerLayout.setDrawerListener(mDrawerToggle); + } + + private void selectItem(int position) { + mCurrentSelectedPosition = position; + if (mDrawerListView != null) { + mDrawerListView.setItemChecked(position, true); + } + if (mDrawerLayout != null) { + mDrawerLayout.closeDrawer(mFragmentContainerView); + } + if (mCallbacks != null) { + mCallbacks.onNavigationDrawerItemSelected(position); + } + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mCallbacks = (NavigationDrawerCallbacks) activity; + } catch (ClassCastException e) { + throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); + } + } + + @Override + public void onDetach() { + super.onDetach(); + mCallbacks = null; + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + // Forward the new configuration the drawer toggle component. + mDrawerToggle.onConfigurationChanged(newConfig); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + // If the drawer is open, show the global app actions in the action bar. See also + // showGlobalContextActionBar, which controls the top-left area of the action bar. + if (mDrawerLayout != null && isDrawerOpen()) { + inflater.inflate(R.menu.global, menu); + showGlobalContextActionBar(); + } + super.onCreateOptionsMenu(menu, inflater); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (mDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + + if (item.getItemId() == R.id.action_execute) { + Toast.makeText(getActivity(), "Running", Toast.LENGTH_SHORT).show(); + return true; + } + + return super.onOptionsItemSelected(item); + } + + /** + * Per the navigation drawer design guidelines, updates the action bar to show the global app + * 'context', rather than just what's in the current screen. + */ + private void showGlobalContextActionBar() { + ActionBar actionBar = getActionBar(); + actionBar.setDisplayShowTitleEnabled(true); + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + actionBar.setTitle(R.string.app_name); + } + + private ActionBar getActionBar() { + return getActivity().getActionBar(); + } + + /** + * Callbacks interface that all activities using this fragment must implement. + */ + public static interface NavigationDrawerCallbacks { + /** + * Called when an item in the navigation drawer is selected. + */ + void onNavigationDrawerItemSelected(int position); + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/SelectBehaviourDialog.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/SelectBehaviourDialog.java new file mode 100755 index 0000000..bdf380f --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/SelectBehaviourDialog.java @@ -0,0 +1,64 @@ +package com.ericsson.uecontrol.gui.fragments; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.os.Bundle; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeBehaviour; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class SelectBehaviourDialog extends DialogFragment { + public static String[] behavioursClasses; + public static String[] behaviourNames; + + private BehaviourSelectionCallback callback; + + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Generate nice behaviour names + if(behavioursClasses == null) { + behavioursClasses = getResources().getStringArray(R.array.behaviours); + behaviourNames = new String[behavioursClasses.length]; + + Pattern p = Pattern.compile("[\\w\\.]*\\.(?:UeBehaviour|)(\\w*)"); + for (int i = 0; i < behavioursClasses.length; i++) { + Matcher m = p.matcher(behavioursClasses[i]); + if(m.find()) + behaviourNames[i] = m.group(1); + else + behaviourNames[i] = behavioursClasses[i]; + } + } + + // Create dialog + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(R.string.select_behaviour); + builder.setItems(behaviourNames, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + try { + if (callback != null){ + Class objClass = Class.forName(behavioursClasses[which]); + callback.behaviourSelected(behaviourNames[which], objClass); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + return builder.create(); + } + + public void setSelectionCallback(BehaviourSelectionCallback c){ + callback = c; + } + + public static interface BehaviourSelectionCallback{ + public void behaviourSelected(String name, Class objClass); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java new file mode 100755 index 0000000..4c80b9d --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/fragments/StatusFragment.java @@ -0,0 +1,82 @@ +package com.ericsson.uecontrol.gui.fragments; + +import android.app.Fragment; +import android.graphics.Color; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.TextView; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeControlExecutor; +import com.ericsson.uecontrol.core.util.ThroughputCalculator; +import com.jjoe64.graphview.GraphView.GraphViewData; +import com.jjoe64.graphview.GraphViewSeries; +import com.jjoe64.graphview.GraphViewSeries.GraphViewSeriesStyle; +import com.jjoe64.graphview.GraphViewStyle; +import com.jjoe64.graphview.LineGraphView; + + +/** + * Created by ezivkoc on 2014-07-15. + */ +public class StatusFragment extends Fragment { + private TextView down_speed; + private TextView up_speed; + private GraphViewSeries downGraph; + private GraphViewSeries upGraph; + private int x = 0; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view = inflater.inflate(R.layout.fragment_status, container, false); + + down_speed = (TextView) view.findViewById(R.id.down_speed); + up_speed = (TextView) view.findViewById(R.id.up_speed); + + // Init the graph + GraphViewData[] zeroPoint = new GraphViewData[]{new GraphViewData(0, 0)}; + downGraph = new GraphViewSeries("Download Throughput", new GraphViewSeriesStyle(Color.GREEN, 3), zeroPoint); + upGraph = new GraphViewSeries("Upload Throughput" , new GraphViewSeriesStyle(Color.RED , 3), zeroPoint); + + LineGraphView graphView = new LineGraphView(this.getActivity(), "GraphViewDemo"); + graphView.addSeries(downGraph); + graphView.addSeries(upGraph); + //graphView.setDrawDataPoints(true); + graphView.setScrollable(true); + graphView.setViewPort(0, 120); + graphView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); + graphView.getGraphViewStyle().setGridStyle(GraphViewStyle.GridStyle.BOTH); + + LinearLayout layout = (LinearLayout) view.findViewById(R.id.graph); + layout.addView(graphView); + + return view; + } + + + private UeControlExecutor.ThroughputListener throughputListener = + new UeControlExecutor.ThroughputListener() { + public void throughputUpdate(final double downThroughput, final double upThroughput) { + if(down_speed != null && up_speed != null) + down_speed.post(new Runnable() { + @Override + public void run() { + down_speed.setText(ThroughputCalculator.getThroughputString(downThroughput)); + up_speed.setText(ThroughputCalculator.getThroughputString(upThroughput)); + downGraph.appendData(new GraphViewData(x, downThroughput), true, 120); + upGraph.appendData(new GraphViewData(x, upThroughput), true, 120); + x++; + } + }); + } + }; + public UeControlExecutor.ThroughputListener getThroughputListener(){ + return throughputListener; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/util/BehaviourListAdapter.java b/app/src/main/java/com/ericsson/uecontrol/gui/util/BehaviourListAdapter.java new file mode 100755 index 0000000..047e2ae --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/util/BehaviourListAdapter.java @@ -0,0 +1,82 @@ +package com.ericsson.uecontrol.gui.util; + +import android.app.Activity; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.ericsson.uecontrol.R; +import com.ericsson.uecontrol.core.UeBehaviour; + +import java.util.List; + +/** + * Created by ezivkoc on 2014-07-15. + */ +public class BehaviourListAdapter extends StableArrayAdapter{ + private static final int VIEW_RESOURCE = R.layout.behaviour_list_item; + + private static LayoutInflater inflater = null; + + private boolean editable = false; + + public BehaviourListAdapter(Activity a, List objects) { + super(a, VIEW_RESOURCE, objects); + inflater = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + + public View getView(int position, View convertView, ViewGroup parent) { + View vi = convertView; + if(convertView==null) + vi = inflater.inflate(VIEW_RESOURCE, null); + + ImageView draggable = (ImageView)vi.findViewById(R.id.draggable); + TextView title = (TextView)vi.findViewById(R.id.title); + TextView description = (TextView)vi.findViewById(R.id.description); + final ProgressBar active = (ProgressBar)vi.findViewById(R.id.active); + final ProgressBar progress = (ProgressBar) vi.findViewById(R.id.progress); + + UeBehaviour behaviour = super.getItem(position); + + // Setting all values in listview + title.setText(behaviour.getName()); + description.setText(behaviour.toString()); + + if(editable) + draggable.setVisibility(View.VISIBLE); + + behaviour.setExecutionListener(new UeBehaviour.BehaviourExecutionListener() { + public void executionStarted() { + progress.post(new Runnable() { + public void run() { + active.setVisibility(View.VISIBLE); + progress.setVisibility(View.VISIBLE); + } + }); + } + public void progressChanged(final float p) { + progress.setMax(100); + progress.setProgress((int) (p * 100)); + } + public void executionStopped() { + progress.post(new Runnable() { + public void run() { + active.setVisibility(View.INVISIBLE); + progress.setVisibility(View.INVISIBLE); + } + }); + } + }); + + return vi; + } + + public void setEditable(boolean b) { + editable = b; + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/util/Configurator.java b/app/src/main/java/com/ericsson/uecontrol/gui/util/Configurator.java new file mode 100755 index 0000000..db2b817 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/util/Configurator.java @@ -0,0 +1,68 @@ +package com.ericsson.uecontrol.gui.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; + +/** + * Created by ezivkoc on 2014-07-24. + */ +public class Configurator { + /** + * Sets a field in a class as externally configurable. + */ + @Retention(RetentionPolicy.RUNTIME) // Make this annotation accessible at runtime via reflection. + @Target({ElementType.FIELD}) // This annotation can only be applied to class fields. + public static @interface Configurable{ + String value(); + } + + public static enum ConfigType{ + STRING, INT + } + + public static class ConfigurationParam{ + protected Field field; + protected ConfigType type; + protected Object value; + + public ConfigType getType(){return type;} + + public int getInt (){return (Integer) value;} + public String setString(){return (String) value;} + + public void setInt (int v) {value = v;} + public void setString(String v){value = v;} + } + + + public static ConfigurationParam[] getConfiguration(Class c){ + ArrayList conf = new ArrayList(); + + Field[] all = c.getFields(); + for(Field f : all){ + if(f.isAnnotationPresent(Configurable.class) && !Modifier.isStatic(f.getModifiers())) { + ConfigurationParam confParam = new ConfigurationParam(); + confParam.field = f; + conf.add(confParam); + } + } + + return (ConfigurationParam[])conf.toArray(); + } + + public static void setConfiguration(ConfigurationParam[] params, Object obj){ + for(ConfigurationParam param : params){ + try { + param.field.setAccessible(true); + param.field.set(obj, param.value); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } +} diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/util/DynamicListView.java b/app/src/main/java/com/ericsson/uecontrol/gui/util/DynamicListView.java new file mode 100755 index 0000000..c326eb7 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/util/DynamicListView.java @@ -0,0 +1,620 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ericsson.uecontrol.gui.util; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.animation.TypeEvaluator; +import android.animation.ValueAnimator; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.drawable.BitmapDrawable; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewTreeObserver; +import android.widget.AbsListView; +import android.widget.ListAdapter; +import android.widget.ListView; + +/** + * The dynamic listview is an extension of listview that supports cell dragging + * and swapping. + *

+ * This layout is in charge of positioning the hover cell in the correct location + * on the screen in response to user touch events. It uses the position of the + * hover cell to determine when two cells should be swapped. If two cells should + * be swapped, all the corresponding data set and layout changes are handled here. + *

+ * If no cell is selected, all the touch events are passed down to the listview + * and behave normally. If one of the items in the listview experiences a + * long press event, the contents of its current visible state are captured as + * a bitmap and its visibility is set to INVISIBLE. A hover cell is then created and + * added to this layout as an overlaying BitmapDrawable above the listview. Once the + * hover cell is translated some distance to signify an item swap, a data set change + * accompanied by animation takes place. When the user releases the hover cell, + * it animates into its corresponding position in the listview. + *

+ * When the hover cell is either above or below the bounds of the listview, this + * listview also scrolls on its own so as to reveal additional content. + */ +public class DynamicListView extends ListView { + private static final int INVALID_POINTER_ID = -1; + private static final int INVALID_ID = -1; + private static final int SMOOTH_SCROLL_AMOUNT_AT_EDGE = 15; + private static final int MOVE_DURATION = 150; + private static final int LINE_THICKNESS = 15; + private static final int REMOVE_OFFSET = 150; + private static final int SWAP_OFFSET = 130; + private static enum TouchMode {UNKNOWN, REMOVE, SWAP}; + + + private int mDownY = -1; + private int mDownX = -1; + private int mLastEventX = -1; + private int mLastEventY = -1; + + private int mTotalOffset = 0; + + private boolean mCellIsMobile = false; + private boolean mIsMobileScrolling = false; + private int mSmoothScrollAmountAtEdge = 0; + + private long mAboveItemId = INVALID_ID; + private long mMobileItemId = INVALID_ID; + private long mBelowItemId = INVALID_ID; + + private BitmapDrawable mHoverCell; + private TouchMode mMode; + private Rect mHoverCellCurrentBounds; + private Rect mHoverCellOriginalBounds; + + private int mActivePointerId = INVALID_POINTER_ID; + + private boolean mIsWaitingForScrollFinish = false; + private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE; + + private DynamicListActionListener listener; + + + public DynamicListView(Context context) { + super(context); + init(context); + } + + public DynamicListView(Context context, AttributeSet attrs) { + super(context, attrs); + init(context); + } + + public DynamicListView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(context); + } + + public void init(Context context) { + setOnScrollListener(mScrollListener); + DisplayMetrics metrics = context.getResources().getDisplayMetrics(); + mSmoothScrollAmountAtEdge = (int) (SMOOTH_SCROLL_AMOUNT_AT_EDGE / metrics.density); + } + + + public void setActionListener(DynamicListActionListener l){ + listener = l; + } + + + protected void startItemHover(){ + mTotalOffset = 0; + + int position = pointToPosition(mDownX, mDownY); + int itemNum = position - getFirstVisiblePosition(); + + View selectedView = getChildAt(itemNum); + if(selectedView != null) { + mMobileItemId = getAdapter().getItemId(position); + mHoverCell = getAndAddHoverView(selectedView); + selectedView.setVisibility(INVISIBLE); + + mCellIsMobile = true; + + updateNeighborViewsForID(mMobileItemId); + } + } + + /** + * Creates the hover cell with the appropriate bitmap and of appropriate + * size. The hover cell's BitmapDrawable is drawn on top of the bitmap every + * single time an invalidate call is made. + */ + private BitmapDrawable getAndAddHoverView(View v) { + int w = v.getWidth(); + int h = v.getHeight(); + int top = v.getTop(); + int left = v.getLeft(); + + mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h); + mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); + + BitmapDrawable drawable = new BitmapDrawable(getResources(), getBitmapWithBorder(v)); + drawable.setBounds(mHoverCellCurrentBounds); + + return drawable; + } + + /** + * Draws a black border over the screenshot of the view passed in. + */ + private Bitmap getBitmapWithBorder(View v) { + Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + + v.draw(canvas); + addBorder(bitmap, Color.BLACK); + + return bitmap; + } + + private void addBorder(Bitmap b, int color){ + Paint paint = new Paint(); + paint.setStyle(Paint.Style.STROKE); + paint.setStrokeWidth(LINE_THICKNESS); + paint.setColor(color); + + Canvas canvas = new Canvas(b); + canvas.drawRect(new Rect(0, 0, b.getWidth(), b.getHeight()), paint); + } + + /** + * Stores a reference to the views above and below the item currently + * corresponding to the hover cell. It is important to note that if this + * item is either at the top or bottom of the list, mAboveItemId or mBelowItemId + * may be invalid. + */ + private void updateNeighborViewsForID(long itemID) { + int position = getPositionForID(itemID); + ListAdapter adapter = getAdapter(); + mAboveItemId = adapter.getItemId(position - 1); + mBelowItemId = adapter.getItemId(position + 1); + } + + /** + * Retrieves the view in the list corresponding to itemID + */ + public View getViewForID(long itemID) { + int firstVisiblePosition = getFirstVisiblePosition(); + ListAdapter adapter = getAdapter(); + for (int i = 0; i < getChildCount(); i++) { + View v = getChildAt(i); + int position = firstVisiblePosition + i; + long id = adapter.getItemId(position); + if (id == itemID) { + return v; + } + } + return null; + } + + /** + * Retrieves the position in the list corresponding to itemID + */ + public int getPositionForID(long itemID) { + View v = getViewForID(itemID); + if (v == null) { + return -1; + } else { + return getPositionForView(v); + } + } + + /** + * dispatchDraw gets invoked when all the child views are about to be drawn. + * By overriding this method, the hover cell (BitmapDrawable) can be drawn + * over the listview's items whenever the listview is redrawn. + */ + @Override + protected void dispatchDraw(Canvas canvas) { + super.dispatchDraw(canvas); + if (mHoverCell != null) { + mHoverCell.draw(canvas); + } + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if(listener != null) { + switch (event.getAction() & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_DOWN: + mDownX = (int) event.getX(); + mDownY = (int) event.getY(); + mActivePointerId = event.getPointerId(0); + mMode = TouchMode.UNKNOWN; + break; + case MotionEvent.ACTION_MOVE: + if (mActivePointerId == INVALID_POINTER_ID) { + break; + } + int pointerIndex = event.findPointerIndex(mActivePointerId); + mLastEventX = (int) event.getX(pointerIndex); + mLastEventY = (int) event.getY(pointerIndex); + int deltaX = mLastEventX - mDownX; + int deltaY = mLastEventY - mDownY; + + if (mMode == TouchMode.UNKNOWN) { + if (Math.abs(deltaX) > 50 || Math.abs(deltaY) > 50) { + if (Math.abs(deltaX) >= Math.abs(deltaY)) + mMode = TouchMode.REMOVE; + if (Math.abs(deltaX) < Math.abs(deltaY) && mDownX < SWAP_OFFSET) + mMode = TouchMode.SWAP; + + if (mMode != TouchMode.UNKNOWN) + startItemHover(); + } + } + + if (mMode == TouchMode.REMOVE) { + mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left + deltaX, + mHoverCellOriginalBounds.top); + mHoverCell.setBounds(mHoverCellCurrentBounds); + + if(mLastEventX + REMOVE_OFFSET > this.getRight()) + addBorder(mHoverCell.getBitmap(), Color.RED); + else + addBorder(mHoverCell.getBitmap(), Color.BLACK); + + invalidate(); + } else if (mMode == TouchMode.SWAP) { + if (mCellIsMobile) { + mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, + mHoverCellOriginalBounds.top + deltaY + mTotalOffset); + mHoverCell.setBounds(mHoverCellCurrentBounds); + invalidate(); + + handleCellSwitch(); + + mIsMobileScrolling = false; + handleMobileCellScroll(); + + return false; + } + } + break; + case MotionEvent.ACTION_UP: + touchEventsEnded(); + break; + case MotionEvent.ACTION_CANCEL: + touchEventsCancelled(); + break; + case MotionEvent.ACTION_POINTER_UP: + /* If a multitouch event took place and the original touch dictating + * the movement of the hover cell has ended, then the dragging event + * ends and the hover cell is animated to its corresponding position + * in the listview. */ + pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> + MotionEvent.ACTION_POINTER_INDEX_SHIFT; + final int pointerId = event.getPointerId(pointerIndex); + if (pointerId == mActivePointerId) { + touchEventsEnded(); + } + break; + default: + break; + } + } + return super.onTouchEvent(event); + } + + /** + * This method determines whether the hover cell has been shifted far enough + * to invoke a cell swap. If so, then the respective cell swap candidate is + * determined and the data set is changed. Upon posting a notification of the + * data set change, a layout is invoked to place the cells in the right place. + * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can + * offset the cell being swapped to where it previously was and then animate it to + * its new position. + */ + private void handleCellSwitch() { + final int deltaY = mLastEventY - mDownY; + int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY; + + View belowView = getViewForID(mBelowItemId); + View mobileView = getViewForID(mMobileItemId); + View aboveView = getViewForID(mAboveItemId); + + boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop()); + boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop()); + + if (isBelow || isAbove) { + + final long switchItemID = isBelow ? mBelowItemId : mAboveItemId; + View switchView = isBelow ? belowView : aboveView; + final int originalItem = getPositionForView(mobileView); + + if (switchView == null) { + updateNeighborViewsForID(mMobileItemId); + return; + } + + listener.swapItems(originalItem, getPositionForView(switchView)); + ((StableArrayAdapter) getAdapter()).notifyDataSetChanged(); + + mDownY = mLastEventY; + + mobileView.setVisibility(View.VISIBLE); + switchView.setVisibility(View.INVISIBLE); + + updateNeighborViewsForID(mMobileItemId); + + final int switchViewStartTop = switchView.getTop(); + final ViewTreeObserver observer = getViewTreeObserver(); + observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + public boolean onPreDraw() { + observer.removeOnPreDrawListener(this); + + View switchView = getViewForID(switchItemID); + + mTotalOffset += deltaY; + + int switchViewNewTop = switchView.getTop(); + int delta = switchViewStartTop - switchViewNewTop; + + switchView.setTranslationY(delta); + + ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, + View.TRANSLATION_Y, 0); + animator.setDuration(MOVE_DURATION); + animator.start(); + + return true; + } + }); + } + } + + /** + * Resets all the appropriate fields to a default state while also animating + * the hover cell back to its correct location. + */ + private void touchEventsEnded() { + final View mobileView = getViewForID(mMobileItemId); + if (mCellIsMobile || mIsWaitingForScrollFinish) { + mCellIsMobile = false; + mIsWaitingForScrollFinish = false; + mIsMobileScrolling = false; + mActivePointerId = INVALID_POINTER_ID; + + // If the autoscroller has not completed scrolling, we need to wait for it to + // finish in order to determine the final location of where the hover cell + // should be animated to. + if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { + mIsWaitingForScrollFinish = true; + return; + } + + if(mMode == TouchMode.REMOVE) { + if (mLastEventX + REMOVE_OFFSET > mobileView.getRight()) { + listener.removeItem(getPositionForView(mobileView)); + ((StableArrayAdapter) getAdapter()).notifyDataSetChanged(); + + mHoverCellCurrentBounds.offsetTo(this.getRight(), mHoverCellCurrentBounds.top); + } + else // reset + mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); + } + else if(mMode == TouchMode.SWAP) { + mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); + } + + // Animate + ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", + sBoundEvaluator, mHoverCellCurrentBounds); + hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + invalidate(); + } + }); + hoverViewAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + setEnabled(false); + } + + @Override + public void onAnimationEnd(Animator animation) { + mAboveItemId = INVALID_ID; + mMobileItemId = INVALID_ID; + mBelowItemId = INVALID_ID; + mobileView.setVisibility(VISIBLE); + mHoverCell = null; + setEnabled(true); + invalidate(); + } + }); + hoverViewAnimator.start(); + } else { + touchEventsCancelled(); + } + } + + /** + * Resets all the appropriate fields to a default state. + */ + private void touchEventsCancelled() { + View mobileView = getViewForID(mMobileItemId); + if (mCellIsMobile) { + mAboveItemId = INVALID_ID; + mMobileItemId = INVALID_ID; + mBelowItemId = INVALID_ID; + mobileView.setVisibility(VISIBLE); + mHoverCell = null; + invalidate(); + } + mCellIsMobile = false; + mIsMobileScrolling = false; + mActivePointerId = INVALID_POINTER_ID; + } + + /** + * This TypeEvaluator is used to animate the BitmapDrawable back to its + * final location when the user lifts his finger by modifying the + * BitmapDrawable's bounds. + */ + private final static TypeEvaluator sBoundEvaluator = new TypeEvaluator() { + public Rect evaluate(float fraction, Rect startValue, Rect endValue) { + return new Rect(interpolate(startValue.left, endValue.left, fraction), + interpolate(startValue.top, endValue.top, fraction), + interpolate(startValue.right, endValue.right, fraction), + interpolate(startValue.bottom, endValue.bottom, fraction)); + } + + public int interpolate(int start, int end, float fraction) { + return (int) (start + fraction * (end - start)); + } + }; + + /** + * Determines whether this listview is in a scrolling state invoked + * by the fact that the hover cell is out of the bounds of the listview; + */ + private void handleMobileCellScroll() { + mIsMobileScrolling = handleMobileCellScroll(mHoverCellCurrentBounds); + } + + /** + * This method is in charge of determining if the hover cell is above + * or below the bounds of the listview. If so, the listview does an appropriate + * upward or downward smooth scroll so as to reveal new items. + */ + public boolean handleMobileCellScroll(Rect r) { + int offset = computeVerticalScrollOffset(); + int height = getHeight(); + int extent = computeVerticalScrollExtent(); + int range = computeVerticalScrollRange(); + int hoverViewTop = r.top; + int hoverHeight = r.height(); + + if (hoverViewTop <= 0 && offset > 0) { + smoothScrollBy(-mSmoothScrollAmountAtEdge, 0); + return true; + } + + if (hoverViewTop + hoverHeight >= height && (offset + extent) < range) { + smoothScrollBy(mSmoothScrollAmountAtEdge, 0); + return true; + } + + return false; + } + + /** + * This scroll listener is added to the listview in order to handle cell swapping + * when the cell is either at the top or bottom edge of the listview. If the hover + * cell is at either edge of the listview, the listview will begin scrolling. As + * scrolling takes place, the listview continuously checks if new cells became visible + * and determines whether they are potential candidates for a cell swap. + */ + private AbsListView.OnScrollListener mScrollListener = new AbsListView.OnScrollListener() { + + private int mPreviousFirstVisibleItem = -1; + private int mPreviousVisibleItemCount = -1; + private int mCurrentFirstVisibleItem; + private int mCurrentVisibleItemCount; + private int mCurrentScrollState; + + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + mCurrentFirstVisibleItem = firstVisibleItem; + mCurrentVisibleItemCount = visibleItemCount; + + mPreviousFirstVisibleItem = (mPreviousFirstVisibleItem == -1) ? mCurrentFirstVisibleItem + : mPreviousFirstVisibleItem; + mPreviousVisibleItemCount = (mPreviousVisibleItemCount == -1) ? mCurrentVisibleItemCount + : mPreviousVisibleItemCount; + + checkAndHandleFirstVisibleCellChange(); + checkAndHandleLastVisibleCellChange(); + + mPreviousFirstVisibleItem = mCurrentFirstVisibleItem; + mPreviousVisibleItemCount = mCurrentVisibleItemCount; + } + + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + mCurrentScrollState = scrollState; + mScrollState = scrollState; + isScrollCompleted(); + } + + /** + * This method is in charge of invoking 1 of 2 actions. Firstly, if the listview + * is in a state of scrolling invoked by the hover cell being outside the bounds + * of the listview, then this scrolling event is continued. Secondly, if the hover + * cell has already been released, this invokes the animation for the hover cell + * to return to its correct position after the listview has entered an idle scroll + * state. + */ + private void isScrollCompleted() { + if (mCurrentVisibleItemCount > 0 && mCurrentScrollState == SCROLL_STATE_IDLE) { + if (mCellIsMobile && mIsMobileScrolling) { + handleMobileCellScroll(); + } else if (mIsWaitingForScrollFinish) { + touchEventsEnded(); + } + } + } + + /** + * Determines if the listview scrolled up enough to reveal a new cell at the + * top of the list. If so, then the appropriate parameters are updated. + */ + public void checkAndHandleFirstVisibleCellChange() { + if (mCurrentFirstVisibleItem != mPreviousFirstVisibleItem) { + if (mCellIsMobile && mMobileItemId != INVALID_ID) { + updateNeighborViewsForID(mMobileItemId); + handleCellSwitch(); + } + } + } + + /** + * Determines if the listview scrolled down enough to reveal a new cell at the + * bottom of the list. If so, then the appropriate parameters are updated. + */ + public void checkAndHandleLastVisibleCellChange() { + int currentLastVisibleItem = mCurrentFirstVisibleItem + mCurrentVisibleItemCount; + int previousLastVisibleItem = mPreviousFirstVisibleItem + mPreviousVisibleItemCount; + if (currentLastVisibleItem != previousLastVisibleItem) { + if (mCellIsMobile && mMobileItemId != INVALID_ID) { + updateNeighborViewsForID(mMobileItemId); + handleCellSwitch(); + } + } + } + }; + + public static interface DynamicListActionListener{ + public void swapItems(int from, int to); + public void removeItem(int which); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ericsson/uecontrol/gui/util/StableArrayAdapter.java b/app/src/main/java/com/ericsson/uecontrol/gui/util/StableArrayAdapter.java new file mode 100755 index 0000000..b2d3db0 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/gui/util/StableArrayAdapter.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.ericsson.uecontrol.gui.util; + +import android.content.Context; +import android.widget.ArrayAdapter; + +import java.util.HashMap; +import java.util.List; + +public class StableArrayAdapter extends ArrayAdapter implements DynamicListView.DynamicListActionListener { + + final int INVALID_ID = -1; + + private HashMap mIdMap = new HashMap(); + private List objects; + + public StableArrayAdapter(Context context, int textViewResourceId, List obj) { + super(context, textViewResourceId, obj); + objects = obj; + generateIds(); + } + + public void generateIds(){ + mIdMap.clear(); + for (int i = 0; i < objects.size(); ++i) { + mIdMap.put(objects.get(i), i); + } + } + + + @Override + public long getItemId(int position) { + if (position < 0 || position >= mIdMap.size()) { + return INVALID_ID; + } + T item = getItem(position); + return mIdMap.get(item); + } + + @Override + public void swapItems(int from, int to) { + T temp = objects.get(from); + objects.set(from, objects.get(to)); + objects.set(to, temp); + } + + @Override + public void removeItem(int which) { + objects.remove(which); + generateIds(); + } + + @Override + public boolean hasStableIds() { + return true; + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/draggable.png b/app/src/main/res/drawable-hdpi/draggable.png new file mode 100755 index 0000000..22bd646 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/draggable.png differ diff --git a/app/src/main/res/drawable-hdpi/drawer_shadow.9.png b/app/src/main/res/drawable-hdpi/drawer_shadow.9.png new file mode 100755 index 0000000..236bff5 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/drawer_shadow.9.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_drawer.png b/app/src/main/res/drawable-hdpi/ic_drawer.png new file mode 100755 index 0000000..c59f601 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_drawer.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_launcher.png b/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100755 index 0000000..96a442e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/drawable-mdpi/drawer_shadow.9.png b/app/src/main/res/drawable-mdpi/drawer_shadow.9.png new file mode 100755 index 0000000..ffe3a28 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/drawer_shadow.9.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_drawer.png b/app/src/main/res/drawable-mdpi/ic_drawer.png new file mode 100755 index 0000000..1ed2c56 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_drawer.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_launcher.png b/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100755 index 0000000..359047d Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png new file mode 100755 index 0000000..fabe9d9 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_drawer.png b/app/src/main/res/drawable-xhdpi/ic_drawer.png new file mode 100755 index 0000000..a5fa74d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_drawer.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_launcher.png b/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100755 index 0000000..71c6d76 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png b/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png new file mode 100755 index 0000000..b91e9d7 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_drawer.png b/app/src/main/res/drawable-xxhdpi/ic_drawer.png new file mode 100755 index 0000000..9c4685d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_drawer.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/app/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100755 index 0000000..4df1894 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml new file mode 100755 index 0000000..bd4f494 --- /dev/null +++ b/app/src/main/res/layout/activity_edit.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100755 index 0000000..3fd1db4 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/behaviour_list_item.xml b/app/src/main/res/layout/behaviour_list_item.xml new file mode 100755 index 0000000..6c1924e --- /dev/null +++ b/app/src/main/res/layout/behaviour_list_item.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_item_list.xml b/app/src/main/res/layout/fragment_item_list.xml new file mode 100755 index 0000000..76c0d0e --- /dev/null +++ b/app/src/main/res/layout/fragment_item_list.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/layout/fragment_navigation_drawer.xml b/app/src/main/res/layout/fragment_navigation_drawer.xml new file mode 100755 index 0000000..5250946 --- /dev/null +++ b/app/src/main/res/layout/fragment_navigation_drawer.xml @@ -0,0 +1,9 @@ + diff --git a/app/src/main/res/layout/fragment_status.xml b/app/src/main/res/layout/fragment_status.xml new file mode 100755 index 0000000..fe7fdc1 --- /dev/null +++ b/app/src/main/res/layout/fragment_status.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/edit.xml b/app/src/main/res/menu/edit.xml new file mode 100755 index 0000000..bc04ac5 --- /dev/null +++ b/app/src/main/res/menu/edit.xml @@ -0,0 +1,9 @@ +

+ + + + diff --git a/app/src/main/res/menu/global.xml b/app/src/main/res/menu/global.xml new file mode 100755 index 0000000..f3b10b6 --- /dev/null +++ b/app/src/main/res/menu/global.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml new file mode 100755 index 0000000..cc45837 --- /dev/null +++ b/app/src/main/res/menu/main.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100755 index 0000000..63fc816 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100755 index 0000000..72e574b --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,8 @@ + + + + com.ericsson.uecontrol.core.behaviour.UeBehaviourSleep + com.ericsson.uecontrol.core.behaviour.UeBehaviourSurfing + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100755 index 0000000..074e7a0 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,9 @@ + + + 16dp + 16dp + + + 240dp + diff --git a/app/src/main/res/values/refs.xml b/app/src/main/res/values/refs.xml new file mode 100755 index 0000000..4b596c9 --- /dev/null +++ b/app/src/main/res/values/refs.xml @@ -0,0 +1,12 @@ + + + + @layout/fragment_item_list + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100755 index 0000000..9e0e231 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,25 @@ + + + UeControl + Section 1 + Section 2 + Section 3 + Open navigation drawer + Close navigation drawer + Run + Stop + Edit + Import + Export + Settings + Execution Settings + Simulate + The execution will be simulated, no actual data will be transferred. + Other Settings + Edit + Add + Select Behaviour + Configure Behaviour + Save + Cancel + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100755 index 0000000..ff6c9d2 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml new file mode 100755 index 0000000..1b27a3a --- /dev/null +++ b/app/src/main/res/xml/preferences.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100755 index 0000000..a75fc81 --- /dev/null +++ b/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:0.12.+' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100755 index 0000000..5d08ba7 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Settings specified in this file will override any Gradle settings +# configured through the IDE. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000..8c0fb64 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000..1e61d1f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100755 index 0000000..8a0b282 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100755 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'