AppFilter: optimizations
This commit is contained in:
parent
f2343bd333
commit
d9712a353e
@ -24,12 +24,12 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
<service
|
<service
|
||||||
android:name=".service.DaedalusTileService"
|
android:name=".service.DaedalusTileService"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:icon="@drawable/ic_security"
|
android:icon="@drawable/ic_security"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
@ -71,7 +71,11 @@
|
|||||||
android:configChanges="keyboard|keyboardHidden|screenLayout|uiMode|orientation|screenSize|smallestScreenSize"
|
android:configChanges="keyboard|keyboardHidden|screenLayout|uiMode|orientation|screenSize|smallestScreenSize"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".activity.FilterAppProxyActivity" />
|
<activity
|
||||||
|
android:name=".activity.AppFilterActivity"
|
||||||
|
android:label=""
|
||||||
|
android:configChanges="keyboard|keyboardHidden|screenLayout|uiMode|orientation|screenSize|smallestScreenSize"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -39,7 +39,7 @@ import java.util.Objects;
|
|||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
public class FilterAppProxyActivity extends AppCompatActivity {
|
public class AppFilterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private RecyclerViewAdapter adapter;
|
private RecyclerViewAdapter adapter;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class FilterAppProxyActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_filter_app);
|
setContentView(R.layout.activity_app_filter);
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar_filter);
|
Toolbar toolbar = findViewById(R.id.toolbar_filter);
|
||||||
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_clear);
|
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_clear);
|
||||||
RecyclerView recyclerView = findViewById(R.id.recyclerView_app_filter_list);
|
RecyclerView recyclerView = findViewById(R.id.recyclerView_app_filter_list);
|
||||||
@ -60,19 +60,10 @@ public class FilterAppProxyActivity extends AppCompatActivity {
|
|||||||
DrawableCompat.setTint(wrappedDrawable, Color.WHITE);
|
DrawableCompat.setTint(wrappedDrawable, Color.WHITE);
|
||||||
toolbar.setNavigationIcon(drawable);
|
toolbar.setNavigationIcon(drawable);
|
||||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||||
|
toolbar.setTitle(R.string.settings_app_filter);
|
||||||
adapter = new RecyclerViewAdapter();
|
adapter = new RecyclerViewAdapter();
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
new Thread(() -> {
|
new Thread(() -> adapter.updateList(getAppList())).start();
|
||||||
ArrayList<AppObject> appList = getAppList();
|
|
||||||
adapter.updateList(appList);
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPostCreate(Bundle savedInstanceState) {
|
|
||||||
super.onPostCreate(savedInstanceState);
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar_filter);
|
|
||||||
toolbar.setTitle(R.string.settings_app_filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,7 +113,7 @@ public class FilterAppProxyActivity extends AppCompatActivity {
|
|||||||
appList = appObjects;
|
appList = appObjects;
|
||||||
|
|
||||||
for (int i = 0; i < appObjects.size(); i++) {
|
for (int i = 0; i < appObjects.size(); i++) {
|
||||||
if (Daedalus.configurations.getFilterAppObjects().contains(appObjects.get(i).appPackageName)) {
|
if (Daedalus.configurations.getAppObjects().contains(appObjects.get(i).appPackageName)) {
|
||||||
checkStatus.put(i, true);
|
checkStatus.put(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +135,7 @@ public class FilterAppProxyActivity extends AppCompatActivity {
|
|||||||
holder.appIcon.setImageDrawable(appList.get(position).appIcon);
|
holder.appIcon.setImageDrawable(appList.get(position).appIcon);
|
||||||
holder.appPackageName = packageName;
|
holder.appPackageName = packageName;
|
||||||
holder.appCheck.setOnCheckedChangeListener(null);
|
holder.appCheck.setOnCheckedChangeListener(null);
|
||||||
if (Daedalus.configurations.getFilterAppObjects().contains(packageName)) {
|
if (Daedalus.configurations.getAppObjects().contains(packageName)) {
|
||||||
holder.appCheck.setChecked(true);
|
holder.appCheck.setChecked(true);
|
||||||
}
|
}
|
||||||
holder.appCheck.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
holder.appCheck.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
@ -186,10 +177,10 @@ public class FilterAppProxyActivity extends AppCompatActivity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (appCheck.isChecked()) {
|
if (appCheck.isChecked()) {
|
||||||
appCheck.setChecked(false);
|
appCheck.setChecked(false);
|
||||||
Daedalus.configurations.getFilterAppObjects().remove(appPackageName);
|
Daedalus.configurations.getAppObjects().remove(appPackageName);
|
||||||
} else {
|
} else {
|
||||||
appCheck.setChecked(true);
|
appCheck.setChecked(true);
|
||||||
Daedalus.configurations.getFilterAppObjects().add(appPackageName);
|
Daedalus.configurations.getAppObjects().add(appPackageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import android.os.Bundle;
|
|||||||
import android.preference.*;
|
import android.preference.*;
|
||||||
import org.itxtech.daedalus.Daedalus;
|
import org.itxtech.daedalus.Daedalus;
|
||||||
import org.itxtech.daedalus.R;
|
import org.itxtech.daedalus.R;
|
||||||
import org.itxtech.daedalus.activity.FilterAppProxyActivity;
|
import org.itxtech.daedalus.activity.AppFilterActivity;
|
||||||
import org.itxtech.daedalus.activity.MainActivity;
|
import org.itxtech.daedalus.activity.MainActivity;
|
||||||
import org.itxtech.daedalus.util.server.DNSServerHelper;
|
import org.itxtech.daedalus.util.server.DNSServerHelper;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
findPreference("settings_app_filter_list").setOnPreferenceClickListener(preference -> {
|
findPreference("settings_app_filter_list").setOnPreferenceClickListener(preference -> {
|
||||||
startActivity(new Intent(getActivity(), FilterAppProxyActivity.class));
|
startActivity(new Intent(getActivity(), AppFilterActivity.class));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class RuleConfigFragment extends ConfigFragment {
|
public class RuleConfigFragment extends ConfigFragment {
|
||||||
private static final OkHttpClient HTTP_CLIENT = new OkHttpClient.Builder()
|
private static final OkHttpClient HTTP_CLIENT = new OkHttpClient.Builder()
|
||||||
.connectTimeout(5, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.readTimeout(10, TimeUnit.SECONDS)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
.writeTimeout(10, TimeUnit.SECONDS)
|
.writeTimeout(30, TimeUnit.SECONDS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final int READ_REQUEST_CODE = 1;
|
private static final int READ_REQUEST_CODE = 1;
|
||||||
|
@ -4,7 +4,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import org.itxtech.daedalus.Daedalus;
|
import org.itxtech.daedalus.Daedalus;
|
||||||
import org.itxtech.daedalus.util.server.CustomDNSServer;
|
import org.itxtech.daedalus.util.server.CustomDNSServer;
|
||||||
import org.itxtech.daedalus.util.server.DNSServer;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@ -28,9 +27,8 @@ public class Configurations {
|
|||||||
|
|
||||||
private static File file;
|
private static File file;
|
||||||
|
|
||||||
private ArrayList<DNSServer> builtInDNSServers;
|
|
||||||
private ArrayList<CustomDNSServer> customDNSServers;
|
private ArrayList<CustomDNSServer> customDNSServers;
|
||||||
private ArrayList<String> filterAppObjects;
|
private ArrayList<String> appObjects;
|
||||||
|
|
||||||
private ArrayList<Rule> hostsRules;
|
private ArrayList<Rule> hostsRules;
|
||||||
private ArrayList<Rule> dnsmasqRules;
|
private ArrayList<Rule> dnsmasqRules;
|
||||||
@ -69,11 +67,11 @@ public class Configurations {
|
|||||||
return customDNSServers;
|
return customDNSServers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getFilterAppObjects() {
|
public ArrayList<String> getAppObjects() {
|
||||||
if (filterAppObjects == null) {
|
if (appObjects == null) {
|
||||||
filterAppObjects = new ArrayList<>();
|
appObjects = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return filterAppObjects;
|
return appObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Rule> getHostsRules() {
|
public ArrayList<Rule> getHostsRules() {
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<string name="settings_rule_sync">同步规则</string>
|
<string name="settings_rule_sync">同步规则</string>
|
||||||
<string name="settings_rule_filename">规则文件名</string>
|
<string name="settings_rule_filename">规则文件名</string>
|
||||||
<string name="settings_rule_import">导入</string>
|
<string name="settings_rule_import">导入</string>
|
||||||
<string name="settings_rule_import_build_in">内置</string>
|
<string name="settings_rule_import_built_in">内置</string>
|
||||||
<string name="settings_rule_import_external">外部</string>
|
<string name="settings_rule_import_external">外部</string>
|
||||||
|
|
||||||
<string name="settings_server_name">服务器名称</string>
|
<string name="settings_server_name">服务器名称</string>
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
<string name="settings_rule_sync">同步規則</string>
|
<string name="settings_rule_sync">同步規則</string>
|
||||||
<string name="settings_rule_filename">規則檔案名稱</string>
|
<string name="settings_rule_filename">規則檔案名稱</string>
|
||||||
<string name="settings_rule_import">匯入</string>
|
<string name="settings_rule_import">匯入</string>
|
||||||
<string name="settings_rule_import_build_in">内置</string>
|
<string name="settings_rule_import_built_in">内置</string>
|
||||||
<string name="settings_rule_import_external">外部</string>
|
<string name="settings_rule_import_external">外部</string>
|
||||||
<string name="settings_dns_query_method">DNS 查询方式</string>
|
<string name="settings_dns_query_method">DNS 查询方式</string>
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
<string name="settings_rule_sync">Sync Rule</string>
|
<string name="settings_rule_sync">Sync Rule</string>
|
||||||
<string name="settings_rule_filename">Rule Filename</string>
|
<string name="settings_rule_filename">Rule Filename</string>
|
||||||
<string name="settings_rule_import">Import</string>
|
<string name="settings_rule_import">Import</string>
|
||||||
<string name="settings_rule_import_build_in">Build-in</string>
|
<string name="settings_rule_import_built_in">Built-in</string>
|
||||||
<string name="settings_rule_import_external">External</string>
|
<string name="settings_rule_import_external">External</string>
|
||||||
|
|
||||||
<string name="settings_server_name">Server Name</string>
|
<string name="settings_server_name">Server Name</string>
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
android:title="@string/settings_rule_import">
|
android:title="@string/settings_rule_import">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="ruleImportBuildIn"
|
android:key="ruleImportBuildIn"
|
||||||
android:title="@string/settings_rule_import_build_in"/>
|
android:title="@string/settings_rule_import_built_in"/>
|
||||||
<org.itxtech.daedalus.widget.ClickPreference
|
<org.itxtech.daedalus.widget.ClickPreference
|
||||||
android:key="ruleImportExternal"
|
android:key="ruleImportExternal"
|
||||||
android:title="@string/settings_rule_import_external"/>
|
android:title="@string/settings_rule_import_external"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user