Merge branch 'master' into dns-over-tcp

This commit is contained in:
PeratX 2017-05-02 21:40:36 +08:00
commit 187b21f758
6 changed files with 38 additions and 14 deletions

View File

@ -15,6 +15,7 @@ import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.DnsServerConfigActivity;
import org.itxtech.daedalus.util.CustomDnsServer;
import org.itxtech.daedalus.util.DnsServer;
/**
* Daedalus Project
@ -93,7 +94,9 @@ public class DnsServerConfigFragment extends PreferenceFragment implements Toolb
} else {
serverName.setText("");
serverAddress.setText("");
serverPort.setText("");
String port = String.valueOf(DnsServer.DNS_SERVER_DEFAULT_PORT);
serverPort.setText(port);
serverPort.setSummary(port);
}
return view;
}

View File

@ -75,6 +75,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
.setContentTitle(getResources().getString(R.string.notification_activated))
.setDefaults(NotificationCompat.DEFAULT_LIGHTS)
.setSmallIcon(R.drawable.ic_security)
.setColor(getResources().getColor(R.color.colorPrimary)) //backward compatibility
.setAutoCancel(false)
.setOngoing(true)
.setTicker(getResources().getString(R.string.notification_activated))

View File

@ -21,10 +21,21 @@ import java.util.ArrayList;
* the Free Software Foundation, version 3.
*/
public class Configurations {
private static final int CUSTOM_DNS_ID_START = 32;
private static File file;
private ArrayList<CustomDnsServer> customDnsServers;
private int totalId;
public int getNextId() {
if (totalId < CUSTOM_DNS_ID_START) {
totalId = CUSTOM_DNS_ID_START;
}
return totalId++;
}
public ArrayList<CustomDnsServer> getCustomDnsServers() {
if (customDnsServers == null) {
customDnsServers = new ArrayList<>();

View File

@ -1,5 +1,7 @@
package org.itxtech.daedalus.util;
import org.itxtech.daedalus.Daedalus;
/**
* Daedalus Project
*
@ -20,7 +22,7 @@ public class CustomDnsServer {
this.name = name;
this.address = address;
this.port = port;
this.id = String.valueOf(DnsServer.totalId++);
this.id = String.valueOf(Daedalus.configurations.getNextId());
}
public String getId() {

View File

@ -13,7 +13,10 @@ import android.content.Context;
* the Free Software Foundation, version 3.
*/
public class DnsServer {
public static int totalId = 0;
public static int DNS_SERVER_DEFAULT_PORT = 53;
private static int totalId = 0;
private String id;
private String address;
@ -28,7 +31,7 @@ public class DnsServer {
}
public DnsServer(String address, int description) {
this(address, description, 53);
this(address, description, DNS_SERVER_DEFAULT_PORT);
}
public int getPort() {

View File

@ -12,24 +12,28 @@
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_custom_dns_name"
android:layout_marginTop="30dp"
android:id="@+id/textView_custom_dns_address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:id="@+id/textView_custom_dns_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_custom_dns_name"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:id="@+id/textView_custom_dns_address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
</android.support.v7.widget.CardView>