# Genius-Android **Repository Path**: fengwu/Genius-Android ## Basic Information - **Project Name**: Genius-Android - **Description**: Android Material theme and Tool library. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: http://www.qiujuer.net - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 56 - **Created**: 2015-03-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Genius--Android-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1463) ## Version 2.3.1 Guide [`GitHub`](https://github.com/qiujuer/Genius-Android) [`OSChina`](http://git.oschina.net/qiujuer/Genius-Android) [`中文`](README-ZH.md) [`English`](README.md) [`Guides`](/docs/guides/GuideCatalog.md) [`Sample`](/release/sample.apk) ##What is Genius-Android? ![icon](art/launcher.png) **Genius-Android** is some of the commonly used method in **Android** collection, **Genius** library provide five basic plate : * `app` (**Ui**) * `animation` (**Animation**) * `widget` (**Material Widget**) * `command` (**Command Line**) * `net tool` (**Ping、Dns...**) * `util` (**Common Method,Class**) ## Screenshots ##### GeniusUI ###### CheckBox ![GeniusUI](art/ui_checkbox.gif) ###### Button ![GeniusUI](art/ui_button.gif) ###### EditText ![GeniusUI](art/ui_edittext.gif) ###### All ![GeniusUI](art/ui_all.png) ##### BlurKit ![BlurKit](art/blur_kit.png) ##### ThemeColors ![ThemeColors](art/theme_colors.png) ## Function modules * `app` > * `UIKit` support the child thread `synchronization` `asynchronous` switching to the main thread > * `BlurKit` support `Java` `Jni` use the `StackBlur` algorithm fuzzy images * `animation` > * `TouchEffectAnimator` Can add click to control effects > * `TouchEffectEnum` Press, Move, Ripple, Ease, None * `widget` > * Fonts `opensans` `roboto` > * Colors `none` `dark` `darker` `light` > * Controls `GeniusButton` `GeniusCheckBox` `GeniusTextView` `GeniusEditText` * `command` > * Independent service command-line work process execution > * Similar to the `ProcessBuilder` operation > * Intelligent correct operation, solve the operation problem > * One key start and cancel the operation, control of freedom > * Can be synchronous and asynchronous execution, the callback event * `net tool` > * One key `Ping` `DNS` `TelNet` `TraceRoute` > * Can be controlled, can be cancelled;Don't need to care about the details > * Concurrent routing tasks, can be in around 40 s testing is completed * `util` > * `AppContext` Global variables, access convenient and quick > * `HashUtils` String with the file `MD5` > * `Tools` `ID` `SN` Determine the device unique identifier > * `Log` Such as system Log as simple to use, one key switch > * `Log` Can store the log to a file, convenient analysis errors > * `Log` You can add event listeners, convenient interface display log information > * `FixedList` Fixed-length queue, automatic pop-up, keep the queue number ## Get library * `Star` and `Fork` this project. * `MavenCentral` remote import: ```gradle // Adding to your project "build.gradle" file dependencies { compile 'com.github.qiujuer:genius:2.3.1' } ``` ## Update Log * Version: `2.3.1` * Date: `2015-02-12` * Log: [`Notes`](docs/NOTES.md) ## Method of application ##### Initialization and destruction ```java Genius.initialize(Application application); Genius.dispose(); ``` ##### `widget` module ```xml // First of all specified in the root container: // The theme style: see screenshot // Provide the font: `opensans` `roboto` // The font size: `bold` `extrabold` `extralight` `light` `regular` // ==================Global Attribute================= // `g_textAppearance`: Specify the font color, the default for ` none ` // `g_fontFamily`: Specify a font of two kinds of fonts // `g_fontWeight`: The specified font weight // `g_fontExtension`: The font extension // `g_borderWidth`: Border width // `g_theme`: Specify the subject style, 17 kinds of arbitrary choice // `g_cornerRadius`: Arc radius, default: ` 0` // `g_cornerRadii`: Arc radius, four angles(A,B,C,D)radius, default: `0` // ==================GeniusButton================== // `g_delayClick`: Delayed response to the click event, Default "True" // `g_touchEffect`: press, move, ease, ripple, none // `g_touchEffectColor`: TouchEffectColor,Invalid when `g_touchEffect` is 'None' // `g_blockButtonEffectHeight`: The button shadow height // ==================GeniusCheckBox================== // `g_ringWidth`: Ring width // `g_circleRadius`: The center of the circle radius // `g_checked`: Is checked // `g_enabled`: Is allow click // Note: If you want to change color, you should use Attributes method "setColors" // And call Attribute.notifyAttributeChange() method // ==================GeniusTextView================== // `g_textColor`: Font color type // `g_backgroundColor`: Background color type // `g_customBackgroundColor`: Background color // ==================GeniusEditText================== // `g_fieldStyle`: Style: `fill` `box` `transparent` `line` // `g_showTitle`: If show Hint Title // `g_titleTextColor`: Title font color // `g_titleTextSize`: Title font size // `g_titlePaddingTop`: Title padding to top // `g_titlePaddingLeft`: Title padding to left ``` ```java // Code to set widget GeniusCheckBox box = new GeniusCheckBox(this); box.setChecked(!box.isChecked()); // Theme CheckBoxAttributes attr = box.getAttributes(); attr.setRingWidth(4); attr.setCircleRadius(22); attr.setTheme(R.array.StrawberryIce, getResources()); // Or // Color is Darker, Dark, Primary, Light, Translucence, Transparent attr.setColors(new int[]{ Color.parseColor("#ffc26165"), Color.parseColor("#ffdb6e77"), Color.parseColor("#ffef7e8b"), Color.parseColor("#fff7c2c8"), Color.parseColor("#ffc2cbcb"), Color.parseColor("#ffe2e7e7")}); // End attr.notifyAttributeChange(); ``` ##### `app` module ```java // "Runnable" implementation method "run()" // "run()" run in the main thread, the can interface // Synchronization to enter the main thread, waiting for the main thread processing to continue after the completion of the subprocess UIKit.runOnMainThreadSync(Runnable runnable); // Asynchronous into the main thread, without waiting for UIKit.runOnMainThreadAsync(Runnable runnable); // Synchronously But the child thread just wait for the waitTime long // @param runnable Runnable Interface // @param waitTime wait for the main thread run Time // @param cancel on the child thread cancel the runnable task UIKit.runOnMainThreadSync(Runnable runnable, int waitTime, boolean cancel) // "bitmap" is to be processed images // "radius" is picture is fuzzy radius // "canReuseInBitmap" Whether directly using the "bitmap" fuzzy, // "false" will copy the "bitmap" to doing fuzzy // Java blur BlurKit.blur(Bitmap bitmap, int radius, boolean canReuseInBitmap); // Jni blur, To the Jni is a kind of Bitmap images BlurKit.blurNatively(Bitmap bitmap, int radius, boolean canReuseInBitmap); // Jni blur, To the Jni is image collection "pixel" BlurKit.blurNativelyPixels(Bitmap bitmap, int radius, boolean canReuseInBitmap); ``` ##### `animation` 模块 ```java // TouchEffectAnimator Allowed to add click on special effects to your control // Types: Press, Move, Ease, Ripple, None public class GeniusButton extends Button { private TouchEffectAnimator touchEffectAnimator = null; // Initialize public void initTouchEffect(TouchEffect touchEffect) { touchEffectAnimator = new TouchEffectAnimator(this); // Set model touchEffectAnimator.setTouchEffect(touchEffect); // Set Color touchEffectAnimator.setEffectColor("color"); // Set this clip radius touchEffectAnimator.setClipRadius(20); // Same as above, Set up four vertices radian touchEffectAnimator.setClipRadii(new float[]{20,20,20,20,20,20,20,20}); // Set animation time factor, you need to set up setTouchEffect() after the call touchEffectAnimator.setAnimDurationFactor(1); } // Delay click event (optional) @Override public boolean performClick() { if (touchEffectAnimator != null) { return !touchEffectAnimator.interceptClick() && super.performClick(); } else return super.performClick(); } // Callback onDraw @Override protected void onDraw(Canvas canvas) { if (touchEffectAnimator != null) touchEffectAnimator.onDraw(canvas); super.onDraw(canvas); } // Callback onTouchEvent @Override public boolean onTouchEvent(MotionEvent event) { if (touchEffectAnimator != null) touchEffectAnimator.onTouchEvent(event); return super.onTouchEvent(event); } } ``` ##### `command` module ```java // Execute the command, the background service automatic control // The same way call way and the ProcessBuilder mass participation // Timeout: Task timeout, optional parameters // Params: executing params,such as: "/system/bin/ping","-c", "4", "-s", "100","www.baidu.com" Command command = new Command(int timeout, String... params); // Synchronous // After the completion of the results returned directly String result = Command.command(new Command(Command.TIMEOUT, "...")); // Asynchronous // Results to event callback method returns Command command = new Command("..."); Command.command(command, new Command.CommandListener() { @Override public void onCompleted(String str) { } @Override public void onCancel() { } @Override public void onError(Exception e) { } }); // To cancel a task command Command.cancel(Command command); // Restart the Command service Command.restart(); // Destroy // Using 'Genius.dispose()' method is run this destroy Command.dispose(); ``` ##### `net tool` module ```java // Ping // Introduced to the domain name or IP // Result: delay, packet loss Ping ping = new Ping("www.baidu.com"); // Start ping.start(); // Return if (ping.getError() == NetModel.SUCCEED) {} else {} ... Others similarly ... ``` ##### `util` module ```java // ===================FixedList=================== // Fixed length queue // Can specify length, using methods similar to ordinary queue // When join the element number to a specified number elements will pop up // Insert the tail pop-up head, tail insertion head pops up // Initialize the maximum length of 5 FixedList list = new FixedList(5); // To obtain the maximum capacity list.getMaxSize(); // Adjust the maximum length; Narrow length will be automatically deleted when the head redundant elements list.setMaxSize(3); // Using List to operation List list1 = new FixedList(2); // ====================HashUtils================== // Hash to calculate(Md5) // String with the file can be calculated Md5 value // Get the MD5 String hash = HashUtils.getMD5String(String str); // Access to the file MD5 String hash = HashUtils.getMD5String(File file); // ======================Log====================== // Log class // Calls the method with using Android as the default method // Can be set if the store log information // Can copy the log information to SD card // Can add the event callback in the main interface, the interface, real-time display the log // Add a callback // The callback class Log.LogCallbackListener listener = new LogCallbackListener() { @Override public void onLogArrived(Log data) { ... } }; // Adding Log.addCallbackListener(listener); // Whether Android call system Log, can control whether to display Log.setCallLog(true); // Is open to a file, the file number, a single file size (Mb) // The default is stored in the application directory is /Genius/Logs Log.setSaveLog(true, 10, 1); // Set whether to monitor external storage inserts // Open: insert an external device (SD), will copy the log files to external storage // This operation depends on whether written to the file open function, not open, this method is invalid Log.setCopyExternalStorage(true, "Test/Logs"); // Copies of internal storage log files to external storage(SD) // This operation depends on whether written to the file open function, not open, this method is invalid Log.copyToExternalStorage("Test/Logs"); // Set the log level // ALL(show all),VERBOSE to ERROR decreasing Log.setLevel(Log.ALL); // Add log Log.d(TAG, "DEBUG "); // ====================Tools==================== // Commonly used toolkit // Are all static methods, later will continue to add // Thread sleep Tools.sleepIgnoreInterrupt(long time); // Copy the files Tools.copyFile(File source, File target); // AndroidId Tools.getAndroidId(Context context); // SN Id Tools.getSerialNumber(); ``` ## Permission ```xml ``` ## Developer Download the project, the project can be imported into `Android Studio`, Android Studio >= 1.0 Project which contains a library and a test project, the library can be imported into your own project use. `Eclipse` Cannot import directly in the program, please create a project in accordance with the corresponding category replacement to their projects. ## Feedback You in use if you have any question, please timely feedback to me, you can use the following contact information to communicate with me * Project: [`Submit Bug or Idea`](https://github.com/qiujuer/Genius-Android/issues) * Email: [`qiujuer@live.cn`](mailto:qiujuer@live.cn) * QQ: `756069544` * QQ Group: [`387403637`](http://shang.qq.com/wpa/qunwpa?idkey=3f1ed8e41ed84b07775ca593032c5d956fbd8c3320ce94817bace00549d58a8f) * WeiBo: [`@qiujuer`](http://weibo.com/qiujuer) * WebSit:[`www.qiujuer.net`](http://www.qiujuer.net) ## Giving developers Are interested in and write a `free`, have joy, also there is sweat, I hope you like my work, but also can support it. Of course, rich holds a money (AliPay: `qiujuer@live.cn`); No money holds personal field, thank you. ## About me ```javascript var info = { nickName : "qiujuer", site : "http://www.qiujuer.net" } ``` License -------- Copyright 2014 CengaLabs. 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.