This commit is contained in:
PeratX 2017-04-24 19:55:46 +08:00
parent b55651877b
commit 8c27d46214
3 changed files with 16 additions and 16 deletions

View File

@ -19,7 +19,7 @@ import org.itxtech.daedalus.BuildConfig;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.fragment.AboutFragment;
import org.itxtech.daedalus.fragment.DNSTestFragment;
import org.itxtech.daedalus.fragment.DnsTestFragment;
import org.itxtech.daedalus.fragment.MainFragment;
import org.itxtech.daedalus.fragment.SettingsFragment;
@ -38,7 +38,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
public static final int LAUNCH_ACTION_NONE = 0;
public static final int LAUNCH_ACTION_ACTIVATE = 1;
public static final int LAUNCH_ACTION_DEACTIVATE = 2;
public static final int LAUNCH_ACTION_AFTRER_DEACTIVATE = 3;
public static final int LAUNCH_ACTION_AFTER_DEACTIVATE = 3;
public static final String LAUNCH_FRAGMENT = "org.itxtech.daedalus.activity.MainActivity.LAUNCH_FRAGMENT";
private static final String TAG = "DMainActivity";
@ -52,7 +52,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private static MainActivity instance = null;
private MainFragment mMain;
private DNSTestFragment mDnsTest;
private DnsTestFragment mDnsTest;
private SettingsFragment mSettings;
private AboutFragment mAbout;
private int currentFragment = FRAGMENT_NONE;
@ -162,7 +162,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
break;
case FRAGMENT_DNS_TEST:
if (mDnsTest == null) {
mDnsTest = new DNSTestFragment();
mDnsTest = new DnsTestFragment();
}
transaction.replace(R.id.id_content, mDnsTest);
toolbar.setTitle(R.string.action_dns_test);
@ -229,7 +229,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
mMain.activateService();
} else if (launchAction == LAUNCH_ACTION_DEACTIVATE) {
Daedalus.getInstance().deactivateService();
} else if (launchAction == LAUNCH_ACTION_AFTRER_DEACTIVATE) {
} else if (launchAction == LAUNCH_ACTION_AFTER_DEACTIVATE) {
Daedalus.updateShortcut(this.getApplicationContext());
mHandler.obtainMessage(MainFragment.MainFragmentHandler.MSG_REFRESH).sendToTarget();
} else {

View File

@ -37,15 +37,12 @@ import java.util.Set;
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*/
public class DNSTestFragment extends Fragment {
private static final int MSG_DISPLAY_STATUS = 0;
private static final int MSG_TEST_DONE = 1;
public class DnsTestFragment extends Fragment {
private static final String TAG = "DServerTest";
private static Thread mThread = null;
private static Runnable mRunnable = null;
private ServerTestHandler mHandler = null;
private DnsTestHandler mHandler = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -84,7 +81,7 @@ public class DNSTestFragment extends Fragment {
for (String dnsServer : dnsServers) {
testText = testServer(client, dnsServer, testDomain, testText);
}
mHandler.obtainMessage(MSG_TEST_DONE).sendToTarget();
mHandler.obtainMessage(DnsTestHandler.MSG_TEST_DONE).sendToTarget();
} catch (Exception e) {
Log.e(TAG, e.toString());
}
@ -94,7 +91,7 @@ public class DNSTestFragment extends Fragment {
Log.d(TAG, "Testing DNS " + dnsServer);
testText.append(getResources().getString(R.string.test_domain)).append(" ").append(testUrl).append("\n").append(getResources().getString(R.string.test_dns_server)).append(" ").append(dnsServer);
mHandler.obtainMessage(MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();
mHandler.obtainMessage(DnsTestHandler.MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();
Question question = new Question(testUrl, Record.TYPE.getType(A.class));
DNSMessage.Builder message = DNSMessage.builder();
@ -121,7 +118,7 @@ public class DNSTestFragment extends Fragment {
Log.e(TAG, e.toString());
}
mHandler.obtainMessage(MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();
mHandler.obtainMessage(DnsTestHandler.MSG_DISPLAY_STATUS, testText.toString()).sendToTarget();
return testText;
}
};
@ -147,7 +144,7 @@ public class DNSTestFragment extends Fragment {
});
mHandler = new ServerTestHandler();
mHandler = new DnsTestHandler();
mHandler.setViews(startTestBut, textViewTestInfo);
return view;
@ -177,7 +174,10 @@ public class DNSTestFragment extends Fragment {
}
}
private static class ServerTestHandler extends Handler {
private static class DnsTestHandler extends Handler {
static final int MSG_DISPLAY_STATUS = 0;
static final int MSG_TEST_DONE = 1;
private Button startTestBtn = null;
private TextView textViewTestInfo = null;

View File

@ -168,7 +168,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
stopSelf();
if (shouldRefresh && MainActivity.getInstance() != null && Daedalus.getInstance().isAppOnForeground()) {
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class).putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_AFTRER_DEACTIVATE));
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class).putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_AFTER_DEACTIVATE));
} else if (shouldRefresh) {
Daedalus.updateShortcut(getApplicationContext());
}