Skip to content

Commit 9919375

Browse files
committed
Release v1.8.0
1 parent 0d88d6f commit 9919375

File tree

14 files changed

+80
-42
lines changed

14 files changed

+80
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Requirements
5151

5252
Open Source Licenses
5353
-------------
54-
* __[ClearEditText](https://github.com/MrFuFuFu/ClearEditText)__ by *[Yuan Fu](https://github.com/MrFuFuFu)* - None
54+
* __[ClearEditText](https://github.com/MrFuFuFu/ClearEditText)__ by *[Yuan Fu](https://github.com/MrFuFuFu)* - [APL 2.0](https://github.com/MrFuFuFu/ClearEditText)
5555
* __[DNS66](https://github.com/julian-klode/dns66)__ by *[Julian Andres Klode](https://github.com/julian-klode)* - [GPLv3](https://github.com/julian-klode/dns66/blob/master/COPYING)
5656
* __[Pcap4J](https://github.com/kaitoy/pcap4j)__ by *[Kaito Yamada](https://github.com/kaitoy)* - [MIT](https://github.com/kaitoy/pcap4j)
5757
* __[MiniDNS](https://github.com/rtreffer/minidns)__ by *[Rene Treffer](https://github.com/rtreffer)* - [LGPLv2.1](https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1)

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "org.itxtech.daedalus"
1111
minSdkVersion 15
1212
targetSdkVersion 25
13-
versionCode 7
14-
versionName "1.7.0"
13+
versionCode 8
14+
versionName "1.8.0"
1515

1616
buildConfigField "String", "BUILD_TIME", "\"${System.currentTimeMillis()}\""
1717
buildConfigField "String", "GIT_COMMIT", "\"${gitCommit}\""

app/src/main/assets/about_html/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@
8787
<div style="font-size: 16px; color: gray;">Open Source Licenses</div>
8888
<br>
8989
<div style="font-size: 14px; color: gray;">
90-
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: None<br>
90+
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: <a
91+
href="https://github.com/MrFuFuFu/ClearEditText">APL 2.0</a><br>
9192
<a href="https://github.com/julian-klode/dns66">DNS66</a>: <a
9293
href="https://github.com/julian-klode/dns66/blob/master/COPYING">GPLv3</a><br>
9394
<a href="https://github.com/kaitoy/pcap4j">Pcap4J</a>: <a href="https://github.com/kaitoy/pcap4j">MIT</a><br>
9495
<a href="https://github.com/rtreffer/minidns">MiniDNS</a>: <a
9596
href="https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1">LGPLv2.1</a><br>
9697
<a href="https://github.com/google/gson">Gson</a>: <a
97-
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a>
98+
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a><br>
9899
</div>
99100
</body>
100101
</html>

app/src/main/assets/about_html/index_zh.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@
8787
<div style="font-size: 16px; color: gray;">Open Source Licenses</div>
8888
<br>
8989
<div style="font-size: 14px; color: gray;">
90-
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: None<br>
90+
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: <a
91+
href="https://github.com/MrFuFuFu/ClearEditText">APL 2.0</a><br>
9192
<a href="https://github.com/julian-klode/dns66">DNS66</a>: <a
9293
href="https://github.com/julian-klode/dns66/blob/master/COPYING">GPLv3</a><br>
9394
<a href="https://github.com/kaitoy/pcap4j">Pcap4J</a>: <a href="https://github.com/kaitoy/pcap4j">MIT</a><br>
9495
<a href="https://github.com/rtreffer/minidns">MiniDNS</a>: <a
9596
href="https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1">LGPLv2.1</a><br>
9697
<a href="https://github.com/google/gson">Gson</a>: <a
97-
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a>
98+
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a><br>
9899
</div>
99100
</body>
100101
</html>

app/src/main/java/org/itxtech/daedalus/Daedalus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public void uncaughtException(Thread t, Throwable e) {
100100
public void onCreate() {
101101
super.onCreate();
102102

103+
instance = this;
104+
103105
Logger.init();
104106

105107
mResolver = new Thread(new RulesResolver());
@@ -111,8 +113,6 @@ public void onCreate() {
111113
}
112114

113115
initData();
114-
115-
instance = this;
116116
}
117117

118118
private void initData() {

app/src/main/java/org/itxtech/daedalus/fragment/GlobalConfigFragment.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
7373
}
7474
});
7575

76+
EditTextPreference logSize = (EditTextPreference) findPreference("settings_log_size");
77+
logSize.setSummary(logSize.getText());
78+
logSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
79+
@Override
80+
public boolean onPreferenceChange(Preference preference, Object newValue) {
81+
preference.setSummary((String) newValue);
82+
return true;
83+
}
84+
});
85+
7686
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
7787
SwitchPreference advanced = (SwitchPreference) findPreference("settings_advanced_switch");
7888
advanced.setEnabled(false);
@@ -137,7 +147,9 @@ private void updateAdvancedOptions(boolean checked) {
137147
public void onViewCreated(View view, Bundle savedInstanceState) {
138148
super.onViewCreated(view, savedInstanceState);
139149

140-
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
141-
.setAction("Action", null).show();
150+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
151+
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
152+
.setAction("Action", null).show();
153+
}
142154
}
143155
}

app/src/main/java/org/itxtech/daedalus/receiver/BootBroadcastReceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import android.content.Context;
55
import android.content.Intent;
66
import android.net.VpnService;
7-
import android.util.Log;
87
import org.itxtech.daedalus.Daedalus;
98
import org.itxtech.daedalus.service.DaedalusVpnService;
109
import org.itxtech.daedalus.util.DnsServerHelper;
10+
import org.itxtech.daedalus.util.Logger;
1111

1212
/**
1313
* Daedalus Project
@@ -35,7 +35,7 @@ public void onReceive(Context context, Intent intent) {
3535

3636
context.startService((new Intent(context, DaedalusVpnService.class)).setAction(DaedalusVpnService.ACTION_ACTIVATE));
3737

38-
Log.d("DBootRecv", "Triggered boot receiver");
38+
Logger.info("Triggered boot receiver");
3939
}
4040

4141
Daedalus.updateShortcut(context);

app/src/main/java/org/itxtech/daedalus/receiver/StatusBarBroadcastReceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import android.content.BroadcastReceiver;
44
import android.content.Context;
55
import android.content.Intent;
6-
import android.util.Log;
76
import org.itxtech.daedalus.Daedalus;
87
import org.itxtech.daedalus.activity.MainActivity;
8+
import org.itxtech.daedalus.util.Logger;
99

1010
import java.lang.reflect.Method;
1111

@@ -38,7 +38,7 @@ public void onReceive(Context context, Intent intent) {
3838
Method collapse = statusBarManager.getClass().getMethod("collapsePanels");
3939
collapse.invoke(statusBarManager);
4040
} catch (Exception e) {
41-
Log.d("DStatusBarRecv", e.toString());
41+
Logger.logException(e);
4242
}
4343
}
4444
}

app/src/main/java/org/itxtech/daedalus/util/Configurations.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ public static Configurations load(File file) {
120120
Configurations config = null;
121121
try {
122122
config = Daedalus.parseJson(Configurations.class, new JsonReader(new FileReader(file)));
123-
} catch (Exception ignored) {
123+
Logger.info("Loading configuration successfully from " + file);
124+
} catch (Exception e) {
125+
Logger.logException(e);
124126
}
125127

126128
if (config == null) {
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.itxtech.daedalus.util;
22

33
import android.util.Log;
4+
import org.itxtech.daedalus.Daedalus;
45

56
import java.io.PrintWriter;
67
import java.io.StringWriter;
@@ -19,30 +20,22 @@
1920
* (at your option) any later version.
2021
*/
2122
public class Logger {
22-
private static StringBuilder builder;
23+
private static StringBuffer buffer = null;
2324

2425
public static void init() {
25-
builder = new StringBuilder();
26+
if (buffer != null) {
27+
buffer.setLength(0);
28+
} else {
29+
buffer = new StringBuffer();
30+
}
2631
}
2732

2833
public static void shutdown() {
29-
builder = null;
34+
buffer = null;
3035
}
3136

3237
public static String getLog() {
33-
return builder.toString();
34-
}
35-
36-
public static void emergency(String message) {
37-
send("[EMERGENCY] " + message);
38-
}
39-
40-
public static void alert(String message) {
41-
send("[ALERT] " + message);
42-
}
43-
44-
public static void critical(String message) {
45-
send("[CRITICAL] " + message);
38+
return buffer.toString();
4639
}
4740

4841
public static void error(String message) {
@@ -53,10 +46,6 @@ public static void warning(String message) {
5346
send("[WARNING] " + message);
5447
}
5548

56-
public static void notice(String message) {
57-
send("[NOTICE] " + message);
58-
}
59-
6049
public static void info(String message) {
6150
send("[INFO] " + message);
6251
}
@@ -66,7 +55,7 @@ public static void debug(String message) {
6655
}
6756

6857
public static void logException(Throwable e) {
69-
alert(getExceptionMessage(e));
58+
error(getExceptionMessage(e));
7059
}
7160

7261
private static String getExceptionMessage(Throwable e) {
@@ -76,9 +65,33 @@ private static String getExceptionMessage(Throwable e) {
7665
return stringWriter.toString();
7766
}
7867

68+
private static int getLogSizeLimit() {
69+
return Integer.parseInt(Daedalus.getPrefs().getString("settings_log_size", "10000"));
70+
}
71+
72+
private static boolean checkBufferSize() {
73+
int limit = getLogSizeLimit();
74+
if (limit == 0) {//DISABLED!
75+
return false;
76+
}
77+
if (limit == -1) {//N0 limit
78+
return true;
79+
}
80+
if (buffer.length() > limit) {//LET's clean it up!
81+
buffer.setLength(limit);
82+
}
83+
return true;
84+
}
85+
7986
private static void send(String message) {
80-
String fileDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss ").format(new Date());
81-
builder.insert(0, "\n").insert(0, message).insert(0, fileDateFormat);
82-
Log.d("Daedalus", message);
87+
try {
88+
if (checkBufferSize()) {
89+
String fileDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date());
90+
buffer.insert(0, "\n").insert(0, message).insert(0, fileDateFormat);
91+
}
92+
Log.d("Daedalus", message);
93+
} catch (Exception e) {
94+
e.printStackTrace();
95+
}
8396
}
8497
}

0 commit comments

Comments
 (0)