androidx: move to new libs
This commit is contained in:
parent
b7c4ff9850
commit
d207a41635
@ -56,14 +56,15 @@ dependencies {
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha10'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04'
|
||||
implementation 'com.google.android.material:material:1.1.0-beta01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
|
||||
implementation "androidx.preference:preference:1.1.0"
|
||||
//DNS
|
||||
implementation 'org.pcap4j:pcap4j-core:1.7.6'
|
||||
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.7.6'
|
||||
implementation 'org.pcap4j:pcap4j-core:1.8.2'
|
||||
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.8.2'
|
||||
implementation 'org.minidns:minidns-client:0.3.4'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.14.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.2.0'
|
||||
|
||||
//Analytics
|
||||
googleReleaseImplementation 'com.google.firebase:firebase-core:17.2.0'
|
||||
|
@ -10,8 +10,8 @@ import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
import android.net.VpnService;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.itxtech.daedalus.activity;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@ -9,6 +7,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.fragment.ConfigFragment;
|
||||
@ -64,7 +64,7 @@ public class ConfigActivity extends AppCompatActivity {
|
||||
toolbar.setOnMenuItemClickListener(fragment);
|
||||
toolbar.inflateMenu(R.menu.custom_config);
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
fragment.setIntent(getIntent());
|
||||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.id_config, fragment);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.itxtech.daedalus.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -100,8 +99,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
if (currentFragment == null || fragmentClass != currentFragment.getClass()) {
|
||||
try {
|
||||
ToolbarFragment fragment = (ToolbarFragment) fragmentClass.newInstance();
|
||||
FragmentManager fm = getFragmentManager();
|
||||
fm.beginTransaction().replace(R.id.id_content, fragment).commit();
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.id_content, fragment).commit();
|
||||
currentFragment = fragment;
|
||||
} catch (Exception e) {
|
||||
Logger.logException(e);
|
||||
@ -153,22 +151,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("觉得还不错?")
|
||||
.setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑,甚至其他…… ;)")
|
||||
.setPositiveButton("为我买杯咖啡", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Daedalus.donate();
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setMessage("感谢您的支持!;)\n我会再接再厉!")
|
||||
.setPositiveButton("确认", null)
|
||||
.show();
|
||||
}
|
||||
})
|
||||
.setNeutralButton("不再显示", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Daedalus.configurations.setActivateCounter(-1);
|
||||
}
|
||||
.setPositiveButton("为我买杯咖啡", (dialog, which) -> {
|
||||
Daedalus.donate();
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setMessage("感谢您的支持!;)\n我会再接再厉!")
|
||||
.setPositiveButton("确认", null)
|
||||
.show();
|
||||
})
|
||||
.setNeutralButton("不再显示", (dialog, which) -> Daedalus.configurations.setActivateCounter(-1))
|
||||
.setNegativeButton("取消", null)
|
||||
.show();
|
||||
}
|
||||
@ -182,6 +172,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
updateMainButton(R.string.button_text_deactivate);
|
||||
Daedalus.updateShortcut(getApplicationContext());
|
||||
}
|
||||
super.onActivityResult(request, result, data);
|
||||
}
|
||||
|
||||
private void updateMainButton(int id) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.preference.PreferenceFragment;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
/**
|
||||
* Daedalus Project
|
||||
@ -15,7 +15,7 @@ import androidx.appcompat.widget.Toolbar;
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
abstract public class ConfigFragment extends PreferenceFragment implements Toolbar.OnMenuItemClickListener {
|
||||
abstract public class ConfigFragment extends PreferenceFragmentCompat implements Toolbar.OnMenuItemClickListener {
|
||||
protected Intent intent = null;
|
||||
|
||||
public void setIntent(Intent intent) {
|
||||
|
@ -2,7 +2,7 @@ package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -29,8 +29,7 @@ public class DNSServerConfigFragment extends ConfigFragment {
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.perf_server);
|
||||
}
|
||||
|
||||
@ -38,19 +37,19 @@ public class DNSServerConfigFragment extends ConfigFragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
EditTextPreference serverName = (EditTextPreference) findPreference("serverName");
|
||||
EditTextPreference serverName = findPreference("serverName");
|
||||
serverName.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference serverAddress = (EditTextPreference) findPreference("serverAddress");
|
||||
EditTextPreference serverAddress = findPreference("serverAddress");
|
||||
serverAddress.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference serverPort = (EditTextPreference) findPreference("serverPort");
|
||||
EditTextPreference serverPort = findPreference("serverPort");
|
||||
serverPort.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
|
@ -2,7 +2,7 @@ package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.preference.*;
|
||||
import androidx.preference.*;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.activity.AppFilterActivity;
|
||||
@ -20,12 +20,10 @@ import org.itxtech.daedalus.util.server.DNSServerHelper;
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
public class GlobalConfigFragment extends PreferenceFragment {
|
||||
public class GlobalConfigFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
Daedalus.getPrefs().edit()
|
||||
.putString("primary_server", DNSServerHelper.getPrimary())
|
||||
.putString("secondary_server", DNSServerHelper.getSecondary())
|
||||
@ -33,7 +31,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
|
||||
addPreferencesFromResource(R.xml.perf_settings);
|
||||
|
||||
ListPreference primaryServer = (ListPreference) findPreference("primary_server");
|
||||
ListPreference primaryServer = findPreference("primary_server");
|
||||
primaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
|
||||
primaryServer.setEntryValues(DNSServerHelper.getIds());
|
||||
primaryServer.setSummary(DNSServerHelper.getDescription(primaryServer.getValue(), Daedalus.getInstance()));
|
||||
@ -42,7 +40,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
|
||||
ListPreference secondaryServer = findPreference("secondary_server");
|
||||
secondaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
|
||||
secondaryServer.setEntryValues(DNSServerHelper.getIds());
|
||||
secondaryServer.setSummary(DNSServerHelper.getDescription(secondaryServer.getValue(), Daedalus.getInstance()));
|
||||
@ -51,21 +49,21 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference testDNSServers = (EditTextPreference) findPreference("dns_test_servers");
|
||||
EditTextPreference testDNSServers = findPreference("dns_test_servers");
|
||||
testDNSServers.setSummary(testDNSServers.getText());
|
||||
testDNSServers.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
EditTextPreference logSize = (EditTextPreference) findPreference("settings_log_size");
|
||||
EditTextPreference logSize = findPreference("settings_log_size");
|
||||
logSize.setSummary(logSize.getText());
|
||||
logSize.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
SwitchPreference darkTheme = (SwitchPreference) findPreference("settings_dark_theme");
|
||||
SwitchPreference darkTheme = findPreference("settings_dark_theme");
|
||||
darkTheme.setOnPreferenceChangeListener((preference, o) -> {
|
||||
getActivity().startActivity(new Intent(Daedalus.getInstance(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS)
|
||||
@ -73,13 +71,13 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
SwitchPreference advanced = (SwitchPreference) findPreference("settings_advanced_switch");
|
||||
SwitchPreference advanced = findPreference("settings_advanced_switch");
|
||||
advanced.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
updateOptions((boolean) newValue, "settings_advanced");
|
||||
return true;
|
||||
});
|
||||
|
||||
SwitchPreference appFilter = (SwitchPreference) findPreference("settings_app_filter_switch");
|
||||
SwitchPreference appFilter = findPreference("settings_app_filter_switch");
|
||||
appFilter.setOnPreferenceChangeListener((p, w) -> {
|
||||
updateOptions((boolean) w, "settings_app_filter");
|
||||
return true;
|
||||
@ -115,7 +113,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
||||
}
|
||||
|
||||
private void updateOptions(boolean checked, String pref) {
|
||||
PreferenceCategory category = (PreferenceCategory) findPreference(pref);
|
||||
PreferenceCategory category = findPreference(pref);
|
||||
for (int i = 1; i < category.getPreferenceCount(); i++) {
|
||||
Preference preference = category.getPreference(i);
|
||||
if (checked) {
|
||||
|
@ -7,8 +7,8 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -72,10 +72,8 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.perf_rule);
|
||||
}
|
||||
|
||||
@ -85,13 +83,13 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
|
||||
mHandler = new RuleConfigHandler().setView(view);
|
||||
|
||||
final EditTextPreference ruleName = (EditTextPreference) findPreference("ruleName");
|
||||
final EditTextPreference ruleName = findPreference("ruleName");
|
||||
ruleName.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
final ListPreference ruleType = (ListPreference) findPreference("ruleType");
|
||||
final ListPreference ruleType = findPreference("ruleType");
|
||||
final String[] entries = {"Hosts", "DNSMasq"};
|
||||
String[] values = {"0", "1"};
|
||||
ruleType.setEntries(entries);
|
||||
@ -101,19 +99,19 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
final EditTextPreference ruleDownloadUrl = (EditTextPreference) findPreference("ruleDownloadUrl");
|
||||
final EditTextPreference ruleDownloadUrl = findPreference("ruleDownloadUrl");
|
||||
ruleDownloadUrl.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
final EditTextPreference ruleFilename = (EditTextPreference) findPreference("ruleFilename");
|
||||
final EditTextPreference ruleFilename = findPreference("ruleFilename");
|
||||
ruleFilename.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
preference.setSummary((String) newValue);
|
||||
return true;
|
||||
});
|
||||
|
||||
ClickPreference ruleSync = (ClickPreference) findPreference("ruleSync");
|
||||
ClickPreference ruleSync = findPreference("ruleSync");
|
||||
ruleSync.setOnPreferenceClickListener(preference -> {
|
||||
save();
|
||||
if (mThread == null) {
|
||||
@ -167,7 +165,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
return false;
|
||||
});
|
||||
|
||||
ListPreference ruleImportBuildIn = (ListPreference) findPreference("ruleImportBuildIn");
|
||||
ListPreference ruleImportBuildIn = findPreference("ruleImportBuildIn");
|
||||
ruleImportBuildIn.setEntries(Rule.getBuildInRuleNames());
|
||||
ruleImportBuildIn.setEntryValues(Rule.getBuildInRuleEntries());
|
||||
ruleImportBuildIn.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
@ -183,7 +181,7 @@ public class RuleConfigFragment extends ConfigFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
ClickPreference ruleImportExternal = (ClickPreference) findPreference("ruleImportExternal");
|
||||
ClickPreference ruleImportExternal = findPreference("ruleImportExternal");
|
||||
ruleImportExternal.setOnPreferenceClickListener(preference -> {
|
||||
performFileSearch();
|
||||
return false;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -28,13 +26,7 @@ public class SettingsFragment extends ToolbarFragment {
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
FragmentManager fm;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
fm = getChildFragmentManager();
|
||||
} else {
|
||||
fm = getFragmentManager();
|
||||
}
|
||||
fm.beginTransaction().replace(R.id.settings_content, new GlobalConfigFragment()).commit();
|
||||
getChildFragmentManager().beginTransaction().replace(R.id.settings_content, new GlobalConfigFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import org.itxtech.daedalus.R;
|
||||
|
||||
|
@ -168,7 +168,10 @@ public class UdpProvider extends Provider {
|
||||
}
|
||||
|
||||
if (!(parsedPacket.getPayload() instanceof UdpPacket)) {
|
||||
Log.i(TAG, "handleDnsRequest: Discarding unknown packet type " + parsedPacket.getPayload());
|
||||
try {
|
||||
Log.i(TAG, "handleDnsRequest: Discarding unknown packet type " + parsedPacket.getPayload());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.itxtech.daedalus.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.ListPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
|
@ -9,9 +9,9 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.1'
|
||||
classpath 'com.google.gms:google-services:4.3.2'
|
||||
classpath 'io.fabric.tools:gradle:1.28.1'
|
||||
classpath 'io.fabric.tools:gradle:1.31.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user