Refactored project & improved DnsServers

This commit is contained in:
PeratX 2017-04-09 14:26:34 +08:00
parent 1e9969c8ff
commit 3e6f3adcb7
22 changed files with 235 additions and 109 deletions

View File

@ -7,20 +7,21 @@
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
<application <application
android:name=".Daedalus"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<service <service
android:name=".DaedalusVpnService" android:name=".service.DaedalusVpnService"
android:permission="android.permission.BIND_VPN_SERVICE"> android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter> <intent-filter>
<action android:name="android.net.VpnService"/> <action android:name="android.net.VpnService"/>
</intent-filter> </intent-filter>
</service> </service>
<receiver android:name=".BootBroadcastReceiver"> <receiver android:name=".receiver.BootBroadcastReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED"/>
@ -29,16 +30,16 @@
</receiver> </receiver>
<receiver <receiver
android:name=".StatusBarBroadcastReceiver" android:name=".receiver.StatusBarBroadcastReceiver"
android:exported="false"> android:exported="false">
<intent-filter> <intent-filter>
<action android:name="org.itxtech.daedalus.StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION"/> <action android:name="org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION"/>
<action android:name="org.itxtech.daedalus.StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION"/> <action android:name="org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<activity <activity
android:name=".MainActivity" android:name=".activity.MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTask" android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
@ -49,17 +50,17 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".SettingsActivity" android:name=".activity.SettingsActivity"
android:launchMode="singleTask" android:launchMode="singleTask"
android:label="@string/action_settings"> android:label="@string/action_settings">
</activity> </activity>
<activity <activity
android:name=".AboutActivity" android:name=".activity.AboutActivity"
android:launchMode="singleTask" android:launchMode="singleTask"
android:label="@string/action_about"> android:label="@string/action_about">
</activity> </activity>
<activity <activity
android:name=".ServerTestActivity" android:name=".activity.ServerTestActivity"
android:launchMode="singleTask" android:launchMode="singleTask"
android:label="@string/action_server_test"> android:label="@string/action_server_test">
</activity> </activity>

View File

@ -0,0 +1,38 @@
package org.itxtech.daedalus;
import android.app.Application;
import org.itxtech.daedalus.util.DnsServer;
import java.util.ArrayList;
import java.util.List;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
public class Daedalus extends Application {
public static final List<DnsServer> DNS_SERVERS = new ArrayList<DnsServer>() {{
add(new DnsServer("0", "113.107.249.56", R.string.server_north_china));
add(new DnsServer("1", "120.27.103.230", R.string.server_east_china));
add(new DnsServer("2", "123.206.61.167", R.string.server_south_china));
}};
private static Daedalus instance = null;
@Override
public void onCreate() {
super.onCreate();
instance = this;
}
public static Daedalus getInstance() {
return instance;
}
}

View File

@ -1,26 +0,0 @@
package org.itxtech.daedalus;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
class DnsServers {
static String getDnsServerAddress(String id) {
switch (id) {
case "0":
return "113.107.249.56";
case "1":
return "120.27.103.230";
case "2":
return "123.206.61.167";
default:
return "123.206.61.167";
}
}
}

View File

