Coder Social home page Coder Social logo

augmify / genius-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qiujuer/genius-android

0.0 0.0 0.0 18.16 MB

Android Material theme and Tool library.

Home Page: http://www.qiujuer.net

License: Apache License 2.0

Java 97.57% Makefile 0.08% C 2.35%

genius-android's Introduction

Android Arsenal

Version 2.2.0 Guide

GitHub OSChina

中文 English Guides Sample

##What is Genius-Android?

icon

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

Button

GeniusUI

EditText

GeniusUI

All

GeniusUI

BlurKit

BlurKit

ThemeColors

ThemeColors

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 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:
// Adding to your project "build.gradle" file
dependencies {
  compile 'com.github.qiujuer:genius:2.2.0'
}

Update Log

  • Version: 2.2.0
  • Date: 2015-01-30
  • Log: Notes

Method of application

Initialization and destruction
Genius.initialize(Application application);
Genius.dispose();
widget module
// First of all specified in the root container:
<LinearLayout
    ...
    xmlns:genius="http://schemas.android.com/apk/res-auto"/>

// The theme style: see screenshot
// Provide the font: `opensans` `roboto`
// The font size: `bold` `extrabold` `extralight` `light` `regular`

// ==================Global Attribute=================
<net.qiujuer.genius.widget.all
    ...
    genius:g_textAppearance="light"
    genius:g_fontFamily="opensans"
    genius:g_fontWeight="bold"
    genius:g_fontExtension="ttf"
    genius:g_borderWidth="5dp"
    genius:g_theme="@array/StrawberryIce"
    genius:g_cornerRadius="5dp"
    genius:g_cornerRadii_A="10dp"
    genius:g_cornerRadii_B="10dp"
    genius:g_cornerRadii_C="10dp"
    genius:g_cornerRadii_D="10dp"/>

// `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==================
<net.qiujuer.genius.widget.GeniusButton
    ...
    genius:g_delayClick="true"
    genius:g_touchEffect="move"
    genius:g_touchEffectColor="#ff4181ff"
    genius:g_blockButtonEffectHeight="10dp" />

// `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==================
<net.qiujuer.genius.widget.GeniusCheckBox
    ...
    genius:g_ringWidth="2dp"
    genius:g_circleRadius="22dp"
    genius:g_checked="true"
    genius:g_enabled="true" />

// `g_ringWidth`: Ring width
// `g_circleRadius`: The center of the circle radius
// `g_checked`: Is checked
// `g_enabled`: Is allow click

// ==================GeniusTextView==================
<net.qiujuer.genius.widget.GeniusTextView
    ...
    genius:g_textColor="light"
    genius:g_backgroundColor="dark"
    genius:g_customBackgroundColor="#FFFFFF" />

// `g_textColor`: Font color type
// `g_backgroundColor`: Background color type
// `g_customBackgroundColor`: Background color

// ==================GeniusEditText==================
<net.qiujuer.genius.widget.GeniusEditText
    ...
    genius:g_fieldStyle="fill"
    genius:g_showTitle="true"
    genius:g_titleTextColor="#ff1fedff"
    genius:g_titleTextSize="12sp"
    genius:g_titlePaddingTop="5dp"
    genius:g_titlePaddingLeft="5dp" />

// `g_fieldStyle`: Style: `fill` `box` `transparent`
// `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
app module
// "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 模块
// 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
// 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
// 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
// ===================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<Integer> list = new FixedList<Integer>(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<Integer> list1 = new FixedList<Integer>(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

    <!-- Internet permission -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Log file permission -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <!-- getDeviceId permission -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    

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

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: [email protected]); No money holds personal field, thank you.

About me

  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.

genius-android's People

Contributors

qiujuer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.