├── .gitignore ├── LICENSE ├── README.md ├── app-debug.apk ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ihongqiqu │ │ └── sharewifi │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── ihongqiqu │ │ │ └── sharewifi │ │ │ ├── MainActivity.java │ │ │ └── WifiAPMgr.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── ihongqiqu │ └── sharewifi │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | # *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | /.idea/ 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## OneKeyShareWifi 2 | 3 | Android 一键建立热点,并生成用户名和密码。 4 | 5 | 产品提了一个需求,希望在手机上能够一键共享自己的移动网络。且希望用户能够通过扫描二维码链接上网络。 6 | 7 | ### 思路 8 | 9 | 经过各种谷歌和文档资料查询,发现 Android 的 API 是不支持对 AP 的操作。但是,这是难不倒我们的工程师的,通过谷歌搜索出来很多通过反射来管理 AP 的方法。这样第一个问题就算解决了。 10 | 11 | 然而,想要实现任何应用扫码连接共享的网络,有很多问题。二维码其实就是一个字符串的一种展现形式。想通过二维码链接网络,其实就是想通过一个字符串来改变世界啊!现在用户量较大的扫二维码应用都会有一些自己的协议,要实现我们的功能,我们必须要选择了通用的协议。扫二维码通用的协议,想来想去就只有链接地址了。一般扫码应用都是支持打开链接地址的。接下来的任务就要交给我们的 H5。想要通过 H5 来实现连接 WiFi 这个功能是不现实(不知道利用 H5 的漏洞能不能搞)。其实如果用户没有网络,二维码携带任何信息都没有什么卵用的。 12 | 13 | 通过反射技术来实现对热点的开关控制实现并不复杂,接下来简单介绍一下。 14 | 15 | ### 实现功能 16 | 17 | 一键建立热点主要需要实现如下功能: 18 | 19 | 1. 获取当前 AP 的开关状态 20 | 2. 打开和关闭 AP 21 | 22 | ### 实现代码 23 | 24 | 检测 AP 的状态,通过反射实现: 25 | 26 | ```java 27 | /** 28 | * check whether wifi hotspot on or off 29 | */ 30 | public boolean isApOn() { 31 | try { 32 | Method method = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled"); 33 | method.setAccessible(true); 34 | return (Boolean) method.invoke(wifiManager); 35 | } 36 | catch (Throwable ignored) {} 37 | return false; 38 | } 39 | ``` 40 | 41 | 打开和关闭 AP,反射实现代码如下: 42 | 43 | ```java 44 | /** 45 | * wifi热点开关 46 | * 47 | * @param enabled true:打开 false:关闭 48 | * @return true:成功 false:失败 49 | */ 50 | public boolean setWifiApEnabled(boolean enabled) { 51 | if (BuildConfig.DEBUG) Log.d("WifiAPMgr", "开启热点"); 52 | if (enabled) { 53 | // wifi和热点不能同时打开,所以打开热点的时候需要关闭wifi 54 | wifiManager.setWifiEnabled(false); 55 | if (BuildConfig.DEBUG) Log.d("WifiAPMgr", "关闭wifi"); 56 | } else { 57 | // wifiManager.setWifiEnabled(true); 58 | } 59 | try { 60 | // 热点的配置类 61 | WifiConfiguration apConfig = new WifiConfiguration(); 62 | // 配置热点的名称(可以在名字后面加点随机数什么的) 63 | apConfig.SSID = apName; 64 | // 配置热点的密码 65 | apConfig.preSharedKey = apPwd; 66 | // 安全:WPA2_PSK 67 | apConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 68 | // 通过反射调用设置热点 69 | Method method = wifiManager.getClass().getMethod( 70 | "setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE); 71 | // 返回热点打开状态 72 | return (Boolean) method.invoke(wifiManager, apConfig, enabled); 73 | } catch (Exception e) { 74 | return false; 75 | } 76 | } 77 | ``` 78 | 79 | ### 效果展示 80 | 81 | 下载 APK 安装体验,下载地址: 82 | [https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/master/app-debug.apk](https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/master/app-debug.apk) 83 | 84 | ### 源码地址 85 | 86 | [https://github.com/jingle1267/OneKeyShareWifi](https://github.com/jingle1267/OneKeyShareWifi) 87 | 88 | ### 参考地址: 89 | 90 | 1. [http://stackoverflow.com/questions/6394599/android-turn-on-off-wifi-hotspot-programmatically](http://stackoverflow.com/questions/6394599/android-turn-on-off-wifi-hotspot-programmatically) 91 | 2. [http://blog.csdn.net/u013049709/article/details/42235829](http://blog.csdn.net/u013049709/article/details/42235829) 92 | -------------------------------------------------------------------------------- /app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app-debug.apk -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | applicationId "com.ihongqiqu.sharewifi" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.1.0' 28 | compile 'com.android.support:support-v4:25.1.0' 29 | testCompile 'junit:junit:4.12' 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/zhenguo/Documents/develop/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ihongqiqu/sharewifi/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.ihongqiqu.sharewifi; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumentation test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() throws Exception { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getTargetContext(); 24 | 25 | assertEquals("com.ihongqiqu.sharewifi", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/ihongqiqu/sharewifi/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.ihongqiqu.sharewifi; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | import android.widget.Toast; 8 | import android.widget.ToggleButton; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | ToggleButton tb_wifi_switch; 13 | TextView tv_ap_info; 14 | 15 | WifiAPMgr mWifiAPMgr; 16 | 17 | String apName = "freeWifi"; 18 | String apPwd = "987654321"; 19 | 20 | Toast mToast; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | mWifiAPMgr = new WifiAPMgr(this, apName, apPwd); 28 | tb_wifi_switch = (ToggleButton) findViewById(R.id.tb_wifi_switch); 29 | tv_ap_info = (TextView) findViewById(R.id.tv_ap_info); 30 | 31 | tb_wifi_switch.setChecked(mWifiAPMgr.isApOn()); 32 | 33 | mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT); 34 | 35 | } 36 | 37 | public void onClick(View view) { 38 | switch (view.getId()) { 39 | case R.id.tb_wifi_switch: 40 | boolean isOn = mWifiAPMgr.isApOn(); 41 | boolean isSuccess = mWifiAPMgr.setWifiApEnabled(!isOn); 42 | StringBuilder msg = new StringBuilder(); 43 | msg.append(isOn ? "关闭" : "开启").append("AP").append(isSuccess ? "成功" : "失败"); 44 | mToast.setText(msg); 45 | mToast.show(); 46 | if (!isOn && isSuccess) { 47 | tv_ap_info.setText("热点名称:" + apName + "\n" 48 | + "热点密码:" + apPwd); 49 | tv_ap_info.setVisibility(View.VISIBLE); 50 | } else { 51 | tv_ap_info.setVisibility(View.INVISIBLE); 52 | } 53 | break; 54 | } 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/ihongqiqu/sharewifi/WifiAPMgr.java: -------------------------------------------------------------------------------- 1 | package com.ihongqiqu.sharewifi; 2 | 3 | import android.content.Context; 4 | import android.net.wifi.WifiConfiguration; 5 | import android.net.wifi.WifiManager; 6 | import android.util.Log; 7 | import java.lang.reflect.Method; 8 | 9 | /** 10 | * wifi AP 管理类 11 | * 提供 AP 状态,开关 AP 12 | *