@ -1,22 +0,0 @@
package org.itxtech.daedalus;
import android.os.Bundle;
import android.preference.PreferenceFragment;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
public class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.perf_settings);
}
}

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.activity;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
@ -12,6 +12,8 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import org.itxtech.daedalus.BuildConfig;
import org.itxtech.daedalus.R;
import java.util.Locale; import java.util.Locale;

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.NotificationManager; import android.app.NotificationManager;
@ -15,6 +15,9 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.DnsServer;
/** /**
* Daedalus Project * Daedalus Project
@ -30,7 +33,7 @@ public class MainActivity extends AppCompatActivity {
private static MainActivity instance = null; private static MainActivity instance = null;
private SharedPreferences prefs; private SharedPreferences prefs;
static MainActivity getInstance() { public static MainActivity getInstance() {
return instance; return instance;
} }
@ -124,8 +127,8 @@ public class MainActivity extends AppCompatActivity {
protected void onActivityResult(int request, int result, Intent data) { protected void onActivityResult(int request, int result, Intent data) {
if (result == RESULT_OK) { if (result == RESULT_OK) {
DaedalusVpnService.primaryServer = DnsServers.getDnsServerAddress(prefs.getString("primary_server", "0")); DaedalusVpnService.primaryServer = DnsServer.getDnsServerAddressById(prefs.getString("primary_server", "0"));
DaedalusVpnService.secondaryServer = DnsServers.getDnsServerAddress(prefs.getString("secondary_server", "1")); DaedalusVpnService.secondaryServer = DnsServer.getDnsServerAddressById(prefs.getString("secondary_server", "1"));
startService(getServiceIntent().setAction(DaedalusVpnService.ACTION_ACTIVATE)); startService(getServiceIntent().setAction(DaedalusVpnService.ACTION_ACTIVATE));

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
@ -16,11 +16,23 @@ import de.measite.minidns.Question;
import de.measite.minidns.Record; import de.measite.minidns.Record;
import de.measite.minidns.record.A; import de.measite.minidns.record.A;
import de.measite.minidns.util.InetAddressUtil; import de.measite.minidns.util.InetAddressUtil;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.DnsServer;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
public class ServerTestActivity extends AppCompatActivity { public class ServerTestActivity extends AppCompatActivity {
private static final int MSG_DISPLAY_STATUS = 0; private static final int MSG_DISPLAY_STATUS = 0;
private static final int MSG_TEST_DONE = 1; private static final int MSG_TEST_DONE = 1;
@ -37,10 +49,14 @@ public class ServerTestActivity extends AppCompatActivity {
final TextView textViewTestInfo = (TextView) findViewById(R.id.textView_test_info); final TextView textViewTestInfo = (TextView) findViewById(R.id.textView_test_info);
final Spinner spinnerServerChoice = (Spinner) findViewById(R.id.spinner_server_choice); final Spinner spinnerServerChoice = (Spinner) findViewById(R.id.spinner_server_choice);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, DnsServer.getDnsServerNames(this));
spinnerServerChoice.setAdapter(spinnerArrayAdapter);
final AutoCompleteTextView textViewTestUrl = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView_test_url); final AutoCompleteTextView textViewTestUrl = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView_test_url);
ArrayAdapter arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.default_test_urls)); ArrayAdapter autoCompleteArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.default_test_urls));
textViewTestUrl.setAdapter(arrayAdapter); textViewTestUrl.setAdapter(autoCompleteArrayAdapter);
final Context context = this;
final Button startTestBut = (Button) findViewById(R.id.button_start_test); final Button startTestBut = (Button) findViewById(R.id.button_start_test);
startTestBut.setOnClickListener(new View.OnClickListener() { startTestBut.setOnClickListener(new View.OnClickListener() {
@ -65,7 +81,7 @@ public class ServerTestActivity extends AppCompatActivity {
testUrl = getResources().getStringArray(R.array.default_test_urls)[0]; testUrl = getResources().getStringArray(R.array.default_test_urls)[0];
} }
String testText = ""; String testText = "";
String[] dnsServers = {DnsServers.getDnsServerAddress(String.valueOf(spinnerServerChoice.getSelectedItemId())), "114.114.114.114", "8.8.8.8"}; String[] dnsServers = {DnsServer.getDnsServerAddressByStringDesription(context, spinnerServerChoice.getSelectedItem().toString()), "114.114.114.114", "8.8.8.8"};
DNSClient client = new DNSClient(null); DNSClient client = new DNSClient(null);
for (String dnsServer : dnsServers) { for (String dnsServer : dnsServers) {
testText = testServer(client, dnsServer, testUrl, testText); testText = testServer(client, dnsServer, testUrl, testText);

View File

@ -1,8 +1,10 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.activity;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.fragment.SettingsFragment;
/** /**
* Daedalus Project * Daedalus Project

View File

@ -0,0 +1,36 @@
package org.itxtech.daedalus.fragment;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.DnsServer;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
public class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.perf_settings);
ListPreference primaryServer = (ListPreference) findPreference("primary_server");
primaryServer.setEntries(DnsServer.getDnsServerNames(Daedalus.getInstance()));
primaryServer.setEntryValues(DnsServer.getDnsServerIds());
primaryServer.setDefaultValue(Daedalus.DNS_SERVERS.get(0).getId());
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
secondaryServer.setEntries(DnsServer.getDnsServerNames(Daedalus.getInstance()));
secondaryServer.setEntryValues(DnsServer.getDnsServerIds());
primaryServer.setDefaultValue(Daedalus.DNS_SERVERS.get(1).getId());
}
}

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -7,6 +7,9 @@ import android.content.SharedPreferences;
import android.net.VpnService; import android.net.VpnService;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.DnsServer;
/** /**
* Daedalus Project * Daedalus Project
@ -30,8 +33,8 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
context.startActivity(vIntent); context.startActivity(vIntent);
} }
DaedalusVpnService.primaryServer = DnsServers.getDnsServerAddress(prefs.getString("primary_server", "0")); DaedalusVpnService.primaryServer = DnsServer.getDnsServerAddressById(prefs.getString("primary_server", "0"));
DaedalusVpnService.secondaryServer = DnsServers.getDnsServerAddress(prefs.getString("secondary_server", "1")); DaedalusVpnService.secondaryServer = DnsServer.getDnsServerAddressById(prefs.getString("secondary_server", "1"));
context.startService((new Intent(context, DaedalusVpnService.class)).setAction(DaedalusVpnService.ACTION_ACTIVATE)); context.startService((new Intent(context, DaedalusVpnService.class)).setAction(DaedalusVpnService.ACTION_ACTIVATE));

View File

@ -1,10 +1,14 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import android.widget.Button; import android.widget.Button;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.activity.SettingsActivity;
import org.itxtech.daedalus.service.DaedalusVpnService;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -19,8 +23,8 @@ import java.lang.reflect.Method;
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
*/ */
public class StatusBarBroadcastReceiver extends BroadcastReceiver { public class StatusBarBroadcastReceiver extends BroadcastReceiver {
static String STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION = "org.itxtech.daedalus.StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION"; public static String STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION = "org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION";
static String STATUS_BAR_BTN_SETTINGS_CLICK_ACTION = "org.itxtech.daedalus.StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION"; public static String STATUS_BAR_BTN_SETTINGS_CLICK_ACTION = "org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION";
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@ -31,7 +35,6 @@ public class StatusBarBroadcastReceiver extends BroadcastReceiver {
if (MainActivity.getInstance() != null) { if (MainActivity.getInstance() != null) {
((Button) MainActivity.getInstance().findViewById(R.id.button_activate)).setText(R.string.button_text_activate); ((Button) MainActivity.getInstance().findViewById(R.id.button_activate)).setText(R.string.button_text_activate);
} }
} }
if (intent.getAction().equals(STATUS_BAR_BTN_SETTINGS_CLICK_ACTION)) { if (intent.getAction().equals(STATUS_BAR_BTN_SETTINGS_CLICK_ACTION)) {
Intent settingsIntent = new Intent(context, SettingsActivity.class); Intent settingsIntent = new Intent(context, SettingsActivity.class);

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus; package org.itxtech.daedalus.service;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
@ -10,6 +10,9 @@ import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver;
/** /**
* Daedalus Project * Daedalus Project
@ -22,11 +25,11 @@ import android.util.Log;
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
*/ */
public class DaedalusVpnService extends VpnService implements Runnable { public class DaedalusVpnService extends VpnService implements Runnable {
static final String ACTION_ACTIVATE = "org.itxtech.daedalus.DaedalusVpnService.ACTION_ACTIVATE"; public static final String ACTION_ACTIVATE = "org.itxtech.daedalus.service.DaedalusVpnService.ACTION_ACTIVATE";
static final String ACTION_DEACTIVATE = "org.itxtech.daedalus.DaedalusVpnService.ACTION_DEACTIVATE"; public static final String ACTION_DEACTIVATE = "org.itxtech.daedalus.service.DaedalusVpnService.ACTION_DEACTIVATE";
static String primaryServer; public static String primaryServer;
static String secondaryServer; public static String secondaryServer;
private Thread mThread = null; private Thread mThread = null;
private static int ip = 0; private static int ip = 0;
@ -57,8 +60,12 @@ public class DaedalusVpnService extends VpnService implements Runnable {
.setAutoCancel(true) .setAutoCancel(true)
.setOngoing(true) .setOngoing(true)
.setContentIntent(pIntent) .setContentIntent(pIntent)
.addAction(R.mipmap.ic_launcher, getResources().getString(R.string.button_text_deactivate), PendingIntent.getBroadcast(this, 0, new Intent(StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION), 0)) .addAction(R.mipmap.ic_launcher, getResources().getString(R.string.button_text_deactivate),
.addAction(R.mipmap.ic_launcher, getResources().getString(R.string.action_settings), PendingIntent.getBroadcast(this, 0, new Intent(StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION), 0)); PendingIntent.getBroadcast(this, 0,
new Intent(StatusBarBroadcastReceiver.STATUS_BAR_BTN_DEACTIVATE_CLICK_ACTION), 0))
.addAction(R.mipmap.ic_launcher, getResources().getString(R.string.action_settings),
PendingIntent.getBroadcast(this, 0,
new Intent(StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION), 0));
Notification notification = builder.build(); Notification notification = builder.build();
notification.flags = Notification.FLAG_NO_CLEAR; notification.flags = Notification.FLAG_NO_CLEAR;

View File

@ -0,0 +1,80 @@
package org.itxtech.daedalus.util;
import android.content.Context;
import org.itxtech.daedalus.Daedalus;
import java.util.ArrayList;
/**
* Daedalus Project
*
* @author iTXTech
* @link https://itxtech.org
* <p>
* 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, version 3.
*/
public class DnsServer {
private String id;
private String address;
private int description;
public DnsServer(String id, String address, int description) {
this.id = id;
this.address = address;
this.description = description;
}
public String getId() {
return id;
}
public String getAddress() {
return address;
}
public int getDescription() {
return description;
}
public String getStringDescription(Context context) {
return context.getResources().getString(description);
}
public static String getDnsServerAddressById(String id) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
if (server.getId().equals(id)) {
return server.getAddress();
}
}
return Daedalus.DNS_SERVERS.get(0).getAddress();
}
public static String getDnsServerAddressByStringDesription(Context context, String description) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
if (server.getStringDescription(context).equals(description)) {
return server.getAddress();
}
}
return Daedalus.DNS_SERVERS.get(0).getAddress();
}
public static String[] getDnsServerIds() {
ArrayList<String> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
for (DnsServer server : Daedalus.DNS_SERVERS) {
servers.add(server.getId());
}
String[] stringServers = new String[Daedalus.DNS_SERVERS.size()];
return servers.toArray(stringServers);
}
public static String[] getDnsServerNames(Context context) {
ArrayList<String> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
for (DnsServer server : Daedalus.DNS_SERVERS) {
servers.add(server.getStringDescription(context));
}
String[] stringServers = new String[Daedalus.DNS_SERVERS.size()];
return servers.toArray(stringServers);
}
}

View File

@ -13,7 +13,7 @@
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="org.itxtech.daedalus.AboutActivity"> tools:context="org.itxtech.daedalus.activity.AboutActivity">
<WebView <WebView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
tools:context="org.itxtech.daedalus.MainActivity"> tools:context="org.itxtech.daedalus.activity.MainActivity">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -13,13 +13,12 @@
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="org.itxtech.daedalus.ServerTestActivity"> tools:context="org.itxtech.daedalus.activity.ServerTestActivity">
<Spinner <Spinner
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/spinner_server_choice" android:layout_alignParentTop="true" android:id="@+id/spinner_server_choice" android:layout_alignParentTop="true"/>
android:entries="@array/dns_server_options"/>
<Button <Button
android:text="@string/action_start_test" android:text="@string/action_start_test"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -9,6 +9,6 @@
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="org.itxtech.daedalus.SettingsActivity"> tools:context="org.itxtech.daedalus.activity.SettingsActivity">
</RelativeLayout> </RelativeLayout>

View File

@ -12,7 +12,7 @@
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main" tools:showIn="@layout/activity_main"
tools:context="org.itxtech.daedalus.MainActivity"> tools:context="org.itxtech.daedalus.activity.MainActivity">
<ImageView <ImageView
android:contentDescription="icon" android:contentDescription="icon"
android:id="@+id/imageView_icon" android:id="@+id/imageView_icon"

View File

@ -1,7 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="org.itxtech.daedalus.AboutActivity"> tools:context="org.itxtech.daedalus.activity.AboutActivity">
<item android:id="@+id/action_visit_itxtech" <item android:id="@+id/action_visit_itxtech"
android:title="@string/action_visit_itxtech" android:title="@string/action_visit_itxtech"
android:orderInCategory="100" android:orderInCategory="100"

View File

@ -1,7 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="org.itxtech.daedalus.MainActivity"> tools:context="org.itxtech.daedalus.activity.MainActivity">
<item android:id="@+id/action_settings" <item android:id="@+id/action_settings"
android:title="@string/action_settings" android:title="@string/action_settings"
android:orderInCategory="100"/> android:orderInCategory="100"/>

View File

@ -1,14 +1,4 @@
<resources> <resources>
<string-array name="dns_server_options">
<item>@string/server_north_china</item>
<item>@string/server_east_china</item>
<item>@string/server_south_china</item>
</string-array>
<string-array name="dns_server_options_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="default_test_urls"> <string-array name="default_test_urls">
<item>google.com</item> <item>google.com</item>
<item>twitter.com</item> <item>twitter.com</item>

View File

@ -20,18 +20,12 @@
<ListPreference <ListPreference
android:key="primary_server" android:key="primary_server"
android:title="@string/primary_server" android:title="@string/primary_server">
android:entries="@array/dns_server_options"
android:entryValues="@array/dns_server_options_values"
android:defaultValue="0">
</ListPreference> </ListPreference>
<ListPreference <ListPreference
android:key="secondary_server" android:key="secondary_server"
android:title="@string/secondary_server" android:title="@string/secondary_server">
android:entries="@array/dns_server_options"
android:entryValues="@array/dns_server_options_values"
android:defaultValue="1">
</ListPreference> </ListPreference>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>