Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoZenz committed Feb 26, 2021
2 parents 13c775c + e03f415 commit 7d30eee
Show file tree
Hide file tree
Showing 97 changed files with 603 additions and 357 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dnsfilter.android"
android:versionCode="1504600"
android:versionName="1.50.46.0" >
android:versionCode="1504700"
android:versionName="1.50.47.0" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/assets/dnsfilter.conf
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ additionalHosts_lastImportTS = 0
reloadIntervalDays =7

# live log settings (Android only) colors, text size
filterLogFormat = <font color='#D03D06'>($CONTENT)</font>
acceptLogFormat = <font color='#23751C'>($CONTENT)</font>
fwdLogFormat = <font color='#ff9900'>($CONTENT)</font>
filterLogFormat = <font color='#E53935'>($CONTENT)</font>
acceptLogFormat = <font color='#43A047'>($CONTENT)</font>
fwdLogFormat = <font color='#FFB300'>($CONTENT)</font>
normalLogFormat = ($CONTENT)
logTextSize = 14

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/dnsfilter/DNSFilterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ of the License, or (at your option) any later version.

public class DNSFilterManager extends ConfigurationAccess {

public static final String VERSION = "1504600";
public static final String VERSION = "1504700";

private static DNSFilterManager INSTANCE = new DNSFilterManager();

Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/dnsfilter/android/DNSFilterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected static class DNSReqForwarder {
//used in case vpn mode is disabled for forwaring dns requests to local dns proxy

String forwardip = null;
String ipFilePath = ExecutionEnvironment.getEnvironment().getWorkDir()+"forward_ip";
String ipFileName = "forward_ip";



Expand Down Expand Up @@ -148,6 +148,7 @@ else if (ip == null)


public void clean() {
String ipFilePath = ExecutionEnvironment.getEnvironment().getWorkDir()+ipFileName;
File f = new File(ipFilePath);
try {
if (f.exists()) {
Expand All @@ -174,6 +175,9 @@ public void clean() {


public synchronized void updateForward() {

String ipFilePath = ExecutionEnvironment.getEnvironment().getWorkDir()+ipFileName;

try {
String ip = getALocalIpAddress();
if (ip !=null &&!ip.equals(forwardip)){
Expand All @@ -195,6 +199,9 @@ public synchronized void updateForward() {
}

public synchronized void clearForward() {

String ipFilePath = ExecutionEnvironment.getEnvironment().getWorkDir()+ipFileName;

if (forwardip == null)
return;

Expand Down Expand Up @@ -630,6 +637,10 @@ private ParcelFileDescriptor initVPN(boolean explicitOp) throws Exception {

builder.setMtu(mtu);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
builder.setMetered(false); //take over defaults from underlying network
}

return builder.setConfigureIntent(pendingIntent).establish();
}

Expand Down
68 changes: 39 additions & 29 deletions app/src/main/java/dnsfilter/android/DNSProxyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class DNSProxyActivity extends Activity implements OnClickListener, Logge
protected static EditText manualDNSView;
protected static boolean advDNSConfigDia_open = false;
protected static String SCROLL_PAUSE = "II ";
protected static String SCROLL_CONTINUE = ">> ";
protected static String SCROLL_CONTINUE = " ";
protected static boolean scroll_locked = false;
protected static TextView link_field;
protected static int link_field_color = Color.TRANSPARENT;
Expand Down Expand Up @@ -161,9 +161,9 @@ public class DNSProxyActivity extends Activity implements OnClickListener, Logge
protected static int NO_ACTION_MENU = 0;


protected static String IN_FILTER_PREF = "X \u0009";
protected static String NO_FILTER_PREF = "✓\u0009";
protected static String IP_FORWARD_PREF = "-> ";
protected static String IN_FILTER_PREF = "\u2002\u2009";
protected static String NO_FILTER_PREF = "✓\u2004\u2009";
protected static String IP_FORWARD_PREF = "\u200A";

//log color and format
protected static String filterLogFormat;
Expand All @@ -176,6 +176,8 @@ public class DNSProxyActivity extends Activity implements OnClickListener, Logge

protected static boolean CHECKING_PASSCODE_DIAG = false;

protected static boolean NO_VPN = false;

protected static DNSProxyActivity INSTANCE;

public static void reloadLocalConfig() {
Expand Down Expand Up @@ -422,9 +424,9 @@ public void onCreate(Bundle savedInstanceState) {
helpBtn.setOnClickListener(this);
remoteCtrlBtn = (Button) findViewById(R.id.remoteCtrlBtn);
if (!CONFIG.isLocal())
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.baseline_settings_remote_24px), null);
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.remote_icon), null);
else
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.outline_settings_remote_24px), null);
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.drawable.remote_icon_outline), null);

remoteCtrlBtn.setOnClickListener(this);
backupBtn = (Button) findViewById(R.id.backupBtn);
Expand Down Expand Up @@ -743,10 +745,10 @@ protected void doBackup() {
TextView backupStatusView = findViewById(R.id.backupLog);
try {
CONFIG.doBackup(getBackupSubFolder());
backupStatusView.setTextColor(Color.parseColor("#23751C"));
backupStatusView.setTextColor(Color.parseColor("#43A047"));
backupStatusView.setText("Backup success!");
} catch (IOException eio) {
backupStatusView.setTextColor(Color.parseColor("#D03D06"));
backupStatusView.setTextColor(Color.parseColor("#E53935"));
backupStatusView.setText("Backup failed! " + eio.getMessage());
}
}
Expand All @@ -755,12 +757,12 @@ protected void doRestoreDefaults() {
TextView backupStatusView = findViewById(R.id.backupLog);
try {
CONFIG.doRestoreDefaults();
backupStatusView.setTextColor(Color.parseColor("#23751C"));
backupStatusView.setTextColor(Color.parseColor("#43A047"));
if (!CONFIG.isLocal())
loadAndApplyConfig(false);
backupStatusView.setText("Restore success!");
} catch (IOException eio) {
backupStatusView.setTextColor(Color.parseColor("#D03D06"));
backupStatusView.setTextColor(Color.parseColor("#E53935"));
backupStatusView.setText("Restore failed! " + eio.getMessage());
}
}
Expand All @@ -769,12 +771,12 @@ protected void doRestore() {
TextView backupStatusView = findViewById(R.id.backupLog);
try {
CONFIG.doRestore(getBackupSubFolder());
backupStatusView.setTextColor(Color.parseColor("#23751C"));
backupStatusView.setTextColor(Color.parseColor("#43A047"));
if (!CONFIG.isLocal())
loadAndApplyConfig(false);
backupStatusView.setText("Restore success!");
} catch (IOException eio) {
backupStatusView.setTextColor(Color.parseColor("#D03D06"));
backupStatusView.setTextColor(Color.parseColor("#E53935"));
backupStatusView.setText("Restore failed! " + eio.getMessage());
}
}
Expand Down Expand Up @@ -829,8 +831,11 @@ protected void applyCopiedHosts(String entryStr, boolean filter) {
String entries = "";
while (entryTokens.hasMoreTokens()) {
String token = entryTokens.nextToken();
if (token.startsWith(IN_FILTER_PREF) || token.startsWith(NO_FILTER_PREF)) {
entries = entries+token.substring(1).trim()+"\n";
if (token.startsWith(IN_FILTER_PREF)) {
entries = entries+token.substring(IN_FILTER_PREF.length()).trim()+"\n";
}
if (token.startsWith(NO_FILTER_PREF)) {
entries = entries+token.substring(NO_FILTER_PREF.length()).trim()+"\n";
}
}

Expand All @@ -845,7 +850,7 @@ private void initAppAndStartup() {
logLine("Initializing ...");
if (BOOT_START) {
Logger.getLogger().logLine("Running on SDK" + Build.VERSION.SDK_INT);
if (Build.VERSION.SDK_INT >= 20) //on older Android we have to keep the app in forgrounnd due to teh VPN Accespt dialog popping up after each reboot.
if (Build.VERSION.SDK_INT >= 20) //on older Android we have to keep the app in forground due to the VPN accept dialog popping up after each reboot.
finish();
BOOT_START = false;
}
Expand Down Expand Up @@ -898,6 +903,10 @@ protected void loadAndApplyConfig(boolean startApp) {

if (config != null) {

boolean dnsProxyMode = Boolean.parseBoolean(config.getProperty("dnsProxyOnAndroid", "false"));
boolean vpnInAdditionToProxyMode = Boolean.parseBoolean(config.getProperty("vpnInAdditionToProxyMode", "false"));
NO_VPN = dnsProxyMode && !vpnInAdditionToProxyMode;

Runnable uiUpdater = new Runnable() {
@Override
public void run() {
Expand All @@ -907,9 +916,9 @@ public void run() {
link_field.setText(fromHtml(link_field_txt));

//Log formatting
filterLogFormat = config.getProperty("filterLogFormat", "<font color='#D03D06'>($CONTENT)</font>");
acceptLogFormat = config.getProperty("acceptLogFormat", "<font color='#23751C'>($CONTENT)</font>");
fwdLogFormat = config.getProperty("fwdLogFormat", "<font color='#ff9900'>($CONTENT)</font>");
filterLogFormat = config.getProperty("filterLogFormat", "<font color='#E53935'>($CONTENT)</font>");
acceptLogFormat = config.getProperty("acceptLogFormat", "<font color='#43A047'>($CONTENT)</font>");
fwdLogFormat = config.getProperty("fwdLogFormat", "<font color='#FFB300'>($CONTENT)</font>");
normalLogFormat = config.getProperty("normalLogFormat","($CONTENT)");

try {
Expand Down Expand Up @@ -942,13 +951,13 @@ public void run() {

rootModeCheck.setChecked(Boolean.parseBoolean(config.getProperty("rootModeOnAndroid", "false")));

//set whitelisted Apps into UI
//set whitelisted apps into UI
appSelector.setSelectedApps(config.getProperty("androidAppWhiteList", ""));

if (!CONFIG.isLocal())
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null,getResources().getDrawable(R.drawable.baseline_settings_remote_24px), null);
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null,getResources().getDrawable(R.drawable.remote_icon), null);
else
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null,getResources().getDrawable(R.drawable.outline_settings_remote_24px), null);
remoteCtrlBtn.setCompoundDrawablesWithIntrinsicBounds(null, null,getResources().getDrawable(R.drawable.remote_icon_outline), null);

switchingConfig = false;
}
Expand Down Expand Up @@ -1400,8 +1409,8 @@ private void handleAdvancedConfig(CheckBox dest) {
((TextView) findViewById(R.id.backupLog)).setText("");
if (advancedConfigCheck.isChecked()) {
setVisibilityForAdvCfg(View.GONE);
//App Whitelisting only supported on SDK >= 21
if (Build.VERSION.SDK_INT >= 21 && CONFIG.isLocal()) {
//App whitelisting only supported on SDK >= 21
if (Build.VERSION.SDK_INT >= 21 && CONFIG.isLocal() && !NO_VPN) {
appWhiteListCheck.setVisibility(View.VISIBLE);
appWhitelistingEnabled=true;
}
Expand Down Expand Up @@ -1543,6 +1552,7 @@ private void handleRestart() {
return;

startup();
loadAndApplyConfig(false);
}
else {
try {
Expand Down Expand Up @@ -1574,10 +1584,10 @@ protected void startup() {
intent = VpnService.prepare(this.getApplicationContext());
if (intent != null) {
startActivityForResult(intent, 0);
} else { //already prepared or vpn disabled
} else { //already prepared or VPN disabled
startSvc();
}
} catch (NullPointerException e) { // NullPointer might occur on Android 4.4 when vpn already initialized
} catch (NullPointerException e) { // NullPointer might occur on Android 4.4 when VPN already initialized
Logger.getLogger().logLine("Seems we are on Android 4.4 or older!");
startSvc(); // assume it is ok!
} catch (Exception e) {
Expand Down Expand Up @@ -1620,7 +1630,7 @@ public void log(String txt) {

@Override
public void message(String txt) {
setMessage(fromHtml("<strong>"+txt+"</strong>"), Color.parseColor("#ffcc00"));
setMessage(fromHtml("<strong>"+txt+"</strong>"), Color.parseColor("#FFC107"));
MsgTO.setTimeout(5000);
}

Expand Down Expand Up @@ -1712,7 +1722,7 @@ public void onDestroyActionMode(ActionMode mode) {
public void onActionModeStarted(android.view.ActionMode mode) {

/* if (Build.VERSION.SDK_INT < 23 && logOutView.hasFocus()) {
// get Action Menu on old devices before 6.0
// get action menu on old devices before 6.0
int start = logOutView.getSelectionStart();
int end = logOutView.getSelectionEnd();
Expand Down Expand Up @@ -1741,8 +1751,8 @@ public boolean onTouch(View v, MotionEvent event) {
}

if (NO_ACTION_MENU > 1) {
//2 times no Action ==> Action Menu not working on this device
// ==>Fallback to the Buttons on top of Log View
//2 times no action ==> action menu not working on this device
// ==>Fallback to the buttons on top of log view
findViewById(R.id.copyfromlog).setVisibility(View.VISIBLE);
}
}
Expand Down
52 changes: 0 additions & 52 deletions app/src/main/res/drawable-night/checkbox_active.xml

This file was deleted.

34 changes: 13 additions & 21 deletions app/src/main/res/drawable-night/checkbox_inactive.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- outer rectangle -->
<item>
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<size
android:width="22dp"
android:height="22dp"/>
<stroke
android:width="2dp"
android:color="#fafafa">
</stroke>
<!-- fake background -->
<solid
android:color="#00FFFFFF">
</solid>
</shape>
</item>

</layer-list>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:pathData="M 19 5 L 19 19 L 5 19 L 5 5 L 19 5 M 19 3 L 5 3 C 3.9 3 3 3.9 3 5 L 3 19 C 3 20.1 3.9 21 5 21 L 19 21 C 20.1 21 21 20.1 21 19 L 21 5 C 21 3.9 20.1 3 19 3 Z"
android:fillColor="#FFFFFF"
android:strokeWidth="1"/>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable-night/menu_inactive.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="32dp"
android:height="28dp"
android:viewportWidth="32"
android:viewportHeight="28">
<path
android:name="path"
android:pathData="M 4 22 L 28 22 L 28 19.3 L 4 19.3 L 4 22 Z M 4 15.3 L 28 15.3 L 28 12.6 L 4 12.6 L 4 15.3 Z M 4 6 L 4 8.7 L 28 8.7 L 28 6 L 4 6 Z"
android:fillColor="#FFFFFF"
android:strokeWidth="1"/>
</vector>
Loading

0 comments on commit 7d30eee

Please sign in to comment.