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