Skip to content

Commit

Permalink
Release v1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed May 28, 2017
1 parent 0d88d6f commit 9919375
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Requirements

Open Source Licenses
-------------
* __[ClearEditText](https://github.com/MrFuFuFu/ClearEditText)__ by *[Yuan Fu](https://github.com/MrFuFuFu)* - None
* __[ClearEditText](https://github.com/MrFuFuFu/ClearEditText)__ by *[Yuan Fu](https://github.com/MrFuFuFu)* - [APL 2.0](https://github.com/MrFuFuFu/ClearEditText)
* __[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)
* __[Pcap4J](https://github.com/kaitoy/pcap4j)__ by *[Kaito Yamada](https://github.com/kaitoy)* - [MIT](https://github.com/kaitoy/pcap4j)
* __[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)
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.itxtech.daedalus"
minSdkVersion 15
targetSdkVersion 25
versionCode 7
versionName "1.7.0"
versionCode 8
versionName "1.8.0"

buildConfigField "String", "BUILD_TIME", "\"${System.currentTimeMillis()}\""
buildConfigField "String", "GIT_COMMIT", "\"${gitCommit}\""
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/assets/about_html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@
<div style="font-size: 16px; color: gray;">Open Source Licenses</div>
<br>
<div style="font-size: 14px; color: gray;">
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: None<br>
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: <a
href="https://github.com/MrFuFuFu/ClearEditText">APL 2.0</a><br>
<a href="https://github.com/julian-klode/dns66">DNS66</a>: <a
href="https://github.com/julian-klode/dns66/blob/master/COPYING">GPLv3</a><br>
<a href="https://github.com/kaitoy/pcap4j">Pcap4J</a>: <a href="https://github.com/kaitoy/pcap4j">MIT</a><br>
<a href="https://github.com/rtreffer/minidns">MiniDNS</a>: <a
href="https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1">LGPLv2.1</a><br>
<a href="https://github.com/google/gson">Gson</a>: <a
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a>
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a><br>
</div>
</body>
</html>
5 changes: 3 additions & 2 deletions app/src/main/assets/about_html/index_zh.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@
<div style="font-size: 16px; color: gray;">Open Source Licenses</div>
<br>
<div style="font-size: 14px; color: gray;">
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: None<br>
<a href="https://github.com/MrFuFuFu/ClearEditText">ClearEditText</a>: <a
href="https://github.com/MrFuFuFu/ClearEditText">APL 2.0</a><br>
<a href="https://github.com/julian-klode/dns66">DNS66</a>: <a
href="https://github.com/julian-klode/dns66/blob/master/COPYING">GPLv3</a><br>
<a href="https://github.com/kaitoy/pcap4j">Pcap4J</a>: <a href="https://github.com/kaitoy/pcap4j">MIT</a><br>
<a href="https://github.com/rtreffer/minidns">MiniDNS</a>: <a
href="https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1">LGPLv2.1</a><br>
<a href="https://github.com/google/gson">Gson</a>: <a
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a>
href="https://github.com/google/gson/blob/master/LICENSE">APL 2.0</a><br>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions app/src/main/java/org/itxtech/daedalus/Daedalus.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public void uncaughtException(Thread t, Throwable e) {
public void onCreate() {
super.onCreate();

instance = this;

Logger.init();

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

initData();

instance = this;
}

private void initData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});

EditTextPreference logSize = (EditTextPreference) findPreference("settings_log_size");
logSize.setSummary(logSize.getText());
logSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
preference.setSummary((String) newValue);
return true;
}
});

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
SwitchPreference advanced = (SwitchPreference) findPreference("settings_advanced_switch");
advanced.setEnabled(false);
Expand Down Expand Up @@ -137,7 +147,9 @@ private void updateAdvancedOptions(boolean checked) {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import android.content.Context;
import android.content.Intent;
import android.net.VpnService;
import android.util.Log;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.DnsServerHelper;
import org.itxtech.daedalus.util.Logger;

/**
* Daedalus Project
Expand Down Expand Up @@ -35,7 +35,7 @@ public void onReceive(Context context, Intent intent) {

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

Log.d("DBootRecv", "Triggered boot receiver");
Logger.info("Triggered boot receiver");
}

Daedalus.updateShortcut(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.util.Logger;

import java.lang.reflect.Method;

Expand Down Expand Up @@ -38,7 +38,7 @@ public void onReceive(Context context, Intent intent) {
Method collapse = statusBarManager.getClass().getMethod("collapsePanels");
collapse.invoke(statusBarManager);
} catch (Exception e) {
Log.d("DStatusBarRecv", e.toString());
Logger.logException(e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public static Configurations load(File file) {
Configurations config = null;
try {
config = Daedalus.parseJson(Configurations.class, new JsonReader(new FileReader(file)));
} catch (Exception ignored) {
Logger.info("Loading configuration successfully from " + file);
} catch (Exception e) {
Logger.logException(e);
}

if (config == null) {
Expand Down
61 changes: 37 additions & 24 deletions app/src/main/java/org/itxtech/daedalus/util/Logger.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.itxtech.daedalus.util;

import android.util.Log;
import org.itxtech.daedalus.Daedalus;

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

public static void init() {
builder = new StringBuilder();
if (buffer != null) {
buffer.setLength(0);
} else {
buffer = new StringBuffer();
}
}

public static void shutdown() {
builder = null;
buffer = null;
}

public static String getLog() {
return builder.toString();
}

public static void emergency(String message) {
send("[EMERGENCY] " + message);
}

public static void alert(String message) {
send("[ALERT] " + message);
}

public static void critical(String message) {
send("[CRITICAL] " + message);
return buffer.toString();
}

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

public static void notice(String message) {
send("[NOTICE] " + message);
}

public static void info(String message) {
send("[INFO] " + message);
}
Expand All @@ -66,7 +55,7 @@ public static void debug(String message) {
}

public static void logException(Throwable e) {
alert(getExceptionMessage(e));
error(getExceptionMessage(e));
}

private static String getExceptionMessage(Throwable e) {
Expand All @@ -76,9 +65,33 @@ private static String getExceptionMessage(Throwable e) {
return stringWriter.toString();
}

private static int getLogSizeLimit() {
return Integer.parseInt(Daedalus.getPrefs().getString("settings_log_size", "10000"));
}

private static boolean checkBufferSize() {
int limit = getLogSizeLimit();
if (limit == 0) {//DISABLED!
return false;
}
if (limit == -1) {//N0 limit
return true;
}
if (buffer.length() > limit) {//LET's clean it up!
buffer.setLength(limit);
}
return true;
}

private static void send(String message) {
String fileDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss ").format(new Date());
builder.insert(0, "\n").insert(0, message).insert(0, fileDateFormat);
Log.d("Daedalus", message);
try {
if (checkBufferSize()) {
String fileDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date());
buffer.insert(0, "\n").insert(0, message).insert(0, fileDateFormat);
}
Log.d("Daedalus", message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void load() {
for (String hostsFile : hostsFiles) {
File file = new File(hostsFile);
if (file.canRead()) {
Logger.info("Loading hosts " + file.toString());
Logger.info("Loading hosts from " + file.toString());
FileInputStream stream = new FileInputStream(file);
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
String strLine;
Expand All @@ -120,7 +120,7 @@ private void load() {
for (String dnsmasqFile : dnsmasqFiles) {
File file = new File(dnsmasqFile);
if (file.canRead()) {
Logger.info("Loading DNSMasq configuration " + file.toString());
Logger.info("Loading DNSMasq configuration from " + file.toString());
FileInputStream stream = new FileInputStream(file);
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
String strLine;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
<string name="settings_manual_summary">访问 GitHub wiki 页面。</string>
<string name="action_log">日志</string>
<string name="action_refresh">刷新</string>
<string name="settings_log_size">日志大小限制</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
<string name="settings_manual_summary">Visit GitHub wiki page.</string>
<string name="action_log">Log</string>
<string name="action_refresh">Refresh</string>
<string name="settings_log_size">Log size limit</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/xml/perf_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
android:key="settings_notification"
android:title="@string/settings_notification"
android:defaultValue="true"/>
<EditTextPreference
android:key="settings_log_size"
android:selectAllOnFocus="false"
android:singleLine="true"
android:numeric="integer"
android:defaultValue="10000"
android:title="@string/settings_log_size"/>
</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit 9919375

Please sign in to comment.