13 | * Created by zhenguo on 1/11/17. 14 | */ 15 | public class WifiAPMgr { 16 | 17 | private final String TAG = WifiAPMgr.class.getSimpleName(); 18 | 19 | private WifiManager wifiManager; 20 | 21 | private static String apName = "freeAP"; 22 | // 密码必须大于8位数 23 | private static String apPwd = "123456789"; 24 | 25 | public WifiAPMgr(Context context) { 26 | this(context, apName, apPwd); 27 | } 28 | 29 | public WifiAPMgr(Context context, String apPwd, String apName) { 30 | wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 31 | WifiAPMgr.apName = apName; 32 | WifiAPMgr.apPwd = apPwd; 33 | } 34 | 35 | /** 36 | * 判断热点开启状态 37 | */ 38 | public boolean isWifiApEnabled() { 39 | return getWifiApState() == WIFI_AP_STATE.WIFI_AP_STATE_ENABLED; 40 | } 41 | 42 | private WIFI_AP_STATE getWifiApState() { 43 | int tmp; 44 | try { 45 | Method method = wifiManager.getClass().getMethod("getWifiApState"); 46 | tmp = ((Integer) method.invoke(wifiManager)); 47 | // Fix for Android 4 48 | if (tmp > 10) { 49 | tmp = tmp - 10; 50 | } 51 | return WIFI_AP_STATE.class.getEnumConstants()[tmp]; 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | return WIFI_AP_STATE.WIFI_AP_STATE_FAILED; 55 | } 56 | } 57 | 58 | public enum WIFI_AP_STATE { 59 | WIFI_AP_STATE_DISABLING, 60 | WIFI_AP_STATE_DISABLED, 61 | WIFI_AP_STATE_ENABLING, 62 | WIFI_AP_STATE_ENABLED, 63 | WIFI_AP_STATE_FAILED 64 | } 65 | 66 | /** 67 | * check whether wifi hotspot on or off 68 | */ 69 | public boolean isApOn() { 70 | try { 71 | Method method = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled"); 72 | method.setAccessible(true); 73 | return (Boolean) method.invoke(wifiManager); 74 | } 75 | catch (Throwable ignored) {} 76 | return false; 77 | } 78 | 79 | /** 80 | * wifi热点开关 81 | * 82 | * @param enabled true:打开 false:关闭 83 | * @return true:成功 false:失败 84 | */ 85 | public boolean setWifiApEnabled(boolean enabled) { 86 | if (BuildConfig.DEBUG) Log.d("WifiAPMgr", "开启热点"); 87 | if (enabled) { 88 | // wifi和热点不能同时打开,所以打开热点的时候需要关闭wifi 89 | wifiManager.setWifiEnabled(false); 90 | if (BuildConfig.DEBUG) Log.d("WifiAPMgr", "关闭wifi"); 91 | } else { 92 | // wifiManager.setWifiEnabled(true); 93 | } 94 | try { 95 | // 热点的配置类 96 | WifiConfiguration apConfig = new WifiConfiguration(); 97 | // 配置热点的名称(可以在名字后面加点随机数什么的) 98 | apConfig.SSID = apName; 99 | // 配置热点的密码 100 | apConfig.preSharedKey = apPwd; 101 | // 安全:WPA2_PSK 102 | apConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 103 | // 通过反射调用设置热点 104 | Method method = wifiManager.getClass().getMethod( 105 | "setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE); 106 | // 返回热点打开状态 107 | return (Boolean) method.invoke(wifiManager, apConfig, enabled); 108 | } catch (Exception e) { 109 | return false; 110 | } 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 22 | 23 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #66000000 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | sharewifi 3 | 4 | Dummy Button 5 | DUMMY\nCONTENT 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/test/java/com/ihongqiqu/sharewifi/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.ihongqiqu.sharewifi; 2 | 3 | import org.junit.Test; 4 | 5 | 6 | import static org.junit.Assert.*; 7 | 8 | /** 9 | * Example local unit test, which will execute on the development machine (host). 10 | * 11 | * @see Testing documentation 12 | */ 13 | public class ExampleUnitTest { 14 | @Test 15 | public void addition_isCorrect() throws Exception { 16 | assertEquals(4, 2 + 2); 17 | } 18 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jingle1267/OneKeyShareWifi/894b64d8d47f068345b227dda62b0bc8b184f478/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------