Updated to IntelliJ IDEA 2018.1 RC (AS3.0)
This commit is contained in:
parent
f79d6086f5
commit
0c253ddc0b
@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'io.fabric'
|
||||
|
||||
def gitCommit = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
|
||||
|
||||
@ -14,8 +15,6 @@ android {
|
||||
|
||||
buildConfigField "String", "BUILD_TIME", "\"${System.currentTimeMillis()}\""
|
||||
buildConfigField "String", "GIT_COMMIT", "\"${gitCommit}\""
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -27,32 +26,39 @@ android {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.apk')) {
|
||||
def fileName = outputFile.name.replace("app", "${defaultConfig.applicationId}_${defaultConfig.versionName}_${gitCommit}")
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all {
|
||||
outputFileName = outputFileName.replace("app", "${defaultConfig.applicationId}_${defaultConfig.versionName}_${gitCommit}")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:27.0.2'
|
||||
compile 'com.android.support:design:27.0.2'
|
||||
compile 'com.android.support:support-v4:27.0.2'
|
||||
compile 'com.android.support:percent:27.0.2'
|
||||
compile 'com.android.support:cardview-v7:27.0.2'
|
||||
|
||||
compile 'org.pcap4j:pcap4j-core:1.7.3'
|
||||
compile 'org.pcap4j:pcap4j-packetfactory-static:1.7.3'
|
||||
compile 'de.measite.minidns:minidns-core:0.2.4'
|
||||
compile 'com.google.code.gson:gson:2.8.2'
|
||||
|
||||
compile 'com.google.firebase:firebase-crash:11.0.4'
|
||||
//Support
|
||||
implementation 'com.android.support:appcompat-v7:27.1.0'
|
||||
implementation 'com.android.support:design:27.1.0'
|
||||
implementation 'com.android.support:support-v4:27.1.0'
|
||||
implementation 'com.android.support:percent:27.1.0'
|
||||
implementation 'com.android.support:cardview-v7:27.1.0'
|
||||
//DNS
|
||||
implementation 'org.pcap4j:pcap4j-core:1.7.3'
|
||||
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.7.3'
|
||||
implementation 'de.measite.minidns:minidns-core:0.2.4'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
//Analytics
|
||||
android.applicationVariants.all { v ->
|
||||
if (v.buildType.name == "release") {
|
||||
implementation 'com.google.firebase:firebase-core:12.0.0'
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
android.applicationVariants.all { v ->
|
||||
if (v.buildType.name == "release"){
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
@ -1,51 +0,0 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "",
|
||||
"project_id": ""
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "",
|
||||
"android_client_info": {
|
||||
"package_name": "org.itxtech.daedalus"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "",
|
||||
"client_type": 3
|
||||
},
|
||||
{
|
||||
"client_id": "",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "org.itxtech.daedalus",
|
||||
"certificate_hash": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": ""
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"analytics_service": {
|
||||
"status": 2,
|
||||
"analytics_property": {
|
||||
"tracking_id": ""
|
||||
}
|
||||
},
|
||||
"appinvite_service": {
|
||||
"status": 1,
|
||||
"other_platform_oauth_client": []
|
||||
},
|
||||
"ads_service": {
|
||||
"status": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
@ -12,7 +12,6 @@ import android.net.VpnService;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import com.google.firebase.crash.FirebaseCrash;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
@ -43,14 +42,6 @@ import java.util.List;
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
public class Daedalus extends Application {
|
||||
static {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
FirebaseCrash.report(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final String SHORTCUT_ID_ACTIVATE = "shortcut_activate";
|
||||
|
||||
|
@ -9,7 +9,6 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.fragment.ConfigFragment;
|
||||
@ -61,12 +60,7 @@ public class ConfigActivity extends AppCompatActivity {
|
||||
Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
|
||||
DrawableCompat.setTint(wrappedDrawable, Color.WHITE);
|
||||
toolbar.setNavigationIcon(drawable);
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
toolbar.setOnMenuItemClickListener(fragment);
|
||||
toolbar.inflateMenu(R.menu.custom_config);
|
||||
|
||||
@ -81,7 +75,7 @@ public class ConfigActivity extends AppCompatActivity {
|
||||
public void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_config);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar_config);
|
||||
switch (getIntent().getIntExtra(LAUNCH_ACTION_FRAGMENT, LAUNCH_FRAGMENT_DNS_SERVER)) {
|
||||
case LAUNCH_FRAGMENT_DNS_SERVER:
|
||||
toolbar.setTitle(R.string.config_dns_server);
|
||||
|
@ -42,12 +42,7 @@ public class AboutFragment extends ToolbarFragment {
|
||||
mWebView.setBackgroundColor(0);
|
||||
mWebView.addJavascriptInterface(this, "JavascriptInterface");
|
||||
|
||||
mWebView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mWebView.setOnLongClickListener(v -> true);
|
||||
|
||||
if (Locale.getDefault().getLanguage().equals("zh")) {
|
||||
mWebView.loadUrl("file:///android_asset/about_html/index_zh.html");
|
||||
|
@ -1,10 +1,8 @@
|
||||
package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.Preference;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -41,30 +39,21 @@ public class DNSServerConfigFragment extends ConfigFragment {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
EditTextPreference serverName = (EditTextPreference) findPreference("serverName");
|
||||
serverName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
serverName.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference serverAddress = (EditTextPreference) findPreference("serverAddress");
|
||||
serverAddress.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
serverAddress.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference serverPort = (EditTextPreference) findPreference("serverPort");
|
||||
serverPort.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
serverPort.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@ -118,12 +107,9 @@ public class DNSServerConfigFragment extends ConfigFragment {
|
||||
if (index != ConfigActivity.ID_NONE) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.notice_delete_confirm_prompt)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Daedalus.configurations.getCustomDNSServers().remove(index);
|
||||
getActivity().finish();
|
||||
}
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
Daedalus.configurations.getCustomDNSServers().remove(index);
|
||||
getActivity().finish();
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create()
|
||||
|
@ -2,6 +2,7 @@ package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@ -70,16 +71,11 @@ public class DNSServersFragment extends ToolbarFragment {
|
||||
});
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab_add_server);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getActivity(), ConfigActivity.class)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_FRAGMENT, ConfigActivity.LAUNCH_FRAGMENT_DNS_SERVER)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
});
|
||||
FloatingActionButton fab = view.findViewById(R.id.fab_add_server);
|
||||
fab.setOnClickListener(v -> startActivity(new Intent(getActivity(), ConfigActivity.class)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_FRAGMENT, ConfigActivity.LAUNCH_FRAGMENT_DNS_SERVER)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)));
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -121,7 +117,7 @@ public class DNSServersFragment extends ToolbarFragment {
|
||||
|
||||
private class DNSServerAdapter extends RecyclerView.Adapter<ViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
CustomDNSServer server = Daedalus.configurations.getCustomDNSServers().get(position);
|
||||
holder.setIndex(position);
|
||||
holder.textViewName.setText(server.getName());
|
||||
@ -134,7 +130,8 @@ public class DNSServersFragment extends ToolbarFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
@NonNull
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_server, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
@ -147,8 +144,8 @@ public class DNSServersFragment extends ToolbarFragment {
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
textViewName = (TextView) view.findViewById(R.id.textView_custom_dns_name);
|
||||
textViewAddress = (TextView) view.findViewById(R.id.textView_custom_dns_address);
|
||||
textViewName = view.findViewById(R.id.textView_custom_dns_name);
|
||||
textViewAddress = view.findViewById(R.id.textView_custom_dns_address);
|
||||
view.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,9 @@ public class DNSTestFragment extends ToolbarFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_dns_test, container, false);
|
||||
|
||||
final TextView textViewTestInfo = (TextView) view.findViewById(R.id.textView_test_info);
|
||||
final TextView textViewTestInfo = view.findViewById(R.id.textView_test_info);
|
||||
|
||||
final Spinner spinnerServerChoice = (Spinner) view.findViewById(R.id.spinner_server_choice);
|
||||
final Spinner spinnerServerChoice = view.findViewById(R.id.spinner_server_choice);
|
||||
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, DNSServerHelper.getAllServers());
|
||||
spinnerServerChoice.setAdapter(spinnerArrayAdapter);
|
||||
spinnerServerChoice.setSelection(DNSServerHelper.getPosition(DNSServerHelper.getPrimary()));
|
||||
@ -93,11 +93,11 @@ public class DNSTestFragment extends ToolbarFragment {
|
||||
add(new Type("DLV", Record.TYPE.DLV));
|
||||
}};
|
||||
|
||||
final Spinner spinnerType = (Spinner) view.findViewById(R.id.spinner_type);
|
||||
final Spinner spinnerType = view.findViewById(R.id.spinner_type);
|
||||
ArrayAdapter<Type> typeAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, types);
|
||||
spinnerType.setAdapter(typeAdapter);
|
||||
|
||||
final AutoCompleteTextView textViewTestDomain = (AutoCompleteTextView) view.findViewById(R.id.autoCompleteTextView_test_url);
|
||||
final AutoCompleteTextView textViewTestDomain = view.findViewById(R.id.autoCompleteTextView_test_url);
|
||||
ArrayAdapter autoCompleteArrayAdapter = new ArrayAdapter<>(Daedalus.getInstance(), android.R.layout.simple_list_item_1, Daedalus.DEFAULT_TEST_DOMAINS);
|
||||
textViewTestDomain.setAdapter(autoCompleteArrayAdapter);
|
||||
|
||||
@ -197,23 +197,16 @@ public class DNSTestFragment extends ToolbarFragment {
|
||||
}
|
||||
};
|
||||
|
||||
final Button startTestBut = (Button) view.findViewById(R.id.button_start_test);
|
||||
startTestBut.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
/*Snackbar.make(v, R.string.notice_start_test, Snackbar.LENGTH_SHORT)
|
||||
.setAction("Action", null).show();*/
|
||||
startTestBut.setEnabled(false);
|
||||
final Button startTestBut = view.findViewById(R.id.button_start_test);
|
||||
startTestBut.setOnClickListener(v -> {
|
||||
startTestBut.setEnabled(false);
|
||||
InputMethodManager imm = (InputMethodManager) Daedalus.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
textViewTestInfo.setText("");
|
||||
|
||||
InputMethodManager imm = (InputMethodManager) Daedalus.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
|
||||
textViewTestInfo.setText("");
|
||||
|
||||
if (mThread == null) {
|
||||
mThread = new Thread(mRunnable);
|
||||
mThread.start();
|
||||
}
|
||||
if (mThread == null) {
|
||||
mThread = new Thread(mRunnable);
|
||||
mThread.start();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -39,59 +39,40 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
primaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
|
||||
primaryServer.setEntryValues(DNSServerHelper.getIds());
|
||||
primaryServer.setSummary(DNSServerHelper.getDescription(primaryServer.getValue(), Daedalus.getInstance()));
|
||||
primaryServer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
/*Snackbar.make(getView(), R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();*/
|
||||
return true;
|
||||
}
|
||||
primaryServer.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
return true;
|
||||
});
|
||||
|
||||
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
|
||||
secondaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
|
||||
secondaryServer.setEntryValues(DNSServerHelper.getIds());
|
||||
secondaryServer.setSummary(DNSServerHelper.getDescription(secondaryServer.getValue(), Daedalus.getInstance()));
|
||||
secondaryServer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
/*Snackbar.make(getView(), R.string.notice_need_restart, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();*/
|
||||
return true;
|
||||
}
|
||||
secondaryServer.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference testDNSServers = (EditTextPreference) findPreference("dns_test_servers");
|
||||
testDNSServers.setSummary(testDNSServers.getText());
|
||||
testDNSServers.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
testDNSServers.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
logSize.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
SwitchPreference darkTheme = (SwitchPreference) findPreference("settings_dark_theme");
|
||||
darkTheme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
getActivity().startActivity(new Intent(Daedalus.getInstance(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS)
|
||||
.putExtra(MainActivity.LAUNCH_NEED_RECREATE, true));
|
||||
return true;
|
||||
}
|
||||
darkTheme.setOnPreferenceChangeListener((preference, o) -> {
|
||||
getActivity().startActivity(new Intent(Daedalus.getInstance(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS)
|
||||
.putExtra(MainActivity.LAUNCH_NEED_RECREATE, true));
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
@ -104,36 +85,24 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
}
|
||||
|
||||
SwitchPreference advanced = (SwitchPreference) findPreference("settings_advanced_switch");
|
||||
advanced.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
updateAdvancedOptions((boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
advanced.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
updateAdvancedOptions((boolean) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("settings_check_update").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/releases");
|
||||
return false;
|
||||
}
|
||||
findPreference("settings_check_update").setOnPreferenceClickListener(preference -> {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/releases");
|
||||
return false;
|
||||
});
|
||||
|
||||
findPreference("settings_issue_tracker").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/issues");
|
||||
return false;
|
||||
}
|
||||
findPreference("settings_issue_tracker").setOnPreferenceClickListener(preference -> {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/issues");
|
||||
return false;
|
||||
});
|
||||
|
||||
findPreference("settings_manual").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/wiki");
|
||||
return false;
|
||||
}
|
||||
findPreference("settings_manual").setOnPreferenceClickListener(preference -> {
|
||||
Daedalus.openUri("https://github.com/iTXTech/Daedalus/wiki");
|
||||
return false;
|
||||
});
|
||||
|
||||
updateAdvancedOptions(advanced.isChecked());
|
||||
|
@ -30,15 +30,12 @@ public class HomeFragment extends ToolbarFragment {
|
||||
View view = inflater.inflate(R.layout.fragment_main, container, false);
|
||||
|
||||
Button but = view.findViewById(R.id.button_activate);
|
||||
but.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (DaedalusVpnService.isActivated()) {
|
||||
Daedalus.deactivateService(getActivity().getApplicationContext());
|
||||
} else {
|
||||
startActivity(new Intent(getActivity(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_ACTIVATE));
|
||||
}
|
||||
but.setOnClickListener(v -> {
|
||||
if (DaedalusVpnService.isActivated()) {
|
||||
Daedalus.deactivateService(getActivity().getApplicationContext());
|
||||
} else {
|
||||
startActivity(new Intent(getActivity(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_ACTIVATE));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -3,7 +3,6 @@ package org.itxtech.daedalus.fragment;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -12,7 +11,6 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -83,12 +81,9 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
mHandler = new RuleConfigHandler().setView(view);
|
||||
|
||||
final EditTextPreference ruleName = (EditTextPreference) findPreference("ruleName");
|
||||
ruleName.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
ruleName.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
final ListPreference ruleType = (ListPreference) findPreference("ruleType");
|
||||
@ -96,127 +91,103 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
String[] values = {"0", "1"};
|
||||
ruleType.setEntries(entries);
|
||||
ruleType.setEntryValues(values);
|
||||
ruleType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary(entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
}
|
||||
ruleType.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary(entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
});
|
||||
|
||||
final EditTextPreference ruleDownloadUrl = (EditTextPreference) findPreference("ruleDownloadUrl");
|
||||
ruleDownloadUrl.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
ruleDownloadUrl.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
final EditTextPreference ruleFilename = (EditTextPreference) findPreference("ruleFilename");
|
||||
ruleFilename.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
}
|
||||
ruleFilename.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
ClickPreference ruleSync = (ClickPreference) findPreference("ruleSync");
|
||||
ruleSync.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
save();
|
||||
if (mThread == null) {
|
||||
Snackbar.make(getView(), R.string.notice_start_download, Snackbar.LENGTH_SHORT).show();
|
||||
if (ruleDownloadUrl.getText().startsWith("content:/")) {
|
||||
mThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
InputStream inputStream = getActivity().getContentResolver().openInputStream(Uri.parse(ruleDownloadUrl.getText()));
|
||||
int readLen;
|
||||
byte[] data = new byte[1024];
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
while ((readLen = inputStream.read(data)) != -1) {
|
||||
buffer.write(data, 0, readLen);
|
||||
}
|
||||
inputStream.close();
|
||||
buffer.flush();
|
||||
mHandler.obtainMessage(RuleConfigHandler.MSG_RULE_DOWNLOADED,
|
||||
new RuleData(ruleFilename.getText(), buffer.toByteArray())).sendToTarget();
|
||||
stopThread();
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
} finally {
|
||||
stopThread();
|
||||
}
|
||||
ruleSync.setOnPreferenceClickListener(preference -> {
|
||||
save();
|
||||
if (mThread == null) {
|
||||
Snackbar.make(getView(), R.string.notice_start_download, Snackbar.LENGTH_SHORT).show();
|
||||
if (ruleDownloadUrl.getText().startsWith("content:/")) {
|
||||
mThread = new Thread(() -> {
|
||||
try {
|
||||
InputStream inputStream = getActivity().getContentResolver().openInputStream(Uri.parse(ruleDownloadUrl.getText()));
|
||||
int readLen;
|
||||
byte[] data = new byte[1024];
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
while ((readLen = inputStream.read(data)) != -1) {
|
||||
buffer.write(data, 0, readLen);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URLConnection connection = new URL(ruleDownloadUrl.getText()).openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String result;
|
||||
while ((result = reader.readLine()) != null) {
|
||||
builder.append("\n").append(result);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
mHandler.obtainMessage(RuleConfigHandler.MSG_RULE_DOWNLOADED,
|
||||
new RuleData(ruleFilename.getText(), builder.toString().getBytes())).sendToTarget();
|
||||
stopThread();
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
} finally {
|
||||
stopThread();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mThread.start();
|
||||
inputStream.close();
|
||||
buffer.flush();
|
||||
mHandler.obtainMessage(RuleConfigHandler.MSG_RULE_DOWNLOADED,
|
||||
new RuleData(ruleFilename.getText(), buffer.toByteArray())).sendToTarget();
|
||||
stopThread();
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
} finally {
|
||||
stopThread();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Snackbar.make(getView(), R.string.notice_now_downloading, Snackbar.LENGTH_LONG).show();
|
||||
mThread = new Thread(() -> {
|
||||
try {
|
||||
URLConnection connection = new URL(ruleDownloadUrl.getText()).openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String result;
|
||||
while ((result = reader.readLine()) != null) {
|
||||
builder.append("\n").append(result);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
mHandler.obtainMessage(RuleConfigHandler.MSG_RULE_DOWNLOADED,
|
||||
new RuleData(ruleFilename.getText(), builder.toString().getBytes())).sendToTarget();
|
||||
stopThread();
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
} finally {
|
||||
stopThread();
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
mThread.start();
|
||||
} else {
|
||||
Snackbar.make(getView(), R.string.notice_now_downloading, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
ListPreference ruleImportBuildIn = (ListPreference) findPreference("ruleImportBuildIn");
|
||||
ruleImportBuildIn.setEntries(Rule.getBuildInRuleNames());
|
||||
ruleImportBuildIn.setEntryValues(Rule.getBuildInRuleEntries());
|
||||
ruleImportBuildIn.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Rule rule = Daedalus.RULES.get(Integer.parseInt((String) newValue));
|
||||
ruleName.setText(rule.getName());
|
||||
ruleName.setSummary(rule.getName());
|
||||
ruleType.setValue(String.valueOf(rule.getType()));
|
||||
ruleType.setSummary(Rule.getTypeById(rule.getType()));
|
||||
ruleFilename.setText(rule.getFileName());
|
||||
ruleFilename.setSummary(rule.getFileName());
|
||||
ruleDownloadUrl.setText(rule.getDownloadUrl());
|
||||
ruleDownloadUrl.setSummary(rule.getDownloadUrl());
|
||||
return true;
|
||||
}
|
||||
ruleImportBuildIn.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
Rule rule = Daedalus.RULES.get(Integer.parseInt((String) newValue));
|
||||
ruleName.setText(rule.getName());
|
||||
ruleName.setSummary(rule.getName());
|
||||
ruleType.setValue(String.valueOf(rule.getType()));
|
||||
ruleType.setSummary(Rule.getTypeById(rule.getType()));
|
||||
ruleFilename.setText(rule.getFileName());
|
||||
ruleFilename.setSummary(rule.getFileName());
|
||||
ruleDownloadUrl.setText(rule.getDownloadUrl());
|
||||
ruleDownloadUrl.setSummary(rule.getDownloadUrl());
|
||||
return true;
|
||||
});
|
||||
|
||||
ClickPreference ruleImportExternal = (ClickPreference) findPreference("ruleImportExternal");
|
||||
ruleImportExternal.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
performFileSearch();
|
||||
} else {
|
||||
Snackbar.make(getView(), R.string.notice_legacy_api, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
return false;
|
||||
ruleImportExternal.setOnPreferenceClickListener(preference -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
performFileSearch();
|
||||
} else {
|
||||
Snackbar.make(getView(), R.string.notice_legacy_api, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@ -338,15 +309,12 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
if (this.id != ConfigActivity.ID_NONE) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.notice_delete_confirm_prompt)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Rule rule = Rule.getRuleById(String.valueOf(RuleConfigFragment.this.id));
|
||||
if (rule != null) {
|
||||
rule.removeFromConfig();
|
||||
}
|
||||
getActivity().finish();
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
Rule rule = Rule.getRuleById(String.valueOf(RuleConfigFragment.this.id));
|
||||
if (rule != null) {
|
||||
rule.removeFromConfig();
|
||||
}
|
||||
getActivity().finish();
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create()
|
||||
|
@ -2,6 +2,7 @@ package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@ -89,15 +90,10 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||
|
||||
FloatingActionButton fab = view.findViewById(R.id.fab_add_rule);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getActivity(), ConfigActivity.class)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_FRAGMENT, ConfigActivity.LAUNCH_FRAGMENT_RULE)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
});
|
||||
fab.setOnClickListener(v -> startActivity(new Intent(getActivity(), ConfigActivity.class)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE)
|
||||
.putExtra(ConfigActivity.LAUNCH_ACTION_FRAGMENT, ConfigActivity.LAUNCH_FRAGMENT_RULE)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)));
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -172,7 +168,7 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
|
||||
private class RuleAdapter extends RecyclerView.Adapter<ViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
Rule rule = getRules().get(position);
|
||||
holder.setId(rule.getId());
|
||||
holder.textViewName.setText(rule.getName());
|
||||
@ -194,7 +190,8 @@ public class RulesFragment extends ToolbarFragment implements Toolbar.OnMenuItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
@NonNull
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_rule, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.itxtech.daedalus.provider;
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
@ -215,6 +216,7 @@ public class TcpProvider extends UdpProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Iterator<TcpProvider.WaitingOnSocketPacket> iterator() {
|
||||
return list.iterator();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.itxtech.daedalus.provider;
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
import android.system.StructPollfd;
|
||||
@ -156,7 +157,7 @@ public class UdpProvider extends Provider {
|
||||
}
|
||||
}
|
||||
|
||||
void readPacketFromDevice(FileInputStream inputStream, byte[] packet) throws DaedalusVpnService.VpnNetworkException, SocketException {
|
||||
void readPacketFromDevice(FileInputStream inputStream, byte[] packet) throws DaedalusVpnService.VpnNetworkException {
|
||||
// Read the outgoing packet from the input stream.
|
||||
int length;
|
||||
|
||||
@ -389,6 +390,7 @@ public class UdpProvider extends Provider {
|
||||
list.add(wosp);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Iterator<WaitingOnSocketPacket> iterator() {
|
||||
return list.iterator();
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.widget.AppCompatAutoCompleteTextView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import org.itxtech.daedalus.R;
|
||||
|
||||
/**
|
||||
@ -23,7 +23,8 @@ import org.itxtech.daedalus.R;
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
public class ClearAutoCompleteTextView extends AutoCompleteTextView implements View.OnTouchListener, View.OnFocusChangeListener, TextWatcher {
|
||||
public class ClearAutoCompleteTextView extends AppCompatAutoCompleteTextView
|
||||
implements View.OnTouchListener, View.OnFocusChangeListener, TextWatcher {
|
||||
|
||||
private Drawable mClearTextIcon;
|
||||
private OnFocusChangeListener mOnFocusChangeListener;
|
||||
|
13
build.gradle
13
build.gradle
@ -3,10 +3,15 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
maven {
|
||||
url 'https://maven.fabric.io/public'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.google.gms:google-services:3.1.1'
|
||||
classpath 'io.fabric.tools:gradle:1.25.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@ -16,9 +21,7 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://maven.google.com'
|
||||
}
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user