getCustomDNSServers() {
if (customDNSServers == null) {
customDNSServers = new ArrayList<>();
}
diff --git a/app/src/main/java/org/itxtech/daedalus/util/DnsServersDetector.java b/app/src/main/java/org/itxtech/daedalus/util/DnsServersDetector.java
new file mode 100644
index 0000000..1f24bef
--- /dev/null
+++ b/app/src/main/java/org/itxtech/daedalus/util/DnsServersDetector.java
@@ -0,0 +1,166 @@
+package org.itxtech.daedalus.util;
+
+import android.content.Context;
+import android.net.*;
+import android.os.Build;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Daedalus Project
+ *
+ * @author iTX Technologies
+ * @link https://itxtech.org
+ *
+ * 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.
+ */
+public class DnsServersDetector {
+ //https://stackoverflow.com/a/48973823
+ private static final String METHOD_EXEC_PROP_DELIM = "]: [";
+
+ public static String[] getServers(Context context) {
+ String[] result;
+ result = getServersMethodSystemProperties();
+ if (result != null && result.length > 0) {
+ return result;
+ }
+ result = getServersMethodConnectivityManager(context);
+ if (result != null && result.length > 0) {
+ return result;
+ }
+ result = getServersMethodExec();
+ if (result != null && result.length > 0) {
+ return result;
+ }
+ return null;
+ }
+
+ private static String[] getServersMethodConnectivityManager(Context context) {
+ ArrayList priorityServersArrayList = new ArrayList<>();
+ ArrayList serversArrayList = new ArrayList<>();
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivityManager != null) {
+ for (Network network : connectivityManager.getAllNetworks()) {
+ NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
+ if (networkInfo.isConnected()) {
+ LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
+ List dnsServersList = linkProperties.getDnsServers();
+ if (linkPropertiesHasDefaultRoute(linkProperties)) {
+ for (InetAddress element : dnsServersList) {
+ String dnsHost = element.getHostAddress();
+ priorityServersArrayList.add(dnsHost);
+ }
+ } else {
+ for (InetAddress element : dnsServersList) {
+ String dnsHost = element.getHostAddress();
+ serversArrayList.add(dnsHost);
+ }
+ }
+ }
+ }
+ }
+ if (priorityServersArrayList.isEmpty()) {
+ priorityServersArrayList.addAll(serversArrayList);
+ }
+ if (priorityServersArrayList.size() > 0) {
+ return priorityServersArrayList.toArray(new String[0]);
+ }
+ return null;
+ }
+
+ private static String[] getServersMethodSystemProperties() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ String re1 = "^\\d+(\\.\\d+){3}$";
+ String re2 = "^[0-9a-f]+(:[0-9a-f]*)+:[0-9a-f]+$";
+ ArrayList serversArrayList = new ArrayList<>();
+ try {
+ Class SystemProperties = Class.forName("android.os.SystemProperties");
+ Method method = SystemProperties.getMethod("get", new Class[]{String.class});
+ String[] netdns = new String[]{"net.dns1", "net.dns2", "net.dns3", "net.dns4"};
+ for (String dns : netdns) {
+ Object[] args = new Object[]{dns};
+ String v = (String) method.invoke(null, args);
+ if (v != null && (v.matches(re1) || v.matches(re2)) && !serversArrayList.contains(v)) {
+ serversArrayList.add(v);
+ }
+ }
+ if (serversArrayList.size() > 0) {
+ return serversArrayList.toArray(new String[0]);
+ }
+ } catch (Exception ex) {
+ Logger.logException(ex);
+ }
+ }
+ return null;
+ }
+
+ private static String[] getServersMethodExec() {
+ try {
+ Process process = Runtime.getRuntime().exec("getprop");
+ InputStream inputStream = process.getInputStream();
+ LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(inputStream));
+ Set serversSet = methodExecParseProps(lineNumberReader);
+ if (serversSet.size() > 0) {
+ return serversSet.toArray(new String[0]);
+ }
+ } catch (Exception ex) {
+ Logger.logException(ex);
+ }
+ return null;
+ }
+
+ private static Set methodExecParseProps(BufferedReader lineNumberReader) throws Exception {
+ String line;
+ HashSet serversSet = new HashSet<>();
+ while ((line = lineNumberReader.readLine()) != null) {
+ int split = line.indexOf(METHOD_EXEC_PROP_DELIM);
+ if (split == -1) {
+ continue;
+ }
+ String property = line.substring(1, split);
+ int valueStart = split + METHOD_EXEC_PROP_DELIM.length();
+ int valueEnd = line.length() - 1;
+ if (valueEnd < valueStart) {
+ continue;
+ }
+ String value = line.substring(valueStart, valueEnd);
+ if (value.isEmpty()) {
+ continue;
+ }
+ if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") ||
+ property.endsWith(".dns3") || property.endsWith(".dns4")) {
+ InetAddress ip = InetAddress.getByName(value);
+ if (ip == null) {
+ continue;
+ }
+ value = ip.getHostAddress();
+ if (value == null || value.length() == 0) {
+ continue;
+ }
+ serversSet.add(value);
+ }
+ }
+ return serversSet;
+ }
+
+ private static boolean linkPropertiesHasDefaultRoute(LinkProperties linkProperties) {
+ for (RouteInfo route : linkProperties.getRoutes()) {
+ if (route.isDefaultRoute()) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/app/src/main/java/org/itxtech/daedalus/widget/ClickPreference.java b/app/src/main/java/org/itxtech/daedalus/widget/ClickPreference.java
index 432bc04..4640abf 100644
--- a/app/src/main/java/org/itxtech/daedalus/widget/ClickPreference.java
+++ b/app/src/main/java/org/itxtech/daedalus/widget/ClickPreference.java
@@ -1,7 +1,7 @@
package org.itxtech.daedalus.widget;
import android.content.Context;
-import android.preference.ListPreference;
+import androidx.preference.ListPreference;
import android.util.AttributeSet;
/**
diff --git a/app/src/main/res/layout/activity_app_filter.xml b/app/src/main/res/layout/activity_app_filter.xml
index 0668267..a0e5c87 100644
--- a/app/src/main/res/layout/activity_app_filter.xml
+++ b/app/src/main/res/layout/activity_app_filter.xml
@@ -25,7 +25,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/card_appview.xml b/app/src/main/res/layout/card_appview.xml
index a41bd15..97e14a3 100644
--- a/app/src/main/res/layout/card_appview.xml
+++ b/app/src/main/res/layout/card_appview.xml
@@ -1,32 +1,28 @@
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical">
+ android:id="@+id/app_icon"
+ android:layout_width="46dp"
+ android:layout_height="46dp"
+ android:paddingEnd="10dp"
+ android:paddingStart="14dp"/>
+ android:id="@+id/app_name"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1.0"/>
+ android:id="@+id/app_check"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:paddingEnd="6dp"
+ android:paddingStart="2dp"/>
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/card_rule.xml b/app/src/main/res/layout/card_rule.xml
index d448b35..d90ecad 100644
--- a/app/src/main/res/layout/card_rule.xml
+++ b/app/src/main/res/layout/card_rule.xml
@@ -14,47 +14,39 @@
app:cardPreventCornerOverlap="true"
android:id="@+id/cardView_indicator">
-
-
+
-
-
-
-
-
-
+ android:padding="@dimen/margin_small"
+ android:id="@+id/textView_rule_name"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentStart="true"/>
+
+
+
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/card_server.xml b/app/src/main/res/layout/card_server.xml
index 1a350a2..6191267 100644
--- a/app/src/main/res/layout/card_server.xml
+++ b/app/src/main/res/layout/card_server.xml
@@ -5,6 +5,7 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:clickable="true"
+ android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp"
app:cardPreventCornerOverlap="true"
@@ -23,7 +24,6 @@
android:id="@+id/textView_custom_dns_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/fragment_dns_servers.xml b/app/src/main/res/layout/fragment_dns_servers.xml
index d012c3e..5021ef3 100644
--- a/app/src/main/res/layout/fragment_dns_servers.xml
+++ b/app/src/main/res/layout/fragment_dns_servers.xml
@@ -11,7 +11,6 @@
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/fragment_dns_test.xml b/app/src/main/res/layout/fragment_dns_test.xml
index 66d3cb2..eb1e1f9 100644
--- a/app/src/main/res/layout/fragment_dns_test.xml
+++ b/app/src/main/res/layout/fragment_dns_test.xml
@@ -41,18 +41,15 @@
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:id="@+id/button_start_test"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentLeft="true"/>
+ android:layout_alignParentEnd="true"/>
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml
index 9ada810..2924b70 100644
--- a/app/src/main/res/layout/fragment_main.xml
+++ b/app/src/main/res/layout/fragment_main.xml
@@ -13,7 +13,6 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="org.itxtech.daedalus.fragment.HomeFragment">
-
+ app:layout_marginTopPercent="15%"
+ android:layout_alignTop="@+id/textView_app_name" android:layout_centerHorizontal="true"/>
diff --git a/app/src/main/res/layout/fragment_rules.xml b/app/src/main/res/layout/fragment_rules.xml
index 05d0491..f10b62d 100644
--- a/app/src/main/res/layout/fragment_rules.xml
+++ b/app/src/main/res/layout/fragment_rules.xml
@@ -11,7 +11,6 @@
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
-
\ No newline at end of file
+
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
deleted file mode 100644
index 1a384e6..0000000
--- a/app/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index db68622..0aa5564 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -3,7 +3,6 @@
Daedalus
开关
- 世界很大,我要去看看。
已启用 iTXTech Daedalus。
正在测试指定的 DNS 服务器……
DNS 查询次数:
@@ -63,9 +62,11 @@
访问 GitHub wiki 页面。
日志大小限制
调试输出
- 不缓存 DoH DNS 的 IP地址
+ 不缓存 DNS 的 IP地址
使用暗主题
DNS 查询方式
+ 运行前台服务
+ 使用系統DNS作為上游DNS
规则名称
规则类型
@@ -103,4 +104,6 @@
google.com
版本:
+
+ 启动时出现了一个错误
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 2d0bedc..0cd2f72 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -3,7 +3,6 @@
Daedalus
开关
- 世界很大,我要去看看。
已啟動 iTXTech Daedalus。
正在測試指定的 DNS 伺服器……
DNS 查詢次數:
@@ -63,7 +62,7 @@
造訪 GitHub wiki 頁面。
紀錄檔大小限制
调试输出 TODO
- 不緩存 DoH DNS 的 IP地址
+ 不緩存 DNS 的 IP地址
使用暗主题
規則名稱
@@ -76,6 +75,7 @@
内置
外部
DNS 查询方式
+ 運行前臺服務
伺服器名稱
伺服器網址
@@ -101,4 +101,6 @@
google.com
版本:
+
+ 啟動時出現了一個錯誤
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9c1de0f..285da87 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,7 +2,6 @@
Daedalus
Toggle
- See the world outside.
iTXTech Daedalus is activated.
Testing specified DNS server…
DNS query times:
@@ -61,10 +60,12 @@
Log Size Limit
Manual
Visit GitHub wiki page.
- Don\'t build DNS Cache for DoH DNS
+ Don\'t cache IP for DNS servers
Debug Output
Use Dark Theme
DNS Query Method
+ Run service in Foreground
+ Use System DNS as upstream DNS
TCP
UDP
@@ -111,4 +112,6 @@
Version:
Git commit:
GitHub
+
+ An error occurred at startup
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index ad9c1a1..a0f82ec 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,8 +1,5 @@
-
-
-
-
+
+
diff --git a/app/src/main/res/xml/perf_rule.xml b/app/src/main/res/xml/perf_rule.xml
index 5e24c80..8753372 100644
--- a/app/src/main/res/xml/perf_rule.xml
+++ b/app/src/main/res/xml/perf_rule.xml
@@ -1,11 +1,14 @@
-
+
+
+
-
+
diff --git a/app/src/main/res/xml/perf_server.xml b/app/src/main/res/xml/perf_server.xml
index 2453e8b..0ec3b11 100644
--- a/app/src/main/res/xml/perf_server.xml
+++ b/app/src/main/res/xml/perf_server.xml
@@ -1,11 +1,14 @@
-
+
+
-
\ No newline at end of file
+
diff --git a/app/src/main/res/xml/perf_settings.xml b/app/src/main/res/xml/perf_settings.xml
index 5540e8c..589f1ea 100644
--- a/app/src/main/res/xml/perf_settings.xml
+++ b/app/src/main/res/xml/perf_settings.xml
@@ -1,7 +1,8 @@
-
-
+
@@ -10,7 +11,6 @@
android:title="@string/primary_server"
android:defaultValue="0">
-
+
@@ -39,6 +41,10 @@
android:key="settings_dark_theme"
android:title="@string/settings_dark_theme"
android:defaultValue="false"/>
+
+ app:iconSpaceReserved="false"
+ android:key="settings_app_filter"
+ android:title="@string/settings_app_filter">
+ android:key="settings_app_filter_switch"
+ android:title="@string/settings_app_filter"
+ android:defaultValue="false"/>
+ android:key="settings_app_filter_mode_switch"
+ android:title="@string/settings_app_filter_mode"
+ android:defaultValue="false"
+ android:enabled="false"/>
+ android:key="settings_app_filter_list"
+ android:title="@string/settings_app_filter_list"
+ android:summary="@string/settings_app_filter_list_summary"
+ android:enabled="false"/>
+
-
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index b99972f..cc4fdc2 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index d5d6d51..6ce793f 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Wed Aug 23 01:02:45 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https://services.gradle.org/distributions/gradle-5.5.1-bin.zip
diff --git a/gradlew b/gradlew
index 4453cce..536f027 100644
--- a/gradlew
+++ b/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -10,38 +26,38 @@
# 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
+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\"`/" >/dev/null
-APP_HOME="`pwd -P`"
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=$(basename "$0")
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
- echo "$*"
+warn() {
+ echo "$*"
}
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
}
# OS specific support (must be 'true' or 'false').
@@ -49,124 +65,119 @@ cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
esac
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
+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
+ 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.
+ 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" -a "$nonstop" = "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"
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "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\""
+ 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"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
- # 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)"
+ # 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
- # 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
+ i=$(expr $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
# Escape application args
-save ( ) {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index f955316..9618d8d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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 DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome